Browse Source

update

add_mode
DengBiao 1 year ago
parent
commit
b614c96bfe
1 changed files with 15 additions and 7 deletions
  1. +15
    -7
      app/customer/svc/svc_central_kitchen_for_school_package.go

+ 15
- 7
app/customer/svc/svc_central_kitchen_for_school_package.go View File

@@ -36,6 +36,7 @@ func CalcBySchoolTerm(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq)
var m []model.CentralKitchenForSchoolPackage var m []model.CentralKitchenForSchoolPackage
now := time.Now() now := time.Now()
today, _ := time.ParseInLocation("2006-01-02", time.Now().Format("2006-01-02"), time.Local) today, _ := time.ParseInLocation("2006-01-02", time.Now().Format("2006-01-02"), time.Local)
tomorrowDay := today.AddDate(0, 0, 1)


err = db.Db.Where("enterprise_id =?", buyPackageReq.EnterpriseId).In("id", buyPackageReq.PackageIds).And("is_delete = 0").And("state = 1").Desc("end_date").Find(&m) err = db.Db.Where("enterprise_id =?", buyPackageReq.EnterpriseId).In("id", buyPackageReq.PackageIds).And("is_delete = 0").And("state = 1").Desc("end_date").Find(&m)
if err != nil { if err != nil {
@@ -54,15 +55,17 @@ func CalcBySchoolTerm(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq)
for _, v1 := range *centralKitchenForSchoolPackageWithDay { for _, v1 := range *centralKitchenForSchoolPackageWithDay {
//3.1、判断是否小于今天 //3.1、判断是否小于今天
date, _ := time.ParseInLocation("2006-01-02", v1.Date, time.Local) date, _ := time.ParseInLocation("2006-01-02", v1.Date, time.Local)
if today.After(date) {
if today.After(date) || today.Equal(date) {
continue continue
} }
if today.Equal(date) {
//2.2、判断是否过了今日可订餐时间

if tomorrowDay.Equal(date) {
//2.2、判断是否过了明日可订餐时间
if now.After(centralKitchenForSchoolReserveMealTime) { if now.After(centralKitchenForSchoolReserveMealTime) {
continue continue
} }
} }

//3.3、计算价格 && 组装数据 //3.3、计算价格 && 组装数据
if v1.IsOpenBreakfast == md.OpenBreakfast && buyPackageReq.IsBuyBreakfast == 1 { if v1.IsOpenBreakfast == md.OpenBreakfast && buyPackageReq.IsBuyBreakfast == 1 {
//早餐 //早餐
@@ -154,6 +157,8 @@ func CalcByMonth(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (tota
var m []model.CentralKitchenForSchoolPackage var m []model.CentralKitchenForSchoolPackage
now := time.Now() now := time.Now()
today, _ := time.ParseInLocation("2006-01-02", time.Now().Format("2006-01-02"), time.Local) today, _ := time.ParseInLocation("2006-01-02", time.Now().Format("2006-01-02"), time.Local)
tomorrowDay := today.AddDate(0, 0, 1)

err = db.Db.Where("enterprise_id =?", buyPackageReq.EnterpriseId).And("id =?", buyPackageReq.PackageId).And("is_delete = 0").And("state = 1").Find(&m) err = db.Db.Where("enterprise_id =?", buyPackageReq.EnterpriseId).And("id =?", buyPackageReq.PackageId).And("is_delete = 0").And("state = 1").Find(&m)
if err != nil { if err != nil {
return return
@@ -171,10 +176,11 @@ func CalcByMonth(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (tota
for _, v1 := range *centralKitchenForSchoolPackageWithDay { for _, v1 := range *centralKitchenForSchoolPackageWithDay {
//3.1、判断是否小于今天 //3.1、判断是否小于今天
date, _ := time.ParseInLocation("2006-01-02", v1.Date, time.Local) date, _ := time.ParseInLocation("2006-01-02", v1.Date, time.Local)
if today.After(date) {
if today.After(date) || today.Equal(date) {
continue continue
} }
if today.Equal(date) {

if tomorrowDay.Equal(date) {
//2.2、判断是否过了今日可订餐时间 //2.2、判断是否过了今日可订餐时间
if now.After(centralKitchenForSchoolReserveMealTime) { if now.After(centralKitchenForSchoolReserveMealTime) {
continue continue
@@ -270,16 +276,18 @@ func CalcByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (totalP


now := time.Now() now := time.Now()
today, _ := time.ParseInLocation("2006-01-02", time.Now().Format("2006-01-02"), time.Local) today, _ := time.ParseInLocation("2006-01-02", time.Now().Format("2006-01-02"), time.Local)
tomorrowDay := today.AddDate(0, 0, 1)

centralKitchenForSchoolReserveMealTime, _ := time.ParseInLocation("2006-01-02 15:04:05", now.Format("2006-01-02")+" "+cfg.Val+":00", time.Local) centralKitchenForSchoolReserveMealTime, _ := time.ParseInLocation("2006-01-02 15:04:05", now.Format("2006-01-02")+" "+cfg.Val+":00", time.Local)


//2、循环拼接数据 //2、循环拼接数据
for _, v1 := range buyPackageReq.WithDays { for _, v1 := range buyPackageReq.WithDays {
//2.1、判断是否小于今天 //2.1、判断是否小于今天
date, _ := time.ParseInLocation("2006-01-02", v1.Date, time.Local) date, _ := time.ParseInLocation("2006-01-02", v1.Date, time.Local)
if today.After(date) {
if today.After(date) || today.Equal(date) {
continue continue
} }
if today.Equal(date) {
if tomorrowDay.Equal(date) {
//2.2、判断是否过了今日可订餐时间 //2.2、判断是否过了今日可订餐时间
if now.After(centralKitchenForSchoolReserveMealTime) { if now.After(centralKitchenForSchoolReserveMealTime) {
continue continue


Loading…
Cancel
Save