From 2b6aa1d55f71c0e2df980274fb0850c204bf479e Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Wed, 30 Aug 2023 17:19:01 +0800 Subject: [PATCH] update --- app/admin/hdl/hdl_data_statistics.go | 66 +++++++++++++++++++ app/admin/hdl/hdl_enterprise.go | 51 ++++++++++++++ app/admin/md/md_enterprise.go | 9 +++ app/admin/md/md_enterprise_manage.go | 4 +- ...kitchen_for_school_with_spec_for_system.go | 22 +++---- app/router/admin_router.go | 7 ++ 6 files changed, 144 insertions(+), 15 deletions(-) create mode 100644 app/admin/hdl/hdl_data_statistics.go diff --git a/app/admin/hdl/hdl_data_statistics.go b/app/admin/hdl/hdl_data_statistics.go new file mode 100644 index 0000000..ab6ab8e --- /dev/null +++ b/app/admin/hdl/hdl_data_statistics.go @@ -0,0 +1,66 @@ +package hdl + +import ( + "applet/app/admin/lib/validate" + "applet/app/admin/md" + "applet/app/admin/svc" + "applet/app/e" + "applet/app/enum" + "github.com/gin-gonic/gin" +) + +func CentralKitchenForSchoolDataStatisticsList(c *gin.Context) { + var req md.EnterpriseListReq + 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.Limit == 0 { + req.Limit = 10 + } + if req.Page == 0 { + req.Page = 10 + } + enterprises, total, err := svc.EnterpriseList(req) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + + e.OutSuc(c, map[string]interface{}{ + "list": enterprises, + "total": total, + "state": []map[string]interface{}{ + { + "name": enum.EnterpriseState(enum.EnterpriseStateForNormal).String(), + "value": enum.EnterpriseStateForNormal, + }, + { + "name": enum.EnterpriseState(enum.EnterpriseStateForFreeze).String(), + "value": enum.EnterpriseStateForFreeze, + }, + }, + "kind": []map[string]interface{}{ + { + "name": enum.EnterprisePvd(enum.EnterprisePvdByCentralKitchenForSchool).String(), + "value": enum.EnterprisePvdByCentralKitchenForSchool, + }, + { + "name": enum.EnterprisePvd(enum.EnterprisePvdByCentralKitchenForFactory).String(), + "value": enum.EnterprisePvdByCentralKitchenForFactory, + }, + { + "name": enum.EnterprisePvd(enum.EnterprisePvdBySelfSupportForSchool).String(), + "value": enum.EnterprisePvdBySelfSupportForSchool, + }, + { + "name": enum.EnterprisePvd(enum.EnterprisePvdBySelfSupportForFactory).String(), + "value": enum.EnterprisePvdBySelfSupportForFactory, + }, + }, + }, nil) + return +} diff --git a/app/admin/hdl/hdl_enterprise.go b/app/admin/hdl/hdl_enterprise.go index f9cb3c6..6d1821f 100644 --- a/app/admin/hdl/hdl_enterprise.go +++ b/app/admin/hdl/hdl_enterprise.go @@ -446,6 +446,57 @@ func ListCentralKitchenForSchoolPackageForSystem(c *gin.Context) { return } +func SetCentralKitchenForSchoolWithSpecForSystem(c *gin.Context) { + var req md.SetCentralKitchenForSchoolWithSpecForSystemReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = validate.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + + centralKitchenForSchoolWithSpecForSystemDb := db.CentralKitchenForSchoolWithSpecForSystem{} + centralKitchenForSchoolWithSpecForSystemDb.Set() + system, err := centralKitchenForSchoolWithSpecForSystemDb.GetCentralKitchenForSchoolWithSpecForSystem() + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + system.BreakfastUnitPrice = req.BreakfastUnitPrice + system.LunchUnitPrice = req.LunchUnitPrice + system.DinnerUnitPrice = req.DinnerUnitPrice + system.BreakfastUnitPriceForTeacher = req.BreakfastUnitPriceForTeacher + system.LunchUnitPriceForTeacher = req.LunchUnitPriceForTeacher + system.DinnerUnitPriceForTeacher = req.DinnerUnitPriceForTeacher + system.UpdateAt = time.Now().Format("2006-01-02 15:04:05") + updateAffected, err := centralKitchenForSchoolWithSpecForSystemDb.CentralKitchenForSchoolWithSpecForSystemUpdate(system.Id, system) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if updateAffected <= 0 { + e.OutErr(c, e.ERR, "更新数据失败") + return + } + e.OutSuc(c, "success", nil) + return +} + +func GetCentralKitchenForSchoolWithSpecForSystem(c *gin.Context) { + centralKitchenForSchoolWithSpecForSystemDb := db.CentralKitchenForSchoolWithSpecForSystem{} + centralKitchenForSchoolWithSpecForSystemDb.Set() + system, err := centralKitchenForSchoolWithSpecForSystemDb.GetCentralKitchenForSchoolWithSpecForSystem() + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + e.OutSuc(c, map[string]interface{}{ + "data": system, + }, nil) + return +} + func SaveCentralKitchenForSchoolPackageForSystem(c *gin.Context) { var req md.SaveCentralKitchenForSchoolPackageForSystemReq err := c.ShouldBindJSON(&req) diff --git a/app/admin/md/md_enterprise.go b/app/admin/md/md_enterprise.go index 853c9c4..8bc1ad6 100644 --- a/app/admin/md/md_enterprise.go +++ b/app/admin/md/md_enterprise.go @@ -54,6 +54,15 @@ type GradeListStruct struct { ClassList []model.Class `json:"class_list"` } +type SetCentralKitchenForSchoolWithSpecForSystemReq struct { + BreakfastUnitPrice string `json:"breakfast_unit_price" binding:"required" label:"早餐-单价"` + BreakfastUnitPriceForTeacher string `json:"breakfast_unit_price_for_teacher" binding:"required" label:"教师-早餐-单价"` + LunchUnitPrice string `json:"lunch_unit_price" binding:"required" label:"午餐-单价"` + LunchUnitPriceForTeacher string `json:"lunch_unit_price_for_teacher" binding:"required" label:"教师-午餐-单价"` + DinnerUnitPrice string `json:"dinner_unit_price" binding:"required" label:"晚餐-单价"` + DinnerUnitPriceForTeacher string `json:"dinner_unit_price_for_teacher" binding:"required" label:"教师-晚餐-单价"` +} + type ListCentralKitchenForSchoolPackageForSystemReq struct { Page int `json:"page" label:"页码"` Limit int `json:"limit" label:"每页数量"` diff --git a/app/admin/md/md_enterprise_manage.go b/app/admin/md/md_enterprise_manage.go index e4be28e..d478956 100644 --- a/app/admin/md/md_enterprise_manage.go +++ b/app/admin/md/md_enterprise_manage.go @@ -117,7 +117,7 @@ type CentralKitchenForSchoolTeacherDeleteReq struct { type CentralKitchenForSchoolStudentAdmissionReq struct { EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` - ClassId int `json:"class_id" binding:"required" label:"班级id"` + ClassId int `json:"class_id" label:"班级id"` GradeId int `json:"grade_id" binding:"required" label:"年级id"` } @@ -322,7 +322,7 @@ type SelfSupportForSchoolStudentDeleteReq struct { type SelfSupportForSchoolStudentAdmissionReq struct { EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` - ClassId int `json:"class_id" binding:"required" label:"班级id"` + ClassId int `json:"class_id" label:"班级id"` GradeId int `json:"grade_id" binding:"required" label:"年级id"` } diff --git a/app/db/model/central_kitchen_for_school_with_spec_for_system.go b/app/db/model/central_kitchen_for_school_with_spec_for_system.go index d595a62..44f818e 100644 --- a/app/db/model/central_kitchen_for_school_with_spec_for_system.go +++ b/app/db/model/central_kitchen_for_school_with_spec_for_system.go @@ -1,17 +1,13 @@ package model -import ( - "time" -) - type CentralKitchenForSchoolWithSpecForSystem struct { - Id int `json:"id" xorm:"not null pk autoincr INT(11)"` - BreakfastUnitPrice string `json:"breakfast_unit_price" xorm:"not null default 0.00 comment('早餐-单价') DECIMAL(4,2)"` - LunchUnitPrice string `json:"lunch_unit_price" xorm:"not null default 0.00 comment('午餐-单价') DECIMAL(4,2)"` - DinnerUnitPrice string `json:"dinner_unit_price" xorm:"not null default 0.00 comment('晚餐-单价') DECIMAL(4,2)"` - BreakfastUnitPriceForTeacher string `json:"breakfast_unit_price_for_teacher" xorm:"not null default 0.00 comment('教师-早餐-单价') DECIMAL(4,2)"` - LunchUnitPriceForTeacher string `json:"lunch_unit_price_for_teacher" xorm:"not null default 0.00 comment('教师-午餐-单价') DECIMAL(4,2)"` - DinnerUnitPriceForTeacher string `json:"dinner_unit_price_for_teacher" xorm:"not null default 0.00 comment('教师-晚餐-单价') DECIMAL(4,2)"` - CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` - UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + BreakfastUnitPrice string `json:"breakfast_unit_price" xorm:"not null default 0.00 comment('早餐-单价') DECIMAL(4,2)"` + LunchUnitPrice string `json:"lunch_unit_price" xorm:"not null default 0.00 comment('午餐-单价') DECIMAL(4,2)"` + DinnerUnitPrice string `json:"dinner_unit_price" xorm:"not null default 0.00 comment('晚餐-单价') DECIMAL(4,2)"` + BreakfastUnitPriceForTeacher string `json:"breakfast_unit_price_for_teacher" xorm:"not null default 0.00 comment('教师-早餐-单价') DECIMAL(4,2)"` + LunchUnitPriceForTeacher string `json:"lunch_unit_price_for_teacher" xorm:"not null default 0.00 comment('教师-午餐-单价') DECIMAL(4,2)"` + DinnerUnitPriceForTeacher string `json:"dinner_unit_price_for_teacher" xorm:"not null default 0.00 comment('教师-晚餐-单价') DECIMAL(4,2)"` + CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` } diff --git a/app/router/admin_router.go b/app/router/admin_router.go index 0ea24e3..e79ef1d 100644 --- a/app/router/admin_router.go +++ b/app/router/admin_router.go @@ -85,6 +85,10 @@ func rFinanceManage(r *gin.RouterGroup) { r.GET("/centralKitchenForSchool/ordDetail", hdl.CentralKitchenForSchoolOrdDetail) //财务管理-(央厨-学校)订单详情 r.POST("/centralKitchenForSchool/ordRefund", hdl.CentralKitchenForSchoolOrdRefund) //财务管理-(央厨-学校)订单退款 r.POST("/selfSupportForSchool/ordList", hdl.SelfSupportForSchoolOrdList) //财务管理-(自营-学校)订单列表 +} + +func rDataStatistics(r *gin.RouterGroup) { + r.POST("/centralKitchenForSchool/list", hdl2.CentralKitchenForSchoolDataStatisticsList) //数据统计-(央厨-学校)-列表 } @@ -104,6 +108,8 @@ func rEnterprise(r *gin.RouterGroup) { r.GET("/detail", hdl2.Detail) r.GET("/schoolBelowGrade", hdl2.SchoolBelowGrade) //"学校"下年级 r.GET("/schoolGradeBelowClass", hdl2.SchoolGradeBelowClass) //"学校"年级下班级 + r.POST("/setCentralKitchenForSchoolWithSpecForSystem", hdl2.SetCentralKitchenForSchoolWithSpecForSystem) //"央厨-学校-套餐-系统" 价格设置 + r.GET("/getCentralKitchenForSchoolWithSpecForSystem", hdl2.GetCentralKitchenForSchoolWithSpecForSystem) //"央厨-学校-套餐-系统" 价格获取 r.POST("/listCentralKitchenForSchoolPackageForSystem", hdl2.ListCentralKitchenForSchoolPackageForSystem) //"央厨-学校-套餐-系统" 列表 r.POST("/saveCentralKitchenForSchoolPackage", hdl2.SaveCentralKitchenForSchoolPackageForSystem) //新增/编辑 "央厨-学校-套餐-系统" r.DELETE("/deleteCentralKitchenForSchoolPackage/:id", hdl2.DeleteCentralKitchenForSchoolPackageForSystem) //删除 "央厨-学校-套餐-系统" @@ -208,4 +214,5 @@ func AdminRoute(r *gin.RouterGroup) { rUser(r.Group("/user")) //用户管理 rAuditCenter(r.Group("/auditCenter")) //审核中心 rFinanceManage(r.Group("/financeManage")) //财务管理 + rDataStatistics(r.Group("/dataStatistics")) //数据统计 }