yujian
2019-12-18 89cc8f054c27f70fcfe16f14554a8a12e0c19e23
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -52,6 +52,7 @@
import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
@@ -121,6 +122,9 @@
   @Resource
   private UserVIPInfoService userVIPInfoService;
   @Resource
   private UserInfoService userInfoService;
   // 奖励订单图片
   public final static String PIC_REWARD = "http://img.flqapp.com/resource/order/order_state_reward.png";
@@ -200,10 +204,9 @@
      // 数据加工重新组织
      orderVOFactory(acceptData, listOrder, listGoods, uid);
      return listOrder;
   }
   /**
    * 订单信息加工
@@ -269,11 +272,11 @@
               order.setVipOrder(false);
         } else
            order.setVipOrder(false);
         if(order.isVipOrder())
         if (order.isVipOrder())
            order.setVipOrderDesc("订单来源:由超级会员的粉丝产生");
      }
      SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
      SimpleDateFormat formatday = new SimpleDateFormat("yyyy.MM.dd");
      // 2019.8.1开始返回维权信息
@@ -489,7 +492,7 @@
            }
         }
         order.setSignList(signList);
         String hongBaoDate = null;
         String hongBaoState_Str = "";
         String hongbaoInfoFontColor = "#E5005C";
@@ -549,21 +552,21 @@
         hongBaoMap.put("content", hongbaoInfo + " ¥" + hongBao.setScale(2, BigDecimal.ROUND_DOWN).toString());
         hongBaoMap.put("fontColor", hongbaoInfoFontColor);
         order.setHongBaoInfo(hongBaoMap);
         // 显示返利、免单详情
         if (HongBaoV2.TYPE_ZIGOU == hongBaoType) {
            // 奖励订单、免单 使用记录
            if (sourceType == null) {
               couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, null, uid, vip, acceptData);
            } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
               couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType,
                     listRecordTB, uid, vip, acceptData);
               couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordTB, uid, vip,
                     acceptData);
            } else if (sourceType == Constant.SOURCE_TYPE_JD) {
               couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType,
                     listRecordJD, uid, vip, acceptData);
               couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordJD, uid, vip,
                     acceptData);
            } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
               couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType,
                     listRecordPDD, uid, vip, acceptData);
               couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordPDD, uid, vip,
                     acceptData);
            }
         }
@@ -575,8 +578,7 @@
         }
      }
   }
   /**
    * 订单: 免单标识 奖励标识
    * 
@@ -586,21 +588,21 @@
    * @param list
    * @param signList
    */
   private void couponFactory(CommonOrderVO order, boolean hasRewardCoupon,   Integer hongBaoState,
         Integer hongBaoType, List<UserSystemCouponRecord> list, Long uid, boolean vip, AcceptData acceptData) throws Exception{
   private void couponFactory(CommonOrderVO order, boolean hasRewardCoupon, Integer hongBaoState, Integer hongBaoType,
         List<UserSystemCouponRecord> list, Long uid, boolean vip, AcceptData acceptData) throws Exception {
      // 是否免单商品
      boolean freeOrder = false;
      // 是否奖励成功
      boolean rewardSuccess = false;
      boolean version2_1 = VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion());
      if (list != null && list.size() > 0) {
         for (UserSystemCouponRecord couponRecord : list) {
            int goodSource = couponRecord.getGoodSource();
            if (goodSource == 0)
               goodSource = 1;
            if (order.getOrderNo().equals(couponRecord.getOrderNo()) && goodSource == order.getSourceType()) {
               Integer state = couponRecord.getState();
               String systemCouponType = couponRecord.getCouponType();
@@ -634,7 +636,7 @@
            }
         }
      }
      // 免单详情
      if (freeOrder) {
         ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO();
@@ -658,19 +660,19 @@
         rewardMap.put("jump", jump);
         order.setRewardDetail(rewardMap);
      }
      // 已使用奖励券
      if (rewardSuccess) {
         ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO();
         rewardStyleVO.setColor("#E5005C");
         rewardStyleVO.setBottomColor("#FFDCEA");
         if (version2_1) {
            rewardStyleVO.setContent("已使用奖励券 >");
         } else {
            rewardStyleVO.setContent("返利奖励 >");
         }
         Map<String, Object> rewardMap = new HashMap<String, Object>();
         rewardMap.put("text", rewardStyleVO);
         Map<String, Object> jumpLink = new HashMap<String, Object>();
@@ -678,15 +680,15 @@
         jumpLink.put("goodsType", order.getSourceType() + "");
         Map<String, Object> jump = new HashMap<String, Object>();
         jump.put("type", 1); // 1 常规跳转页面
         jump.put("type", 1); // 1 常规跳转页面
         jump.put("params", jumpLink);
         jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("rewardCouponDetail"));
         rewardMap.put("jump", jump);
         order.setRewardDetail(rewardMap);
      }
      // 是否可使用奖励券
      if (!rewardSuccess && !freeOrder && HongBaoV2.TYPE_ZIGOU == hongBaoType
      if (!rewardSuccess && !freeOrder && HongBaoV2.TYPE_ZIGOU == hongBaoType
            && HongBaoV2.STATE_YILINGQU == hongBaoState && !vip && CommonOrder.STATE_WQ != order.getState()) {
         // 下单时间
         Date thirdCreateTime = order.getThirdCreateTime();
@@ -694,11 +696,11 @@
         Date accountTime = order.getAccountTime();
         if (thirdCreateTime == null || accountTime == null)
            return;
         // 下单日期是否是符合上线日期
         long downOrderTime = thirdCreateTime.getTime();
         long limitDate = TimeUtil.parse(Constant.COUPON_REWARD_TIME).getTime();
         if (downOrderTime > limitDate)  {
         long downOrderTime = thirdCreateTime.getTime();
         long limitDate = TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME);
         if (downOrderTime > limitDate)  {
            // 2.1 开始新版
            rewardCounponLimitTime(order, accountTime);
         } else if (hasRewardCoupon) {
@@ -707,16 +709,16 @@
            rewardStyleVO.setColor("#E5005C");
            rewardStyleVO.setBottomColor("#FFDCEA");
            rewardStyleVO.setContent("返利奖励 >");
            Map<String, Object> jumpLink = new HashMap<String, Object>();
            jumpLink.put("orderNo", order.getOrderNo());
            jumpLink.put("goodsType", order.getSourceType() + "");
            Map<String, Object> jump = new HashMap<String, Object>();
            jump.put("type", 2); // 弹框
            jump.put("params", jumpLink);
            jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("rewardCouponDetail"));
            Map<String, Object> rewardMap = new HashMap<String, Object>();
            rewardMap.put("text", rewardStyleVO);
            rewardMap.put("jump", jump);
@@ -725,13 +727,13 @@
      }
   }
   private void rewardCounponLimitTime(CommonOrderVO order,Date accountTime) throws Exception {
   private void rewardCounponLimitTime(CommonOrderVO order, Date accountTime) throws Exception {
      // 倒计时验证
      Date endDay = DateUtil.plusDayDate(Constant.COUPON_REWARD_LIMIT_DAY, accountTime);
      long currentTime = java.lang.System.currentTimeMillis();
      if (endDay.getTime() <= currentTime)
         return;
      String num = null;
      String unit = null;
      boolean canUse = false;
@@ -762,16 +764,16 @@
      }
      // 已经超时
      if (!canUse)
      if (!canUse)
         return;
      Map<String, Object> rewardMap = new HashMap<String, Object>();
      ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO();
      rewardStyleVO.setColor("#E5005C");
      rewardStyleVO.setBottomColor("#FFDCEA");
      rewardStyleVO.setContent("使用奖励券");
      rewardMap.put("text", rewardStyleVO);
      ClientTextStyleVO txt1 = new ClientTextStyleVO();
      txt1.setContent("剩");
      txt1.setColor("#666666");
@@ -804,13 +806,12 @@
      rewardMap.put("jump", jump);
      order.setRewardDetail(rewardMap);
   }
   @Override
   public Map<String, BigDecimal> countHistoryOrder(Long uid, Integer day, Integer source) {
      return commonOrderMapper.countHistoryOrder(uid, day, source);
   }
   @Override
   public OrderCountVO getOrderCount(Long uid, Integer day, Integer source) {
      return commonOrderMapper.getOrderCount(uid, day, source);
@@ -1093,6 +1094,16 @@
      if (oldCommonOrder == null)// 新增
      {
         commonOrder.setCreateTime(new Date());
         // 查询是否为vip
         boolean isVIP = userVIPInfoService.isVIP(commonOrder.getUserInfo().getId());
         if (isVIP)
            commonOrder.setUrank(100);// VIP订单
         else {
            UserInfo user = userInfoService.selectAvailableByPrimaryKey(commonOrder.getUserInfo().getId());
            if (user != null)
               commonOrder.setUrank(user.getRank());
         }
         commonOrderMapper.insertSelective(commonOrder);
         // 插入映射,保证交易ID的完整性
         commonOrderTradeIdMapMapper.insertSelective(new CommonOrderTradeIdMap(commonOrder.getId(),
@@ -1527,8 +1538,8 @@
      JSONObject map = new JSONObject();
      // 订单标识
      List<String> signList = new ArrayList<String>();
      //signList.add(CommonOrder.TYPE_FANLI);
      //signList.add(PIC_REWARD); // 加入奖励成功图片
      // signList.add(CommonOrder.TYPE_FANLI);
      // signList.add(PIC_REWARD); // 加入奖励成功图片
      map.put("signList", signList);
      ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO();