@@ -677,6 +677,7 @@ func CentralKitchenForSchoolOrdList(c *gin.Context) { | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
//enterpriseDb := db.EnterpriseDb{} | |||
//enterpriseDb.Set() | |||
//enterprise, err := enterpriseDb.GetEnterprise(req.EnterpriseId) | |||
@@ -759,6 +760,102 @@ func CentralKitchenForSchoolOrdList(c *gin.Context) { | |||
return | |||
} | |||
func CentralKitchenForSchoolReserveList(c *gin.Context) { | |||
var req md.CentralKitchenForSchoolReserveListReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
resp, total, err := svc2.CentralKitchenForSchoolReserveList(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": resp, | |||
"total": total, | |||
"kind_list": []map[string]interface{}{ | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserWithDayKind.String(enum.CentralKitchenForSchoolUserWithDayKindForBreakfast), | |||
"value": enum.CentralKitchenForSchoolUserWithDayKindForBreakfast, | |||
}, | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserWithDayKind.String(enum.CentralKitchenForSchoolUserWithDayKindForLunch), | |||
"value": enum.CentralKitchenForSchoolUserWithDayKindForLunch, | |||
}, | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserWithDayKind.String(enum.CentralKitchenForSchoolUserWithDayKindForDinner), | |||
"value": enum.CentralKitchenForSchoolUserWithDayKindForDinner, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
} | |||
func CentralKitchenForSchoolReserveDetail(c *gin.Context) { | |||
id := c.DefaultQuery("id", "") | |||
centralKitchenForSchoolPackageOrdForReserveDb := db.CentralKitchenForSchoolPackageOrdForReserve{} | |||
centralKitchenForSchoolPackageOrdForReserveDb.Set("") | |||
centralKitchenForSchoolPackageOrdForReserve, err := centralKitchenForSchoolPackageOrdForReserveDb.GetCentralKitchenForSchoolPackageOrdForReserveById(utils.StrToInt(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 | |||
} | |||
var m []model.CentralKitchenForSchoolUserWithDay | |||
err = db.Db.Where("ord_no =?", centralKitchenForSchoolPackageOrdForReserve.OutTradeNo). | |||
And("date >=? and date <=?", centralKitchenForSchoolPackageOrdForReserve.MealTimeStart, centralKitchenForSchoolPackageOrdForReserve.MealTimeEnd). | |||
Find(&m) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": m, | |||
"kind_list": []map[string]interface{}{ | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserWithDayKind.String(enum.CentralKitchenForSchoolUserWithDayKindForBreakfast), | |||
"value": enum.CentralKitchenForSchoolUserWithDayKindForBreakfast, | |||
}, | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserWithDayKind.String(enum.CentralKitchenForSchoolUserWithDayKindForLunch), | |||
"value": enum.CentralKitchenForSchoolUserWithDayKindForLunch, | |||
}, | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserWithDayKind.String(enum.CentralKitchenForSchoolUserWithDayKindForDinner), | |||
"value": enum.CentralKitchenForSchoolUserWithDayKindForDinner, | |||
}, | |||
}, | |||
"state_list": []map[string]interface{}{ | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserWithDayState.String(enum.CentralKitchenForSchoolUserWithDayStateForWait), | |||
"value": enum.CentralKitchenForSchoolUserWithDayStateForWait, | |||
}, | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserWithDayState.String(enum.CentralKitchenForSchoolUserWithDayStateForAlready), | |||
"value": enum.CentralKitchenForSchoolUserWithDayStateForAlready, | |||
}, | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserWithDayState.String(enum.CentralKitchenForSchoolUserWithDayStateForCanceling), | |||
"value": enum.CentralKitchenForSchoolUserWithDayStateForCanceling, | |||
}, | |||
{ | |||
"name": enum.CentralKitchenForSchoolUserWithDayState.String(enum.CentralKitchenForSchoolUserWithDayStateForCancel), | |||
"value": enum.CentralKitchenForSchoolUserWithDayStateForCancel, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
} | |||
func CentralKitchenForSchoolOrdRefund(c *gin.Context) { | |||
var req md.CentralKitchenForSchoolOrdRefundReq | |||
err := c.ShouldBindJSON(&req) | |||
@@ -788,6 +885,35 @@ func CentralKitchenForSchoolOrdRefund(c *gin.Context) { | |||
return | |||
} | |||
func CentralKitchenForSchoolBatchAskForLeave(c *gin.Context) { | |||
var req md.CentralKitchenForSchoolBatchAskForLeaveReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
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 | |||
} | |||
err = svc2.CentralKitchenForSchoolBatchAskForLeave(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func CentralKitchenForSchoolOrdDetail(c *gin.Context) { | |||
outTradeNo := c.DefaultQuery("out_trade_no", "") | |||
centralKitchenForSchoolPackageOrd := db.CentralKitchenForSchoolPackageOrd{} | |||
@@ -205,12 +205,47 @@ func SelfSupportForSchoolTeacherUpdate(c *gin.Context) { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
info.CollectFaceType = req.CollectFaceType | |||
_, err = selfSupportForUserFaceInfoDb.SelfSupportForUserFaceInfoUpdate(info, "collect_face_type") | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
if info == nil { | |||
now := time.Now() | |||
selfSupportForSchoolInfoDb := db.SelfSupportForSchoolInfoDb{} | |||
selfSupportForSchoolInfoDb.Set(req.EnterpriseId) | |||
selfSupportForSchoolInfo, err := selfSupportForSchoolInfoDb.GetSelfSupportForSchoolInfo() | |||
if err != nil { | |||
return | |||
} | |||
if selfSupportForSchoolInfo == nil { | |||
e.OutErr(c, e.ERR, "当前学校暂未完成《一脸通行入驻》") | |||
return | |||
} | |||
info = &model.SelfSupportForUserFaceInfo{ | |||
EnterpriseId: req.EnterpriseId, | |||
UserIdentityId: req.UserIdentityId, | |||
CollectFaceType: req.CollectFaceType, | |||
SchoolCode: selfSupportForSchoolInfo.SchoolCode, | |||
SchoolStdCode: selfSupportForSchoolInfo.SchoolStdCode, | |||
ParentUserId: "", | |||
ParentLogonId: "", | |||
UserId: "", | |||
SchoolFacePassStatus: "CLOSE", | |||
SchoolFacePaymentStatus: "CLOSE", | |||
ConcentrateSchoolFacePassStatus: 1, | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
} | |||
_, err1 := selfSupportForUserFaceInfoDb.SelfSupportForUserFaceInfoInsert(info) | |||
if err1 != nil { | |||
e.OutErr(c, e.ERR, err1.Error()) | |||
return | |||
} | |||
} else { | |||
info.CollectFaceType = req.CollectFaceType | |||
_, err = selfSupportForUserFaceInfoDb.SelfSupportForUserFaceInfoUpdate(info, "collect_face_type") | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
@@ -645,3 +680,35 @@ func SelfSupportForSchoolAddTeacher(c *gin.Context) { | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func SelfSupportForSchoolOrdList(c *gin.Context) { | |||
var req md.SelfSupportForSchoolOrdListReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
resp, total, err := svc2.SelfSupportForSchoolOrdList(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": resp, | |||
"total": total, | |||
"order_status_list": []map[string]interface{}{ | |||
{ | |||
"name": enum.SelfSupportForSchoolOrdOrderStatus.String(enum.SelfSupportForSchoolOrdOrderStatusForWait), | |||
"value": enum.SelfSupportForSchoolOrdOrderStatusForWait, | |||
}, | |||
{ | |||
"name": enum.SelfSupportForSchoolOrdOrderStatus.String(enum.SelfSupportForSchoolOrdOrderStatusForSuccess), | |||
"value": enum.SelfSupportForSchoolOrdOrderStatusForSuccess, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
} |
@@ -151,11 +151,36 @@ func EnterpriseAdd(c *gin.Context) { | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
} | |||
_, err = enterpriseDb.EnterpriseInsert(&enterprise) | |||
enterpriseId, err := enterpriseDb.EnterpriseInsert(&enterprise) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if req.Kind == enum.EnterprisePvdByCentralKitchenForSchool { | |||
//新增 `central_kitchen_for_school_set` && `central_kitchen_for_school_with_spec` | |||
centralKitchenForSchoolSetDb := db.CentralKitchenForSchoolSetDb{} | |||
centralKitchenForSchoolSetDb.Set(enterpriseId) | |||
centralKitchenForSchoolSetDb.CentralKitchenForSchoolSetInsert(&model.CentralKitchenForSchoolSet{ | |||
EnterpriseId: enterpriseId, | |||
IsOpenTeacherReportMeal: 1, | |||
IsOpenReportMealForDay: 1, | |||
IsOpenReportMealForMonth: 1, | |||
IsOpenReportMealForSemester: 1, | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
centralKitchenForSchoolWithSpec := db.CentralKitchenForSchoolWithSpec{} | |||
centralKitchenForSchoolWithSpec.Set(enterpriseId) | |||
centralKitchenForSchoolWithSpec.CentralKitchenForSchoolWithSpecInsert(&model.CentralKitchenForSchoolWithSpec{ | |||
EnterpriseId: enterpriseId, | |||
IsOpenBreakfast: 1, | |||
IsOpenLunch: 1, | |||
IsOpenDinner: 1, | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
@@ -391,3 +416,83 @@ func EnterpriseUpdateState(c *gin.Context) { | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func ListCentralKitchenForSchoolPackageForSystem(c *gin.Context) { | |||
var req md.ListCentralKitchenForSchoolPackageForSystemReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
centralKitchenForSchoolPackageForSystemDb := db.CentralKitchenForSchoolPackageForSystemDb{} | |||
centralKitchenForSchoolPackageForSystemDb.Set() | |||
list, total, err := centralKitchenForSchoolPackageForSystemDb.CentralKitchenForSchoolPackageForSystemList(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": list, | |||
"total": total, | |||
}, nil) | |||
return | |||
} | |||
func SaveCentralKitchenForSchoolPackageForSystem(c *gin.Context) { | |||
var req md.SaveCentralKitchenForSchoolPackageForSystemReq | |||
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.Id > 0 { | |||
err = svc.UpdateCentralKitchenForSchoolPackageForSystem(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
} else { | |||
err = svc.AddCentralKitchenForSchoolPackageForSystem(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func SyncCentralKitchenForSchoolPackageForSystem(c *gin.Context) { | |||
var req md.SyncCentralKitchenForSchoolPackageForSystemReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
err = svc.SyncCentralKitchenForSchoolPackageForSystem(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func DeleteCentralKitchenForSchoolPackageForSystem(c *gin.Context) { | |||
id := c.Param("id") | |||
err := svc.DeleteCentralKitchenForSchoolPackageForSystem(utils.StrToInt(id)) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} |
@@ -53,3 +53,40 @@ type GradeListStruct struct { | |||
Grade model.Grade `json:"grade"` | |||
ClassList []model.Class `json:"class_list"` | |||
} | |||
type ListCentralKitchenForSchoolPackageForSystemReq struct { | |||
Page int `json:"page" label:"页码"` | |||
Limit int `json:"limit" label:"每页数量"` | |||
Year string `json:"year" label:"年份"` | |||
Month string `json:"month" label:"月份"` | |||
} | |||
type SaveCentralKitchenForSchoolPackageForSystemReq struct { | |||
Id int `json:"id" label:"套餐ID"` | |||
Year string `json:"year" binding:"required" label:"年份"` | |||
Month string `json:"month" binding:"required" label:"月份"` | |||
StartDate string `json:"start_date" binding:"required" label:"开始时间"` | |||
EndDate string `json:"end_date" binding:"required" label:"截止时间"` | |||
State int `json:"state" label:"状态(1:可用 2:不可用)"` | |||
DateList []struct { | |||
Date string `json:"date"` | |||
IsOpenBreakfast int `json:"is_open_breakfast"` | |||
IsOpenLunch int `json:"is_open_lunch"` | |||
IsOpenDinner int `json:"is_open_dinner"` | |||
IsOpenReplenish int `json:"is_open_replenish"` | |||
} `json:"date_list" binding:"required" label:"日期"` | |||
} | |||
type SyncCentralKitchenForSchoolPackageForSystemReq struct { | |||
Ids []int `json:"ids" label:"套餐ids"` | |||
EnterpriseIds []int `json:"enterprise_ids" label:"校企ids"` | |||
IsCarryPackagePrice bool `json:"is_carry_package_price" label:"是否跟随套餐价格"` | |||
} | |||
type CentralKitchenForSchoolPackageForSystemWithDay struct { | |||
Date string `json:"date"` | |||
IsOpenBreakfast int `json:"is_open_breakfast"` | |||
IsOpenLunch int `json:"is_open_lunch"` | |||
IsOpenDinner int `json:"is_open_dinner"` | |||
IsOpenReplenish int `json:"is_open_replenish"` | |||
} |
@@ -187,6 +187,7 @@ type CentralKitchenForSchoolOrdListResp struct { | |||
State int `json:"state"` | |||
OrdState int `json:"ord_state"` | |||
CreateAt string `json:"create_at"` | |||
Phone string `json:"phone" label:"家长联系电话"` | |||
Name string `json:"name" label:"姓名"` | |||
Grade string `json:"grade" label:"年级"` | |||
GradeId int `json:"grade_id" label:"年级id"` | |||
@@ -205,10 +206,42 @@ type CentralKitchenForSchoolOrdListReq struct { | |||
OrdSate int `json:"ord_state" label:"订单状态"` | |||
GradeId int `json:"grade_id" label:"年级id"` | |||
ClassId int `json:"class_id" label:"班级id"` | |||
Phone string `json:"phone" label:"家长联系电话"` | |||
StartDate string `json:"start_date" label:"开始时间"` | |||
EndDate string `json:"end_date" label:"截止时间"` | |||
} | |||
type CentralKitchenForSchoolReserveListReq struct { | |||
EnterpriseId int `json:"enterprise_id" label:"企业id"` | |||
Limit int `json:"limit" binding:"required"` | |||
Page int `json:"page" binding:"required"` | |||
Name string `json:"name" label:"姓名"` | |||
OutTradeNo string `json:"out_trade_no" label:"订单号"` | |||
Kind int `json:"kind" label:"预定类型"` | |||
GradeId int `json:"grade_id" label:"年级id"` | |||
ClassId int `json:"class_id" label:"班级id"` | |||
Phone string `json:"phone" label:"家长联系电话"` | |||
StartDate string `json:"start_date" label:"开始时间"` | |||
EndDate string `json:"end_date" label:"截止时间"` | |||
} | |||
type CentralKitchenForSchoolReserveListResp struct { | |||
EnterpriseId int `json:"enterprise_id" ` | |||
EnterpriseName string `json:"enterprise_name" ` | |||
Uid int `json:"uid" ` | |||
UserIdentityId int `json:"user_identity_id" ` | |||
UserIdentityName string `json:"user_identity_name" ` | |||
Kind int `json:"kind"` | |||
OutTradeNo string `json:"out_trade_no" ` | |||
ReserveMonth string `json:"reserve_month"` | |||
CreateAt string `json:"create_at"` | |||
Phone string `json:"phone" label:"家长联系电话"` | |||
Grade string `json:"grade" label:"年级"` | |||
GradeId int `json:"grade_id" label:"年级id"` | |||
Class string `json:"class" label:"班级"` | |||
ClassId int `json:"class_id" label:"班级id"` | |||
} | |||
type SelfSupportForSchoolUserUpdateReq struct { | |||
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` | |||
Uid int `json:"uid" binding:"required" label:"用户id"` | |||
@@ -374,3 +407,47 @@ type SelfSupportForSchoolAddTeacherReq struct { | |||
Name string `json:"name" label:"名称"` | |||
IdNo string `json:"id_no" label:"身份证号"` | |||
} | |||
type SelfSupportForSchoolOrdListReq struct { | |||
EnterpriseId int `json:"enterprise_id" label:"企业id"` | |||
Limit int `json:"limit" binding:"required"` | |||
Page int `json:"page" binding:"required"` | |||
Name string `json:"name" label:"姓名"` | |||
Phone string `json:"phone" label:"用户电话"` | |||
OutTradeNo string `json:"out_trade_no" label:"订单号"` | |||
OrderStatus int `json:"order_status" label:"订单状态"` | |||
GradeId int `json:"grade_id" label:"年级id"` | |||
ClassId int `json:"class_id" label:"班级id"` | |||
StartDate string `json:"start_date" label:"刷脸-开始时间"` | |||
EndDate string `json:"end_date" label:"刷脸-截止时间"` | |||
} | |||
type SelfSupportForSchoolOrdListResp struct { | |||
EnterpriseId int `json:"enterprise_id" ` | |||
EnterpriseName string `json:"enterprise_name" ` | |||
Uid int `json:"uid" ` | |||
UserIdentityId int `json:"user_identity_id" ` | |||
UserIdentityName string `json:"user_identity_name" ` | |||
TotalPrice string `json:"total_price" ` | |||
OutTradeNo string `json:"out_trade_no" ` | |||
TradeNo string `json:"trade_no"` | |||
OrderStatus int `json:"order_status"` | |||
Phone string `json:"phone"` | |||
FaceTime string `json:"face_time"` | |||
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:"班级id"` | |||
DeviceSn string `json:"device_sn" label:"设备编号"` | |||
} | |||
type CentralKitchenForSchoolBatchAskForLeaveReq struct { | |||
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` | |||
GradeId int `json:"grade_id" binding:"required" label:"年级id"` | |||
ClassId int `json:"class_id" label:"班级id"` | |||
IsBreakfast int `json:"is_breakfast" label:"是否退早餐(1:退 0:不退)"` | |||
IsLunch int `json:"is_lunch" label:"是否退午餐(1:退 0:不退)"` | |||
IsDinner int `json:"is_dinner" label:"是否退晚餐(1:退 0:不退)"` | |||
Date string `json:"date"` | |||
} |
@@ -72,6 +72,7 @@ func CentralKitchenForSchoolUserUpdate(req md.CentralKitchenForSchoolUserUpdateR | |||
Kind: enum2.UserIdentityKindForCommon, | |||
Identity: enum2.UserIdentityForCentralKitchenForStudent, | |||
EnterpriseId: req.EnterpriseId, | |||
State: enum2.UserIdentityStateForNormal, | |||
Memo: "", | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
@@ -431,6 +432,10 @@ func CentralKitchenForSchoolOrdList(req md.CentralKitchenForSchoolOrdListReq) (r | |||
if req.Name != "" { | |||
sess.And("user_identity.name like ?", "%"+req.Name+"%") | |||
} | |||
if req.Phone != "" { | |||
sess.And("user.phone like ?", "%"+req.Phone+"%") | |||
} | |||
if len(classWithUserIdentityIdsOne) > 0 { | |||
sess.In("user_identity.id", classWithUserIdentityIdsOne) | |||
} | |||
@@ -442,6 +447,7 @@ func CentralKitchenForSchoolOrdList(req md.CentralKitchenForSchoolOrdListReq) (r | |||
count, err = sess. | |||
Join("LEFT", "user_identity", "central_kitchen_for_school_package_ord.user_identity_id = user_identity.id"). | |||
Join("LEFT", "enterprise", "enterprise.id = user_identity.enterprise_id"). | |||
Join("LEFT", "user", "user.id = user_identity.uid"). | |||
Join("LEFT", "class_with_user", "class_with_user.user_identity_id = user_identity.id"). | |||
Join("LEFT", "class", "class_with_user.class_id = class.id"). | |||
Join("LEFT", "grade", "class.grade_id = grade.id"). | |||
@@ -464,6 +470,7 @@ func CentralKitchenForSchoolOrdList(req md.CentralKitchenForSchoolOrdListReq) (r | |||
State: v.CentralKitchenForSchoolPackageOrd.State, | |||
OrdState: v.CentralKitchenForSchoolPackageOrd.OrdState, | |||
CreateAt: v.CentralKitchenForSchoolPackageOrd.CreateAt, | |||
Phone: v.User.Phone, | |||
Name: v.UserIdentity.Name, | |||
Grade: v.Grade.Name, | |||
GradeId: v.Grade.Id, | |||
@@ -474,6 +481,105 @@ func CentralKitchenForSchoolOrdList(req md.CentralKitchenForSchoolOrdListReq) (r | |||
return | |||
} | |||
func CentralKitchenForSchoolReserveList(req md.CentralKitchenForSchoolReserveListReq) (resp []md.CentralKitchenForSchoolReserveListResp, count int64, err error) { | |||
var classWithUserIdentityIdsOne []int | |||
var classWithUserIdentityIdsTwo []int | |||
classWithUserDb := db.ClassWithUserDb{} | |||
classWithUserDb.Set() | |||
if req.ClassId != 0 { | |||
classWithUsers, err2 := classWithUserDb.FindUserIdentity(req.ClassId) | |||
if err2 != nil { | |||
return nil, 0, err2 | |||
} | |||
for _, v := range *classWithUsers { | |||
classWithUserIdentityIdsOne = append(classWithUserIdentityIdsOne, v.UserIdentityId) | |||
} | |||
} | |||
if req.GradeId != 0 { | |||
classDb := db.ClassDb{} | |||
classDb.Set(req.GradeId) | |||
classes, err3 := classDb.FindClass() | |||
if err3 != nil { | |||
return nil, 0, err3 | |||
} | |||
var classesId []int | |||
for _, v := range *classes { | |||
classesId = append(classesId, v.Id) | |||
} | |||
classWithUsers, err4 := classWithUserDb.FindUserIdentity(classesId) | |||
if err4 != nil { | |||
return nil, 0, err4 | |||
} | |||
for _, v := range *classWithUsers { | |||
classWithUserIdentityIdsTwo = append(classWithUserIdentityIdsTwo, v.UserIdentityId) | |||
} | |||
} | |||
sess := db.Db.Where("1=1").Desc("central_kitchen_for_school_package_ord_for_reserve.id") | |||
if req.EnterpriseId != 0 { | |||
sess.And("central_kitchen_for_school_package_ord_for_reserve.enterprise_id =?", req.EnterpriseId) | |||
} | |||
if req.StartDate != "" { | |||
sess.And("central_kitchen_for_school_package_ord_for_reserve.meal_time_start >= ?", req.StartDate) | |||
} | |||
if req.EndDate != "" { | |||
sess.And("central_kitchen_for_school_package_ord_for_reserve.meal_time_start <= ?", req.EndDate) | |||
} | |||
if req.Kind != 0 { | |||
sess.And("central_kitchen_for_school_package_ord_for_reserve.kind = ?", req.Kind) | |||
} | |||
if req.OutTradeNo != "" { | |||
sess.And("central_kitchen_for_school_package_ord_for_reserve.out_trade_no like ?", "%"+req.OutTradeNo+"%") | |||
} | |||
if req.Name != "" { | |||
sess.And("user_identity.name like ?", "%"+req.Name+"%") | |||
} | |||
if req.Phone != "" { | |||
sess.And("user.phone like ?", "%"+req.Phone+"%") | |||
} | |||
if len(classWithUserIdentityIdsOne) > 0 { | |||
sess.In("user_identity.id", classWithUserIdentityIdsOne) | |||
} | |||
if len(classWithUserIdentityIdsTwo) > 0 { | |||
sess.In("user_identity.id", classWithUserIdentityIdsTwo) | |||
} | |||
var m []*db.CentralKitchenForSchoolPackageOrdForReserveWithUserIdentity | |||
count, err = sess. | |||
Join("LEFT", "central_kitchen_for_school_package_ord", "central_kitchen_for_school_package_ord_for_reserve.out_trade_no = central_kitchen_for_school_package_ord.out_trade_no"). | |||
Join("LEFT", "user_identity", "central_kitchen_for_school_package_ord.user_identity_id = user_identity.id"). | |||
Join("LEFT", "enterprise", "enterprise.id = user_identity.enterprise_id"). | |||
Join("LEFT", "user", "user.id = user_identity.uid"). | |||
Join("LEFT", "class_with_user", "class_with_user.user_identity_id = user_identity.id"). | |||
Join("LEFT", "class", "class_with_user.class_id = class.id"). | |||
Join("LEFT", "grade", "class.grade_id = grade.id"). | |||
Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m) | |||
if err != nil { | |||
return nil, 0, err | |||
} | |||
for _, v := range m { | |||
resp = append(resp, md.CentralKitchenForSchoolReserveListResp{ | |||
EnterpriseId: v.UserIdentity.EnterpriseId, | |||
EnterpriseName: v.Enterprise.Name, | |||
Uid: v.UserIdentity.Uid, | |||
UserIdentityId: v.UserIdentity.Id, | |||
UserIdentityName: v.CentralKitchenForSchoolPackageOrd.UserIdentityName, | |||
Kind: v.CentralKitchenForSchoolPackageOrdForReserve.Kind, | |||
ReserveMonth: v.CentralKitchenForSchoolPackageOrdForReserve.ReserveMonth, | |||
CreateAt: v.CentralKitchenForSchoolPackageOrdForReserve.CreateAt, | |||
OutTradeNo: v.CentralKitchenForSchoolPackageOrd.OutTradeNo, | |||
Phone: v.User.Phone, | |||
Grade: v.Grade.Name, | |||
GradeId: v.Grade.Id, | |||
Class: v.Class.Name, | |||
ClassId: v.Class.Id, | |||
}) | |||
} | |||
return | |||
} | |||
func CentralKitchenForSchoolOrdRefund(req md.CentralKitchenForSchoolOrdRefundReq) (err error) { | |||
//1、查询出所有 `central_kitchen_for_school_user_with_day` 记录 | |||
var m []model.CentralKitchenForSchoolUserWithDay | |||
@@ -483,47 +589,249 @@ func CentralKitchenForSchoolOrdRefund(req md.CentralKitchenForSchoolOrdRefundReq | |||
if err != nil { | |||
return err | |||
} | |||
if len(m) > 0 { | |||
//2、更改 `central_kitchen_for_school_user_with_day` 的 state 为 退款中 | |||
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) | |||
_, err = db.ExecuteOriginalSql(db.Db, sql) | |||
if err != nil { | |||
return err | |||
} | |||
//2、更改 `central_kitchen_for_school_user_with_day` 的 state 为 退款中 | |||
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) | |||
_, err = db.ExecuteOriginalSql(db.Db, sql) | |||
if err != nil { | |||
return err | |||
} | |||
//3、循环处理数据 | |||
var dealOutTradeNo = map[string]string{} | |||
var centralKitchenForSchoolUserRefundDays []*model.CentralKitchenForSchoolUserRefundDay | |||
now := time.Now() | |||
for _, v := range m { | |||
dealOutTradeNo[v.OrdNo] = v.OrdNo | |||
centralKitchenForSchoolUserRefundDays = append(centralKitchenForSchoolUserRefundDays, &model.CentralKitchenForSchoolUserRefundDay{ | |||
Uid: v.Uid, | |||
IdentityId: v.IdentityId, | |||
RecordsId: v.Id, | |||
State: enum2.CentralKitchenForSchoolUserRefundDayStateForAuditing, | |||
Amount: v.Amount, | |||
Memo: "", | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
} | |||
//3、循环处理数据 | |||
var dealOutTradeNo = map[string]string{} | |||
var centralKitchenForSchoolUserRefundDays []*model.CentralKitchenForSchoolUserRefundDay | |||
now := time.Now() | |||
for _, v := range m { | |||
dealOutTradeNo[v.OrdNo] = v.OrdNo | |||
centralKitchenForSchoolUserRefundDays = append(centralKitchenForSchoolUserRefundDays, &model.CentralKitchenForSchoolUserRefundDay{ | |||
Uid: v.Uid, | |||
IdentityId: v.IdentityId, | |||
RecordsId: v.Id, | |||
State: enum2.CentralKitchenForSchoolUserRefundDayStateForAuditing, | |||
Amount: v.Amount, | |||
Memo: "", | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
//4、处理 `central_kitchen_for_school_package_ord` 的 订单状态(ord_state) | |||
for _, v := range dealOutTradeNo { | |||
err1 := JudgePackageOrdOrdState(v) | |||
if err1 != nil { | |||
return err1 | |||
} | |||
} | |||
//5、新增 `central_kitchen_for_school_user_refund_day` 数据 | |||
centralKitchenForSchoolUserRefundDayDb := db.CentralKitchenForSchoolUserRefundDayDb{} | |||
centralKitchenForSchoolUserRefundDayDb.Set(0) | |||
_, err = centralKitchenForSchoolUserRefundDayDb.BatchAddCentralKitchenForSchoolUserRefundDays(centralKitchenForSchoolUserRefundDays) | |||
} | |||
return | |||
} | |||
//4、处理 `central_kitchen_for_school_package_ord` 的 订单状态(ord_state) | |||
for _, v := range dealOutTradeNo { | |||
err1 := JudgePackageOrdOrdState(v) | |||
func CentralKitchenForSchoolBatchAskForLeave(req md.CentralKitchenForSchoolBatchAskForLeaveReq) (err error) { | |||
classWithUserDb := db.ClassWithUserDb{} | |||
classWithUserDb.Set() | |||
//1、判断 "按年级" / "按班级" | |||
var classWithUser *[]model.ClassWithUser | |||
if req.ClassId != 0 { | |||
classWithUser, err = classWithUserDb.FindUserIdentity(req.ClassId) | |||
if err != nil { | |||
return err | |||
} | |||
} else { | |||
classDb := db.ClassDb{} | |||
classDb.Set(req.GradeId) | |||
classes, err1 := classDb.FindClass() | |||
if err1 != nil { | |||
return err1 | |||
} | |||
var classIds []int | |||
for _, v := range *classes { | |||
classIds = append(classIds, v.Id) | |||
} | |||
classWithUser, err = classWithUserDb.FindUserIdentity(classIds) | |||
if err != nil { | |||
return err | |||
} | |||
} | |||
var identityIds []string | |||
for _, v := range *classWithUser { | |||
identityIds = append(identityIds, utils.IntToStr(v.UserIdentityId)) | |||
} | |||
if len(identityIds) <= 0 { | |||
return errors.New("【" + req.Date + "】,无需请假学生") | |||
} | |||
//2、查询出所有 `central_kitchen_for_school_user_with_day` 记录 | |||
var m []model.CentralKitchenForSchoolUserWithDay | |||
centralKitchenForSchoolUserWithDayDb := db.CentralKitchenForSchoolUserWithDayDb{} | |||
centralKitchenForSchoolUserWithDayDb.Set(0) | |||
if req.IsBreakfast == 1 { | |||
err = centralKitchenForSchoolUserWithDayDb.Db.In("identity_id", identityIds).And("date =?", req.Date). | |||
And("kind =?", enum2.CentralKitchenForSchoolUserWithDayKindForBreakfast).Find(&m) | |||
if err != nil { | |||
return err | |||
} | |||
if len(m) > 0 { | |||
//2、更改 `central_kitchen_for_school_user_with_day` 的 state 为 退款中 | |||
sql := "update central_kitchen_for_school_user_with_day set state = %d where identity_id In (%s) and date = %s and kind = %d" | |||
idsStr := strings.Join(identityIds, ",") | |||
sql = fmt.Sprintf(sql, enum2.CentralKitchenForSchoolUserWithDayStateForCanceling, idsStr, req.Date, enum2.CentralKitchenForSchoolUserWithDayKindForBreakfast) | |||
fmt.Println(sql) | |||
_, err = db.ExecuteOriginalSql(db.Db, sql) | |||
if err != nil { | |||
return err | |||
} | |||
//3、循环处理数据 | |||
var dealOutTradeNo = map[string]string{} | |||
var centralKitchenForSchoolUserRefundDays []*model.CentralKitchenForSchoolUserRefundDay | |||
now := time.Now() | |||
for _, v := range m { | |||
dealOutTradeNo[v.OrdNo] = v.OrdNo | |||
centralKitchenForSchoolUserRefundDays = append(centralKitchenForSchoolUserRefundDays, &model.CentralKitchenForSchoolUserRefundDay{ | |||
Uid: v.Uid, | |||
IdentityId: v.IdentityId, | |||
RecordsId: v.Id, | |||
State: enum2.CentralKitchenForSchoolUserRefundDayStateForAuditing, | |||
Amount: v.Amount, | |||
Memo: "", | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
} | |||
//4、处理 `central_kitchen_for_school_package_ord` 的 订单状态(ord_state) | |||
for _, v := range dealOutTradeNo { | |||
err1 := JudgePackageOrdOrdState(v) | |||
if err1 != nil { | |||
return err1 | |||
} | |||
} | |||
//5、新增 `central_kitchen_for_school_user_refund_day` 数据 | |||
centralKitchenForSchoolUserRefundDayDb := db.CentralKitchenForSchoolUserRefundDayDb{} | |||
centralKitchenForSchoolUserRefundDayDb.Set(0) | |||
_, err = centralKitchenForSchoolUserRefundDayDb.BatchAddCentralKitchenForSchoolUserRefundDays(centralKitchenForSchoolUserRefundDays) | |||
if err != nil { | |||
return err | |||
} | |||
} | |||
} | |||
if req.IsLunch == 1 { | |||
err = centralKitchenForSchoolUserWithDayDb.Db.In("identity_id", identityIds).And("date =?", req.Date). | |||
And("kind =?", enum2.CentralKitchenForSchoolUserWithDayKindForLunch).Find(&m) | |||
if err != nil { | |||
return err | |||
} | |||
if len(m) > 0 { | |||
//2、更改 `central_kitchen_for_school_user_with_day` 的 state 为 退款中 | |||
sql := "update central_kitchen_for_school_user_with_day set state = %d where identity_id In (%s) and date = %s and kind = %d" | |||
idsStr := strings.Join(identityIds, ",") | |||
sql = fmt.Sprintf(sql, enum2.CentralKitchenForSchoolUserWithDayStateForCanceling, idsStr, req.Date, enum2.CentralKitchenForSchoolUserWithDayKindForLunch) | |||
fmt.Println(sql) | |||
_, err = db.ExecuteOriginalSql(db.Db, sql) | |||
if err != nil { | |||
return err | |||
} | |||
//3、循环处理数据 | |||
var dealOutTradeNo = map[string]string{} | |||
var centralKitchenForSchoolUserRefundDays []*model.CentralKitchenForSchoolUserRefundDay | |||
now := time.Now() | |||
for _, v := range m { | |||
dealOutTradeNo[v.OrdNo] = v.OrdNo | |||
centralKitchenForSchoolUserRefundDays = append(centralKitchenForSchoolUserRefundDays, &model.CentralKitchenForSchoolUserRefundDay{ | |||
Uid: v.Uid, | |||
IdentityId: v.IdentityId, | |||
RecordsId: v.Id, | |||
State: enum2.CentralKitchenForSchoolUserRefundDayStateForAuditing, | |||
Amount: v.Amount, | |||
Memo: "", | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
} | |||
//4、处理 `central_kitchen_for_school_package_ord` 的 订单状态 (ord_state) | |||
for _, v := range dealOutTradeNo { | |||
err1 := JudgePackageOrdOrdState(v) | |||
if err1 != nil { | |||
return err1 | |||
} | |||
} | |||
//5、新增 `central_kitchen_for_school_user_refund_day` 数据 | |||
centralKitchenForSchoolUserRefundDayDb := db.CentralKitchenForSchoolUserRefundDayDb{} | |||
centralKitchenForSchoolUserRefundDayDb.Set(0) | |||
_, err = centralKitchenForSchoolUserRefundDayDb.BatchAddCentralKitchenForSchoolUserRefundDays(centralKitchenForSchoolUserRefundDays) | |||
if err != nil { | |||
return err | |||
} | |||
} | |||
} | |||
//5、新增 `central_kitchen_for_school_user_refund_day` 数据 | |||
centralKitchenForSchoolUserRefundDayDb := db.CentralKitchenForSchoolUserRefundDayDb{} | |||
centralKitchenForSchoolUserRefundDayDb.Set(0) | |||
_, err = centralKitchenForSchoolUserRefundDayDb.BatchAddCentralKitchenForSchoolUserRefundDays(centralKitchenForSchoolUserRefundDays) | |||
if req.IsDinner == 1 { | |||
err = centralKitchenForSchoolUserWithDayDb.Db.In("identity_id", identityIds).And("date =?", req.Date). | |||
And("kind =?", enum2.CentralKitchenForSchoolUserWithDayKindForDinner).Find(&m) | |||
if err != nil { | |||
return err | |||
} | |||
if len(m) < 0 { | |||
//2、更改 `central_kitchen_for_school_user_with_day` 的 state 为 退款中 | |||
sql := "update central_kitchen_for_school_user_with_day set state = %d where identity_id In (%s) and date = %s and kind = %d" | |||
idsStr := strings.Join(identityIds, ",") | |||
sql = fmt.Sprintf(sql, enum2.CentralKitchenForSchoolUserWithDayStateForCanceling, idsStr, req.Date, enum2.CentralKitchenForSchoolUserWithDayKindForDinner) | |||
fmt.Println(sql) | |||
_, err = db.ExecuteOriginalSql(db.Db, sql) | |||
if err != nil { | |||
return err | |||
} | |||
//3、循环处理数据 | |||
var dealOutTradeNo = map[string]string{} | |||
var centralKitchenForSchoolUserRefundDays []*model.CentralKitchenForSchoolUserRefundDay | |||
now := time.Now() | |||
for _, v := range m { | |||
dealOutTradeNo[v.OrdNo] = v.OrdNo | |||
centralKitchenForSchoolUserRefundDays = append(centralKitchenForSchoolUserRefundDays, &model.CentralKitchenForSchoolUserRefundDay{ | |||
Uid: v.Uid, | |||
IdentityId: v.IdentityId, | |||
RecordsId: v.Id, | |||
State: enum2.CentralKitchenForSchoolUserRefundDayStateForAuditing, | |||
Amount: v.Amount, | |||
Memo: "", | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
} | |||
//4、处理 `central_kitchen_for_school_package_ord` 的 订单状态(ord_state) | |||
for _, v := range dealOutTradeNo { | |||
err1 := JudgePackageOrdOrdState(v) | |||
if err1 != nil { | |||
return err1 | |||
} | |||
} | |||
//5、新增 `central_kitchen_for_school_user_refund_day` 数据 | |||
centralKitchenForSchoolUserRefundDayDb := db.CentralKitchenForSchoolUserRefundDayDb{} | |||
centralKitchenForSchoolUserRefundDayDb.Set(0) | |||
_, err = centralKitchenForSchoolUserRefundDayDb.BatchAddCentralKitchenForSchoolUserRefundDays(centralKitchenForSchoolUserRefundDays) | |||
if err != nil { | |||
return err | |||
} | |||
} | |||
} | |||
return | |||
} | |||
@@ -63,6 +63,7 @@ func SelfSupportForSchoolUserUpdate(req md.SelfSupportForSchoolUserUpdateReq) (e | |||
Identity: enum2.UserIdentityForSelfSupportForTeacher, | |||
EnterpriseId: req.EnterpriseId, | |||
Memo: "", | |||
State: enum2.UserIdentityStateForNormal, | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
@@ -83,6 +84,7 @@ func SelfSupportForSchoolUserUpdate(req md.SelfSupportForSchoolUserUpdateReq) (e | |||
Identity: enum2.UserIdentityForSelfSupportForWorker, | |||
EnterpriseId: req.EnterpriseId, | |||
Memo: "", | |||
State: enum2.UserIdentityStateForNormal, | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
@@ -101,6 +103,7 @@ func SelfSupportForSchoolUserUpdate(req md.SelfSupportForSchoolUserUpdateReq) (e | |||
Identity: enum2.UserIdentityForSelfSupportForStudent, | |||
EnterpriseId: req.EnterpriseId, | |||
Memo: "", | |||
State: enum2.UserIdentityStateForNormal, | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
@@ -531,3 +534,104 @@ func SelfSupportForSchoolClassList(req md.SelfSupportForSchoolClassListReq) (m [ | |||
} | |||
return | |||
} | |||
func SelfSupportForSchoolOrdList(req md.SelfSupportForSchoolOrdListReq) (resp []md.SelfSupportForSchoolOrdListResp, count int64, err error) { | |||
var classWithUserIdentityIdsOne []int | |||
var classWithUserIdentityIdsTwo []int | |||
classWithUserDb := db.ClassWithUserDb{} | |||
classWithUserDb.Set() | |||
if req.ClassId != 0 { | |||
classWithUsers, err2 := classWithUserDb.FindUserIdentity(req.ClassId) | |||
if err2 != nil { | |||
return nil, 0, err2 | |||
} | |||
for _, v := range *classWithUsers { | |||
classWithUserIdentityIdsOne = append(classWithUserIdentityIdsOne, v.UserIdentityId) | |||
} | |||
} | |||
if req.GradeId != 0 { | |||
classDb := db.ClassDb{} | |||
classDb.Set(req.GradeId) | |||
classes, err3 := classDb.FindClass() | |||
if err3 != nil { | |||
return nil, 0, err3 | |||
} | |||
var classesId []int | |||
for _, v := range *classes { | |||
classesId = append(classesId, v.Id) | |||
} | |||
classWithUsers, err4 := classWithUserDb.FindUserIdentity(classesId) | |||
if err4 != nil { | |||
return nil, 0, err4 | |||
} | |||
for _, v := range *classWithUsers { | |||
classWithUserIdentityIdsTwo = append(classWithUserIdentityIdsTwo, v.UserIdentityId) | |||
} | |||
} | |||
sess := db.Db.Desc("self_support_for_school_ord.id") | |||
if req.EnterpriseId != 0 { | |||
sess.And("self_support_for_school_ord.enterprise_id =?", req.EnterpriseId) | |||
} | |||
if req.StartDate != "" { | |||
sess.And("self_support_for_school_ord.face_time >= ?", req.StartDate) | |||
} | |||
if req.EndDate != "" { | |||
sess.And("self_support_for_school_ord.face_time <= ?", req.EndDate) | |||
} | |||
if req.OrderStatus != 0 { | |||
sess.And("self_support_for_school_ord.order_status = ", req.OrderStatus) | |||
} | |||
if req.OutTradeNo != "" { | |||
sess.And("self_support_for_school_ord.out_order_no like ?", "%"+req.OutTradeNo+"%") | |||
} | |||
if req.Name != "" { | |||
sess.And("user_identity.name like ?", "%"+req.Name+"%") | |||
} | |||
if req.Phone != "" { | |||
sess.And("user.phone like ?", "%"+req.Phone+"%") | |||
} | |||
if len(classWithUserIdentityIdsOne) > 0 { | |||
sess.In("user_identity.id", classWithUserIdentityIdsOne) | |||
} | |||
if len(classWithUserIdentityIdsTwo) > 0 { | |||
sess.In("user_identity.id", classWithUserIdentityIdsTwo) | |||
} | |||
var m []*db.SelfSupportForSchoolOrdWithUserIdentity | |||
count, err = sess. | |||
Join("LEFT", "user_identity", "self_support_for_school_ord.user_identity_id = user_identity.id"). | |||
Join("LEFT", "enterprise", "enterprise.id = user_identity.enterprise_id"). | |||
Join("LEFT", "user", "user.id = user_identity.uid"). | |||
Join("LEFT", "class_with_user", "class_with_user.user_identity_id = user_identity.id"). | |||
Join("LEFT", "class", "class_with_user.class_id = class.id"). | |||
Join("LEFT", "grade", "class.grade_id = grade.id"). | |||
Limit(req.Limit, (req.Page-1)*req.Limit).Desc("self_support_for_school_ord.face_time").FindAndCount(&m) | |||
if err != nil { | |||
return nil, 0, err | |||
} | |||
for _, v := range m { | |||
resp = append(resp, md.SelfSupportForSchoolOrdListResp{ | |||
EnterpriseId: v.UserIdentity.EnterpriseId, | |||
EnterpriseName: v.Enterprise.Name, | |||
Uid: v.UserIdentity.Uid, | |||
UserIdentityId: v.UserIdentity.Id, | |||
UserIdentityName: v.SelfSupportForSchoolOrd.Consumer, | |||
TotalPrice: v.SelfSupportForSchoolOrd.TradeAmount, | |||
OutTradeNo: v.SelfSupportForSchoolOrd.OutOrderNo, | |||
TradeNo: v.SelfSupportForSchoolOrd.TradeNo, | |||
OrderStatus: v.SelfSupportForSchoolOrd.OrderStatus, | |||
FaceTime: v.SelfSupportForSchoolOrd.FaceTime, | |||
Phone: v.User.Phone, | |||
Name: v.UserIdentity.Name, | |||
Grade: v.Grade.Name, | |||
GradeId: v.Grade.Id, | |||
Class: v.Class.Name, | |||
ClassId: v.Class.Id, | |||
DeviceSn: v.SelfSupportForSchoolOrd.DeviceSn, | |||
}) | |||
} | |||
return | |||
} |
@@ -9,6 +9,7 @@ import ( | |||
"applet/app/enum" | |||
"applet/app/utils" | |||
"errors" | |||
"time" | |||
) | |||
func CentralKitchenForSchoolOrderRefundList(req md.CentralKitchenForSchoolOrderRefundListReq) (resp []md.CentralKitchenForSchoolOrderRefundListResp, total int64, err error) { | |||
@@ -169,6 +170,7 @@ func CentralKitchenForSchoolOrderRefundAudit(req md.CentralKitchenForSchoolOrder | |||
err = errors.New("更新退款订单记录状态失败") | |||
return | |||
} | |||
updateAck1, err4 := centralKitchenForSchoolUserWithDayDb.CentralKitchenForSchoolUserWithDayUpdate(userWithDay.Id, userWithDay, "state") | |||
if err4 != nil { | |||
_ = session.Rollback() | |||
@@ -209,6 +211,18 @@ func CentralKitchenForSchoolOrderRefundAudit(req md.CentralKitchenForSchoolOrder | |||
_ = session.Rollback() | |||
return err6 | |||
} | |||
returnDay.State = enum.CentralKitchenForSchoolUserRefundDayStateForAuditComplete | |||
returnDay.RefundDate = time.Now().Format("2006-01-02 15:04:05") | |||
updateAck2, err7 := centralKitchenForSchoolUserWithDayDb.CentralKitchenForSchoolUserWithDayUpdate(userWithDay.Id, userWithDay, "state") | |||
if err7 != nil { | |||
_ = session.Rollback() | |||
return err7 | |||
} | |||
if updateAck2 <= 0 { | |||
_ = session.Rollback() | |||
err = errors.New("更新退款订单记录时间失败") | |||
return | |||
} | |||
} | |||
} | |||
@@ -16,7 +16,7 @@ func AddCentralKitchenForSchoolPackage(req md.SaveCentralKitchenForSchoolPackage | |||
//TODO::判断当前月份是否存在 | |||
centralKitchenForSchoolPackageDb := db.CentralKitchenForSchoolPackageDb{} | |||
centralKitchenForSchoolPackageDb.Set() | |||
isHasPackage, err := centralKitchenForSchoolPackageDb.GetCentralKitchenForSchoolPackageByMonth(req.Year, req.Month) | |||
isHasPackage, err := centralKitchenForSchoolPackageDb.GetCentralKitchenForSchoolPackageByMonth(req.EnterpriseId, req.Year, req.Month) | |||
if err != nil { | |||
return err | |||
} | |||
@@ -0,0 +1,258 @@ | |||
package svc | |||
import ( | |||
"applet/app/admin/md" | |||
"applet/app/db" | |||
"applet/app/db/model" | |||
"encoding/json" | |||
"errors" | |||
"time" | |||
) | |||
func AddCentralKitchenForSchoolPackageForSystem(req md.SaveCentralKitchenForSchoolPackageForSystemReq) (err error) { | |||
session := db.Db.NewSession() | |||
defer session.Close() | |||
session.Begin() | |||
now := time.Now() | |||
//TODO::判断当前月份是否存在 | |||
centralKitchenForSchoolPackageForSystemDb := db.CentralKitchenForSchoolPackageForSystemDb{} | |||
centralKitchenForSchoolPackageForSystemDb.Set() | |||
isHasPackage, err := centralKitchenForSchoolPackageForSystemDb.GetCentralKitchenForSchoolPackageForSystemByMonth(req.Year, req.Month) | |||
if err != nil { | |||
return err | |||
} | |||
if isHasPackage != nil { | |||
return errors.New("请勿重复添加【" + req.Month + "】套餐") | |||
} | |||
//新增`central_kitchen_for_school_package` | |||
var centralKitchenForSchoolPackageForSystemWithDays []*md.CentralKitchenForSchoolPackageForSystemWithDay | |||
for _, v := range req.DateList { | |||
centralKitchenForSchoolPackageForSystemWithDays = append(centralKitchenForSchoolPackageForSystemWithDays, &md.CentralKitchenForSchoolPackageForSystemWithDay{ | |||
Date: v.Date, | |||
IsOpenBreakfast: v.IsOpenBreakfast, | |||
IsOpenLunch: v.IsOpenLunch, | |||
IsOpenDinner: v.IsOpenDinner, | |||
IsOpenReplenish: v.IsOpenReplenish, | |||
}) | |||
} | |||
centralKitchenForSchoolPackageForSystemWithDaysStr, _ := json.Marshal(centralKitchenForSchoolPackageForSystemWithDays) | |||
_, err = centralKitchenForSchoolPackageForSystemDb.CentralKitchenForSchoolPackageForSystemInsertBySession(session, &model.CentralKitchenForSchoolPackageForSystem{ | |||
Id: 0, | |||
Year: req.Year, | |||
Month: req.Month, | |||
TotalPrice: "0", | |||
StartDate: req.StartDate, | |||
EndDate: req.EndDate, | |||
WithDate: string(centralKitchenForSchoolPackageForSystemWithDaysStr), | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
if err != nil { | |||
_ = session.Rollback() | |||
return err | |||
} | |||
return session.Commit() | |||
} | |||
func SyncCentralKitchenForSchoolPackageForSystem(req md.SyncCentralKitchenForSchoolPackageForSystemReq) (err error) { | |||
centralKitchenForSchoolWithSpecForSystemDb := db.CentralKitchenForSchoolWithSpecForSystem{} | |||
centralKitchenForSchoolWithSpecForSystemDb.Set() | |||
centralKitchenForSchoolWithSpecForSystem, err := centralKitchenForSchoolWithSpecForSystemDb.GetCentralKitchenForSchoolWithSpecForSystem() | |||
if err != nil { | |||
return err | |||
} | |||
if centralKitchenForSchoolWithSpecForSystem == nil && req.IsCarryPackagePrice { | |||
return errors.New("未设置套餐价格") | |||
} | |||
session := db.Db.NewSession() | |||
defer session.Close() | |||
session.Begin() | |||
now := time.Now() | |||
centralKitchenForSchoolPackageDb := db.CentralKitchenForSchoolPackageDb{} | |||
centralKitchenForSchoolPackageDb.Set() | |||
for _, id := range req.Ids { | |||
centralKitchenForSchoolPackageForSystemDb := db.CentralKitchenForSchoolPackageForSystemDb{} | |||
centralKitchenForSchoolPackageForSystemDb.Set() | |||
centralKitchenForSchoolPackageForSystem, err1 := centralKitchenForSchoolPackageForSystemDb.GetCentralKitchenForSchoolPackageForSystem(id) | |||
if err1 != nil { | |||
return err1 | |||
} | |||
if centralKitchenForSchoolPackageForSystem == nil { | |||
return errors.New("套餐记录不存在") | |||
} | |||
var withDate []*md.CentralKitchenForSchoolPackageForSystemWithDay | |||
err2 := json.Unmarshal([]byte(centralKitchenForSchoolPackageForSystem.WithDate), &withDate) | |||
if err2 != nil { | |||
_ = session.Rollback() | |||
return err2 | |||
} | |||
for _, v := range req.EnterpriseIds { | |||
//1、查询对应校企 | |||
enterpriseDb := db.EnterpriseDb{} | |||
enterpriseDb.Set() | |||
enterprise, err3 := enterpriseDb.GetEnterprise(v) | |||
if err3 != nil { | |||
_ = session.Rollback() | |||
return err3 | |||
} | |||
//TODO::判断当前月份是否存在 | |||
isHasPackage, err4 := centralKitchenForSchoolPackageDb.GetCentralKitchenForSchoolPackageByMonth(v, centralKitchenForSchoolPackageForSystem.Year, centralKitchenForSchoolPackageForSystem.Month) | |||
if err4 != nil { | |||
return err4 | |||
} | |||
if isHasPackage != nil { | |||
_ = session.Rollback() | |||
return errors.New("请勿重复添加【" + enterprise.Name + "单位下】,【" + centralKitchenForSchoolPackageForSystem.Year + "-" + centralKitchenForSchoolPackageForSystem.Month + "】的套餐") | |||
} | |||
//2、查询`central_kitchen_for_school_with_spec` | |||
centralKitchenForSchoolWithSpec := db.CentralKitchenForSchoolWithSpec{} | |||
centralKitchenForSchoolWithSpec.Set(v) | |||
spec, err5 := centralKitchenForSchoolWithSpec.GetCentralKitchenForSchoolWithSpec() | |||
if err5 != nil { | |||
_ = session.Rollback() | |||
return err5 | |||
} | |||
//3、新增`central_kitchen_for_school_package` | |||
packageId, err6 := centralKitchenForSchoolPackageDb.CentralKitchenForSchoolPackageInsertBySession(session, &model.CentralKitchenForSchoolPackage{ | |||
EnterpriseId: v, | |||
Year: centralKitchenForSchoolPackageForSystem.Year, | |||
Month: centralKitchenForSchoolPackageForSystem.Month, | |||
TotalPrice: "0", | |||
StartDate: centralKitchenForSchoolPackageForSystem.StartDate, | |||
EndDate: centralKitchenForSchoolPackageForSystem.EndDate, | |||
State: 1, | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
if err6 != nil { | |||
_ = session.Rollback() | |||
return err6 | |||
} | |||
//4、批量新增 `central_kitchen_for_school_package_with_day` | |||
var centralKitchenForSchoolPackageWithDays []*model.CentralKitchenForSchoolPackageWithDay | |||
for _, v := range withDate { | |||
var isOpenBreakfast, isOpenLunch, isOpenDinner, isOpenReplenish = md.CloseBreakfast, md.CloseLunch, md.CloseDinner, md.CloseReplenish | |||
if spec.IsOpenBreakfast == md.OpenBreakfast && v.IsOpenBreakfast == md.OpenBreakfast { | |||
isOpenBreakfast = md.OpenBreakfast | |||
} | |||
if spec.IsOpenLunch == md.OpenLunch && v.IsOpenLunch == md.OpenLunch { | |||
isOpenLunch = md.OpenLunch | |||
} | |||
if spec.IsOpenDinner == md.OpenDinner && v.IsOpenDinner == md.OpenDinner { | |||
isOpenDinner = md.OpenDinner | |||
} | |||
if v.IsOpenReplenish == md.OpenReplenish { | |||
isOpenReplenish = md.OpenReplenish | |||
} | |||
centralKitchenForSchoolPackageWithDays = append(centralKitchenForSchoolPackageWithDays, &model.CentralKitchenForSchoolPackageWithDay{ | |||
Date: v.Date, | |||
PackageId: packageId, | |||
IsOpenBreakfast: isOpenBreakfast, | |||
IsOpenLunch: isOpenLunch, | |||
IsOpenDinner: isOpenDinner, | |||
IsOpenReplenish: isOpenReplenish, | |||
}) | |||
} | |||
centralKitchenForSchoolPackageWithDayDb := db.CentralKitchenForSchoolPackageWithDayDb{} | |||
centralKitchenForSchoolPackageWithDayDb.Set(packageId) | |||
_, err7 := centralKitchenForSchoolPackageWithDayDb.BatchAddCentralKitchenForSchoolPackageWithDaysBySession(session, centralKitchenForSchoolPackageWithDays) | |||
if err7 != nil { | |||
_ = session.Rollback() | |||
return err7 | |||
} | |||
// 8、判断是否 "是否跟随套餐价格" | |||
if req.IsCarryPackagePrice { | |||
spec.BreakfastUnitPrice = centralKitchenForSchoolWithSpecForSystem.BreakfastUnitPrice | |||
spec.LunchUnitPrice = centralKitchenForSchoolWithSpecForSystem.LunchUnitPrice | |||
spec.DinnerUnitPrice = centralKitchenForSchoolWithSpecForSystem.DinnerUnitPrice | |||
spec.BreakfastUnitPriceForTeacher = centralKitchenForSchoolWithSpecForSystem.BreakfastUnitPriceForTeacher | |||
spec.LunchUnitPriceForTeacher = centralKitchenForSchoolWithSpecForSystem.LunchUnitPriceForTeacher | |||
spec.DinnerUnitPriceForTeacher = centralKitchenForSchoolWithSpecForSystem.DinnerUnitPriceForTeacher | |||
_, err8 := centralKitchenForSchoolWithSpec.CentralKitchenForSchoolWithSpecUpdate(spec.Id, spec, "breakfast_unit_price", "lunch_unit_price", "dinner_unit_price", "breakfast_unit_price_for_teacher", "lunch_unit_price_for_teacher", "dinner_unit_price_for_teacher") | |||
if err8 != nil { | |||
_ = session.Rollback() | |||
return err8 | |||
} | |||
} | |||
} | |||
} | |||
return session.Commit() | |||
} | |||
func UpdateCentralKitchenForSchoolPackageForSystem(req md.SaveCentralKitchenForSchoolPackageForSystemReq) (err error) { | |||
session := db.Db.NewSession() | |||
defer session.Close() | |||
session.Begin() | |||
now := time.Now() | |||
//修改`central_kitchen_for_school_package` | |||
centralKitchenForSchoolPackageForSystemDb := db.CentralKitchenForSchoolPackageForSystemDb{} | |||
centralKitchenForSchoolPackageForSystemDb.Set() | |||
centralKitchenForSchoolPackageForSystem, err := centralKitchenForSchoolPackageForSystemDb.GetCentralKitchenForSchoolPackageForSystem(req.Id) | |||
if err != nil { | |||
_ = session.Rollback() | |||
return err | |||
} | |||
if centralKitchenForSchoolPackageForSystem == nil { | |||
_ = session.Rollback() | |||
return errors.New("未查询到对应套餐记录") | |||
} | |||
var centralKitchenForSchoolPackageForSystemWithDays []*md.CentralKitchenForSchoolPackageForSystemWithDay | |||
for _, v := range req.DateList { | |||
centralKitchenForSchoolPackageForSystemWithDays = append(centralKitchenForSchoolPackageForSystemWithDays, &md.CentralKitchenForSchoolPackageForSystemWithDay{ | |||
Date: v.Date, | |||
IsOpenBreakfast: v.IsOpenBreakfast, | |||
IsOpenLunch: v.IsOpenLunch, | |||
IsOpenDinner: v.IsOpenDinner, | |||
IsOpenReplenish: v.IsOpenReplenish, | |||
}) | |||
} | |||
centralKitchenForSchoolPackageForSystemWithDaysStr, _ := json.Marshal(centralKitchenForSchoolPackageForSystemWithDays) | |||
centralKitchenForSchoolPackageForSystem.Year = req.Year | |||
centralKitchenForSchoolPackageForSystem.Month = req.Month | |||
centralKitchenForSchoolPackageForSystem.StartDate = req.StartDate | |||
centralKitchenForSchoolPackageForSystem.EndDate = req.EndDate | |||
centralKitchenForSchoolPackageForSystem.WithDate = string(centralKitchenForSchoolPackageForSystemWithDaysStr) | |||
centralKitchenForSchoolPackageForSystem.UpdateAt = now.Format("2006-01-02 15:04:05") | |||
affected, err := centralKitchenForSchoolPackageForSystemDb.CentralKitchenForSchoolPackageForSystemUpdateBySession(session, centralKitchenForSchoolPackageForSystem.Id, centralKitchenForSchoolPackageForSystem) | |||
if err != nil { | |||
_ = session.Rollback() | |||
return | |||
} | |||
if affected == 0 { | |||
_ = session.Rollback() | |||
return errors.New("更新套餐记录失败") | |||
} | |||
return session.Commit() | |||
} | |||
func DeleteCentralKitchenForSchoolPackageForSystem(packageId int) (err error) { | |||
//1、删除`central_kitchen_for_school_package` | |||
centralKitchenForSchoolPackageForSystemDb := db.CentralKitchenForSchoolPackageForSystemDb{} | |||
centralKitchenForSchoolPackageForSystemDb.Set() | |||
centralKitchenForSchoolPackage, err := centralKitchenForSchoolPackageForSystemDb.GetCentralKitchenForSchoolPackageForSystem(packageId) | |||
if err != nil { | |||
return err | |||
} | |||
if centralKitchenForSchoolPackage == nil { | |||
return errors.New("未查询到对应套餐记录") | |||
} | |||
affected, err := centralKitchenForSchoolPackageForSystemDb.CentralKitchenForSchoolPackageForSystemDelete(packageId) | |||
if err != nil { | |||
return | |||
} | |||
if affected == 0 { | |||
return errors.New("删除套餐记录失败") | |||
} | |||
return | |||
} |
@@ -43,7 +43,7 @@ func SelfSupportForSchoolInfo(enterpriseId int) (err error, resp md.SelfSupportF | |||
resp.SchoolFacePassNum, _ = selfSupportForUserFaceInfoDb.CountSchoolFacePassStatus(enterpriseId, "open") | |||
resp.SchoolFacePaymentNum, _ = selfSupportForUserFaceInfoDb.CountSchoolFacePaymentStatus(enterpriseId, "open") | |||
resp.SingleSchoolFacePassNum, _ = selfSupportForUserFaceInfoDb.CountCollectFaceType(enterpriseId, 1) | |||
resp.ConcentrateSchoolFacePassNum, _ = selfSupportForUserFaceInfoDb.CountCollectFaceType(enterpriseId, 1) | |||
resp.ConcentrateSchoolFacePassNum, _ = selfSupportForUserFaceInfoDb.CountCollectFaceType(enterpriseId, 2) | |||
return | |||
} |
@@ -5,9 +5,11 @@ import ( | |||
"applet/app/customer/md" | |||
svc "applet/app/customer/svc/order" | |||
"applet/app/db" | |||
"applet/app/db/model" | |||
"applet/app/e" | |||
"applet/app/enum" | |||
"applet/app/utils" | |||
"encoding/json" | |||
"github.com/gin-gonic/gin" | |||
"time" | |||
) | |||
@@ -90,17 +92,16 @@ func CentralKitchenForSchoolOrderDetail(c *gin.Context) { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应订单记录") | |||
return | |||
} | |||
centralKitchenForSchoolUserWithDayDb := db.CentralKitchenForSchoolUserWithDayDb{} | |||
centralKitchenForSchoolUserWithDayDb.Set(0) | |||
list, err := centralKitchenForSchoolUserWithDayDb.FindCentralKitchenForSchoolUserWithDayByOrdNo(ord.OutTradeNo) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
var total, totalBreakfast, totalLunch, totalDinner int | |||
total = len(*list) | |||
for _, v := range *list { | |||
var list []*model.CentralKitchenForSchoolUserWithDay | |||
err1 := json.Unmarshal([]byte(ord.WithDayData), &list) | |||
if err1 != nil { | |||
e.OutErr(c, e.ERR, err1.Error()) | |||
return | |||
} | |||
total = len(list) | |||
for _, v := range list { | |||
if v.Kind == enum.CentralKitchenForSchoolUserWithDayKindForBreakfast { | |||
totalBreakfast++ | |||
} | |||
@@ -119,6 +120,7 @@ func CentralKitchenForSchoolOrderDetail(c *gin.Context) { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"enterprise": enterprise, | |||
"total": total, | |||
@@ -8,8 +8,10 @@ import ( | |||
"applet/app/db/model" | |||
"applet/app/e" | |||
"applet/app/enum" | |||
"applet/app/utils" | |||
"encoding/json" | |||
"github.com/gin-gonic/gin" | |||
"time" | |||
) | |||
func BuyPackage(c *gin.Context) { | |||
@@ -84,9 +86,32 @@ func OrdState(c *gin.Context) { | |||
e.OutErr(c, e.ERR, err4.Error()) | |||
return | |||
} | |||
var hasMonths = map[string]map[string]interface{}{} | |||
var hasKinds = map[string][]string{} | |||
for _, v := range data { | |||
date, _ := time.ParseInLocation("2006-01-02", v.Date, time.Local) | |||
if hasMonths[utils.TimeParseStd(v.Date).Month().String()] == nil { | |||
hasMonths[utils.TimeParseStd(v.Date).Month().String()] = make(map[string]interface{}) | |||
hasMonths[utils.TimeParseStd(v.Date).Month().String()]["meal_time_start"] = date.Format("2006-01-02") | |||
hasMonths[utils.TimeParseStd(v.Date).Month().String()]["meal_time_end"] = date.Format("2006-01-02") | |||
} else { | |||
startTime, _ := time.ParseInLocation("2006-01-02", utils.AnyToString(hasMonths[utils.TimeParseStd(v.Date).Month().String()]["meal_time_start"]), time.Local) | |||
if startTime.After(date) { | |||
hasMonths[utils.TimeParseStd(v.Date).Month().String()]["meal_time_start"] = date.Format("2006-01-02") | |||
} | |||
endTime, _ := time.ParseInLocation("2006-01-02", utils.AnyToString(hasMonths[utils.TimeParseStd(v.Date).Month().String()]["meal_time_end"]), time.Local) | |||
if endTime.Before(date) { | |||
hasMonths[utils.TimeParseStd(v.Date).Month().String()]["meal_time_end"] = date.Format("2006-01-02") | |||
} | |||
} | |||
hasMonths[utils.TimeParseStd(v.Date).Month().String()]["month"] = int(utils.TimeParseStd(v.Date).Month()) | |||
hasKinds[utils.TimeParseStd(v.Date).Month().String()] = append(hasKinds[utils.TimeParseStd(v.Date).Month().String()], utils.IntToStr(v.Kind)) | |||
v.OrdNo = outTradeNo | |||
} | |||
centralKitchenForSchoolUserWithDayDb := db.CentralKitchenForSchoolUserWithDayDb{} | |||
centralKitchenForSchoolUserWithDayDb.Set(0) | |||
_, err5 := centralKitchenForSchoolUserWithDayDb.BatchAddCentralKitchenForSchoolUserWithDays(data) | |||
@@ -94,8 +119,36 @@ func OrdState(c *gin.Context) { | |||
e.OutErr(c, e.ERR, err5.Error()) | |||
return | |||
} | |||
} | |||
//TODO::插入数据至 `central_kitchen_for_school_package_ord_for_reserve` | |||
centralKitchenForSchoolPackageOrdForReserve := db.CentralKitchenForSchoolPackageOrdForReserve{} | |||
centralKitchenForSchoolPackageOrdForReserve.Set(outTradeNo) | |||
var isHasKind []string | |||
for k, v := range hasMonths { | |||
for _, v1 := range hasKinds[k] { | |||
if !utils.InArr(v1, isHasKind) { | |||
_, err3 := centralKitchenForSchoolPackageOrdForReserve.CentralKitchenForSchoolPackageOrdForReserveInsert(&model.CentralKitchenForSchoolPackageOrdForReserve{ | |||
EnterpriseId: ord.EnterpriseId, | |||
Uid: ord.Uid, | |||
UserIdentityName: ord.UserIdentityName, | |||
UserIdentityId: ord.UserIdentityId, | |||
Kind: utils.StrToInt(v1), | |||
OutTradeNo: ord.OutTradeNo, | |||
ReserveMonth: utils.AnyToString(v["month"]), | |||
MealTimeStart: utils.AnyToString(v["meal_time_start"]), | |||
MealTimeEnd: utils.AnyToString(v["meal_time_end"]), | |||
CreateAt: time.Now().Format("2006-01-02 15:04:05"), | |||
UpdateAt: time.Now().Format("2006-01-02 15:04:05"), | |||
}) | |||
if err3 != nil { | |||
e.OutErr(c, e.ERR, err3.Error()) | |||
return | |||
} | |||
isHasKind = append(isHasKind, v1) | |||
} | |||
} | |||
} | |||
} | |||
_, err3 := centralKitchenForSchoolPackageOrd.CentralKitchenForSchoolPackageOrdUpdate(ord, "state", "ord_state") | |||
if err3 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err3.Error()) | |||
@@ -0,0 +1,49 @@ | |||
package hdl | |||
import ( | |||
"applet/app/admin/lib/validate" | |||
"applet/app/customer/md" | |||
svc "applet/app/customer/svc/order" | |||
"applet/app/e" | |||
"applet/app/enum" | |||
"github.com/gin-gonic/gin" | |||
) | |||
func SelfSupportForSchoolOrderList(c *gin.Context) { | |||
var req md.SelfSupportForSchoolOrderListReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
list, total, err := svc.SupportOrderList(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
tradeAmountTotal, err := svc.SupportOrderStatistic(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": list, | |||
"total": total, | |||
"trade_amount_total": tradeAmountTotal, | |||
"ord_status_list": []map[string]interface{}{ | |||
{ | |||
"name": enum.SelfSupportForSchoolOrdOrderStatus.String(enum.SelfSupportForSchoolOrdOrderStatusForWait), | |||
"value": enum.SelfSupportForSchoolOrdOrderStatusForWait, | |||
}, | |||
{ | |||
"name": enum.SelfSupportForSchoolOrdOrderStatus.String(enum.SelfSupportForSchoolOrdOrderStatusForSuccess), | |||
"value": enum.SelfSupportForSchoolOrdOrderStatusForSuccess, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
} |
@@ -2,10 +2,13 @@ package hdl | |||
import ( | |||
"applet/app/customer/svc" | |||
svc2 "applet/app/customer/svc/order" | |||
"applet/app/db" | |||
"applet/app/e" | |||
"applet/app/enum" | |||
"applet/app/utils" | |||
"github.com/gin-gonic/gin" | |||
"time" | |||
) | |||
func UserInfo(c *gin.Context) { | |||
@@ -42,6 +45,35 @@ func UserInfo(c *gin.Context) { | |||
tmp["class"] = data.Class | |||
} | |||
} | |||
now := time.Now() | |||
if v.UserIdentity.Identity == enum.UserIdentityForSelfSupportForStudent || v.UserIdentity.Identity == enum.UserIdentityForSelfSupportForTeacher { | |||
//TODO:: 自营-学生 or 自营-教职员工 | |||
sMDate := utils.GetFirstDateOfMonth(now).Format("2006-01-02 15:04:05") | |||
eMDate := utils.GetLastDateOfMonth(now).Format("2006-01-02 15:04:05") | |||
sTDate, eTDate := utils.GetDateTimeRangeStr("today") | |||
monthStatistic, err2 := svc2.SupportUserIdentityOrderStatistic(v.UserIdentity.Id, sMDate, eMDate) | |||
if err2 != nil { | |||
e.OutErr(c, e.ERR, err2.Error()) | |||
return | |||
} | |||
dayStatistic, err2 := svc2.SupportUserIdentityOrderStatistic(v.UserIdentity.Id, sTDate, eTDate) | |||
if err2 != nil { | |||
e.OutErr(c, e.ERR, err2.Error()) | |||
return | |||
} | |||
tmp["month_statistic"] = monthStatistic | |||
tmp["day_statistic"] = dayStatistic | |||
} | |||
if v.UserIdentity.Identity == enum.UserIdentityForSelfSupportForWorker { | |||
selfSupportForUserFaceInfoDb := db.SelfSupportForUserFaceInfoDb{} | |||
selfSupportForUserFaceInfoDb.Set(0) | |||
tmp["school_face_pass_num"], _ = selfSupportForUserFaceInfoDb.CountSchoolFacePassStatus(v.EnterpriseId, "open") | |||
tmp["school_face_payment_num"], _ = selfSupportForUserFaceInfoDb.CountSchoolFacePaymentStatus(v.EnterpriseId, "open") | |||
tmp["concentrate_school_face_pass_num"], _ = selfSupportForUserFaceInfoDb.CountCollectFaceType(v.EnterpriseId, 2) | |||
tmp["single_school_face_pass_num"], _ = selfSupportForUserFaceInfoDb.CountCollectFaceType(v.EnterpriseId, 1) | |||
} | |||
identityList = append(identityList, tmp) | |||
} | |||
@@ -78,10 +78,6 @@ func SaveCentralKitchenForSchoolUserIdentity(c *gin.Context) { | |||
} | |||
} | |||
} else { | |||
if isHasUserIdentity.Uid != user.Id { | |||
e.OutErr(c, e.ERR, "当前身份信息已被绑定使用") | |||
return | |||
} | |||
//4、修改身份信息 | |||
isHasUserIdentity.Uid = user.Id | |||
isHasUserIdentity.Name = req.Name | |||
@@ -45,3 +45,12 @@ type CentralKitchenForSchoolMyReserveRespList struct { | |||
LunchTotal int `json:"lunch_total" label:"午餐-总计"` | |||
DinnerTotal int `json:"dinner_total" label:"晚餐-总计"` | |||
} | |||
type SelfSupportForSchoolOrderListReq struct { | |||
UserIdentityId int `json:"user_identity_id" label:"用户身份id"` | |||
Limit int `json:"limit"` | |||
Page int `json:"page" ` | |||
OrderStatus int `json:"order_status" ` | |||
StartDate string `json:"start_date" ` | |||
EndDate string `json:"end_date" ` | |||
} |
@@ -4,7 +4,7 @@ type SaveCentralKitchenForSchoolUserIdentityReq struct { | |||
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` | |||
IsTeacher bool `json:"is_teacher" label:"是否教师"` | |||
Name string `json:"name" binding:"required" label:"姓名"` | |||
IdNo string `json:"id_no" binding:"required" label:"身份证号码"` | |||
IdNo string `json:"id_no" label:"身份证号码"` | |||
GradeId int `json:"grade_id" label:"年级id"` | |||
ClassId int `json:"class_id" label:"班级id"` | |||
} | |||
@@ -0,0 +1,61 @@ | |||
package svc | |||
import ( | |||
"applet/app/customer/md" | |||
"applet/app/db" | |||
"applet/app/db/model" | |||
"applet/app/utils" | |||
"fmt" | |||
) | |||
func SupportOrderList(req md.SelfSupportForSchoolOrderListReq) (m []model.SelfSupportForSchoolOrd, total int64, err error) { | |||
sess := db.Db.Desc("id").Where("user_identity_id =?", req.UserIdentityId).Limit(req.Limit, (req.Page-1)*req.Limit) | |||
if req.OrderStatus != 0 { | |||
sess.And("order_status = ?", req.OrderStatus) | |||
} | |||
if req.StartDate != "" { | |||
sess.And("create_at >= ?", req.StartDate) | |||
} | |||
if req.EndDate != "" { | |||
sess.And("create_at <= ?", req.EndDate) | |||
} | |||
total, err = sess.FindAndCount(&m) | |||
if err != nil { | |||
return | |||
} | |||
return | |||
} | |||
func SupportOrderStatistic(req md.SelfSupportForSchoolOrderListReq) (total float64, err error) { | |||
var sql = fmt.Sprintf("SELECT SUM(trade_amount) AS trade_amount_total FROM self_support_for_school_ord where user_identity_id = '%d'", req.UserIdentityId) | |||
if req.OrderStatus != 0 { | |||
sql += fmt.Sprintf(" and order_status = %d", req.OrderStatus) | |||
} | |||
if req.StartDate != "" { | |||
sql += fmt.Sprintf(" and create_at = %s", req.StartDate) | |||
} | |||
if req.EndDate != "" { | |||
sql += fmt.Sprintf(" and create_at <= %s", req.StartDate) | |||
} | |||
mapArr1, err := db.QueryNativeString(db.Db, sql) | |||
if err != nil { | |||
return | |||
} | |||
if mapArr1 != nil { | |||
total = utils.StrToFloat64(mapArr1[0]["trade_amount_total"]) | |||
} | |||
return | |||
} | |||
func SupportUserIdentityOrderStatistic(userIdentityId int, sDate, eDate string) (total float64, err error) { | |||
var sql = fmt.Sprintf("SELECT SUM(trade_amount) AS trade_amount_total FROM self_support_for_school_ord where user_identity_id = '%d' and face_time >= '%s' and face_time <= '%s'", | |||
userIdentityId, sDate, eDate) | |||
mapArr1, err := db.QueryNativeString(db.Db, sql) | |||
if err != nil { | |||
return | |||
} | |||
if mapArr1 != nil { | |||
total = utils.StrToFloat64(mapArr1[0]["trade_amount_total"]) | |||
} | |||
return | |||
} |
@@ -311,6 +311,7 @@ func CalcByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (totalP | |||
} else { | |||
amount = centralKitchenForSchoolWithSpecData.DinnerUnitPrice | |||
} | |||
totalPrice += utils.StrToFloat64(amount) | |||
data = append(data, &model.CentralKitchenForSchoolUserWithDay{ | |||
Uid: uid, | |||
IdentityId: buyPackageReq.UserIdentityId, | |||
@@ -28,9 +28,9 @@ func (centralKitchenForSchoolPackageDb *CentralKitchenForSchoolPackageDb) GetCen | |||
return m, nil | |||
} | |||
func (centralKitchenForSchoolPackageDb *CentralKitchenForSchoolPackageDb) GetCentralKitchenForSchoolPackageByMonth(year, month string) (m *model.CentralKitchenForSchoolPackage, err error) { | |||
func (centralKitchenForSchoolPackageDb *CentralKitchenForSchoolPackageDb) GetCentralKitchenForSchoolPackageByMonth(enterpriseId int, year, month string) (m *model.CentralKitchenForSchoolPackage, err error) { | |||
m = new(model.CentralKitchenForSchoolPackage) | |||
has, err := centralKitchenForSchoolPackageDb.Db.Where("year =? and month =? and is_delete = 0", year, month).Get(m) | |||
has, err := centralKitchenForSchoolPackageDb.Db.Where("enterprise_id =?", enterpriseId).And("year =? and month =? and is_delete = 0", year, month).Get(m) | |||
if err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
@@ -0,0 +1,104 @@ | |||
package db | |||
import ( | |||
"applet/app/admin/md" | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"reflect" | |||
"xorm.io/xorm" | |||
) | |||
type CentralKitchenForSchoolPackageForSystemDb struct { | |||
Db *xorm.Engine `json:"db"` | |||
} | |||
func (centralKitchenForSchoolPackageForSystemDb *CentralKitchenForSchoolPackageForSystemDb) Set() { // set方法 | |||
centralKitchenForSchoolPackageForSystemDb.Db = Db | |||
} | |||
func (centralKitchenForSchoolPackageForSystemDb *CentralKitchenForSchoolPackageForSystemDb) GetCentralKitchenForSchoolPackageForSystem(id int) (m *model.CentralKitchenForSchoolPackageForSystem, err error) { | |||
m = new(model.CentralKitchenForSchoolPackageForSystem) | |||
has, err := centralKitchenForSchoolPackageForSystemDb.Db.Where("id =?", id).Get(m) | |||
if err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func (centralKitchenForSchoolPackageForSystemDb *CentralKitchenForSchoolPackageForSystemDb) GetCentralKitchenForSchoolPackageForSystemByMonth(year, month string) (m *model.CentralKitchenForSchoolPackageForSystem, err error) { | |||
m = new(model.CentralKitchenForSchoolPackageForSystem) | |||
has, err := centralKitchenForSchoolPackageForSystemDb.Db.Where("year =? and month =? and is_delete = 0", year, month).Get(m) | |||
if err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func (centralKitchenForSchoolPackageForSystemDb *CentralKitchenForSchoolPackageForSystemDb) FindCentralKitchenForSchoolPackageForSystem() (*[]model.CentralKitchenForSchoolPackageForSystem, error) { | |||
var m []model.CentralKitchenForSchoolPackageForSystem | |||
if err := centralKitchenForSchoolPackageForSystemDb.Db.Desc("id").Find(&m); err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
return &m, nil | |||
} | |||
func (centralKitchenForSchoolPackageForSystemDb *CentralKitchenForSchoolPackageForSystemDb) CentralKitchenForSchoolPackageForSystemInsert(m *model.CentralKitchenForSchoolPackageForSystem) (int, error) { | |||
_, err := centralKitchenForSchoolPackageForSystemDb.Db.InsertOne(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return m.Id, nil | |||
} | |||
func (centralKitchenForSchoolPackageForSystemDb *CentralKitchenForSchoolPackageForSystemDb) CentralKitchenForSchoolPackageForSystemInsertBySession(session *xorm.Session, m *model.CentralKitchenForSchoolPackageForSystem) (int, error) { | |||
_, err := session.InsertOne(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return m.Id, nil | |||
} | |||
func (centralKitchenForSchoolPackageForSystemDb *CentralKitchenForSchoolPackageForSystemDb) CentralKitchenForSchoolPackageForSystemDelete(id interface{}) (int64, error) { | |||
if reflect.TypeOf(id).Kind() == reflect.Slice { | |||
return Db.In("id", id).Delete(model.CentralKitchenForSchoolPackageForSystem{}) | |||
} else { | |||
return Db.Where("id = ?", id).Delete(model.CentralKitchenForSchoolPackageForSystem{}) | |||
} | |||
} | |||
func (centralKitchenForSchoolPackageForSystemDb *CentralKitchenForSchoolPackageForSystemDb) CentralKitchenForSchoolPackageForSystemUpdateBySession(session *xorm.Session, id interface{}, m *model.CentralKitchenForSchoolPackageForSystem, forceColums ...string) (int64, error) { | |||
var ( | |||
affected int64 | |||
err error | |||
) | |||
if forceColums != nil { | |||
affected, err = session.Where("id=?", id).Cols(forceColums...).Update(m) | |||
} else { | |||
affected, err = session.Where("id=?", id).Update(m) | |||
} | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
func (centralKitchenForSchoolPackageForSystemDb *CentralKitchenForSchoolPackageForSystemDb) CentralKitchenForSchoolPackageForSystemList(req md.ListCentralKitchenForSchoolPackageForSystemReq) (m []model.CentralKitchenForSchoolPackageForSystem, total int64, err error) { | |||
sess := centralKitchenForSchoolPackageForSystemDb.Db.Desc("id").Limit(req.Limit, (req.Page-1)*req.Limit) | |||
if req.Year != "" { | |||
sess.And("year = ?", req.Year) | |||
} | |||
if req.Month != "" { | |||
sess.And("month = ?", req.Month) | |||
} | |||
total, err = sess.FindAndCount(&m) | |||
if err != nil { | |||
return | |||
} | |||
return | |||
} |
@@ -97,6 +97,7 @@ type CentralKitchenForSchoolPackageOrdWithUserIdentity struct { | |||
model.CentralKitchenForSchoolPackageOrd `xorm:"extends"` | |||
model.UserIdentity `xorm:"extends"` | |||
model.Enterprise `xorm:"extends"` | |||
model.User `xorm:"extends"` | |||
model.ClassWithUser `xorm:"extends"` | |||
model.Class `xorm:"extends"` | |||
model.Grade `xorm:"extends"` | |||
@@ -0,0 +1,109 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"reflect" | |||
"xorm.io/xorm" | |||
) | |||
type CentralKitchenForSchoolPackageOrdForReserve struct { | |||
Db *xorm.Engine `json:"db"` | |||
OutTradeNo string `json:"out_trade_no"` | |||
} | |||
func (centralKitchenForSchoolPackageOrdForReserveDb *CentralKitchenForSchoolPackageOrdForReserve) Set(outTradeNo string) { // set方法 | |||
centralKitchenForSchoolPackageOrdForReserveDb.Db = Db | |||
centralKitchenForSchoolPackageOrdForReserveDb.OutTradeNo = outTradeNo | |||
} | |||
func (centralKitchenForSchoolPackageOrdForReserveDb *CentralKitchenForSchoolPackageOrdForReserve) GetCentralKitchenForSchoolPackageOrdForReserveById(id int) (m *model.CentralKitchenForSchoolPackageOrdForReserve, err error) { | |||
m = new(model.CentralKitchenForSchoolPackageOrdForReserve) | |||
has, err := centralKitchenForSchoolPackageOrdForReserveDb.Db.Where("id =?", id).Get(m) | |||
if err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func (centralKitchenForSchoolPackageOrdForReserveDb *CentralKitchenForSchoolPackageOrdForReserve) GetCentralKitchenForSchoolPackageOrdForReserve() (m *model.CentralKitchenForSchoolPackageOrdForReserve, err error) { | |||
m = new(model.CentralKitchenForSchoolPackageOrdForReserve) | |||
has, err := centralKitchenForSchoolPackageOrdForReserveDb.Db.Where("out_trade_no =?", centralKitchenForSchoolPackageOrdForReserveDb.OutTradeNo).Get(m) | |||
if err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func (centralKitchenForSchoolPackageOrdForReserveDb *CentralKitchenForSchoolPackageOrdForReserve) CentralKitchenForSchoolPackageOrdForReserveInsert(m *model.CentralKitchenForSchoolPackageOrdForReserve) (int, error) { | |||
_, err := centralKitchenForSchoolPackageOrdForReserveDb.Db.InsertOne(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return m.Id, nil | |||
} | |||
func (centralKitchenForSchoolPackageOrdForReserveDb *CentralKitchenForSchoolPackageOrdForReserve) CentralKitchenForSchoolPackageOrdForReserveInsertBySession(session *xorm.Session, m *model.CentralKitchenForSchoolPackageOrdForReserve) (int, error) { | |||
_, err := session.InsertOne(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return m.Id, nil | |||
} | |||
func (centralKitchenForSchoolPackageOrdForReserveDb *CentralKitchenForSchoolPackageOrdForReserve) BatchAddCentralKitchenForSchoolPackageOrdForReserves(mm []*model.CentralKitchenForSchoolPackageOrdForReserve) (int64, error) { | |||
affected, err := centralKitchenForSchoolPackageOrdForReserveDb.Db.Insert(mm) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
func (centralKitchenForSchoolPackageOrdForReserveDb *CentralKitchenForSchoolPackageOrdForReserve) CentralKitchenForSchoolPackageOrdForReserveDeleteById(id interface{}) (int64, error) { | |||
if reflect.TypeOf(id).Kind() == reflect.Slice { | |||
return Db.In("id", id).Delete(model.CentralKitchenForSchoolPackageOrdForReserve{}) | |||
} else { | |||
return Db.Where("id = ?", id).Delete(model.CentralKitchenForSchoolPackageOrdForReserve{}) | |||
} | |||
} | |||
func (centralKitchenForSchoolPackageOrdForReserveDb *CentralKitchenForSchoolPackageOrdForReserve) CentralKitchenForSchoolPackageOrdForReserveDelete() (int64, error) { | |||
return Db.Where("out_trade_no = ?", centralKitchenForSchoolPackageOrdForReserveDb.OutTradeNo).Delete(model.CentralKitchenForSchoolPackageOrdForReserve{}) | |||
} | |||
func (centralKitchenForSchoolPackageOrdForReserveDb *CentralKitchenForSchoolPackageOrdForReserve) CentralKitchenForSchoolPackageOrdForReserveUpdate(m *model.CentralKitchenForSchoolPackageOrdForReserve, forceColums ...string) (int64, error) { | |||
var ( | |||
affected int64 | |||
err error | |||
) | |||
if forceColums != nil { | |||
affected, err = centralKitchenForSchoolPackageOrdForReserveDb.Db.Where("out_trade_no=?", centralKitchenForSchoolPackageOrdForReserveDb.OutTradeNo).Cols(forceColums...).Update(m) | |||
} else { | |||
affected, err = centralKitchenForSchoolPackageOrdForReserveDb.Db.Where("out_trade_no=?", centralKitchenForSchoolPackageOrdForReserveDb.OutTradeNo).Update(m) | |||
} | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
type CentralKitchenForSchoolPackageOrdForReserveWithUserIdentity struct { | |||
model.CentralKitchenForSchoolPackageOrdForReserve `xorm:"extends"` | |||
model.CentralKitchenForSchoolPackageOrd `xorm:"extends"` | |||
model.UserIdentity `xorm:"extends"` | |||
model.Enterprise `xorm:"extends"` | |||
model.User `xorm:"extends"` | |||
model.ClassWithUser `xorm:"extends"` | |||
model.Class `xorm:"extends"` | |||
model.Grade `xorm:"extends"` | |||
} | |||
func (CentralKitchenForSchoolPackageOrdForReserveWithUserIdentity) TableName() string { | |||
return "central_kitchen_for_school_package_ord_for_reserve" | |||
} |
@@ -0,0 +1,68 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"reflect" | |||
"xorm.io/xorm" | |||
) | |||
type CentralKitchenForSchoolWithSpecForSystem struct { | |||
Db *xorm.Engine `json:"db"` | |||
} | |||
func (centralKitchenForSchoolWithSpecForSystemDb *CentralKitchenForSchoolWithSpecForSystem) Set() { // set方法 | |||
centralKitchenForSchoolWithSpecForSystemDb.Db = Db | |||
} | |||
func (centralKitchenForSchoolWithSpecForSystemDb *CentralKitchenForSchoolWithSpecForSystem) GetCentralKitchenForSchoolWithSpecForSystem() (m *model.CentralKitchenForSchoolWithSpecForSystem, err error) { | |||
m = new(model.CentralKitchenForSchoolWithSpecForSystem) | |||
has, err := centralKitchenForSchoolWithSpecForSystemDb.Db.Where("id >=1").Get(m) | |||
if err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func (centralKitchenForSchoolWithSpecForSystemDb *CentralKitchenForSchoolWithSpecForSystem) CentralKitchenForSchoolWithSpecForSystemInsert(m *model.CentralKitchenForSchoolWithSpecForSystem) (int, error) { | |||
_, err := centralKitchenForSchoolWithSpecForSystemDb.Db.InsertOne(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return m.Id, nil | |||
} | |||
func (centralKitchenForSchoolWithSpecForSystemDb *CentralKitchenForSchoolWithSpecForSystem) BatchAddCentralKitchenForSchoolWithSpecForSystems(mm []*model.CentralKitchenForSchoolWithSpecForSystem) (int64, error) { | |||
affected, err := centralKitchenForSchoolWithSpecForSystemDb.Db.Insert(mm) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
func (centralKitchenForSchoolWithSpecForSystemDb *CentralKitchenForSchoolWithSpecForSystem) CentralKitchenForSchoolWithSpecForSystemDeleteById(id interface{}) (int64, error) { | |||
if reflect.TypeOf(id).Kind() == reflect.Slice { | |||
return Db.In("id", id).Delete(model.CentralKitchenForSchoolWithSpecForSystem{}) | |||
} else { | |||
return Db.Where("id = ?", id).Delete(model.CentralKitchenForSchoolWithSpecForSystem{}) | |||
} | |||
} | |||
func (centralKitchenForSchoolWithSpecForSystemDb *CentralKitchenForSchoolWithSpecForSystem) CentralKitchenForSchoolWithSpecForSystemUpdate(id interface{}, m *model.CentralKitchenForSchoolWithSpecForSystem, forceColums ...string) (int64, error) { | |||
var ( | |||
affected int64 | |||
err error | |||
) | |||
if forceColums != nil { | |||
affected, err = centralKitchenForSchoolWithSpecForSystemDb.Db.Where("id=?", id).Cols(forceColums...).Update(m) | |||
} else { | |||
affected, err = centralKitchenForSchoolWithSpecForSystemDb.Db.Where("id=?", id).Update(m) | |||
} | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} |
@@ -0,0 +1,108 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"reflect" | |||
"xorm.io/xorm" | |||
) | |||
type SelfSupportForSchoolOrd struct { | |||
Db *xorm.Engine `json:"db"` | |||
OutOrderNo string `json:"user_identity_id"` | |||
} | |||
func (selfSupportForSchoolOrdOrdDb *SelfSupportForSchoolOrd) Set(outOrderNo string) { // set方法 | |||
selfSupportForSchoolOrdOrdDb.Db = Db | |||
selfSupportForSchoolOrdOrdDb.OutOrderNo = outOrderNo | |||
} | |||
func (selfSupportForSchoolOrdOrdDb *SelfSupportForSchoolOrd) GetSelfSupportForSchoolOrdById(id int) (m *model.SelfSupportForSchoolOrd, err error) { | |||
m = new(model.SelfSupportForSchoolOrd) | |||
has, err := selfSupportForSchoolOrdOrdDb.Db.Where("id =?", id).Get(m) | |||
if err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func (selfSupportForSchoolOrdOrdDb *SelfSupportForSchoolOrd) GetSelfSupportForSchoolOrd() (m *model.SelfSupportForSchoolOrd, err error) { | |||
m = new(model.SelfSupportForSchoolOrd) | |||
has, err := selfSupportForSchoolOrdOrdDb.Db.Where("out_trade_no =?", selfSupportForSchoolOrdOrdDb.OutOrderNo).Get(m) | |||
if err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func (selfSupportForSchoolOrdOrdDb *SelfSupportForSchoolOrd) SelfSupportForSchoolOrdInsert(m *model.SelfSupportForSchoolOrd) (int, error) { | |||
_, err := selfSupportForSchoolOrdOrdDb.Db.InsertOne(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return m.Id, nil | |||
} | |||
func (selfSupportForSchoolOrdOrdDb *SelfSupportForSchoolOrd) SelfSupportForSchoolOrdInsertBySession(session *xorm.Session, m *model.SelfSupportForSchoolOrd) (int, error) { | |||
_, err := session.InsertOne(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return m.Id, nil | |||
} | |||
func (selfSupportForSchoolOrdOrdDb *SelfSupportForSchoolOrd) BatchAddSelfSupportForSchoolOrds(mm []*model.SelfSupportForSchoolOrd) (int64, error) { | |||
affected, err := selfSupportForSchoolOrdOrdDb.Db.Insert(mm) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
func (selfSupportForSchoolOrdOrdDb *SelfSupportForSchoolOrd) SelfSupportForSchoolOrdDeleteById(id interface{}) (int64, error) { | |||
if reflect.TypeOf(id).Kind() == reflect.Slice { | |||
return Db.In("id", id).Delete(model.SelfSupportForSchoolOrd{}) | |||
} else { | |||
return Db.Where("id = ?", id).Delete(model.SelfSupportForSchoolOrd{}) | |||
} | |||
} | |||
func (selfSupportForSchoolOrdOrdDb *SelfSupportForSchoolOrd) SelfSupportForSchoolOrdDelete() (int64, error) { | |||
return Db.Where("out_trade_no = ?", selfSupportForSchoolOrdOrdDb.OutOrderNo).Delete(model.SelfSupportForSchoolOrd{}) | |||
} | |||
func (selfSupportForSchoolOrdOrdDb *SelfSupportForSchoolOrd) SelfSupportForSchoolOrdUpdate(m *model.SelfSupportForSchoolOrd, forceColums ...string) (int64, error) { | |||
var ( | |||
affected int64 | |||
err error | |||
) | |||
if forceColums != nil { | |||
affected, err = selfSupportForSchoolOrdOrdDb.Db.Where("out_trade_no=?", selfSupportForSchoolOrdOrdDb.OutOrderNo).Cols(forceColums...).Update(m) | |||
} else { | |||
affected, err = selfSupportForSchoolOrdOrdDb.Db.Where("out_trade_no=?", selfSupportForSchoolOrdOrdDb.OutOrderNo).Update(m) | |||
} | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
type SelfSupportForSchoolOrdWithUserIdentity struct { | |||
model.SelfSupportForSchoolOrd `xorm:"extends"` | |||
model.UserIdentity `xorm:"extends"` | |||
model.Enterprise `xorm:"extends"` | |||
model.User `xorm:"extends"` | |||
model.ClassWithUser `xorm:"extends"` | |||
model.Class `xorm:"extends"` | |||
model.Grade `xorm:"extends"` | |||
} | |||
func (SelfSupportForSchoolOrdWithUserIdentity) TableName() string { | |||
return "self_support_for_school_ord" | |||
} |
@@ -0,0 +1,13 @@ | |||
package model | |||
type CentralKitchenForSchoolPackageForSystem struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Year string `json:"year" xorm:"not null default '0000' comment('年份') VARCHAR(50)"` | |||
Month string `json:"month" xorm:"not null default '00' comment('月份') VARCHAR(50)"` | |||
TotalPrice string `json:"total_price" xorm:"not null default 0.00 comment('总价') DECIMAL(8,2)"` | |||
StartDate string `json:"start_date" xorm:"not null default '0000-00-00' comment('起始时间') CHAR(50)"` | |||
EndDate string `json:"end_date" xorm:"not null default '0000-00-00' comment('截止时间') CHAR(50)"` | |||
WithDate string `json:"with_date" xorm:"not null comment('包含天份') TEXT"` | |||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||
} |
@@ -0,0 +1,16 @@ | |||
package model | |||
type CentralKitchenForSchoolPackageOrdForReserve struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
EnterpriseId int `json:"enterprise_id" xorm:"not null default 0 comment('所属单位id') INT(11)"` | |||
Uid int `json:"uid" xorm:"not null default 0 comment('用户id') INT(11)"` | |||
UserIdentityName string `json:"user_identity_name" xorm:"not null default '' comment('用户身份名称(起备份作用)') CHAR(50)"` | |||
UserIdentityId int `json:"user_identity_id" xorm:"not null default 0 comment('用户身份id') INT(11)"` | |||
Kind int `json:"kind" xorm:"not null default 1 comment('预定类型(1:早餐 2:午餐 3:晚餐)') TINYINT(1)"` | |||
OutTradeNo string `json:"out_trade_no" xorm:"not null default '' comment('商户订单号') VARCHAR(255)"` | |||
ReserveMonth string `json:"reserve_month" xorm:"not null default '' comment('预定月份') CHAR(50)"` | |||
MealTimeStart string `json:"meal_time_start" xorm:"not null default '0000-00-00' comment('就餐时间-开始') CHAR(50)"` | |||
MealTimeEnd string `json:"meal_time_end" xorm:"not null default '0000-00-00' comment('就餐时间-截止') CHAR(50)"` | |||
CreateAt string `json:"create_at" xorm:"not null pk default 'CURRENT_TIMESTAMP' DATETIME"` | |||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||
} |
@@ -10,6 +10,7 @@ type CentralKitchenForSchoolUserRefundDay struct { | |||
State int `json:"state" xorm:"not null default 1 comment('状态(1:审核中 2:审核通过 3:审核拒绝 4:退款已完成)') TINYINT(1)"` | |||
Amount string `json:"amount" xorm:"not null default 0.00 comment('金额') DECIMAL(6,2)"` | |||
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"` | |||
RefundDate string `json:"refund_date" xorm:"not null default '0000-00-00 00:00:00' comment('退款时间') CHAR(50)"` | |||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||
} |
@@ -0,0 +1,17 @@ | |||
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"` | |||
} |
@@ -0,0 +1,32 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type SelfSupportForSchoolOrd struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
EnterpriseId int `json:"enterprise_id" xorm:"not null default 0 comment('所属单位id') INT(11)"` | |||
Uid int `json:"uid" xorm:"not null default 0 comment('用户id') INT(11)"` | |||
UserIdentityId int `json:"user_identity_id" xorm:"not null default 0 comment('用户身份id') INT(11)"` | |||
OutOrderNo string `json:"out_order_no" xorm:"not null default '' comment('外部订单号,设备端产生') VARCHAR(255)"` | |||
TradeNo string `json:"trade_no" xorm:"not null default '' comment('第三方交易号,支付宝,微信,ISV渠道等') VARCHAR(255)"` | |||
Consumer string `json:"consumer" xorm:"not null default '' comment('消费人(花名册名称)') CHAR(100)"` | |||
BuyerId string `json:"buyer_id" xorm:"not null default '' comment('云校园定义买家标识(支付宝刷脸用户id)') CHAR(100)"` | |||
SellerId string `json:"seller_id" xorm:"not null default '' comment('卖家支付宝uid') CHAR(100)"` | |||
DeviceSn string `json:"device_sn" xorm:"not null default '' comment('设备编号') CHAR(100)"` | |||
SchoolName string `json:"school_name" xorm:"not null default '' comment('学校名称') CHAR(100)"` | |||
SchoolCode string `json:"school_code" xorm:"not null default '' comment('学校内标') CHAR(100)"` | |||
StoreBusinessScenario string `json:"store_business_scenario" xorm:"not null default '' comment('门店经营场景') CHAR(100)"` | |||
StoreName string `json:"store_name" xorm:"not null default '' comment('门店名称') CHAR(100)"` | |||
CpStoreId string `json:"cp_store_id" xorm:"not null default '' comment('门店编号') CHAR(100)"` | |||
MerchantName string `json:"merchant_name" xorm:"not null default '' comment('商户名称') CHAR(100)"` | |||
CpMerchantId string `json:"cp_merchant_id" xorm:"not null default '' comment('商户编码') CHAR(100)"` | |||
TradeAmount string `json:"trade_amount" xorm:"not null default 0.00 comment('交易总金额') DECIMAL(8,2)"` | |||
FaceTime string `json:"face_time" xorm:"not null default '' comment('刷脸时间') CHAR(100)"` | |||
OrderStatus int `json:"order_status" xorm:"not null default 0 comment('支付状态 (0:待支付 1:支付成功)') TINYINT(1)"` | |||
DebtBusinessCode string `json:"debt_business_code" xorm:"not null default '' comment('欠费订单异常渠道异常码(欠费返回)') CHAR(100)"` | |||
DebtBusinessMsg string `json:"debt_business_msg" xorm:"not null default '' comment('欠费订单欠费原因(欠费返回)') VARCHAR(255)"` | |||
CreateAt time.Time `json:"create_at" xorm:"not null pk default 'CURRENT_TIMESTAMP' DATETIME"` | |||
UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||
} |
@@ -1,51 +1,18 @@ | |||
package enum | |||
type CentralKitchenForSchoolPackageOrdState int32 | |||
type SelfSupportForSchoolOrdOrderStatus int32 | |||
const ( | |||
CentralKitchenForSchoolPackageOrdStateForWait = 0 | |||
CentralKitchenForSchoolPackageOrdStateForSuccess = 1 | |||
CentralKitchenForSchoolPackageOrdStateForFail = 2 | |||
SelfSupportForSchoolOrdOrderStatusForWait = 0 | |||
SelfSupportForSchoolOrdOrderStatusForSuccess = 1 | |||
) | |||
func (gt CentralKitchenForSchoolPackageOrdState) String() string { | |||
func (gt SelfSupportForSchoolOrdOrderStatus) String() string { | |||
switch gt { | |||
case CentralKitchenForSchoolPackageOrdStateForWait: | |||
case SelfSupportForSchoolOrdOrderStatusForWait: | |||
return "待支付" | |||
case CentralKitchenForSchoolPackageOrdStateForSuccess: | |||
case SelfSupportForSchoolOrdOrderStatusForSuccess: | |||
return "支付成功" | |||
case CentralKitchenForSchoolPackageOrdStateForFail: | |||
return "支付失败" | |||
default: | |||
return "未知" | |||
} | |||
} | |||
type CentralKitchenForSchoolPackageOrdOrdState int32 | |||
const ( | |||
CentralKitchenForSchoolPackageOrdOrdStateForWait = 0 | |||
CentralKitchenForSchoolPackageOrdOrdStateForSuccess = 1 | |||
CentralKitchenForSchoolPackageOrdOrdStateForRefunding = 2 | |||
CentralKitchenForSchoolPackageOrdOrdStateForPartRefunded = 3 | |||
CentralKitchenForSchoolPackageOrdOrdStateForRefunded = 4 | |||
CentralKitchenForSchoolPackageOrdOrdStateForComplete = 5 | |||
) | |||
func (gt CentralKitchenForSchoolPackageOrdOrdState) String() string { | |||
switch gt { | |||
case CentralKitchenForSchoolPackageOrdOrdStateForWait: | |||
return "待支付" | |||
case CentralKitchenForSchoolPackageOrdOrdStateForSuccess: | |||
return "预约成功" | |||
case CentralKitchenForSchoolPackageOrdOrdStateForRefunding: | |||
return "退款中" | |||
case CentralKitchenForSchoolPackageOrdOrdStateForPartRefunded: | |||
return "部分退款" | |||
case CentralKitchenForSchoolPackageOrdOrdStateForRefunded: | |||
return "已退款" | |||
case CentralKitchenForSchoolPackageOrdOrdStateForComplete: | |||
return "已完成" | |||
default: | |||
return "未知" | |||
} | |||
@@ -0,0 +1,29 @@ | |||
package enum | |||
type Month int | |||
const ( | |||
January Month = 1 | |||
February | |||
March | |||
April | |||
May | |||
June | |||
July | |||
August | |||
September | |||
October | |||
November | |||
December | |||
) |
@@ -0,0 +1,52 @@ | |||
package enum | |||
type CentralKitchenForSchoolPackageOrdState int32 | |||
const ( | |||
CentralKitchenForSchoolPackageOrdStateForWait = 0 | |||
CentralKitchenForSchoolPackageOrdStateForSuccess = 1 | |||
CentralKitchenForSchoolPackageOrdStateForFail = 2 | |||
) | |||
func (gt CentralKitchenForSchoolPackageOrdState) String() string { | |||
switch gt { | |||
case CentralKitchenForSchoolPackageOrdStateForWait: | |||
return "待支付" | |||
case CentralKitchenForSchoolPackageOrdStateForSuccess: | |||
return "支付成功" | |||
case CentralKitchenForSchoolPackageOrdStateForFail: | |||
return "支付失败" | |||
default: | |||
return "未知" | |||
} | |||
} | |||
type CentralKitchenForSchoolPackageOrdOrdState int32 | |||
const ( | |||
CentralKitchenForSchoolPackageOrdOrdStateForWait = 0 | |||
CentralKitchenForSchoolPackageOrdOrdStateForSuccess = 1 | |||
CentralKitchenForSchoolPackageOrdOrdStateForRefunding = 2 | |||
CentralKitchenForSchoolPackageOrdOrdStateForPartRefunded = 3 | |||
CentralKitchenForSchoolPackageOrdOrdStateForRefunded = 4 | |||
CentralKitchenForSchoolPackageOrdOrdStateForComplete = 5 | |||
) | |||
func (gt CentralKitchenForSchoolPackageOrdOrdState) String() string { | |||
switch gt { | |||
case CentralKitchenForSchoolPackageOrdOrdStateForWait: | |||
return "待支付" | |||
case CentralKitchenForSchoolPackageOrdOrdStateForSuccess: | |||
return "预约成功" | |||
case CentralKitchenForSchoolPackageOrdOrdStateForRefunding: | |||
return "退款中" | |||
case CentralKitchenForSchoolPackageOrdOrdStateForPartRefunded: | |||
return "部分退款" | |||
case CentralKitchenForSchoolPackageOrdOrdStateForRefunded: | |||
return "已退款" | |||
case CentralKitchenForSchoolPackageOrdOrdStateForComplete: | |||
return "已完成" | |||
default: | |||
return "未知" | |||
} | |||
} |
@@ -84,6 +84,7 @@ func rFinanceManage(r *gin.RouterGroup) { | |||
r.POST("/centralKitchenForSchool/ordList", hdl.CentralKitchenForSchoolOrdList) //财务管理-(央厨-学校)订单列表 | |||
r.GET("/centralKitchenForSchool/ordDetail", hdl.CentralKitchenForSchoolOrdDetail) //财务管理-(央厨-学校)订单详情 | |||
r.POST("/centralKitchenForSchool/ordRefund", hdl.CentralKitchenForSchoolOrdRefund) //财务管理-(央厨-学校)订单退款 | |||
r.POST("/selfSupportForSchool/ordList", hdl.SelfSupportForSchoolOrdList) //财务管理-(自营-学校)订单列表 | |||
} | |||
@@ -101,8 +102,12 @@ func rEnterprise(r *gin.RouterGroup) { | |||
r.POST("/updateState", hdl2.EnterpriseUpdateState) | |||
r.POST("/addGrade", hdl2.EnterpriseAddGrade) | |||
r.GET("/detail", hdl2.Detail) | |||
r.GET("/schoolBelowGrade", hdl2.SchoolBelowGrade) //"学校"下年级 | |||
r.GET("/schoolGradeBelowClass", hdl2.SchoolGradeBelowClass) //"学校"年级下班级 | |||
r.GET("/schoolBelowGrade", hdl2.SchoolBelowGrade) //"学校"下年级 | |||
r.GET("/schoolGradeBelowClass", hdl2.SchoolGradeBelowClass) //"学校"年级下班级 | |||
r.POST("/listCentralKitchenForSchoolPackageForSystem", hdl2.ListCentralKitchenForSchoolPackageForSystem) //"央厨-学校-套餐-系统" 列表 | |||
r.POST("/saveCentralKitchenForSchoolPackage", hdl2.SaveCentralKitchenForSchoolPackageForSystem) //新增/编辑 "央厨-学校-套餐-系统" | |||
r.DELETE("/deleteCentralKitchenForSchoolPackage/:id", hdl2.DeleteCentralKitchenForSchoolPackageForSystem) //删除 "央厨-学校-套餐-系统" | |||
r.POST("/syncCentralKitchenForSchoolPackageForSystem", hdl2.SyncCentralKitchenForSchoolPackageForSystem) //"央厨-学校-套餐-系统" 同步数据 | |||
} | |||
func rEnterpriseManage(r *gin.RouterGroup) { | |||
@@ -125,6 +130,9 @@ func rEnterpriseManage(r *gin.RouterGroup) { | |||
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("/centralKitchenForSchoolOrderRefundList", hdl2.CentralKitchenForSchoolOrderRefundList) //"央厨-学校"订单退款列表 | |||
//r.POST("/centralKitchenForSchoolOrderRefundAudit", hdl2.CentralKitchenForSchoolOrderRefundAudit) //"央厨-学校"订单退款审核 | |||
@@ -156,6 +164,7 @@ func rEnterpriseManage(r *gin.RouterGroup) { | |||
r.DELETE("/selfSupportForSchool/classDelete/:id", hdl.SelfSupportForSchoolClassDelete) //"自营-学校"班级删除 | |||
r.POST("/selfSupportForSchool/addWorker", hdl.SelfSupportForSchoolAddWorker) //"自营-学校"添加工作人员 | |||
r.POST("/selfSupportForSchool/addTeacher", hdl.SelfSupportForSchoolAddTeacher) //"自营-学校"添加老师 | |||
r.POST("/selfSupportForSchool/ordList", hdl.SelfSupportForSchoolOrdList) //"自营-学校"订单列表 | |||
} | |||
@@ -10,6 +10,7 @@ import ( | |||
func CustomerInit(r *gin.RouterGroup) { | |||
rPay(r.Group("/pay")) | |||
rCentralKitchenForSchoolOrder(r.Group("/order/centralKitchenForSchool")) | |||
rSelfSupportForSchoolOrder(r.Group("/order/selfSupportForSchool")) | |||
rSelfSupportForSchool(r.Group("/selfSupportForSchool")) | |||
rUserIdentity(r.Group("/userIdentity")) | |||
@@ -61,6 +62,11 @@ func rCentralKitchenForSchoolOrder(r *gin.RouterGroup) { | |||
r.POST("/refundList", hdl.CentralKitchenForSchoolOrderRefundList) // 央厨学校-订单退款列表 | |||
} | |||
func rSelfSupportForSchoolOrder(r *gin.RouterGroup) { | |||
r.Use(mw.Auth) //检测登录状态 | |||
r.POST("/list", hdl.SelfSupportForSchoolOrderList) // 自营学校-订单列表 | |||
} | |||
func rSelfSupportForSchool(r *gin.RouterGroup) { //自营学校 | |||
r.Use(mw.Auth) //检测登录状态 | |||
r.GET("/educateSceneTokenQuery", selfSupportForSchoolhdl.EducateSceneTokenQuery) // 自营学校-查询刷脸用户开通详细信息 | |||
@@ -67,7 +67,7 @@ func TimeParse(format, src string) (time.Time, error) { | |||
} | |||
func TimeParseStd(src string) time.Time { | |||
t, _ := TimeParse("2006-01-02 15:04:05", src) | |||
t, _ := TimeParse("2006-01-02", src) | |||
return t | |||
} | |||
@@ -185,7 +185,6 @@ func GetTimeRange(s string) map[string]int64 { | |||
func GetDateTimeRangeStr(s string) (string, string) { | |||
t := time.Now() | |||
var stime, etime time.Time | |||
switch s { | |||
case "today": | |||
stime = time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location()) | |||