@@ -10,6 +10,7 @@ import ( | |||
"applet/app/e" | |||
"applet/app/enum" | |||
"applet/app/utils" | |||
"fmt" | |||
"github.com/gin-gonic/gin" | |||
"time" | |||
) | |||
@@ -822,6 +823,85 @@ func CentralKitchenForSchoolReserveList(c *gin.Context) { | |||
return | |||
} | |||
func CentralKitchenForSchoolReserveUpdateStudent(c *gin.Context) { | |||
if c.Request.Method != "GET" { | |||
var req md.CentralKitchenForSchoolReserveUpdateStudentReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
//1、查询对应的 user_identity | |||
userIdentityDb := db.UserIdentityDb{} | |||
userIdentityDb.Set(req.Uid) | |||
identity, err := userIdentityDb.GetUserIdentity(req.UserIdentityId) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
//1、修改 central_kitchen_for_school_package_ord_for_reserve | |||
centralKitchenForSchoolPackageOrdForReserveDb := db.CentralKitchenForSchoolPackageOrdForReserve{} | |||
centralKitchenForSchoolPackageOrdForReserveDb.Set("") | |||
centralKitchenForSchoolPackageOrdForReserve, err := centralKitchenForSchoolPackageOrdForReserveDb.GetCentralKitchenForSchoolPackageOrdForReserveById(req.Id) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if centralKitchenForSchoolPackageOrdForReserve == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") | |||
return | |||
} | |||
centralKitchenForSchoolPackageOrdForReserve.UserIdentityId = req.UserIdentityId | |||
centralKitchenForSchoolPackageOrdForReserve.UserIdentityName = identity.Name | |||
updateAffected, err := centralKitchenForSchoolPackageOrdForReserveDb.CentralKitchenForSchoolPackageOrdForReserveUpdate(centralKitchenForSchoolPackageOrdForReserve, "user_identity_name", "user_identity_id", "update_at") | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if updateAffected <= 0 { | |||
e.OutErr(c, e.ERR_DB_ORM, "更新预定记录失败") | |||
return | |||
} | |||
//2、修改 central_kitchen_for_school_user_with_day | |||
sql := "update central_kitchen_for_school_user_with_day set identity_id = %d where identity_id = %d and kind = %d and date >= '%s' and date <= '%s'" | |||
sql = fmt.Sprintf(sql, req.UserIdentityId, req.OriginalUserIdentityId, centralKitchenForSchoolPackageOrdForReserve.Kind, centralKitchenForSchoolPackageOrdForReserve.MealTimeStart, centralKitchenForSchoolPackageOrdForReserve.MealTimeEnd) | |||
fmt.Println("sql >>>>>", sql) | |||
_, err = db.ExecuteOriginalSql(db.Db, sql) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
//查询出当前用户下所有身份 | |||
uid := c.DefaultQuery("uid", "") | |||
userIdentityDb := db.UserIdentityDb{} | |||
userIdentityDb.Set(utils.StrToInt(uid)) | |||
identity, err := userIdentityDb.FindUserIdentityByKind(enum.UserIdentityForCentralKitchenForStudent) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
var resp []interface{} | |||
for _, v := range *identity { | |||
resp = append(resp, map[string]interface{}{ | |||
"name": v.UserIdentity.Name, | |||
"enterprise_name": v.Enterprise.Name, | |||
"user_identity_id": v.UserIdentity.Id, | |||
}) | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": resp, | |||
}, nil) | |||
return | |||
} | |||
func CentralKitchenForSchoolReserveDetail(c *gin.Context) { | |||
id := c.DefaultQuery("id", "") | |||
centralKitchenForSchoolPackageOrdForReserveDb := db.CentralKitchenForSchoolPackageOrdForReserve{} | |||
@@ -247,6 +247,14 @@ type CentralKitchenForSchoolReserveListReq struct { | |||
EndDate string `json:"end_date" label:"截止时间"` | |||
} | |||
type CentralKitchenForSchoolReserveUpdateStudentReq struct { | |||
Id int `json:"id" ` | |||
EnterpriseId int `json:"enterprise_id" label:"企业id"` | |||
UserIdentityId int `json:"user_identity_id" ` | |||
OriginalUserIdentityId int `json:"original_user_identity_id" ` | |||
Uid int `json:"uid" ` | |||
} | |||
type CentralKitchenForSchoolReserveListResp struct { | |||
Id int `json:"id" ` | |||
EnterpriseId int `json:"enterprise_id" ` | |||
@@ -92,6 +92,18 @@ func (userIdentityDb *UserIdentityDb) FindUserIdentity() (*[]UserIdentityWithEnt | |||
return &m, nil | |||
} | |||
func (userIdentityDb *UserIdentityDb) FindUserIdentityByKind(identity int) (*[]UserIdentityWithEnterprise, error) { | |||
var m []UserIdentityWithEnterprise | |||
if err := userIdentityDb.Db. | |||
Join("LEFT", "enterprise", "user_identity.enterprise_id = enterprise.id"). | |||
Where("user_identity.state =?", enum.UserIdentityStateForNormal). | |||
And("user_identity.identity =?", identity). | |||
And("user_identity.uid =?", userIdentityDb.Uid).Desc("user_identity.id").Find(&m); err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
return &m, nil | |||
} | |||
func (userIdentityDb *UserIdentityDb) FindUserIdentityWithClass() (*[]UserIdentityWithClass, error) { | |||
var m []UserIdentityWithClass | |||
if err := userIdentityDb.Db. | |||
@@ -156,23 +156,25 @@ func rEnterpriseManage(r *gin.RouterGroup) { | |||
r.POST("/centralKitchenForSchool/userUpdate", hdl.CentralKitchenForSchoolUserUpdate) //"央厨-学校"用户编辑 | |||
r.POST("/centralKitchenForSchool/userDelete", hdl.CentralKitchenForSchoolUserDelete) //"央厨-学校"用户删除 | |||
r.POST("/centralKitchenForSchool/studentList", hdl.CentralKitchenForSchoolStudentList) //"央厨-学校"学生列表 | |||
r.POST("/centralKitchenForSchool/studentUpdate", hdl.CentralKitchenForSchoolStudentUpdate) //"央厨-学校"学生编辑 | |||
r.POST("/centralKitchenForSchool/studentDelete", hdl.CentralKitchenForSchoolStudentDelete) //"央厨-学校"学生删除 | |||
r.POST("/centralKitchenForSchool/studentAdmission", hdl.CentralKitchenForSchoolStudentAdmission) //"央厨-学校"学生升学 | |||
r.POST("/centralKitchenForSchool/teacherList", hdl.CentralKitchenForSchoolTeacherList) //"央厨-学校"教师列表 | |||
r.POST("/centralKitchenForSchool/teacherUpdate", hdl.CentralKitchenForSchoolTeacherUpdate) //"央厨-学校"教师编辑 | |||
r.POST("/centralKitchenForSchool/teacherDelete", hdl.CentralKitchenForSchoolTeacherDelete) //"央厨-学校"教师删除 | |||
r.POST("/centralKitchenForSchool/gradeList", hdl.CentralKitchenForSchoolGradeList) //"央厨-学校"年级列表 | |||
r.DELETE("/centralKitchenForSchool/gradeDelete/:id", hdl.CentralKitchenForSchoolGradeDelete) //"央厨-学校"年级删除 | |||
r.POST("/centralKitchenForSchool/classList", hdl.CentralKitchenForSchoolClassList) //"央厨-学校"班级列表 | |||
r.DELETE("/centralKitchenForSchool/classDelete/:id", hdl.CentralKitchenForSchoolClassDelete) //"央厨-学校"班级删除 | |||
r.POST("/centralKitchenForSchool/ordList", hdl.CentralKitchenForSchoolOrdList) //"央厨-学校"订单列表 | |||
r.GET("/centralKitchenForSchool/ordDetail", hdl.CentralKitchenForSchoolOrdDetail) //"央厨-学校"订单详情 | |||
r.POST("/centralKitchenForSchool/ordRefund", hdl.CentralKitchenForSchoolOrdRefund) //"央厨-学校"订单退款 | |||
r.POST("/centralKitchenForSchool/batchAskForLeave", hdl.CentralKitchenForSchoolBatchAskForLeave) //"央厨-学校"批量请假 | |||
r.POST("/centralKitchenForSchool/reserveList", hdl.CentralKitchenForSchoolReserveList) //"央厨-学校"预定列表 | |||
r.GET("/centralKitchenForSchool/reserveDetail", hdl.CentralKitchenForSchoolReserveDetail) //"央厨-学校"预定详情 | |||
r.POST("/centralKitchenForSchool/studentList", hdl.CentralKitchenForSchoolStudentList) //"央厨-学校"学生列表 | |||
r.POST("/centralKitchenForSchool/studentUpdate", hdl.CentralKitchenForSchoolStudentUpdate) //"央厨-学校"学生编辑 | |||
r.POST("/centralKitchenForSchool/studentDelete", hdl.CentralKitchenForSchoolStudentDelete) //"央厨-学校"学生删除 | |||
r.POST("/centralKitchenForSchool/studentAdmission", hdl.CentralKitchenForSchoolStudentAdmission) //"央厨-学校"学生升学 | |||
r.POST("/centralKitchenForSchool/teacherList", hdl.CentralKitchenForSchoolTeacherList) //"央厨-学校"教师列表 | |||
r.POST("/centralKitchenForSchool/teacherUpdate", hdl.CentralKitchenForSchoolTeacherUpdate) //"央厨-学校"教师编辑 | |||
r.POST("/centralKitchenForSchool/teacherDelete", hdl.CentralKitchenForSchoolTeacherDelete) //"央厨-学校"教师删除 | |||
r.POST("/centralKitchenForSchool/gradeList", hdl.CentralKitchenForSchoolGradeList) //"央厨-学校"年级列表 | |||
r.DELETE("/centralKitchenForSchool/gradeDelete/:id", hdl.CentralKitchenForSchoolGradeDelete) //"央厨-学校"年级删除 | |||
r.POST("/centralKitchenForSchool/classList", hdl.CentralKitchenForSchoolClassList) //"央厨-学校"班级列表 | |||
r.DELETE("/centralKitchenForSchool/classDelete/:id", hdl.CentralKitchenForSchoolClassDelete) //"央厨-学校"班级删除 | |||
r.POST("/centralKitchenForSchool/ordList", hdl.CentralKitchenForSchoolOrdList) //"央厨-学校"订单列表 | |||
r.GET("/centralKitchenForSchool/ordDetail", hdl.CentralKitchenForSchoolOrdDetail) //"央厨-学校"订单详情 | |||
r.POST("/centralKitchenForSchool/ordRefund", hdl.CentralKitchenForSchoolOrdRefund) //"央厨-学校"订单退款 | |||
r.POST("/centralKitchenForSchool/batchAskForLeave", hdl.CentralKitchenForSchoolBatchAskForLeave) //"央厨-学校"批量请假 | |||
r.POST("/centralKitchenForSchool/reserveList", hdl.CentralKitchenForSchoolReserveList) //"央厨-学校"预定列表 | |||
r.GET("/centralKitchenForSchool/reserveUpdateStudent", hdl.CentralKitchenForSchoolReserveUpdateStudent) //"央厨-学校"修改学生预定 | |||
r.POST("/centralKitchenForSchool/reserveUpdateStudent", hdl.CentralKitchenForSchoolReserveUpdateStudent) //"央厨-学校"修改学生预定 | |||
r.GET("/centralKitchenForSchool/reserveDetail", hdl.CentralKitchenForSchoolReserveDetail) //"央厨-学校"预定详情 | |||
r.POST("/centralKitchenForSchoolOrderRefundList", hdl2.CentralKitchenForSchoolOrderRefundList) //"央厨-学校"订单退款列表 | |||
//r.POST("/centralKitchenForSchoolOrderRefundAudit", hdl2.CentralKitchenForSchoolOrderRefundAudit) //"央厨-学校"订单退款审核 | |||