From d960fdbfe07a65cb80ccb764bfb15ce78ebfd84a Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 10 四月 2020 18:21:04 +0800 Subject: [PATCH] 消息修改 --- fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderMoneySettleServiceImpl.java | 106 +++------------------------------------------------- 1 files changed, 7 insertions(+), 99 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderMoneySettleServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderMoneySettleServiceImpl.java index ce58095..88133fd 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderMoneySettleServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderMoneySettleServiceImpl.java @@ -37,25 +37,21 @@ import com.yeshi.fanli.entity.order.HongBaoOrder; import com.yeshi.fanli.entity.order.HongBaoV2SettleTemp; import com.yeshi.fanli.entity.order.InviteOrderSubsidy; -import com.yeshi.fanli.entity.order.OrderTeamReward; import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder; import com.yeshi.fanli.exception.money.InviteOrderSubsidyDebtException; import com.yeshi.fanli.exception.money.OrderMoneySettleException; -import com.yeshi.fanli.exception.money.OrderTeamRewardDebtException; import com.yeshi.fanli.exception.money.UserMoneyDetailException; import com.yeshi.fanli.exception.order.TaoBaoWeiQuanException; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.hongbao.AccountDetailsHongBaoMapService; import com.yeshi.fanli.service.inter.hongbao.HongBaoV2SettleTempService; import com.yeshi.fanli.service.inter.money.InviteOrderSubsidyDebtService; -import com.yeshi.fanli.service.inter.money.OrderTeamRewardDebtService; import com.yeshi.fanli.service.inter.money.UserMoneyService; import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService; import com.yeshi.fanli.service.inter.money.tb.TaoBaoWeiQuanDrawBackService; import com.yeshi.fanli.service.inter.order.CommonOrderService; import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService; import com.yeshi.fanli.service.inter.order.OrderMoneySettleService; -import com.yeshi.fanli.service.inter.order.OrderTeamRewardService; import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService; import com.yeshi.fanli.service.inter.user.UserSystemCouponService; import com.yeshi.fanli.util.Constant; @@ -115,12 +111,6 @@ @Resource private HongBaoV2SettleTempService hongBaoV2SettleTempService; - - @Resource - private OrderTeamRewardService orderTeamRewardService; - - @Resource - private OrderTeamRewardDebtService orderTeamRewardDebtService; // 涓嬬骇琚皝绂侊紝绾㈠寘澶辨晥 private void invalidHongBaoForbidden(Long id) { @@ -344,6 +334,7 @@ Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.orderFanLiActual, mqMsg); String taskKey = getTaskKey(uid); msg.setKey(taskKey); + // 娣诲姞浜嬪姟娑堟伅 try { orderTransactionProducer.send(msg, new LocalTransactionExecuter() { @@ -552,8 +543,9 @@ UserInfo user = userInfoMapper.selectByPrimaryKey(uid); // 鏂扮増閫氱煡 + userMoneyMsgNotificationService.fanliOrderReceived(uid, orderId, sourceType, userGoodsCount.get(uid), money, - user.getMyHongBao()); + user.getMyHongBao(), orderList.get(0).getThirdCreateTime()); } // 閫氱煡鍏嶅崟鍒拌处 try { @@ -850,7 +842,8 @@ // 鏂扮増閫氱煡 userMoneyMsgNotificationService.shareOrderReceived(uid, Constant.SOURCE_TYPE_TAOBAO, shareOrders.size(), - shareGoodsCount, sharemoney, userInfoMapper.selectAvailableByPrimaryKey(uid).getMyHongBao()); + shareGoodsCount, sharemoney, userInfoMapper.selectAvailableByPrimaryKey(uid).getMyHongBao(), null, + null); for (String orderId : drawBackOrders) taoBaoWeiQuanDrawBackService.doWeiQuanShare(orderId); @@ -948,8 +941,8 @@ // 鏂扮増閫氱煡 userMoneyMsgNotificationService.shareOrderReceived(uid, Constant.SOURCE_TYPE_TAOBAO, shareOrders.size(), - shareGoodsCount, sharemoney, userInfoMapper.selectAvailableByPrimaryKey(uid).getMyHongBao()); - + shareGoodsCount, sharemoney, userInfoMapper.selectAvailableByPrimaryKey(uid).getMyHongBao(), null, + null); } hongBaoV2SettleTempService.addTemp(recieveHongBaoIds, key); @@ -1073,89 +1066,4 @@ return debtMoney; } - private BigDecimal kouKuanReward(List<OrderTeamReward> rewardList, BigDecimal debtMoney) { - BigDecimal average = debtMoney.divide(new BigDecimal(rewardList.size()), 2, RoundingMode.UP); - for (int i = 0; i < rewardList.size(); i++) { - OrderTeamReward sidy = rewardList.get(i); - BigDecimal subMoney = null; - if (average.compareTo(sidy.getMoney()) >= 0) { - subMoney = sidy.getMoney(); - } else { - subMoney = average; - } - if (subMoney.compareTo(debtMoney) > 0) - subMoney = debtMoney; - debtMoney = debtMoney.subtract(subMoney); - sidy.setMoney(sidy.getMoney().subtract(subMoney)); - - if (sidy.getMoney().compareTo(new BigDecimal(0)) == 0) { - rewardList.remove(i); - i--; - } - } - return debtMoney; - } - - @Transactional(rollbackFor = Exception.class) - @Override - public void orderTeamRewardSettle(Long uid) throws OrderMoneySettleException { - long count = orderTeamRewardService.countCanSettle(uid); - if (count <= 0) { - return; - } - int pageSize = 2000; - int page = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); - // 鏌ヨ鍑洪渶瑕佸埌璐︾殑濂栧姳 - List<OrderTeamReward> totalList = new ArrayList<>(); - for (int i = 0; i < page; i++) { - List<OrderTeamReward> list = orderTeamRewardService.listCanSettle(uid, i + 1, pageSize); - if (list != null && list.size() > 0) - totalList.addAll(list); - } - - if (totalList.size() > 0) { - BigDecimal debtMoney = orderTeamRewardDebtService.getTotalDebtMoney(uid); - BigDecimal originalDebtMoney = new BigDecimal(debtMoney.toString());// 鎬荤殑娆犳 - List<OrderTeamReward> copyRewardList = new ArrayList<>(); - copyRewardList.addAll(totalList); - while (debtMoney.compareTo(new BigDecimal(0)) > 0 && copyRewardList.size() > 0) {// 鏈夋瑺娆撅紝杩樻湁杩樼殑 - debtMoney = kouKuanReward(copyRewardList, debtMoney); - } - // 鍋胯繕娆犳閲戦 - BigDecimal repayMoney = originalDebtMoney.subtract(debtMoney); - BigDecimal bannce = null; - if (repayMoney.compareTo(new BigDecimal(0)) > 0) { - try { - bannce = orderTeamRewardDebtService.repayDebtByUid(uid, repayMoney); - // 鍓╀綑鐨勮ˉ璐撮噾棰� - } catch (OrderTeamRewardDebtException e) { - throw new OrderMoneySettleException(2, "杩樻寮傚父"); - } - } - if (bannce != null && bannce.compareTo(new BigDecimal(0)) > 0) { - // 濡傛灉鏈夎繕鍓╀笅鐨勯挶灏卞姞鍒扮涓�涓笂闈� - totalList.get(0).setMoney(totalList.get(0).getMoney().add(bannce)); - } - - BigDecimal totalMoney = new BigDecimal(0); - for (OrderTeamReward reward : totalList) { - orderTeamRewardService.settleById(reward.getId(), reward.getMoney()); - totalMoney = totalMoney.add(reward.getMoney()); - } - - // 瀹為檯鍒拌处濂栧姳 - UserMoneyDetail userMoneyDetail = null; - try { - userMoneyDetail = UserMoneyDetailFactory.createOrderTeamReward(uid, totalMoney, new Date()); - } catch (UserMoneyDetailException e) { - throw new OrderMoneySettleException(1, "璐︽埛鏄庣粏鏋勫缓鍑洪敊"); - } - // 娣诲姞璧勯噾 - userMoneyService.addUserMoney(uid, totalMoney, userMoneyDetail); - // 娣诲姞娑堟伅 - userMoneyMsgNotificationService.orderTeamReward(uid, new Date(), "绯荤粺鑷姩涓嬪彂", totalMoney, - userInfoMapper.selectAvailableByPrimaryKey(uid).getMyHongBao()); - } - - } } -- Gitblit v1.8.0