admin
2019-08-19 9c09cead959dbeef292628f345e5f80c30fc3d17
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -1894,12 +1894,16 @@
               long num = 10000 + (long) (Math.random() * 10000);
               token = UserUtil.getInviteCode(num);
               
               String endDay = DateUtil.plusDay(Constant.TOKEN_DAYS - 1,nowDate);
               SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
               Date endTime = format.parse(endDay);
               TokenRecord tokenRecord = new TokenRecord();
               tokenRecord.setUid(uid);
               tokenRecord.setIdentify(id+"");
               tokenRecord.setType(tokenTypeEnum);
               tokenRecord.setStartTime(nowDate);
               tokenRecord.setEndTime(DateUtil.plusDayDate(3, nowDate));
               tokenRecord.setEndTime(endTime);
               tokenRecord.setToken(token);
               tokenRecord.setState(0);
               tokenRecordService.insertSelective(tokenRecord);
@@ -1917,16 +1921,30 @@
            throw new UserSystemCouponException(1, "口令生成失败");
         
         // 插入赠送记录
         UserSystemCouponGiveRecord giveRecord = new UserSystemCouponGiveRecord();
         giveRecord.setCouponId(id);
         giveRecord.setGiveUid(uid);
         giveRecord.setGiveTime(nowDate);
         userSystemCouponGiveRecordService.insertSelective(giveRecord);
         try {
            String endDay = DateUtil.plusDay(Constant.GIVE_DAYS - 1, new Date());
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            Date endTime = format.parse(endDay);
            UserSystemCouponGiveRecord giveRecord = new UserSystemCouponGiveRecord();
            giveRecord.setCouponId(id);
            giveRecord.setGiveUid(uid);
            giveRecord.setGiveTime(nowDate);
            giveRecord.setEndTime(endTime);
            userSystemCouponGiveRecordService.insertSelective(giveRecord);
         } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
            throw new UserSystemCouponException(1, "赠送记录创建失败");
         }
      }
      
      if(StringUtil.isNullOrEmpty(token))
         throw new UserSystemCouponException(1, "口令生成失败");
      userSystemCoupon.setState(UserSystemCoupon.STATE_IN_USE);
      userSystemCoupon.setGive(true);
      userSystemCouponMapper.updateByPrimaryKeySelective(userSystemCoupon);
      String tips = "送给你一张返利奖励券快去领取吧,复制本条消息[&%s&],打开[返利券]App领取,使用后可让返利加倍。\r\n" 
            +"----------------------------\r\n" 
            + "下载[返利券]App链接:%s\r\n"
@@ -1957,8 +1975,6 @@
      couponRecord.setCreateTime(date);
      couponRecord.setUpdateTime(date);
      userSystemCouponRecordService.insertSelective(couponRecord);
      // TODO 赠送消息
   }