@@ -191,7 +191,7 @@ type CentralKitchenForSchoolOrdListResp struct { | |||||
} | } | ||||
type CentralKitchenForSchoolOrdListReq 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"` | Limit int `json:"limit" binding:"required"` | ||||
Page int `json:"page" binding:"required"` | Page int `json:"page" binding:"required"` | ||||
Name string `json:"name" label:"姓名"` | Name string `json:"name" label:"姓名"` | ||||
@@ -16,17 +16,17 @@ func CheckPermission(c *gin.Context) { | |||||
//TODO::判断是否为超管 | //TODO::判断是否为超管 | ||||
if admin.IsSuperAdministrator == enum.IsSuperAdministratorTure { | if admin.IsSuperAdministrator == enum.IsSuperAdministratorTure { | ||||
c.Next() | 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() | |||||
} | } |
@@ -434,7 +434,7 @@ func CentralKitchenForSchoolOrdRefund(req md.CentralKitchenForSchoolOrdRefundReq | |||||
} | } | ||||
//2、更改 `central_kitchen_for_school_user_with_day` 的 state 为 退款中 | //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, ",") | idsStr := strings.Join(req.Ids, ",") | ||||
sql = fmt.Sprintf(sql, enum2.CentralKitchenForSchoolUserWithDayStateForCanceling, idsStr) | sql = fmt.Sprintf(sql, enum2.CentralKitchenForSchoolUserWithDayStateForCanceling, idsStr) | ||||
fmt.Println(sql) | fmt.Println(sql) | ||||
@@ -444,7 +444,7 @@ func CentralKitchenForSchoolOrdRefund(req md.CentralKitchenForSchoolOrdRefundReq | |||||
} | } | ||||
//3、循环处理数据 | //3、循环处理数据 | ||||
var dealOutTradeNo map[string]string | |||||
var dealOutTradeNo = map[string]string{} | |||||
var centralKitchenForSchoolUserRefundDays []*model.CentralKitchenForSchoolUserRefundDay | var centralKitchenForSchoolUserRefundDays []*model.CentralKitchenForSchoolUserRefundDay | ||||
now := time.Now() | now := time.Now() | ||||
for _, v := range m { | for _, v := range m { | ||||
@@ -7,7 +7,9 @@ import ( | |||||
"applet/app/db" | "applet/app/db" | ||||
"applet/app/e" | "applet/app/e" | ||||
"applet/app/enum" | "applet/app/enum" | ||||
"applet/app/utils" | |||||
"github.com/gin-gonic/gin" | "github.com/gin-gonic/gin" | ||||
"time" | |||||
) | ) | ||||
func CentralKitchenForSchoolOrderList(c *gin.Context) { | func CentralKitchenForSchoolOrderList(c *gin.Context) { | ||||
@@ -284,3 +286,24 @@ func CentralKitchenForSchoolOrderRefundList(c *gin.Context) { | |||||
}, nil) | }, nil) | ||||
return | 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 | |||||
} |
@@ -4,7 +4,6 @@ import ( | |||||
"applet/app/customer/lib/validate" | "applet/app/customer/lib/validate" | ||||
"applet/app/customer/md" | "applet/app/customer/md" | ||||
"applet/app/customer/svc" | "applet/app/customer/svc" | ||||
svc2 "applet/app/customer/svc/order" | |||||
"applet/app/db" | "applet/app/db" | ||||
"applet/app/db/model" | "applet/app/db/model" | ||||
"applet/app/e" | "applet/app/e" | ||||
@@ -248,23 +247,173 @@ func SaveSelfSupportForSchoolUserIdentity(c *gin.Context) { | |||||
return | 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 | 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 { | if err != nil { | ||||
e.OutErr(c, e.ERR, err.Error()) | |||||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||||
return | 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 | return | ||||
} | } |
@@ -18,3 +18,23 @@ type SaveSelfSupportForSchoolUserIdentityReq struct { | |||||
GradeId int `json:"grade_id" label:"年级id"` | GradeId int `json:"grade_id" label:"年级id"` | ||||
ClassId int `json:"class_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"` | |||||
} |
@@ -123,8 +123,8 @@ func rEnterpriseManage(r *gin.RouterGroup) { | |||||
r.GET("/centralKitchenForSchool/ordDetail", hdl.CentralKitchenForSchoolOrdDetail) //"央厨-学校"订单详情 | r.GET("/centralKitchenForSchool/ordDetail", hdl.CentralKitchenForSchoolOrdDetail) //"央厨-学校"订单详情 | ||||
r.POST("/centralKitchenForSchool/ordRefund", hdl.CentralKitchenForSchoolOrdRefund) //"央厨-学校"订单退款 | 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.POST("/setBasicCentralKitchenForSchool", hdl.SetBasicCentralKitchenForSchool) //"央厨-学校"设置基础设置 | ||||
r.GET("/getBasicCentralKitchenForSchool", hdl.GetBasicCentralKitchenForSchool) //"央厨-学校"获取基础设置 | r.GET("/getBasicCentralKitchenForSchool", hdl.GetBasicCentralKitchenForSchool) //"央厨-学校"获取基础设置 | ||||
@@ -11,6 +11,7 @@ func CustomerInit(r *gin.RouterGroup) { | |||||
rPay(r.Group("/pay")) | rPay(r.Group("/pay")) | ||||
rCentralKitchenForSchoolOrder(r.Group("/order/centralKitchenForSchool")) | rCentralKitchenForSchoolOrder(r.Group("/order/centralKitchenForSchool")) | ||||
rSelfSupportForSchool(r.Group("/selfSupportForSchool")) | rSelfSupportForSchool(r.Group("/selfSupportForSchool")) | ||||
rUserIdentity(r.Group("/userIdentity")) | |||||
r.POST("/curlAlipayPlanetEcocampusApiRosterSignUpInfoTest", hdl.CurlAlipayPlanetEcocampusApiRosterSignUpInfo) | r.POST("/curlAlipayPlanetEcocampusApiRosterSignUpInfoTest", hdl.CurlAlipayPlanetEcocampusApiRosterSignUpInfo) | ||||
@@ -67,3 +68,10 @@ func rSelfSupportForSchool(r *gin.RouterGroup) { //自营学校 | |||||
r.GET("/educateSceneTokenCreateForConcentratedCollectApplet", selfSupportForSchoolhdl.EducateSceneTokenCreateForConcentratedCollectApplet) // 自营学校-教育场景token生成处理器(作用于 跳转到集采小程序) | r.GET("/educateSceneTokenCreateForConcentratedCollectApplet", selfSupportForSchoolhdl.EducateSceneTokenCreateForConcentratedCollectApplet) // 自营学校-教育场景token生成处理器(作用于 跳转到集采小程序) | ||||
r.GET("/educateFacepayApply", selfSupportForSchoolhdl.EducateFacepayApply) // 自营学校-创建刷脸支付开通标识 | 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) // 修改"自营-学校"身份信息 | |||||
} |