fix:团队统计修改

This commit is contained in:
yys 2026-04-22 17:57:55 +08:00
parent d578280f82
commit 63f251de66
2 changed files with 12 additions and 12 deletions

View File

@ -151,13 +151,15 @@ export default {
2: "充值赠送", 2: "充值赠送",
3: "体验金赠送", 3: "体验金赠送",
4: "体验金回收", 4: "体验金回收",
5: "一键衣", 5: "一键衣",
6: "图生图2", 6: "图生图2",
7: "一键换脸", 7: "一键换脸",
8: "快捷生图", 8: "快捷生图",
9: "快捷生视频", 9: "快捷生视频",
10: "退款", 10: "退款",
11: "系统操作" 11: "系统操作",
12: "团队下发",
13: "团队收回"
}, },
// //
loading: true, loading: true,

View File

@ -23,7 +23,7 @@ import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.service.ISysDeptService; import com.ruoyi.system.service.ISysDeptService;
/** /**
* 部门与用户积分互转的事务内逻辑由门面在 Redisson 锁内调用 *团队与用户积分互转的事务内逻辑由门面在 Redisson 锁内调用
*/ */
@Service @Service
public class DeptUserScoreTransferTxService { public class DeptUserScoreTransferTxService {
@ -45,17 +45,15 @@ public class DeptUserScoreTransferTxService {
Long deptId = user.getDeptId(); Long deptId = user.getDeptId();
BigDecimal amount = toAmountBigDecimal(request.getAmount()); BigDecimal amount = toAmountBigDecimal(request.getAmount());
String orderNum = buildOrderNum(); String orderNum = buildOrderNum();
String remark = buildRemark(request.getRemark(), "部门下放积分至用户");
int rows = deptService.subtractDeptBalance(deptId, amount); int rows = deptService.subtractDeptBalance(deptId, amount);
if (rows == 0) { if (rows == 0) {
throw new ServiceException("部门积分不足或部门不存在"); throw new ServiceException("团队积分不足");
} }
aiUserService.addUserBalance(orderNum, user.getId(), amount, BalanceChangerConstants.DEPT_SCORE_ISSUE, remark); aiUserService.addUserBalance(orderNum, user.getId(), amount, BalanceChangerConstants.DEPT_SCORE_ISSUE, request.getRemark());
BigDecimal deptBalAfter = getDeptBalance(deptId); BigDecimal deptBalAfter = getDeptBalance(deptId);
insertGroupRecord(orderNum, deptId, GroupBalanceChangeType.ISSUE.getCode(), amount.negate(), deptBalAfter, remark); insertGroupRecord(orderNum, deptId, GroupBalanceChangeType.ISSUE.getCode(), amount.negate(), deptBalAfter, request.getRemark());
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ -75,13 +73,13 @@ public class DeptUserScoreTransferTxService {
} }
String orderNum = buildOrderNum(); String orderNum = buildOrderNum();
String remark = buildRemark(request.getRemark(), "用户积分回收至部门"); String remark = buildRemark(request.getRemark(), "用户积分回收至团队");
aiUserService.addUserBalance(orderNum, user.getId(), amount.negate(), BalanceChangerConstants.DEPT_SCORE_RECLAIM, remark); aiUserService.addUserBalance(orderNum, user.getId(), amount.negate(), BalanceChangerConstants.DEPT_SCORE_RECLAIM, remark);
int rows = deptService.addDeptBalance(deptId, amount); int rows = deptService.addDeptBalance(deptId, amount);
if (rows == 0) { if (rows == 0) {
throw new ServiceException("部门不存在或已删除"); throw new ServiceException("团队不存在或已删除");
} }
BigDecimal deptBalAfter = getDeptBalance(deptId); BigDecimal deptBalAfter = getDeptBalance(deptId);
@ -94,7 +92,7 @@ public class DeptUserScoreTransferTxService {
throw new ServiceException("用户不存在"); throw new ServiceException("用户不存在");
} }
if (user.getDeptId() == null) { if (user.getDeptId() == null) {
throw new ServiceException("用户未分配部门,无法操作"); throw new ServiceException("用户未分配团队,无法操作");
} }
if (user.getDelFlag() != null && !"0".equals(user.getDelFlag())) { if (user.getDelFlag() != null && !"0".equals(user.getDelFlag())) {
throw new ServiceException("用户已删除或无效"); throw new ServiceException("用户已删除或无效");
@ -120,7 +118,7 @@ public class DeptUserScoreTransferTxService {
private BigDecimal getDeptBalance(Long deptId) { private BigDecimal getDeptBalance(Long deptId) {
SysDept dept = deptService.selectDeptById(deptId); SysDept dept = deptService.selectDeptById(deptId);
if (dept == null) { if (dept == null) {
throw new ServiceException("部门不存在"); throw new ServiceException("团队不存在");
} }
return dept.getBalance() == null ? BigDecimal.ZERO : dept.getBalance(); return dept.getBalance() == null ? BigDecimal.ZERO : dept.getBalance();
} }