From 9f56a3478708633de7e5f013901a4539b01b638c Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期二, 30 六月 2020 12:05:50 +0800
Subject: [PATCH] 订单结算时的红包

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/cloud/UserCloudServiceImpl.java |   73 ++++++++++++++++++++++++++++++++----
 1 files changed, 65 insertions(+), 8 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/cloud/UserCloudServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/cloud/UserCloudServiceImpl.java
index 4bbbb8a..141e421 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/cloud/UserCloudServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/cloud/UserCloudServiceImpl.java
@@ -14,6 +14,7 @@
 import org.yeshi.utils.BigDecimalUtil;
 import org.yeshi.utils.taobao.TbImgUtil;
 
+import com.alibaba.druid.support.logging.Log;
 import com.aliyun.openservices.ons.api.Message;
 import com.aliyun.openservices.ons.api.Producer;
 import com.yeshi.fanli.dao.mybatis.user.cloud.UserCloudMapper;
@@ -407,6 +408,7 @@
 	}
 
 	private void sendCircleByDynamic(Long uid, String id, int way) throws UserCloudException {
+		long time1= java.lang.System.currentTimeMillis();
 		UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
 		if (user == null)
 			throw new UserCloudException(1, "鐢ㄦ埛淇℃伅涓嶅瓨鍦�");
@@ -427,7 +429,11 @@
 
 		if (StringUtil.isNullOrEmpty(relationId))
 			throw new UserCloudException(2, "娣樺疂鏈巿鏉冿紝璇峰墠寰�\"鎴戠殑\"缁戝畾娣樺疂璐﹀彿");
+		
+		long time2= java.lang.System.currentTimeMillis();
+		LogHelper.test("sendCircleByDynamic淇濋獙璇佺敤鎴风姸鎬侊細" + (time2 - time1));
 
+		
 		// 楠岃瘉鏄惁寮�閫�
 		UserCloud userCloud = userCloudMapper.getValidByUid(uid);
 		if (userCloud == null)
@@ -441,6 +447,10 @@
 		if (StringUtil.isNullOrEmpty(wxId))
 			throw new UserCloudException(1003, "寰俊鍙蜂笉瀛樺湪锛岃鍏堝井淇$櫥褰�");
 
+		long time3= java.lang.System.currentTimeMillis();
+		LogHelper.test("sendCircleByDynamic楠岃瘉鏄惁婊¤冻寮�閫氾細" + (time3 - time2));
+
+		
 		// 楠岃瘉寮�鍚姸鎬�
 		List<UserCloudGroup> listGroup = userCloudGroupService.listByUid(uid);
 		if (listGroup == null || listGroup.size() == 0)
@@ -455,6 +465,9 @@
 		if (listOpen.size() == 0)
 			throw new UserCloudException(1005, "璇峰厛寮�鍚簯鍙戝崟缇ゅ姛鑳�");
 
+		long time4= java.lang.System.currentTimeMillis();
+		LogHelper.test("sendCircleByDynamic楠岃瘉鏄惁寮�鍚細" + (time4 - time3));
+		
 		// 楠岃瘉鍙戝湀鏄惁鍙
 		GoodsEvaluate evaluate = goodsEvaluateService.getById(id);
 		if (evaluate == null || evaluate.getState() == 0)
@@ -468,6 +481,9 @@
 		if (comments == null || comments.size() == 0)
 			throw new UserCloudException(1, "璇ュ唴瀹逛笉鑳借浆閾�");
 
+		long time5= java.lang.System.currentTimeMillis();
+		LogHelper.test("sendCircleByDynamic楠岃瘉鍙戝湀鍐呭鏄惁婊¤冻锛�" + (time5 - time4));
+		
 		// 妫�娴嬪井淇℃槸鍚︾櫥褰曠姸鎬�
 		if (!AitaokerApiUtil.onlineCheck(robotId)) {
 			// 閫氱煡鐧诲綍寰俊
@@ -476,6 +492,9 @@
 			throw new UserCloudException(1003, "寰俊宸叉帀绾匡紝闇�瑕侀噸鏂版壂鎻忎簩缁寸爜鐧诲綍");
 		}
 
+		long time6= java.lang.System.currentTimeMillis();
+		LogHelper.test("sendCircleByDynamic楠岃瘉鍙戞槸鍚︾櫥褰曪細" + (time6 - time5));
+		
 		boolean hasToken = false;
 		List<String> listComment = new ArrayList<>();
 		for (CommentInfo commentInfo : comments) {
@@ -527,6 +546,10 @@
 				listImg.add(imgInfo.getUrl());
 			}
 		}
+		
+		long time7= java.lang.System.currentTimeMillis();
+		LogHelper.test("sendCircleByDynamic鍙戝湀鍐呭缁勭粐杞摼锛�" + (time7 - time6));
+		
 
 		// 淇濆瓨鍙戦�佽褰�
 		UserCloudSendRecord sendRecord = new UserCloudSendRecord();
@@ -540,6 +563,10 @@
 		UserCloudSendRecord result = userCloudSendRecordService.save(sendRecord);
 		String pid = result.getId();
 
+		long time8= java.lang.System.currentTimeMillis();
+		LogHelper.test("sendCircleByDynamic淇濆瓨鍙戝湀璁板綍锛�" + (time8 - time7));
+		
+		
 		for (UserCloudGroup cloudGroup : listOpen) {
 			String title = evaluate.getTitle();
 
@@ -631,6 +658,10 @@
 			}
 			userCloudSendContentService.save(sendContent);
 		}
+		
+		long time9= java.lang.System.currentTimeMillis();
+		LogHelper.test("sendCircleByDynamic鎵ц鍙戝湀鑰楁椂锛�" + (time9 - time8));
+		
 	}
 
 	@Override
@@ -672,6 +703,8 @@
 
 	private void sendCircleByGoods(Long uid, Long goodsId, Integer goodsType, Long storeId, Long sellerId, int way)
 			throws UserCloudException {
+		long begainTime = java.lang.System.currentTimeMillis();
+		
 		// 楠岃瘉鏄惁鎺堟潈
 		UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
 		if (user == null)
@@ -694,11 +727,19 @@
 		if (StringUtil.isNullOrEmpty(relationId))
 			throw new UserCloudException(2, "娣樺疂鏈巿鏉冿紝璇峰墠寰�\"鎴戠殑\"缁戝畾娣樺疂璐﹀彿");
 
+		long time2 = java.lang.System.currentTimeMillis();
+		LogHelper.test("sendCircleByGoods楠岃瘉鐢ㄦ埛鑰楁椂锛�" + (time2 - begainTime));
+		
+		
 		// 楠岃瘉鏄惁寮�閫�
 		UserCloud userCloud = userCloudMapper.getValidByUid(uid);
 		if (userCloud == null)
 			throw new UserCloudException(1001, "浜戝彂鍗曞凡杩囨湡");
-
+		
+		long time3= java.lang.System.currentTimeMillis();
+		LogHelper.test("sendCircleByGoods楠岃瘉鏄惁寮�閫氾細" + (time3 - time2));
+		
+		long time4 = time3;
 		// 鍔犲叆鎴戠殑澶囬�夊簱
 		if (storeId == null) {
 			try {
@@ -710,6 +751,8 @@
 						+ "]鍘熷洜锛�" + e.getMsg());
 				throw new UserCloudException(1, "鍔犲叆浜戝彂鍗曞閫夊簱澶辫触");
 			}
+			time4= java.lang.System.currentTimeMillis();
+			LogHelper.test("sendCircleByGoods鍔犲叆澶囬�夊簱锛�" + (time4 - time3));
 		}
 
 		// 鑷�夊簱鍟嗗搧鏄惁鎵撳紑
@@ -736,6 +779,9 @@
 		if (listGroup == null || listGroup.size() == 0)
 			throw new UserCloudException(1003, "璇峰厛鐧诲綍寰俊");
 
+		long time5= java.lang.System.currentTimeMillis();
+		LogHelper.test("sendCircleByGoods楠岃瘉鏄惁缁戝畾寰俊锛�" + (time5 - time4));
+		
 		List<UserCloudGroup> listOpen = new ArrayList<>();
 		for (UserCloudGroup cloudGrou : listGroup) {
 			if (cloudGrou.getState()) {
@@ -754,6 +800,9 @@
 			throw new UserCloudException(1003, "寰俊宸叉帀绾匡紝闇�瑕侀噸鏂版壂鎻忎簩缁寸爜鐧诲綍");
 		}
 
+		long time6= java.lang.System.currentTimeMillis();
+		LogHelper.test("sendCircleByGoods楠岃瘉鏄惁鐧诲綍寰俊锛�" + (time6 - time5));
+		
 		// 淇濆瓨鍙戦�佽褰�
 		UserCloudSendRecord sendRecord = new UserCloudSendRecord();
 		sendRecord.setUid(uid);
@@ -770,6 +819,9 @@
 			sendRecord.setSendWay(UserCloudSendRecord.SEND_WAY_MANUAL);
 		}
 		UserCloudSendRecord result = userCloudSendRecordService.save(sendRecord);
+		
+		long time7= java.lang.System.currentTimeMillis();
+		LogHelper.test("sendCircleByGoods淇濆瓨鍙戦�佽褰曪細" + (time7 - time6));
 
 		try {
 			if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
@@ -792,7 +844,8 @@
 				record.setUpdateTime(new Date());
 				userCloudGoodsService.updateByPrimaryKeySelective(record);
 			}
-
+			long time8= java.lang.System.currentTimeMillis();
+			LogHelper.test("sendCircleByGoods鎵ц鍙戦�侊細" + (time8 - time7));
 		} catch (UserCloudException e) {
 			LogHelper.cloudInfo("autoSendCustomGoods - [uid:" + uid + " 搴搃d:" + storeId + "]鍘熷洜锛�" + e.getMsg());
 			// 鏇存柊鍙戝崟璁板綍
@@ -1147,7 +1200,7 @@
 	}
 
 	@Override
-	public void fixedTimeSend(List<GoodsEvaluate> listActivity, List<GoodsEvaluate> listGoods) {
+	public void fixedTimeSend(List<GoodsEvaluate> listActivity, List<GoodsEvaluate> listGoods, boolean timeLimit) {
 		if (listGoods == null && listActivity == null)
 			return;
 		// 涓�涓皬鏃朵箣鍓�
@@ -1166,11 +1219,15 @@
 					if (cloudManage == null || cloudManage.getOfficial() == null || !cloudManage.getOfficial()) {
 						continue;
 					}
-					// 鏄惁鍦ㄤ竴涓皬鏃跺唴宸插彂閫佽繃
-					UserCloudSendRecord last = userCloudSendRecordService.getLastByUid(uid, lastTime);
-					if (last != null)
-						continue;
-
+					
+					// 鏃堕棿闂撮殧锛氭槸鍚﹀湪涓�涓皬鏃跺唴宸插彂閫佽繃
+					if (timeLimit) {
+						UserCloudSendRecord last = userCloudSendRecordService.getLastByUid(uid, lastTime);
+						if (last != null)
+							continue;
+					}
+					
+				
 					String evaluateId = null;
 					// 娲诲姩
 					if (listActivity != null && listActivity.size() > 0) {

--
Gitblit v1.8.0