yujian
2019-07-18 a554e5d690e2689221fc34569280872d5926443f
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -213,17 +213,39 @@
   public void listDataFactory(AcceptData acceptData, List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods, Long uid) {
      List<String> listNo = new ArrayList<String>();
      List<String> listTB = new ArrayList<String>();
      List<String> listJD = new ArrayList<String>();
      List<String> listPDD = new ArrayList<String>();
      for (CommonOrderVO commonOrderVO : listOrder) {
         listNo.add(commonOrderVO.getOrderNo());
         Integer sourceType = commonOrderVO.getSourceType();
         if (sourceType == null) {
            continue;
         } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
            listTB.add(commonOrderVO.getOrderNo());
         } else if (sourceType == Constant.SOURCE_TYPE_JD) {
            listJD.add(commonOrderVO.getOrderNo());
         } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
            listPDD.add(commonOrderVO.getOrderNo());
         }
      }
      // 已经使用券订单
      List<UserSystemCouponRecord> couponRecordList = userSystemCouponRecordService.getRecordByOrderNoList(listNo);
      List<UserSystemCouponRecord> listRecordTB = null;
      if (listTB.size() > 0) {
         listRecordTB = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_TAOBAO, listTB);
      }
       List<UserSystemCouponRecord> listRecordJD = null;
      if (listJD.size() > 0) {
         listRecordJD = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_JD, listJD);
      }
      List<UserSystemCouponRecord> listRecordPDD = null;
      if (listPDD.size() > 0) {
         listRecordPDD = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_PDD, listPDD);
      }
      /* 组合商品信息 */
      for (CommonOrderVO commonOrder : listGoods) {
         CommonOrderGoods goods = commonOrder.getCommonOrderGoods();
         if (goods == null) {
            continue;
@@ -231,7 +253,6 @@
         String orderNo1 = commonOrder.getOrderNo();
         Integer sourceType = commonOrder.getSourceType();
         for (CommonOrderVO order : listOrder) {
            String orderNo2 = order.getOrderNo();
            Integer sourceType2 = order.getSourceType();
@@ -349,6 +370,8 @@
         } else if (CommonOrder.STATE_WQ == orderState) {
            orderStateContent = "已维权";
            Integer sourceType = order.getSourceType();
            if (sourceType != null && sourceType == Constant.SOURCE_TYPE_TAOBAO) {
            /* 订单维权 判断是否全部维权 */
            List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderMapper
                  .selectListByOrderIdAndState(order.getOrderNo(), "维权成功");
@@ -373,6 +396,7 @@
               hongBaoState = HongBaoV2.STATE_BUFENSHIXIAO; // 部分失效
            } else {
               hongBaoState = HongBaoV2.STATE_SHIXIAO; // 全部失效
               }
            }
         }
         orderStateMap.put("content", orderStateContent);
@@ -469,26 +493,55 @@
         // 非自购的订单 不显示返利、免单详情
         if (HongBaoV2.TYPE_ZIGOU != hongBaoType) {
            // 订单标识
            order.setSignList(signList);
         } else {
            Integer sourceType = order.getSourceType();
            // 奖励订单、免单 使用记录
            if (sourceType == null) {
               setSystemCouponRecord(order, hasRewardCoupon, hongBaoState, hongBaoType, null, signList);
            } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
               setSystemCouponRecord(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordTB, signList);
            } else if (sourceType == Constant.SOURCE_TYPE_JD) {
               setSystemCouponRecord(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordJD, signList);
            } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
               setSystemCouponRecord(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordPDD, signList);
            }
         }
         // 邀请隐藏订单号
          if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
               || HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType
               || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
             String orderNo = order.getOrderNo();
             orderNo = orderNo.substring(0, orderNo.length()-6);
             order.setOrderNo(orderNo + "******");
         }
      }
   }
   /**
    * 订单: 免单标识  奖励标识
    * @param order
    * @param hasRewardCoupon
    * @param hongBaoState
    * @param list
    * @param signList
    */
   public void setSystemCouponRecord(CommonOrderVO order, boolean hasRewardCoupon, Integer hongBaoState, Integer hongBaoType,
         List<UserSystemCouponRecord> list, List<String> signList) {
            // 是否免单商品
            boolean freeOrder = false;
            // 是否奖励成功
            boolean rewardSuccess = false;
            // 奖励订单、免单 使用记录
            if (couponRecordList != null && couponRecordList.size() > 0) {
               for (UserSystemCouponRecord couponRecord : couponRecordList) {
      if (list != null && list.size() > 0) {
         for (UserSystemCouponRecord couponRecord : list) {
                  // 订单号匹配
                  if (order.getOrderNo().equals(couponRecord.getOrderNo())) {
                     String systemCouponType = couponRecord.getCouponType();
                     Integer state = couponRecord.getState();
               String systemCouponType = couponRecord.getCouponType();
                     // 奖励订单: 且成功
                     if (CouponTypeEnum.rebatePercentCoupon.name().equals(systemCouponType)
                           && UserSystemCouponRecord.STATE_SUCCESS == state) {
@@ -577,8 +630,6 @@
               rewardMap.put("jump", jump);
               order.setRewardDetail(rewardMap);
            }
         }
      }
   }
@@ -908,10 +959,10 @@
   @Override
   public List<CommonOrderVO> listQuery(long start, int count, Integer keyType, String key, Integer state,
         Integer type, Integer orderState, String startTime, String endTime) throws CommonOrderException {
         Integer type, Integer orderState, String startTime, String endTime, Integer source) throws CommonOrderException {
      List<CommonOrderVO> list = commonOrderMapper.listQuery(start, count, keyType, key, state, type, orderState,
            startTime, endTime);
            startTime, endTime, source);
      if (list == null) {
         list = new ArrayList<CommonOrderVO>();
@@ -921,13 +972,36 @@
         return list;
      }
      
      List<String> listNo = new ArrayList<String>();
      List<String> listTB = new ArrayList<String>();
      List<String> listJD = new ArrayList<String>();
      List<String> listPDD = new ArrayList<String>();
      for (CommonOrderVO commonOrderVO : list) {
         listNo.add(commonOrderVO.getOrderNo());
         Integer sourceType = commonOrderVO.getSourceType();
         if (sourceType == null) {
            continue;
         } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
            listTB.add(commonOrderVO.getOrderNo());
         } else if (sourceType == Constant.SOURCE_TYPE_JD) {
            listJD.add(commonOrderVO.getOrderNo());
         } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
            listPDD.add(commonOrderVO.getOrderNo());
      }
      // 已经使用券订单
      List<UserSystemCouponRecord> couponRecordList = userSystemCouponRecordService.getRecordByOrderNoList(listNo);
      }
      List<UserSystemCouponRecord> listRecordTB = null;
      if (listTB.size() > 0) {
         listRecordTB = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_TAOBAO, listTB);
      }
       List<UserSystemCouponRecord> listRecordJD = null;
      if (listJD.size() > 0) {
         listRecordJD = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_JD, listJD);
      }
      List<UserSystemCouponRecord> listRecordPDD = null;
      if (listPDD.size() > 0) {
         listRecordPDD = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_PDD, listPDD);
      }
      SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
      for (CommonOrderVO order : list) {
@@ -1006,12 +1080,14 @@
            }
         }
         
         // 奖励订单、免单 使用记录
         if (couponRecordList != null && couponRecordList.size() > 0) {
            for (UserSystemCouponRecord couponRecord : couponRecordList) {
               // 订单号匹配
               if (order.getOrderNo().equals(couponRecord.getOrderNo())) {
         Integer sourceType = order.getSourceType();
         // 奖励订单、免单 使用记录
         if (sourceType == null) {
         } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO && listRecordTB != null && listRecordTB.size() > 0) {
            for (UserSystemCouponRecord couponRecord : listRecordTB) {
               if (order.getOrderNo().equals(couponRecord.getOrderNo())) {
                  String systemCouponType = couponRecord.getCouponType();
                  Integer couponState = couponRecord.getState();
                  if (CouponTypeEnum.freeCoupon.name().equals(systemCouponType)
@@ -1021,13 +1097,40 @@
                         order.setOtherState(1);
                     } 
                  }
                  break;
               }
            }
         } else if (sourceType == Constant.SOURCE_TYPE_JD && listRecordJD != null && listRecordJD.size() > 0) {
            for (UserSystemCouponRecord couponRecord : listRecordJD) {
               if (order.getOrderNo().equals(couponRecord.getOrderNo())) {
                  String systemCouponType = couponRecord.getCouponType();
                  Integer couponState = couponRecord.getState();
                  if (CouponTypeEnum.freeCoupon.name().equals(systemCouponType)
                        || CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)) {
                      if (UserSystemCouponRecord.STATE_SUCCESS == couponState) {
                        // 免单成功
                         order.setOtherState(1);
                     }
                  }
                  break;
               }
            }
         } else if (sourceType == Constant.SOURCE_TYPE_PDD && listRecordPDD != null && listRecordPDD.size() > 0) {
            for (UserSystemCouponRecord couponRecord : listRecordPDD) {
               if (order.getOrderNo().equals(couponRecord.getOrderNo())) {
                  String systemCouponType = couponRecord.getCouponType();
                  Integer couponState = couponRecord.getState();
                  if (CouponTypeEnum.freeCoupon.name().equals(systemCouponType)
                        || CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)) {
                      if (UserSystemCouponRecord.STATE_SUCCESS == couponState) {
                        // 免单成功
                         order.setOtherState(1);
                     }
                  }
                  break;
               }
            }
         }
      }
      return list;
@@ -1036,8 +1139,8 @@
   @Override
   public long countQuery(Integer keyType, String key, Integer state, Integer type, Integer orderState,
         String startTime, String endTime) throws CommonOrderException {
      return commonOrderMapper.countQuery(keyType, key, state, type, orderState, startTime, endTime);
         String startTime, String endTime, Integer source) throws CommonOrderException {
      return commonOrderMapper.countQuery(keyType, key, state, type, orderState, startTime, endTime, source);
   }