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

72 lines
1.8 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 := eg.Where("1=1")
  11. if arg["store_uid"] != "" {
  12. sess.And("uid=?", arg["store_uid"])
  13. }
  14. if arg["parent_uid"] != "" {
  15. sess.And("parent_uid=?", arg["parent_uid"])
  16. }
  17. if arg["state"] != "" {
  18. sess.And("state=?", arg["state"])
  19. }
  20. if arg["ids"] != "" {
  21. sess.In("id", strings.Split(arg["ids"], ","))
  22. }
  23. if arg["alipay_account"] != "" {
  24. sess.And("withdraw_account like ?", "%"+arg["alipay_account"]+"%")
  25. }
  26. if arg["alipay_name"] != "" {
  27. sess.And("withdraw_name like ?", "%"+arg["alipay_name"]+"%")
  28. }
  29. if arg["store_name"] != "" {
  30. var data1 []model.CommunityTeamStore
  31. eg.Where("name like ?", "%"+arg["store_name"]+"%").Find(&data1)
  32. uid := []int{-1}
  33. for _, v := range data1 {
  34. uid = append(uid, v.Uid)
  35. }
  36. sess.In("uid", uid)
  37. }
  38. if arg["start_time"] != "" {
  39. sess.And("create_at>=?", arg["start_time"])
  40. }
  41. if arg["end_time"] != "" {
  42. sess.And("create_at<=?", arg["end_time"])
  43. }
  44. if arg["payment_start_time"] != "" {
  45. sess.And("payment_date>=?", arg["payment_start_time"])
  46. }
  47. if arg["payment_end_time"] != "" {
  48. sess.And("payment_date<=?", arg["payment_end_time"])
  49. }
  50. limit := utils.StrToInt(arg["size"])
  51. start := (utils.StrToInt(arg["p"]) - 1) * limit
  52. if limit > 0 {
  53. sess.Limit(limit, start)
  54. }
  55. count, err := sess.Desc("id").FindAndCount(&data)
  56. if err != nil {
  57. return nil, count
  58. }
  59. return &data, count
  60. }
  61. func GetStoreWithdrawById(sess *xorm.Session, id string) *model.CommunityTeamStoreWithdrawApply {
  62. var data model.CommunityTeamStoreWithdrawApply
  63. get, err := sess.Where("id=?", id).Get(&data)
  64. if get == false || err != nil {
  65. return nil
  66. }
  67. return &data
  68. }