yujian
2019-08-19 f4fd61271ae71f12c37fe1526c2cc3b63a1198c6
fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java
@@ -220,12 +220,12 @@
         perface = new BigDecimal(1);
      } else {
         // 计算推广红包
         String warningRate = configTaoLiJinService.getValueByKey("warning_value");
         String warningRate = configTaoLiJinService.getValueByKey("warning_value",new Date());
         perface = TaoLiJinUtil.getSpreadMoney(warningRate, goods);
      }
      UserTaoLiJinRecord record = createUserTaoLiJin(2, uid, goods.getAuctionId(), perface, totalNum, name,
            sendStartTime, sendEndTime, null, useEndTime, TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT);
            sendStartTime, sendEndTime, null, useEndTime, TaoBaoConstant.TAOBAO_TLJ_RELATION_PID_DEFAULT);
      String sendUrl = record.getSendUrl() + "&relationId=" + relationId;
      record.setSendUrl(sendUrl);
      UserTaoLiJinRecord updateRecoed=new UserTaoLiJinRecord();
@@ -533,16 +533,27 @@
      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 {
         String endDay = DateUtil.plusDay(Constant.GIVE_DAYS - 1, nowDate);
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
         Date endTime = format.parse(endDay);
         // 赠送记录
         UserTaoLiJinGiveRecord giveRecord = new UserTaoLiJinGiveRecord();
         giveRecord.setAmount(amount);
         giveRecord.setGiveUid(uid);
         giveRecord.setState(UserTaoLiJinGiveRecord.STATE_INIT);
         giveRecord.setGiveTime(nowDate);
         giveRecord.setEndTime(endTime);
         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++) {
@@ -551,12 +562,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(giveRecord.getId()+""); // 记录id
            tokenRecord.setIdentify(giveId + ""); // 记录id
            tokenRecord.setType(TokenTypeEnum.taoLiJin);
            tokenRecord.setStartTime(nowDate);
            tokenRecord.setEndTime(DateUtil.plusDayDate(3, nowDate));
            tokenRecord.setEndTime(endTime);
            tokenRecord.setToken(token);
            tokenRecord.setState(0);
            tokenRecordService.insertSelective(tokenRecord);