// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn . //go:build plus package userconfigs import "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" type OrderType = string const ( OrderTypeCharge OrderType = "charge" // 充值 OrderTypeBuyNSPlan OrderType = "buyNSPlan" // 购买DNS套餐 OrderTypeBuyTrafficPackage OrderType = "buyTrafficPackage" // 购买流量包 OrderTypeBuyAntiDDoSInstance OrderType = "buyAntiDDoSInstance" // 购买高防实例 OrderTypeRenewAntiDDoSInstance OrderType = "renewAntiDDoSInstance" // 续费高防实例 ) // OrderTypeBuyNSPlanParams 购买NS套餐参数 type OrderTypeBuyNSPlanParams struct { PlanId int64 `json:"planId"` DayFrom string `json:"dayFrom"` DayTo string `json:"dayTo"` Period string `json:"period"` } // OrderTypeBuyTrafficPackageParams 购买流量包参数 type OrderTypeBuyTrafficPackageParams struct { PackageId int64 `json:"packageId"` RegionId int64 `json:"regionId"` PeriodId int64 `json:"periodId"` PeriodCount int32 `json:"periodCount"` // 冗余数据,防止 Period 在生成订单时发生变更 PeriodUnit string `json:"periodUnit"` Count int32 `json:"count"` } // OrderTypeBuyAntiDDoSInstanceParams 购买高防实例 type OrderTypeBuyAntiDDoSInstanceParams struct { PackageId int64 `json:"packageId"` PeriodId int64 `json:"periodId"` PeriodCount int32 `json:"periodCount"` // 冗余数据,防止 Period 在生成订单时发生变更 PeriodUnit string `json:"periodUnit"` Count int32 `json:"count"` } // OrderTypeRenewAntiDDoSInstanceParams 续费高防实例 type OrderTypeRenewAntiDDoSInstanceParams struct { UserInstanceId int64 `json:"userInstanceId"` // 用户实例ID PeriodId int64 `json:"periodId"` // 有效期ID } func FindAllOrderTypes() []*shared.Definition { return []*shared.Definition{ { Name: "充值", Code: OrderTypeCharge, }, { Name: "购买DNS套餐", Code: OrderTypeBuyNSPlan, }, { Name: "购买流量包", Code: OrderTypeBuyTrafficPackage, }, { Name: "购买DDoS高防实例", Code: OrderTypeBuyAntiDDoSInstance, }, { Name: "续费DDoS高防实例", Code: OrderTypeRenewAntiDDoSInstance, }, } } func IsValidOrderType(orderType string) bool { for _, def := range FindAllOrderTypes() { if def.Code == orderType { return true } } return false } func FindOrderTypeName(orderType OrderType) string { for _, def := range FindAllOrderTypes() { if def.Code == orderType { return def.Name } } return "" } type OrderStatus = string const ( OrderStatusNone OrderStatus = "none" OrderStatusCancelled OrderStatus = "cancelled" OrderStatusFinished OrderStatus = "finished" ) func FindOrderStatusName(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, }, } }