admin
2020-04-09 aa774af6df16ef11e1e34ac5aeed9aae0cb3e8e2
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -31,6 +31,7 @@
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.bus.user.UserSystemCouponRecord;
import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
import com.yeshi.fanli.entity.goods.CommonGoods;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.jd.JDOrder;
@@ -65,6 +66,7 @@
import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
import com.yeshi.fanli.service.inter.user.invite.UserInviteService;
import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
import com.yeshi.fanli.service.manger.user.UserLevelManager;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.StringUtil;
@@ -136,9 +138,12 @@
   @Resource
   private UserInfoService userInfoService;
   @Resource
   private UserInviteService userInviteService;
   @Resource
   private UserLevelManager userLevelManager;
   @Resource(name = "producer")
   private Producer orderProducer;
@@ -285,7 +290,6 @@
      }
      Map<Long, Boolean> vipUserMap = userVIPInfoService.listByUids(needSelectVIPUidList);
      // 设置是否为vip订单
      for (CommonOrderVO order : listOrder) {
         if (order.getHongBaoType() == HongBaoV2.TYPE_YIJI || order.getHongBaoType() == HongBaoV2.TYPE_ERJI
@@ -345,7 +349,6 @@
                  totalSettlement = commonOrder.getTotalPayment();
               }
               commonGoodsVO.setActualPay("付款金额:¥" + totalSettlement);
               // 邀请订单信息保护
               if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
@@ -920,9 +923,18 @@
      for (TaoBaoOrder taoBaoOrder : taoBaoOrders) {
         CommonOrder newCommonOrder = CommonOrderFactory.create(taoBaoOrder);
         CommonOrderGoods cog = new CommonOrderGoods();
         cog.setGoodsId(taoBaoOrder.getAuctionId() + "");
         cog.setGoodsType(Constant.SOURCE_TYPE_TAOBAO);
         newCommonOrder.setCommonOrderGoods(cog);
         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());
            newCommonOrder.setCommonOrderGoods(cog);
         } else {
            cog.setGoodsId(taoBaoOrder.getAuctionId() + "");
            cog.setGoodsType(Constant.SOURCE_TYPE_TAOBAO);
            newCommonOrder.setCommonOrderGoods(cog);
         }
         newCommonOrder.setStateWholeOrder(wholeOrderState);
         // 订单商品插入
         List<CommonOrderGoods> commonGoodsList = commonOrderGoodsMapper.listByGoodsIdAndGoodsType(cog.getGoodsId(),
@@ -930,22 +942,25 @@
         if (commonGoodsList.size() <= 0)// 不存在就插入商品
         {
            TaoBaoGoodsBrief taoBaoGoods = null;
            try {
               taoBaoGoods = TaoKeApiUtil.getSimpleGoodsInfo(taoBaoOrder.getAuctionId());
               LogManager.getLogger(LogType.taobaoGoods).info(String.format("订单商品分类:%s#%s#%s",
                     taoBaoGoods.getAuctionId(), taoBaoGoods.getRootCategoryName(), taoBaoGoods.getLeafName()));
            } catch (TaobaoGoodsDownException e) {
               e.printStackTrace();
               LogHelper.errorDetailInfo(e, "AUCTIONID:" + taoBaoOrder.getAuctionId(), "");
            if (cog.getGoodsType() != Constant.SOURCE_TYPE_ELME) {
               try {
                  taoBaoGoods = TaoBaoUtil.getSimpleGoodsBrief(taoBaoOrder.getAuctionId());
                  // 记录商品分类
                  taoBaoGoods = TaoKeApiUtil.getSimpleGoodsInfo(taoBaoOrder.getAuctionId());
                  LogManager.getLogger(LogType.taobaoGoods)
                        .info(String.format("订单商品分类:%s#%s#%s", taoBaoGoods.getAuctionId(),
                              taoBaoGoods.getRootCategoryName(), taoBaoGoods.getLeafName()));
               } catch (TaobaoGoodsDownException e) {
                  e.printStackTrace();
                  LogHelper.errorDetailInfo(e, "AUCTIONID:" + taoBaoOrder.getAuctionId(), "");
                  try {
                     taoBaoGoods = TaoBaoUtil.getSimpleGoodsBrief(taoBaoOrder.getAuctionId());
                     // 记录商品分类
               } catch (Exception e1) {
                  CommonGoods commonGoods = commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType(
                        taoBaoOrder.getAuctionId(), Constant.SOURCE_TYPE_TAOBAO);
                  if (commonGoods != null)
                     taoBaoGoods = TaoBaoUtil.convert(commonGoods);
                  } catch (Exception e1) {
                     CommonGoods commonGoods = commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType(
                           taoBaoOrder.getAuctionId(), Constant.SOURCE_TYPE_TAOBAO);
                     if (commonGoods != null)
                        taoBaoGoods = TaoBaoUtil.convert(commonGoods);
                  }
               }
            }
            if (taoBaoGoods != null) {
@@ -958,6 +973,7 @@
         newCommonOrder.setUserInfo(new UserInfo(uid));
         commonOrderList.add(addCommonOrder(newCommonOrder));
      }
      addConfirmMQMsg(commonOrderList);
      return commonOrderList;
   }
@@ -1119,6 +1135,7 @@
         newCommonOrder.setUserInfo(new UserInfo(uid));
         commonOrderList.add(addCommonOrder(newCommonOrder));
      }
      addConfirmMQMsg(commonOrderList);
      return commonOrderList;
   }
@@ -1167,10 +1184,11 @@
      if (oldCommonOrder == null)// 新增
      {
         commonOrder.setCreateTime(new Date());
         UserLevelEnum userLevel = userLevelManager.getUserLevel(commonOrder.getUserInfo().getId(),
               commonOrder.getThirdCreateTime());
         // 查询是否为vip
         boolean isVIP = userVIPInfoService.isVIP(commonOrder.getUserInfo().getId());
         if (isVIP)
            commonOrder.setUrank(100);// VIP订单
         if (userLevel != null)
            commonOrder.setUrank(userLevel.getOrderRank());// VIP订单
         else {
            UserInfo user = userInfoService.selectAvailableByPrimaryKey(commonOrder.getUserInfo().getId());
            if (user != null)
@@ -1734,14 +1752,11 @@
      return commonOrderMapper.countSearchOrderByUid(uid, list);
   }
   @Override
   public List<CommonOrder> getMinSettleTimeAndUid() {
      return commonOrderMapper.getMinSettleTimeAndUid();
   }
   @Override
   public List<CommonOrderVO> searchOrderByUid(AcceptData acceptData, int page, int size, Long uid, List<ESOrder> list)
         throws Exception {
@@ -1896,7 +1911,7 @@
               } else if (CommonOrderGoodsVO.TYPE_TMALL.equalsIgnoreCase(shopType)) {
                  order.setOrderType(2);
               }
               Integer goodsType = commonGoodsVO.getGoodsType();
               if (goodsType != null & goodsType == Constant.SOURCE_TYPE_ELME) {
                  order.setOrderType(Constant.SOURCE_TYPE_ELME); // 饿了么订单
@@ -1905,8 +1920,7 @@
               order.getListOrderGoods().add(commonGoodsVO);
            }
         }
         // 订单类型
         if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
            Integer orderType = order.getOrderType();
@@ -1918,7 +1932,6 @@
         } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
            order.setOrderType(4);
         }
         Date thirdCreateTime = order.getThirdCreateTime();
         if (thirdCreateTime != null) {
@@ -1930,7 +1943,6 @@
         if (settleTime != null) {
            order.setReceiveTime("收货时间:" + format.format(settleTime));
         }
         /* 订单状态 转换处理 */
         String orderStateContent = "";
@@ -1952,17 +1964,17 @@
            }
         }
         // 2.1显示返利说明连接>
         // 2.1显示返利说明连接> 未失效-自购-分享
         if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) {
            if (CommonOrder.STATE_SX != orderState && thirdCreateTime.getTime() > TimeUtil.convertDateToTemp(Constant.ORDER_SHOW_BRACE_TIME)) {
            if (CommonOrder.STATE_SX != orderState
                  && thirdCreateTime.getTime() > TimeUtil.convertDateToTemp(Constant.ORDER_SHOW_BRACE_TIME)
                  && ((HongBaoV2.TYPE_ZIGOU == hongBaoType || 2 == hongBaoType)
                        || HongBaoV2.TYPE_SHARE_GOODS == hongBaoType)) {
               String rebateLink = configService.get(ConfigKeyEnum.orderRebateDescLink.getKey());
               order.setRebateLink(rebateLink + "?orderNo=" + orderNo +"&sourceType=" + sourceType);
               order.setRebateLink(rebateLink + "?orderNo=" + orderNo + "&sourceType=" + sourceType);
            }
         }
         BigDecimal hongBao = order.getHongBao();
         if (hongBao == null) {
            hongBao = new BigDecimal(0);