From 7ad7905f32ef6b2d67bbd45260a0413be904fa8d Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期五, 20 九月 2019 14:33:08 +0800
Subject: [PATCH] 品牌 、金币任务bug

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/integral/IntegralTaskRecordServiceImpl.java |   46 +++++++++++++++++++---------------------------
 1 files changed, 19 insertions(+), 27 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/integral/IntegralTaskRecordServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/integral/IntegralTaskRecordServiceImpl.java
index a9e170a..0f751a1 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/integral/IntegralTaskRecordServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/integral/IntegralTaskRecordServiceImpl.java
@@ -190,9 +190,9 @@
 	}
 
 	@Override
-	@Transactional
+	@Transactional(rollbackFor=Exception.class)
 	public Integer receiveGoldCoinALL(Long uid) throws IntegralTaskRecordException {
-		UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
+		UserInfoExtra userInfoExtra = userInfoExtraService.getByUidForUpdate(uid);
 		if (userInfoExtra == null)
 			throw new IntegralTaskRecordException(1, "鐢ㄦ埛淇℃伅涓嶅叏");
 
@@ -205,31 +205,27 @@
 			if (addDetail(uid, record))
 				totalGoldCoin += record.getGoldCoin();
 		}
-
+		
 		Integer goldCoin = userInfoExtra.getGoldCoin();
 		if (goldCoin == null)
 			goldCoin = 0;
 
-		UserInfoExtra extra = new UserInfoExtra();
-		extra.setId(userInfoExtra.getId());
-		extra.setGoldCoin(goldCoin + totalGoldCoin);
-		try {
-			userInfoExtraService.saveUserInfoExtra(extra);
-		} catch (UserInfoExtraException e) {
-			throw new IntegralTaskRecordException(1, "鐢ㄦ埛淇℃伅涓嶅叏");
-		}
-
-		return extra.getGoldCoin();
+		goldCoin = goldCoin + totalGoldCoin;
+		
+		// 鏇存柊閲戝竵
+		userInfoExtraService.updateGoldCoin(userInfoExtra.getId(), goldCoin);
+		
+		return goldCoin;
 	}
 
-	@Override
-	@Transactional
+	@Override	
+	@Transactional(rollbackFor=Exception.class)
 	public Integer receiveGoldCoin(Long uid, Set<Long> idList) throws IntegralTaskRecordException {
 		if (idList == null || idList.size() == 0) {
 			throw new IntegralTaskRecordException(1, "id涓虹┖");
 		}
 
-		UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
+		UserInfoExtra userInfoExtra = userInfoExtraService.getByUidForUpdate(uid);
 		if (userInfoExtra == null) {
 			throw new IntegralTaskRecordException(1, "鐢ㄦ埛淇℃伅涓嶅叏");
 		}
@@ -248,25 +244,21 @@
 			if (addDetail(uid, record))
 				totalGoldCoin += record.getGoldCoin();
 		}
-
+		
 		Integer goldCoin = userInfoExtra.getGoldCoin();
 		if (goldCoin == null)
 			goldCoin = 0;
 
-		UserInfoExtra extra = new UserInfoExtra();
-		extra.setId(userInfoExtra.getId());
-		extra.setGoldCoin(goldCoin + totalGoldCoin);
-		try {
-			userInfoExtraService.saveUserInfoExtra(extra);
-		} catch (UserInfoExtraException e) {
-			throw new IntegralTaskRecordException(1, "鐢ㄦ埛淇℃伅涓嶅叏");
-		}
+		goldCoin = goldCoin + totalGoldCoin;
+		
+		// 鏇存柊閲戝竵
+		userInfoExtraService.updateGoldCoin(userInfoExtra.getId(), goldCoin);
 
-		return extra.getGoldCoin();
+		return goldCoin;
 	}
 
+	@Transactional
 	public boolean addDetail(Long uid, IntegralTaskRecord record) throws IntegralTaskRecordException {
-
 		Long uid2 = record.getUid();
 		if (uid2 == null || uid.longValue() != uid2.longValue())
 			return false; // 鐢ㄦ埛id涓嶇鍚�

--
Gitblit v1.8.0