优化结构

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
+5 -14
View File
@@ -424,15 +424,15 @@ func paymentCreateRequiresNotifyURL(provider string, extra, config map[string]an
normalized := strings.NewReplacer(".", "_", "-", "_", " ", "_").Replace(strings.ToLower(strings.TrimSpace(value)))
switch provider {
case bizpayment.PaymentAlipay, bizpayment.PaymentAlipayV3:
return !contains([]string{"pay", "trade_pay", "alipay_trade_pay", "barcode", "barcode_pay", "micropay", "face_to_face"}, normalized)
return !paymentkit.ContainsFold([]string{"pay", "trade_pay", "alipay_trade_pay", "barcode", "barcode_pay", "micropay", "face_to_face"}, normalized)
case bizpayment.PaymentWechatV2:
return !contains([]string{"micropay", "micro_pay", "barcode", "barcode_pay", "pay_code", "payment_code"}, normalized)
return !paymentkit.ContainsFold([]string{"micropay", "micro_pay", "barcode", "barcode_pay", "pay_code", "payment_code"}, normalized)
case bizpayment.PaymentWechatV3:
return !contains([]string{"micropay", "micro_pay", "codepay", "code_pay", "barcode", "barcode_pay", "facepay", "face_pay"}, normalized)
return !paymentkit.ContainsFold([]string{"micropay", "micro_pay", "codepay", "code_pay", "barcode", "barcode_pay", "facepay", "face_pay"}, normalized)
case bizpayment.PaymentQQ:
return !contains([]string{"micropay", "micro_pay", "barcode", "barcode_pay"}, normalized)
return !paymentkit.ContainsFold([]string{"micropay", "micro_pay", "barcode", "barcode_pay"}, normalized)
case bizpayment.PaymentLakala:
return !contains([]string{"retail", "retail_pay", "micropay", "barcode"}, normalized)
return !paymentkit.ContainsFold([]string{"retail", "retail_pay", "micropay", "barcode"}, normalized)
default:
return true
}
@@ -516,12 +516,3 @@ func paymentCallbackAck(provider string, values map[string]any, success bool) bi
}
return ack
}
func contains(values []string, value string) bool {
for _, item := range values {
if item == value {
return true
}
}
return false
}
+8 -1
View File
@@ -1,9 +1,16 @@
package payment
import "gorm.io/gorm"
import (
"gorm.io/gorm"
"github.com/google/wire"
)
// Provider is the narrow persistence seam required by payment repositories.
// Keeping it here lets payment remain an independent data module.
type Provider interface {
DB() *gorm.DB
}
// ProviderSet wires payment persistence repositories.
var ProviderSet = wire.NewSet(NewPaymentRepo, NewPaymentOrderRepo)
-6
View File
@@ -1,6 +0,0 @@
package payment
import "github.com/google/wire"
// ProviderSet wires payment persistence repositories.
var ProviderSet = wire.NewSet(NewPaymentRepo, NewPaymentOrderRepo)