From c3f10da9aa6f4d8fecccc1c9574567ee0766ab48 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期六, 28 十二月 2019 10:09:00 +0800 Subject: [PATCH] 学院 --- fanli/src/main/java/com/yeshi/fanli/service/manger/HongBaoV2AddManager.java | 59 ++++++++++++++++++----------------------------------------- 1 files changed, 18 insertions(+), 41 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/manger/HongBaoV2AddManager.java b/fanli/src/main/java/com/yeshi/fanli/service/manger/HongBaoV2AddManager.java index daa791b..ac0b95a 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/manger/HongBaoV2AddManager.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/manger/HongBaoV2AddManager.java @@ -28,7 +28,6 @@ import com.yeshi.fanli.entity.order.HongBaoOrder; import com.yeshi.fanli.exception.order.HongBaoException; import com.yeshi.fanli.exception.user.UserAccountException; -import com.yeshi.fanli.exception.user.UserInfoException; import com.yeshi.fanli.service.inter.order.CommonOrderService; import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; import com.yeshi.fanli.service.inter.order.msg.UserOrderMsgNotificationService; @@ -78,32 +77,6 @@ @Resource private UserVIPInfoService userVIPInfoService; - // 淇濆瓨绾㈠寘 - public void saveHongBao1(CommonOrder commonOrder, int commonOrderType) throws HongBaoException, UserInfoException { - // 鏌ヨ涓�2绾х殑淇℃伅 - long uid = commonOrder.getUserInfo().getId(); - UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid); - if (user == null) - throw new UserInfoException(1, "鐢ㄦ埛涓嶅瓨鍦�"); - - UserInfo lastUser = threeSaleSerivce.getBoss(uid); - UserInfo superLastUser = null; - if (lastUser != null) { - lastUser = userInfoService.selectAvailableByPrimaryKey(lastUser.getId()); - if (lastUser != null) - superLastUser = threeSaleSerivce.getBoss(lastUser.getId()); - if (superLastUser != null) - superLastUser = userInfoService.selectAvailableByPrimaryKey(superLastUser.getId()); - } - - if (commonOrderType == CommonOrder.ORDER_TYPE_ZIGOU) { - // 淇濆瓨绾㈠寘淇℃伅 - - } else if (commonOrderType == CommonOrder.ORDER_TYPE_SHARE) { - - } - } - /** * 娣诲姞绾㈠寘淇℃伅 * @@ -123,7 +96,6 @@ boolean hasAdd = false; boolean hasUpdate = false; Set<Integer> stateSet = new HashSet<>();// 璁㈠崟鐘舵�丼et - boolean isVIP = userVIPInfoService.isVIP(commonOrderList.get(0).getUserInfo().getId()); for (CommonOrder commonOrder : commonOrderList) { stateSet.add(commonOrder.getState()); goodsCount += commonOrder.getCount(); @@ -131,7 +103,7 @@ throw new HongBaoException(1, "璁㈠崟淇℃伅涓嶅畬鏁�"); HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId()); if (hongBaoOrder == null) { - saveHongBao(commonOrder, type, isVIP, notificationMap); + saveHongBao(commonOrder, type, notificationMap); hasAdd = true; } else { boolean update = updateHongBao(hongBaoOrder, commonOrder, type, notificationMap); @@ -241,7 +213,7 @@ return CommonOrder.STATE_SX; } - @Transactional + @Transactional(rollbackFor = Exception.class) private boolean updateHongBao(HongBaoOrder hongBaoOrder, CommonOrder commonOrder, int type, Map<Integer, HongBaoOrder> notificationMap) throws HongBaoException, UserAccountException { System.out.println(commonOrder.getOrderNo()); @@ -365,7 +337,7 @@ HongBaoV2.TYPE_YIJI, MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstRate.divide(new BigDecimal(100)))); if (firstHongbao != null) - addInviteHongBao(firstHongbao, notificationMap, commonOrder); + addInviteHongBao(firstHongbao, null, notificationMap, commonOrder); } boss = threeSaleSerivce.getBoss(boss.getId()); if (boss != null) { @@ -380,7 +352,7 @@ HongBaoV2.TYPE_ERJI, MoneyBigDecimalUtil.mul(hongBao.getMoney(), secondRate.divide(new BigDecimal(100)))); if (secondHongbao != null) - addInviteHongBao(secondHongbao, notificationMap, commonOrder); + addInviteHongBao(secondHongbao, null, notificationMap, commonOrder); } } } @@ -457,9 +429,11 @@ return true; } - @Transactional - private void saveHongBao(CommonOrder commonOrder, int type, boolean vip, Map<Integer, HongBaoOrder> notificationMap) + @Transactional(rollbackFor = Exception.class) + private void saveHongBao(CommonOrder commonOrder, int type, Map<Integer, HongBaoOrder> notificationMap) throws HongBaoException, UserAccountException { + + boolean vip = commonOrder.getUrank() != null && commonOrder.getUrank() == 100; if (type == HongBaoV2.TYPE_ZIGOU) {// 鑾峰彇鑷喘鐨勮繑鍒╂瘮渚� BigDecimal fanliRate = hongBaoManageService .getRate(new OrderHongBaoRateParams(0, type, false, vip, commonOrder.getThirdCreateTime())); @@ -512,7 +486,7 @@ HongBaoV2 firstHongbao = createInviteHongBao(boss.getId(), hongBao, commonOrder, HongBaoV2.TYPE_YIJI, MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstRate.divide(new BigDecimal(100)))); - addInviteHongBao(firstHongbao, notificationMap, commonOrder); + addInviteHongBao(firstHongbao, null, notificationMap, commonOrder); // 鎻掑叆浜岀骇瀛愮孩鍖� boss = threeSaleSerivce.getBoss(boss.getId()); @@ -524,7 +498,7 @@ HongBaoV2 secondHongbao = createInviteHongBao(boss.getId(), hongBao, commonOrder, HongBaoV2.TYPE_ERJI, MoneyBigDecimalUtil.mul(hongBao.getMoney(), secondRate.divide(new BigDecimal(100)))); - addInviteHongBao(secondHongbao, notificationMap, commonOrder); + addInviteHongBao(secondHongbao, null, notificationMap, commonOrder); } } @@ -543,7 +517,7 @@ if (shareRate.compareTo(new BigDecimal(0)) <= 0) return; - HongBaoV2 hongBao = createShareHongBao(commonOrder, shareRate,vip); + HongBaoV2 hongBao = createShareHongBao(commonOrder, shareRate, vip); if (hongBao == null) return; addFanLiOrShareHongBao(hongBao, commonOrder, notificationMap); @@ -560,7 +534,7 @@ HongBaoV2.TYPE_SHARE_YIJI, MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstLevelRate.divide(new BigDecimal(100)))); - addInviteHongBao(firstHongbao, notificationMap, commonOrder); + addInviteHongBao(firstHongbao, hongBao.getUserInfo().getNickName(), notificationMap, commonOrder); // 浜岀骇鍒嗕韩璧� boss = threeSaleSerivce.getBoss(boss.getId()); @@ -572,7 +546,7 @@ HongBaoV2 secondChild = createInviteHongBao(boss.getId(), hongBao, commonOrder, HongBaoV2.TYPE_SHARE_ERJI, MoneyBigDecimalUtil.mul(hongBao.getMoney(), secondLevelRate.divide(new BigDecimal(100)))); - addInviteHongBao(secondChild, notificationMap, commonOrder); + addInviteHongBao(secondChild, null, notificationMap, commonOrder); } } } @@ -610,8 +584,8 @@ * @param notificationMap * @param commonOrder */ - private void addInviteHongBao(HongBaoV2 child, Map<Integer, HongBaoOrder> notificationMap, - CommonOrder commonOrder) { + private void addInviteHongBao(HongBaoV2 child, String parentHongBaoUserName, + Map<Integer, HongBaoOrder> notificationMap, CommonOrder commonOrder) { if (child != null) { hongBaoV2Mapper.insertSelective(child); // 鐢ㄦ埛閫氱煡 @@ -619,6 +593,9 @@ HongBaoV2 tempHongBao = new HongBaoV2(child.getId()); tempHongBao.setUserInfo(child.getUserInfo()); tempHongBao.setMoney(child.getMoney()); + if (child.getType() == HongBaoV2.TYPE_SHARE_YIJI) + tempHongBao.setBeizhu(parentHongBaoUserName); + CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId()); tempCommonOrder.setPayment(commonOrder.getPayment()); notificationMap.put(child.getType(), new HongBaoOrder(tempCommonOrder, tempHongBao)); -- Gitblit v1.8.0