智盟项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

db_playlet_sale_order.go 1.9 KiB

1 year ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package db
  2. import (
  3. "applet/app/db/model"
  4. "applet/app/utils"
  5. "xorm.io/xorm"
  6. )
  7. type PlayletSaleOrderDb struct {
  8. Db *xorm.Engine `json:"db"`
  9. }
  10. func (playletSaleOrderDb *PlayletSaleOrderDb) Set() { // set方法
  11. playletSaleOrderDb.Db = ZhimengDb
  12. }
  13. func (playletSaleOrderDb *PlayletSaleOrderDb) GetPlayletVideoOrderByOid(oid, ordType string) *model.PlayletSaleOrder {
  14. var data model.PlayletSaleOrder
  15. get, err := playletSaleOrderDb.Db.Where("oid=? and ord_type=?", oid, ordType).Get(&data)
  16. if get == false || err != nil {
  17. return nil
  18. }
  19. return &data
  20. }
  21. func (playletSaleOrderDb *PlayletSaleOrderDb) PlayletVideoOrderUpdate(id int, data *model.PlayletSaleOrder) bool {
  22. get, err := playletSaleOrderDb.Db.Where("id=?", id).Update(data)
  23. if get == 0 || err != nil {
  24. return false
  25. }
  26. return true
  27. }
  28. func (playletSaleOrderDb *PlayletSaleOrderDb) PlayletVideoOrderInsert(data *model.PlayletSaleOrder) bool {
  29. get, err := playletSaleOrderDb.Db.InsertOne(data)
  30. if get == 0 || err != nil {
  31. return false
  32. }
  33. return true
  34. }
  35. func (playletSaleOrderDb *PlayletSaleOrderDb) GetPlayletVideoOrderList(args map[string]string) []model.PlayletSaleOrder {
  36. /***
  37. p 页数
  38. size 个数
  39. start_time 开始时间
  40. end_time 结束时间
  41. ord_type 订单类型
  42. video_type 视频类型
  43. */
  44. var data = make([]model.PlayletSaleOrder, 0)
  45. size := utils.StrToInt(args["size"])
  46. offet := (utils.StrToInt(args["p"]) - 1) * size
  47. sess := playletSaleOrderDb.Db.Where("uid=?", args["mid"])
  48. if args["start_time"] != "" {
  49. sess = sess.And("update_time>=?", args["start_time"])
  50. }
  51. if args["end_time"] != "" {
  52. sess = sess.And("update_time>=?", args["end_time"])
  53. }
  54. if args["ord_type"] != "" {
  55. sess = sess.And("ord_type=?", args["ord_type"])
  56. }
  57. if args["video_type"] != "" {
  58. sess = sess.And("video_type=?", args["video_type"])
  59. }
  60. sess.Limit(size, offet).OrderBy("update_time desc,id desc").Find(&data)
  61. return data
  62. }