admin
2020-01-17 81a2c8e297787cc7dc405d6db4972cb917cd80b5
fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java
@@ -99,14 +99,12 @@
   @Resource
   private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
   
   @Override
   public void insertSelective(TokenRecord record) {
      record.setCreateTime(new Date());
      record.setUpdateTime(new Date());
      tokenRecordMapper.insertSelective(record);
   }
   
   @Override
   public void updateByPrimaryKeySelective(TokenRecord record) {
@@ -124,7 +122,7 @@
   }
   @Override
   public TokenVO discernToken(String token, Long uid, AcceptData acceptData) throws TokenRecordException {
   public TokenVO discernToken(String token, Long uid, String platform, String version) throws TokenRecordException {
      // 解析口令
      String parseToken = TokenUtil.parseToken(token);
      if (StringUtil.isNullOrEmpty(parseToken)) 
@@ -141,10 +139,9 @@
      Date now = new Date();
      Date endTimeToken = rokenRecord.getEndTime();
      Integer stateTtoken = rokenRecord.getState();
      if (endTimeToken != null && endTimeToken.getTime() < now.getTime()
            || (stateTtoken != null && stateTtoken == 1) || StringUtil.isNullOrEmpty(rokenRecord.getIdentify()))
      if (endTimeToken != null && endTimeToken.getTime() < now.getTime() || (stateTtoken != null && stateTtoken == 1)
            || StringUtil.isNullOrEmpty(rokenRecord.getIdentify()))
         throw new TokenRecordException(1, "口令已失效");
      
      Integer num = 0;
      Integer type = 0;
@@ -167,7 +164,8 @@
         if (userCoupon == null || userCoupon.getGive() == null || !userCoupon.getGive())
            throw new TokenRecordException(1, "券不存在或非赠送状态");
         
         if (userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE || (endTime != null && endTime.getTime() < now.getTime())) {
         if (userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE
               || (endTime != null && endTime.getTime() < now.getTime())) {
            tips.add("哎呀,这张免单券已失效了!");
         } else if (userCoupon.getState() == UserSystemCoupon.STATE_END_USE) {
            tips.add("哎呀,这张免单券已被领取了!");
@@ -202,8 +200,8 @@
         if (userCoupon == null || userCoupon.getGive() == null || !userCoupon.getGive())
            throw new TokenRecordException(1, "券不存在或非赠送状态");
         
         if (userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE|| (endTime != null && endTime.getTime() < now.getTime())) {
         if (userCoupon.getState() == UserSystemCoupon.STATE_OVERDUE
               || (endTime != null && endTime.getTime() < now.getTime())) {
            tips.add("哎呀,这张返利奖励券已失效了!");
         } else if (userCoupon.getState() == UserSystemCoupon.STATE_END_USE) {
            tips.add("哎呀,这张返利奖励券已被领取了!");
@@ -225,9 +223,8 @@
            throw new TokenRecordException(1, "口令已失效");
         }
      } else if (tokenType == TokenTypeEnum.redPack) {
         if(!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
         if (!VersionUtil.greaterThan_2_0_5(platform, version))
            throw new TokenRecordException(1, "请升级到最新版");
         
         type = 13;
         RedPackGiveRecord giveRecord = redPackGiveRecordService.selectByPrimaryKey(Long.parseLong(identify));
@@ -295,8 +292,6 @@
      tokenVO.setType(type);
      return tokenVO;
   }
   @Override
   public String receiveToken(String token, Long uid, AcceptData acceptData) throws TokenRecordException {
@@ -446,8 +441,9 @@
         
         UserSystemCoupon userSystemCoupon= null;
         try {
            userSystemCoupon = userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(),
                  UserSystemCoupon.SOURCE_GIVE, systemCoupon.getPercent(),true);
            userSystemCoupon = userSystemCouponService.insertUserCoupon(uid,
                  CouponTypeEnum.rebatePercentCoupon.name(), UserSystemCoupon.SOURCE_GIVE,
                  systemCoupon.getPercent(), true);
         } catch (Exception e) {
            LogHelper.errorDetailInfo(e);
            throw new TokenRecordException(1, "领取失败");
@@ -487,6 +483,7 @@
         msg = "领取成功[返利奖励券]成功,请到[我的-福利中心]中查看";
         // 消息 + 队员
         executor.execute(new Runnable() {
            @Override
            public void run() {
               SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
@@ -521,7 +518,8 @@
         try {
            msg = "领取红包成功,请到[我的-红包]中查看";
            // 领取红包、更新记录
            RedPackGiveRecord giveRecord = redPackGiveRecordService.receiveFriendsGive(uid, Long.parseLong(identify));
            RedPackGiveRecord giveRecord = redPackGiveRecordService.receiveFriendsGive(uid,
                  Long.parseLong(identify));
            // 消息 + 队员
            executor.execute(new Runnable() {
               @Override
@@ -548,7 +546,8 @@
                  dto.setUserInfo("昵称:" + giveUserName + " ID:" + giveUid);
                  dto.setTime(sd.format(giveRecord.getGiveTime()));
                  dto.setMoney("¥" + giveRecord.getAmount().setScale(2));
                  userMoneyMsgNotificationService.redPackMsg(uid, MsgTypeMoneyTypeEnum.redPackReceiveOff, new Gson().toJson(dto), beiZhu);
                  userMoneyMsgNotificationService.redPackMsg(uid, MsgTypeMoneyTypeEnum.redPackReceiveOff,
                        new Gson().toJson(dto), beiZhu);
                  
                  // 赠送人消息
                  String userName = "无";
@@ -560,7 +559,8 @@
                  givedto.setUserInfo("昵称:" + userName + " ID:" + uid);
                  givedto.setTime(sd.format(new Date()));
                  givedto.setMoney("¥" + giveRecord.getAmount().setScale(2));
                  userMoneyMsgNotificationService.redPackMsg(giveUid, MsgTypeMoneyTypeEnum.redPackGiveOff, new Gson().toJson(givedto), giveBeiZhu);
                  userMoneyMsgNotificationService.redPackMsg(giveUid, MsgTypeMoneyTypeEnum.redPackGiveOff,
                        new Gson().toJson(givedto), giveBeiZhu);
               }
            });
         } catch (RedPackGiveRecordException e) {
@@ -602,7 +602,6 @@
      return invite;
   }
   
   private void addInviteMsg(Long uid, Long giveUid, String giftName) {
      try {
         UserInfo user = userInfoService.selectByPKey(giveUid);
@@ -632,7 +631,6 @@
      return tokenRecordMapper.overdueList(count);
   }
   @Override
   public void overdue(List<TokenRecord> list) {
      if (list == null || list.size() == 0)
@@ -644,7 +642,6 @@
         tokenRecordMapper.updateByPrimaryKeySelective(tokenRecord);
      }
   }
   
   @Override
   public void invalidByRedPack(Long id) {