From 094eec7bc97089e661671a224f09de6cd87891a3 Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Tue, 12 Sep 2023 16:27:17 +0800 Subject: [PATCH] update --- ...ntral_kitchen_for_school_export_records.go | 1 + app/admin/md/md_enterprise_manage.go | 3 -- app/admin/svc/svc_data_statisstics.go | 43 +++++++++++++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/app/admin/md/md_central_kitchen_for_school_export_records.go b/app/admin/md/md_central_kitchen_for_school_export_records.go index 259f976..09860a5 100644 --- a/app/admin/md/md_central_kitchen_for_school_export_records.go +++ b/app/admin/md/md_central_kitchen_for_school_export_records.go @@ -12,6 +12,7 @@ type CentralKitchenForSchoolDataStatisticsExportReq struct { Kind int `json:"kind" binding:"required" label:"导出类型"` StartDate string `json:"start_date" binding:"required" label:"起始时间"` EndDate string `json:"end_date" binding:"required" label:"截止时间"` + MealKindList []int `json:"meal_kind_list" label:"就餐类型(1:早餐 2:午餐 3:晚餐)"` EnterpriseId int `json:"enterprise_id" label:"校企id"` EnterpriseName string `json:"enterprise_name" label:"校企名称"` } diff --git a/app/admin/md/md_enterprise_manage.go b/app/admin/md/md_enterprise_manage.go index 0409e8c..a654136 100644 --- a/app/admin/md/md_enterprise_manage.go +++ b/app/admin/md/md_enterprise_manage.go @@ -496,8 +496,6 @@ type SelfSupportForSchoolOrdListResp struct { type CentralKitchenForSchoolBatchAskForLeaveReqBySchool struct { EnterpriseIds []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:不退)"` @@ -507,7 +505,6 @@ type CentralKitchenForSchoolBatchAskForLeaveReqBySchool struct { type CentralKitchenForSchoolBatchAskForLeaveReqByGrade struct { EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` GradeIds []int `json:"grade_ids" 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:不退)"` diff --git a/app/admin/svc/svc_data_statisstics.go b/app/admin/svc/svc_data_statisstics.go index 91a355d..9517a84 100644 --- a/app/admin/svc/svc_data_statisstics.go +++ b/app/admin/svc/svc_data_statisstics.go @@ -437,10 +437,38 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD println("<<<>>>>Error:::", err.Error()) return } + + //查找预定数据 + var outTradeNoList []string + for _, v := range m { + outTradeNoList = append(outTradeNoList, v.OutTradeNo) + } + var mm []model.CentralKitchenForSchoolPackageOrdForReserve + sess1 := db.Db.Desc("id") + if req.EnterpriseId != 0 { + sess1.And("enterprise_id = ?", req.EnterpriseId) + } + if len(req.MealKindList) > 0 { + sess1.In("kind", req.MealKindList) + } + err = sess1.In("out_trade_no", outTradeNoList).Find(&mm) + if err != nil { + logx.Error(err) + println("<<<>>>>Error:::", err.Error()) + return + } + var exportOutTradeNoList []string + for _, v := range mm { + exportOutTradeNoList = append(exportOutTradeNoList, v.OutTradeNo) + } + titleList = []string{"订单号", "学生姓名", "学校", "年级", "班级", "家长电话", "预定日期", "预定天数", "订单价格", "支付时间", "订单状态"} xlsx.SetSheetRow("Sheet1", "A1", &titleList) j := 2 //表头被第一行用了,只能从第二行开始 for _, v := range m { + if !utils.InArr(v.OutTradeNo, exportOutTradeNoList) { + continue + } var ordState string //订单状态(0:待支付 1:预约成功 2:退款中 3:部分退款 4:已退款 5:已完成) switch v.CentralKitchenForSchoolPackageOrd.OrdState { case enum.CentralKitchenForSchoolPackageOrdOrdStateForWait: @@ -502,6 +530,9 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD if req.EndDate != "" { sess.And("central_kitchen_for_school_user_refund_day.create_at <= ?", req.EndDate) } + if len(req.MealKindList) > 0 { + sess.In("central_kitchen_for_school_user_with_day.kind", req.MealKindList) + } var m []*db.CentralKitchenForSchoolUserRefundDayWithData _, err := sess. Join("LEFT", "central_kitchen_for_school_user_with_day", "central_kitchen_for_school_user_refund_day.records_id = central_kitchen_for_school_user_with_day.id"). @@ -574,6 +605,9 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD if req.EndDate != "" { sess.And("central_kitchen_for_school_package_ord_for_reserve.meal_time_start <= ?", req.EndDate) } + if len(req.MealKindList) > 0 { + sess.In("central_kitchen_for_school_package_ord_for_reserve.kind", req.MealKindList) + } _, 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"). @@ -715,6 +749,9 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD if req.EndDate != "" { sess.And("central_kitchen_for_school_package_ord_for_reserve.meal_time_start <= ?", req.EndDate) } + if len(req.MealKindList) > 0 { + sess.In("central_kitchen_for_school_package_ord_for_reserve.kind", req.MealKindList) + } _, 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"). @@ -858,6 +895,9 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD if req.EndDate != "" { sess.And("central_kitchen_for_school_user_refund_day.create_at <= ?", req.EndDate) } + if len(req.MealKindList) > 0 { + sess.In("central_kitchen_for_school_user_with_day.kind", req.MealKindList) + } var m []*db.CentralKitchenForSchoolUserRefundDayWithData _, err := sess. Join("LEFT", "central_kitchen_for_school_user_with_day", "central_kitchen_for_school_user_refund_day.records_id = central_kitchen_for_school_user_with_day.id"). @@ -1220,6 +1260,9 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD if req.EndDate != "" { sess.And("central_kitchen_for_school_package_ord_for_reserve.meal_time_start <= ?", req.EndDate) } + if len(req.MealKindList) > 0 { + sess.In("central_kitchen_for_school_package_ord_for_reserve.kind", req.MealKindList) + } _, 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").