实现用户订单、在线支付接口(商业版可用)
This commit is contained in:
60
pkg/userconfigs/order_constants.go
Normal file
60
pkg/userconfigs/order_constants.go
Normal file
@@ -0,0 +1,60 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package userconfigs
|
||||
|
||||
import "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
|
||||
type OrderType = string
|
||||
|
||||
const (
|
||||
OrderTypeCharge OrderType = "charge"
|
||||
)
|
||||
|
||||
func IsValidOrderType(s string) bool {
|
||||
return s == OrderTypeCharge
|
||||
}
|
||||
|
||||
func OrderTypeName(orderType OrderType) string {
|
||||
switch orderType {
|
||||
case OrderTypeCharge:
|
||||
return "充值"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type OrderStatus = string
|
||||
|
||||
const (
|
||||
OrderStatusNone OrderStatus = "none"
|
||||
OrderStatusCancelled OrderStatus = "cancelled"
|
||||
OrderStatusFinished OrderStatus = "finished"
|
||||
)
|
||||
|
||||
func OrderStatusName(orderStatus OrderStatus) string {
|
||||
switch orderStatus {
|
||||
case OrderStatusNone:
|
||||
return "未支付"
|
||||
case OrderStatusCancelled:
|
||||
return "已取消"
|
||||
case OrderStatusFinished:
|
||||
return "已完成"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func FindAllOrderStatusList() []*shared.Definition {
|
||||
return []*shared.Definition{
|
||||
{
|
||||
Name: "已完成",
|
||||
Code: OrderStatusFinished,
|
||||
},
|
||||
{
|
||||
Name: "未支付",
|
||||
Code: OrderStatusNone,
|
||||
},
|
||||
{
|
||||
Name: "已取消",
|
||||
Code: OrderStatusCancelled,
|
||||
},
|
||||
}
|
||||
}
|
||||
23
pkg/userconfigs/user_order_config.go
Normal file
23
pkg/userconfigs/user_order_config.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package userconfigs
|
||||
|
||||
import "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
|
||||
// UserOrderConfig 用户订单配置
|
||||
type UserOrderConfig struct {
|
||||
EnablePay bool `json:"enablePay"` // 启用支付
|
||||
DisablePageHTML string `json:"disablePageHTML"` // 禁用支付时的页面提示
|
||||
OrderLife *shared.TimeDuration `json:"orderLife"` // 过期时间
|
||||
}
|
||||
|
||||
func DefaultUserOrderConfig() *UserOrderConfig {
|
||||
return &UserOrderConfig{
|
||||
EnablePay: false,
|
||||
DisablePageHTML: "暂不提供在线充值功能,请联系管理员充值。",
|
||||
OrderLife: &shared.TimeDuration{
|
||||
Count: 1,
|
||||
Unit: shared.TimeDurationUnitHour,
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user