实现余额购买接口 & 实现全局 id 生成器

This commit is contained in:
2025-04-08 17:15:23 +08:00
parent c02d843dbc
commit 4c47a71f30
10 changed files with 506 additions and 116 deletions

View File

@@ -28,17 +28,17 @@ func newBill(db *gorm.DB, opts ...gen.DOOption) bill {
tableName := _bill.billDo.TableName()
_bill.ALL = field.NewAsterisk(tableName)
_bill.ID = field.NewInt32(tableName, "id")
_bill.OrderID = field.NewInt32(tableName, "order_id")
_bill.UserID = field.NewInt32(tableName, "user_id")
_bill.ProductID = field.NewInt32(tableName, "product_id")
_bill.Info = field.NewString(tableName, "info")
_bill.Count_ = field.NewInt32(tableName, "count")
_bill.Price = field.NewFloat64(tableName, "price")
_bill.Amount = field.NewFloat64(tableName, "amount")
_bill.Payment = field.NewFloat64(tableName, "payment")
_bill.CreatedAt = field.NewTime(tableName, "created_at")
_bill.UpdatedAt = field.NewTime(tableName, "updated_at")
_bill.DeletedAt = field.NewField(tableName, "deleted_at")
_bill.TradeID = field.NewInt32(tableName, "trade_id")
_bill.ResourceID = field.NewInt32(tableName, "resource_id")
_bill.Type = field.NewInt32(tableName, "type")
_bill.BillNo = field.NewString(tableName, "bill_no")
_bill.fillFieldMap()
@@ -48,19 +48,19 @@ func newBill(db *gorm.DB, opts ...gen.DOOption) bill {
type bill struct {
billDo
ALL field.Asterisk
ID field.Int32 // 账单ID
OrderID field.Int32 // 订单ID
UserID field.Int32 // 用户ID
ProductID field.Int32 // 产品ID
Info field.String // 产品可读信息
Count_ field.Int32 // 购买数量
Price field.Float64 // 单价
Amount field.Float64 // 总金额
Payment field.Float64 // 支付金额
CreatedAt field.Time // 创建时间
UpdatedAt field.Time // 更新时间
DeletedAt field.Field // 删除时间
ALL field.Asterisk
ID field.Int32 // 账单ID
UserID field.Int32 // 用户ID
Info field.String // 产品可读信息
Amount field.Float64 // 总金额
Payment field.Float64 // 支付金额
CreatedAt field.Time // 创建时间
UpdatedAt field.Time // 更新时间
DeletedAt field.Field // 删除时间
TradeID field.Int32
ResourceID field.Int32
Type field.Int32
BillNo field.String
fieldMap map[string]field.Expr
}
@@ -78,17 +78,17 @@ func (b bill) As(alias string) *bill {
func (b *bill) updateTableName(table string) *bill {
b.ALL = field.NewAsterisk(table)
b.ID = field.NewInt32(table, "id")
b.OrderID = field.NewInt32(table, "order_id")
b.UserID = field.NewInt32(table, "user_id")
b.ProductID = field.NewInt32(table, "product_id")
b.Info = field.NewString(table, "info")
b.Count_ = field.NewInt32(table, "count")
b.Price = field.NewFloat64(table, "price")
b.Amount = field.NewFloat64(table, "amount")
b.Payment = field.NewFloat64(table, "payment")
b.CreatedAt = field.NewTime(table, "created_at")
b.UpdatedAt = field.NewTime(table, "updated_at")
b.DeletedAt = field.NewField(table, "deleted_at")
b.TradeID = field.NewInt32(table, "trade_id")
b.ResourceID = field.NewInt32(table, "resource_id")
b.Type = field.NewInt32(table, "type")
b.BillNo = field.NewString(table, "bill_no")
b.fillFieldMap()
@@ -107,17 +107,17 @@ func (b *bill) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
func (b *bill) fillFieldMap() {
b.fieldMap = make(map[string]field.Expr, 12)
b.fieldMap["id"] = b.ID
b.fieldMap["order_id"] = b.OrderID
b.fieldMap["user_id"] = b.UserID
b.fieldMap["product_id"] = b.ProductID
b.fieldMap["info"] = b.Info
b.fieldMap["count"] = b.Count_
b.fieldMap["price"] = b.Price
b.fieldMap["amount"] = b.Amount
b.fieldMap["payment"] = b.Payment
b.fieldMap["created_at"] = b.CreatedAt
b.fieldMap["updated_at"] = b.UpdatedAt
b.fieldMap["deleted_at"] = b.DeletedAt
b.fieldMap["trade_id"] = b.TradeID
b.fieldMap["resource_id"] = b.ResourceID
b.fieldMap["type"] = b.Type
b.fieldMap["bill_no"] = b.BillNo
}
func (b bill) clone(db *gorm.DB) bill {