fix:支付
This commit is contained in:
@@ -100,12 +100,16 @@ var (
|
||||
CodeLogoCombineErr = &StatusResponse{5115, "logo combine fail"} // 合图失败
|
||||
CodeLogoCombineNoFoundErr = &StatusResponse{5116, "template record not found"} // 模版不存在
|
||||
|
||||
CodeErrOrder = &StatusResponse{5300, "create order failed"} // 订单错误
|
||||
CodeErrOrderCreatShoppingCartEmpty = &StatusResponse{5301, "create order failed, shopping cart is empty"} // 订单创建失败,购物车为空
|
||||
CodeErrOrderCreatShoppingCartNotMatched = &StatusResponse{5302, "create order failed, shopping cart not matched"} // 订单创建失败,购物车不相符
|
||||
CodeErrOrderCreatProductAbsent = &StatusResponse{5303, "create order failed, product is absent"} // 订单创建失败,商品不存在
|
||||
CodeErrOrderCreatProductPriceAbsent = &StatusResponse{5304, "create order failed, price of product is absent"} // 订单创建失败,商品价格不存在
|
||||
CodeErrOrderCreatProductAccessoryAbsent = &StatusResponse{5305, "create order failed, accessory of product is absent"} // 订单创建失败,商品配件不存在
|
||||
CodeErrOrder = &StatusResponse{5300, "create order failed"} // 订单错误
|
||||
CodeErrOrderCreatShoppingCartEmpty = &StatusResponse{5301, "create order failed, shopping cart is empty"} // 订单创建失败,购物车为空
|
||||
CodeErrOrderCreatShoppingCartNotMatched = &StatusResponse{5302, "create order failed, shopping cart not matched"} // 订单创建失败,购物车不相符
|
||||
CodeErrOrderCreatProductAbsent = &StatusResponse{5303, "create order failed, product is absent"} // 订单创建失败,商品不存在
|
||||
CodeErrOrderCreatProductPriceAbsent = &StatusResponse{5304, "create order failed, price of product is absent"} // 订单创建失败,商品价格不存在
|
||||
CodeErrOrderCreatProductAccessoryAbsent = &StatusResponse{5305, "create order failed, accessory of product is absent"} // 订单创建失败,商品配件不存在
|
||||
CodeErrOrderCreatePrePaymentParam = &StatusResponse{5306, "create payment failed, the shipping address is illegal"} // 订单创建失败,商品配件不存在
|
||||
CodeErrOrderCreatePrePaymentInfoNoFound = &StatusResponse{5307, "create payment failed, order info not found"}
|
||||
CodeErrOrderCreatePrePaymentPaidDeposit = &StatusResponse{5308, "create payment failed, order is paid"}
|
||||
CodeErrOrderCreatePrePaymentTimeout = &StatusResponse{5309, "create payment failed, timeout"}
|
||||
)
|
||||
|
||||
type Response struct {
|
||||
|
||||
@@ -58,7 +58,7 @@ func MetadataModulePATCH(tx *gorm.DB, module string, tableStructPointer any, upd
|
||||
WHEN metadata IS NULL THEN ?
|
||||
ELSE JSON_MERGE_PATCH(metadata, ?)
|
||||
END
|
||||
WHERE module = '%s' and %s;`
|
||||
WHERE order_sn = '%s' and %s;`
|
||||
|
||||
var err error
|
||||
var metadata []byte
|
||||
@@ -147,3 +147,46 @@ func MetadataResourcePATCH(tx *gorm.DB, rid string, updateMetadata any, values .
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func MetadataOrderPATCH(tx *gorm.DB, sql string, orderSn string, tableStructPointer any, updateMetadata any, WhereKeysCond string, values ...any) error {
|
||||
stype := reflect.TypeOf(tableStructPointer)
|
||||
if stype.Kind() == reflect.Pointer {
|
||||
stype = stype.Elem()
|
||||
}
|
||||
|
||||
updatesql := `UPDATE %s
|
||||
SET metadata = CASE
|
||||
WHEN metadata IS NULL THEN ?
|
||||
ELSE JSON_MERGE_PATCH(metadata, ?)
|
||||
END%s
|
||||
WHERE order_sn = '%s' and %s;`
|
||||
|
||||
var err error
|
||||
var metadata []byte
|
||||
|
||||
switch mdata := updateMetadata.(type) {
|
||||
case []byte:
|
||||
metadata = mdata
|
||||
case string:
|
||||
metadata = []byte(mdata)
|
||||
default:
|
||||
metadata, err = json.Marshal(updateMetadata)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
var args []any
|
||||
|
||||
args = append(args, metadata, metadata)
|
||||
args = append(args, values...)
|
||||
|
||||
updatesql = fmt.Sprintf(updatesql, tx.NamingStrategy.TableName(stype.Name()), sql, orderSn, WhereKeysCond)
|
||||
// logx.Error(updatesql)
|
||||
err = tx.Exec(updatesql, args...).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ type Config struct {
|
||||
func NewPayDriver(PayMethod int64, config *Config) Pay {
|
||||
switch PayMethod {
|
||||
case int64(constants.PAYMETHOD_STRIPE):
|
||||
return &Stripe{Key: config.Stripe.Key}
|
||||
return &Stripe{Key: config.Stripe.Key, PayType: config.Stripe.PayType}
|
||||
default:
|
||||
return &Stripe{Key: config.Stripe.Key}
|
||||
return &Stripe{Key: config.Stripe.Key, PayType: config.Stripe.PayType}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -81,9 +81,6 @@ func (stripePay *Stripe) GeneratePrepayment(req *GeneratePrepaymentReq) (res *Ge
|
||||
params := &stripe.PaymentIntentParams{
|
||||
Amount: stripe.Int64(req.Amount),
|
||||
Currency: stripe.String(string(req.Currency)),
|
||||
AutomaticPaymentMethods: &stripe.PaymentIntentAutomaticPaymentMethodsParams{
|
||||
Enabled: stripe.Bool(true),
|
||||
},
|
||||
PaymentMethodTypes: stripe.StringSlice([]string{
|
||||
"card",
|
||||
// "ideal",
|
||||
|
||||
Reference in New Issue
Block a user