From 39f6fca28e3f78abe48f08e474ec011abb990b36 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期三, 09 九月 2026 10:39:21 +0800
Subject: [PATCH] update
---
backend/src/main/java/com/tourguide/modules/finance/service/GuideWithdrawableBalanceService.java | 27 ++++++++++++++++++++++++++-
1 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/backend/src/main/java/com/tourguide/modules/finance/service/GuideWithdrawableBalanceService.java b/backend/src/main/java/com/tourguide/modules/finance/service/GuideWithdrawableBalanceService.java
index fb10bf9..84ab601 100644
--- a/backend/src/main/java/com/tourguide/modules/finance/service/GuideWithdrawableBalanceService.java
+++ b/backend/src/main/java/com/tourguide/modules/finance/service/GuideWithdrawableBalanceService.java
@@ -2,6 +2,8 @@
import com.tourguide.common.exception.BusinessException;
import com.tourguide.modules.user.mapper.GuideUserMapper;
+import com.tourguide.modules.user.mapper.GuideTeamMapper;
+import com.tourguide.modules.user.entity.GuideTeam;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
@@ -11,9 +13,11 @@
@Service
public class GuideWithdrawableBalanceService {
private final GuideUserMapper guideUserMapper;
+ private final GuideTeamMapper guideTeamMapper;
- public GuideWithdrawableBalanceService(GuideUserMapper guideUserMapper) {
+ public GuideWithdrawableBalanceService(GuideUserMapper guideUserMapper, GuideTeamMapper guideTeamMapper) {
this.guideUserMapper = guideUserMapper;
+ this.guideTeamMapper = guideTeamMapper;
}
public BigDecimal getAvailableAmount(Long guideId) {
@@ -33,6 +37,27 @@
}
}
+ public BigDecimal getAvailableTeamAmount(Long teamId) {
+ if (teamId == null) return BigDecimal.ZERO.setScale(2);
+ GuideTeam team = guideTeamMapper.selectById(teamId);
+ return money(team == null ? null : team.getBalance());
+ }
+
+ public boolean debitTeam(Long teamId, BigDecimal amount) {
+ BigDecimal value = money(amount);
+ return teamId != null && value.signum() > 0
+ && guideTeamMapper.decreaseBalance(teamId, value) == 1;
+ }
+
+ public void creditTeam(Long teamId, BigDecimal amount) {
+ BigDecimal value = money(amount);
+ if (value.signum() == 0) return;
+ if (teamId == null || value.signum() < 0
+ || guideTeamMapper.increaseBalance(teamId, value) != 1) {
+ throw new BusinessException(500, "讲解队余额更新失败");
+ }
+ }
+
private BigDecimal money(BigDecimal value) {
return (value == null ? BigDecimal.ZERO : value).setScale(2, RoundingMode.HALF_UP);
}
--
Gitblit v1.7.1