支持提号完成后财务调整
This commit is contained in:
@@ -2,6 +2,7 @@ package pickup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"hfb_sys/backend/internal/auditlog"
|
||||
)
|
||||
@@ -63,6 +64,39 @@ func (s *Service) UpdateProfit(ctx context.Context, pickupID uint64, req UpdateP
|
||||
return s.repo.UpdateProfit(ctx, pickupID, req, adminID, meta)
|
||||
}
|
||||
|
||||
func (s *Service) CreateFinancialAdjustment(ctx context.Context, pickupID uint64, req FinancialAdjustmentRequest, adminID uint64, meta auditlog.Meta) (*PickupDTO, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
}
|
||||
if pickupID == 0 || (req.ProfitAmountCent == nil && req.SettleAmountCent == nil) || strings.TrimSpace(req.Reason) == "" {
|
||||
return nil, ErrFinancialAdjustmentInvalid
|
||||
}
|
||||
if (req.ProfitAmountCent != nil && *req.ProfitAmountCent < 0) || (req.SettleAmountCent != nil && *req.SettleAmountCent < 0) {
|
||||
return nil, ErrFinancialAdjustmentInvalid
|
||||
}
|
||||
return s.repo.CreateFinancialAdjustment(ctx, pickupID, req, adminID, meta)
|
||||
}
|
||||
|
||||
func (s *Service) ListFinancialAdjustments(ctx context.Context, pickupID uint64) ([]FinancialAdjustmentDTO, error) {
|
||||
if s.repo == nil {
|
||||
return nil, ErrDependencyUnavailable
|
||||
}
|
||||
if pickupID == 0 {
|
||||
return nil, ErrPickupNotFound
|
||||
}
|
||||
return s.repo.ListFinancialAdjustments(ctx, pickupID)
|
||||
}
|
||||
|
||||
func (s *Service) SettleFinancialAdjustment(ctx context.Context, adjustmentID uint64, req FinancialAdjustmentSettlementRequest, adminID uint64, meta auditlog.Meta) error {
|
||||
if s.repo == nil {
|
||||
return ErrDependencyUnavailable
|
||||
}
|
||||
if adjustmentID == 0 {
|
||||
return ErrFinancialAdjustmentNotFound
|
||||
}
|
||||
return s.repo.SettleFinancialAdjustment(ctx, adjustmentID, req, adminID, meta)
|
||||
}
|
||||
|
||||
func (s *Service) Cancel(ctx context.Context, pickupID uint64, reason string, adminID uint64, meta auditlog.Meta) error {
|
||||
if s.repo == nil {
|
||||
return ErrDependencyUnavailable
|
||||
|
||||
Reference in New Issue
Block a user