yujian
2019-12-18 89cc8f054c27f70fcfe16f14554a8a12e0c19e23
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -877,35 +877,35 @@
         throw new UserSystemCouponException(1, "亲,很遗憾,该订单已不能使用返利奖励券~");
      
      CommonOrderVO orderVO = listVo.get(0);
      // 版本区分:2.1
      if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) {
      // 2.1新版
      Date thirdCreateTime = orderVO.getThirdCreateTime();
      Date accountTime = orderVO.getAccountTime();
      if (thirdCreateTime == null || accountTime == null)
         throw new UserSystemCouponException(1, "该订单不能使用奖励券");
      long downOrderTime = thirdCreateTime.getTime();
      long limitDate = TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME);
      if (downOrderTime > limitDate) {
         boolean valid = false;
         Date thirdCreateTime = orderVO.getThirdCreateTime();
         Date accountTime = orderVO.getAccountTime();
         if (thirdCreateTime != null && accountTime != null) {
            long downOrderTime = thirdCreateTime.getTime();
            long limitDate = TimeUtil.parse(Constant.COUPON_REWARD_TIME).getTime();
            if (downOrderTime > limitDate) {
               Date endDay = DateUtil.plusDayDate(Constant.COUPON_REWARD_LIMIT_DAY, accountTime);
               long currentTime = java.lang.System.currentTimeMillis();
               if (endDay.getTime() > currentTime) {
                  DateInfo dateInfo = DateUtil.dateDiff3(currentTime, endDay.getTime());
                  if (dateInfo != null) {
                     if (dateInfo.getDay() > 0)
                        valid = true;
         Date endDay = DateUtil.plusDayDate(Constant.COUPON_REWARD_LIMIT_DAY, accountTime);
         long currentTime = java.lang.System.currentTimeMillis();
         if (endDay.getTime() > currentTime) {
            DateInfo dateInfo = DateUtil.dateDiff3(currentTime, endDay.getTime());
            if (dateInfo != null) {
               if (dateInfo.getDay() > 0)
                  valid = true;
                     if (!valid && dateInfo.getHour() > 0)
                        valid = true;
               if (!valid && dateInfo.getHour() > 0)
                  valid = true;
                     if (!valid && dateInfo.getMinute() > 0)
                        valid = true;
               if (!valid && dateInfo.getMinute() > 0)
                  valid = true;
                     if (!valid && dateInfo.getSecond() > 0)
                        valid = true;
                  }
               }
               if (!valid && dateInfo.getSecond() > 0)
                  valid = true;
            }
         }
         }
         
         if (!valid)
            throw new UserSystemCouponException(1, "该订单不能使用奖励券");
@@ -2075,12 +2075,13 @@
      }
      Date nowDate = new Date();
      Date endTime = DateUtil.plusDayDate(Constant.GIVE_DAYS, nowDate);
      // 插入赠送记录
      UserSystemCouponGiveRecord giveRecord = new UserSystemCouponGiveRecord();
      giveRecord.setCouponId(id);
      giveRecord.setGiveUid(uid);
      giveRecord.setGiveTime(nowDate);
      giveRecord.setEndTime(DateUtil.plusDayDate(Constant.GIVE_DAYS, nowDate));
      giveRecord.setEndTime(endTime);
      userSystemCouponGiveRecordService.insertSelective(giveRecord);
      // 创建记录
@@ -2089,7 +2090,7 @@
      tokenRecord.setIdentify(giveRecord.getId() + "");
      tokenRecord.setType(tokenTypeEnum);
      tokenRecord.setStartTime(nowDate);
      tokenRecord.setEndTime(DateUtil.plusDayDate(Constant.TOKEN_DAYS, nowDate));
      tokenRecord.setEndTime(endTime);
      tokenRecord.setState(0);
      tokenRecordService.insertSelective(tokenRecord);
@@ -2125,6 +2126,8 @@
      msg.setUserSystemCouponId(id);
      msg.setCouponType(type.name());
      Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.systemCouponDrawback, msg);
      // 延迟一分钟
      message.setStartDeliverTime(endTime.getTime() + 1000 * 60);
      try {
         producer.send(message);
      } catch (Exception e) {
@@ -2317,7 +2320,7 @@
   }
   @Override
   @RequestSerializableByKeyService(key = "#id")
   @RequestSerializableByKeyService(key = "#couponId")
   @Transactional(rollbackFor = Exception.class)
   public void sendBackByGiveId(Long couponId) {
      if (couponId == null)