优化结构

This commit is contained in:
Yvan
2026-08-28 09:44:11 +08:00
parent 279692375b
commit e997d9718e
26 changed files with 106 additions and 129 deletions
+2 -8
View File
@@ -388,12 +388,8 @@ func NewPaymentUsecase(repo PaymentRepo, orders PaymentOrderRepo, hooks PaymentH
}
func NewConfiguredPaymentUsecase(repo PaymentRepo, orders PaymentOrderRepo, hooks PaymentHooks, sources *PaymentOrderSourceRegistry, fulfillments *PaymentFulfillmentRegistry, appLogger *slog.Logger) (*PaymentUsecase, error) {
if sources == nil || sources.Len() == 0 {
return nil, errors.New("支付业务订单来源未注册,无法启动支付服务")
}
if fulfillments == nil || fulfillments.Len() == 0 {
return nil, errors.New("支付发货 handler 未注册,无法启动支付服务")
}
// Business modules are optional in the template. Missing modules are
// reported when the corresponding payment operation is invoked.
return NewPaymentUsecase(repo, orders, hooks, sources, fulfillments, appLogger), nil
}
@@ -924,8 +920,6 @@ func (uc *PaymentUsecase) refundWithOrder(ctx context.Context, provider, tradeNo
message := ""
if providerErr != nil {
message = providerErr.Error()
} else if !accepted {
message = "支付平台未接受退款请求"
}
order, err = uc.orders.CompletePaymentRefundRequest(ctx, provider, tradeNo, token, accepted, message)
if err != nil {
-1
View File
@@ -100,7 +100,6 @@ type ErrorRecord struct {
type AuditRecordRepo interface {
RecordOperation(context.Context, *OperationRecord) error
RecordLogin(context.Context, *LoginLog) error
RecordDataAccess(context.Context, *DataAccessLog) error
CreateError(context.Context, *ErrorRecord) error
}
+4 -1
View File
@@ -206,7 +206,10 @@ func (uc *MediaUsecase) CompleteUpload(ctx context.Context, userID, uploadID uin
return nil, value
}
chunks, err := uc.ListChunks(ctx, uploadID)
if err != nil || len(chunks) != session.ChunkTotal {
if err != nil {
return fail(err)
}
if len(chunks) != session.ChunkTotal {
return fail(fmt.Errorf("分片不全: %d/%d", len(chunks), session.ChunkTotal))
}
sort.Slice(chunks, func(i, j int) bool { return chunks[i].Index < chunks[j].Index })