解耦订单和申诉模块外部依赖
This commit is contained in:
@@ -204,24 +204,27 @@ type flowServices struct {
|
||||
|
||||
func newFlowServices(db *gorm.DB) flowServices {
|
||||
listingRepo := listing.NewRepository(db)
|
||||
orderRepo := order.NewRepository(db)
|
||||
walletRepo := wallet.NewRepository(db)
|
||||
configRepo := paymentconfig.NewRepository(db, &paymentconfig.MockEncryptor{})
|
||||
paymentRepo := payment.NewRepository(db, configRepo, orderRepo, walletRepo)
|
||||
disputeRepo := dispute.NewRepository(db)
|
||||
orderRepo.SetRefundFunc(func(ctx context.Context, orderID uint64, refundAmountCent int64, bizType string, remark string) (string, error) {
|
||||
refund, err := paymentRepo.StartRefund(ctx, orderID, refundAmountCent, bizType, remark)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return refund.Status, nil
|
||||
var paymentRepo *payment.Repository
|
||||
orderRepo := order.NewRepository(db, order.Dependencies{
|
||||
RefundStarter: order.RefundStarterFunc(func(ctx context.Context, orderID uint64, refundAmountCent int64, bizType string, remark string) (string, error) {
|
||||
refund, err := paymentRepo.StartRefund(ctx, orderID, refundAmountCent, bizType, remark)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return refund.Status, nil
|
||||
}),
|
||||
})
|
||||
disputeRepo.SetRefundFunc(func(ctx context.Context, orderID uint64, refundAmountCent int64, bizType string, remark string) (string, error) {
|
||||
refund, err := paymentRepo.StartRefund(ctx, orderID, refundAmountCent, bizType, remark)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return refund.Status, nil
|
||||
paymentRepo = payment.NewRepository(db, configRepo, orderRepo, walletRepo)
|
||||
disputeRepo := dispute.NewRepository(db, dispute.Dependencies{
|
||||
RefundStarter: dispute.RefundStarterFunc(func(ctx context.Context, orderID uint64, refundAmountCent int64, bizType string, remark string) (string, error) {
|
||||
refund, err := paymentRepo.StartRefund(ctx, orderID, refundAmountCent, bizType, remark)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return refund.Status, nil
|
||||
}),
|
||||
})
|
||||
|
||||
return flowServices{
|
||||
|
||||
Reference in New Issue
Block a user