数据模型使用指针类型字段以避免空值自动更新的问题
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"platform/pkg/u"
|
||||
bill2 "platform/web/domains/bill"
|
||||
resource2 "platform/web/domains/resource"
|
||||
trade2 "platform/web/domains/trade"
|
||||
@@ -56,9 +57,9 @@ func (s *resourceService) CreateResource(uid int32, now time.Time, ser *CreateRe
|
||||
// 生成账单
|
||||
bill := m.Bill{
|
||||
UserID: uid,
|
||||
ResourceID: resource.ID,
|
||||
ResourceID: &resource.ID,
|
||||
BillNo: ID.GenReadable("bil"),
|
||||
Info: "购买套餐 - " + name,
|
||||
Info: u.P("购买套餐 - " + name),
|
||||
Type: int32(bill2.TypeConsume),
|
||||
Amount: amount,
|
||||
}
|
||||
@@ -185,7 +186,7 @@ func (s *resourceService) CompleteResource(tradeNo string, now time.Time, opResu
|
||||
Select(q.Bill.ResourceID).
|
||||
Updates(&m.Bill{
|
||||
ID: cache.BillId,
|
||||
ResourceID: resource.ID,
|
||||
ResourceID: &resource.ID,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -248,7 +249,7 @@ func createResource(q *q.Query, uid int32, now time.Time, data CreateResourceDat
|
||||
// 套餐基本信息
|
||||
var resource = m.Resource{
|
||||
UserID: uid,
|
||||
ResourceNo: ID.GenReadable("res"),
|
||||
ResourceNo: u.P(ID.GenReadable("res")),
|
||||
Active: true,
|
||||
}
|
||||
|
||||
@@ -261,8 +262,8 @@ func createResource(q *q.Query, uid int32, now time.Time, data CreateResourceDat
|
||||
resource.Short = &m.ResourceShort{
|
||||
Type: data.Mode,
|
||||
Live: data.Live,
|
||||
Quota: data.Quota,
|
||||
Expire: orm.LocalDateTime(now.Add(duration)),
|
||||
Quota: &data.Quota,
|
||||
Expire: u.P(orm.LocalDateTime(now.Add(duration))),
|
||||
DailyLimit: data.DailyLimit,
|
||||
}
|
||||
|
||||
@@ -273,8 +274,8 @@ func createResource(q *q.Query, uid int32, now time.Time, data CreateResourceDat
|
||||
resource.Long = &m.ResourceLong{
|
||||
Type: data.Mode,
|
||||
Live: data.Live,
|
||||
Quota: data.Quota,
|
||||
Expire: orm.LocalDateTime(now.Add(duration)),
|
||||
Quota: &data.Quota,
|
||||
Expire: u.P(orm.LocalDateTime(now.Add(duration))),
|
||||
DailyLimit: data.DailyLimit,
|
||||
}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user