实现余额购买接口 & 实现全局 id 生成器
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -28,12 +28,12 @@ func newRefund(db *gorm.DB, opts ...gen.DOOption) refund {
|
||||
tableName := _refund.refundDo.TableName()
|
||||
_refund.ALL = field.NewAsterisk(tableName)
|
||||
_refund.ID = field.NewInt32(tableName, "id")
|
||||
_refund.OrderID = field.NewInt32(tableName, "order_id")
|
||||
_refund.ProductID = field.NewInt32(tableName, "product_id")
|
||||
_refund.Amount = field.NewFloat64(tableName, "amount")
|
||||
_refund.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_refund.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_refund.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
_refund.TradeID = field.NewInt32(tableName, "trade_id")
|
||||
|
||||
_refund.fillFieldMap()
|
||||
|
||||
@@ -45,12 +45,12 @@ type refund struct {
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int32 // 退款ID
|
||||
OrderID field.Int32 // 订单ID
|
||||
ProductID field.Int32 // 产品ID
|
||||
Amount field.Float64 // 退款金额
|
||||
CreatedAt field.Time // 创建时间
|
||||
UpdatedAt field.Time // 更新时间
|
||||
DeletedAt field.Field // 删除时间
|
||||
TradeID field.Int32
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
@@ -68,12 +68,12 @@ func (r refund) As(alias string) *refund {
|
||||
func (r *refund) updateTableName(table string) *refund {
|
||||
r.ALL = field.NewAsterisk(table)
|
||||
r.ID = field.NewInt32(table, "id")
|
||||
r.OrderID = field.NewInt32(table, "order_id")
|
||||
r.ProductID = field.NewInt32(table, "product_id")
|
||||
r.Amount = field.NewFloat64(table, "amount")
|
||||
r.CreatedAt = field.NewTime(table, "created_at")
|
||||
r.UpdatedAt = field.NewTime(table, "updated_at")
|
||||
r.DeletedAt = field.NewField(table, "deleted_at")
|
||||
r.TradeID = field.NewInt32(table, "trade_id")
|
||||
|
||||
r.fillFieldMap()
|
||||
|
||||
@@ -92,12 +92,12 @@ func (r *refund) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
func (r *refund) fillFieldMap() {
|
||||
r.fieldMap = make(map[string]field.Expr, 7)
|
||||
r.fieldMap["id"] = r.ID
|
||||
r.fieldMap["order_id"] = r.OrderID
|
||||
r.fieldMap["product_id"] = r.ProductID
|
||||
r.fieldMap["amount"] = r.Amount
|
||||
r.fieldMap["created_at"] = r.CreatedAt
|
||||
r.fieldMap["updated_at"] = r.UpdatedAt
|
||||
r.fieldMap["deleted_at"] = r.DeletedAt
|
||||
r.fieldMap["trade_id"] = r.TradeID
|
||||
}
|
||||
|
||||
func (r refund) clone(db *gorm.DB) refund {
|
||||
|
||||
Reference in New Issue
Block a user