| | |
| | | private final GuideUserMapper guideUserMapper; |
| | | private final GuideTeamMapper guideTeamMapper; |
| | | private final PlatformSettingsService settingsService; |
| | | private final GuideWithdrawalService guideWithdrawalService; |
| | | |
| | | public AdminFinanceService(TourOrderMapper orderMapper, GuideWithdrawalMapper withdrawalMapper, |
| | | GuideUserMapper guideUserMapper, GuideTeamMapper guideTeamMapper, |
| | | PlatformSettingsService settingsService) { |
| | | PlatformSettingsService settingsService, |
| | | GuideWithdrawalService guideWithdrawalService) { |
| | | this.orderMapper = orderMapper; |
| | | this.withdrawalMapper = withdrawalMapper; |
| | | this.guideUserMapper = guideUserMapper; |
| | | this.guideTeamMapper = guideTeamMapper; |
| | | this.settingsService = settingsService; |
| | | this.guideWithdrawalService = guideWithdrawalService; |
| | | } |
| | | |
| | | public FinanceLedgerPageResponse ledger(long page, long size, String direction, String keyword, |
| | |
| | | |
| | | @Transactional |
| | | public WithdrawalResponse processWithdrawal(Long id, WithdrawalProcessRequest request, String processor) { |
| | | GuideWithdrawal withdrawal = withdrawalMapper.selectById(id); |
| | | if (withdrawal == null) throw new BusinessException(404, "提现申请不存在"); |
| | | if (!"PENDING".equals(withdrawal.getStatus())) throw new BusinessException(409, "提现申请已处理"); |
| | | if ("REJECTED".equals(request.getStatus()) && !StringUtils.hasText(request.getAuditRemark())) { |
| | | throw new BusinessException(400, "驳回提现时请填写处理备注"); |
| | | } |
| | | withdrawal.setStatus(request.getStatus()); |
| | | withdrawal.setAuditRemark(StringUtils.hasText(request.getAuditRemark()) ? request.getAuditRemark().trim() : null); |
| | | withdrawal.setProcessor(processor); |
| | | withdrawal.setProcessedAt(LocalDateTime.now()); |
| | | withdrawalMapper.updateById(withdrawal); |
| | | return new WithdrawalResponse(withdrawal); |
| | | return guideWithdrawalService.process(id, request.getStatus(), request.getAuditRemark(), processor); |
| | | } |
| | | |
| | | private LambdaQueryWrapper<TourOrder> ledgerQuery(boolean refund, String keyword, String paymentMethod, |
| | |
| | | guideIncome = guideIncome.negate(); |
| | | amount = amount.negate(); |
| | | } |
| | | LocalDateTime settledAt = order.getCompletedAt() == null ? null |
| | | : order.getCompletedAt().plusDays(settings.getSettlementDays()); |
| | | LocalDateTime settledAt = order.getSettledAt() == null |
| | | ? order.getSettlementDueAt() : order.getSettledAt(); |
| | | Long teamId = order.getCommissionTeamId() != null |
| | | ? order.getCommissionTeamId() |
| | | : guide == null ? null : guide.getTeamId(); |