From 2a93320d3adf8c72ea127df59d0bdd043917dd79 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 15 十一月 2019 15:12:11 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 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 42f0976..6c85258 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
@@ -2560,7 +2560,10 @@
 	@RequestSerializableByKeyService(key = "#uid")
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public void triggerFreeCouponActivate(Long uid) {
+	public void triggerFreeCouponActivate(Long uid, String orderNo, Integer source) {
+		if (uid == null || source == null || StringUtil.isNullOrEmpty(orderNo)) 
+			return;
+		
 		UserSystemCoupon coupon = userSystemCouponMapper.getNeedActivateCouponByType(uid,
 				CouponTypeEnum.freeCoupon.name());
 		if (coupon == null)
@@ -2568,6 +2571,20 @@
 
 		Long id = coupon.getId();
 		UserSystemCouponActivate couponActivate = userSystemCouponActivateService.selectForUpdate(id);
+		if (couponActivate == null)
+			return;
+		
+		// 楠岃瘉鍚岃鍗曟槸鍚﹀瓨鍦�
+		String key = orderNo + "_" + source;
+		String ordernos = couponActivate.getOrdernos();
+		if (!StringUtil.isNullOrEmpty(ordernos)) {
+			String[] array = ordernos.split(",");
+			if (array != null)
+				for (int i= 0; i < array.length; i ++) {
+					if (array[i].equals(key))
+						return;
+				}
+		}
 
 		// 婵�娲绘暟閲�
 		boolean result = false;
@@ -2581,10 +2598,17 @@
 			state = UserSystemCouponActivate.STATE_END;
 		}
 
+		if (StringUtil.isNullOrEmpty(ordernos)) {
+			ordernos = key;
+		} else {
+			ordernos = ordernos + "," + key;
+		}
+		
 		UserSystemCouponActivate updateActivate = new UserSystemCouponActivate();
 		updateActivate.setId(id);
 		updateActivate.setState(state);
 		updateActivate.setCount(count);
+		updateActivate.setOrdernos(ordernos);
 		updateActivate.setUpdateTime(new Date());
 		userSystemCouponActivateService.updateByPrimaryKeySelective(updateActivate);
 

--
Gitblit v1.8.0