瀏覽代碼

update

add_mode
DengBiao 1 年之前
父節點
當前提交
b614c96bfe
共有 1 個檔案被更改,包括 15 行新增7 行删除
  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 查看文件

@@ -36,6 +36,7 @@ func CalcBySchoolTerm(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq)
var m []model.CentralKitchenForSchoolPackage
now := time.Now()
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)
if err != nil {
@@ -54,15 +55,17 @@ func CalcBySchoolTerm(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq)
for _, v1 := range *centralKitchenForSchoolPackageWithDay {
//3.1、判断是否小于今天
date, _ := time.ParseInLocation("2006-01-02", v1.Date, time.Local)
if today.After(date) {
if today.After(date) || today.Equal(date) {
continue
}
if today.Equal(date) {
//2.2、判断是否过了今日可订餐时间

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

//3.3、计算价格 && 组装数据
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
now := time.Now()
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)
if err != nil {
return
@@ -171,10 +176,11 @@ func CalcByMonth(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (tota
for _, v1 := range *centralKitchenForSchoolPackageWithDay {
//3.1、判断是否小于今天
date, _ := time.ParseInLocation("2006-01-02", v1.Date, time.Local)
if today.After(date) {
if today.After(date) || today.Equal(date) {
continue
}
if today.Equal(date) {

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

now := time.Now()
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)

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


Loading…
取消
儲存