From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 25 二月 2025 16:41:22 +0800
Subject: [PATCH] 淘宝转链接口更新

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackBalanceServiceImpl.java |  213 ++++++++++++++++++++++++++++-------------------------
 1 files changed, 113 insertions(+), 100 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 7da0ce9..51a74d8 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
@@ -1,101 +1,114 @@
-package com.yeshi.fanli.service.impl.redpack;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-import javax.annotation.Resource;
-
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import com.yeshi.fanli.dao.mybatis.redpack.RedPackBalanceMapper;
-import com.yeshi.fanli.entity.redpack.RedPackBalance;
-import com.yeshi.fanli.entity.redpack.RedPackDetail;
-import com.yeshi.fanli.exception.redpack.RedPackBalanceException;
-import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
-import com.yeshi.fanli.service.inter.redpack.RedPackDetailService;
-
-@Service
-public class RedPackBalanceServiceImpl implements RedPackBalanceService {
-
-	@Resource
-	private RedPackBalanceMapper redPackBalanceMapper;
-
-	@Resource
-	private RedPackDetailService redPackDetailService;
-
-	@Override
-	public RedPackBalance selectByPrimaryKey(Long uid) {
-		return redPackBalanceMapper.selectByPrimaryKey(uid);
-	}
-
-	@Override
-	public BigDecimal getBalance(Long uid) {
-		if (uid == null || uid == 0)
-			return new BigDecimal(0);
-		
-		RedPackBalance redPackBalance = redPackBalanceMapper.selectByPrimaryKey(uid);
-		if (redPackBalance != null)
+package com.yeshi.fanli.service.impl.redpack;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.yeshi.fanli.dao.mybatis.redpack.RedPackBalanceMapper;
+import com.yeshi.fanli.entity.redpack.RedPackBalance;
+import com.yeshi.fanli.entity.redpack.RedPackDetail;
+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 {
+
+	@Resource
+	private RedPackBalanceMapper redPackBalanceMapper;
+
+	@Resource
+	private RedPackDetailService redPackDetailService;
+
+	@Override
+	public RedPackBalance selectByPrimaryKey(Long uid) {
+		return redPackBalanceMapper.selectByPrimaryKey(uid);
+	}
+
+	@Override
+	public BigDecimal getBalance(Long uid){
+		if (uid == null || uid == 0)
+			return new BigDecimal(0);
+		
+		RedPackBalance redPackBalance = redPackBalanceMapper.selectByPrimaryKey(uid);
+		if (redPackBalance != null && redPackBalance.getMoney() != null)
 			return redPackBalance.getMoney();
-		return new BigDecimal(0);
-	}
-
-	@Override
-	public void addRedPack(Long uid, BigDecimal money) {
-		if (uid == null || uid == 0 || money == null)
-			return;
-		RedPackBalance redPackBalance = redPackBalanceMapper.selectForUpdate(uid);
-		if (redPackBalance == null) {
-			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 {
-			redPackBalanceMapper.addRedPack(uid, money);
-		}
-	}
-
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public void addRedPack(Long uid, BigDecimal money, RedPackDetail detail) throws RedPackBalanceException {
-		if (uid == null || uid == 0 || money == null || detail == null)
-			throw new RedPackBalanceException(1, "鍙傛暟浼犻�掍笉瀹屾暣");
-		// 鍔犲叆鏄庣粏
-		redPackDetailService.insertSelective(detail);
-		// 娣诲姞绾㈠寘
-		RedPackBalance redPackBalance = redPackBalanceMapper.selectForUpdate(uid);
-		if (redPackBalance == null) {
-			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 {
-			redPackBalanceMapper.addRedPack(uid, money);
-		}
-	}
-
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public void subRedPack(Long uid, BigDecimal money, RedPackDetail detail) throws RedPackBalanceException {
-		if (uid == null || uid == 0 || money == null || detail == null)
-			throw new RedPackBalanceException(1, "鍙傛暟浼犻�掍笉瀹屾暣");
-		// 鍔犲叆鏄庣粏
-		redPackDetailService.insertSelective(detail);
-
-		RedPackBalance balance = redPackBalanceMapper.selectForUpdate(uid);
-		if (balance.getMoney() == null)
-			throw new RedPackBalanceException(2, "绾㈠寘浣欓涓嶈冻");
-
-		if (balance.getMoney().compareTo(money) < 0)
-			throw new RedPackBalanceException(2, "绾㈠寘浣欓涓嶈冻");
-
-		// 鍑忓皯绾㈠寘
-		redPackBalanceMapper.subRedPack(uid, money);
-	}
-}
+		return new BigDecimal(0);
+	}
+
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void addRedPack(Long uid, BigDecimal money, RedPackDetail detail) throws RedPackBalanceException {
+		if (uid == null || uid == 0 || money == null || detail == null)
+			throw new RedPackBalanceException(1, "鍙傛暟浼犻�掍笉瀹屾暣");
+		// 鍔犲叆鏄庣粏
+		redPackDetailService.insertSelective(detail);
+		// 娣诲姞绾㈠寘
+		RedPackBalance redPackBalance = redPackBalanceMapper.selectForUpdate(uid);
+		if (redPackBalance == null) {
+			redPackBalance = new RedPackBalance();
+			redPackBalance.setId(uid);
+			redPackBalance.setMoney(money);
+			redPackBalance.setCreateTime(new Date());
+			redPackBalance.setUpdateTime(new Date());
+			redPackBalanceMapper.insertSelective(redPackBalance);
+		} else {
+			redPackBalanceMapper.addRedPack(uid, money);
+		}
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void subRedPack(Long uid, BigDecimal money, RedPackDetail detail) throws RedPackBalanceException {
+		if (uid == null || uid == 0 || money == null || detail == null)
+			throw new RedPackBalanceException(1, "鍙傛暟浼犻�掍笉瀹屾暣");
+		// 鍔犲叆鏄庣粏
+		redPackDetailService.insertSelective(detail);
+
+		RedPackBalance balance = redPackBalanceMapper.selectForUpdate(uid);
+		if (balance.getMoney() == null)
+			throw new RedPackBalanceException(2, "绾㈠寘浣欓涓嶈冻");
+
+		if (balance.getMoney().compareTo(money) < 0)
+			throw new RedPackBalanceException(2, "绾㈠寘浣欓涓嶈冻");
+		
+		// 鍑忓皯绾㈠寘
+		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