附近小店
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

38 wiersze
1022 B

  1. package db
  2. import (
  3. "applet/app/db/model"
  4. "applet/app/utils"
  5. "time"
  6. "xorm.io/xorm"
  7. )
  8. func GetCoupon(eg *xorm.Engine, req map[string]string) *[]model.CommunityTeamCoupon {
  9. var data []model.CommunityTeamCoupon
  10. limit := 10
  11. start := (utils.StrToInt(req["p"]) - 1) * limit
  12. sess := eg.Where("store_type=0 and num>0 and state=1 and ((valid_time_end>? and valid_time_type=1) or valid_time_type=2)", time.Now().Format("2006-01-02 15:04:05")).OrderBy("sort desc,id desc").Limit(limit, start)
  13. if req["name"] != "" {
  14. sess.And("name like ?", "%"+req["name"]+"%")
  15. }
  16. if req["start_time"] != "" {
  17. sess.And("created_time>=?", req["start_time"])
  18. }
  19. if req["end_time"] != "" {
  20. sess.And("created_time<=?", req["end_time"])
  21. }
  22. err := sess.Find(&data)
  23. if err != nil {
  24. return nil
  25. }
  26. return &data
  27. }
  28. func GetCouponById(eg *xorm.Engine, id string) *model.CommunityTeamCoupon {
  29. var data model.CommunityTeamCoupon
  30. get, err := eg.Where("id=?", id).Get(&data)
  31. if get == false || err != nil {
  32. return nil
  33. }
  34. return &data
  35. }