| | |
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
|
| | | import com.yeshi.fanli.dto.HongBao;
|
| | | import com.yeshi.fanli.dto.HongBaoDTO;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
|
| | |
| | | import com.yeshi.fanli.service.inter.order.ShareGoodsActivityOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserNotificationService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
|
| | | @Service
|
| | |
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | |
|
| | | @Resource
|
| | | private UserNotificationService userNotificationService;
|
| | |
|
| | | @Resource
|
| | | private UserOrderMsgNotificationService userOrderMsgNotificationService;
|
| | |
| | | BigDecimal money = notify.getMoney();
|
| | | switch (t) {
|
| | | case HongBaoV2.TYPE_ZIGOU:
|
| | | userOrderMsgNotificationService.orderFanLiStatistic(uid, orderId, orderType,commonOrder.getPayment(),
|
| | | money, goodsCount, state);
|
| | | userOrderMsgNotificationService.orderFanLiStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, goodsCount, state);
|
| | | break;
|
| | | case HongBaoV2.TYPE_SHARE_GOODS:
|
| | | userNotificationService.orderShareStatisticed(uid, orderId, goodsCount, MsgOrderDetail.STATE_FK,
|
| | | null, money);
|
| | | userOrderMsgNotificationService.orderShareStatistic(uid, orderId,orderType, commonOrder.getPayment(),
|
| | | money, goodsCount, state);
|
| | |
|
| | | userOrderMsgNotificationService.orderShareStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, goodsCount, state);
|
| | | break;
|
| | | case HongBaoV2.TYPE_YIJI:
|
| | | userNotificationService.orderInviteStatisticed(uid, orderId, goodsCount,
|
| | | MsgOrderDetail.STATE_FK, null, money);
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId,orderType, commonOrder.getPayment(),
|
| | | money, goodsCount, state);
|
| | |
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, goodsCount, state);
|
| | | break;
|
| | | case HongBaoV2.TYPE_ERJI:
|
| | | userNotificationService.orderInviteStatisticed(uid, orderId, goodsCount,
|
| | | MsgOrderDetail.STATE_FK, null, money);
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId,orderType, commonOrder.getPayment(),
|
| | | money, goodsCount, state);
|
| | |
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, goodsCount, state);
|
| | | break;
|
| | |
|
| | | case HongBaoV2.TYPE_SHARE_YIJI:
|
| | | userOrderMsgNotificationService.orderShareFirstLevelStatistic(uid, orderId,orderType,
|
| | | userOrderMsgNotificationService.orderShareFirstLevelStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, goodsCount, state, notify.getBeizhu());
|
| | | break;
|
| | | }
|
| | |
| | | BigDecimal money = notify.getMoney();
|
| | | switch (t) {
|
| | | case HongBaoV2.TYPE_ZIGOU:
|
| | | userOrderMsgNotificationService.orderFanLiStateChanged(uid, orderId,orderType, commonOrder.getPayment(),
|
| | | money, state);
|
| | | userOrderMsgNotificationService.orderFanLiStateChanged(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, state);
|
| | | break;
|
| | | case HongBaoV2.TYPE_SHARE_GOODS:
|
| | | userOrderMsgNotificationService.orderShareStateChanged(uid, orderId,orderType, commonOrder.getPayment(),
|
| | | money, state);
|
| | | userOrderMsgNotificationService.orderShareStateChanged(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, state);
|
| | | break;
|
| | | case HongBaoV2.TYPE_YIJI:
|
| | | userOrderMsgNotificationService.orderInviteStateChanged(uid, orderId,orderType, commonOrder.getPayment(),
|
| | | money, state);
|
| | | userOrderMsgNotificationService.orderInviteStateChanged(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, state);
|
| | | break;
|
| | | case HongBaoV2.TYPE_ERJI:
|
| | | userOrderMsgNotificationService.orderInviteStateChanged(uid, orderId,orderType, commonOrder.getPayment(),
|
| | | money, state);
|
| | | userOrderMsgNotificationService.orderInviteStateChanged(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, state);
|
| | | break;
|
| | | case HongBaoV2.TYPE_SHARE_YIJI:
|
| | | userOrderMsgNotificationService.orderShareFirstLevelStateChanged(uid, orderId,orderType,
|
| | | userOrderMsgNotificationService.orderShareFirstLevelStateChanged(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, state);
|
| | | }
|
| | | }
|
| | |
| | | HongBaoV2 oldHongBao = hongBaoV2Mapper.selectByPrimaryKey(hongBaoOrder.getHongBaoV2().getId());
|
| | | if (oldHongBao == null)
|
| | | throw new HongBaoException(10, "红包对象不存在");
|
| | | // 已经失效或者已经领取的红包不做处理
|
| | | // 已经失效,已经领取,新老状态一致的红包不做处理
|
| | | if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO || oldHongBao.getState() == HongBaoV2.STATE_YILINGQU)
|
| | | return;
|
| | |
|
| | |
| | | hongBao.setState(HongBaoV2.STATE_KELINGQU);
|
| | | hongBao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100))));
|
| | | hongBao.setPreGetTime(new Date(commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L));
|
| | | if (commonOrder.getSourceType() == Constant.SOURCE_TYPE_PDD)// 拼多多15天过1个小时到账
|
| | | hongBao.setPreGetTime(new Date(
|
| | | commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L + 1000 * 60 * 60 * 1L));
|
| | | else
|
| | | hongBao.setPreGetTime(new Date(commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L));
|
| | | if (mianDan)
|
| | | hongBao.setMoney(commonOrder.getSettlement().compareTo(commonOrder.getPayment()) <= 0
|
| | | ? commonOrder.getSettlement() : commonOrder.getPayment());// 返利结算与付款较小的金额
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_SX) {
|
| | | hongBao.setState(HongBaoV2.STATE_SHIXIAO);
|
| | | hongBao.setMoney(new BigDecimal(0));
|
| | | }
|
| | |
|
| | | // 新老红包状态一致不处理
|
| | | if (oldHongBao.getState().intValue() == hongBao.getState())
|
| | | return;
|
| | |
|
| | | if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO) {
|
| | | if (mianDan) {
|
| | | try {
|
| | | userSystemCouponService.updateStateByDrawback(commonOrder.getOrderNo());
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(hongBao);
|
| | |
|
| | | // 加入通知
|
| | |
| | | }
|
| | | }
|
| | | } else if (type == HongBaoV2.TYPE_SHARE_GOODS) {
|
| | | BigDecimal fanliRate = hongBaoManageService.getShareRate(commonOrder.getCreateTime().getTime());
|
| | | BigDecimal fanliRate = null;
|
| | | if (commonOrder.getSourceType() == Constant.SOURCE_TYPE_TAOBAO
|
| | | && commonOrder.getSourcePosition().equalsIgnoreCase(TaoBaoConstant.TAOBAO_TLJ_RELATION_PID_DEFAULT))
|
| | | fanliRate = hongBaoManageService.getTLJShareRate(commonOrder.getCreateTime().getTime());
|
| | | else
|
| | | fanliRate = hongBaoManageService.getShareRate(commonOrder.getCreateTime().getTime());
|
| | |
|
| | | List<ShareGoodsActivityOrder> list = shareGoodsActivityOrderService
|
| | | .listByOrderIdAndUid(commonOrder.getUserInfo().getId(), commonOrder.getOrderNo());
|
| | | if (list != null && list.size() > 0) {
|
| | |
| | | // 查询是否有免单计划
|
| | | BigDecimal mianDanMoney = null;
|
| | | if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_FK) {
|
| | | List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_TAOBAO,
|
| | | List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(commonOrder.getSourceType(),
|
| | | commonOrder.getOrderNo());
|
| | | if (orderList != null && orderList.size() == 1) {// 只有1个订单才参与免单
|
| | | BigDecimal payMent = commonOrder.getPayment();
|
| | |
| | | }
|
| | | }
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_SX) {// 设置免单券失效
|
| | | commonOrder.setPayment(new BigDecimal(0));// 订单失效后的付款金额设置为0
|
| | | try {
|
| | | userSystemCouponService.updateStateByDrawback(commonOrder.getOrderNo());
|
| | | } catch (Exception e) {
|
| | |
| | | hongBao.setState(HongBaoV2.STATE_KELINGQU);
|
| | | hongBao.setMoney(
|
| | | MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100))));
|
| | | hongBao.setPreGetTime(new Date(commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L));
|
| | | if (commonOrder.getSourceType() == Constant.SOURCE_TYPE_PDD)// 拼多多15天半到账
|
| | | hongBao.setPreGetTime(new Date(
|
| | | commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L + 1000 * 60 * 60 * 12L));
|
| | | else
|
| | | hongBao.setPreGetTime(new Date(commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L));
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_SX) {
|
| | | hongBao.setState(HongBaoV2.STATE_SHIXIAO);
|
| | | hongBao.setMoney(new BigDecimal(0));
|
| | |
| | | if (commonOrder.getState() == CommonOrder.STATE_SX || commonOrder.getState() == CommonOrder.STATE_WQ)
|
| | | return;
|
| | | // 分享赚
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate(commonOrder.getCreateTime().getTime());
|
| | | BigDecimal shareRate = null;
|
| | | if (commonOrder.getSourceType() == Constant.SOURCE_TYPE_TAOBAO
|
| | | && commonOrder.getSourcePosition().equalsIgnoreCase(TaoBaoConstant.TAOBAO_TLJ_RELATION_PID_DEFAULT))// 来自于淘礼金的分享
|
| | | shareRate = hongBaoManageService.getTLJShareRate(commonOrder.getCreateTime().getTime());
|
| | | else
|
| | | shareRate = hongBaoManageService.getShareRate(commonOrder.getCreateTime().getTime());
|
| | |
|
| | | // 判断订单分享活动是否开启
|
| | | if ("1".equalsIgnoreCase(configService.get("share_goods_activity_open"))) {
|
| | |
| | | hb.setMoney(hongBao.getMoney());
|
| | |
|
| | | try {
|
| | | userShareGoodsGroupService.updateOrderRecord(hb,commonOrder.getSourceType());
|
| | | userShareGoodsGroupService.updateOrderRecord(hb, commonOrder.getSourceType());
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | | public List<Long> getUidByNear30DayShareSucceed() {
|
| | | return hongBaoV2Mapper.getUidByNear30DayShareSucceed();
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void invalidInviteHongBaoByParentUid(Long parentUid, String beiZhu) {
|
| | | List<Integer> typeList = new ArrayList<>();
|
| | | typeList.add(HongBaoV2.TYPE_YIJI);
|
| | | typeList.add(HongBaoV2.TYPE_ERJI);
|
| | | typeList.add(HongBaoV2.TYPE_SHARE_YIJI);
|
| | | typeList.add(HongBaoV2.TYPE_SHARE_ERJI);
|
| | | List<Integer> stateList = new ArrayList<>();
|
| | | stateList.add(HongBaoV2.STATE_KELINGQU);
|
| | | stateList.add(HongBaoV2.STATE_BUKELINGQU);
|
| | | long count = hongBaoV2Mapper.countByParentUidAndTypeAndState(parentUid, typeList, stateList);
|
| | | int page = (int) (count % 100 == 0 ? count / 100 : count / 100 + 1);
|
| | | for (int i = 1; i <= page; i++) {
|
| | | List<HongBaoV2> list = hongBaoV2Mapper.listByParentUidAndTypeAndState(parentUid, typeList, stateList, 0,
|
| | | 100);
|
| | | if (list != null)
|
| | | for (HongBaoV2 v2 : list) {
|
| | | HongBaoV2 update = new HongBaoV2(v2.getId());
|
| | | update.setUpdateTime(new Date());
|
| | | update.setState(HongBaoV2.STATE_SHIXIAO);
|
| | | update.setBeizhu(beiZhu);
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<HongBaoV2> listBySourceTypeAndTradeIdListAndUid(int sourceType, long uid, List<String> tradeIdList) {
|
| | | if (tradeIdList == null || tradeIdList.size() == 0)
|
| | | return null;
|
| | | return hongBaoV2Mapper.listBySourceTypeAndTradeIdListAndUid(sourceType, uid, tradeIdList);
|
| | | }
|
| | | }
|