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

37 lines
898 B

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