附近小店
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_store_withdraw.go 1.9 KiB

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