From 89d4961ada5e44f33a94dae992bc14d24bec78a0 Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Wed, 4 Oct 2023 16:36:57 +0800 Subject: [PATCH] update --- app/admin/svc/svc_data_statisstics.go | 33 ++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/app/admin/svc/svc_data_statisstics.go b/app/admin/svc/svc_data_statisstics.go index 427d046..43d609e 100644 --- a/app/admin/svc/svc_data_statisstics.go +++ b/app/admin/svc/svc_data_statisstics.go @@ -662,7 +662,6 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD } if len(months) > 0 { sess.In("central_kitchen_for_school_package_ord_for_reserve.reserve_month", months) - } //if req.EndDate != "" { // sess.And("central_kitchen_for_school_package_ord_for_reserve.meal_time_start <= ?", req.EndDate) @@ -851,10 +850,24 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD if req.EnterpriseId != 0 { sess.And("central_kitchen_for_school_package_ord_for_reserve.enterprise_id =?", req.EnterpriseId) } + var months []time.Month if req.StartDate != "" { sDate, _ := time.ParseInLocation("2006-01-02 15:04:05", req.StartDate, time.Local) eDate, _ := time.ParseInLocation("2006-01-02 15:04:05", req.EndDate, time.Local) - sess.And("central_kitchen_for_school_package_ord_for_reserve.meal_time_start <= ? and central_kitchen_for_school_package_ord_for_reserve.meal_time_end >= ?", sDate.Format("2006-01-02"), eDate.Format("2006-01-02")) + _, sMonth, _ := sDate.Date() + _, eMonth, _ := eDate.Date() + diffMonth := sMonth - eMonth + if diffMonth == 0 { + //TODO::查询一个月 + months = append(months, sMonth) + } else { + for i := sMonth; i <= eMonth; i++ { + months = append(months, i) + } + } + } + if len(months) > 0 { + sess.In("central_kitchen_for_school_package_ord_for_reserve.reserve_month", months) } //if req.EndDate != "" { // sess.And("central_kitchen_for_school_package_ord_for_reserve.meal_time_start <= ?", req.EndDate) @@ -1478,10 +1491,24 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD if req.EnterpriseId != 0 { sess.And("central_kitchen_for_school_package_ord_for_reserve.enterprise_id =?", req.EnterpriseId) } + var months []time.Month if req.StartDate != "" { sDate, _ := time.ParseInLocation("2006-01-02 15:04:05", req.StartDate, time.Local) eDate, _ := time.ParseInLocation("2006-01-02 15:04:05", req.EndDate, time.Local) - sess.And("central_kitchen_for_school_package_ord_for_reserve.meal_time_start <= ? and central_kitchen_for_school_package_ord_for_reserve.meal_time_end >= ?", sDate.Format("2006-01-02"), eDate.Format("2006-01-02")) + _, sMonth, _ := sDate.Date() + _, eMonth, _ := eDate.Date() + diffMonth := sMonth - eMonth + if diffMonth == 0 { + //TODO::查询一个月 + months = append(months, sMonth) + } else { + for i := sMonth; i <= eMonth; i++ { + months = append(months, i) + } + } + } + if len(months) > 0 { + sess.In("central_kitchen_for_school_package_ord_for_reserve.reserve_month", months) } //if req.EndDate != "" { // sess.And("central_kitchen_for_school_package_ord_for_reserve.meal_time_start <= ?", req.EndDate)