From 395cd4c4caf01e1b3ad134834e5c1db284b59074 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 11 四月 2020 18:18:15 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java | 146 ++++-------------------------------------------- 1 files changed, 14 insertions(+), 132 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java index 0f6faa1..10f777c 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java @@ -1,6 +1,5 @@ package com.yeshi.fanli.service.impl.user; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -11,13 +10,8 @@ import org.springframework.core.task.TaskExecutor; import org.springframework.stereotype.Service; -import com.google.gson.Gson; import com.yeshi.fanli.dao.mybatis.user.TokenRecordMapper; -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; import com.yeshi.fanli.entity.bus.user.TokenRecord.TokenTypeEnum; @@ -29,7 +23,6 @@ import com.yeshi.fanli.entity.redpack.RedPackGiveRecord; import com.yeshi.fanli.entity.system.SystemCoupon; import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum; -import com.yeshi.fanli.exception.redpack.RedPackGiveRecordException; import com.yeshi.fanli.exception.user.TokenRecordException; import com.yeshi.fanli.exception.user.UserInfoExtraException; import com.yeshi.fanli.log.LogHelper; @@ -347,8 +340,8 @@ UserSystemCoupon userSystemCoupon = null; try { - userSystemCoupon = userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.freeCoupon.name(), - UserSystemCoupon.SOURCE_GIVE, null, true); + userSystemCoupon = userSystemCouponService.freeCouponWin(giveUid, CouponTypeEnum.freeCoupon, + UserSystemCoupon.SOURCE_GIVE, 1, true); } catch (Exception e) { LogHelper.errorDetailInfo(e); throw new TokenRecordException(1, "棰嗗彇澶辫触"); @@ -390,29 +383,7 @@ 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); - - // 婵�娲婚個璇蜂俊鎭� - if (addTeam) - addInviteMsg(uid, giveUid, "鍏嶅崟鍒�"); + addInviteTeam(uid, giveUid, userInfoExtra); } }); } else if (tokenType == TokenTypeEnum.rebatePercentCoupon) { @@ -441,9 +412,8 @@ UserSystemCoupon userSystemCoupon = null; try { - userSystemCoupon = userSystemCouponService.insertUserCoupon(uid, - CouponTypeEnum.rebatePercentCoupon.name(), UserSystemCoupon.SOURCE_GIVE, - systemCoupon.getPercent(), true); + userSystemCoupon = userSystemCouponService.rewardCouponWin(uid, UserSystemCoupon.SOURCE_GIVE, 1, true, + systemCoupon.getPercent()); } catch (Exception e) { LogHelper.errorDetailInfo(e); throw new TokenRecordException(1, "棰嗗彇澶辫触"); @@ -486,86 +456,21 @@ @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); - - // 婵�娲婚個璇蜂俊鎭� - if (addTeam) - addInviteMsg(uid, giveUid, "杩斿埄濂栧姳鍒�"); + addInviteTeam(uid, giveUid, userInfoExtra); } }); } else if (tokenType == TokenTypeEnum.redPack) { if (!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) throw new TokenRecordException(1, "璇峰崌绾у埌鏈�鏂扮増"); - try { - msg = "棰嗗彇绾㈠寘鎴愬姛锛岃鍒癧鎴戠殑-绾㈠寘]涓煡鐪�"; - // 棰嗗彇绾㈠寘銆佹洿鏂拌褰� - RedPackGiveRecord giveRecord = redPackGiveRecordService.receiveFriendsGive(uid, - Long.parseLong(identify)); - // 娑堟伅 + 闃熷憳 - 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 = "鏃�"; - String giveBeiZhu = "鏃�"; - if (addTeam) { - beiZhu = "浣犲凡鎴愪负璧犻�佷汉鐨勭洿鎺ョ矇涓�"; - giveBeiZhu = "棰嗗彇浜哄凡鎴愪负浣犵殑鐩存帴绮変笣"; - // 婵�娲婚個璇蜂俊鎭� - addInviteMsg(uid, giveUid, giveRecord.getAmount().setScale(2) + "鍏冪孩鍖�"); - } - - // 棰嗗彇浜烘秷鎭� - String giveUserName = "鏃�"; - UserInfo giveuser = userInfoService.selectByPKey(giveUid); - if (giveuser != null && !StringUtil.isNullOrEmpty(giveuser.getNickName())) - giveUserName = giveuser.getNickName(); - MsgRedPackGiveContentDTO dto = new MsgRedPackGiveContentDTO(); - dto.setTitle("绾㈠寘棰嗗彇"); - 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); - - // 璧犻�佷汉娑堟伅 - String userName = "鏃�"; - UserInfo user = userInfoService.selectByPKey(uid); - if (user != null && !StringUtil.isNullOrEmpty(user.getNickName())) - userName = user.getNickName(); - MsgRedPackGiveContentDTO givedto = new MsgRedPackGiveContentDTO(); - givedto.setTitle("绾㈠寘璧犻��"); - 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); - } - }); - } catch (RedPackGiveRecordException e) { - throw new TokenRecordException(1, e.getMsg()); - } + msg = "棰嗗彇绾㈠寘鎴愬姛锛岃鍒癧鎴戠殑-绾㈠寘]涓煡鐪�"; + // 娑堟伅 + 闃熷憳 + executor.execute(new Runnable() { + @Override + public void run() { + addInviteTeam(uid, giveUid, userInfoExtra); + } + }); } else if (tokenType == TokenTypeEnum.taoLiJin) { throw new TokenRecordException(1, "鎺ㄥ箍绾㈠寘鐩稿叧鍔熻兘宸蹭笅绾匡紒"); } else { @@ -602,29 +507,6 @@ return invite; } - private void addInviteMsg(Long uid, Long giveUid, String giftName) { - 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("浣犵殑閭�璇风爜锛�" + inviteCode); - msgInvite.setInviter("鏄电О锛�" + user.getNickName()); - msgInvite.setMode("鎴愬姛棰嗗彇閭�璇蜂汉鐨�" + giftName); - userInviteMsgNotificationService.receiveGift(uid, "閭�璇峰叧绯讳竴鏃︾‘绔嬫棤娉曟洿鏀� ", msgInvite); - } catch (Exception e) { - LogHelper.errorDetailInfo(e); - } - } @Override public List<TokenRecord> overdueList(int count) { -- Gitblit v1.8.0