From 24a8d17e007545f7426c48352109aa1a9c6587ee Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 06 五月 2020 12:02:09 +0800
Subject: [PATCH] IOS上线隐藏我的界面的banner与超级会员升级信息

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackBalanceServiceImpl.java |   57 +++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 35 insertions(+), 22 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackBalanceServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackBalanceServiceImpl.java
index 04176c2..e8cc4a8 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackBalanceServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackBalanceServiceImpl.java
@@ -2,6 +2,7 @@
 
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 
 import javax.annotation.Resource;
 
@@ -14,6 +15,7 @@
 import com.yeshi.fanli.exception.redpack.RedPackBalanceException;
 import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
 import com.yeshi.fanli.service.inter.redpack.RedPackDetailService;
+import com.yeshi.fanli.vo.redpack.RedPackBalanceVO;
 
 @Service
 public class RedPackBalanceServiceImpl implements RedPackBalanceService {
@@ -29,26 +31,14 @@
 		return redPackBalanceMapper.selectByPrimaryKey(uid);
 	}
 
-	private void verify(RedPackBalance redPackBalance) throws RedPackBalanceException{
-		if (redPackBalance == null)
-			return;
-		
-		if (redPackBalance.getState() != null && redPackBalance.getState() == RedPackBalance.STATE_LOCKED) 
-			throw new RedPackBalanceException(1, "绾㈠寘宸插皝绂侊紝鎰熻阿浣跨敤");
-	}
-	
 	@Override
-	public BigDecimal getBalance(Long uid) throws RedPackBalanceException{
+	public BigDecimal getBalance(Long uid){
 		if (uid == null || uid == 0)
 			return new BigDecimal(0);
 		
 		RedPackBalance redPackBalance = redPackBalanceMapper.selectByPrimaryKey(uid);
-		if (redPackBalance != null) {
-			// 楠岃瘉
-			verify(redPackBalance);
-			
-			return redPackBalance.getMoney();
-		}
+		if (redPackBalance != null && redPackBalance.getMoney() != null)
+			return redPackBalance.getMoney();
 		return new BigDecimal(0);
 	}
 
@@ -66,13 +56,10 @@
 			redPackBalance = new RedPackBalance();
 			redPackBalance.setId(uid);
 			redPackBalance.setMoney(money);
-			redPackBalance.setState(RedPackBalance.STATE_INIT);
 			redPackBalance.setCreateTime(new Date());
 			redPackBalance.setUpdateTime(new Date());
 			redPackBalanceMapper.insertSelective(redPackBalance);
 		} else {
-			// 楠岃瘉
-			verify(redPackBalance);
 			redPackBalanceMapper.addRedPack(uid, money);
 		}
 	}
@@ -91,11 +78,37 @@
 
 		if (balance.getMoney().compareTo(money) < 0)
 			throw new RedPackBalanceException(2, "绾㈠寘浣欓涓嶈冻");
-
-		// 楠岃瘉
-		verify(balance);
-					
+		
 		// 鍑忓皯绾㈠寘
 		redPackBalanceMapper.subRedPack(uid, money);
 	}
+	
+	
+	@Override
+	public RedPackBalance selectForUpdate(Long uid) {
+		return redPackBalanceMapper.selectForUpdate(uid);
+	}
+	
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void resetRedPack(Long uid, RedPackDetail detail) throws RedPackBalanceException {
+		if (uid == null || uid == 0 || detail == null)
+			throw new RedPackBalanceException(1, "鍙傛暟浼犻�掍笉瀹屾暣");
+		// 鍔犲叆鏄庣粏
+		redPackDetailService.insertSelective(detail);
+		// 閲嶇疆
+		redPackBalanceMapper.resetRedPack(uid);
+	}
+	
+	
+	@Override
+	public List<RedPackBalanceVO> query(Integer start, Integer count, String key, Integer state,Integer order){
+		return redPackBalanceMapper.query(start, count, key, state,order);
+	}
+	
+	@Override
+	public long count(String key, Integer state){
+		return redPackBalanceMapper.count(key, state);
+	}
+	
 }

--
Gitblit v1.8.0