108 lines
3.4 KiB
Go
108 lines
3.4 KiB
Go
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
|
//go:build plus
|
|
|
|
package userconfigs
|
|
|
|
// 所有账户相关的事件类型
|
|
|
|
type AccountEventType = string
|
|
|
|
const (
|
|
AccountEventTypeCharge AccountEventType = "charge" // 充值
|
|
AccountEventTypeAward AccountEventType = "award" // 赠送
|
|
AccountEventTypeBuyPlan AccountEventType = "buyPlan" // 购买CDN套餐
|
|
AccountEventTypePayBill AccountEventType = "payBill" // 支付账单
|
|
AccountEventTypeRefund AccountEventType = "refund" // 退款
|
|
AccountEventTypeWithdraw AccountEventType = "withdraw" // 提现
|
|
AccountEventTypeBuyNSPlan AccountEventType = "buyNSPlan" // 购买DNS套餐
|
|
AccountEventTypeBuyTrafficPackage AccountEventType = "buyTrafficPackage" // 购买流量包
|
|
AccountEventTypeBuyAntiDDoSPackage AccountEventType = "buyAntiDDoSPackage" // 购买高防实例
|
|
AccountEventTypeRenewAntiDDoSPackage AccountEventType = "renewAntiDDoSPackage" // 续费高防实例
|
|
)
|
|
|
|
type AccountEvent struct {
|
|
Name string `json:"name"` // 名称
|
|
Code AccountEventType `json:"code"` // 代号
|
|
Description string `json:"description"` // 描述
|
|
IsPositive bool `json:"isPositive"` // 是否为正向
|
|
}
|
|
|
|
var AccountIncomeEventTypes = []AccountEventType{AccountEventTypeCharge} // 收入
|
|
var AccountExpenseEventTypes = []AccountEventType{AccountEventTypeWithdraw} // 支出
|
|
|
|
// FindAllAccountEventTypes 查找所有的事件类型
|
|
func FindAllAccountEventTypes() []*AccountEvent {
|
|
return []*AccountEvent{
|
|
{
|
|
Name: "充值",
|
|
Code: AccountEventTypeCharge,
|
|
Description: "为用户账户充值。",
|
|
IsPositive: true,
|
|
},
|
|
{
|
|
Name: "赠送",
|
|
Code: AccountEventTypeAward,
|
|
Description: "为用户账户赠送余额。",
|
|
IsPositive: true,
|
|
},
|
|
{
|
|
Name: "购买CDN套餐",
|
|
Code: AccountEventTypeBuyPlan,
|
|
Description: "购买CDN套餐支出。",
|
|
IsPositive: false,
|
|
},
|
|
{
|
|
Name: "支付账单",
|
|
Code: AccountEventTypePayBill,
|
|
Description: "支付账单支出。",
|
|
IsPositive: false,
|
|
},
|
|
{
|
|
Name: "退款",
|
|
Code: AccountEventTypeRefund,
|
|
Description: "退款到用户账户。",
|
|
IsPositive: true,
|
|
},
|
|
{
|
|
Name: "提现",
|
|
Code: AccountEventTypeWithdraw,
|
|
Description: "用户从账户提现。",
|
|
IsPositive: false,
|
|
},
|
|
{
|
|
Name: "购买DNS套餐",
|
|
Code: AccountEventTypeBuyNSPlan,
|
|
Description: "购买DNS套餐支出。",
|
|
IsPositive: false,
|
|
},
|
|
{
|
|
Name: "购买流量包",
|
|
Code: AccountEventTypeBuyTrafficPackage,
|
|
Description: "购买流量包支出",
|
|
IsPositive: false,
|
|
},
|
|
{
|
|
Name: "购买DDoS高防实例",
|
|
Code: AccountEventTypeBuyAntiDDoSPackage,
|
|
Description: "购买DDoS高防实例支出",
|
|
IsPositive: false,
|
|
},
|
|
{
|
|
Name: "续费DDoS高防实例",
|
|
Code: AccountEventTypeRenewAntiDDoSPackage,
|
|
Description: "续费DDoS高防实例支出",
|
|
IsPositive: false,
|
|
},
|
|
}
|
|
}
|
|
|
|
// FindAccountEvent 根据事件类型查找事件定义
|
|
func FindAccountEvent(eventType AccountEventType) *AccountEvent {
|
|
for _, e := range FindAllAccountEventTypes() {
|
|
if e.Code == eventType {
|
|
return e
|
|
}
|
|
}
|
|
return nil
|
|
}
|