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

db_order_goods_doing.go 1.6 KiB

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