yujian
2019-08-20 df300df7832cc3d24f1b09297998e8bee8cfd126
fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java
@@ -533,16 +533,23 @@
      if (amount.compareTo(tlj) > 0)
         throw new UserTaoLiJinRecordException(1, "红包余额不足");
      
      Long giveId = null;
      Date nowDate = new Date();
      // 赠送记录
      UserTaoLiJinGiveRecord giveRecord = new UserTaoLiJinGiveRecord();
      giveRecord.setAmount(amount);
      giveRecord.setGiveUid(uid);
      giveRecord.setState(UserTaoLiJinGiveRecord.STATE_INIT);
      giveRecord.setGiveTime(nowDate);
      userTaoLiJinGiveRecordService.insertSelective(giveRecord);
      try {
         // 赠送记录
         UserTaoLiJinGiveRecord giveRecord = new UserTaoLiJinGiveRecord();
         giveRecord.setAmount(amount);
         giveRecord.setGiveUid(uid);
         giveRecord.setState(UserTaoLiJinGiveRecord.STATE_INIT);
         giveRecord.setGiveTime(nowDate);
         giveRecord.setEndTime(DateUtil.plusDayDate(Constant.GIVE_DAYS, new Date()));
         userTaoLiJinGiveRecordService.insertSelective(giveRecord);
         giveId = giveRecord.getId();
      } catch (Exception e) {
         LogHelper.errorDetailInfo(e);
         throw new UserTaoLiJinRecordException(1, "赠送记录创建失败");
      }
      
      String token = null;
      for (int i = 0; i < 5; i++) {
@@ -553,10 +560,10 @@
            
            TokenRecord tokenRecord = new TokenRecord();
            tokenRecord.setUid(uid);
            tokenRecord.setIdentify(giveRecord.getId()+""); // 记录id
            tokenRecord.setIdentify(giveId + ""); // 记录id
            tokenRecord.setType(TokenTypeEnum.taoLiJin);
            tokenRecord.setStartTime(nowDate);
            tokenRecord.setEndTime(DateUtil.plusDayDate(3, nowDate));
            tokenRecord.setEndTime(DateUtil.plusDayDate(Constant.TOKEN_DAYS, new Date()));
            tokenRecord.setToken(token);
            tokenRecord.setState(0);
            tokenRecordService.insertSelective(tokenRecord);
@@ -579,12 +586,13 @@
      updateExtra.setUpdateTime(new Date());
      userMoneyExtraService.updateByPrimaryKeySelective(updateExtra);
      
      String tips = "送给你[%s]元推广红包快去领取吧,复制本条消息[&%s&],打开[返利券]App领取,用推广分享爆款商品,成单率更高哦。\r\n"
             + "----------------------------\r\n"
             + "下载[返利券]App链接:%s\r\n"
             + "PS:口令将会24小时内失效,请及时领取。";
      tips = String.format(tips, amount, token, configService.get("app_down_link"));
      String tips = configTaoLiJinService.getValueByKey("give_taolijin_tips");
      String projectChineseName = Constant.systemCommonConfig.getProjectChineseName();
      while(tips.contains("{APP名称}")) {
         tips = tips.replace("{APP名称}", projectChineseName);
      }
      tips = tips.replace("{口令}", token).replace("{下载链接}", configService.get("app_down_link"))
            .replace("{面额}", amount.setScale(0).toString());
      
      executor.execute(new Runnable() {
         @Override