智慧食堂
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.

svc_enterprise.go 3.4 KiB

пре 1 година
пре 1 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. package svc
  2. import (
  3. "applet/app/customer/md"
  4. "applet/app/db"
  5. "applet/app/db/model"
  6. )
  7. func EnterpriseList(req md.EnterpriseListReq) (m []model.Enterprise, total int64, err error) {
  8. eg := db.Db.Where("1=1")
  9. if req.Name != "" {
  10. eg.And("name like ?", "%"+req.Name+"%")
  11. }
  12. total, err = eg.Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m)
  13. if err != nil {
  14. return
  15. }
  16. return
  17. }
  18. func CentralKitchenForSchoolInfo(enterpriseId int) (err error, resp md.CentralKitchenForSchoolInfoResp) {
  19. //1、查询`enterprise`
  20. enterpriseDb := db.EnterpriseDb{}
  21. enterpriseDb.Set()
  22. enterprise, err := enterpriseDb.GetEnterprise(enterpriseId)
  23. if err != nil {
  24. return
  25. }
  26. resp.Name = enterprise.Name
  27. resp.Memo = enterprise.Memo
  28. resp.Kind = enterprise.Kind
  29. resp.State = enterprise.State
  30. //2、查询`central_kitchen_for_school_with_spec`
  31. centralKitchenForSchoolWithSpec := db.CentralKitchenForSchoolWithSpec{}
  32. centralKitchenForSchoolWithSpec.Set(enterpriseId)
  33. spec, err := centralKitchenForSchoolWithSpec.GetCentralKitchenForSchoolWithSpec()
  34. if err != nil {
  35. return
  36. }
  37. if spec != nil {
  38. resp.IsOpenBreakfast = spec.IsOpenBreakfast
  39. resp.IsOpenLunch = spec.IsOpenLunch
  40. resp.IsOpenDinner = spec.IsOpenDinner
  41. resp.BreakfastUnitPrice = spec.BreakfastUnitPrice
  42. resp.BreakfastUnitPriceForTeacher = spec.BreakfastUnitPriceForTeacher
  43. resp.LunchUnitPrice = spec.LunchUnitPrice
  44. resp.LunchUnitPriceForTeacher = spec.LunchUnitPriceForTeacher
  45. resp.DinnerUnitPrice = spec.DinnerUnitPrice
  46. resp.DinnerUnitPriceForTeacher = spec.DinnerUnitPriceForTeacher
  47. }
  48. //3、查询`central_kitchen_for_school_set`
  49. centralKitchenForSchoolSetDb := db.CentralKitchenForSchoolSetDb{}
  50. centralKitchenForSchoolSetDb.Set(enterpriseId)
  51. set, err := centralKitchenForSchoolSetDb.GetCentralKitchenForSchoolSet()
  52. if err != nil {
  53. return
  54. }
  55. if set != nil {
  56. resp.IsOpenTeacherReportMeal = set.IsOpenTeacherReportMeal
  57. resp.IsOpenReportMealForDay = set.IsOpenReportMealForDay
  58. resp.IsOpenReportMealForMonth = set.IsOpenReportMealForMonth
  59. resp.IsOpenReportMealForSemester = set.IsOpenReportMealForSemester
  60. }
  61. return
  62. }
  63. func NursingHomePackageInfo(enterpriseId int) (err error, resp md.NursingHomePackageInfoResp) {
  64. //1、查询`enterprise`
  65. enterpriseDb := db.EnterpriseDb{}
  66. enterpriseDb.Set()
  67. enterprise, err := enterpriseDb.GetEnterprise(enterpriseId)
  68. if err != nil {
  69. return
  70. }
  71. resp.Name = enterprise.Name
  72. resp.Memo = enterprise.Memo
  73. resp.Kind = enterprise.Kind
  74. resp.State = enterprise.State
  75. //2、查询`central_kitchen_for_school_with_spec`
  76. centralKitchenForSchoolWithSpec := db.NursingHomeWithSpec{}
  77. centralKitchenForSchoolWithSpec.Set(enterpriseId)
  78. spec, err := centralKitchenForSchoolWithSpec.GetNursingHomeWithSpec()
  79. if err != nil {
  80. return
  81. }
  82. if spec != nil {
  83. resp.IsOpenBreakfast = spec.IsOpenBreakfast
  84. resp.IsOpenLunch = spec.IsOpenLunch
  85. resp.IsOpenDinner = spec.IsOpenDinner
  86. resp.BreakfastUnitPrice = spec.BreakfastUnitPrice
  87. resp.LunchUnitPrice = spec.LunchUnitPrice
  88. resp.DinnerUnitPrice = spec.DinnerUnitPrice
  89. }
  90. //3、查询`central_kitchen_for_school_set`
  91. centralKitchenForSchoolSetDb := db.NursingHomeSetDb{}
  92. centralKitchenForSchoolSetDb.Set(enterpriseId)
  93. set, err := centralKitchenForSchoolSetDb.GetNursingHomeSet()
  94. if err != nil {
  95. return
  96. }
  97. if set != nil {
  98. resp.IsOpenReportMealForDay = set.IsOpenReportMealForDay
  99. resp.IsOpenReportMealForMonth = set.IsOpenReportMealForMonth
  100. resp.IsOpenReportMealForYear = set.IsOpenReportMealForYear
  101. }
  102. return
  103. }