重构增加模型枚举值定义
This commit is contained in:
@@ -7,6 +7,9 @@ import (
|
||||
"fmt"
|
||||
"platform/pkg/rds"
|
||||
"platform/web/core"
|
||||
bill2 "platform/web/domains/bill"
|
||||
resource2 "platform/web/domains/resource"
|
||||
trade2 "platform/web/domains/trade"
|
||||
m "platform/web/models"
|
||||
q "platform/web/queries"
|
||||
"strings"
|
||||
@@ -19,7 +22,7 @@ var Resource = &resourceService{}
|
||||
|
||||
type resourceService struct{}
|
||||
|
||||
func (s *resourceService) PrepareResource(ctx context.Context, data *CreateResourceData, uid int32, method TransactionMethod) (*TransactionPrepareResult, error) {
|
||||
func (s *resourceService) PrepareResource(ctx context.Context, data *CreateResourceData, uid int32, method trade2.Method) (*TransactionPrepareResult, error) {
|
||||
amount := data.GetPrice()
|
||||
|
||||
// 保存到数据库
|
||||
@@ -32,7 +35,7 @@ func (s *resourceService) PrepareResource(ctx context.Context, data *CreateResou
|
||||
Subject: "购买套餐 - " + data.GetName(),
|
||||
Amount: amount,
|
||||
ExpireAt: time.Now().Add(30 * time.Minute),
|
||||
Type: TransactionTypePurchase,
|
||||
Type: trade2.TypeRecharge,
|
||||
Method: method,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -150,7 +153,7 @@ func (s *resourceService) CreateResource(data *CreateResourceData, uid int32) er
|
||||
ResourceID: resource.ID,
|
||||
BillNo: ID.GenReadable("bil"),
|
||||
Info: "购买套餐 - " + data.GetName(),
|
||||
Type: 1,
|
||||
Type: int32(bill2.TypeConsume),
|
||||
Amount: data.GetPrice(),
|
||||
}
|
||||
err = q.Bill.
|
||||
@@ -243,7 +246,7 @@ func createResource(q *q.Query, data *CreateResourceData, uid int32) (*m.Resourc
|
||||
UserID: uid,
|
||||
ResourceNo: ID.GenReadable("res"),
|
||||
Active: true,
|
||||
Type: 1,
|
||||
Type: int32(resource2.TypeDynamic),
|
||||
Pss: &m.ResourcePss{
|
||||
Type: data.Type,
|
||||
Live: data.Live,
|
||||
@@ -260,7 +263,7 @@ func createResource(q *q.Query, data *CreateResourceData, uid int32) (*m.Resourc
|
||||
return &resource, nil
|
||||
}
|
||||
|
||||
func (s *resourceService) CancelResource(ctx context.Context, tradeNo string, at time.Time, method TransactionMethod) error {
|
||||
func (s *resourceService) CancelResource(ctx context.Context, tradeNo string, at time.Time, method trade2.Method) error {
|
||||
// 删除请求缓存
|
||||
_, err := rds.Client.Del(ctx, tradeNo).Result()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user