|
- package svc
-
- import (
- "applet/app/customer/md"
- "applet/app/db"
- "applet/app/db/model"
- "applet/app/enum"
- )
-
- func EnterpriseList(req md.EnterpriseListReq, platform string) (m []model.Enterprise, total int64, err error) {
- eg := db.Db.Where("1=1")
- if platform == "wx_applet" {
- eg.And("pvd != ? ", enum.EnterprisePvdForFaceScanPayment).Or("pvd = ? and mode !=?", enum.EnterprisePvdForFaceScanPayment, enum.EnterpriseModeForSchool)
- }
- if platform == "alipay_applet" {
- //TODO::暂只开放金茂小学支付宝购买权限
- eg.And("pvd != ? ", enum.EnterprisePvdForOnlinePayment).Or("pvd = ? and mode !=?", enum.EnterprisePvdForOnlinePayment, enum.EnterpriseModeForSchool).Or("id = 7")
- }
- if req.Name != "" {
- eg.And("name like ?", "%"+req.Name+"%")
- }
- total, err = eg.Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m)
- if err != nil {
- return
- }
- return
- }
-
- func CentralKitchenForSchoolInfo(enterpriseId int) (err error, resp md.CentralKitchenForSchoolInfoResp) {
- //1、查询`enterprise`
- enterpriseDb := db.EnterpriseDb{}
- enterpriseDb.Set()
- enterprise, err := enterpriseDb.GetEnterprise(enterpriseId)
- if err != nil {
- return
- }
- resp.Name = enterprise.Name
- resp.Memo = enterprise.Memo
- resp.Kind = enterprise.Kind
- resp.State = enterprise.State
-
- //2、查询`central_kitchen_for_school_with_spec`
- centralKitchenForSchoolWithSpec := db.CentralKitchenForSchoolWithSpec{}
- centralKitchenForSchoolWithSpec.Set(enterpriseId)
- spec, err := centralKitchenForSchoolWithSpec.GetCentralKitchenForSchoolWithSpec()
- if err != nil {
- return
- }
- if spec != nil {
- resp.IsOpenBreakfast = spec.IsOpenBreakfast
- resp.IsOpenLunch = spec.IsOpenLunch
- resp.IsOpenDinner = spec.IsOpenDinner
- resp.BreakfastUnitPrice = spec.BreakfastUnitPrice
- resp.BreakfastUnitPriceForTeacher = spec.BreakfastUnitPriceForTeacher
- resp.LunchUnitPrice = spec.LunchUnitPrice
- resp.LunchUnitPriceForTeacher = spec.LunchUnitPriceForTeacher
- resp.DinnerUnitPrice = spec.DinnerUnitPrice
- resp.DinnerUnitPriceForTeacher = spec.DinnerUnitPriceForTeacher
- }
-
- //3、查询`central_kitchen_for_school_set`
- centralKitchenForSchoolSetDb := db.CentralKitchenForSchoolSetDb{}
- centralKitchenForSchoolSetDb.Set(enterpriseId)
- set, err := centralKitchenForSchoolSetDb.GetCentralKitchenForSchoolSet()
- if err != nil {
- return
- }
- if set != nil {
- resp.IsOpenTeacherReportMeal = set.IsOpenTeacherReportMeal
- resp.IsOpenReportMealForDay = set.IsOpenReportMealForDay
- resp.IsOpenReportMealForMonth = set.IsOpenReportMealForMonth
- resp.IsOpenReportMealForSemester = set.IsOpenReportMealForSemester
- resp.IsOpenTeacherReportMealForDay = set.IsOpenTeacherReportMealForDay
- resp.IsOpenTeacherReportMealForMonth = set.IsOpenTeacherReportMealForMonth
- resp.IsOpenTeacherReportMealForSemester = set.IsOpenTeacherReportMealForSemester
- }
- return
- }
-
- func NursingHomePackageInfo(enterpriseId int) (err error, resp md.NursingHomePackageInfoResp) {
- //1、查询`enterprise`
- enterpriseDb := db.EnterpriseDb{}
- enterpriseDb.Set()
- enterprise, err := enterpriseDb.GetEnterprise(enterpriseId)
- if err != nil {
- return
- }
- resp.Name = enterprise.Name
- resp.Memo = enterprise.Memo
- resp.Kind = enterprise.Kind
- resp.State = enterprise.State
-
- //2、查询`central_kitchen_for_school_with_spec`
- centralKitchenForSchoolWithSpec := db.NursingHomeWithSpec{}
- centralKitchenForSchoolWithSpec.Set(enterpriseId)
- spec, err := centralKitchenForSchoolWithSpec.GetNursingHomeWithSpec()
- if err != nil {
- return
- }
- if spec != nil {
- resp.IsOpenBreakfast = spec.IsOpenBreakfast
- resp.IsOpenLunch = spec.IsOpenLunch
- resp.IsOpenDinner = spec.IsOpenDinner
- resp.BreakfastUnitPrice = spec.BreakfastUnitPrice
- resp.LunchUnitPrice = spec.LunchUnitPrice
- resp.DinnerUnitPrice = spec.DinnerUnitPrice
- }
-
- //3、查询`central_kitchen_for_school_set`
- centralKitchenForSchoolSetDb := db.NursingHomeSetDb{}
- centralKitchenForSchoolSetDb.Set(enterpriseId)
- set, err := centralKitchenForSchoolSetDb.GetNursingHomeSet()
- if err != nil {
- return
- }
- if set != nil {
- resp.IsOpenReportMealForDay = set.IsOpenReportMealForDay
- resp.IsOpenReportMealForMonth = set.IsOpenReportMealForMonth
- resp.IsOpenReportMealForYear = set.IsOpenReportMealForYear
- }
- return
- }
|