附近小店
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.
 
 
 

99 lines
2.6 KiB

  1. package db
  2. import (
  3. "applet/app/db/model"
  4. "applet/app/utils"
  5. "strings"
  6. "xorm.io/xorm"
  7. )
  8. func GetStoreWithdraw(eg *xorm.Engine, arg map[string]string) (*[]model.CommunityTeamStoreWithdrawApply, int64) {
  9. var data []model.CommunityTeamStoreWithdrawApply
  10. sess := CommWhere(eg, arg)
  11. limit := utils.StrToInt(arg["size"])
  12. start := (utils.StrToInt(arg["p"]) - 1) * limit
  13. if limit > 0 {
  14. sess.Limit(limit, start)
  15. }
  16. count, err := sess.Desc("id").FindAndCount(&data)
  17. if err != nil {
  18. return nil, count
  19. }
  20. return &data, count
  21. }
  22. func GetStoreFlow(eg *xorm.Engine, arg map[string]string) (*[]model.CommunityTeamStoreAmountFlow, int64) {
  23. var data []model.CommunityTeamStoreAmountFlow
  24. sess := eg.Where("1=1")
  25. if arg["store_uid"] != "" {
  26. sess.And("uid=?", arg["store_uid"])
  27. }
  28. if arg["ord_type"] != "" {
  29. sess.And("ord_type=?", arg["ord_type"])
  30. }
  31. limit := utils.StrToInt(arg["size"])
  32. start := (utils.StrToInt(arg["p"]) - 1) * limit
  33. if limit > 0 {
  34. sess.Limit(limit, start)
  35. }
  36. count, err := sess.Desc("id").FindAndCount(&data)
  37. if err != nil {
  38. return nil, count
  39. }
  40. return &data, count
  41. }
  42. func CommWhere(eg *xorm.Engine, arg map[string]string) *xorm.Session {
  43. sess := eg.Where("1=1")
  44. if arg["store_uid"] != "" {
  45. sess.And("uid=?", arg["store_uid"])
  46. }
  47. if arg["parent_uid"] != "" {
  48. sess.And("parent_uid=?", arg["parent_uid"])
  49. }
  50. if arg["store_type"] != "" {
  51. sess.And("store_type=?", arg["store_type"])
  52. }
  53. if arg["state"] != "" {
  54. sess.And("state=?", arg["state"])
  55. }
  56. if arg["ids"] != "" {
  57. sess.In("id", strings.Split(arg["ids"], ","))
  58. }
  59. if arg["alipay_account"] != "" {
  60. sess.And("withdraw_account like ?", "%"+arg["alipay_account"]+"%")
  61. }
  62. if arg["alipay_name"] != "" {
  63. sess.And("withdraw_name like ?", "%"+arg["alipay_name"]+"%")
  64. }
  65. if arg["store_name"] != "" {
  66. var data1 []model.CommunityTeamStore
  67. eg.Where("name like ?", "%"+arg["store_name"]+"%").Find(&data1)
  68. uid := []int{-1}
  69. for _, v := range data1 {
  70. uid = append(uid, v.Uid)
  71. }
  72. sess.In("uid", uid)
  73. }
  74. if arg["start_time"] != "" {
  75. sess.And("create_at>=?", arg["start_time"])
  76. }
  77. if arg["end_time"] != "" {
  78. sess.And("create_at<=?", arg["end_time"])
  79. }
  80. if arg["payment_start_time"] != "" {
  81. sess.And("payment_date>=?", arg["payment_start_time"])
  82. }
  83. if arg["payment_end_time"] != "" {
  84. sess.And("payment_date<=?", arg["payment_end_time"])
  85. }
  86. return sess
  87. }
  88. func GetStoreWithdrawById(sess *xorm.Session, id string) *model.CommunityTeamStoreWithdrawApply {
  89. var data model.CommunityTeamStoreWithdrawApply
  90. get, err := sess.Where("id=?", id).Get(&data)
  91. if get == false || err != nil {
  92. return nil
  93. }
  94. return &data
  95. }