From 28cf328a098334b51a3e9d2d56f983fb8c862211 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期六, 23 五月 2020 09:54:38 +0800 Subject: [PATCH] 足迹、收藏订单兼容新需求 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/ThreeSaleSerivceImpl.java | 296 +++++++++++++++++++--------------------------------------- 1 files changed, 97 insertions(+), 199 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/ThreeSaleSerivceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/ThreeSaleSerivceImpl.java index 2ed0593..b8c591e 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/ThreeSaleSerivceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/ThreeSaleSerivceImpl.java @@ -21,7 +21,6 @@ import com.yeshi.fanli.dto.mq.user.body.UserInviteMQMsg; 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.UserInfo; import com.yeshi.fanli.exception.user.ThreeSaleException; import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; @@ -35,7 +34,6 @@ import com.yeshi.fanli.service.inter.user.invite.UserInviteMsgNotificationService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.StringUtil; -import com.yeshi.fanli.util.VersionUtil; import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory; import com.yeshi.fanli.util.rocketmq.MQTopicName; @@ -107,16 +105,6 @@ threeSale.setWorker(inviteeUser); threeSaleMapper.insertSelective(threeSale); - List<ThreeSale> listExpire = threeSaleMapper.getExpireRecord(inviter.getId(), inviteeUser.getId()); - if (listExpire != null && listExpire.size() > 0) { - // 鍒犻櫎澶辨晥 - for (ThreeSale saleExpire : listExpire) { - msgInviteDetailService.deleteByThreeSale(saleExpire); - } - // 鍒犻櫎宸插け鏁堝叧绯� - threeSaleMapper.deleteExpireRecord(inviter.getId(), inviteeUser.getId()); - } - } else {// 鏄凡缁忓瓨鍦ㄧ殑鐢ㄦ埛 if (worker.getId().longValue() == inviter.getId()) throw new ThreeSaleException(4, "涓嶈兘缁戝畾鑷繁"); @@ -146,20 +134,6 @@ threeSale.setUpdateTime(java.lang.System.currentTimeMillis()); threeSale.setWorker(worker); threeSaleMapper.insertSelective(threeSale); - - // 鍒犻櫎宸插け鏁堝叧绯� - threeSaleMapper.deleteExpireRecord(inviter.getId(), worker.getId()); - - List<ThreeSale> listExpire = threeSaleMapper.getExpireRecord(inviter.getId(), worker.getId()); - if (listExpire != null && listExpire.size() > 0) { - // 鍒犻櫎鍘嗗彶閫氱煡 - for (ThreeSale saleExpire : listExpire) { - msgInviteDetailService.deleteByThreeSale(saleExpire); - } - // 鍒犻櫎宸插け鏁堝叧绯� - threeSaleMapper.deleteExpireRecord(inviter.getId(), worker.getId()); - } - } else { // 杩樺瓨鍦ㄦ湁鏁堢殑閭�璇凤紝鍒欎笉鍋氬鐞� } @@ -230,80 +204,30 @@ // if (inviter != null) // reComputeUserRank(inviter.getId()); // 娣诲姞鍒伴槦鍒� - inviteSuccess(oldSale.getBoss().getId(), worker); + inviteSuccess(worker.getId(), oldSale.getBoss().getId()); } } @Override - public long getFirstUsersCount(Long uid) { - return threeSaleMapper.countFirstTeam(uid, null); - } - - @Override - public long getSecondUsersCount(Long uid) { - return threeSaleMapper.countSecondTeam(uid, null); - } - - @Override - public List<ThreeSale> queryMyFirstTeamList(int start, int count, String key, Long bossId) { - return threeSaleMapper.queryMyFirstTeamList(start, count, key, bossId); - } - - @Override - public long queryCountMyFirstTeamList(String key, Long bossId) { - return threeSaleMapper.queryCountMyFirstTeamList(key, bossId); - } - - @Override - public List<ThreeSale> queryMySecondTeamList(int start, int count, String key, Long bossId) { - return threeSaleMapper.queryMySecondTeamList(start, count, key, bossId); - } - - @Override - public long queryCountMySecondTeamList(String key, Long bossId) { - return threeSaleMapper.queryCountMySecondTeamList(key, bossId); - } - - @Override - public int deleteByPrimaryKey(Long id) { - return threeSaleMapper.deleteByPrimaryKey(id); - } - - @Override - public List<Long> queryLongTimeFailed(int daysNum) { - return threeSaleMapper.queryLongTimeFailed(daysNum); - } - - @Override - public List<ThreeSale> queryLongTimeSuccess(int daysNum) { - return threeSaleMapper.queryLongTimeSuccess(daysNum); - } - - @Override - public int updateExpire(List<Long> list) { - return threeSaleMapper.updateExpire(list); - } - - @Override public List<ThreeSale> listFirstTeamQuery(long start, int count, Long uid, Integer state, String startTime, - String endTime) { - return threeSaleMapper.listFirstTeamQuery(start, count, uid, state, startTime, endTime); + String endTime, Integer validState) { + return threeSaleMapper.listFirstTeamQuery(start, count, uid, state, startTime, endTime, validState); } @Override - public long countFirstTeamQuery(Long uid, Integer state, String startTime, String endTime) { - return threeSaleMapper.countFirstTeamQuery(uid, state, startTime, endTime); + public long countFirstTeamQuery(Long uid, Integer state, String startTime, String endTime, Integer validState) { + return threeSaleMapper.countFirstTeamQuery(uid, state, startTime, endTime, validState); } @Override public List<ThreeSale> listSecondTeamQuery(long start, int count, Long uid, Integer state, String startTime, - String endTime) { - return threeSaleMapper.listSecondTeamQuery(start, count, uid, state, startTime, endTime); + String endTime, Integer validState) { + return threeSaleMapper.listSecondTeamQuery(start, count, uid, state, startTime, endTime, validState); } @Override - public long countSecondTeamQuery(Long uid, Integer state, String startTime, String endTime) { - return threeSaleMapper.countSecondTeamQuery(uid, state, startTime, endTime); + public long countSecondTeamQuery(Long uid, Integer state, String startTime, String endTime, Integer validState) { + return threeSaleMapper.countSecondTeamQuery(uid, state, startTime, endTime, validState); } @Override @@ -314,16 +238,6 @@ @Override public long countSuperiorQuery(Integer state, Long uid) { 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) { - return threeSaleMapper.countSecondTeam(uid, state); } @Override @@ -342,27 +256,22 @@ } @Override - public JSONObject getMyFirstTeam(long start, int count, Long uid, Integer state) { - - List<ThreeSale> list = threeSaleMapper.listFirstTeam(start, count, uid, state); + public JSONObject getMyFirstTeam(long start, int count, Long uid) { + List<ThreeSale> list = threeSaleMapper.listFirstTeam(start, count, uid, null); if (list == null) { list = new ArrayList<ThreeSale>(); } - - long countTotal = threeSaleMapper.countFirstTeam(uid, state); - + long countTotal = threeSaleMapper.countFirstTeam(uid, null); return organizeTeam(countTotal, list); } @Override - public JSONObject getMySecondTeam(long start, int count, Long uid, Integer state) { - List<ThreeSale> list = threeSaleMapper.listSecondTeam(start, count, uid, state); + public JSONObject getMySecondTeam(long start, int count, Long uid) { + List<ThreeSale> list = threeSaleMapper.listSecondTeam(start, count, uid, null); if (list == null) { list = new ArrayList<ThreeSale>(); } - - long countTotal = threeSaleMapper.countSecondTeam(uid, state); - + long countTotal = threeSaleMapper.countSecondTeam(uid, null); return organizeTeam(countTotal, list); } @@ -493,33 +402,14 @@ @Override @Transactional(rollbackFor = Exception.class) - public void bindRelationshipByInviteCode(UserInfo invitee, UserInfo inviter) throws ThreeSaleException { - if (invitee == null || inviter == null) + public void bindInviteRelationship(Long workerId, Long bossId) throws ThreeSaleException { + if (workerId == null || bossId == null) throw new ThreeSaleException(1, "鐢ㄦ埛淇℃伅涓虹┖"); // 鏂板缓绔嬬‘瀹氬叧绯� ThreeSale threeSale = new ThreeSale(); - threeSale.setBoss(inviter); - threeSale.setWorker(invitee); - threeSale.setState(true); - threeSale.setExpire(ThreeSale.EXPIRE_NORMAL); - threeSale.setSucceedTime(java.lang.System.currentTimeMillis()); - threeSale.setCreateTime(java.lang.System.currentTimeMillis()); - threeSale.setUpdateTime(java.lang.System.currentTimeMillis()); - threeSaleMapper.insertSelective(threeSale); - - inviteSuccess(inviter.getId(), invitee); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void bindRelationshipByWX(UserInfo invitee, Long inviterId) throws ThreeSaleException { - if (invitee == null || inviterId == null) - throw new ThreeSaleException(1, "鐢ㄦ埛淇℃伅涓虹┖"); - // 鏂板缓绔嬬‘瀹氬叧绯� - ThreeSale threeSale = new ThreeSale(); - threeSale.setBoss(new UserInfo(inviterId)); - threeSale.setWorker(invitee); + threeSale.setBoss(new UserInfo(bossId)); + threeSale.setWorker(new UserInfo(workerId)); threeSale.setState(true); threeSale.setExpire(ThreeSale.EXPIRE_NORMAL); threeSale.setSucceedTime(java.lang.System.currentTimeMillis()); @@ -528,16 +418,17 @@ threeSaleMapper.insertSelective(threeSale); // 閭�璇锋垚鍔燂細娑堟伅銆佺浉鍏冲鐞� - inviteSuccess(inviterId, invitee); + inviteSuccess(workerId, bossId); } /** * 閭�璇锋垚鍔� */ @Transactional - private void inviteSuccess(Long bossId, UserInfo invitee) { + private void inviteSuccess(Long workerId, Long bossId) { if (!Constant.IS_TEST) { - UserInviteMQMsg msg = new UserInviteMQMsg(bossId, invitee.getId(), null, new Date(), UserInviteMQMsg.STATE_SUCCESS); + UserInviteMQMsg msg = new UserInviteMQMsg(bossId, workerId, null, new Date(), + UserInviteMQMsg.STATE_SUCCESS); Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteSuccess, msg); producer.send(message); } @@ -545,24 +436,24 @@ executor.execute(new Runnable() { @Override public void run() { - try { - // 閭�璇烽噾甯� - integralGetService.addInviteLevelOne(bossId, invitee.getId()); + try { // 閭�璇烽噾甯� + integralGetService.addInviteLevelOne(bossId, workerId); } catch (Exception e) { e.printStackTrace(); } - + try { // 鐩存帴绮変笣閭�璇锋垚鍔� + UserInfo invitee = userInfoService.selectByPKey(workerId); userInviteMsgNotificationService.directInviteSuccess(bossId, invitee.getNickName(), invitee.getPortrait(), new Date()); - + // 闂存帴绮変笣閭�璇锋垚鍔� ThreeSale myBoss = threeSaleMapper.getMyBoss(bossId); if (myBoss != null) { UserInfo boss = userInfoService.selectByPKey(bossId); - userInviteMsgNotificationService.indirectInviteSuccess(bossId, boss.getNickName(), - invitee.getNickName(), invitee.getPortrait(), new Date()); + userInviteMsgNotificationService.indirectInviteSuccess(myBoss.getBoss().getId(), + boss.getNickName(), invitee.getNickName(), invitee.getPortrait(), new Date()); } } catch (Exception e) { e.printStackTrace(); @@ -583,11 +474,6 @@ } @Override - public long countSuccessFirstTeam(Long uid) { - return threeSaleMapper.countFirstTeam(uid, 1); - } - - @Override public ThreeSale selectByWorkerId(Long workerId) { return threeSaleMapper.selectSuccessByWorkerId(workerId); } @@ -603,34 +489,53 @@ } @Override - public List<ThreeSale> listFirstTeam(long start, int count, Long uid, Integer state) { - return threeSaleMapper.listFirstTeam(start, count, uid, state); + public List<ThreeSale> listFirstTeam(long start, int count, Long uid) { + return threeSaleMapper.listFirstTeam(start, count, uid, null); } @Override - public List<ThreeSale> listFirstTeamByUndeleted(long start, int count, Long uid) { - return threeSaleMapper.listFirstTeamByUndeleted(start, count, uid); + public List<ThreeSale> listSecondTeam(long start, int count, Long uid) { + return threeSaleMapper.listSecondTeam(start, count, uid, null); } - + @Override - public long countFirstTeamByUndeleted(Long uid) { - return threeSaleMapper.countFirstTeamByUndeleted(uid); + public List<ThreeSale> listFirstTeam(long start, int count, Long uid, List<Long> listId) { + return threeSaleMapper.listFirstTeam(start, count, uid, listId); } - + @Override - public List<ThreeSale> listSecondTeamByUndeleted(long start, int count, Long uid) { - return threeSaleMapper.listSecondTeamByUndeleted(start, count, uid); + public List<ThreeSale> listSecondTeam(long start, int count, Long uid, List<Long> listId) { + return threeSaleMapper.listSecondTeam(start, count, uid, listId); } - + @Override - public long countSecondTeamByUndeleted(Long uid) { - return threeSaleMapper.countSecondTeamByUndeleted(uid); + public long countFirstTeam(Long uid) { + return threeSaleMapper.countFirstTeam(uid, null); } - - + @Override - public List<ThreeSale> listSecondTeam(long start, int count, Long uid, Integer state) { - return threeSaleMapper.listSecondTeam(start, count, uid, state); + public long countSecondTeam(Long uid) { + return threeSaleMapper.countSecondTeam(uid, null); + } + + @Override + public long countFirstTeam(Long uid, List<Long> listId) { + return threeSaleMapper.countFirstTeam(uid, listId); + } + + @Override + public long countSecondTeam(Long uid, List<Long> listId) { + return threeSaleMapper.countSecondTeam(uid, listId); + } + + @Override + public long countFirstTeamByDate(Long uid, int dayType) { + return threeSaleMapper.countFirstTeamByDate(uid, dayType); + } + + @Override + public long countSecondTeamByDate(Long uid, int dayType) { + return threeSaleMapper.countSecondTeamByDate(uid, dayType); } @Override @@ -671,47 +576,40 @@ return deepList; } - - @Override - public void remvoeBreak(Long id, Long uid, Long tid) { - ThreeSale threeSale = threeSaleMapper.selectByPrimaryKey(id); - if (threeSale == null) { - return; + public List<ThreeSale> getMyBossDeepList(Long uid) { + // TODO 闇�瑕佹洿鍔犵畝渚跨殑鏂瑰紡澶勭悊 + return getMyBossDeepList(uid, 100); + } + + @Override + public Long getTopBoss(Long uid) { + Long bossUid = null; + UserInfo boss = getBoss(uid); + while (boss != null) { + bossUid = boss.getId(); + boss = getBoss(boss.getId()); } - - Long workerId = threeSale.getWorker().getId(); - if (tid.longValue() != workerId.longValue()) { - return; - } - - Integer expire = threeSale.getExpire(); - if (expire == ThreeSale.EXPIRE_NORMAL) { - return; - } - - int upExpire = expire; - Long bossId = threeSale.getBoss().getId(); - if (bossId.longValue() == uid.longValue()) { // 鐩存帴绮変笣 - if (expire == ThreeSale.EXPIRE_BREAK_VIP_DEL4) { - upExpire =ThreeSale.EXPIRE_BREAK_VIP_DEL34; - } else { - upExpire = ThreeSale.EXPIRE_BREAK_VIP_DEL3; - } - } else { // 闂存帴绮変笣 - if (expire == ThreeSale.EXPIRE_BREAK_VIP_DEL3) { - upExpire =ThreeSale.EXPIRE_BREAK_VIP_DEL34; - } else { - upExpire = ThreeSale.EXPIRE_BREAK_VIP_DEL4; - } - } - - ThreeSale update = new ThreeSale(); - update.setId(id); - update.setExpire(upExpire); - update.setUpdateTime(java.lang.System.currentTimeMillis()); - threeSaleMapper.updateByPrimaryKeySelective(update); + return bossUid; + } + + @Override + public List<ThreeSale> listAll(Date minTime, Date maxTime, int page, int pageSize) { + return threeSaleMapper.listAll(minTime == null ? null : minTime.getTime(), + maxTime == null ? null : maxTime.getTime(), (page - 1) * pageSize, pageSize); + } + + @Override + public long countAll(Date minTime, Date maxTime) { + return threeSaleMapper.countAll(minTime == null ? null : minTime.getTime(), + maxTime == null ? null : maxTime.getTime()); + } + + + @Override + public List<Long> getAllBossId(){ + return threeSaleMapper.getAllBossId(); } } -- Gitblit v1.8.0