|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- package db
-
- import (
- "applet/app/db/model"
- "applet/app/utils"
- "xorm.io/xorm"
- )
-
- type PlayletSaleOrderDb struct {
- Db *xorm.Engine `json:"db"`
- }
-
- func (playletSaleOrderDb *PlayletSaleOrderDb) Set() { // set方法
- playletSaleOrderDb.Db = ZhimengDb
- }
-
- func (playletSaleOrderDb *PlayletSaleOrderDb) GetPlayletVideoOrderByOid(oid, ordType string) *model.PlayletSaleOrder {
- var data model.PlayletSaleOrder
- get, err := playletSaleOrderDb.Db.Where("oid=? and ord_type=?", oid, ordType).Get(&data)
- if get == false || err != nil {
- return nil
- }
- return &data
- }
-
- func (playletSaleOrderDb *PlayletSaleOrderDb) PlayletVideoOrderUpdate(id int, data *model.PlayletSaleOrder) bool {
- get, err := playletSaleOrderDb.Db.Where("id=?", id).Update(data)
- if get == 0 || err != nil {
- return false
- }
- return true
- }
-
- func (playletSaleOrderDb *PlayletSaleOrderDb) PlayletVideoOrderInsert(data *model.PlayletSaleOrder) bool {
- get, err := playletSaleOrderDb.Db.InsertOne(data)
- if get == 0 || err != nil {
- return false
- }
- return true
- }
-
- func (playletSaleOrderDb *PlayletSaleOrderDb) GetPlayletVideoOrderList(args map[string]string) []model.PlayletSaleOrder {
- /***
- p 页数
- size 个数
- start_time 开始时间
- end_time 结束时间
- ord_type 订单类型
- video_type 视频类型
-
- */
- var data = make([]model.PlayletSaleOrder, 0)
- size := utils.StrToInt(args["size"])
- offet := (utils.StrToInt(args["p"]) - 1) * size
- sess := playletSaleOrderDb.Db.Where("uid=?", args["mid"])
- if args["start_time"] != "" {
- sess = sess.And("update_time>=?", args["start_time"])
- }
- if args["end_time"] != "" {
- sess = sess.And("update_time>=?", args["end_time"])
- }
- if args["ord_type"] != "" {
- sess = sess.And("ord_type=?", args["ord_type"])
- }
- if args["video_type"] != "" {
- sess = sess.And("video_type=?", args["video_type"])
- }
- sess.Limit(size, offet).OrderBy("update_time desc,id desc").Find(&data)
- return data
- }
|