admin
2020-04-21 0b57cfd62e842b309d03467b96a331c673ecad7c
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -22,6 +22,7 @@
import com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper;
import com.yeshi.fanli.dao.mybatis.order.CommonOrderMapper;
import com.yeshi.fanli.dao.mybatis.order.CommonOrderTradeIdMapMapper;
import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoOrderGoodsMapper;
import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
import com.yeshi.fanli.dto.mq.order.OrderTopicTagEnum;
import com.yeshi.fanli.dto.mq.order.body.OrderConfirmMQMsg;
@@ -48,6 +49,7 @@
import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
import com.yeshi.fanli.entity.taobao.TaoBaoOrderGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
import com.yeshi.fanli.exception.order.CommonOrderException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
@@ -135,7 +137,7 @@
   @Resource
   private InviteOrderSubsidyService inviteOrderSubsidyService;
   @Resource
   private InviteOrderSubsidyDebtService inviteOrderSubsidyDebtService;
@@ -150,6 +152,9 @@
   @Resource
   private UserLevelManager userLevelManager;
   @Resource
   private TaoBaoOrderGoodsMapper taoBaoOrderGoodsMapper;
   @Resource(name = "producer")
   private Producer orderProducer;
@@ -320,7 +325,7 @@
      // 当前用户是否VIP
      boolean vip = userInviteService.verifyVIP(uid);
      // 是否存在奖励券
      boolean hasRewardCoupon = userSystemCouponService.getValidRebateCoupon(uid);
      for (CommonOrderVO order : listOrder) {
@@ -879,7 +884,6 @@
      return commonOrderMapper.countUserOrderToApp(uid, type, startTime, endTime, day, source, state, stateOrder);
   }
   @Override
   public BigDecimal getWeiQuanMoney(List<TaoBaoWeiQuanOrder> listWQ, int sourceType, Long uid) {
      BigDecimal weiQuanMoney = new BigDecimal(0);
@@ -941,8 +945,14 @@
         if ("饿了么".equalsIgnoreCase(taoBaoOrder.getOrderType())) {
            cog.setGoodsId(taoBaoOrder.getTradeId() + "");
            cog.setGoodsType(Constant.SOURCE_TYPE_ELME);
            cog.setPicture("http://img.flqapp.com/resource/goods/elme_picture_demo.png");
            cog.setTitle(taoBaoOrder.getTitle());
            TaoBaoOrderGoods goods = taoBaoOrderGoodsMapper.selectByTradeId(taoBaoOrder.getTradeId());
            if (goods == null) {
               cog.setPicture("http://img.flqapp.com/resource/goods/elme_picture_demo.png");
               cog.setTitle(taoBaoOrder.getTitle());
            } else {
               cog.setPicture(goods.getImg());
               cog.setTitle(goods.getTitle());
            }
            newCommonOrder.setCommonOrderGoods(cog);
         } else {
            cog.setGoodsId(taoBaoOrder.getAuctionId() + "");
@@ -1799,7 +1809,6 @@
      return listVO;
   }
   @Override
   public Date getThirdCreateTime(String orderId, int sourceType) {
      List<CommonOrder> list = listBySourceTypeAndOrderId(sourceType, orderId);
@@ -1808,7 +1817,6 @@
      return list.get(0).getThirdCreateTime();
   }
   @Override
   public List<CommonOrderVO> getOrderList(AcceptData acceptData, Integer page, Long uid, Integer state, Integer type,
         Integer orderState, String orderNo, String startTime, String endTime, Integer dateType,
@@ -1842,9 +1850,7 @@
      return commonOrderMapper.countOrderList(uid, state, type, orderState, orderNo, startTime, endTime, dateType,
            listSource);
   }
   /**
    * 订单信息加工
    * 
@@ -1870,7 +1876,7 @@
               }
            }
         }
         Integer sourceType = order.getSourceType();
         if (sourceType == null) {
            continue;
@@ -1897,7 +1903,6 @@
      if (listPDD.size() > 0) {
         listRecordPDD = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_PDD, listPDD);
      }
      SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
      SimpleDateFormat formatday = new SimpleDateFormat("yyyy.MM.dd");
@@ -1989,7 +1994,6 @@
            order.setReceiveTime("收货时间:" + format.format(settleTime));
         }
         Map<String, String> orderStateMap = new HashMap<String, String>();
         // 订单状态
         Integer orderState = order.getState();
@@ -2002,21 +2006,21 @@
               orderState = buFenOrder.getState();
            }
         }
         // 显示返利说明连接> 未失效
         if (CommonOrder.STATE_SX != orderState
               && thirdCreateTime.getTime() > TimeUtil.convertDateToTemp(Constant.ORDER_SHOW_BRACE_TIME)) {
            String rebateLink = configService.get(ConfigKeyEnum.orderRebateDescLink.getKey());
            order.setRebateLink(rebateLink + "?orderNo=" + orderNo + "&sourceType=" + sourceType);
         }
         // 红包信息
         List<HongBaoOrder> hongBaoOrderList = hongBaoOrderService.listDetailByOrderIdAndSourceTypeAndUid(orderNo, sourceType, uid);
         List<HongBaoOrder> hongBaoOrderList = hongBaoOrderService.listDetailByOrderIdAndSourceTypeAndUid(orderNo,
               sourceType, uid);
         HongBaoCountVO hongBaoCountVO = hongBaoOrderService.getHongBaoCountVO(hongBaoOrderList);
         BigDecimal hongBao = hongBaoCountVO.getValidMoney();
         Integer hongBaoState = hongBaoCountVO.getCurrentState();
         /* 订单状态 转换处理 */
         String orderStateContent = "";
         if (CommonOrder.STATE_FK == orderState) {
@@ -2029,7 +2033,8 @@
            orderStateContent = "已售后";
            if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
               /* 订单维权 判断是否全部维权 */
               List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderMapper.selectListByOrderIdAndState(order.getOrderNo(), "维权成功");
               List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderMapper
                     .selectListByOrderIdAndState(order.getOrderNo(), "维权成功");
               BigDecimal weiQuanMoney = getWeiQuanMoney(listWQ, sourceType, uid);
               hongBao = MoneyBigDecimalUtil.sub(hongBao, weiQuanMoney);
            }
@@ -2048,9 +2053,9 @@
            order.setOrderOrigin("1");
            order.setHongBaoTypePic(CommonOrder.TYPE_FANLI);
            signList.add(CommonOrder.TYPE_FANLI);
            // 是否已使用奖励券、免单券情况
             if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
            if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
               couponUseFactory(order, listRecordTB);
            } else if (sourceType == Constant.SOURCE_TYPE_JD) {
               couponUseFactory(order, listRecordJD);
@@ -2072,22 +2077,24 @@
            order.setOrderOrigin("3");
            order.setHongBaoTypePic(CommonOrder.TYPE_INVITE);
            signList.add(CommonOrder.TYPE_INVITE);
            // 红包加上补贴金额
            InviteOrderSubsidy orderSubsidy = inviteOrderSubsidyService.getByOrderNoAndType(uid, orderNo, sourceType);
            InviteOrderSubsidy orderSubsidy = inviteOrderSubsidyService.getByOrderNoAndType(uid, orderNo,
                  sourceType);
            if (orderSubsidy != null && orderSubsidy.getMoney() != null) {
               BigDecimal subsidyMoney = orderSubsidy.getMoney();
               // 维权金额
               InviteOrderSubsidyDebt subsidyDebt = inviteOrderSubsidyDebtService.getBySourceId(orderSubsidy.getId());
               InviteOrderSubsidyDebt subsidyDebt = inviteOrderSubsidyDebtService
                     .getBySourceId(orderSubsidy.getId());
               if (subsidyDebt != null && subsidyDebt.getOriginMoney() != null) {
                  subsidyMoney = subsidyMoney.subtract(subsidyDebt.getOriginMoney());
               }
               //  最终补贴
               }
               // 最终补贴
               if (subsidyMoney.compareTo(new BigDecimal(0)) > 0) {
                  hongBao = hongBao.add(subsidyMoney);
               }
            }
         }
         }
         order.setSignList(signList);
         String hongBaoDate = null;
@@ -2130,15 +2137,16 @@
         stateMap.put("fontColor", stateFontColor);
         order.setAccountState(stateMap);
         hongbaoInfo = hongBaoState_Str + hongbaoInfo;
         Map<String, String> hongBaoMap = new HashMap<String, String>();
         hongBaoMap.put("content", hongbaoInfo + " ¥" + hongBao.setScale(2, BigDecimal.ROUND_DOWN).toString());
         hongBaoMap.put("fontColor", hongbaoInfoFontColor);
         order.setHongBaoInfo(hongBaoMap);
         // 分享、邀请 隐藏订单号
         if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType || HongBaoV2.TYPE_ERJI == hongBaoType
               || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
         if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
               || HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType
               || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
            order.setOrderNo(UserUtil.filterOrderId(order.getOrderNo()));
         }
      }