All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m7s
微信按当前 v2/v3 配置分别生成 MWEB/H5 链接,支付宝复用 C 端 WAP 链接,并让可用支付方式基于生效配置判断。 Constraint: 支付链接统一通过 qr_content 返回,由前端渲染二维码;按要求不运行测试 Rejected: 微信 Native 与支付宝当面付 | 会引入非当前商户配置所需的额外产品开通 Confidence: high Scope-risk: moderate Directive: 微信 H5/MWEB 二维码仅承诺系统相机或外部浏览器扫码链路 Tested: 相关 Go 包编译通过;gofmt 与 git diff --check 通过 Not-tested: 按用户要求未运行自动化测试及真实支付联调
31 lines
1.1 KiB
Go
31 lines
1.1 KiB
Go
// Package agentrecharge 定义代理在线充值的纯业务规则。
|
|
package agentrecharge
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
|
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
|
)
|
|
|
|
// ValidateOnlineCreation 校验代理在线充值的角色、金额和支付方式不变量。
|
|
func ValidateOnlineCreation(userType int, amount int64, paymentMethod string) error {
|
|
if userType != constants.UserTypeAgent {
|
|
return errors.New(errors.CodeForbidden, "仅代理账号可以创建在线扫码充值")
|
|
}
|
|
if amount < constants.AgentOnlineRechargeMinAmount || amount > constants.AgentRechargeMaxAmount {
|
|
return errors.New(errors.CodeInvalidParam, "在线充值金额必须在100元至100万元之间")
|
|
}
|
|
switch strings.TrimSpace(paymentMethod) {
|
|
case constants.RechargeMethodWechat, constants.RechargeMethodAlipay:
|
|
return nil
|
|
default:
|
|
return errors.New(errors.CodeInvalidParam, "在线充值支付方式无效")
|
|
}
|
|
}
|
|
|
|
// CanCloseAfterPaymentURLFailure 判断支付链接生成明确失败后能否关闭充值单。
|
|
func CanCloseAfterPaymentURLFailure(status int) bool {
|
|
return status == constants.RechargeStatusPending
|
|
}
|