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

57 lines
1.6 KiB

  1. package db
  2. import (
  3. "applet/app/db/model"
  4. "applet/app/utils"
  5. "xorm.io/xorm"
  6. )
  7. func GetStoreAmount(sess *xorm.Session, storeId int, agentUid, storeType int) *model.CommunityTeamStoreAmount {
  8. var data model.CommunityTeamStoreAmount
  9. get, err := sess.Where("uid=? and parent_uid=? and store_type=?", storeId, agentUid, storeType).Get(&data)
  10. if get == false || err != nil {
  11. return nil
  12. }
  13. return &data
  14. }
  15. func GetStoreAmountEg(eg *xorm.Engine, storeId int, agentUid, storeType int) *model.CommunityTeamStoreAmount {
  16. var data model.CommunityTeamStoreAmount
  17. get, err := eg.Where("uid=? and parent_uid=? and store_type=?", storeId, agentUid, storeType).Get(&data)
  18. if get == false || err != nil {
  19. return nil
  20. }
  21. return &data
  22. }
  23. func GetStoreAmountFlowList(eg *xorm.Engine, arg map[string]string) (*[]model.CommunityTeamStoreAmountFlow, int64) {
  24. var data []model.CommunityTeamStoreAmountFlow
  25. sess := eg.Where("1=1")
  26. if arg["store_uid"] != "" {
  27. sess.And("uid=?", arg["store_uid"])
  28. }
  29. if arg["parent_uid"] != "" {
  30. sess.And("parent_uid=?", arg["parent_uid"])
  31. }
  32. if arg["store_type"] != "" {
  33. sess.And("store_type=?", arg["store_type"])
  34. }
  35. if arg["title"] != "" {
  36. sess.And("title like ?", "%"+arg["title"]+"%")
  37. }
  38. if arg["oid"] != "" {
  39. sess.And("oid like ?", "%"+arg["oid"]+"%")
  40. }
  41. if arg["start_time"] != "" {
  42. sess.And("create_at>=?", arg["start_time"])
  43. }
  44. if arg["end_time"] != "" {
  45. sess.And("create_at<=?", arg["end_time"])
  46. }
  47. limit := utils.StrToInt(arg["size"])
  48. start := (utils.StrToInt(arg["p"]) - 1) * limit
  49. count, err := sess.Desc("id").Limit(limit, start).FindAndCount(&data)
  50. if err != nil {
  51. return nil, count
  52. }
  53. return &data, count
  54. }