yujian
2019-11-06 54e6398cabe1b32b1dbc9857c6a99d8f15b549f7
fanli/src/main/java/com/yeshi/fanli/service/impl/user/integral/IntegralTaskRecordServiceImpl.java
@@ -1,5 +1,6 @@
package com.yeshi.fanli.service.impl.user.integral;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -236,16 +237,10 @@
            totalGoldCoin += record.getGoldCoin();
      }
      Integer goldCoin = userInfoExtra.getGoldCoin();
      if (goldCoin == null)
         goldCoin = 0;
      goldCoin = goldCoin + totalGoldCoin;
      // 更新金币
      userInfoExtraService.updateGoldCoin(userInfoExtra.getId(), goldCoin);
      userInfoExtraService.updateGoldCoin(userInfoExtra.getId(), totalGoldCoin);
      return goldCoin;
      return totalGoldCoin+(userInfoExtra.getGoldCoin()==null?0:userInfoExtra.getGoldCoin());
   }
   @Transactional
@@ -312,7 +307,7 @@
         FrequencyEnum frequency = integralTask.getFrequency();
         if (frequency == FrequencyEnum.everyday) {
            int num = integralTaskRecordMapper.countByTaskIdTodayNum(uid, taskId,
                  TimeUtil.getWholeTime(record.getCreateTime().getTime()));
                  TimeUtil.getWholeTime(record.getCreateTime().getTime()), record.getId());
            if (num <= 0)
               num = 1;
            String title = taskClass.getName() + "-" + integralTask.getName() + "-第" + num + "次";
@@ -381,6 +376,14 @@
      return integralTaskRecordMapper.listByUidAndTaskId(uid, taskId, (page - 1) * count, count);
   }
   @Override
   public long getTotalGoldCoinByUid(Long uid) {
      return integralTaskRecordMapper.getTotalGoldCoinByUid(uid);
   }
   @Async()
   @Override
   public void firstRebateOrderRewardBoss(Long uid, Long originUid, String beizu) {
@@ -491,4 +494,56 @@
      }
      userOtherMsgNotificationService.firstOrderRewardMsg(uid, null, msgOther);
   }
   /**
    * 推广红包折算金币
    * @param uid
    * @param addGoldCoin
    * @param tlj
    */
   @Override
   public void taoLiJinExchange(Long uid, Integer addGoldCoin, BigDecimal tlj) {
      String uniqueKey = "taoLiJinExchange-" + uid.toString();
      IntegralDetail detailRecord = integralDetailService.getDetailByUniqueKey(uniqueKey);
      if (detailRecord != null)
         return;
      UserInfoExtra userInfoExtra = userInfoExtraService.getByUidForUpdate(uid);
      if (userInfoExtra == null)
         return;
      Integer goldCoin = userInfoExtra.getGoldCoin();
      if (goldCoin == null)
         goldCoin = 0;
      goldCoin = goldCoin + addGoldCoin;
      try {
         UserInfoExtra extra = new UserInfoExtra();
         extra.setId(userInfoExtra.getId());
         extra.setGoldCoin(goldCoin);
         userInfoExtraService.saveUserInfoExtra(extra);
      } catch (UserInfoExtraException e) {
         LogHelper.errorDetailInfo(e);
         return;
      }
      // 金币详情
      IntegralDetail detail = new IntegralDetail();
      detail.setTitle("推广红包下线-系统折算成金币");
      detail.setUid(uid);
      detail.setMoney(addGoldCoin);
      detail.setUniqueKey(uniqueKey);
      detail.setCreateTime(new Date());
      integralDetailService.insertSelective(detail);
      // 消息
      MsgOtherRewardIntegralDTO msgOther = new MsgOtherRewardIntegralDTO();
      msgOther.setTitle("推广红包");
      msgOther.setTotal("推广红包¥" + tlj.setScale(2));
      msgOther.setNum(goldCoin + "枚");
      msgOther.setSource("已进入到可用金币中");
      msgOther.setExplain("原推广红包功能下线,剩余推广红包按照10:1折算为金币 ");
      userOtherMsgNotificationService.taoLiJinExchangeMsg(uid, "本折算有且仅有一次", msgOther);
   }
}