diff --git a/app/customer/svc/order/svc_central_kitchen_for_school_order.go b/app/customer/svc/order/svc_central_kitchen_for_school_order.go index 0d392eb..a8cbb65 100644 --- a/app/customer/svc/order/svc_central_kitchen_for_school_order.go +++ b/app/customer/svc/order/svc_central_kitchen_for_school_order.go @@ -41,7 +41,7 @@ func OrderStatistic(req md.CentralKitchenForSchoolOrderListReq) (total float64, func CentralKitchenForSchoolOrderRefund(req md.CentralKitchenForSchoolOrderRefundReq) (err error) { sysCfgDb := db.SysCfgDb{} sysCfgDb.Set() - cfg, err := sysCfgDb.SysCfgGetOne(enum.CentralKitchenForSchoolReserveMealTime) + cfg, err := sysCfgDb.SysCfgGetOne(enum.CentralKitchenForSchoolCancelMealTime) if err != nil { return } @@ -65,11 +65,18 @@ func CentralKitchenForSchoolOrderRefund(req md.CentralKitchenForSchoolOrderRefun //2、判断是否为可退餐时间段 now := time.Now() today, _ := time.ParseInLocation("2006-01-02", time.Now().Format("2006-01-02"), time.Local) - centralKitchenForSchoolReserveMealTime, _ := time.ParseInLocation("2006-01-02 15:04:05", now.Format("2006-01-02")+" "+cfg.Val+":00", time.Local) + tomorrowDay := today.AddDate(0, 0, 1) + + centralKitchenForSchoolCancelMealTime, _ := time.ParseInLocation("2006-01-02 15:04:05", now.Format("2006-01-02")+" "+cfg.Val+":00", time.Local) date, _ := time.ParseInLocation("2006-01-02", centralKitchenForSchoolUserWithDay.Date, time.Local) - if today.Equal(date) { - //2.2、判断是否过了今日可订餐时间 - if now.After(centralKitchenForSchoolReserveMealTime) { + if today.After(date) || today.Equal(date) { + //2.2、判断是否小于今天 + err = errors.New("当前订餐不在可退订时间范围内") + return + } + if tomorrowDay.Equal(date) { + //2.3、判断是否过了明日可订餐时间 + if now.After(centralKitchenForSchoolCancelMealTime) { err = errors.New("当前订餐不在可退订时间范围内") return }