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

78 lines
2.0 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 CommWhere(eg *xorm.Engine, arg map[string]string) *xorm.Session {
  23. sess := eg.Where("1=1")
  24. if arg["store_uid"] != "" {
  25. sess.And("uid=?", arg["store_uid"])
  26. }
  27. if arg["parent_uid"] != "" {
  28. sess.And("parent_uid=?", arg["parent_uid"])
  29. }
  30. if arg["store_type"] != "" {
  31. sess.And("store_type=?", arg["store_type"])
  32. }
  33. if arg["state"] != "" {
  34. sess.And("state=?", arg["state"])
  35. }
  36. if arg["ids"] != "" {
  37. sess.In("id", strings.Split(arg["ids"], ","))
  38. }
  39. if arg["alipay_account"] != "" {
  40. sess.And("withdraw_account like ?", "%"+arg["alipay_account"]+"%")
  41. }
  42. if arg["alipay_name"] != "" {
  43. sess.And("withdraw_name like ?", "%"+arg["alipay_name"]+"%")
  44. }
  45. if arg["store_name"] != "" {
  46. var data1 []model.CommunityTeamStore
  47. eg.Where("name like ?", "%"+arg["store_name"]+"%").Find(&data1)
  48. uid := []int{-1}
  49. for _, v := range data1 {
  50. uid = append(uid, v.Uid)
  51. }
  52. sess.In("uid", uid)
  53. }
  54. if arg["start_time"] != "" {
  55. sess.And("create_at>=?", arg["start_time"])
  56. }
  57. if arg["end_time"] != "" {
  58. sess.And("create_at<=?", arg["end_time"])
  59. }
  60. if arg["payment_start_time"] != "" {
  61. sess.And("payment_date>=?", arg["payment_start_time"])
  62. }
  63. if arg["payment_end_time"] != "" {
  64. sess.And("payment_date<=?", arg["payment_end_time"])
  65. }
  66. return sess
  67. }
  68. func GetStoreWithdrawById(sess *xorm.Session, id string) *model.CommunityTeamStoreWithdrawApply {
  69. var data model.CommunityTeamStoreWithdrawApply
  70. get, err := sess.Where("id=?", id).Get(&data)
  71. if get == false || err != nil {
  72. return nil
  73. }
  74. return &data
  75. }