智慧食堂
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

svc_enterprise.go 4.3 KiB

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