智慧食堂
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

112 lignes
3.4 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. }
  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. }