From 17e98d7bcc27072f97976d24eb504abb02914891 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期六, 11 四月 2020 09:20:14 +0800 Subject: [PATCH] 消息 --- fanli/src/main/java/com/yeshi/fanli/service/impl/order/InviteOrderSubsidyServiceImplV2.java | 124 ++++++++++++++--------------------------- 1 files changed, 43 insertions(+), 81 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/InviteOrderSubsidyServiceImplV2.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/InviteOrderSubsidyServiceImplV2.java index 30be748..82ebf90 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/InviteOrderSubsidyServiceImplV2.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/InviteOrderSubsidyServiceImplV2.java @@ -4,11 +4,9 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Date; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import javax.annotation.Resource; @@ -18,13 +16,10 @@ import com.yeshi.fanli.dao.mybatis.order.InviteOrderSubsidyMapper; import com.yeshi.fanli.entity.bus.user.HongBaoV2; -import com.yeshi.fanli.entity.bus.user.ThreeSale; -import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum; import com.yeshi.fanli.entity.order.CommonOrder; import com.yeshi.fanli.entity.order.HongBaoOrder; import com.yeshi.fanli.entity.order.InviteOrderSubsidy; -import com.yeshi.fanli.entity.order.OrderTeamReward; import com.yeshi.fanli.exception.order.CommonOrderException; import com.yeshi.fanli.exception.order.InviteOrderSubsidyException; import com.yeshi.fanli.exception.order.OrderTeamRewardException; @@ -34,7 +29,6 @@ import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyServiceV2; import com.yeshi.fanli.service.inter.order.OrderHongBaoMapService; import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService; -import com.yeshi.fanli.service.inter.order.OrderTeamRewardService; import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce; import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService; @@ -73,9 +67,6 @@ private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; @Resource - private OrderTeamRewardService orderTeamRewardService; - - @Resource private ThreeSaleSerivce threeSaleSerivce; @Override @@ -110,77 +101,12 @@ update.setState(orderSubsidy.getState()); update.setUpdateTime(new Date()); inviteOrderSubsidyMapper.updateByPrimaryKeySelective(update); - // 娣诲姞濂栧姳 - addTeamReward(old.getId()); + //TODO 鍒犻櫎娣诲姞濂栧姳 } else {// 娣诲姞 if (orderSubsidy.getCreateTime() == null) orderSubsidy.setCreateTime(new Date()); inviteOrderSubsidyMapper.insertSelective(orderSubsidy); - // 娣诲姞濂栧姳 - addTeamReward(orderSubsidy.getId()); - } - } - - // 娣诲姞鍥㈤槦濂栧姳 - private void addTeamReward(Long subsidyId) throws OrderTeamRewardException, CommonOrderException { - // 鏌ヨ鍥㈤槦濂栧姳鐨勪汉 - // 璁$畻鐩稿簲鐨勬瘮渚� - InviteOrderSubsidy subsidy = inviteOrderSubsidyMapper.selectByPrimaryKeyForUpdate(subsidyId); - if (subsidy == null) - throw new OrderTeamRewardException(20, "琛ヨ创涓嶅瓨鍦�"); - - // 鑾峰彇涓�4绾х敤鎴� - List<CommonOrder> commonOrderList = commonOrderService.listBySourceTypeAndOrderId(subsidy.getSourceType(), - subsidy.getOrderNo()); - if (commonOrderList == null || commonOrderList.size() == 0) { - throw new CommonOrderException(1, "璁㈠崟涓嶅瓨鍦�"); - } - - Long sourceUid = commonOrderList.get(0).getUserInfo().getId(); - - List<ThreeSale> bossList = threeSaleSerivce.getMyBossDeepList(sourceUid, 4); - // 鏃犻渶瑕佸洟闃熷鍔辩殑涓婄骇 - if (bossList.size() < 3) - return; - - Set<Long> rewardUid = new HashSet<>(); - for (int i = 2; i < bossList.size(); i++) { - rewardUid.add(bossList.get(i).getBoss().getId()); - } - // 鍒犻櫎鏈ˉ璐寸敤鎴风殑涓嬬骇 - for (int i = 0; i < bossList.size(); i++) { - if (bossList.get(i).getBoss().getId().longValue() == subsidy.getUid()) { - break; - } else { - bossList.remove(i); - i--; - } - } - - // 鑾峰彇琛ヨ创鐢ㄦ埛鐨勭洿鎺ヤ笂绾� - if (bossList.size() > 1 && bossList.get(1).getSucceedTime() < subsidy.getCreateTime().getTime()) { - UserInfo boss = bossList.get(1).getBoss(); - UserLevelEnum userLevel = userLevelManager.getUserLevel(boss.getId()); - BigDecimal rewardMoney = orderHongBaoMoneyComputeService.computeFirstTeamReward(subsidy.getMoney(), - subsidy.getCreateTime(), userLevel); - - if (rewardMoney != null) { - // 娣诲姞濂栧姳 - orderTeamRewardService.addOrUpdate(subsidy, rewardMoney, boss.getId(), OrderTeamReward.LEVEL_ONE); - } - - // 鑾峰彇琛ヨ创鐨勯棿鎺ヤ笂绾� - if (bossList.size() > 2 && bossList.get(2).getSucceedTime() < subsidy.getCreateTime().getTime()) { - boss = bossList.get(2).getBoss(); - userLevel = userLevelManager.getUserLevel(boss.getId()); - rewardMoney = orderHongBaoMoneyComputeService.computeSecondTeamReward(subsidy.getMoney(), - subsidy.getCreateTime(), userLevel); - if (rewardMoney != null) { - // 娣诲姞濂栧姳 - orderTeamRewardService.addOrUpdate(subsidy, rewardMoney, boss.getId(), OrderTeamReward.LEVEL_TWO); - } - } - + //TODO 鍒犻櫎娣诲姞濂栧姳 } } @@ -191,7 +117,9 @@ if (list != null && list.size() > 0) { // 蹇呴』鏄嚜璐鍗曟墠杩斿埄 HongBaoV2 parent = hongBaoV2Service.selectByPrimaryKey(list.get(0).getHongBaoV2().getId()); - if (parent != null && parent.getUrank() != UserLevelEnum.superVIP.getOrderRank()) {// 涓嶆槸瓒呯骇浼氬憳鐨勮嚜璐�/鍒嗕韩鎵嶈ˉ璐� + if (parent != null && parent.getUrank() != UserLevelEnum.superVIP.getOrderRank() + && (parent.getType() == HongBaoV2.TYPE_SHARE_GOODS || parent.getType() == HongBaoV2.TYPE_ZIGOU)) {// 涓嶆槸瓒呯骇浼氬憳鐨勮嚜璐�/鍒嗕韩鎵嶈ˉ璐� + boolean isShare = (parent.getType() == HongBaoV2.TYPE_SHARE_GOODS); List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(sourceType, orderId); if (orderList == null || orderList.size() == 0) @@ -249,7 +177,7 @@ // 璁$畻濂栧姳閲� for (Iterator<Long> its = uidHongBaoMap.keySet().iterator(); its.hasNext();) { Long uid = its.next(); - UserLevelEnum userLevel = userLevelManager.getUserLevel(uid); + UserLevelEnum userLevel = userLevelManager.getUserLevel(uid, placeOrderTime); int type = uidHongBaoMap.get(uid); if (type == HongBaoV2.TYPE_YIJI || type == HongBaoV2.TYPE_ERJI) { @@ -273,7 +201,7 @@ else orderSubsidy.setLevel(InviteOrderSubsidy.LEVEL_TWO); // 浼氬憳鎵嶈兘琛ヨ创 - if (userLevel != UserLevelEnum.daRen) + if (userLevel != UserLevelEnum.daRen) { try { addOrderSubsidy(orderSubsidy); } catch (OrderTeamRewardException e) { @@ -281,6 +209,11 @@ } catch (CommonOrderException e) { throw new InviteOrderSubsidyException(e.getCode(), e.getMsg()); } + // 鍒嗕韩璧氫笉鑳戒娇鐢ㄨ繑鍒╁鍔卞埜锛屼笉鐢ㄧ瓑寰�5澶� + if (isShare) { + validByOrderIdAndSourceType(orderId, sourceType); + } + } } } } @@ -328,8 +261,8 @@ InviteOrderSubsidy update = new InviteOrderSubsidy(subsidy.getId()); update.setState(InviteOrderSubsidy.STATE_INVALID); update.setUpdateTime(new Date()); + update.setInValidTime(new Date()); inviteOrderSubsidyMapper.updateByPrimaryKeySelective(update); - orderTeamRewardService.invalidByOrderIdAndSourceType(subsidy.getId()); } } } @@ -359,9 +292,9 @@ InviteOrderSubsidy update = new InviteOrderSubsidy(subsidy.getId()); update.setState(InviteOrderSubsidy.STATE_VALID); update.setUpdateTime(new Date()); + update.setValidTime(new Date()); update.setPreGetTime(preGetTime); inviteOrderSubsidyMapper.updateByPrimaryKeySelective(update); - orderTeamRewardService.validByOrderIdAndSourceType(subsidy.getId(), preGetTime); } } } @@ -375,4 +308,33 @@ inviteOrderSubsidyMapper.updateByPrimaryKeySelective(orderSubsidy); } + + @Override + public BigDecimal sumRecievedMoneyByUid(long uid, Integer level) { + BigDecimal money = inviteOrderSubsidyMapper.sumRecievedMoneyByUid(uid, level); + if (money == null) { + money = new BigDecimal(0); + } + return money; + } + + @Override + public BigDecimal sumValidMoneyByUidAndDate(long uid, Integer day, Integer level) { + BigDecimal money = inviteOrderSubsidyMapper.sumValidMoneyByUidAndDate(uid, day, level); + if (money == null) { + money = new BigDecimal(0); + } + return money; + } + + @Override + public BigDecimal sumMoneyByUidAndDateAndState(long uid, Integer day, Integer level, Integer state) { + BigDecimal money = inviteOrderSubsidyMapper.sumMoneyByUidAndDateAndState(uid, day, level, state); + if (money == null) { + money = new BigDecimal(0); + } + return money; + } + + } -- Gitblit v1.8.0