yujian
2020-03-25 010760fd974453a70948fef465284d8c817314f5
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -38,6 +38,7 @@
import com.yeshi.fanli.entity.order.HongBaoOrder;
import com.yeshi.fanli.entity.order.InviteOrderSubsidy;
import com.yeshi.fanli.entity.pdd.PDDOrder;
import com.yeshi.fanli.entity.system.ConfigKeyEnum;
import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
@@ -70,9 +71,9 @@
import com.yeshi.fanli.util.jd.JDApiUtil;
import com.yeshi.fanli.util.jd.JDUtil;
import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.util.user.UserLevelUtil;
import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
import com.yeshi.fanli.vo.order.CommonOrderGoodsVO;
import com.yeshi.fanli.vo.order.CommonOrderVO;
@@ -210,7 +211,11 @@
      }
      // 数据加工重新组织
      orderVOFactory(acceptData, listOrder, listGoods, uid);
      if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) {
         orderVOFactoryNew(acceptData, listOrder, listGoods, uid);
      } else {
         orderVOFactory(acceptData, listOrder, listGoods, uid);
      }
      return listOrder;
   }
@@ -267,6 +272,7 @@
      }
      Map<Long, Boolean> vipUserMap = userVIPInfoService.listByUids(needSelectVIPUidList);
      // 设置是否为vip订单
      for (CommonOrderVO order : listOrder) {
         if (order.getHongBaoType() == HongBaoV2.TYPE_YIJI || order.getHongBaoType() == HongBaoV2.TYPE_ERJI
@@ -293,10 +299,10 @@
      boolean vip = userVIPInfoService.isVIP(uid);
      // 是否存在奖励券
      boolean hasRewardCoupon = userSystemCouponService.getValidRebateCoupon(uid);
      for (CommonOrderVO order : listOrder) {
         String orderNo = order.getOrderNo();
         Integer sourceType = order.getSourceType();
         Integer hongBaoType = order.getHongBaoType();
         // 商品信息组合
         for (CommonOrderVO commonOrder : listGoods) {
@@ -327,7 +333,7 @@
               }
               commonGoodsVO.setActualPay("付款金额:¥" + totalSettlement);
               Integer hongBaoType = order.getHongBaoType();
               // 邀请订单信息保护
               if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
                     || HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType
@@ -356,10 +362,8 @@
         }
         Date thirdCreateTime = order.getThirdCreateTime();
         if (thirdCreateTime != null) {
            order.setDownTime("下单时间:" + format.format(thirdCreateTime));
            order.setObtainTime(thirdCreateTime.getTime());
         }
         order.setDownTime("下单时间:" + format.format(thirdCreateTime));
         order.setObtainTime(thirdCreateTime.getTime());
         Date settleTime = order.getSettleTime();
         if (settleTime != null) {
@@ -446,7 +450,6 @@
         // 订单标识
         List<String> signList = new ArrayList<String>();
         /* 订单返利类型 转换 */
         Integer hongBaoType = order.getHongBaoType();
         if (HongBaoV2.TYPE_ZIGOU == hongBaoType || 2 == hongBaoType) {
            // 自购
            hongbaoInfo = "返利";
@@ -902,7 +905,7 @@
         wholeOrderState = CommonOrder.STATE_WHOLE_ORDER_BUFENYOUXIAO;
      for (TaoBaoOrder taoBaoOrder : taoBaoOrders) {
         CommonOrder newCommonOrder = TaoBaoOrderUtil.convert(taoBaoOrder);
         CommonOrder newCommonOrder = CommonOrderFactory.create(taoBaoOrder);
         CommonOrderGoods cog = new CommonOrderGoods();
         cog.setGoodsId(taoBaoOrder.getAuctionId() + "");
         cog.setGoodsType(Constant.SOURCE_TYPE_TAOBAO);
@@ -1240,7 +1243,7 @@
   @Override
   public List<CommonOrderVO> listQuery(long start, int count, Integer keyType, String key, Integer state,
         Integer type, Integer orderState, String startTime, String endTime, Integer source, List<Long> listShopId,
         List<Long> listGoodsId, Date minTime, BigDecimal money,BigDecimal payment) throws CommonOrderException {
         List<Long> listGoodsId, Date minTime, BigDecimal money, BigDecimal payment) throws CommonOrderException {
      List<CommonOrderVO> list = null;
@@ -1249,7 +1252,7 @@
               startTime, endTime, source, payment);
      } else {
         list = commonOrderMapper.listQuery(start, count, keyType, key, state, type, orderState, startTime, endTime,
               source, listShopId, listGoodsId, minTime, money,payment);
               source, listShopId, listGoodsId, minTime, money, payment);
      }
      if (list == null) {
@@ -1436,7 +1439,7 @@
   @Override
   public long countQuery(Integer keyType, String key, Integer state, Integer type, Integer orderState,
         String startTime, String endTime, Integer source, List<Long> listShopId, List<Long> listGoodsId,
         Date minTime, BigDecimal money,BigDecimal payment) throws CommonOrderException {
         Date minTime, BigDecimal money, BigDecimal payment) throws CommonOrderException {
      if (StringUtil.isNullOrEmpty(key) || keyType == 1) {// 搜索框无值或者按订单号搜索时都只搜索主订单
         return commonOrderMapper.countQueryWithNoChild(keyType, key, state, type, orderState, startTime, endTime,
               source, payment);
@@ -1673,7 +1676,8 @@
   }
   @Override
   public List<CommonOrderVO> searchOrderByUid(int page, int size, Long uid, List<ESOrder> list) throws Exception {
   public List<CommonOrderVO> searchOrderByUid(AcceptData acceptData, int page, int size, Long uid, List<ESOrder> list)
         throws Exception {
      List<CommonOrderVO> listVO = commonOrderMapper.searchOrderByUid((page - 1) * size, size, uid, list);
      // 订单信息为空
@@ -1690,7 +1694,7 @@
      }
      // 数据加工重新组织
      orderVOFactoryNew(listVO, listGoods, uid);
      orderVOFactoryNew(acceptData, listVO, listGoods, uid);
      return listVO;
   }
@@ -1703,8 +1707,8 @@
    * @param listGoods
    * @param uid
    */
   private void orderVOFactoryNew(List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods, Long uid)
         throws Exception {
   private void orderVOFactoryNew(AcceptData acceptData, List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods,
         Long uid) throws Exception {
      List<String> listTB = new ArrayList<String>();
      List<String> listJD = new ArrayList<String>();
      List<String> listPDD = new ArrayList<String>();
@@ -1745,23 +1749,19 @@
               || order.getHongBaoType() == HongBaoV2.TYPE_SHARE_ERJI)
            needSelectVIPUidList.add(Long.parseLong(order.getUserId()));
      }
      Map<Long, Boolean> vipUserMap = userVIPInfoService.listByUids(needSelectVIPUidList);
      // 设置是否为vip订单
      for (CommonOrderVO order : listOrder) {
         if (order.getHongBaoType() == HongBaoV2.TYPE_YIJI || order.getHongBaoType() == HongBaoV2.TYPE_ERJI
               || order.getHongBaoType() == HongBaoV2.TYPE_SHARE_ERJI
               || order.getHongBaoType() == HongBaoV2.TYPE_SHARE_ERJI) {
            if (vipUserMap.get(Long.parseLong(order.getUserId())) != null
                  && vipUserMap.get(Long.parseLong(order.getUserId())) == true)
               order.setVipOrder(true);
            else
               order.setVipOrder(false);
         } else
            order.setVipOrder(false);
         if (order.isVipOrder())
            order.setVipOrderDesc("订单来源:由超级会员的粉丝产生");
            Integer urank = order.getUrank();
            if (urank != null) {
               String levelName = UserLevelUtil.getLevelName(urank);
               if (!StringUtil.isNullOrEmpty(levelName)) {
                  order.setOrderDesc("订单来源:" + levelName);
               }
            }
         }
      }
      SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
@@ -1777,6 +1777,7 @@
      for (CommonOrderVO order : listOrder) {
         String orderNo = order.getOrderNo();
         Integer sourceType = order.getSourceType();
         Integer hongBaoType = order.getHongBaoType();
         // 商品信息组合
         for (CommonOrderVO commonOrder : listGoods) {
@@ -1807,7 +1808,6 @@
               }
               commonGoodsVO.setActualPay("付款金额:¥" + totalSettlement);
               Integer hongBaoType = order.getHongBaoType();
               // 邀请订单信息保护
               if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
                     || HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType
@@ -1830,6 +1830,11 @@
                     order.setOrderType(2);
                  }
               }
               Integer goodsType = commonGoodsVO.getGoodsType();
               if (goodsType != null & goodsType == 6) {
                  order.setOrderType(5); // 饿了么订单
               }
               order.getListOrderGoods().add(commonGoodsVO);
            }
@@ -1839,6 +1844,14 @@
         if (thirdCreateTime != null) {
            order.setDownTime("下单时间:" + format.format(thirdCreateTime));
            order.setObtainTime(thirdCreateTime.getTime());
         }
         // 2.1显示返利说明连接>
         if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) {
            if (thirdCreateTime.getTime() > TimeUtil.convertDateToTemp(Constant.ORDER_SHOW_BRACE_TIME)) {
               String rebateLink = configService.get(ConfigKeyEnum.orderRebateDescLink.getKey());
               order.setRebateLink(rebateLink + "?orderNo=" + orderNo +"&sourceType=" + sourceType);
            }
         }
         Date settleTime = order.getSettleTime();
@@ -1915,7 +1928,6 @@
         // 订单标识
         List<String> signList = new ArrayList<String>();
         /* 订单返利类型 转换 */
         Integer hongBaoType = order.getHongBaoType();
         if (HongBaoV2.TYPE_ZIGOU == hongBaoType || 2 == hongBaoType) {
            // 自购
            hongbaoInfo = "返利";
@@ -2184,4 +2196,12 @@
      }
   }
   @Override
   public Date getThirdCreateTime(String orderId, int sourceType) {
      List<CommonOrder> list = listBySourceTypeAndOrderId(sourceType, orderId);
      if (list == null || list.size() == 0)
         return null;
      return list.get(0).getThirdCreateTime();
   }
}