admin
2019-12-06 cd637932a970e7935b17d41568fe89c92775bccc
fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java
@@ -16,6 +16,7 @@
import com.yeshi.fanli.dto.msg.MsgInviteContentDTO;
import com.yeshi.fanli.dto.msg.MsgOtherGiveContentDTO;
import com.yeshi.fanli.dto.msg.MsgRedPackGiveContentDTO;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail.MsgTypeMoneyTypeEnum;
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinGiveRecord;
import com.yeshi.fanli.entity.bus.user.TokenRecord;
@@ -48,6 +49,7 @@
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TokenUtil;
import com.yeshi.fanli.util.VersionUtil;
import com.yeshi.fanli.vo.msg.TokenVO;
@Service
@@ -117,7 +119,7 @@
   }
   @Override
   public TokenVO discernToken(String token, Long uid) throws TokenRecordException {
   public TokenVO discernToken(String token, Long uid, AcceptData acceptData) throws TokenRecordException {
      // 解析口令
      String parseToken = TokenUtil.parseToken(token);
      if (StringUtil.isNullOrEmpty(parseToken)) 
@@ -218,6 +220,10 @@
            throw new TokenRecordException(1, "口令已失效");
         }
      } else if (tokenType == TokenTypeEnum.redPack) {
         if(!VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion()))
            throw new TokenRecordException(1, "请升级到最新版");
         type = 13;
         RedPackGiveRecord giveRecord = redPackGiveRecordService.selectByPrimaryKey(Long.parseLong(identify));
         if (giveRecord == null)
@@ -288,7 +294,7 @@
   
   @Override
   public String receiveToken(String token, Long uid) throws TokenRecordException {
   public String receiveToken(String token, Long uid, AcceptData acceptData) throws TokenRecordException {
      if (uid == null || uid <= 0)
         throw new TokenRecordException(1, "用户未登录");
@@ -504,6 +510,9 @@
            }
         });
      } else if (tokenType == TokenTypeEnum.redPack) {
         if(!VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion()))
            throw new TokenRecordException(1, "请升级到最新版");
         try {
            msg = "领取红包成功,请到[我的-红包]中查看";
            // 领取红包、更新记录
@@ -617,9 +626,35 @@
         return;
      Date date = new Date();
      for (TokenRecord tokenRecord: list) {
         Integer state = tokenRecord.getState();
         if (state != null && state == 0)
            continue;
         tokenRecord.setState(1);
         tokenRecord.setUpdateTime(date);
         tokenRecordMapper.updateByPrimaryKeySelective(tokenRecord);
      }
   }
   @Override
   public void invalidByRedPack(Long id) {
      if (id == null)
         return;
      List<String> list = new ArrayList<String>();
      list.add(TokenTypeEnum.redPack.name());
      tokenRecordMapper.invalidByTypeAndIdentify(list, id.toString());
   }
   @Override
   public void invalidByCoupon(Long id) {
      if (id == null)
         return;
      List<String> list = new ArrayList<String>();
      list.add(TokenTypeEnum.freeCoupon.name());
      list.add(TokenTypeEnum.rebatePercentCoupon.name());
      tokenRecordMapper.invalidByTypeAndIdentify(list, id.toString());
   }
}