admin
2019-08-19 9c09cead959dbeef292628f345e5f80c30fc3d17
fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java
@@ -72,6 +72,7 @@
   private UserOtherMsgNotificationService userOtherMsgNotificationService;
   
   
   @Override
   public void insertSelective(TokenRecord record) {
      record.setCreateTime(new Date());
@@ -125,7 +126,7 @@
      TokenVO tokenVO = new TokenVO();
      tokenVO.setToken(token);
      tokenVO.setNickName(nickName);
      tokenVO.setNickName(nickName + "赠送");
      tokenVO.setPortrait(portrait);
      String identify = rokenRecord.getIdentify();
@@ -157,6 +158,7 @@
                  throw new TokenRecordException(1001, "温馨提示,[免单券]需要登录后领取");
               state = true;
               tokenVO.setAmount(1);
               UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
               if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
                  tips.add("确认领取后,你将成为赠送者的一级队员;");
@@ -191,6 +193,7 @@
                  throw new TokenRecordException(1001, "温馨提示,[返利奖励券]需要登录后领取");
               state = true;
               tokenVO.setAmount(1);
               UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
               if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
                  tips.add("确认领取后,你将成为赠送者的一级队员;");
@@ -216,7 +219,10 @@
            if (uid == null || uid <= 0)
               throw new TokenRecordException(1001, "温馨提示,[推广红包]需要登录后领取");
            BigDecimal amount = giveRecord.getAmount();
            state = true;
            tokenVO.setAmount(Integer.parseInt(amount.setScale(0).toString()));
            UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
            if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
               tips.add("确认领取后,你将成为赠送者的一级队员;");
@@ -238,7 +244,7 @@
   }
   @Override
   public void receiveToken(String token, Long uid) throws TokenRecordException {
   public String receiveToken(String token, Long uid) throws TokenRecordException {
      if (uid == null || uid <= 0)
         throw new TokenRecordException(1, "用户未登录");
@@ -268,6 +274,8 @@
      if (userInfoExtra == null) 
         throw new TokenRecordException(1, "用户信息缺失");
         
      String msg = "领取成功";
      TokenTypeEnum tokenType = rokenRecord.getType();
      if (tokenType == TokenTypeEnum.freeCoupon) {
         long couponId = Long.parseLong(identify);
@@ -312,6 +320,7 @@
            giveRecord.setReceiveTime(new Date());
            userSystemCouponGiveRecordService.updateByPrimaryKeySelective(giveRecord);
            
            msg = "领取成功[免单券]成功,请到[我的-福利中心]中查看";
            // 消息 + 队员
            executor.execute(new Runnable() {
               @Override
@@ -384,6 +393,7 @@
            giveRecord.setReceiveTime(new Date());
            userSystemCouponGiveRecordService.updateByPrimaryKeySelective(giveRecord);
            
            msg = "领取成功[返利奖励券]成功,请到[我的-福利中心]中查看";
            // 消息 + 队员
            executor.execute(new Runnable() {
               @Override
@@ -394,11 +404,16 @@
                  if (addTeam)
                     beiZhu = "领取人已经成为你的一级队员";
                  
                  String userName = "无";
                  UserInfo user = userInfoService.selectByPKey(uid);
                  if (user != null && !StringUtil.isNullOrEmpty(user.getNickName()))
                     userName = user.getNickName();
                  MsgOtherGiveContentDTO msgOther = new MsgOtherGiveContentDTO();
                  msgOther.setType(MsgOtherGiveContentDTO.TYEP_COUPON);
                  msgOther.setTitle("赠送奖励券");
                  msgOther.setGiveType("你赠送的奖励券被成功领取");
                  msgOther.setReceiveInfo("昵称:[昵称昵称昵称/无]ID:[854245]");
                  msgOther.setReceiveInfo("昵称:  " + userName +" ID:" + uid);
                  msgOther.setGiveTime(sd.format(giveRecord.getGiveTime()));
                  msgOther.setReceiveTime(sd.format(new Date()));
                  userOtherMsgNotificationService.tokenGiveMsg(giveUid, beiZhu, msgOther);
@@ -431,6 +446,35 @@
               updateRecord.setReceiveUid(uid);
               updateRecord.setState(UserTaoLiJinGiveRecord.STATE_RECEIVE);
               userTaoLiJinGiveRecordService.updateByPrimaryKeySelective(updateRecord);
               msg = "领取成功[推广红包]成功,请到[我的-推广红包]中查看";
               // 消息 + 队员
               executor.execute(new Runnable() {
                  @Override
                  public void run() {
                     SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH.mm");
                     boolean addTeam = addInviteTeam(uid, giveUid, userInfoExtra);
                     String beiZhu = "无";
                     if (addTeam)
                        beiZhu = "领取人已经成为你的一级队员";
                     String userName = "无";
                     UserInfo user = userInfoService.selectByPKey(uid);
                     if (user != null && !StringUtil.isNullOrEmpty(user.getNickName()))
                        userName = user.getNickName();
                     MsgOtherGiveContentDTO msgOther = new MsgOtherGiveContentDTO();
                     msgOther.setType(MsgOtherGiveContentDTO.TYEP_COUPON);
                     msgOther.setTitle("赠送推广红包");
                     msgOther.setGiveType("你赠送的推广红包被成功领取");
                     msgOther.setReceiveInfo("昵称:  " + userName +" ID:" + uid);
                     msgOther.setGiveTime(sd.format(giveRecord.getGiveTime()));
                     msgOther.setReceiveTime(sd.format(new Date()));
                     userOtherMsgNotificationService.tokenGiveMsg(giveUid, beiZhu, msgOther);
                  }
               });
            } catch (UserTaoLiJinOriginException e) {
               e.printStackTrace();
            }
@@ -438,7 +482,8 @@
      } else {
         throw new TokenRecordException(1, "无对应类型");
      }
      return msg;
   }