|
|
@@ -3,6 +3,7 @@ package hdl |
|
|
|
import ( |
|
|
|
"applet/app/admin/lib/validate" |
|
|
|
"applet/app/admin/md" |
|
|
|
"applet/app/admin/svc" |
|
|
|
svc2 "applet/app/admin/svc/enterprise_manage" |
|
|
|
"applet/app/db" |
|
|
|
"applet/app/db/model" |
|
|
@@ -10,6 +11,7 @@ import ( |
|
|
|
"applet/app/enum" |
|
|
|
"applet/app/utils" |
|
|
|
"github.com/gin-gonic/gin" |
|
|
|
"time" |
|
|
|
) |
|
|
|
|
|
|
|
func NursingHomeUserUpdate(c *gin.Context) { |
|
|
@@ -72,381 +74,364 @@ func NursingHomeUserDelete(c *gin.Context) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
//func GetCentralKitchenForSchoolWithSpec(c *gin.Context) { |
|
|
|
// enterpriseId := utils.StrToInt(c.DefaultQuery("enterprise_id", "0")) |
|
|
|
// centralKitchenForSchoolWithSpec := db.CentralKitchenForSchoolWithSpec{} |
|
|
|
// centralKitchenForSchoolWithSpec.Set(enterpriseId) |
|
|
|
// data, err := centralKitchenForSchoolWithSpec.GetCentralKitchenForSchoolWithSpec() |
|
|
|
// if err != nil { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// |
|
|
|
// e.OutSuc(c, map[string]interface{}{ |
|
|
|
// "data": data, |
|
|
|
// }, nil) |
|
|
|
// return |
|
|
|
//} |
|
|
|
// |
|
|
|
//func SetCentralKitchenForSchoolWithSpec(c *gin.Context) { |
|
|
|
// var req md.SetCentralKitchenForSchoolWithSpecReq |
|
|
|
// err := c.ShouldBindJSON(&req) |
|
|
|
// if err != nil { |
|
|
|
// err = validate.HandleValidateErr(err) |
|
|
|
// err1 := err.(e.E) |
|
|
|
// e.OutErr(c, err1.Code, err1.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// centralKitchenForSchoolWithSpec := db.CentralKitchenForSchoolWithSpec{} |
|
|
|
// centralKitchenForSchoolWithSpec.Set(req.EnterpriseId) |
|
|
|
// |
|
|
|
// spec, err := centralKitchenForSchoolWithSpec.GetCentralKitchenForSchoolWithSpec() |
|
|
|
// if err != nil { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// |
|
|
|
// _, err = centralKitchenForSchoolWithSpec.CentralKitchenForSchoolWithSpecDelete() |
|
|
|
// if err != nil { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// |
|
|
|
// now := time.Now() |
|
|
|
// if spec != nil { |
|
|
|
// insertConfirm, err1 := centralKitchenForSchoolWithSpec.CentralKitchenForSchoolWithSpecInsert(&model.CentralKitchenForSchoolWithSpec{ |
|
|
|
// IsOpenBreakfast: spec.IsOpenBreakfast, |
|
|
|
// IsOpenLunch: spec.IsOpenLunch, |
|
|
|
// IsOpenDinner: spec.IsOpenDinner, |
|
|
|
// EnterpriseId: req.EnterpriseId, |
|
|
|
// BreakfastUnitPrice: req.BreakfastUnitPrice, |
|
|
|
// LunchUnitPrice: req.LunchUnitPrice, |
|
|
|
// DinnerUnitPrice: req.DinnerUnitPrice, |
|
|
|
// BreakfastUnitPriceForTeacher: req.BreakfastUnitPriceForTeacher, |
|
|
|
// LunchUnitPriceForTeacher: req.LunchUnitPriceForTeacher, |
|
|
|
// DinnerUnitPriceForTeacher: req.DinnerUnitPriceForTeacher, |
|
|
|
// CreateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
// UpdateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
// }) |
|
|
|
// if err1 != nil { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err1.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// if insertConfirm <= 0 { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, "新增数据失败") |
|
|
|
// return |
|
|
|
// } |
|
|
|
// } else { |
|
|
|
// insertConfirm, err1 := centralKitchenForSchoolWithSpec.CentralKitchenForSchoolWithSpecInsert(&model.CentralKitchenForSchoolWithSpec{ |
|
|
|
// EnterpriseId: req.EnterpriseId, |
|
|
|
// BreakfastUnitPrice: req.BreakfastUnitPrice, |
|
|
|
// LunchUnitPrice: req.LunchUnitPrice, |
|
|
|
// DinnerUnitPrice: req.DinnerUnitPrice, |
|
|
|
// BreakfastUnitPriceForTeacher: req.BreakfastUnitPriceForTeacher, |
|
|
|
// LunchUnitPriceForTeacher: req.LunchUnitPriceForTeacher, |
|
|
|
// DinnerUnitPriceForTeacher: req.DinnerUnitPriceForTeacher, |
|
|
|
// CreateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
// UpdateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
// }) |
|
|
|
// if err1 != nil { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err1.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// if insertConfirm <= 0 { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, "新增数据失败") |
|
|
|
// return |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// e.OutSuc(c, "success", nil) |
|
|
|
// return |
|
|
|
//} |
|
|
|
// |
|
|
|
//func ListCentralKitchenForSchoolPackage(c *gin.Context) { |
|
|
|
// var req md.ListCentralKitchenForSchoolPackageReq |
|
|
|
// err := c.ShouldBindJSON(&req) |
|
|
|
// if err != nil { |
|
|
|
// err = validate.HandleValidateErr(err) |
|
|
|
// err1 := err.(e.E) |
|
|
|
// e.OutErr(c, err1.Code, err1.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// centralKitchenForSchoolPackageDb := db.CentralKitchenForSchoolPackageDb{} |
|
|
|
// centralKitchenForSchoolPackageDb.Set() |
|
|
|
// list, total, err := centralKitchenForSchoolPackageDb.CentralKitchenForSchoolPackageList(req) |
|
|
|
// if err != nil { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// e.OutSuc(c, map[string]interface{}{ |
|
|
|
// "list": list, |
|
|
|
// "total": total, |
|
|
|
// "state_list": []map[string]interface{}{ |
|
|
|
// { |
|
|
|
// "name": "可用", |
|
|
|
// "value": 1, |
|
|
|
// }, |
|
|
|
// { |
|
|
|
// "name": "不可用", |
|
|
|
// "value": 2, |
|
|
|
// }, |
|
|
|
// }, |
|
|
|
// }, nil) |
|
|
|
// return |
|
|
|
//} |
|
|
|
// |
|
|
|
//func DetailCentralKitchenForSchoolPackage(c *gin.Context) { |
|
|
|
// packageId := utils.StrToInt(c.DefaultQuery("package_id", "")) |
|
|
|
// centralKitchenForSchoolPackageDb := db.CentralKitchenForSchoolPackageDb{} |
|
|
|
// centralKitchenForSchoolPackageDb.Set() |
|
|
|
// centralKitchenForSchoolPackage, err := centralKitchenForSchoolPackageDb.GetCentralKitchenForSchoolPackage(packageId) |
|
|
|
// if err != nil { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// if centralKitchenForSchoolPackage == nil { |
|
|
|
// e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") |
|
|
|
// return |
|
|
|
// } |
|
|
|
// |
|
|
|
// centralKitchenForSchoolPackageWithDayDb := db.CentralKitchenForSchoolPackageWithDayDb{} |
|
|
|
// centralKitchenForSchoolPackageWithDayDb.Set(packageId) |
|
|
|
// centralKitchenForSchoolPackageWithDay, err := centralKitchenForSchoolPackageWithDayDb.FindCentralKitchenForSchoolPackageWithDay() |
|
|
|
// if err != nil { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// var resp = md.SaveCentralKitchenForSchoolPackageReq{ |
|
|
|
// PackageId: centralKitchenForSchoolPackage.Id, |
|
|
|
// EnterpriseId: centralKitchenForSchoolPackage.EnterpriseId, |
|
|
|
// Year: centralKitchenForSchoolPackage.Year, |
|
|
|
// Month: centralKitchenForSchoolPackage.Month, |
|
|
|
// StartDate: centralKitchenForSchoolPackage.StartDate, |
|
|
|
// EndDate: centralKitchenForSchoolPackage.EndDate, |
|
|
|
// DateList: nil, |
|
|
|
// } |
|
|
|
// for _, v := range *centralKitchenForSchoolPackageWithDay { |
|
|
|
// resp.DateList = append(resp.DateList, struct { |
|
|
|
// Date string `json:"date"` |
|
|
|
// IsOpenBreakfast int32 `json:"is_open_breakfast"` |
|
|
|
// IsOpenLunch int32 `json:"is_open_lunch"` |
|
|
|
// IsOpenDinner int32 `json:"is_open_dinner"` |
|
|
|
// IsOpenReplenish int32 `json:"is_open_replenish"` |
|
|
|
// }{Date: v.Date, IsOpenBreakfast: int32(v.IsOpenBreakfast), IsOpenLunch: int32(v.IsOpenLunch), IsOpenDinner: int32(v.IsOpenDinner), IsOpenReplenish: int32(v.IsOpenReplenish)}) |
|
|
|
// } |
|
|
|
// e.OutSuc(c, resp, nil) |
|
|
|
// return |
|
|
|
//} |
|
|
|
// |
|
|
|
//func SaveCentralKitchenForSchoolPackage(c *gin.Context) { |
|
|
|
// var req md.SaveCentralKitchenForSchoolPackageReq |
|
|
|
// err := c.ShouldBindJSON(&req) |
|
|
|
// if err != nil { |
|
|
|
// err = validate.HandleValidateErr(err) |
|
|
|
// err1 := err.(e.E) |
|
|
|
// e.OutErr(c, err1.Code, err1.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// //判断是新增 / 编辑 |
|
|
|
// if req.PackageId > 0 { |
|
|
|
// err = svc.UpdateCentralKitchenForSchoolPackage(req) |
|
|
|
// if err != nil { |
|
|
|
// e.OutErr(c, e.ERR, err.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// } else { |
|
|
|
// err = svc.AddCentralKitchenForSchoolPackage(req) |
|
|
|
// if err != nil { |
|
|
|
// e.OutErr(c, e.ERR, err.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// } |
|
|
|
// e.OutSuc(c, "success", nil) |
|
|
|
// return |
|
|
|
//} |
|
|
|
// |
|
|
|
//func SetBasicCentralKitchenForSchool(c *gin.Context) { |
|
|
|
// var req md.SetBasicCentralKitchenForSchoolReq |
|
|
|
// err := c.ShouldBindJSON(&req) |
|
|
|
// if err != nil { |
|
|
|
// err = validate.HandleValidateErr(err) |
|
|
|
// err1 := err.(e.E) |
|
|
|
// e.OutErr(c, err1.Code, err1.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// now := time.Now() |
|
|
|
// |
|
|
|
// //1、更新 central_kitchen_for_school_set |
|
|
|
// centralKitchenForSchoolSetDb := db.CentralKitchenForSchoolSetDb{} |
|
|
|
// centralKitchenForSchoolSetDb.Set(req.EnterpriseId) |
|
|
|
// set, err := centralKitchenForSchoolSetDb.GetCentralKitchenForSchoolSet() |
|
|
|
// if err != nil { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// if set != nil { |
|
|
|
// set.IsOpenTeacherReportMeal = req.IsOpenTeacherReportMeal |
|
|
|
// set.IsOpenReportMealForDay = req.IsOpenReportMealForDay |
|
|
|
// set.IsOpenReportMealForMonth = req.IsOpenReportMealForMonth |
|
|
|
// set.IsOpenReportMealForSemester = req.IsOpenReportMealForSemester |
|
|
|
// set.UpdateAt = now.Format("2006-01-02 15:04:05") |
|
|
|
// _, err2 := centralKitchenForSchoolSetDb.CentralKitchenForSchoolSetUpdate(set.Id, set, "is_open_teacher_report_meal", "is_open_report_meal_for_day", "is_open_report_meal_for_month", "is_open_report_meal_for_semester", "update_at") |
|
|
|
// if err2 != nil { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err2.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// } else { |
|
|
|
// _, err2 := centralKitchenForSchoolSetDb.CentralKitchenForSchoolSetInsert(&model.CentralKitchenForSchoolSet{ |
|
|
|
// EnterpriseId: req.EnterpriseId, |
|
|
|
// IsOpenTeacherReportMeal: req.IsOpenTeacherReportMeal, |
|
|
|
// IsOpenReportMealForDay: req.IsOpenReportMealForDay, |
|
|
|
// IsOpenReportMealForMonth: req.IsOpenReportMealForMonth, |
|
|
|
// IsOpenReportMealForSemester: req.IsOpenReportMealForSemester, |
|
|
|
// CreateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
// UpdateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
// }) |
|
|
|
// if err2 != nil { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err2.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// //2、更新 central_kitchen_for_school_with_spec |
|
|
|
// centralKitchenForSchoolWithSpec := db.CentralKitchenForSchoolWithSpec{} |
|
|
|
// centralKitchenForSchoolWithSpec.Set(req.EnterpriseId) |
|
|
|
// spec, err := centralKitchenForSchoolWithSpec.GetCentralKitchenForSchoolWithSpec() |
|
|
|
// if err != nil { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// if spec != nil { |
|
|
|
// spec.IsOpenBreakfast = req.IsOpenBreakfast |
|
|
|
// spec.IsOpenLunch = req.IsOpenLunch |
|
|
|
// spec.IsOpenDinner = req.IsOpenDinner |
|
|
|
// spec.UpdateAt = now.Format("2006-01-02 15:04:05") |
|
|
|
// _, err2 := centralKitchenForSchoolWithSpec.CentralKitchenForSchoolWithSpecUpdate(spec.Id, spec, "is_open_breakfast", "is_open_lunch", "is_open_dinner", "update_at") |
|
|
|
// if err2 != nil { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err2.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// } else { |
|
|
|
// _, err2 := centralKitchenForSchoolWithSpec.CentralKitchenForSchoolWithSpecInsert(&model.CentralKitchenForSchoolWithSpec{ |
|
|
|
// EnterpriseId: req.EnterpriseId, |
|
|
|
// IsOpenBreakfast: req.IsOpenBreakfast, |
|
|
|
// IsOpenLunch: req.IsOpenLunch, |
|
|
|
// IsOpenDinner: req.IsOpenDinner, |
|
|
|
// CreateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
// UpdateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
// }) |
|
|
|
// if err2 != nil { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err2.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// //3、更新 `enterprise` |
|
|
|
// enterpriseDb := db.EnterpriseDb{} |
|
|
|
// enterpriseDb.Set() |
|
|
|
// enterprise, err := enterpriseDb.GetEnterprise(req.EnterpriseId) |
|
|
|
// if err != nil { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// if enterprise == nil { |
|
|
|
// e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") |
|
|
|
// return |
|
|
|
// } |
|
|
|
// enterprise.Name = req.Name |
|
|
|
// enterprise.State = req.State |
|
|
|
// enterprise.UpdateAt = now.Format("2006-01-02 15:04:05") |
|
|
|
// _, err = enterpriseDb.EnterpriseUpdate(enterprise, "name", "state", "update_at") |
|
|
|
// if err != nil { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// |
|
|
|
// e.OutSuc(c, "success", nil) |
|
|
|
// return |
|
|
|
//} |
|
|
|
// |
|
|
|
//func GetBasicCentralKitchenForSchool(c *gin.Context) { |
|
|
|
// enterpriseId := utils.StrToInt(c.DefaultQuery("enterprise_id", "0")) |
|
|
|
// |
|
|
|
// //1、获取 central_kitchen_for_school_set |
|
|
|
// centralKitchenForSchoolSetDb := db.CentralKitchenForSchoolSetDb{} |
|
|
|
// centralKitchenForSchoolSetDb.Set(enterpriseId) |
|
|
|
// set, err := centralKitchenForSchoolSetDb.GetCentralKitchenForSchoolSet() |
|
|
|
// if err != nil { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// if set == nil { |
|
|
|
// set = &model.CentralKitchenForSchoolSet{ |
|
|
|
// EnterpriseId: enterpriseId, |
|
|
|
// IsOpenTeacherReportMeal: 0, |
|
|
|
// IsOpenReportMealForDay: 0, |
|
|
|
// IsOpenReportMealForMonth: 0, |
|
|
|
// IsOpenReportMealForSemester: 0, |
|
|
|
// CreateAt: time.Now().Format("2006-01-02 15:04:05"), |
|
|
|
// UpdateAt: time.Now().Format("2006-01-02 15:04:05"), |
|
|
|
// } |
|
|
|
// _, err2 := centralKitchenForSchoolSetDb.CentralKitchenForSchoolSetInsert(set) |
|
|
|
// if err2 != nil { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err2.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// //2、获取 central_kitchen_for_school_with_spec |
|
|
|
// centralKitchenForSchoolWithSpec := db.CentralKitchenForSchoolWithSpec{} |
|
|
|
// centralKitchenForSchoolWithSpec.Set(enterpriseId) |
|
|
|
// spec, err := centralKitchenForSchoolWithSpec.GetCentralKitchenForSchoolWithSpec() |
|
|
|
// if err != nil { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// if spec == nil { |
|
|
|
// spec = &model.CentralKitchenForSchoolWithSpec{ |
|
|
|
// EnterpriseId: enterpriseId, |
|
|
|
// IsOpenBreakfast: 0, |
|
|
|
// IsOpenLunch: 0, |
|
|
|
// IsOpenDinner: 0, |
|
|
|
// BreakfastUnitPrice: "0", |
|
|
|
// LunchUnitPrice: "0", |
|
|
|
// DinnerUnitPrice: "0", |
|
|
|
// BreakfastUnitPriceForTeacher: "0", |
|
|
|
// LunchUnitPriceForTeacher: "0", |
|
|
|
// DinnerUnitPriceForTeacher: "0", |
|
|
|
// CreateAt: time.Now().Format("2006-01-02 15:04:05"), |
|
|
|
// UpdateAt: time.Now().Format("2006-01-02 15:04:05"), |
|
|
|
// } |
|
|
|
// _, err2 := centralKitchenForSchoolWithSpec.CentralKitchenForSchoolWithSpecInsert(spec) |
|
|
|
// if err2 != nil { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err2.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// //3、更新 `enterprise` |
|
|
|
// enterpriseDb := db.EnterpriseDb{} |
|
|
|
// enterpriseDb.Set() |
|
|
|
// enterprise, err := enterpriseDb.GetEnterprise(enterpriseId) |
|
|
|
// if err != nil { |
|
|
|
// e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
// return |
|
|
|
// } |
|
|
|
// if enterprise == nil { |
|
|
|
// e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") |
|
|
|
// return |
|
|
|
// } |
|
|
|
// |
|
|
|
// e.OutSuc(c, map[string]interface{}{ |
|
|
|
// "central_kitchen_for_school_set": set, |
|
|
|
// "central_kitchen_for_school_with_spec": spec, |
|
|
|
// "enterprise": enterprise, |
|
|
|
// }, nil) |
|
|
|
// return |
|
|
|
//} |
|
|
|
func GetNursingHomeWithSpec(c *gin.Context) { |
|
|
|
enterpriseId := utils.StrToInt(c.DefaultQuery("enterprise_id", "0")) |
|
|
|
nursingHomeWithSpec := db.NursingHomeWithSpec{} |
|
|
|
nursingHomeWithSpec.Set(enterpriseId) |
|
|
|
data, err := nursingHomeWithSpec.GetNursingHomeWithSpec() |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
e.OutSuc(c, map[string]interface{}{ |
|
|
|
"data": data, |
|
|
|
}, nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func SetNursingHomeWithSpec(c *gin.Context) { |
|
|
|
var req md.SetNursingHomeWithSpecReq |
|
|
|
err := c.ShouldBindJSON(&req) |
|
|
|
if err != nil { |
|
|
|
err = validate.HandleValidateErr(err) |
|
|
|
err1 := err.(e.E) |
|
|
|
e.OutErr(c, err1.Code, err1.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
nursingHomeWithSpec := db.NursingHomeWithSpec{} |
|
|
|
nursingHomeWithSpec.Set(req.EnterpriseId) |
|
|
|
|
|
|
|
spec, err := nursingHomeWithSpec.GetNursingHomeWithSpec() |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
now := time.Now() |
|
|
|
if spec != nil { |
|
|
|
insertConfirm, err1 := nursingHomeWithSpec.NursingHomeWithSpecInsert(&model.NursingHomeWithSpec{ |
|
|
|
IsOpenBreakfast: spec.IsOpenBreakfast, |
|
|
|
IsOpenLunch: spec.IsOpenLunch, |
|
|
|
IsOpenDinner: spec.IsOpenDinner, |
|
|
|
EnterpriseId: req.EnterpriseId, |
|
|
|
BreakfastUnitPrice: req.BreakfastUnitPrice, |
|
|
|
LunchUnitPrice: req.LunchUnitPrice, |
|
|
|
DinnerUnitPrice: req.DinnerUnitPrice, |
|
|
|
CreateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
UpdateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
}) |
|
|
|
if err1 != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if insertConfirm <= 0 { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, "新增数据失败") |
|
|
|
return |
|
|
|
} |
|
|
|
} else { |
|
|
|
insertConfirm, err1 := nursingHomeWithSpec.NursingHomeWithSpecInsert(&model.NursingHomeWithSpec{ |
|
|
|
EnterpriseId: req.EnterpriseId, |
|
|
|
BreakfastUnitPrice: req.BreakfastUnitPrice, |
|
|
|
LunchUnitPrice: req.LunchUnitPrice, |
|
|
|
DinnerUnitPrice: req.DinnerUnitPrice, |
|
|
|
CreateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
UpdateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
}) |
|
|
|
if err1 != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if insertConfirm <= 0 { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, "新增数据失败") |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
e.OutSuc(c, "success", nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func ListNursingHomePackage(c *gin.Context) { |
|
|
|
var req md.ListNursingHomePackageReq |
|
|
|
err := c.ShouldBindJSON(&req) |
|
|
|
if err != nil { |
|
|
|
err = validate.HandleValidateErr(err) |
|
|
|
err1 := err.(e.E) |
|
|
|
e.OutErr(c, err1.Code, err1.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
nursingHomePackageDb := db.NursingHomePackageDb{} |
|
|
|
nursingHomePackageDb.Set() |
|
|
|
list, total, err := nursingHomePackageDb.NursingHomePackageList(req) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
e.OutSuc(c, map[string]interface{}{ |
|
|
|
"list": list, |
|
|
|
"total": total, |
|
|
|
"state_list": []map[string]interface{}{ |
|
|
|
{ |
|
|
|
"name": "可用", |
|
|
|
"value": 1, |
|
|
|
}, |
|
|
|
{ |
|
|
|
"name": "不可用", |
|
|
|
"value": 2, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func DetailNursingHomePackage(c *gin.Context) { |
|
|
|
packageId := utils.StrToInt(c.DefaultQuery("package_id", "")) |
|
|
|
nursingHomePackageDb := db.NursingHomePackageDb{} |
|
|
|
nursingHomePackageDb.Set() |
|
|
|
NursingHomePackage, err := nursingHomePackageDb.GetNursingHomePackage(packageId) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if NursingHomePackage == nil { |
|
|
|
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
nursingHomePackageWithDayDb := db.NursingHomePackageWithDayDb{} |
|
|
|
nursingHomePackageWithDayDb.Set(packageId) |
|
|
|
nursingHomePackageWithDay, err := nursingHomePackageWithDayDb.FindNursingHomePackageWithDay() |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
var resp = md.SaveNursingHomePackageReq{ |
|
|
|
PackageId: NursingHomePackage.Id, |
|
|
|
EnterpriseId: NursingHomePackage.EnterpriseId, |
|
|
|
Year: NursingHomePackage.Year, |
|
|
|
Month: NursingHomePackage.Month, |
|
|
|
StartDate: NursingHomePackage.StartDate, |
|
|
|
EndDate: NursingHomePackage.EndDate, |
|
|
|
DateList: nil, |
|
|
|
} |
|
|
|
for _, v := range *nursingHomePackageWithDay { |
|
|
|
resp.DateList = append(resp.DateList, struct { |
|
|
|
Date string `json:"date"` |
|
|
|
IsOpenBreakfast int32 `json:"is_open_breakfast"` |
|
|
|
IsOpenLunch int32 `json:"is_open_lunch"` |
|
|
|
IsOpenDinner int32 `json:"is_open_dinner"` |
|
|
|
IsOpenReplenish int32 `json:"is_open_replenish"` |
|
|
|
}{Date: v.Date, IsOpenBreakfast: int32(v.IsOpenBreakfast), IsOpenLunch: int32(v.IsOpenLunch), IsOpenDinner: int32(v.IsOpenDinner), IsOpenReplenish: int32(v.IsOpenReplenish)}) |
|
|
|
} |
|
|
|
e.OutSuc(c, resp, nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func SaveNursingHomePackage(c *gin.Context) { |
|
|
|
var req md.SaveNursingHomePackageReq |
|
|
|
err := c.ShouldBindJSON(&req) |
|
|
|
if err != nil { |
|
|
|
err = validate.HandleValidateErr(err) |
|
|
|
err1 := err.(e.E) |
|
|
|
e.OutErr(c, err1.Code, err1.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
//判断是新增 / 编辑 |
|
|
|
if req.PackageId > 0 { |
|
|
|
err = svc.UpdateNursingHomePackage(req) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
} else { |
|
|
|
err = svc.AddNursingHomePackage(req) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
e.OutSuc(c, "success", nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func SetBasicNursingHome(c *gin.Context) { |
|
|
|
var req md.SetBasicNursingHomeReq |
|
|
|
err := c.ShouldBindJSON(&req) |
|
|
|
if err != nil { |
|
|
|
err = validate.HandleValidateErr(err) |
|
|
|
err1 := err.(e.E) |
|
|
|
e.OutErr(c, err1.Code, err1.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
now := time.Now() |
|
|
|
|
|
|
|
//1、更新 nursing_home_set |
|
|
|
nursingHomeSetDb := db.NursingHomeSetDb{} |
|
|
|
nursingHomeSetDb.Set(req.EnterpriseId) |
|
|
|
set, err := nursingHomeSetDb.GetNursingHomeSet() |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if set != nil { |
|
|
|
set.IsOpenReportMealForYear = req.IsOpenReportMealForYear |
|
|
|
set.IsOpenReportMealForDay = req.IsOpenReportMealForDay |
|
|
|
set.IsOpenReportMealForMonth = req.IsOpenReportMealForMonth |
|
|
|
set.UpdateAt = now.Format("2006-01-02 15:04:05") |
|
|
|
_, err2 := nursingHomeSetDb.NursingHomeSetUpdate(set.Id, set, "is_open_report_meal_for_day", "is_open_report_meal_for_month", "is_open_report_meal_for_year", "update_at") |
|
|
|
if err2 != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
} else { |
|
|
|
_, err2 := nursingHomeSetDb.NursingHomeSetInsert(&model.NursingHomeSet{ |
|
|
|
EnterpriseId: req.EnterpriseId, |
|
|
|
IsOpenReportMealForYear: req.IsOpenReportMealForYear, |
|
|
|
IsOpenReportMealForDay: req.IsOpenReportMealForDay, |
|
|
|
IsOpenReportMealForMonth: req.IsOpenReportMealForMonth, |
|
|
|
CreateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
UpdateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
}) |
|
|
|
if err2 != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//2、更新 nursing_home_with_spec |
|
|
|
nursingHomeWithSpec := db.NursingHomeWithSpec{} |
|
|
|
nursingHomeWithSpec.Set(req.EnterpriseId) |
|
|
|
spec, err := nursingHomeWithSpec.GetNursingHomeWithSpec() |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if spec != nil { |
|
|
|
spec.IsOpenBreakfast = req.IsOpenBreakfast |
|
|
|
spec.IsOpenLunch = req.IsOpenLunch |
|
|
|
spec.IsOpenDinner = req.IsOpenDinner |
|
|
|
spec.UpdateAt = now.Format("2006-01-02 15:04:05") |
|
|
|
_, err2 := nursingHomeWithSpec.NursingHomeWithSpecUpdate(spec.Id, spec, "is_open_breakfast", "is_open_lunch", "is_open_dinner", "update_at") |
|
|
|
if err2 != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
} else { |
|
|
|
_, err2 := nursingHomeWithSpec.NursingHomeWithSpecInsert(&model.NursingHomeWithSpec{ |
|
|
|
EnterpriseId: req.EnterpriseId, |
|
|
|
IsOpenBreakfast: req.IsOpenBreakfast, |
|
|
|
IsOpenLunch: req.IsOpenLunch, |
|
|
|
IsOpenDinner: req.IsOpenDinner, |
|
|
|
CreateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
UpdateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|
}) |
|
|
|
if err2 != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//3、更新 `enterprise` |
|
|
|
enterpriseDb := db.EnterpriseDb{} |
|
|
|
enterpriseDb.Set() |
|
|
|
enterprise, err := enterpriseDb.GetEnterprise(req.EnterpriseId) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if enterprise == nil { |
|
|
|
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") |
|
|
|
return |
|
|
|
} |
|
|
|
enterprise.Name = req.Name |
|
|
|
enterprise.State = req.State |
|
|
|
enterprise.UpdateAt = now.Format("2006-01-02 15:04:05") |
|
|
|
_, err = enterpriseDb.EnterpriseUpdate(enterprise, "name", "state", "update_at") |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
e.OutSuc(c, "success", nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func GetBasicNursingHome(c *gin.Context) { |
|
|
|
enterpriseId := utils.StrToInt(c.DefaultQuery("enterprise_id", "0")) |
|
|
|
|
|
|
|
//1、获取 nursing_home_set |
|
|
|
nursingHomeSetDb := db.NursingHomeSetDb{} |
|
|
|
nursingHomeSetDb.Set(enterpriseId) |
|
|
|
set, err := nursingHomeSetDb.GetNursingHomeSet() |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if set == nil { |
|
|
|
set = &model.NursingHomeSet{ |
|
|
|
EnterpriseId: enterpriseId, |
|
|
|
IsOpenReportMealForDay: 0, |
|
|
|
IsOpenReportMealForMonth: 0, |
|
|
|
IsOpenReportMealForYear: 0, |
|
|
|
CreateAt: time.Now().Format("2006-01-02 15:04:05"), |
|
|
|
UpdateAt: time.Now().Format("2006-01-02 15:04:05"), |
|
|
|
} |
|
|
|
_, err2 := nursingHomeSetDb.NursingHomeSetInsert(set) |
|
|
|
if err2 != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//2、获取 nursing_home_with_spec |
|
|
|
nursingHomeWithSpec := db.NursingHomeWithSpec{} |
|
|
|
nursingHomeWithSpec.Set(enterpriseId) |
|
|
|
spec, err := nursingHomeWithSpec.GetNursingHomeWithSpec() |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if spec == nil { |
|
|
|
spec = &model.NursingHomeWithSpec{ |
|
|
|
EnterpriseId: enterpriseId, |
|
|
|
IsOpenBreakfast: 0, |
|
|
|
IsOpenLunch: 0, |
|
|
|
IsOpenDinner: 0, |
|
|
|
BreakfastUnitPrice: "0", |
|
|
|
LunchUnitPrice: "0", |
|
|
|
DinnerUnitPrice: "0", |
|
|
|
CreateAt: time.Now().Format("2006-01-02 15:04:05"), |
|
|
|
UpdateAt: time.Now().Format("2006-01-02 15:04:05"), |
|
|
|
} |
|
|
|
_, err2 := nursingHomeWithSpec.NursingHomeWithSpecInsert(spec) |
|
|
|
if err2 != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//3、更新 `enterprise` |
|
|
|
enterpriseDb := db.EnterpriseDb{} |
|
|
|
enterpriseDb.Set() |
|
|
|
enterprise, err := enterpriseDb.GetEnterprise(enterpriseId) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if enterprise == nil { |
|
|
|
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
e.OutSuc(c, map[string]interface{}{ |
|
|
|
"central_kitchen_for_school_set": set, |
|
|
|
"central_kitchen_for_school_with_spec": spec, |
|
|
|
"enterprise": enterprise, |
|
|
|
}, nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func NursingHomeOrdList(c *gin.Context) { |
|
|
|
var req md.NursingHomeOrdListReq |
|
|
@@ -486,42 +471,42 @@ func NursingHomeOrdList(c *gin.Context) { |
|
|
|
}, |
|
|
|
"state_list": []map[string]interface{}{ |
|
|
|
{ |
|
|
|
"name": enum.CentralKitchenForSchoolPackageOrdState.String(enum.CentralKitchenForSchoolPackageOrdStateForWait), |
|
|
|
"value": enum.CentralKitchenForSchoolPackageOrdStateForWait, |
|
|
|
"name": enum.NursingHomePackageOrdState.String(enum.NursingHomePackageOrdStateForWait), |
|
|
|
"value": enum.NursingHomePackageOrdStateForWait, |
|
|
|
}, |
|
|
|
{ |
|
|
|
"name": enum.CentralKitchenForSchoolPackageOrdState.String(enum.CentralKitchenForSchoolPackageOrdStateForSuccess), |
|
|
|
"value": enum.CentralKitchenForSchoolPackageOrdStateForSuccess, |
|
|
|
"name": enum.NursingHomePackageOrdState.String(enum.NursingHomePackageOrdStateForSuccess), |
|
|
|
"value": enum.NursingHomePackageOrdStateForSuccess, |
|
|
|
}, |
|
|
|
{ |
|
|
|
"name": enum.CentralKitchenForSchoolPackageOrdState.String(enum.CentralKitchenForSchoolPackageOrdStateForFail), |
|
|
|
"value": enum.CentralKitchenForSchoolPackageOrdStateForFail, |
|
|
|
"name": enum.NursingHomePackageOrdState.String(enum.NursingHomePackageOrdStateForFail), |
|
|
|
"value": enum.NursingHomePackageOrdStateForFail, |
|
|
|
}, |
|
|
|
}, |
|
|
|
"ord_state_list": []map[string]interface{}{ |
|
|
|
{ |
|
|
|
"name": enum.CentralKitchenForSchoolPackageOrdOrdState.String(enum.CentralKitchenForSchoolPackageOrdOrdStateForWait), |
|
|
|
"value": enum.CentralKitchenForSchoolPackageOrdOrdStateForWait, |
|
|
|
"name": enum.NursingHomePackageOrdOrdState.String(enum.NursingHomePackageOrdOrdStateForWait), |
|
|
|
"value": enum.NursingHomePackageOrdOrdStateForWait, |
|
|
|
}, |
|
|
|
{ |
|
|
|
"name": enum.CentralKitchenForSchoolPackageOrdOrdState.String(enum.CentralKitchenForSchoolPackageOrdOrdStateForSuccess), |
|
|
|
"value": enum.CentralKitchenForSchoolPackageOrdOrdStateForSuccess, |
|
|
|
"name": enum.NursingHomePackageOrdOrdState.String(enum.NursingHomePackageOrdOrdStateForSuccess), |
|
|
|
"value": enum.NursingHomePackageOrdOrdStateForSuccess, |
|
|
|
}, |
|
|
|
{ |
|
|
|
"name": enum.CentralKitchenForSchoolPackageOrdOrdState.String(enum.CentralKitchenForSchoolPackageOrdOrdStateForRefunding), |
|
|
|
"value": enum.CentralKitchenForSchoolPackageOrdOrdStateForRefunding, |
|
|
|
"name": enum.NursingHomePackageOrdOrdState.String(enum.NursingHomePackageOrdOrdStateForRefunding), |
|
|
|
"value": enum.NursingHomePackageOrdOrdStateForRefunding, |
|
|
|
}, |
|
|
|
{ |
|
|
|
"name": enum.CentralKitchenForSchoolPackageOrdOrdState.String(enum.CentralKitchenForSchoolPackageOrdOrdStateForPartRefunded), |
|
|
|
"value": enum.CentralKitchenForSchoolPackageOrdOrdStateForPartRefunded, |
|
|
|
"name": enum.NursingHomePackageOrdOrdState.String(enum.NursingHomePackageOrdOrdStateForPartRefunded), |
|
|
|
"value": enum.NursingHomePackageOrdOrdStateForPartRefunded, |
|
|
|
}, |
|
|
|
{ |
|
|
|
"name": enum.CentralKitchenForSchoolPackageOrdOrdState.String(enum.CentralKitchenForSchoolPackageOrdOrdStateForRefunded), |
|
|
|
"value": enum.CentralKitchenForSchoolPackageOrdOrdStateForRefunded, |
|
|
|
"name": enum.NursingHomePackageOrdOrdState.String(enum.NursingHomePackageOrdOrdStateForRefunded), |
|
|
|
"value": enum.NursingHomePackageOrdOrdStateForRefunded, |
|
|
|
}, |
|
|
|
{ |
|
|
|
"name": enum.CentralKitchenForSchoolPackageOrdOrdState.String(enum.CentralKitchenForSchoolPackageOrdOrdStateForComplete), |
|
|
|
"value": enum.CentralKitchenForSchoolPackageOrdOrdStateForComplete, |
|
|
|
"name": enum.NursingHomePackageOrdOrdState.String(enum.NursingHomePackageOrdOrdStateForComplete), |
|
|
|
"value": enum.NursingHomePackageOrdOrdStateForComplete, |
|
|
|
}, |
|
|
|
}, |
|
|
|
"user_identity_kind_list": []map[string]interface{}{ |
|
|
@@ -738,3 +723,14 @@ func NursingHomeOrdDetail(c *gin.Context) { |
|
|
|
}, nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func DeleteNursingHomePackage(c *gin.Context) { |
|
|
|
packageId := c.Param("id") |
|
|
|
err := svc.DeleteNursingHomePackage(utils.StrToInt(packageId)) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
e.OutSuc(c, "success", nil) |
|
|
|
return |
|
|
|
} |