From 9eeda0d3049b71877c373c04d65533939b5582ef Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期一, 02 九月 2019 09:55:55 +0800 Subject: [PATCH] getBoss方法只查询有效上级信息 --- fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java | 134 +++++++++++++++++++++++--------------------- 1 files changed, 69 insertions(+), 65 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java index de660c3..b9c6f0a 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java @@ -8,6 +8,7 @@ import javax.annotation.Resource; +import org.springframework.context.annotation.Lazy; import org.springframework.core.task.TaskExecutor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -18,11 +19,12 @@ import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo; import com.yeshi.fanli.entity.bus.user.UserActiveLog; import com.yeshi.fanli.entity.bus.user.UserInfo; -import com.yeshi.fanli.entity.bus.user.UserInfoExtra; import com.yeshi.fanli.exception.ThreeSaleException; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService; +import com.yeshi.fanli.service.inter.hongbao.ThreeSaleExtraInfoSerivce; import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce; +import com.yeshi.fanli.service.inter.integral.IntegralGetService; import com.yeshi.fanli.service.inter.msg.MsgInviteDetailService; import com.yeshi.fanli.service.inter.msg.UserInviteMsgNotificationService; import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService; @@ -57,20 +59,26 @@ @Resource private MsgInviteDetailService msgInviteDetailService; - + @Resource private UserTaoLiJinOriginService userTaoLiJinOriginService; - + @Resource private UserActiveLogService userActiveLogService; - + @Resource private UserInfoExtraService userInfoExtraService; + + @Resource + private ThreeSaleExtraInfoSerivce threeSaleExtraInfoSerivce; + + @Lazy + @Resource + private IntegralGetService integralGetService; + @Resource(name = "taskExecutor") private TaskExecutor executor; - - public UserInfo getBoss(final long uid) { return threeSaleMapper.selectBoss(uid); @@ -319,12 +327,10 @@ return threeSaleMapper.countSuperiorQuery(state, uid); } - @Override public long countFirstTeam(Long uid, Integer state) { return threeSaleMapper.countFirstTeam(uid, state); } - @Override public long countSecondTeam(Long uid, Integer state) { @@ -356,7 +362,7 @@ long countTotal = threeSaleMapper.countFirstTeam(uid, state); - return organizeTeam(countTotal, list, uid); + return organizeTeam(countTotal, list); } @Override @@ -368,10 +374,10 @@ long countTotal = threeSaleMapper.countSecondTeam(uid, state); - return organizeTeam(countTotal, list, uid); + return organizeTeam(countTotal, list); } - public JSONObject organizeTeam(long count, List<ThreeSale> list, Long uid) { + public JSONObject organizeTeam(long count, List<ThreeSale> list) { JSONObject result = new JSONObject(); @@ -402,18 +408,15 @@ object.put("memoName", memoName); String nickName = ""; - Long workerId= null; String portrait = ""; Long lastLoginTime = null; UserInfo worker = threeSale.getWorker(); if (worker != null) { - workerId = worker.getId(); portrait = worker.getPortrait(); lastLoginTime = worker.getLastLoginTime(); nickName = worker.getNickName(); } - object.put("workerId", workerId); object.put("nickName", nickName); object.put("portrait", portrait); @@ -438,15 +441,8 @@ // 寰�骞� contentJson.put("content", "鏈�杩戠櫥褰� " + format.format(lastLoginTime)); } + array.add(contentJson); - - - if (workerId != null) { - UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(workerId); - if (userInfoExtra != null) - object.put("weiXin", userInfoExtra.getWeiXin()); - } - } else if (threeSale.getExpire() != null && (threeSale.getExpire() == 1 || threeSale.getExpire().equals(1))) { @@ -490,12 +486,6 @@ resultArray.add(object); } - boolean bdWeiXin = false; - UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); - if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin())) - bdWeiXin = true; - - result.put("bdWeiXin", bdWeiXin); result.put("count", count); result.put("result_list", resultArray); @@ -514,16 +504,18 @@ @Override @Transactional - public void bindRelationshipByInviteCode(UserInfo invitee, UserInfo inviter, String platform, String version) throws ThreeSaleException { + public void bindRelationshipByInviteCode(UserInfo invitee, UserInfo inviter) throws ThreeSaleException { - if (invitee == null || inviter == null) + if (invitee == null || inviter == null) throw new ThreeSaleException(1, "鐢ㄦ埛淇℃伅涓虹┖"); - + // 鑾峰彇鏈夋晥鐨勯個璇峰叧绯� ThreeSale threeSale = threeSaleMapper.getRelationshipByBossIdAndWorkerId(inviter.getId(), invitee.getId()); if (threeSale != null) { // 鏈夋晥鍏崇郴--鐢熸晥 + threeSale.setBoss(inviter); + threeSale.setWorker(invitee); threeSale.setState(true); threeSale.setExpire(ThreeSale.EXPIRE_NORMAL); threeSale.setSucceedTime(java.lang.System.currentTimeMillis()); @@ -557,16 +549,17 @@ // 閭�璇锋秷鎭� userInviteMsgNotificationService.inviteSuccess(inviter.getId(), threeSale); - + executor.execute(new Runnable() { @Override public void run() { + + UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(inviter.getId()); try { - UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(inviter.getId()); - if (activeLog != null && !StringUtil.isNullOrEmpty(activeLog.getVersionCode()) ) { + if (activeLog != null && !StringUtil.isNullOrEmpty(activeLog.getVersionCode())) { String versionCode = activeLog.getVersionCode(); String channel = activeLog.getChannel(); - + boolean result = false; // 娓犻亾鏄痑ppstore 鍒ゆ柇涓篒OS if (!StringUtil.isNullOrEmpty(channel) && "appstore".equalsIgnoreCase(channel)) { @@ -574,14 +567,14 @@ } else { result = VersionUtil.greaterThan_1_5_60("android", versionCode); } - + if (result) { // 琚個璇峰悕绉� - String inviteName= invitee.getNickName(); + String inviteName = invitee.getNickName(); if (StringUtil.isNullOrEmpty(inviteName)) { UserInfo userInfo = userInfoService.selectByPKey(invitee.getId()); if (userInfo != null) { - inviteName= userInfo.getNickName(); + inviteName = userInfo.getNickName(); } } // 濂栧姳閭�璇风孩鍖咃紙娣樼ぜ閲戯級 @@ -591,23 +584,26 @@ } catch (Exception e) { LogHelper.errorDetailInfo(e); } + + // 閭�璇烽噾甯� + integralGetService.addInviteLevelOne(inviter.getId(), invitee.getId()); } }); - - + } @Override @Transactional - public void bindRelationshipByWX(UserInfo invitee, Long inviterId, ThreeSale threeSaleOld, String platform, String version) throws ThreeSaleException { + public void bindRelationshipByWX(UserInfo invitee, Long inviterId, ThreeSale threeSaleOld) + throws ThreeSaleException { if (invitee == null || (inviterId == null && threeSaleOld == null)) throw new ThreeSaleException(1, "鐢ㄦ埛淇℃伅涓虹┖"); - + ThreeSale threeSale = null; - if (inviterId != null ) { + if (inviterId != null) { // 鏂板缓绔嬬‘瀹氬叧绯� - threeSale = new ThreeSale(); + threeSale = new ThreeSale(); threeSale.setBoss(new UserInfo(inviterId)); threeSale.setWorker(invitee); threeSale.setState(true); @@ -616,10 +612,10 @@ threeSale.setCreateTime(java.lang.System.currentTimeMillis()); threeSale.setUpdateTime(java.lang.System.currentTimeMillis()); threeSaleMapper.insertSelective(threeSale); - - // 閭�璇峰叧绯诲け鏁� 1.5.3 涔嬪墠澶辨晥 + + // 閭�璇峰叧绯诲け鏁� 1.5.3 涔嬪墠澶辨晥 if (threeSaleOld != null) { - ThreeSale three = new ThreeSale(); + ThreeSale three = new ThreeSale(); three.setId(threeSaleOld.getId()); three.setExpire(ThreeSale.EXPIRE_OUTOFDATE); three.setUpdateTime(java.lang.System.currentTimeMillis()); @@ -632,48 +628,48 @@ threeSaleOld.setSucceedTime(java.lang.System.currentTimeMillis()); threeSaleOld.setUpdateTime(java.lang.System.currentTimeMillis()); threeSaleMapper.updateByPrimaryKeySelective(threeSaleOld); - + threeSale = threeSaleOld; } if (threeSale == null) { throw new ThreeSaleException(1, "鍏崇郴缁戝畾澶辫触"); } - + UserInfo boss = userInfoService.selectByPKey(threeSale.getBoss().getId()); threeSale.setBoss(boss); - + threeSale.setWorker(invitee); + // 娣诲姞鍒伴槦鍒� ThreeSaleCMQManager.getInstance().addThreeSaleMsg(threeSale); - + // 閭�璇锋秷鎭� userInviteMsgNotificationService.inviteSuccess(threeSale.getBoss().getId(), threeSale); - - + executor.execute(new Runnable() { @Override public void run() { try { - UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(inviterId); - if (activeLog != null && !StringUtil.isNullOrEmpty(activeLog.getVersionCode()) ) { + UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(inviterId); + if (activeLog != null && !StringUtil.isNullOrEmpty(activeLog.getVersionCode())) { boolean result = false; String versionCode = activeLog.getVersionCode(); String channel = activeLog.getChannel(); - + // 娓犻亾鏄痑ppstore 鍒ゆ柇涓篒OS if (!StringUtil.isNullOrEmpty(channel) && "appstore".equalsIgnoreCase(channel)) { result = VersionUtil.greaterThan_1_5_60("ios", versionCode); } else { result = VersionUtil.greaterThan_1_5_60("android", versionCode); } - + if (result) { // 琚個璇峰悕绉� - String inviteName= invitee.getNickName(); + String inviteName = invitee.getNickName(); if (StringUtil.isNullOrEmpty(inviteName)) { UserInfo userInfo = userInfoService.selectByPKey(invitee.getId()); if (userInfo != null) { - inviteName= userInfo.getNickName(); + inviteName = userInfo.getNickName(); } } // 濂栧姳閭�璇风孩鍖咃紙娣樼ぜ閲戯級 @@ -686,7 +682,7 @@ } }); } - + /** * 鏍规嵁閭�璇疯�呮煡璇㈠叧绯� * @@ -697,8 +693,7 @@ public ThreeSale getByWorkerId(Long workerId) { return threeSaleMapper.getByWorkerId(workerId); } - - + @Override public long countSuccessFirstTeam(Long uid) { return threeSaleMapper.countFirstTeam(uid, 1); @@ -708,11 +703,20 @@ public ThreeSale selectByWorkerId(Long workerId) { return threeSaleMapper.selectSuccessByWorkerId(workerId); } - - + @Override - public List<ThreeSale> getSuccessByDate(Long bossId, Long minTime, Long maxTime){ + public List<ThreeSale> getSuccessByDate(Long bossId, Long minTime, Long maxTime) { return threeSaleMapper.getSuccessByDate(bossId, minTime, maxTime); } + @Override + public List<ThreeSale> listFirstTeam(long start, int count, Long uid, Integer state) { + return threeSaleMapper.listFirstTeam(start, count, uid, state); + } + + @Override + public List<ThreeSale> listSecondTeam(long start, int count, Long uid, Integer state) { + return threeSaleMapper.listSecondTeam(start, count, uid, state); + } + } -- Gitblit v1.8.0