admin
2020-04-15 d4588f4e43336b26b356b869c29d0c76390167d5
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java
@@ -214,11 +214,14 @@
            String pid = String.format("mm_%s_%s_%s", configList.get(0).getAccountId(),
                  list.get(0).getSourceMediaId(), list.get(0).getAdPositionId());
            if ("饿了么".equalsIgnoreCase(list.get(0).getOrderType())) {
               // 处理饿了么订单
               elmeOrderMap.put(orderId, list);
            }
            else {
               // 饿了么订单开始归入到淘宝订单
               if (TimeUtil.convertToTimeTemp(list.get(0).getCreateTime(),
                     "yyyy-MM-dd HH:mm:ss") >= Constant.NEW_ORDER_FANLI_RULE_TIME) {
                  fanliOrderMap.put(orderId, list);
               } else {
                  elmeOrderMap.put(orderId, list);
               }
            } else {
               if (!StringUtil.isNullOrEmpty(list.get(0).getSpecialId())
                     || pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID)) {// 设置渠道ID当做会员运营ID的位置ID
                  fanliOrderMap.put(orderId, list);
@@ -403,7 +406,8 @@
               || hb.getPreGetTime().getTime() > System.currentTimeMillis())
            continue;
         try {
            CMQManager.getInstance().addFanLiMsgNew(hb);
            if (Constant.ENABLE_MQ)
               CMQManager.getInstance().addFanLiMsgNew(hb);
         } catch (Exception e) {
            try {
               LogHelper.errorDetailInfo(e);
@@ -494,6 +498,7 @@
                           hongBaoOrder.getCommonOrder().getSourceType(), key);
                     return TransactionStatus.CommitTransaction;
                  } catch (Exception e) {
                     e.printStackTrace();
                     return TransactionStatus.RollbackTransaction;
                  }
               }
@@ -516,7 +521,8 @@
         for (TaoBaoWeiQuanOrder order : orderList) {
            try {
               if (order.getState().contains("维权成功")) {
                  CMQManager.getInstance().addWeiQuanOrderMsg(order);
                  if (Constant.ENABLE_MQ)
                     CMQManager.getInstance().addWeiQuanOrderMsg(order);
               }
            } catch (Exception e) {
               LogHelper.error("维权订单加入到队列出错:" + order != null ? new Gson().toJson(order) : null);
@@ -547,7 +553,7 @@
               if (drawBack == null) {// 还未扣款
                  OrderLogHelper.taoBaoWeiQuan("已到账未扣款处理:子订单号:" + order.getOrderItemId());
                  try {
                     taoBaoWeiQuanDrawBackService.doWeiQuanFanli(order.getOrderId());
                     taoBaoWeiQuanDrawBackService.doWeiQuanFanli(order.getOrderId(), true);
                     taoBaoWeiQuanDrawBackService.doWeiQuanShare(order.getOrderId());
                     taoBaoWeiQuanDrawBackService.doWeiQuanInvite(order.getOrderId());
                  } catch (TaoBaoWeiQuanException e) {
@@ -596,7 +602,8 @@
      while (its.hasNext()) {
         Long uid = its.next();
         try {
            CMQManager.getInstance().addFanLiTiChengMsg(uid);
            if (Constant.ENABLE_MQ)
               CMQManager.getInstance().addFanLiTiChengMsg(uid);
         } catch (Exception e) {
            e.printStackTrace();
            LogHelper.error(e);
@@ -608,20 +615,21 @@
   @Transactional(rollbackFor = Exception.class)
   public void fanliInvaiteAndShare(Long uid) throws TaoBaoWeiQuanException {
      // 邀请赚到账
      Date now = new Date();
      try {
         orderMoneySettleService.inviteSettleTB(uid);
         orderMoneySettleService.inviteSettleTB(uid, now);
      } catch (OrderMoneySettleException e) {
         e.printStackTrace();
      }
      try {
         orderMoneySettleService.inviteSettleJD(uid);
         orderMoneySettleService.inviteSettleJD(uid, now);
      } catch (OrderMoneySettleException e) {
         e.printStackTrace();
      }
      //
      try {
         orderMoneySettleService.inviteSettlePDD(uid);
         orderMoneySettleService.inviteSettlePDD(uid, now);
      } catch (OrderMoneySettleException e) {
         e.printStackTrace();
      }
@@ -641,6 +649,29 @@
      //
      try {
         orderMoneySettleService.shareSettlePDD(uid);
      } catch (OrderMoneySettleException e) {
         e.printStackTrace();
      }
   }
   @Override
   @Transactional(rollbackFor = Exception.class)
   public void fanliPreInvaite(Long uid, Date maxPreGetTime) {
      // 邀请赚到账
      try {
         orderMoneySettleService.inviteSettleTB(uid, maxPreGetTime);
      } catch (OrderMoneySettleException e) {
         e.printStackTrace();
      }
      try {
         orderMoneySettleService.inviteSettleJD(uid, maxPreGetTime);
      } catch (OrderMoneySettleException e) {
         e.printStackTrace();
      }
      try {
         orderMoneySettleService.inviteSettlePDD(uid, maxPreGetTime);
      } catch (OrderMoneySettleException e) {
         e.printStackTrace();
      }
@@ -667,9 +698,16 @@
         if (oldOrder == null) {
            Long targetUid = null;
            if (pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID)
                  && !StringUtil.isNullOrEmpty(orderList.get(0).getRelationId())) {
                  && !StringUtil.isNullOrEmpty(orderList.get(0).getRelationId())) {// 处理非返利商品库的商品
               targetUid = taoBaoBuyRelationMapService.selectUidByRelationId(orderList.get(0).getRelationId());
            } else if (pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_ELEME_PID)
                  && !StringUtil.isNullOrEmpty(orderList.get(0).getRelationId())) {// 处理饿了么的订单
               UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService
                     .getByRelationId(orderList.get(0).getRelationId());
               if (extraInfo != null) {
                  targetUid = extraInfo.getUser().getId();
               }
            } else if (!StringUtil.isNullOrEmpty(orderList.get(0).getSpecialId())) {
               UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService
                     .getBySpecialId(orderList.get(0).getSpecialId());
@@ -738,7 +776,8 @@
               order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
               order.setUserInfo(new UserInfo(uid));
               try {
                  PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
                  if (Constant.ENABLE_MQ)
                     PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
               } catch (Exception e) {
               }
            }
@@ -788,7 +827,8 @@
               order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
               order.setUserInfo(new UserInfo(uid));
               try {
                  PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
                  if (Constant.ENABLE_MQ)
                     PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
               } catch (Exception e) {
               }
            }
@@ -910,7 +950,8 @@
            order.setOrderType(Constant.SOURCE_TYPE_JD);
            order.setUserInfo(new UserInfo(uid));
            try {
               PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
               if (Constant.ENABLE_MQ)
                  PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
            } catch (Exception e) {
            }
         }
@@ -941,7 +982,8 @@
            order.setOrderType(Constant.SOURCE_TYPE_JD);
            order.setUserInfo(new UserInfo(uid));
            try {
               PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
               if (Constant.ENABLE_MQ)
                  PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
            } catch (Exception e) {
            }
         }
@@ -1050,7 +1092,8 @@
            order.setOrderType(Constant.SOURCE_TYPE_PDD);
            order.setUserInfo(new UserInfo(uid));
            try {
               PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
               if (Constant.ENABLE_MQ)
                  PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
            } catch (Exception e) {
            }
         }
@@ -1083,7 +1126,8 @@
            order.setOrderType(Constant.SOURCE_TYPE_PDD);
            order.setUserInfo(new UserInfo(uid));
            try {
               PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
               if (Constant.ENABLE_MQ)
                  PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
            } catch (Exception e) {
            }
         }
@@ -1181,7 +1225,9 @@
            update.setUpdateTime(new Date());
            hongBaoV2Service.updateByPrimaryKeySelective(update);
         }
      userSystemCouponService.systemGiveRewardCoupon(uid, 1, orderId, sourceType, "因商家违约未能结算返利或商家已经关店");
      // TODO 商家关店跑路需要赠送金币
      // userSystemCouponService.systemGiveRewardCoupon(uid, 1, orderId,
      // sourceType, "因商家违约未能结算返利或商家已经关店");
   }
   @Transactional
@@ -1236,7 +1282,7 @@
   public List<HongBaoV2> getCanBalanceElmeFanliHongBao() {
      List<Integer> list = new ArrayList<>();
      list.add(HongBaoV2.TYPE_ELME);
      return hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(list, null, null, 0, 1000);
      return hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(list, null, null, new Date(), 0, 1000);
   }
   @Override
@@ -1273,9 +1319,6 @@
         }
         userMoneyService.addUserMoney(hongBao.getUserInfo().getId(), hongBao.getMoney(), detail);
         BigDecimal balance = userInfoMapper.selectByPrimaryKey(hongBao.getUserInfo().getId()).getMyHongBao();
         // 添加消息
         userMoneyMsgNotificationService.elmeFanli(hongBao.getUserInfo().getId(), order.getOrderId(),
               hongBao.getMoney(), balance);
      }
      // 返利到账
   }