admin
2020-01-07 6fdcc0c26dd33e87a024a69ed635d9aedb59cad6
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
@@ -115,9 +117,14 @@
   public TokenRecord getNearByTypeAndIdentify(String type, String identify) {
      return tokenRecordMapper.getNearByTypeAndIdentify(type, identify);
   }
   @Override
   public TokenRecord getByTypeAndIdentify(String type, String identify) {
      return tokenRecordMapper.getByTypeAndIdentify(type, identify);
   }
   @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)) 
@@ -171,7 +178,7 @@
            state = true;
            UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
            if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
               tips.add("确认领取后,你将成为赠送人的一级队员;");
               tips.add("确认领取后,你将成为赠送人的直接粉丝;");
               tips.add("获赠的免单券,需要激活后才能使用,详情参见免单券激活规则;");
               tips.add("成功领取后,请到“我的-福利中心”查看。");
            } else {
@@ -207,7 +214,7 @@
            state = true;
            UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
            if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
               tips.add("确认领取后,你将成为赠送人的一级队员;");
               tips.add("确认领取后,你将成为赠送人的直接粉丝;");
               tips.add("板栗快省奖励券,可用于“已到账”的返利订单,在返利的基础上再获得一定比例的返利;");
               tips.add("成功领取后,请到“我的-福利中心”中查看。");
            } else {
@@ -218,6 +225,10 @@
            throw new TokenRecordException(1, "口令已失效");
         }
      } else if (tokenType == TokenTypeEnum.redPack) {
         if(!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
            throw new TokenRecordException(1, "请升级到最新版");
         type = 13;
         RedPackGiveRecord giveRecord = redPackGiveRecordService.selectByPrimaryKey(Long.parseLong(identify));
         if (giveRecord == null)
@@ -238,7 +249,7 @@
            state = true;
            UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
            if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
               tips.add("确认领取后,你将成为赠送人的一级队员;");
               tips.add("确认领取后,你将成为赠送人的直接粉丝;");
               tips.add("红包可提现,可购买折扣商品;");
               tips.add("成功领取后,请到“我的-红包”中查看。");
            } else {
@@ -288,7 +299,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, "用户未登录");
@@ -388,7 +399,7 @@
               boolean addTeam = addInviteTeam(uid, giveUid, userInfoExtra);
               String beiZhu = "无";
               if (addTeam)
                  beiZhu = "领取人已经成为你的一级队员";
                  beiZhu = "领取人已经成为你的直接粉丝";
               String userName = "无";
               UserInfo user = userInfoService.selectByPKey(uid);
@@ -482,7 +493,7 @@
               boolean addTeam = addInviteTeam(uid, giveUid, userInfoExtra);
               String beiZhu = "无";
               if (addTeam)
                  beiZhu = "领取人已经成为你的一级队员";
                  beiZhu = "领取人已经成为你的直接粉丝";
               String userName = "无";
               UserInfo user = userInfoService.selectByPKey(uid);
@@ -504,6 +515,9 @@
            }
         });
      } else if (tokenType == TokenTypeEnum.redPack) {
         if(!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
            throw new TokenRecordException(1, "请升级到最新版");
         try {
            msg = "领取红包成功,请到[我的-红包]中查看";
            // 领取红包、更新记录
@@ -518,8 +532,8 @@
                  String beiZhu = "无";
                  String giveBeiZhu = "无";
                  if (addTeam) {
                     beiZhu = "你已成为赠送人的一级队员";
                     giveBeiZhu = "领取人已成为你的一级队员";
                     beiZhu = "你已成为赠送人的直接粉丝";
                     giveBeiZhu = "领取人已成为你的直接粉丝";
                     // 激活邀请信息
                     addInviteMsg(uid, giveUid, giveRecord.getAmount().setScale(2) + "元红包");
                  }
@@ -593,10 +607,18 @@
      try {
         UserInfo user = userInfoService.selectByPKey(giveUid);
         UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
         String inviteCode = null;
         if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCodeVip())) {
            inviteCode = userInfoExtra.getInviteCodeVip();
         } else {
            inviteCode = userInfoExtra.getInviteCode();
         }
         MsgInviteContentDTO msgInvite = new MsgInviteContentDTO();
         msgInvite.setTitle("邀请消息");
         msgInvite.setState("成功激活邀请");
         msgInvite.setCode("你的邀请码:" + userInfoExtra.getInviteCode());
         msgInvite.setCode("你的邀请码:" + inviteCode);
         msgInvite.setInviter("昵称:"+user.getNickName());
         msgInvite.setMode("成功领取邀请人的" + giftName);
         userInviteMsgNotificationService.receiveGift(uid, "邀请关系一旦确立无法更改 ", msgInvite);
@@ -622,4 +644,26 @@
         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());
   }
}