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

115 lines
3.7 KiB

  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. resp.IsOpenTeacherReportMealForDay = set.IsOpenTeacherReportMealForDay
  61. resp.IsOpenTeacherReportMealForMonth = set.IsOpenTeacherReportMealForMonth
  62. resp.IsOpenTeacherReportMealForSemester = set.IsOpenTeacherReportMealForSemester
  63. }
  64. return
  65. }
  66. func NursingHomePackageInfo(enterpriseId int) (err error, resp md.NursingHomePackageInfoResp) {
  67. //1、查询`enterprise`
  68. enterpriseDb := db.EnterpriseDb{}
  69. enterpriseDb.Set()
  70. enterprise, err := enterpriseDb.GetEnterprise(enterpriseId)
  71. if err != nil {
  72. return
  73. }
  74. resp.Name = enterprise.Name
  75. resp.Memo = enterprise.Memo
  76. resp.Kind = enterprise.Kind
  77. resp.State = enterprise.State
  78. //2、查询`central_kitchen_for_school_with_spec`
  79. centralKitchenForSchoolWithSpec := db.NursingHomeWithSpec{}
  80. centralKitchenForSchoolWithSpec.Set(enterpriseId)
  81. spec, err := centralKitchenForSchoolWithSpec.GetNursingHomeWithSpec()
  82. if err != nil {
  83. return
  84. }
  85. if spec != nil {
  86. resp.IsOpenBreakfast = spec.IsOpenBreakfast
  87. resp.IsOpenLunch = spec.IsOpenLunch
  88. resp.IsOpenDinner = spec.IsOpenDinner
  89. resp.BreakfastUnitPrice = spec.BreakfastUnitPrice
  90. resp.LunchUnitPrice = spec.LunchUnitPrice
  91. resp.DinnerUnitPrice = spec.DinnerUnitPrice
  92. }
  93. //3、查询`central_kitchen_for_school_set`
  94. centralKitchenForSchoolSetDb := db.NursingHomeSetDb{}
  95. centralKitchenForSchoolSetDb.Set(enterpriseId)
  96. set, err := centralKitchenForSchoolSetDb.GetNursingHomeSet()
  97. if err != nil {
  98. return
  99. }
  100. if set != nil {
  101. resp.IsOpenReportMealForDay = set.IsOpenReportMealForDay
  102. resp.IsOpenReportMealForMonth = set.IsOpenReportMealForMonth
  103. resp.IsOpenReportMealForYear = set.IsOpenReportMealForYear
  104. }
  105. return
  106. }