From aa43ebe703d3b28520a8b1e4b852b8beb957c5ca Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期一, 20 四月 2020 14:21:25 +0800
Subject: [PATCH] 京东订单爬单规则修改

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderMoneySettleServiceImpl.java |   71 ++++++++---------------------------
 1 files changed, 16 insertions(+), 55 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 daa1f7a..d1b375d 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
@@ -2,7 +2,6 @@
 
 import java.math.BigDecimal;
 import java.util.ArrayList;
-import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -322,8 +321,7 @@
 
 	@Transactional(rollbackFor = Exception.class)
 	@Override
-	public void shareSettleTB(Long uid) throws OrderMoneySettleException {
-		Date maxPregetTime = new Date();
+	public void shareSettleTB(Long uid, Date maxPregetTime) throws OrderMoneySettleException {
 		/**
 		 * 澶勭悊鍒嗕韩璧�
 		 */
@@ -369,8 +367,7 @@
 
 	@Transactional(rollbackFor = Exception.class)
 	@Override
-	public void shareSettleJD(Long uid) throws OrderMoneySettleException {
-		Date maxPregetTime = new Date();
+	public void shareSettleJD(Long uid, Date maxPregetTime) throws OrderMoneySettleException {
 		/**
 		 * 澶勭悊鍒嗕韩璧�
 		 */
@@ -411,8 +408,7 @@
 
 	@Transactional(rollbackFor = Exception.class)
 	@Override
-	public void shareSettlePDD(Long uid) throws OrderMoneySettleException {
-		Date maxPregetTime = new Date();
+	public void shareSettlePDD(Long uid, Date maxPregetTime) throws OrderMoneySettleException {
 		/**
 		 * 澶勭悊鍒嗕韩璧�
 		 */
@@ -669,7 +665,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) {
@@ -693,7 +688,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
@@ -710,22 +704,8 @@
 		if (sharemoney.compareTo(new BigDecimal(0)) > 0) {
 			// 娣诲姞鏂扮増璇︽儏璁板綍
 			try {
-				// 璁$畻鏈湀鐨勬湁鏁堣鍗曪紝澶辨晥璁㈠崟锛岀淮鏉冭鍗�
-				Calendar ca = Calendar.getInstance();
-
-				Date maxDate = new Date(TimeUtil
-						.convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
-				ca.add(Calendar.MONTH, -1);
-
-				Date minDate = new Date(TimeUtil
-						.convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
-				long validCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_JS,
-						minDate, maxDate, Constant.SOURCE_TYPE_TAOBAO);
-				long weiQuanCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
-						minDate, maxDate, Constant.SOURCE_TYPE_TAOBAO);
-
 				UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShare(uid, Constant.SOURCE_TYPE_TAOBAO,
-						(int) validCount, (int) weiQuanCount, sharemoney, new Date());
+						sharemoney, new Date());
 				// 娣诲姞璧勯噾
 				userMoneyService.addUserMoney(uid, sharemoney, userMoneyDetail);
 
@@ -742,9 +722,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);
@@ -755,7 +734,8 @@
 		// 鎵�鏈夌殑杩斿埄鍒拌处绾㈠寘ID
 		for (Long hongBaoId : recieveHongBaoIds) {
 			try {
-				HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId);
+				if (Constant.ENABLE_MQ)
+					HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId);
 			} catch (Exception e) {
 				LogHelper.errorDetailInfo(e);
 			}
@@ -774,7 +754,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) {
@@ -795,9 +774,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,22 +785,8 @@
 		if (sharemoney.compareTo(new BigDecimal(0)) > 0) {
 			// 娣诲姞鏂扮増璇︽儏璁板綍
 			try {
-				// 璁$畻鏈湀鐨勬湁鏁堣鍗曪紝澶辨晥璁㈠崟锛岀淮鏉冭鍗�
-				Calendar ca = Calendar.getInstance();
-
-				Date maxDate = new Date(TimeUtil
-						.convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
-				ca.add(Calendar.MONTH, -1);
-
-				Date minDate = new Date(TimeUtil
-						.convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
-				long validCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_JS,
-						minDate, maxDate, sourceType);
-				long weiQuanCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
-						minDate, maxDate, sourceType);
-
-				UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShare(uid, sourceType, (int) validCount,
-						(int) weiQuanCount, sharemoney, new Date());
+				UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShare(uid, sourceType, sharemoney,
+						new Date());
 				// 娣诲姞璧勯噾
 				userMoneyService.addUserMoney(uid, sharemoney, userMoneyDetail);
 
@@ -840,10 +802,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);
@@ -851,7 +811,8 @@
 		// 鎵�鏈夌殑杩斿埄鍒拌处绾㈠寘ID
 		for (Long hongBaoId : recieveHongBaoIds) {
 			try {
-				HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId);
+				if (Constant.ENABLE_MQ)
+					HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId);
 			} catch (Exception e) {
 				LogHelper.errorDetailInfo(e);
 			}
@@ -868,9 +829,9 @@
 	 */
 	@Transactional(rollbackFor = Exception.class)
 	@Override
-	public void inviteSubsidySettle(Long uid, String taskKey,Date maxPreGetTime)
+	public void inviteSubsidySettle(Long uid, String taskKey, Date maxPreGetTime)
 			throws OrderMoneySettleException, TeamEincomeRecordException, ParamsException {
-		teamSubsidyManager.addToTeamEincome(uid, taskKey,maxPreGetTime);
+		teamSubsidyManager.addToTeamEincome(uid, taskKey, maxPreGetTime);
 	}
 
 	private String getTaskKey(Long uid) {

--
Gitblit v1.8.0