From 3e4ef41ffacd7f5fda2e81c3810cd11a6375b83c Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期一, 15 六月 2020 16:32:35 +0800 Subject: [PATCH] 好单库转链支持 --- fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderMoneySettleServiceImpl.java | 127 ++++++++++++++++++++++++++++++----------- 1 files changed, 92 insertions(+), 35 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 ed03683..f9fe5fb 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 @@ -53,7 +53,6 @@ import com.yeshi.fanli.service.inter.order.OrderMoneySettleService; import com.yeshi.fanli.service.inter.user.UserSystemCouponService; import com.yeshi.fanli.service.manger.order.TeamRewardManager; -import com.yeshi.fanli.service.manger.order.TeamSubsidyManager; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.TimeUtil; import com.yeshi.fanli.util.cmq.HongBaoRecieveCMQManager; @@ -108,9 +107,6 @@ @Resource private TeamRewardManager teamRewardManager; - @Resource - private TeamSubsidyManager teamSubsidyManager; - // 涓嬬骇琚皝绂侊紝绾㈠寘澶辨晥 private void invalidHongBaoForbidden(Long id) { HongBaoV2 updateHongBaoV2 = new HongBaoV2(id); @@ -159,6 +155,9 @@ } } } + + if(hongBaoList.size()==0) + return; String taskKey = getTaskKey(uid); @@ -228,6 +227,9 @@ } } } + + if(hongBaoList.size()==0) + return; // 閭�璇疯禋鍒拌处浜嬪姟娑堟伅 @@ -294,6 +296,76 @@ } } } + + if(hongBaoList.size()==0) + return; + + // 閭�璇疯禋鍒拌处浜嬪姟娑堟伅 + String taskKey = getTaskKey(uid); + TeamRewardPreRecieveMQMsg mqMsg = new TeamRewardPreRecieveMQMsg(taskKey, uid, sourceType, maxPregetTime, + new Date()); + Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.teamRewardPreRecieved, mqMsg); + msg.setKey(taskKey); + // 娣诲姞浜嬪姟娑堟伅 + try { + orderTransactionProducer.send(msg, new LocalTransactionExecuter() { + @Override + public TransactionStatus execute(Message arg0, Object arg1) { + try { + fanliInvite(hongBaoList, uid, sourceType, taskKey, maxPregetTime); + } catch (Exception e) { + return TransactionStatus.RollbackTransaction; + } + return TransactionStatus.CommitTransaction; + } + }, null); + } catch (Exception e) { + LogHelper.mqError(e.getMessage(), msg.getTopic(), msg.getTag(), new Gson().toJson(mqMsg)); + } + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void inviteSettleVipShop(Long uid, Date maxPregetTime) throws OrderMoneySettleException { + // 鏌ヨUID鐨勪竴浜岀骇閭�璇疯禋 + int sourceType = Constant.SOURCE_TYPE_VIP; + List<Integer> types = new ArrayList<>(); + types.add(HongBaoV2.TYPE_YIJI); + types.add(HongBaoV2.TYPE_ERJI); + types.add(HongBaoV2.TYPE_SHARE_YIJI); + types.add(HongBaoV2.TYPE_SHARE_ERJI); + long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid, sourceType, maxPregetTime); + List<HongBaoV2> hongBaoList = new ArrayList<>(); + // 1000鏉℃暟鎹负1椤� + int page = (int) (count % 1000 == 0 ? count / 1000 : count / 1000 + 1); + for (int i = 0; i < page; i++) { + List<HongBaoV2> tempHongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, sourceType, + maxPregetTime, i * 1000, 1000); + if (tempHongBaoList != null && tempHongBaoList.size() > 0) + hongBaoList.addAll(tempHongBaoList); + } + + for (int i = 0; i < hongBaoList.size(); i++) { + HongBaoV2 item = hongBaoList.get(i); + if (item != null && item.getParent() != null) { + if (item != null) { + HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(item.getParent().getId()); + if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) { + CommonOrder co = hongBaoOrder.getCommonOrder(); + // 涓婄骇鐢ㄦ埛涓嶆槸姝e父鐢ㄦ埛锛岃鍗曞潎涓嶈兘鍒拌处 + UserInfo userInfo = userInfoMapper.selectAvailableByPrimaryKey(co.getUserInfo().getId()); + if (userInfo == null || userInfo.getState() != UserInfo.STATE_NORMAL) { + invalidHongBaoForbidden(item.getId()); + hongBaoList.remove(i); + i--; + } + } + } + } + } + + if(hongBaoList.size()==0) + return; // 閭�璇疯禋鍒拌处浜嬪姟娑堟伅 String taskKey = getTaskKey(uid); @@ -409,10 +481,19 @@ @Transactional(rollbackFor = Exception.class) @Override public void shareSettlePDD(Long uid, Date maxPregetTime) throws OrderMoneySettleException { + shareSettleVipShop(Constant.SOURCE_TYPE_PDD, uid, maxPregetTime); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void shareSettleVipShop(Long uid, Date maxPregetTime) throws OrderMoneySettleException { + shareSettleVipShop(Constant.SOURCE_TYPE_VIP, uid, maxPregetTime); + } + + private void shareSettleVipShop(int sourceType, Long uid, Date maxPregetTime) throws OrderMoneySettleException { /** * 澶勭悊鍒嗕韩璧� */ - int sourceType = Constant.SOURCE_TYPE_PDD; List<Integer> types = new ArrayList<>(); // 鏌ヨUID鐨勫垎浜禋璁㈠崟 @@ -665,7 +746,6 @@ List<Long> hbIdList = new ArrayList<>(); Set<String> drawBackOrders = new HashSet<String>(); List<Long> recieveHongBaoIds = new ArrayList<>(); - int shareGoodsCount = 0; Set<String> shareOrders = new HashSet<>(); for (HongBaoV2 hongBao : hongBaoList) { @@ -689,7 +769,6 @@ HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(hongBao.getId()); if (hongBaoOrder != null) { balanceTime = hongBaoOrder.getCommonOrder().getSettleTime(); - shareGoodsCount += hongBaoOrder.getCommonOrder().getCount(); } shareOrders.add(hongBaoOrder.getCommonOrder().getOrderNo()); if (balanceTime != null @@ -724,9 +803,8 @@ } // 鏂扮増閫氱煡 - userMoneyMsgNotificationService.shareOrderReceived(uid, Constant.SOURCE_TYPE_TAOBAO, shareOrders.size(), - shareGoodsCount, sharemoney, userInfoMapper.selectAvailableByPrimaryKey(uid).getMyHongBao(), null, - null); + userMoneyMsgNotificationService.shareOrderReceived(uid, Constant.SOURCE_TYPE_TAOBAO, sharemoney, + userInfoMapper.selectAvailableByPrimaryKey(uid).getMyHongBao(), new Date()); for (String orderId : drawBackOrders) taoBaoWeiQuanDrawBackService.doWeiQuanShare(orderId); @@ -757,7 +835,6 @@ BigDecimal sharemoney = new BigDecimal(0); List<Long> hbIdList = new ArrayList<>(); List<Long> recieveHongBaoIds = new ArrayList<>(); - int shareGoodsCount = 0; Set<String> shareOrders = new HashSet<>(); for (HongBaoV2 hongBao : hongBaoList) { @@ -778,9 +855,6 @@ hbIdList.add(hongBao.getId()); // 2018-08-05 杩囧悗鐨勮鍗曟墠澶勭悊缁存潈 HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(hongBao.getId()); - if (hongBaoOrder != null) { - shareGoodsCount += hongBaoOrder.getCommonOrder().getCount(); - } shareOrders.add(hongBaoOrder.getCommonOrder().getOrderNo()); } } @@ -809,10 +883,8 @@ } } - // 鏂扮増閫氱煡 - userMoneyMsgNotificationService.shareOrderReceived(uid, Constant.SOURCE_TYPE_TAOBAO, shareOrders.size(), - shareGoodsCount, sharemoney, userInfoMapper.selectAvailableByPrimaryKey(uid).getMyHongBao(), null, - null); + userMoneyMsgNotificationService.shareOrderReceived(uid, sourceType, sharemoney, + userInfoMapper.selectAvailableByPrimaryKey(uid).getMyHongBao(), new Date()); } hongBaoV2SettleTempService.addTemp(recieveHongBaoIds, key); @@ -820,27 +892,12 @@ // 鎵�鏈夌殑杩斿埄鍒拌处绾㈠寘ID for (Long hongBaoId : recieveHongBaoIds) { try { - if(Constant.ENABLE_MQ) - HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId); + if (Constant.ENABLE_MQ) + HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId); } catch (Exception e) { LogHelper.errorDetailInfo(e); } } - } - - /** - * 閭�璇疯ˉ璐寸粨绠� - * - * @param orderId - * @param sourceType - * @throws ParamsException - * @throws TeamEincomeRecordException - */ - @Transactional(rollbackFor = Exception.class) - @Override - public void inviteSubsidySettle(Long uid, String taskKey, Date maxPreGetTime) - throws OrderMoneySettleException, TeamEincomeRecordException, ParamsException { - teamSubsidyManager.addToTeamEincome(uid, taskKey, maxPreGetTime); } private String getTaskKey(Long uid) { -- Gitblit v1.8.0