f
This commit is contained in:
@@ -9,13 +9,38 @@ import (
|
||||
var ErrNotFound = sqlx.ErrNotFound
|
||||
var ErrNoRowsUpdate = errors.New("update db no rows change")
|
||||
|
||||
// 平台
|
||||
// 平台(请求头 X-Platform / JWT platform)
|
||||
var PlatformWxMini string = "wxmini"
|
||||
var PlatformWxH5 string = "wxh5"
|
||||
var PlatformApp string = "app"
|
||||
var PlatformH5 string = "h5"
|
||||
var PlatformAdmin string = "admin"
|
||||
|
||||
// 订单支付场景 order.payment_scene(MySQL ENUM)
|
||||
const (
|
||||
PaymentSceneApp = "app"
|
||||
PaymentSceneH5 = "h5"
|
||||
PaymentSceneMiniProgram = "mini_program"
|
||||
PaymentScenePublicAccount = "public_account"
|
||||
PaymentSceneTest = "test"
|
||||
)
|
||||
|
||||
// PaymentSceneFromPlatform 将运行时平台标识映射为 order.payment_scene 枚举值
|
||||
func PaymentSceneFromPlatform(platform string) string {
|
||||
switch platform {
|
||||
case PlatformWxMini:
|
||||
return PaymentSceneMiniProgram
|
||||
case PlatformWxH5:
|
||||
return PaymentScenePublicAccount
|
||||
case PlatformH5:
|
||||
return PaymentSceneH5
|
||||
case PlatformApp:
|
||||
return PaymentSceneApp
|
||||
default:
|
||||
return PaymentSceneApp
|
||||
}
|
||||
}
|
||||
|
||||
// 用户授权类型
|
||||
var UserAuthTypeMobile string = "mobile"
|
||||
var UserAuthTypeWxMiniOpenID string = "wxmini_openid"
|
||||
@@ -37,6 +62,28 @@ var AgentLeveNameNormal string = "normal"
|
||||
var AgentLeveNameVIP string = "VIP"
|
||||
var AgentLeveNameSVIP string = "SVIP"
|
||||
|
||||
// 订单支付平台 order.payment_platform(varchar,非 ENUM)
|
||||
const (
|
||||
PaymentPlatformAlipay = "alipay"
|
||||
PaymentPlatformWechat = "wechat" // 普通微信支付(JSAPI/H5/APP)
|
||||
PaymentPlatformWechatXpay = "wechat_xpay" // 小程序虚拟支付
|
||||
PaymentPlatformAppleIAP = "appleiap"
|
||||
)
|
||||
|
||||
// IsXpayOrder 是否为小程序虚拟支付订单(含历史 wechat+mini_program 查询单)
|
||||
func IsXpayOrder(order *Order) bool {
|
||||
if order == nil {
|
||||
return false
|
||||
}
|
||||
if order.PaymentPlatform == PaymentPlatformWechatXpay {
|
||||
return true
|
||||
}
|
||||
// 兼容改造前:查询单 Q_ 前缀 + 小程序场景 + pay_method=wechat
|
||||
return order.PaymentPlatform == PaymentPlatformWechat &&
|
||||
order.PaymentScene == PaymentSceneMiniProgram &&
|
||||
len(order.OrderNo) > 2 && order.OrderNo[:2] == "Q_"
|
||||
}
|
||||
|
||||
const (
|
||||
OrderStatusPending = "pending"
|
||||
OrderStatusPaid = "paid"
|
||||
|
||||
Reference in New Issue
Block a user