面包店
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.
 
 
 
 
 

56 regels
1.4 KiB

  1. package db
  2. import (
  3. "applet/app/db/model"
  4. "applet/app/utils"
  5. "xorm.io/xorm"
  6. )
  7. func GetOrderGoodsDoingList(eg *xorm.Engine, param map[string]string) (*[]model.OrderGoods, int64) {
  8. var order []model.OrderGoods
  9. sess := eg.Where("state!=0 and state!=5")
  10. if param["admin_name"] != "" {
  11. var data []model.Admin
  12. eg.Where("memo like ?", "%"+param["admin_name"]+"%")
  13. ids := []int{-1}
  14. for _, v := range data {
  15. ids = append(ids, v.AdmId)
  16. }
  17. sess.In("admin_id", ids)
  18. }
  19. if param["enterprise_name"] != "" {
  20. var data []model.Enterprise
  21. eg.Where("name like ?", "%"+param["enterprise_name"]+"%")
  22. ids := []int{-1}
  23. for _, v := range data {
  24. ids = append(ids, v.Id)
  25. }
  26. sess.In("enterprise_id", ids)
  27. }
  28. if param["oid"] != "" {
  29. sess.And("oid like ?", "%"+param["oid"]+"%")
  30. }
  31. if param["state"] != "" {
  32. sess.And("state =?", param["state"])
  33. }
  34. if param["enterprise_id"] != "" {
  35. sess.And("enterprise_id =?", param["enterprise_id"])
  36. }
  37. if param["goods_title"] != "" {
  38. sess.And("goods_title like ?", "%"+param["goods_title"]+"%")
  39. }
  40. if param["start_time"] != "" {
  41. sess.And("time>=?", param["start_time"])
  42. }
  43. if param["end_time"] != "" {
  44. sess.And("time<=?", param["end_time"])
  45. }
  46. size := utils.StrToInt(param["limit"])
  47. start := (utils.StrToInt(param["page"]) - 1) * size
  48. count, err := sess.Limit(size, start).OrderBy("time desc,id desc").FindAndCount(&order)
  49. if err != nil {
  50. return nil, count
  51. }
  52. return &order, count
  53. }