From 891d1535999075a354ff1014ae5dbede5cfddc29 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 23 五月 2020 19:12:52 +0800
Subject: [PATCH] 唯品会订单,苏宁相关代码添加

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderMoneySettleServiceImpl.java |   77 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 74 insertions(+), 3 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 0bb8f33..c7b3011 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
@@ -107,7 +107,6 @@
 	@Resource
 	private TeamRewardManager teamRewardManager;
 
-
 	// 涓嬬骇琚皝绂侊紝绾㈠寘澶辨晥
 	private void invalidHongBaoForbidden(Long id) {
 		HongBaoV2 updateHongBaoV2 = new HongBaoV2(id);
@@ -318,6 +317,70 @@
 
 	@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--;
+						}
+					}
+				}
+			}
+		}
+
+		// 閭�璇疯禋鍒拌处浜嬪姟娑堟伅
+		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 shareSettleTB(Long uid, Date maxPregetTime) throws OrderMoneySettleException {
 		/**
 		 * 澶勭悊鍒嗕韩璧�
@@ -406,10 +469,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鐨勫垎浜禋璁㈠崟
@@ -815,7 +887,6 @@
 			}
 		}
 	}
-
 
 	private String getTaskKey(Long uid) {
 		return uid + "-" + UUID.randomUUID().toString();

--
Gitblit v1.8.0