附近小店
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

db_order.go 4.1 KiB

2 mesi fa
2 mesi fa
2 mesi fa
2 mesi fa
2 mesi fa
1 mese fa
2 mesi fa
2 mesi fa
2 mesi fa
2 mesi fa
2 mesi fa
2 mesi fa
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. package db
  2. import (
  3. "applet/app/db/model"
  4. "applet/app/md"
  5. "applet/app/utils"
  6. "xorm.io/xorm"
  7. )
  8. func GetOrderByOid(eg *xorm.Engine, oid string) *model.CommunityTeamOrder {
  9. var data model.CommunityTeamOrder
  10. get, err := eg.Where("oid=?", oid).Get(&data)
  11. if get == false || err != nil {
  12. return nil
  13. }
  14. return &data
  15. }
  16. func GetOrderEg(eg *xorm.Engine, oid string) *model.CommunityTeamOrder {
  17. var data model.CommunityTeamOrder
  18. get, err := eg.Where("oid=?", oid).Get(&data)
  19. if get == false || err != nil {
  20. return nil
  21. }
  22. return &data
  23. }
  24. func GetOrderPayEg(eg *xorm.Engine, oid string) *model.CommunityTeamPayOrder {
  25. var data model.CommunityTeamPayOrder
  26. get, err := eg.Where("oid=?", oid).Get(&data)
  27. if get == false || err != nil {
  28. return nil
  29. }
  30. return &data
  31. }
  32. func GetOrderPay(sess *xorm.Session, oid string) *model.CommunityTeamPayOrder {
  33. var data model.CommunityTeamPayOrder
  34. get, err := sess.Where("oid=?", oid).Get(&data)
  35. if get == false || err != nil {
  36. return nil
  37. }
  38. return &data
  39. }
  40. func GetOrder(sess *xorm.Session, oid string) *model.CommunityTeamOrder {
  41. var data model.CommunityTeamOrder
  42. get, err := sess.Where("oid=?", oid).Get(&data)
  43. if get == false || err != nil {
  44. return nil
  45. }
  46. return &data
  47. }
  48. func GetOrderInfo(sess *xorm.Session, oid string) *[]model.CommunityTeamOrderInfo {
  49. var data []model.CommunityTeamOrderInfo
  50. err := sess.Where("oid=?", oid).Find(&data)
  51. if err != nil {
  52. return nil
  53. }
  54. return &data
  55. }
  56. func GetOrderInfoAllEg(eg *xorm.Engine, oid string) *[]model.CommunityTeamOrderInfo {
  57. var data []model.CommunityTeamOrderInfo
  58. err := eg.Where("oid=?", oid).Find(&data)
  59. if err != nil {
  60. return nil
  61. }
  62. return &data
  63. }
  64. func GetOrderInfoEg(eg *xorm.Engine, oid string) *model.CommunityTeamOrderInfo {
  65. var data model.CommunityTeamOrderInfo
  66. get, err := eg.Where("oid=?", oid).Asc("id").Get(&data)
  67. if get == false || err != nil {
  68. return nil
  69. }
  70. return &data
  71. }
  72. func GetOrderList(eg *xorm.Engine, arg map[string]string) *[]model.CommunityTeamOrder {
  73. var data []model.CommunityTeamOrder
  74. sess := eg.Where("1=1")
  75. if arg["uid"] != "" {
  76. sess.And("uid=?", arg["uid"])
  77. }
  78. if arg["state"] != "" {
  79. sess.And("state=?", arg["state"])
  80. }
  81. if arg["store_uid"] != "" {
  82. sess.And("store_uid=?", arg["store_uid"])
  83. }
  84. if arg["code"] != "" {
  85. sess.And("code=?", arg["code"])
  86. }
  87. limit := utils.StrToInt(arg["size"])
  88. start := (utils.StrToInt(arg["p"]) - 1) * limit
  89. err := sess.OrderBy("id desc").Limit(limit, start).Find(&data)
  90. if err != nil {
  91. return nil
  92. }
  93. return &data
  94. }
  95. func GetStoreOrderList(eg *xorm.Engine, req md.StoreOrder, parent_uid int) (*[]model.CommunityTeamOrder, int64, error) {
  96. var data []model.CommunityTeamOrder
  97. sess := eg.Where("1=1")
  98. if req.Oid != "" {
  99. sess.And("oid like ?", "%"+req.Oid+"%")
  100. }
  101. if req.StoreName != "" {
  102. var store []model.CommunityTeamStore
  103. eg.Where("name like ?", "%"+req.StoreName+"%").Find(&store)
  104. ids := []int{-1}
  105. for _, v := range store {
  106. ids = append(ids, v.Id)
  107. }
  108. sess.In("store_uid", ids)
  109. }
  110. if req.Phone != "" {
  111. var user []model.User
  112. eg.Where("phone like ?", "%"+req.Phone+"%").Find(&user)
  113. ids := []int{-1}
  114. for _, v := range user {
  115. ids = append(ids, v.Uid)
  116. }
  117. sess.In("uid", ids)
  118. }
  119. if req.Nickname != "" {
  120. var user []model.User
  121. eg.Where("nickname like ?", "%"+req.Nickname+"%").Find(&user)
  122. ids := []int{-1}
  123. for _, v := range user {
  124. ids = append(ids, v.Uid)
  125. }
  126. sess.In("uid", ids)
  127. }
  128. if req.StoreUid != "" {
  129. sess.And("store_uid=?", req.StoreUid)
  130. }
  131. if req.StoreType != "" {
  132. sess.And("store_type=?", req.StoreType)
  133. }
  134. if parent_uid > 0 {
  135. sess.And("parent_uid=?", parent_uid)
  136. }
  137. if req.StartTime != "" {
  138. sess.And("create_at>=?", req.StartTime)
  139. }
  140. if req.EndTime != "" {
  141. sess.And("create_at<=?", req.EndTime)
  142. }
  143. if req.ConfirmStartTime != "" {
  144. sess.And("confirm_at>=?", req.ConfirmStartTime)
  145. }
  146. if req.ConfirmEndTime != "" {
  147. sess.And("confirm_at<=?", req.ConfirmEndTime)
  148. }
  149. size := utils.StrToInt(req.Size)
  150. start := (utils.StrToInt(req.P) - 1) * size
  151. count, err := sess.Limit(size, start).OrderBy("create_at desc,id desc").FindAndCount(&data)
  152. if err != nil {
  153. return nil, 0, err
  154. }
  155. return &data, count, nil
  156. }