From 48934b8c3da5a6791d0805ff0c1d327da834cc2d Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期一, 29 六月 2020 16:39:18 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java |   35 ++++++++++++++++-------------------
 1 files changed, 16 insertions(+), 19 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 4a103ec..4f8aa92 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
@@ -1217,7 +1217,7 @@
 
 		// 鏌ヨ璁板綍
 		UserSystemCouponRecord record = userSystemCouponRecordService.getRecordByOrderNo(orderNo,
-				UserSystemCouponRecord.STATE_SUCCESS);
+				sourceType, UserSystemCouponRecord.STATE_SUCCESS);
 		if (record == null) {
 			throw new UserSystemCouponException(1, "娌℃湁浣跨敤鍒歌褰�");
 		}
@@ -1295,7 +1295,7 @@
 		}
 
 		// 鏌ヨ璁板綍
-		UserSystemCouponRecord record = userSystemCouponRecordService.getRecordByOrderNo(orderNo, null);
+		UserSystemCouponRecord record = userSystemCouponRecordService.getRecordByOrderNo(orderNo,sourceType, null);
 		if (record == null) {
 			throw new UserSystemCouponException(1, "娌℃湁浣跨敤鍒歌褰�");
 		}
@@ -1491,18 +1491,16 @@
 
 	@Transactional(rollbackFor = Exception.class)
 	@Override
-	public void updateStateByDrawback(String orderNo) throws Exception {
+	public void updateStateByDrawback(String orderNo, Integer sourceType) throws Exception {
 
 		if (orderNo == null || orderNo.trim().length() == 0) {
 			return;
 		}
 
-		UserSystemCouponRecord record = userSystemCouponRecordService.getRecordByOrderNo(orderNo, null);
+		UserSystemCouponRecord record = userSystemCouponRecordService.getRecordByOrderNo(orderNo,sourceType, null);
 		if (record == null) {
 			return;
 		}
-
-		record.setOrderNo(orderNo);
 		record.setUpdateTime(new Date());
 		record.setState(UserSystemCouponRecord.STATE_FAIL_DRAWBACK);
 		userSystemCouponRecordService.updateByPrimaryKeySelective(record);
@@ -1513,18 +1511,15 @@
 
 	@Transactional(rollbackFor = Exception.class)
 	@Override
-	public void updateStateByArrivalAccount(String orderNo) throws Exception {
-
+	public void updateStateByArrivalAccount(String orderNo, Integer sourceType) throws Exception {
 		if (orderNo == null || orderNo.trim().length() == 0) {
 			return;
 		}
 
-		UserSystemCouponRecord record = userSystemCouponRecordService.getRecordByOrderNo(orderNo, 2);
+		UserSystemCouponRecord record = userSystemCouponRecordService.getRecordByOrderNo(orderNo,sourceType, 2);
 		if (record == null) {
 			return;
 		}
-
-		record.setOrderNo(orderNo);
 		record.setUpdateTime(new Date());
 		record.setState(UserSystemCouponRecord.STATE_SUCCESS);
 		userSystemCouponRecordService.updateByPrimaryKeySelective(record);
@@ -1537,15 +1532,13 @@
 
 	@Transactional(rollbackFor = Exception.class)
 	@Override
-	public boolean updateCouponRecordUsed(Long uid, String orderNo, BigDecimal payment, Long auctionId)
+	public boolean updateCouponRecordUsed(Long uid, String orderNo, BigDecimal payment, Long gId,Integer sourceType)
 			throws Exception {
-
-		boolean isfree = false;
-
-		if (uid == null || payment == null || auctionId == null || orderNo == null || orderNo.trim().length() == 0) {
+		if (uid == null || payment == null || gId == null || orderNo == null || orderNo.trim().length() == 0) {
 			throw new Exception("浼犻�掑弬鏁颁笉鑳戒负绌�");
 		}
-
+		
+		boolean isfree = false;
 		// 鏌ヨ绛夊緟鍖归厤鐨勫埜璁板綍
 		List<UserSystemCouponRecord> list = userSystemCouponRecordService.getRecordByState(uid,
 				UserSystemCouponRecord.STATE_WAIT);
@@ -1559,7 +1552,11 @@
 
 		for (UserSystemCouponRecord userSystemCouponRecord : list) {
 			Long goodId = userSystemCouponRecord.getGoodId();
-			if (auctionId.equals(goodId)) {
+			Integer goodSource = userSystemCouponRecord.getGoodSource();
+			if (goodSource == null)
+				continue;
+				
+			if (gId.equals(goodId) && goodSource == sourceType) {
 				matching = true; // 鍖归厤鎴愬姛
 				record = userSystemCouponRecord;
 				break;
@@ -1568,7 +1565,7 @@
 
 		// 鍟嗗搧鍖归厤鎴愬姛
 		if (matching) {
-
+			record.setGoodSource(sourceType);
 			record.setOrderNo(orderNo);
 			record.setUpdateTime(new Date());
 

--
Gitblit v1.8.0