From 3a6d8273402557c64618e9661d71a87b3f9885cf Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Fri, 6 Oct 2023 15:56:59 +0800 Subject: [PATCH] update --- .../svc_central_kitchen_for_school.go | 43 +++++++++++++------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go b/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go index d130f7a..390e613 100644 --- a/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go +++ b/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go @@ -738,15 +738,32 @@ func CentralKitchenForSchoolReserveList(req md.CentralKitchenForSchoolReserveLis } } - var centralKitchenForSchoolUserWithDayIds []string - if req.StartDate != "" && req.EndDate != "" { - var m []model.CentralKitchenForSchoolUserWithDay - if err1 := db.Db.In("state", []int{enum2.CentralKitchenForSchoolUserWithDayStateForWait, enum2.CentralKitchenForSchoolUserWithDayStateForAlready}). - And("date >= ? And date <= ?", req.StartDate, req.EndDate).Asc("date").Find(&m); err != nil { - return nil, 0, err1 - } - for _, v := range m { - centralKitchenForSchoolUserWithDayIds = append(centralKitchenForSchoolUserWithDayIds, v.OrdNo) + //var centralKitchenForSchoolUserWithDayIds []string + //if req.StartDate != "" && req.EndDate != "" { + // var m []model.CentralKitchenForSchoolUserWithDay + // if err1 := db.Db.In("state", []int{enum2.CentralKitchenForSchoolUserWithDayStateForWait, enum2.CentralKitchenForSchoolUserWithDayStateForAlready}). + // And("date >= ? And date <= ?", req.StartDate, req.EndDate).Asc("date").Find(&m); err != nil { + // return nil, 0, err1 + // } + // for _, v := range m { + // centralKitchenForSchoolUserWithDayIds = append(centralKitchenForSchoolUserWithDayIds, v.OrdNo) + // } + //} + + 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) + _, 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) + } } } @@ -774,10 +791,12 @@ func CentralKitchenForSchoolReserveList(req md.CentralKitchenForSchoolReserveLis if len(classWithUserIdentityIdsTwo) > 0 { sess.In("user_identity.id", classWithUserIdentityIdsTwo) } - if len(centralKitchenForSchoolUserWithDayIds) > 0 { - sess.In("central_kitchen_for_school_package_ord.out_trade_no", centralKitchenForSchoolUserWithDayIds) + //if len(centralKitchenForSchoolUserWithDayIds) > 0 { + // sess.In("central_kitchen_for_school_package_ord.out_trade_no", centralKitchenForSchoolUserWithDayIds) + //} + if len(months) > 0 { + sess.In("central_kitchen_for_school_package_ord_for_reserve.reserve_month", months) } - 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").