From 0272ffc3e7037e10c2ddadeea6c597850903878f Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 30 八月 2019 14:34:00 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java |   59 ++++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 38 insertions(+), 21 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
index d8024a5..bcd4059 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -10,7 +10,9 @@
 
 import javax.annotation.Resource;
 
+import org.springframework.context.annotation.Lazy;
 import org.springframework.core.task.TaskExecutor;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.yeshi.utils.DateUtil;
@@ -105,6 +107,7 @@
 	private UserSystemCouponRecordService userSystemCouponRecordService;
 
 	@Resource
+	@Lazy
 	private HongBaoV2Service hongBaoV2Service;
 
 	@Resource
@@ -141,6 +144,7 @@
 	private CommonOrderCountService commonOrderCountService;
 	
 	@Resource
+	@Lazy
 	private PushCouponService pushCouponService;
 	
 	@Resource
@@ -1754,9 +1758,11 @@
 					// 鍙娇鐢ㄣ�� 鍙禒閫�
 					userCouponVO.setState(UserSystemCoupon.STATE_USE_GIVE);
 
-					// 杩斿埄濂栧姳鍒�- 璺宠浆鑷冲凡鍒拌处-宸叉敹璐�
-					jumpLink.put("state", "2");
-					jumpLink.put("type", "1");
+					// 璁㈠崟鍒楄〃
+					jumpLink.put("state", "2"); // 宸叉敹璐�
+					jumpLink.put("type", "1");  // 杩斿埄璁㈠崟
+					jumpLink.put("title", "杩斿埄璁㈠崟"); // 鏍囬鍚�
+					jumpLink.put("goodsType", "0"); // 璁㈠崟鏉ユ簮
 					jumpBtn = new HashMap<String, Object>();
 					jumpBtn.put("params", jumpLink);
 					jumpBtn.put("jumpDetail", jumpDetailV2Service.getByTypeCache("order_screen_list"));
@@ -2145,16 +2151,10 @@
 		userSystemCoupon.setUseTime(null);
 		userSystemCoupon.setState(UserSystemCoupon.STATE_CAN_USE);
 		userSystemCoupon.setUpdateTime(new Date());
-		userSystemCouponMapper.updateByPrimaryKey(userSystemCoupon);
+		userSystemCouponMapper.updateByPrimaryKeySelective(userSystemCoupon);
 		
 		// 浣跨敤璁板綍
 		if  (record != null) {
-			UserSystemCouponRecord useRecordUpdate = new UserSystemCouponRecord();
-			useRecordUpdate.setId(record.getId());
-			useRecordUpdate.setState(UserSystemCouponRecord.STATE_WAIT_TIME_OUT);
-			useRecordUpdate.setUpdateTime(new Date());
-			userSystemCouponRecordService.updateByPrimaryKeySelective(useRecordUpdate);
-			
 			if (CouponTypeEnum.welfareFreeCoupon.name().equals(record.getCouponType())) {
 				userOtherMsgNotificationService.welfareCouponDrawBack(userSystemCoupon, record.getOrderNo());
 			} else if (CouponTypeEnum.freeCoupon.name().equals(record.getCouponType())) {
@@ -2166,27 +2166,44 @@
 	}
 	
 	
+	@Async()
 	@Transactional
 	@Override
 	public void sendBackTimeOutCoupon(Long uid) {
-		// 瓒呰繃10鍒嗛挓   鏈鍖归厤鐨勫埜
-		List<UserSystemCouponRecord> list = userSystemCouponRecordService.getCouponByUsingTimeOut(uid, 600L);
-		if (list == null || list.size() == 0) {
+		// 鍟嗗搧鐩稿叧鐨勫埜
+		List<SystemCoupon> couponList = systemCouponService.getGoodsCouponList();
+		if (couponList == null || couponList.size() == 0) {
 			return;
 		}
 
-		for (UserSystemCouponRecord couponRecord : list) {
-			// 鏇存柊鐘舵�侊細鍖归厤瓒呮椂
-			couponRecord.setState(UserSystemCouponRecord.STATE_WAIT_TIME_OUT);
-			couponRecord.setUpdateTime(new Date());
-			userSystemCouponRecordService.updateByPrimaryKeySelective(couponRecord);
+		List<Long> list = new ArrayList<Long>();
+		for (SystemCoupon systemCoupon: couponList) {
+			list.add(systemCoupon.getId());
+		}
+		
+		// 瓒呰繃10鍒嗛挓   鏈鍖归厤鐨勫厤鍗曞埜
+		List<UserSystemCoupon> listUserCoupon = userSystemCouponMapper.getCouponByUsingTimeOut(uid, list, 600L);
+		if (listUserCoupon == null || listUserCoupon.size() == 0) {
+			return;
+		}
 
+		for (UserSystemCoupon userCoupon : listUserCoupon) {
 			// 鐘舵�佸垵濮嬪寲
-			UserSystemCoupon userSystemCoupon = couponRecord.getUserSystemCoupon();
+			UserSystemCoupon userSystemCoupon = new UserSystemCoupon();
+			userSystemCoupon.setId(userCoupon.getId());
 			userSystemCoupon.setState(UserSystemCoupon.STATE_CAN_USE);
 			userSystemCoupon.setUseTime(null);
 			userSystemCoupon.setUpdateTime(new Date());
-			userSystemCouponMapper.updateByPrimaryKey(userSystemCoupon);
+			userSystemCouponMapper.updateByPrimaryKeySelective(userSystemCoupon);
+			
+			UserSystemCouponRecord record = userSystemCouponRecordService.getNearByUserCouponId(userCoupon.getId());
+			if (record != null) {
+				UserSystemCouponRecord couponRecord = new UserSystemCouponRecord();
+				couponRecord.setId(record.getId());
+				couponRecord.setUpdateTime(new Date());
+				couponRecord.setState(UserSystemCouponRecord.STATE_WAIT_TIME_OUT);
+				userSystemCouponRecordService.updateByPrimaryKeySelective(couponRecord);
+			}
 		}
 	}
 
@@ -2241,7 +2258,7 @@
 			userSystemCoupon.setUseTime(null);
 			userSystemCoupon.setState(UserSystemCoupon.STATE_CAN_USE);
 			userSystemCoupon.setUpdateTime(new Date());
-			userSystemCouponMapper.updateByPrimaryKey(userSystemCoupon);
+			userSystemCouponMapper.updateByPrimaryKeySelective(userSystemCoupon);
 			
 			// 浣跨敤璁板綍
 			UserSystemCouponRecord useRecord = userSystemCouponRecordService.getNearByUserCouponId(couponId);

--
Gitblit v1.8.0