直充类型商品必传

This commit is contained in:
李子铭 2024-11-11 17:13:58 +08:00
parent 796650d161
commit 06b6c24d7f
2 changed files with 36 additions and 18 deletions

View File

@ -6,7 +6,6 @@ import (
"gitee.com/chengdu_blue_brothers/openapi-go-sdk-v2/api"
"gitee.com/chengdu_blue_brothers/openapi-go-sdk-v2/notify"
"gitee.com/chengdu_blue_brothers/openapi-go-sdk-v2/sdk"
"plugins/utils/helper"
"plugins/zltxv2/internal/vo"
)
@ -46,24 +45,17 @@ func (c *Config) client() (*sdk.Client, error) {
}
func (c *Config) orderReq(in *proto.OrderRequest) *api.OrderCreateReq {
accountType := int64(0)
if in.Order.Account == "" {
accountType = 0
} else if helper.IsPhoneNumber(in.Order.Account) {
accountType = 1
} else if helper.IsValidQQ(in.Order.Account) {
accountType = 2
}
var accountType vo.AccountType
return &api.OrderCreateReq{
OutTradeNo: in.Order.OrderNo, // 商户侧订单号长度只能是1-64位
ProductId: in.Product.ProductNo, // 产品编码不能为空
Number: int(in.Order.Quantity), // 部分商品存在限购数量,具体可联系商务
NotifyUrl: c.NotifyUrl, // 订单回调通知地址长度不能为空且长度不能超过255
Extends: string(in.Order.Extra), // 部分特殊商品需要,具体可联系商务
RechargeAccount: in.Order.Account, // 账号类型:直充类型商品必传,商品为卡密类型时,则表示接收卡密的手机号
AccountType: accountType, // 直充类型商品必传 - 1手机号 - 2: QQ 号
Attach: "", // 透传参数,当传了此参数时,查询和回调接口中将原样携带此参数
UnitPrice: 0, // 交易商品单价单位最多保留4位小数 - 0或不传表示不限制 - 当此价格小于采购价时,下单失败
OutTradeNo: in.Order.OrderNo, // 商户侧订单号长度只能是1-64位
ProductId: in.Product.ProductNo, // 产品编码不能为空
Number: int(in.Order.Quantity), // 部分商品存在限购数量,具体可联系商务
NotifyUrl: c.NotifyUrl, // 订单回调通知地址长度不能为空且长度不能超过255
Extends: string(in.Order.Extra), // 部分特殊商品需要,具体可联系商务
RechargeAccount: in.Order.Account, // 账号类型:直充类型商品必传,商品为卡密类型时,则表示接收卡密的手机号
AccountType: accountType.AccountType(in.Order.Account).Value(), // 直充类型商品必传 - 1手机号 - 2: QQ 号
Attach: "", // 透传参数,当传了此参数时,查询和回调接口中将原样携带此参数
UnitPrice: 0, // 交易商品单价单位最多保留4位小数 - 0或不传表示不限制 - 当此价格小于采购价时,下单失败
}
}

View File

@ -0,0 +1,26 @@
package vo
import "plugins/utils/helper"
type AccountType int64
const (
AccountTypeDefault AccountType = iota // 充值成功
AccountTypePhone
AccountTypeQQ
)
func (o AccountType) AccountType(account string) AccountType {
if account == "" {
return AccountTypeDefault
} else if helper.IsPhoneNumber(account) {
return AccountTypePhone
} else if helper.IsValidQQ(account) {
return AccountTypeQQ
}
return AccountTypeDefault
}
func (o AccountType) Value() int64 {
return int64(o)
}