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/money/TeamDividentsDebtServiceImpl.java |  242 ++++++++++++++++++++++++------------------------
 1 files changed, 122 insertions(+), 120 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/money/TeamDividentsDebtServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/money/TeamDividentsDebtServiceImpl.java
index 347696f..a784338 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/money/TeamDividentsDebtServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/money/TeamDividentsDebtServiceImpl.java
@@ -1,120 +1,122 @@
-package com.yeshi.fanli.service.impl.money;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-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.money.TeamDividentsDebtMapper;
-import com.yeshi.fanli.dao.mybatis.money.TeamDividentsDebtRepayHistoryMapper;
-import com.yeshi.fanli.entity.order.dividents.TeamDividentsDebt;
-import com.yeshi.fanli.entity.order.dividents.TeamDividentsDebtRepayHistory;
-import com.yeshi.fanli.exception.money.TeamDividentsDebtException;
-import com.yeshi.fanli.service.inter.money.TeamDividentsDebtService;
-
-@Service
-public class TeamDividentsDebtServiceImpl implements TeamDividentsDebtService {
-	@Resource
-	private TeamDividentsDebtMapper teamDividentsDebtMapper;
-
-	@Resource
-	private TeamDividentsDebtRepayHistoryMapper teamDividentsDebtRepayHistoryMapper;
-
-	@Transactional(rollbackFor = Exception.class)
-	@Override
-	public void addDebt(TeamDividentsDebt debt) throws TeamDividentsDebtException {
-		if (debt == null || debt.getOriginMoney() == null || debt.getUid() == null) {
-			throw new TeamDividentsDebtException(1, "鏁版嵁涓嶅畬鏁�");
-		}
-		if (debt.getCreateTime() == null)
-			debt.setCreateTime(new Date());
-		debt.setLeftMoney(debt.getOriginMoney());
-		teamDividentsDebtMapper.insertSelective(debt);
-	}
-
-	@Transactional(rollbackFor = Exception.class)
-	@Override
-	public void repayDebt(Long debtId, BigDecimal money) throws TeamDividentsDebtException {
-		TeamDividentsDebt debt = teamDividentsDebtMapper.selectByPrimaryKeyForUpdate(debtId);
-		if (debt == null)
-			throw new TeamDividentsDebtException(1, "鍊哄姟ID涓嶅瓨鍦�");
-		if (money == null || money.compareTo(new BigDecimal(0)) <= 0)
-			throw new TeamDividentsDebtException(3, "杩橀挶蹇呴』澶т簬0");
-		if (debt.getLeftMoney().compareTo(money) < 0)
-			throw new TeamDividentsDebtException(2, "杩橀挶杩囧");
-		// 杩橀挶
-		TeamDividentsDebt update = new TeamDividentsDebt();
-		update.setId(debt.getId());
-		update.setLeftMoney(debt.getLeftMoney().subtract(money));
-		update.setUpdateTime(new Date());
-		teamDividentsDebtMapper.updateByPrimaryKeySelective(update);
-		// 鍔犲叆杩橀挶璁板綍
-		TeamDividentsDebtRepayHistory record = new TeamDividentsDebtRepayHistory();
-		record.setCreateTime(new Date());
-		record.setDebt(debt);
-		record.setMoney(money);
-		record.setUid(debt.getUid());
-		teamDividentsDebtRepayHistoryMapper.insertSelective(record);
-	}
-
-	@Transactional(rollbackFor = Exception.class)
-	@Override
-	public BigDecimal repayDebtByUid(Long uid, BigDecimal money) throws TeamDividentsDebtException {
-		// 杩橀挶
-		long count = countNeedRepayDebt(uid);
-		int page = (int) (count % 200 == 0 ? count / 200 : count / 200 + 1);
-		List<TeamDividentsDebt> totalList = new ArrayList<>();
-		for (int i = 0; i < page; i++) {
-			List<TeamDividentsDebt> tempList = listNeedRepayDebt(uid, i + 1, 200);
-			if (tempList != null && tempList.size() > 0) {
-				totalList.addAll(tempList);
-			}
-		}
-
-		// 鍓╀綑璧勯噾
-		BigDecimal leftMoney = new BigDecimal(money.toString());
-
-		for (TeamDividentsDebt debt : totalList) {
-			if (leftMoney.compareTo(new BigDecimal(0)) <= 0)// 浣欓涓嶈冻鎵f
-				break;
-			BigDecimal repayMoney = null;
-			if (debt.getLeftMoney().compareTo(leftMoney) >= 0)
-				repayMoney = new BigDecimal(leftMoney.toString());
-			else
-				repayMoney = debt.getLeftMoney();
-			try {
-				repayDebt(debt.getId(), repayMoney);
-				leftMoney = leftMoney.subtract(repayMoney);
-			} catch (TeamDividentsDebtException e) {
-				// 涓婄瑪杩樻鏈垚鍔燂紝缁х画涓嬩竴绗旇繕娆�
-			}
-		}
-
-		return leftMoney;// 杩斿洖鍓╀綑鐨勮祫閲�
-	}
-
-	@Override
-	public List<TeamDividentsDebt> listNeedRepayDebt(Long uid, int page, int count) {
-		return teamDividentsDebtMapper.listByLeftMoneyAndUid(new BigDecimal("0.01"), null, uid, (page - 1) * count,
-				count);
-	}
-
-	@Override
-	public long countNeedRepayDebt(Long uid) {
-		return teamDividentsDebtMapper.countByLeftMoneyAndUid(new BigDecimal("0.01"), null, uid);
-	}
-
-	@Override
-	public BigDecimal getTotalDebtMoney(Long uid) {
-		BigDecimal money = teamDividentsDebtMapper.sumLeftMoneyByUid(uid);
-		if (money == null)
-			money = new BigDecimal(0);
-		return money;
-	}
-
-}
+package com.yeshi.fanli.service.impl.money;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+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.money.TeamDividentsDebtMapper;
+import com.yeshi.fanli.dao.mybatis.money.TeamDividentsDebtRepayHistoryMapper;
+import com.yeshi.fanli.entity.order.dividents.TeamDividentsDebt;
+import com.yeshi.fanli.entity.order.dividents.TeamDividentsDebtRepayHistory;
+import com.yeshi.fanli.exception.money.TeamDividentsDebtException;
+import com.yeshi.fanli.service.inter.money.TeamDividentsDebtService;
+
+@Service
+public class TeamDividentsDebtServiceImpl implements TeamDividentsDebtService {
+	@Resource
+	private TeamDividentsDebtMapper teamDividentsDebtMapper;
+
+	@Resource
+	private TeamDividentsDebtRepayHistoryMapper teamDividentsDebtRepayHistoryMapper;
+
+	@Transactional(rollbackFor = Exception.class)
+	@Override
+	public void addDebt(TeamDividentsDebt debt) throws TeamDividentsDebtException {
+		if (debt == null || debt.getOriginMoney() == null || debt.getUid() == null) {
+			throw new TeamDividentsDebtException(1, "鏁版嵁涓嶅畬鏁�");
+		}
+		if (debt.getCreateTime() == null)
+			debt.setCreateTime(new Date());
+		debt.setLeftMoney(debt.getOriginMoney());
+		teamDividentsDebtMapper.insertSelective(debt);
+	}
+
+	@Transactional(rollbackFor = Exception.class)
+	@Override
+	public void repayDebt(Long debtId, BigDecimal money) throws TeamDividentsDebtException {
+		TeamDividentsDebt debt = teamDividentsDebtMapper.selectByPrimaryKeyForUpdate(debtId);
+		if (debt == null)
+			throw new TeamDividentsDebtException(1, "鍊哄姟ID涓嶅瓨鍦�");
+		if (money == null || money.compareTo(new BigDecimal(0)) <= 0)
+			throw new TeamDividentsDebtException(3, "杩橀挶蹇呴』澶т簬0");
+		if (debt.getLeftMoney().compareTo(money) < 0)
+			throw new TeamDividentsDebtException(2, "杩橀挶杩囧");
+		// 杩橀挶
+		TeamDividentsDebt update = new TeamDividentsDebt();
+		update.setId(debt.getId());
+		update.setLeftMoney(debt.getLeftMoney().subtract(money));
+		update.setUpdateTime(new Date());
+		teamDividentsDebtMapper.updateByPrimaryKeySelective(update);
+		// 鍔犲叆杩橀挶璁板綍
+		TeamDividentsDebtRepayHistory record = new TeamDividentsDebtRepayHistory();
+		record.setCreateTime(new Date());
+		record.setDebt(debt);
+		record.setMoney(money);
+		record.setUid(debt.getUid());
+		teamDividentsDebtRepayHistoryMapper.insertSelective(record);
+	}
+
+	@Transactional(rollbackFor = Exception.class)
+	@Override
+	public BigDecimal repayDebtByUid(Long uid, Date maxEstimatePayTime, BigDecimal money)
+			throws TeamDividentsDebtException {
+		// 杩橀挶
+		long count = countNeedRepayDebt(uid, maxEstimatePayTime);
+		int page = (int) (count % 200 == 0 ? count / 200 : count / 200 + 1);
+		List<TeamDividentsDebt> totalList = new ArrayList<>();
+		for (int i = 0; i < page; i++) {
+			List<TeamDividentsDebt> tempList = listNeedRepayDebt(uid, maxEstimatePayTime, i + 1, 200);
+			if (tempList != null && tempList.size() > 0) {
+				totalList.addAll(tempList);
+			}
+		}
+
+		// 鍓╀綑璧勯噾
+		BigDecimal leftMoney = new BigDecimal(money.toString());
+
+		for (TeamDividentsDebt debt : totalList) {
+			if (leftMoney.compareTo(new BigDecimal(0)) <= 0)// 浣欓涓嶈冻鎵f
+				break;
+			BigDecimal repayMoney = null;
+			if (debt.getLeftMoney().compareTo(leftMoney) >= 0)
+				repayMoney = new BigDecimal(leftMoney.toString());
+			else
+				repayMoney = debt.getLeftMoney();
+			try {
+				repayDebt(debt.getId(), repayMoney);
+				leftMoney = leftMoney.subtract(repayMoney);
+			} catch (TeamDividentsDebtException e) {
+				// 涓婄瑪杩樻鏈垚鍔燂紝缁х画涓嬩竴绗旇繕娆�
+			}
+		}
+
+		return leftMoney;// 杩斿洖鍓╀綑鐨勮祫閲�
+	}
+
+	@Override
+	public List<TeamDividentsDebt> listNeedRepayDebt(Long uid, Date maxEstimatePayTime, int page, int count) {
+		return teamDividentsDebtMapper.listByLeftMoneyAndUidAndMaxEstimatePayTime(new BigDecimal("0.01"), null, uid,
+				maxEstimatePayTime, (page - 1) * count, count);
+	}
+
+	@Override
+	public long countNeedRepayDebt(Long uid, Date maxEstimatePayTime) {
+		return teamDividentsDebtMapper.countByLeftMoneyAndUidAndMaxEstimatePayTime(new BigDecimal("0.01"), null, uid,
+				maxEstimatePayTime);
+	}
+
+	@Override
+	public BigDecimal getTotalDebtMoney(Long uid, Date maxEstimatePayTime) {
+		BigDecimal money = teamDividentsDebtMapper.sumLeftMoneyByUid(uid, maxEstimatePayTime);
+		if (money == null)
+			money = new BigDecimal(0);
+		return money;
+	}
+
+}

--
Gitblit v1.8.0