面包店
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

53 行
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.OrderGoodsDoingFlow, int64) {
  8. var order []model.OrderGoodsDoingFlow
  9. sess := eg.Where("1=1")
  10. if param["admin_name"] != "" {
  11. var data []model.Admin
  12. eg.Where("memo like ?", "%"+param["admin_name"]+"%").Find(&data)
  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"]+"%").Find(&data)
  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["state"] != "" {
  29. sess.And("state =?", param["state"])
  30. }
  31. if param["enterprise_id"] != "" {
  32. sess.And("enterprise_id =?", param["enterprise_id"])
  33. }
  34. if param["goods_title"] != "" {
  35. sess.And("goods_title like ?", "%"+param["goods_title"]+"%")
  36. }
  37. if param["start_time"] != "" {
  38. sess.And("time>=?", param["start_time"])
  39. }
  40. if param["end_time"] != "" {
  41. sess.And("time<=?", param["end_time"])
  42. }
  43. size := utils.StrToInt(param["limit"])
  44. start := (utils.StrToInt(param["page"]) - 1) * size
  45. count, err := sess.Limit(size, start).OrderBy("time desc,id desc").FindAndCount(&order)
  46. if err != nil {
  47. return nil, count
  48. }
  49. return &order, count
  50. }