kefu/models/user_orders.go

46 lines
1.4 KiB
Go
Raw Normal View History

2024-12-10 02:50:12 +00:00
package models
import (
"kefu/types"
)
type User_order struct {
ID uint `gorm:"primary_key" json:"id"`
OrderSn string `json:"order_sn"`
NewExpireTime string `json:"new_expire_time"`
Money uint `json:"money"`
Payment string `json:"payment"`
Type uint `json:"type"`
Comment string `json:"comment"`
CreatedAt types.Time `json:"created_at"`
Operator string `json:"operator"`
KefuName string `json:"kefu_name"`
EntId string `json:"ent_id"`
}
func (this *User_order) AddUserOrder() error {
return DB.Create(this).Error
}
func CountUserOrder(query interface{}, args ...interface{}) uint {
var v uint
DB.Table("user_order").Where(query, args...).Count(&v)
return v
}
func FindUserOrders(page, pagesize int, query interface{}, args ...interface{}) []User_order {
offset := (page - 1) * pagesize
var res []User_order
DB.Table("user_order").Where(query, args...).Order("id desc").Offset(offset).Limit(pagesize).Find(&res)
return res
}
func FindUserOrder(query interface{}, args ...interface{}) User_order {
var res User_order
DB.Table("user_order").Where(query, args...).Order("id desc").First(&res)
return res
}
func UpdateUserOrderTypedWhere(status uint, query interface{}, args ...interface{}) {
values := map[string]uint{
"Type": status,
}
DB.Model(&User_order{}).Where(query, args...).Update(values)
}