|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- package svc
-
- import (
- "applet/app/customer/md"
- "applet/app/db"
- "applet/app/db/model"
- )
-
- func EnterpriseList(req md.EnterpriseListReq) (m []model.Enterprise, total int64, err error) {
- eg := db.Db.Where("1=1")
- 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
- }
- 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
- }
|