智慧食堂-队列消费项目
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 4.5 KiB

2 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. package svc
  2. import (
  3. "applet/app/customer/md"
  4. "applet/app/db"
  5. "applet/app/db/model"
  6. "applet/app/enum"
  7. )
  8. func EnterpriseList(req md.EnterpriseListReq, platform string) (m []model.Enterprise, total int64, err error) {
  9. eg := db.Db.Where("1=1")
  10. if platform == "wx_applet" {
  11. eg.And("pvd != ? ", enum.EnterprisePvdForFaceScanPayment).Or("pvd = ? and mode !=?", enum.EnterprisePvdForFaceScanPayment, enum.EnterpriseModeForSchool)
  12. }
  13. if platform == "alipay_applet" {
  14. //TODO::暂只开放金茂小学支付宝购买权限
  15. eg.And("pvd != ? ", enum.EnterprisePvdForOnlinePayment).Or("pvd = ? and mode !=?", enum.EnterprisePvdForOnlinePayment, enum.EnterpriseModeForSchool).Or("id = 7")
  16. }
  17. if req.Name != "" {
  18. eg.And("name like ?", "%"+req.Name+"%")
  19. }
  20. total, err = eg.Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m)
  21. if err != nil {
  22. return
  23. }
  24. return
  25. }
  26. func CentralKitchenForSchoolInfo(enterpriseId int) (err error, resp md.CentralKitchenForSchoolInfoResp) {
  27. //1、查询`enterprise`
  28. enterpriseDb := db.EnterpriseDb{}
  29. enterpriseDb.Set()
  30. enterprise, err := enterpriseDb.GetEnterprise(enterpriseId)
  31. if err != nil {
  32. return
  33. }
  34. resp.Name = enterprise.Name
  35. resp.Memo = enterprise.Memo
  36. resp.Kind = enterprise.Kind
  37. resp.State = enterprise.State
  38. //2、查询`central_kitchen_for_school_with_spec`
  39. centralKitchenForSchoolWithSpec := db.CentralKitchenForSchoolWithSpec{}
  40. centralKitchenForSchoolWithSpec.Set(enterpriseId)
  41. spec, err := centralKitchenForSchoolWithSpec.GetCentralKitchenForSchoolWithSpec()
  42. if err != nil {
  43. return
  44. }
  45. if spec != nil {
  46. resp.IsOpenBreakfast = spec.IsOpenBreakfast
  47. resp.IsOpenLunch = spec.IsOpenLunch
  48. resp.IsOpenDinner = spec.IsOpenDinner
  49. resp.IsOpenBreakfastForTeacher = spec.IsOpenBreakfastForTeacher
  50. resp.IsOpenLunchForTeacher = spec.IsOpenLunchForTeacher
  51. resp.IsOpenDinnerForTeacher = spec.IsOpenDinnerForTeacher
  52. resp.BreakfastUnitPrice = spec.BreakfastUnitPrice
  53. resp.BreakfastUnitPriceForTeacher = spec.BreakfastUnitPriceForTeacher
  54. resp.LunchUnitPrice = spec.LunchUnitPrice
  55. resp.LunchUnitPriceForTeacher = spec.LunchUnitPriceForTeacher
  56. resp.DinnerUnitPrice = spec.DinnerUnitPrice
  57. resp.DinnerUnitPriceForTeacher = spec.DinnerUnitPriceForTeacher
  58. resp.BreakfastTeacherNotice = spec.BreakfastTeacherNotice
  59. resp.LunchTeacherNotice = spec.LunchTeacherNotice
  60. resp.DinnerTeacherNotice = spec.DinnerTeacherNotice
  61. }
  62. //3、查询`central_kitchen_for_school_set`
  63. centralKitchenForSchoolSetDb := db.CentralKitchenForSchoolSetDb{}
  64. centralKitchenForSchoolSetDb.Set(enterpriseId)
  65. set, err := centralKitchenForSchoolSetDb.GetCentralKitchenForSchoolSet()
  66. if err != nil {
  67. return
  68. }
  69. if set != nil {
  70. resp.IsOpenTeacherReportMeal = set.IsOpenTeacherReportMeal
  71. resp.IsOpenReportMealForDay = set.IsOpenReportMealForDay
  72. resp.IsOpenReportMealForMonth = set.IsOpenReportMealForMonth
  73. resp.IsOpenReportMealForSemester = set.IsOpenReportMealForSemester
  74. resp.IsOpenTeacherReportMealForDay = set.IsOpenTeacherReportMealForDay
  75. resp.IsOpenTeacherReportMealForMonth = set.IsOpenTeacherReportMealForMonth
  76. resp.IsOpenTeacherReportMealForSemester = set.IsOpenTeacherReportMealForSemester
  77. }
  78. return
  79. }
  80. func NursingHomePackageInfo(enterpriseId int) (err error, resp md.NursingHomePackageInfoResp) {
  81. //1、查询`enterprise`
  82. enterpriseDb := db.EnterpriseDb{}
  83. enterpriseDb.Set()
  84. enterprise, err := enterpriseDb.GetEnterprise(enterpriseId)
  85. if err != nil {
  86. return
  87. }
  88. resp.Name = enterprise.Name
  89. resp.Memo = enterprise.Memo
  90. resp.Kind = enterprise.Kind
  91. resp.State = enterprise.State
  92. //2、查询`central_kitchen_for_school_with_spec`
  93. centralKitchenForSchoolWithSpec := db.NursingHomeWithSpec{}
  94. centralKitchenForSchoolWithSpec.Set(enterpriseId)
  95. spec, err := centralKitchenForSchoolWithSpec.GetNursingHomeWithSpec()
  96. if err != nil {
  97. return
  98. }
  99. if spec != nil {
  100. resp.IsOpenBreakfast = spec.IsOpenBreakfast
  101. resp.IsOpenLunch = spec.IsOpenLunch
  102. resp.IsOpenDinner = spec.IsOpenDinner
  103. resp.BreakfastUnitPrice = spec.BreakfastUnitPrice
  104. resp.LunchUnitPrice = spec.LunchUnitPrice
  105. resp.DinnerUnitPrice = spec.DinnerUnitPrice
  106. }
  107. //3、查询`central_kitchen_for_school_set`
  108. centralKitchenForSchoolSetDb := db.NursingHomeSetDb{}
  109. centralKitchenForSchoolSetDb.Set(enterpriseId)
  110. set, err := centralKitchenForSchoolSetDb.GetNursingHomeSet()
  111. if err != nil {
  112. return
  113. }
  114. if set != nil {
  115. resp.IsOpenReportMealForDay = set.IsOpenReportMealForDay
  116. resp.IsOpenReportMealForMonth = set.IsOpenReportMealForMonth
  117. resp.IsOpenReportMealForYear = set.IsOpenReportMealForYear
  118. }
  119. return
  120. }