From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/TeamFansInfoServiceImpl.java | 371 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 342 insertions(+), 29 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/TeamFansInfoServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/TeamFansInfoServiceImpl.java index a291038..3e4caa4 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/TeamFansInfoServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/TeamFansInfoServiceImpl.java @@ -10,72 +10,380 @@ import com.yeshi.fanli.dao.user.invite.TeamFansInfoDao; import com.yeshi.fanli.dto.user.ThreeSaleFocusDTO; +import com.yeshi.fanli.dto.vip.UserVIPLevel; import com.yeshi.fanli.entity.bus.user.TeamFansInfo; +import com.yeshi.fanli.entity.bus.user.ThreeSale; +import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo; +import com.yeshi.fanli.entity.bus.user.UserActiveLog; +import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo; +import com.yeshi.fanli.entity.bus.user.UserInfo; +import com.yeshi.fanli.entity.bus.user.UserInfoExtra; +import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum; +import com.yeshi.fanli.log.LogHelper; +import com.yeshi.fanli.service.inter.count.HongBaoV2CountService; +import com.yeshi.fanli.service.inter.order.CommonOrderService; +import com.yeshi.fanli.service.inter.user.UserActiveLogService; +import com.yeshi.fanli.service.inter.user.UserInfoExtraService; +import com.yeshi.fanli.service.inter.user.UserInfoService; import com.yeshi.fanli.service.inter.user.invite.TeamFansInfoService; +import com.yeshi.fanli.service.inter.user.invite.ThreeSaleExtraInfoSerivce; import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce; +import com.yeshi.fanli.service.inter.user.invite.UserInviteService; +import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService; +import com.yeshi.fanli.util.StringUtil; +import com.yeshi.fanli.util.user.UserLevelUtil; @Service public class TeamFansInfoServiceImpl implements TeamFansInfoService { @Resource private TeamFansInfoDao teamFansInfoDao; - + @Resource private ThreeSaleSerivce threeSaleSerivce; - - @Override - public void save(TeamFansInfo record) { - teamFansInfoDao.save(record); + + @Resource + private UserInfoService userInfoService; + + @Resource + private UserInfoExtraService userInfoExtraService; + + @Resource + private ThreeSaleExtraInfoSerivce threeSaleExtraInfoSerivce; + + @Resource + private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; + + @Resource + private HongBaoV2CountService hongBaoV2CountService; + + @Resource + private UserInviteService userInviteService; + + @Resource + private CommonOrderService commonOrderService; + + @Resource + private UserActiveLogService userActiveLogService; + + + /** + * 鍒濆鍖栨暟鎹� + * @param record + */ + private void initData(TeamFansInfo record) { + if (StringUtil.isNullOrEmpty(record.getNickName())) + record.setNickName(""); + if (record.getLevel() == null) + record.setLevel(UserLevelEnum.daRen); + if (record.getStateValid() == null) + record.setStateValid(false); + if (record.getTaobaoBind() == null) + record.setTaobaoBind(false); + if (record.getWeixinId() == null) + record.setWeixinId(""); + if (record.getPhone() == null) + record.setPhone(""); + if (record.getPhoneOpen() == null) + record.setPhoneOpen(true); + if (record.getInviteCode() == null) + record.setInviteCode(""); + if (record.getActiveTime() == null) + record.setActiveTime(new Date()); + if (record.getFansNum() == null) + record.setFansNum(0); + if (record.getIncome() == null) + record.setIncome(0); + if (record.getIncomeTime() == null) + record.setIncomeTime(new Date()); + if (record.getMemoName() == null) + record.setMemoName(""); + if (record.getTags() == null) + record.setTags(""); + if (record.getMemoNameSup() == null) + record.setMemoNameSup(""); + if (record.getTagsSup() == null) + record.setTagsSup(""); + + if (StringUtil.isNullOrEmpty(record.getWeixinId())) { + record.setWeixinIdExist(false); + } else { + record.setWeixinIdExist(true); + } + } - + @Override + public void addFansInfo(Long workerId, Long bossId, Date successTime) { + + LogHelper.test("addFansInfo-鏂板-" + workerId); + + UserInfo userInfo = userInfoService.selectByPKey(workerId); + if (userInfo == null) { + return; + } + + String phone = ""; + if (!StringUtil.isNullOrEmpty(userInfo.getPhone())) { + phone = userInfo.getPhone(); + } + + // 澶囨敞鍚� + String memoName = null; + ThreeSaleExtraInfo threeSaleExtraInfo = threeSaleExtraInfoSerivce.getbyBossIdAndWorkerId(bossId, workerId); + if (threeSaleExtraInfo != null) { + if (!StringUtil.isNullOrEmpty(threeSaleExtraInfo.getNickname())) { + memoName = threeSaleExtraInfo.getNickname(); + } + } + + // 寰俊鍙枫�佹椿璺冩椂闂� + String inviteCode = ""; + String weixinId = ""; + boolean weixinBind = false; + UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(workerId); + if (userInfoExtra != null) { + String weiXin = userInfoExtra.getWeiXin(); + if (!StringUtil.isNullOrEmpty(weiXin)) { + weixinId = weiXin; + weixinBind = true; + } + String inviteCodeVip = userInfoExtra.getInviteCodeVip(); + String inviteCode2 = userInfoExtra.getInviteCode(); + if (!StringUtil.isNullOrEmpty(inviteCode2)) { + if (!StringUtil.isNullOrEmpty(inviteCodeVip)) { + inviteCode = inviteCodeVip; + } else { + inviteCode = inviteCode2; + } + } + } + + Date activeTime = new Date(1514736000000L); // 榛樿20181-1-1; + UserActiveLog userActiveLog = userActiveLogService.getUserLatestActiveInfo(workerId); + if (userActiveLog != null) { + activeTime = userActiveLog.getCreateTime(); + } + + // 娣樺疂鎺堟潈 + boolean taobaoBind = false; + UserExtraTaoBaoInfo taoBaoInfo = userExtraTaoBaoInfoService.getByUid(workerId); + if (taoBaoInfo != null && !StringUtil.isNullOrEmpty(taoBaoInfo.getRelationId()) + && !StringUtil.isNullOrEmpty(taoBaoInfo.getSpecialId())) { + taobaoBind = true; + } + + // 绮変笣鏁伴噺 + long firstTeam = threeSaleSerivce.countFirstTeam(workerId); + long secondTeam = threeSaleSerivce.countSecondTeam(workerId); + int fansNum = (int) (firstTeam + secondTeam); + + // 鏀跺叆 + BigDecimal income = hongBaoV2CountService.sumMoneyArrivalByUidAndNearDay(workerId, 60); + if (income == null) + income = new BigDecimal(0); + + // 鏈夋晥绮変笣 + boolean stateValid = false; + long countValid = commonOrderService.countOrderByUidAndSettled(workerId, BigDecimal.valueOf(1)); + if (countValid > 0) { + stateValid = true; + } + + // 鏌ヨ绮変笣绛夌骇 + UserLevelEnum level = null; + UserVIPLevel vipLevel = userInviteService.getVIPLevelByUid(workerId); + if (vipLevel != null && vipLevel.getLevel() != null) { + level = UserLevelUtil.getByLevel(vipLevel.getLevel()); + } + if (level == null) { + level = UserLevelEnum.daRen; + } + level = UserLevelUtil.getShowLevel(level); + + // 鏄惁瀛樺湪涓婁笂绾� + Long bossSuperId = null; + ThreeSale superThree = threeSaleSerivce.selectByWorkerId(bossId); + if (superThree != null) + bossSuperId = superThree.getBoss().getId(); + + TeamFansInfo focusInfo = new TeamFansInfo(); + focusInfo.setBossId(bossId); + focusInfo.setWorkerId(workerId); + focusInfo.setBossSuperId(bossSuperId); + focusInfo.setJoinTime(successTime); + focusInfo.setNickName(userInfo.getNickName()); + focusInfo.setMemoName(memoName); + focusInfo.setWeixinIdExist(weixinBind); + focusInfo.setWeixinId(weixinId); + focusInfo.setPhone(phone); + focusInfo.setPhoneOpen(true); + focusInfo.setInviteCode(inviteCode); + focusInfo.setActiveTime(activeTime); + focusInfo.setFansNum(fansNum); + focusInfo.setTaobaoBind(taobaoBind); + focusInfo.setIncome(income.multiply(BigDecimal.valueOf(100)).setScale(2, BigDecimal.ROUND_DOWN).intValue()); + focusInfo.setIncomeTime(new Date()); + focusInfo.setStateValid(stateValid); + focusInfo.setLevel(level); + focusInfo.setId(workerId.toString()); + focusInfo.setCrateTime(new Date()); + + // 鍒濆鍖栧�� + initData(focusInfo); + + teamFansInfoDao.save(focusInfo); + } + @Override public void updateMemoName(Long workerId, int type, String memoName) { - teamFansInfoDao.updateMemoName(workerId, type, memoName); + LogHelper.test("updateMemoName-鏇存柊-" + workerId); + TeamFansInfo teamFansInfo = new TeamFansInfo(); + teamFansInfo.setWorkerId(workerId); + if (type == 1) { + teamFansInfo.setMemoName(memoName); + } else { + teamFansInfo.setMemoNameSup(memoName); + } + update(teamFansInfo); } @Override public void updateTags(Long workerId, int type, String tags) { - teamFansInfoDao.updateTags(workerId, type, tags); + LogHelper.test("updateTags-鏇存柊-" + workerId); + TeamFansInfo teamFansInfo = new TeamFansInfo(); + teamFansInfo.setWorkerId(workerId); + if (type == 1) { + teamFansInfo.setTags(tags); + } else { + teamFansInfo.setTagsSup(tags); + } + update(teamFansInfo); } - + @Override public void updateNickName(Long workerId, String nickName) { - teamFansInfoDao.updateNickName(workerId, nickName); + LogHelper.test("updateNickName-鏇存柊-" + workerId); + TeamFansInfo teamFansInfo = new TeamFansInfo(); + teamFansInfo.setWorkerId(workerId); + teamFansInfo.setNickName(nickName); + update(teamFansInfo); } - - + @Override public void updateStateValid(Long workerId, boolean stateValid) { - teamFansInfoDao.updateStateValid(workerId, stateValid); + LogHelper.test("updateStateValid-鏇存柊-" + workerId); + TeamFansInfo teamFansInfo = new TeamFansInfo(); + teamFansInfo.setWorkerId(workerId); + teamFansInfo.setStateValid(stateValid); + update(teamFansInfo); } - + @Override public void updateTaobaoBind(Long workerId, boolean taobaoBind) { - teamFansInfoDao.updateTaobaoBind(workerId, taobaoBind); - } - - @Override - public void updateWeixinBind(Long workerId, boolean weixinBind) { - teamFansInfoDao.updateWeixinBind(workerId, weixinBind); + LogHelper.test("updateTaobaoBind-鏇存柊-" + workerId); + TeamFansInfo teamFansInfo = new TeamFansInfo(); + teamFansInfo.setWorkerId(workerId); + teamFansInfo.setTaobaoBind(taobaoBind); + update(teamFansInfo); } @Override public void updateActiveTime(Long workerId, Date activeTime) { - teamFansInfoDao.updateActiveTime(workerId, activeTime); + LogHelper.test("updateActiveTime-鏇存柊-" + workerId); + TeamFansInfo teamFansInfo = new TeamFansInfo(); + teamFansInfo.setWorkerId(workerId); + teamFansInfo.setActiveTime(activeTime); + update(teamFansInfo); } @Override - public void updateFansNum(Long workerId) { - long firstTeam = threeSaleSerivce.countFirstTeam(workerId); - long secondTeam = threeSaleSerivce.countSecondTeam(workerId); - int fansNum = (int) (firstTeam + secondTeam); - teamFansInfoDao.updateFansNum(workerId, fansNum); + public void updateWeixinId(Long workerId, String weixinId) { + LogHelper.test("updateWeixinId-鏇存柊-" + workerId); + TeamFansInfo teamFansInfo = new TeamFansInfo(); + teamFansInfo.setWorkerId(workerId); + teamFansInfo.setWeixinId(weixinId); + if (StringUtil.isNullOrEmpty(weixinId)) { + teamFansInfo.setWeixinIdExist(false); + } else { + teamFansInfo.setWeixinIdExist(true); + } + update(teamFansInfo); + } + + @Override + public void updateInviteCode(Long workerId, String inviteCode) { + LogHelper.test("updateInviteCode-鏇存柊-" + workerId); + TeamFansInfo teamFansInfo = new TeamFansInfo(); + teamFansInfo.setWorkerId(workerId); + teamFansInfo.setInviteCode(inviteCode); + update(teamFansInfo); + } + + @Override + public void updatePhone(Long workerId, String phone) { + LogHelper.test("updatePhone-鏇存柊-" + workerId); + TeamFansInfo teamFansInfo = new TeamFansInfo(); + teamFansInfo.setWorkerId(workerId); + teamFansInfo.setPhone(phone); + update(teamFansInfo); + } + + @Override + public void updateLevel(Long workerId, UserLevelEnum level) { + LogHelper.test("updateLevel-鏇存柊-" + workerId); + TeamFansInfo teamFansInfo = new TeamFansInfo(); + teamFansInfo.setLevel(level); + teamFansInfo.setWorkerId(workerId); + update(teamFansInfo); + } + + @Override + public void updatePhoneOpen(Long workerId, boolean phoneOpen) { + LogHelper.test("updatePhoneOpen-鏇存柊-" + workerId); + TeamFansInfo teamFansInfo = new TeamFansInfo(); + teamFansInfo.setWorkerId(workerId); + teamFansInfo.setPhoneOpen(phoneOpen); + update(teamFansInfo); } @Override public void updateIncome(Long workerId, BigDecimal income) { - teamFansInfoDao.updateIncome(workerId, income); + LogHelper.test("updateIncome-鏇存柊-" + workerId); + if (income == null) { + income = BigDecimal.ZERO; + } + + TeamFansInfo teamFansInfo = new TeamFansInfo(); + teamFansInfo.setWorkerId(workerId); + teamFansInfo.setIncome(income.multiply(BigDecimal.valueOf(100)).setScale(0, BigDecimal.ROUND_DOWN).intValue()); + teamFansInfo.setIncomeTime(new Date()); + update(teamFansInfo); + } + + @Override + public void updateFansNum(Long workerId) { + LogHelper.test("updateFansNum-鏇存柊-" + workerId); + long firstTeam = threeSaleSerivce.countFirstTeam(workerId); + long secondTeam = threeSaleSerivce.countSecondTeam(workerId); + int fansNum = (int) (firstTeam + secondTeam); + TeamFansInfo teamFansInfo = new TeamFansInfo(); + teamFansInfo.setWorkerId(workerId); + teamFansInfo.setFansNum(fansNum); + update(teamFansInfo); + } + + private void update(TeamFansInfo record) { + if (record == null || record.getWorkerId() == null) { + return; + } + // 鏃犻個璇峰叧绯� 涓嶆搷浣� + ThreeSale threeSale = threeSaleSerivce.selectByWorkerId(record.getWorkerId()); + if (threeSale == null) + return; + + record.setId(record.getWorkerId().toString()); + teamFansInfoDao.updateSelective(record); } @@ -83,14 +391,19 @@ public List<TeamFansInfo> query(int start, int count, int type, Long uid, ThreeSaleFocusDTO focusDTO) { return teamFansInfoDao.query(start, count, type, uid, focusDTO); } - + @Override public long count(int type, Long uid, ThreeSaleFocusDTO focusDTO) { return teamFansInfoDao.count(type, uid, focusDTO); } - + @Override public TeamFansInfo getbyWorkerId(Long workerId) { return teamFansInfoDao.getbyWorkerId(workerId); } + + @Override + public List<TeamFansInfo> queryByUserInfo(String key) { + return teamFansInfoDao.queryByUserInfo(key); + } } -- Gitblit v1.8.0