feat: 移除“租户管理员为用户充值 / 每租户一套余额”能力:余额统一为全局用户余额
This commit is contained in:
@@ -35,18 +35,18 @@ func newOrderItem(db *gorm.DB, opts ...gen.DOOption) orderItemQuery {
|
||||
_orderItemQuery.Snapshot = field.NewJSONB(tableName, "snapshot")
|
||||
_orderItemQuery.CreatedAt = field.NewTime(tableName, "created_at")
|
||||
_orderItemQuery.UpdatedAt = field.NewTime(tableName, "updated_at")
|
||||
_orderItemQuery.Content = orderItemQueryBelongsToContent{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Content", "Content"),
|
||||
}
|
||||
|
||||
_orderItemQuery.Order = orderItemQueryBelongsToOrder{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Order", "Order"),
|
||||
}
|
||||
|
||||
_orderItemQuery.Content = orderItemQueryBelongsToContent{
|
||||
db: db.Session(&gorm.Session{}),
|
||||
|
||||
RelationField: field.NewRelation("Content", "Content"),
|
||||
}
|
||||
|
||||
_orderItemQuery.fillFieldMap()
|
||||
|
||||
return _orderItemQuery
|
||||
@@ -66,9 +66,9 @@ type orderItemQuery struct {
|
||||
Snapshot field.JSONB // 内容快照:JSON;建议包含 title/price/discount 等,用于历史展示与审计
|
||||
CreatedAt field.Time // 创建时间:默认 now()
|
||||
UpdatedAt field.Time // 更新时间:默认 now()
|
||||
Content orderItemQueryBelongsToContent
|
||||
Order orderItemQueryBelongsToOrder
|
||||
|
||||
Order orderItemQueryBelongsToOrder
|
||||
Content orderItemQueryBelongsToContent
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
@@ -143,101 +143,20 @@ func (o *orderItemQuery) fillFieldMap() {
|
||||
|
||||
func (o orderItemQuery) clone(db *gorm.DB) orderItemQuery {
|
||||
o.orderItemQueryDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
o.Content.db = db.Session(&gorm.Session{Initialized: true})
|
||||
o.Content.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
o.Order.db = db.Session(&gorm.Session{Initialized: true})
|
||||
o.Order.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
o.Content.db = db.Session(&gorm.Session{Initialized: true})
|
||||
o.Content.db.Statement.ConnPool = db.Statement.ConnPool
|
||||
return o
|
||||
}
|
||||
|
||||
func (o orderItemQuery) replaceDB(db *gorm.DB) orderItemQuery {
|
||||
o.orderItemQueryDo.ReplaceDB(db)
|
||||
o.Content.db = db.Session(&gorm.Session{})
|
||||
o.Order.db = db.Session(&gorm.Session{})
|
||||
o.Content.db = db.Session(&gorm.Session{})
|
||||
return o
|
||||
}
|
||||
|
||||
type orderItemQueryBelongsToContent struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a orderItemQueryBelongsToContent) Where(conds ...field.Expr) *orderItemQueryBelongsToContent {
|
||||
if len(conds) == 0 {
|
||||
return &a
|
||||
}
|
||||
|
||||
exprs := make([]clause.Expression, 0, len(conds))
|
||||
for _, cond := range conds {
|
||||
exprs = append(exprs, cond.BeCond().(clause.Expression))
|
||||
}
|
||||
a.db = a.db.Clauses(clause.Where{Exprs: exprs})
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a orderItemQueryBelongsToContent) WithContext(ctx context.Context) *orderItemQueryBelongsToContent {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a orderItemQueryBelongsToContent) Session(session *gorm.Session) *orderItemQueryBelongsToContent {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a orderItemQueryBelongsToContent) Model(m *OrderItem) *orderItemQueryBelongsToContentTx {
|
||||
return &orderItemQueryBelongsToContentTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a orderItemQueryBelongsToContent) Unscoped() *orderItemQueryBelongsToContent {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type orderItemQueryBelongsToContentTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a orderItemQueryBelongsToContentTx) Find() (result *Content, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a orderItemQueryBelongsToContentTx) Append(values ...*Content) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a orderItemQueryBelongsToContentTx) Replace(values ...*Content) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a orderItemQueryBelongsToContentTx) Delete(values ...*Content) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a orderItemQueryBelongsToContentTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a orderItemQueryBelongsToContentTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a orderItemQueryBelongsToContentTx) Unscoped() *orderItemQueryBelongsToContentTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type orderItemQueryBelongsToOrder struct {
|
||||
db *gorm.DB
|
||||
|
||||
@@ -319,6 +238,87 @@ func (a orderItemQueryBelongsToOrderTx) Unscoped() *orderItemQueryBelongsToOrder
|
||||
return &a
|
||||
}
|
||||
|
||||
type orderItemQueryBelongsToContent struct {
|
||||
db *gorm.DB
|
||||
|
||||
field.RelationField
|
||||
}
|
||||
|
||||
func (a orderItemQueryBelongsToContent) Where(conds ...field.Expr) *orderItemQueryBelongsToContent {
|
||||
if len(conds) == 0 {
|
||||
return &a
|
||||
}
|
||||
|
||||
exprs := make([]clause.Expression, 0, len(conds))
|
||||
for _, cond := range conds {
|
||||
exprs = append(exprs, cond.BeCond().(clause.Expression))
|
||||
}
|
||||
a.db = a.db.Clauses(clause.Where{Exprs: exprs})
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a orderItemQueryBelongsToContent) WithContext(ctx context.Context) *orderItemQueryBelongsToContent {
|
||||
a.db = a.db.WithContext(ctx)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a orderItemQueryBelongsToContent) Session(session *gorm.Session) *orderItemQueryBelongsToContent {
|
||||
a.db = a.db.Session(session)
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a orderItemQueryBelongsToContent) Model(m *OrderItem) *orderItemQueryBelongsToContentTx {
|
||||
return &orderItemQueryBelongsToContentTx{a.db.Model(m).Association(a.Name())}
|
||||
}
|
||||
|
||||
func (a orderItemQueryBelongsToContent) Unscoped() *orderItemQueryBelongsToContent {
|
||||
a.db = a.db.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type orderItemQueryBelongsToContentTx struct{ tx *gorm.Association }
|
||||
|
||||
func (a orderItemQueryBelongsToContentTx) Find() (result *Content, err error) {
|
||||
return result, a.tx.Find(&result)
|
||||
}
|
||||
|
||||
func (a orderItemQueryBelongsToContentTx) Append(values ...*Content) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Append(targetValues...)
|
||||
}
|
||||
|
||||
func (a orderItemQueryBelongsToContentTx) Replace(values ...*Content) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Replace(targetValues...)
|
||||
}
|
||||
|
||||
func (a orderItemQueryBelongsToContentTx) Delete(values ...*Content) (err error) {
|
||||
targetValues := make([]interface{}, len(values))
|
||||
for i, v := range values {
|
||||
targetValues[i] = v
|
||||
}
|
||||
return a.tx.Delete(targetValues...)
|
||||
}
|
||||
|
||||
func (a orderItemQueryBelongsToContentTx) Clear() error {
|
||||
return a.tx.Clear()
|
||||
}
|
||||
|
||||
func (a orderItemQueryBelongsToContentTx) Count() int64 {
|
||||
return a.tx.Count()
|
||||
}
|
||||
|
||||
func (a orderItemQueryBelongsToContentTx) Unscoped() *orderItemQueryBelongsToContentTx {
|
||||
a.tx = a.tx.Unscoped()
|
||||
return &a
|
||||
}
|
||||
|
||||
type orderItemQueryDo struct{ gen.DO }
|
||||
|
||||
func (o orderItemQueryDo) Debug() *orderItemQueryDo {
|
||||
|
||||
Reference in New Issue
Block a user