diff --git a/app/admin/md/md_enterprise_manage.go b/app/admin/md/md_enterprise_manage.go index 06658de..39d1a5e 100644 --- a/app/admin/md/md_enterprise_manage.go +++ b/app/admin/md/md_enterprise_manage.go @@ -191,7 +191,7 @@ type CentralKitchenForSchoolOrdListResp struct { } type CentralKitchenForSchoolOrdListReq struct { - EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` + EnterpriseId int `json:"enterprise_id" label:"企业id"` Limit int `json:"limit" binding:"required"` Page int `json:"page" binding:"required"` Name string `json:"name" label:"姓名"` diff --git a/app/admin/mw/mw_admin_permission.go b/app/admin/mw/mw_admin_permission.go index b309b2e..640349d 100644 --- a/app/admin/mw/mw_admin_permission.go +++ b/app/admin/mw/mw_admin_permission.go @@ -16,17 +16,17 @@ func CheckPermission(c *gin.Context) { //TODO::判断是否为超管 if admin.IsSuperAdministrator == enum.IsSuperAdministratorTure { c.Next() + } else { + rolePermissionKey := fmt.Sprintf(md.AdminRolePermissionKey, utils.GetIP(c.Request), utils.AnyToString(admin.AdmId)) + isHasPermission, err := svc.CheckUserRole(rolePermissionKey, c.Request.RequestURI, admin.AdmId) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + if !isHasPermission { + e.OutErr(c, e.ERR_FORBIDEN, "当前用户暂未拥有该路由权限,请联系管理员") + return + } + c.Next() } - - rolePermissionKey := fmt.Sprintf(md.AdminRolePermissionKey, utils.GetIP(c.Request), utils.AnyToString(admin.AdmId)) - isHasPermission, err := svc.CheckUserRole(rolePermissionKey, c.Request.RequestURI, admin.AdmId) - if err != nil { - e.OutErr(c, e.ERR, err.Error()) - return - } - if !isHasPermission { - e.OutErr(c, e.ERR_FORBIDEN, "当前用户暂未拥有该路由权限,请联系管理员") - return - } - c.Next() } diff --git a/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go b/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go index c5c399f..45ca339 100644 --- a/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go +++ b/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go @@ -434,7 +434,7 @@ func CentralKitchenForSchoolOrdRefund(req md.CentralKitchenForSchoolOrdRefundReq } //2、更改 `central_kitchen_for_school_user_with_day` 的 state 为 退款中 - sql := "update central_kitchen_for_school_user_with_day set status = %s where id In (%s)" + sql := "update central_kitchen_for_school_user_with_day set state = %d where id In (%s)" idsStr := strings.Join(req.Ids, ",") sql = fmt.Sprintf(sql, enum2.CentralKitchenForSchoolUserWithDayStateForCanceling, idsStr) fmt.Println(sql) @@ -444,7 +444,7 @@ func CentralKitchenForSchoolOrdRefund(req md.CentralKitchenForSchoolOrdRefundReq } //3、循环处理数据 - var dealOutTradeNo map[string]string + var dealOutTradeNo = map[string]string{} var centralKitchenForSchoolUserRefundDays []*model.CentralKitchenForSchoolUserRefundDay now := time.Now() for _, v := range m { diff --git a/app/customer/hdl/hdl_central_kitchen_for_school_order.go b/app/customer/hdl/hdl_central_kitchen_for_school_order.go index 240f490..db7a69a 100644 --- a/app/customer/hdl/hdl_central_kitchen_for_school_order.go +++ b/app/customer/hdl/hdl_central_kitchen_for_school_order.go @@ -7,7 +7,9 @@ import ( "applet/app/db" "applet/app/e" "applet/app/enum" + "applet/app/utils" "github.com/gin-gonic/gin" + "time" ) func CentralKitchenForSchoolOrderList(c *gin.Context) { @@ -284,3 +286,24 @@ func CentralKitchenForSchoolOrderRefundList(c *gin.Context) { }, nil) return } + +func CentralKitchenForSchoolMyReserve(c *gin.Context) { + date := c.DefaultQuery("date", "") + userIdentityId := c.DefaultQuery("user_identity_id", "") + if date == "" { + e.OutErr(c, e.ERR_INVALID_ARGS, "日期不能为空") + return + } + startDate := date + "-01" + startDateTime, _ := time.Parse("2006-01-02", startDate) + endDate := startDateTime.AddDate(0, 1, -1).Format("2006-01-02") + err, resp := svc.CentralKitchenForSchoolMyReserve(utils.StrToInt(userIdentityId), date, startDate, endDate) + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + e.OutSuc(c, map[string]interface{}{ + "info": resp, + }, nil) + return +} diff --git a/app/customer/hdl/hdl_user_identity.go b/app/customer/hdl/hdl_user_identity.go index 9d20a64..b7760c0 100644 --- a/app/customer/hdl/hdl_user_identity.go +++ b/app/customer/hdl/hdl_user_identity.go @@ -4,7 +4,6 @@ import ( "applet/app/customer/lib/validate" "applet/app/customer/md" "applet/app/customer/svc" - svc2 "applet/app/customer/svc/order" "applet/app/db" "applet/app/db/model" "applet/app/e" @@ -248,23 +247,173 @@ func SaveSelfSupportForSchoolUserIdentity(c *gin.Context) { return } -func CentralKitchenForSchoolMyReserve(c *gin.Context) { - date := c.DefaultQuery("date", "") - userIdentityId := c.DefaultQuery("user_identity_id", "") - if date == "" { - e.OutErr(c, e.ERR_INVALID_ARGS, "日期不能为空") +func UpdateCentralKitchenForSchoolUserIdentity(c *gin.Context) { + var req md.UpdateCentralKitchenForSchoolUserIdentityReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = validate.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + user := svc.GetUser(c) + now := time.Time{} + //1、查询当前身份是否存在 + userIdentityDb := db.UserIdentityDb{} + userIdentityDb.Set(user.Id) + userIdentity, err := userIdentityDb.GetUserIdentity(req.UserIdentityId) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + + if userIdentity == nil { + e.OutErr(c, e.ERR_NO_DATA, "当前身份信息不存在") + return + } + //2、修改身份信息 + userIdentity.Name = req.Name + userIdentity.IdNo = req.IdNo + _, err = userIdentityDb.UserIdentityUpdate(userIdentity.Id, userIdentity, "id_no", "name") + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + + //3、修改 class_with_user 记录 + if userIdentity.Identity == enum.UserIdentityForCentralKitchenForStudent { + classWithUserDb := db.ClassWithUserDb{} + classWithUserDb.Set() + classWithUser, err1 := classWithUserDb.GetClassWithUserByUserIdentityId(userIdentity.Id) + if err1 != nil { + e.OutErr(c, e.ERR_DB_ORM, err1.Error()) + return + } + if classWithUser == nil { + _, err2 := classWithUserDb.ClassWithUserInsert(&model.ClassWithUser{ + UserIdentityId: userIdentity.Id, + ClassId: req.ClassId, + 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 + } + } else { + classWithUser.ClassId = req.ClassId + _, err2 := classWithUserDb.ClassWithUserUpdateByUserIdentity(userIdentity.Id, classWithUser, "class_id") + if err2 != nil { + e.OutErr(c, e.ERR_DB_ORM, err2.Error()) + return + } + } + } + + e.OutSuc(c, "success", nil) + return +} + +func UpdateSelfSupportForSchoolUserIdentity(c *gin.Context) { + var req md.UpdateSelfSupportForSchoolUserIdentityReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = validate.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) return } - startDate := date + "-01" - startDateTime, _ := time.Parse("2006-01-02", startDate) - endDate := startDateTime.AddDate(0, 1, -1).Format("2006-01-02") - err, resp := svc2.CentralKitchenForSchoolMyReserve(utils.StrToInt(userIdentityId), date, startDate, endDate) + user := svc.GetUser(c) + now := time.Time{} + //1、查询当前身份是否存在 + userIdentityDb := db.UserIdentityDb{} + userIdentityDb.Set(user.Id) + userIdentity, err := userIdentityDb.GetUserIdentity(req.UserIdentityId) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + + if userIdentity == nil { + e.OutErr(c, e.ERR_NO_DATA, "当前身份信息不存在") + return + } + //2、修改身份信息 + userIdentity.Name = req.Name + userIdentity.IdNo = req.IdNo + _, err = userIdentityDb.UserIdentityUpdate(userIdentity.Id, userIdentity, "id_no", "name") if err != nil { - e.OutErr(c, e.ERR, err.Error()) + e.OutErr(c, e.ERR_DB_ORM, err.Error()) return } - e.OutSuc(c, map[string]interface{}{ - "info": resp, - }, nil) + + //3、修改 class_with_user 记录 + if userIdentity.Identity == enum.UserIdentityForSelfSupportForStudent { + classWithUserDb := db.ClassWithUserDb{} + classWithUserDb.Set() + classWithUser, err1 := classWithUserDb.GetClassWithUserByUserIdentityId(userIdentity.Id) + if err1 != nil { + e.OutErr(c, e.ERR_DB_ORM, err1.Error()) + return + } + if classWithUser == nil { + _, err2 := classWithUserDb.ClassWithUserInsert(&model.ClassWithUser{ + UserIdentityId: userIdentity.Id, + ClassId: req.ClassId, + 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 + } + } else { + classWithUser.ClassId = req.ClassId + _, err2 := classWithUserDb.ClassWithUserUpdateByUserIdentity(userIdentity.Id, classWithUser, "class_id") + if err2 != nil { + e.OutErr(c, e.ERR_DB_ORM, err2.Error()) + return + } + } + } + + e.OutSuc(c, "success", nil) + return +} + +func DeleteUserIdentity(c *gin.Context) { + userIdentityId := utils.StrToInt(c.Param("id")) + + user := svc.GetUser(c) + //1、查询当前身份是否存在 + userIdentityDb := db.UserIdentityDb{} + userIdentityDb.Set(user.Id) + userIdentity, err := userIdentityDb.GetUserIdentity(userIdentityId) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if userIdentity == nil { + e.OutErr(c, e.ERR_NO_DATA, "当前身份信息不存在") + return + } + + switch userIdentity.Identity { + case enum.UserIdentityForCentralKitchenForStudent: + + break + case enum.UserIdentityForCentralKitchenForTeacher: + break + case enum.UserIdentityForCentralKitchenForWorker: + break + case enum.UserIdentityForSelfSupportForStudent: + break + case enum.UserIdentityForSelfSupportForTeacher: + break + case enum.UserIdentityForSelfSupportForWorker: + break + } + + e.OutSuc(c, "success", nil) return } diff --git a/app/customer/md/md_user_identity.go b/app/customer/md/md_user_identity.go index 9fe2ee9..96ab15c 100644 --- a/app/customer/md/md_user_identity.go +++ b/app/customer/md/md_user_identity.go @@ -18,3 +18,23 @@ type SaveSelfSupportForSchoolUserIdentityReq struct { GradeId int `json:"grade_id" label:"年级id"` ClassId int `json:"class_id" label:"班级id"` } + +type UpdateCentralKitchenForSchoolUserIdentityReq struct { + IdNo string `json:"id_no" label:"身份证号"` + Name string `json:"name" label:"姓名"` + Grade string `json:"grade" label:"年级"` + GradeId int `json:"grade_id" label:"年级id"` + Class string `json:"class" label:"班级"` + ClassId int `json:"class_id" label:"班级"` + UserIdentityId int `json:"user_identity_id" label:"用户身份id"` +} + +type UpdateSelfSupportForSchoolUserIdentityReq struct { + IdNo string `json:"id_no" label:"身份证号"` + Name string `json:"name" label:"姓名"` + Grade string `json:"grade" label:"年级"` + GradeId int `json:"grade_id" label:"年级id"` + Class string `json:"class" label:"班级"` + ClassId int `json:"class_id" label:"班级"` + UserIdentityId int `json:"user_identity_id" label:"用户身份id"` +} diff --git a/app/router/admin_router.go b/app/router/admin_router.go index 7e09ed9..f72aa77 100644 --- a/app/router/admin_router.go +++ b/app/router/admin_router.go @@ -123,8 +123,8 @@ func rEnterpriseManage(r *gin.RouterGroup) { r.GET("/centralKitchenForSchool/ordDetail", hdl.CentralKitchenForSchoolOrdDetail) //"央厨-学校"订单详情 r.POST("/centralKitchenForSchool/ordRefund", hdl.CentralKitchenForSchoolOrdRefund) //"央厨-学校"订单退款 - r.POST("/centralKitchenForSchoolOrderRefundList", hdl2.CentralKitchenForSchoolOrderRefundList) //"央厨-学校"订单退款列表 - r.POST("/centralKitchenForSchoolOrderRefundAudit", hdl2.CentralKitchenForSchoolOrderRefundAudit) //"央厨-学校"订单退款审核 + r.POST("/centralKitchenForSchoolOrderRefundList", hdl2.CentralKitchenForSchoolOrderRefundList) //"央厨-学校"订单退款列表 + //r.POST("/centralKitchenForSchoolOrderRefundAudit", hdl2.CentralKitchenForSchoolOrderRefundAudit) //"央厨-学校"订单退款审核 r.POST("/setBasicCentralKitchenForSchool", hdl.SetBasicCentralKitchenForSchool) //"央厨-学校"设置基础设置 r.GET("/getBasicCentralKitchenForSchool", hdl.GetBasicCentralKitchenForSchool) //"央厨-学校"获取基础设置 diff --git a/app/router/customer_router.go b/app/router/customer_router.go index 3937d34..eef48d2 100644 --- a/app/router/customer_router.go +++ b/app/router/customer_router.go @@ -11,6 +11,7 @@ func CustomerInit(r *gin.RouterGroup) { rPay(r.Group("/pay")) rCentralKitchenForSchoolOrder(r.Group("/order/centralKitchenForSchool")) rSelfSupportForSchool(r.Group("/selfSupportForSchool")) + rUserIdentity(r.Group("/userIdentity")) r.POST("/curlAlipayPlanetEcocampusApiRosterSignUpInfoTest", hdl.CurlAlipayPlanetEcocampusApiRosterSignUpInfo) @@ -67,3 +68,10 @@ func rSelfSupportForSchool(r *gin.RouterGroup) { //自营学校 r.GET("/educateSceneTokenCreateForConcentratedCollectApplet", selfSupportForSchoolhdl.EducateSceneTokenCreateForConcentratedCollectApplet) // 自营学校-教育场景token生成处理器(作用于 跳转到集采小程序) r.GET("/educateFacepayApply", selfSupportForSchoolhdl.EducateFacepayApply) // 自营学校-创建刷脸支付开通标识 } + +func rUserIdentity(r *gin.RouterGroup) { //用户身份 + r.Use(mw.Auth) //检测登录状态 + r.DELETE("/deleteUserIdentity/:id", hdl.DeleteUserIdentity) // 删除身份信息 + r.POST("/updateCentralKitchenForSchoolUserIdentity", hdl.UpdateCentralKitchenForSchoolUserIdentity) // 修改"央厨-学校"身份信息 + r.POST("/updateSelfSupportForSchoolUserIdentity", hdl.UpdateSelfSupportForSchoolUserIdentity) // 修改"自营-学校"身份信息 +}