admin
2020-02-18 ddf5db7d31af51fcf697eac0cee7dd46ff73bcc1
fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java
@@ -60,6 +60,7 @@
import com.yeshi.fanli.exception.order.TaoBaoWeiQuanException;
import com.yeshi.fanli.exception.user.UserAccountException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.log.OrderLogHelper;
import com.yeshi.fanli.service.inter.elme.ElmeHongBaoOrderMapService;
import com.yeshi.fanli.service.inter.elme.ElmeOrderProcessService;
import com.yeshi.fanli.service.inter.elme.ElmeOrderService;
@@ -79,7 +80,7 @@
import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
import com.yeshi.fanli.service.manger.HongBaoV2AddManager;
import com.yeshi.fanli.service.manger.order.HongBaoV2AddManager;
import com.yeshi.fanli.util.CMQManager;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
@@ -417,7 +418,7 @@
   private HongBaoOrderMapper hongBaoOrderMapper;
   @Override
   @Transactional(rollbackFor=Exception.class)
   @Transactional(rollbackFor = Exception.class)
   public void fanli(HongBaoV2 hb1) throws TaoBaoWeiQuanException {
      // 查询最新的红包数据
      hb1 = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hb1.getId());
@@ -484,18 +485,27 @@
      String key = mainUser.getId() + "-" + UUID.randomUUID().toString();
      msg.setKey(key);
      try {
         orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
            @Override
            public TransactionStatus execute(Message arg0, Object arg1) {
               try {
                  orderMoneySettleService.ziGouSettle(hongBaoOrder.getCommonOrder().getOrderNo(),
                        hongBaoOrder.getCommonOrder().getSourceType(), key);
                  return TransactionStatus.CommitTransaction;
               } catch (Exception e) {
                  return TransactionStatus.RollbackTransaction;
         if (!Constant.IS_TEST)
            orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
               @Override
               public TransactionStatus execute(Message arg0, Object arg1) {
                  try {
                     orderMoneySettleService.ziGouSettle(hongBaoOrder.getCommonOrder().getOrderNo(),
                           hongBaoOrder.getCommonOrder().getSourceType(), key);
                     return TransactionStatus.CommitTransaction;
                  } catch (Exception e) {
                     e.printStackTrace();
                     return TransactionStatus.RollbackTransaction;
                  }
               }
            }, null);
         else {
            try {
               orderMoneySettleService.ziGouSettle(hongBaoOrder.getCommonOrder().getOrderNo(),
                     hongBaoOrder.getCommonOrder().getSourceType(), key);
            } catch (Exception e) {
            }
         }, null);
         }
      } catch (Exception e) {
         LogHelper.mqError(e.getMessage(), msg.getTopic(), msg.getTag(), new Gson().toJson(mqMsg));
      }
@@ -524,13 +534,8 @@
      if (orderList != null && orderList.size() > 0 & !StringUtil.isNullOrEmpty(orderList.get(0).getSettlementTime()))
         order.setJieSuanTime(
               new Date(TimeUtil.convertToTimeTemp(orderList.get(0).getSettlementTime(), "yyyy-MM-dd HH:mm:ss")));
      // if (order.getJieSuanTime().getTime() >=
      // TimeUtil.convertToTimeTemp("2018-08-05", "yyyy-MM-dd")) {
      // return;
      // }
      // TODO 处理维权成功但是已到账的订单
      // 处理维权成功但是已到账的订单
      if (order.getJieSuanTime().getTime() > TimeUtil.convertToTimeTemp("2019-01-01", "yyyy-MM-dd")) {// 结算时间在2月1号的开始处理已到账但是维权的
         CommonOrder commonOrder = commonOrderService.selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO,
               order.getOrderItemId());
@@ -541,15 +546,34 @@
               TaoBaoWeiQuanDrawBack drawBack = taoBaoWeiQuanDrawBackService
                     .selectByOrderItemId(order.getOrderItemId());
               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) {
                     try {
                        LogHelper.errorDetailInfo(e, null, "订单号:" + order.getOrderId());
                        LogHelper.errorDetailInfo(e, "到账后处理维权扣款出错", "订单号:" + order.getOrderId());
                     } catch (Exception e1) {
                        e1.printStackTrace();
                     }
                  }
               } else {
                  // 查询子红包是否已到账
                  List<HongBaoV2> children = hongBaoV2Service
                        .listChildrenById(hongBaoOrder.getHongBaoV2().getId());
                  for (HongBaoV2 hongBaoV2 : children) {
                     if (hongBaoV2.getState() == HongBaoV2.STATE_YILINGQU) {
                        try {
                           taoBaoWeiQuanDrawBackService.doWeiQuanInvite(order.getOrderId());
                        } catch (TaoBaoWeiQuanException e) {
                           try {
                              LogHelper.errorDetailInfo(e, "到账后处理维权扣款出错", "订单号:" + order.getOrderId());
                           } catch (Exception e1) {
                              e1.printStackTrace();
                           }
                        }
                        break;
                     }
                  }
               }
@@ -1289,12 +1313,13 @@
      } catch (UserAccountException e) {
      }
      if (resultCode == 1) {// 只发送新增消息
         OrderMQMsg mqMsg = new OrderMQMsg(orderId, sourceType, uid, OrderMQMsg.HANDLE_TYPE_ADD,
               isCommonOrderValid(coList), 0, new Date());
         Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.orderStatistic, mqMsg);
         producer.send(msg);
      }
      if (!Constant.IS_TEST)
         if (resultCode == 1) {// 只发送新增消息
            OrderMQMsg mqMsg = new OrderMQMsg(orderId, sourceType, uid, OrderMQMsg.HANDLE_TYPE_ADD,
                  isCommonOrderValid(coList), 0, new Date());
            Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.orderStatistic, mqMsg);
            producer.send(msg);
         }
   }
   /**