卡只允许支付宝支付,设备只允许微信支付,钱包充值也遵循这个规则
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m53s

This commit is contained in:
2026-07-03 10:26:48 +09:00
parent 0d79130e07
commit 346156ee9b
2 changed files with 38 additions and 0 deletions

View File

@@ -279,6 +279,18 @@ func (h *ClientWalletHandler) CreateRecharge(c *fiber.Ctx) error {
return err
}
// 第三方支付方式与资产类型必须匹配:单卡只允许支付宝,设备只允许微信
switch resolved.Asset.AssetType {
case "card":
if req.PaymentMethod != constants.RechargeMethodAlipay {
return errors.New(errors.CodeInvalidParam, "单卡资产只支持支付宝充值")
}
case "device":
if req.PaymentMethod != constants.RechargeMethodWechat {
return errors.New(errors.CodeInvalidParam, "设备资产只支持微信充值")
}
}
config, err := h.wechatConfigService.GetActiveConfig(resolved.SkipPermissionCtx)
if err != nil {
return err

View File

@@ -229,6 +229,18 @@ func (s *Service) CreateOrder(ctx context.Context, customerID uint, req *dto.Cli
}()
if forceRecharge.NeedForceRecharge {
// 强充第三方支付方式与资产类型必须匹配:单卡只允许支付宝,设备只允许微信
switch assetInfo.AssetType {
case "card":
if req.PaymentMethod != model.PaymentMethodAlipay {
return nil, errors.New(errors.CodeInvalidParam, "单卡资产强充只支持支付宝支付")
}
case constants.ResourceTypeDevice:
if req.PaymentMethod == model.PaymentMethodAlipay {
return nil, errors.New(errors.CodeInvalidParam, "设备资产强充只支持微信支付")
}
}
if req.PaymentMethod == model.PaymentMethodAlipay {
// 支付宝强充:不需要 app_type / OpenID
activeConfig, err := s.wechatConfigService.GetActiveConfig(skipCtx)
@@ -1241,6 +1253,20 @@ func (s *Service) PayOrder(ctx context.Context, customerID uint, orderID uint, r
return nil, errors.New(errors.CodeNeedRealname)
}
// 第三方支付方式与资产类型必须匹配:单卡只允许支付宝,设备只允许微信
if req.PaymentMethod == model.PaymentMethodWechat || req.PaymentMethod == model.PaymentMethodAlipay {
switch order.OrderType {
case model.OrderTypeSingleCard:
if req.PaymentMethod != model.PaymentMethodAlipay {
return nil, errors.New(errors.CodeInvalidParam, "单卡资产只支持支付宝支付")
}
case model.OrderTypeDevice:
if req.PaymentMethod != model.PaymentMethodWechat {
return nil, errors.New(errors.CodeInvalidParam, "设备资产只支持微信支付")
}
}
}
switch req.PaymentMethod {
case model.PaymentMethodWallet:
if err := s.orderPaymentService.WalletPay(skipCtx, orderID, model.BuyerTypePersonal, customerID); err != nil {