附近小店
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_order.go 1.8 KiB

3 月之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package db
  2. import (
  3. "applet/app/db/model"
  4. "applet/app/utils"
  5. "xorm.io/xorm"
  6. )
  7. func GetOrderEg(eg *xorm.Engine, oid string) *model.CommunityTeamOrder {
  8. var data model.CommunityTeamOrder
  9. get, err := eg.Where("oid=?", oid).Get(&data)
  10. if get == false || err != nil {
  11. return nil
  12. }
  13. return &data
  14. }
  15. func GetOrder(sess *xorm.Session, oid string) *model.CommunityTeamOrder {
  16. var data model.CommunityTeamOrder
  17. get, err := sess.Where("oid=?", oid).Get(&data)
  18. if get == false || err != nil {
  19. return nil
  20. }
  21. return &data
  22. }
  23. func GetOrderInfo(sess *xorm.Session, oid string) *[]model.CommunityTeamOrderInfo {
  24. var data []model.CommunityTeamOrderInfo
  25. err := sess.Where("oid=?", oid).Find(&data)
  26. if err != nil {
  27. return nil
  28. }
  29. return &data
  30. }
  31. func GetOrderInfoAllEg(eg *xorm.Engine, oid string) *[]model.CommunityTeamOrderInfo {
  32. var data []model.CommunityTeamOrderInfo
  33. err := eg.Where("oid=?", oid).Find(&data)
  34. if err != nil {
  35. return nil
  36. }
  37. return &data
  38. }
  39. func GetOrderInfoEg(eg *xorm.Engine, oid string) *model.CommunityTeamOrderInfo {
  40. var data model.CommunityTeamOrderInfo
  41. get, err := eg.Where("oid=?", oid).Asc("id").Get(&data)
  42. if get == false || err != nil {
  43. return nil
  44. }
  45. return &data
  46. }
  47. func GetOrderList(eg *xorm.Engine, arg map[string]string) *[]model.CommunityTeamOrder {
  48. var data []model.CommunityTeamOrder
  49. sess := eg.Where("1=1")
  50. if arg["uid"] != "" {
  51. sess.And("uid=?", arg["uid"])
  52. }
  53. if arg["state"] != "" {
  54. sess.And("state=?", arg["state"])
  55. }
  56. if arg["store_uid"] != "" {
  57. sess.And("store_uid=?", arg["store_uid"])
  58. }
  59. if arg["code"] != "" {
  60. sess.And("code=?", arg["code"])
  61. }
  62. limit := utils.StrToInt(arg["size"])
  63. start := (utils.StrToInt(arg["p"]) - 1) * limit
  64. err := sess.OrderBy("id desc").Limit(limit, start).Find(&data)
  65. if err != nil {
  66. return nil
  67. }
  68. return &data
  69. }