2021-08-28 05:06:00 +00:00
|
|
|
package app
|
|
|
|
|
|
|
|
import (
|
|
|
|
. "../../../hotime"
|
|
|
|
. "../../../hotime/common"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
var ctg_order_dateCtr = Ctr{
|
|
|
|
|
|
|
|
"info": func(that *Context) {
|
|
|
|
|
|
|
|
//today:=time.Now().Weekday()
|
2021-08-28 22:08:19 +00:00
|
|
|
id := ObjToInt(that.Req.FormValue("id"))
|
|
|
|
category := that.Db.Get("category", "*", Map{"id": id})
|
2021-08-28 05:06:00 +00:00
|
|
|
if category == nil {
|
|
|
|
that.Display(4, "找不到该类别!")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-09-15 20:33:10 +00:00
|
|
|
todayPMTime, _ := time.ParseInLocation("2006-01-02 15:04", time.Now().Format("2006-01-02")+" 14:00", time.Local)
|
|
|
|
todayAMTime, _ := time.ParseInLocation("2006-01-02 15:04", time.Now().Format("2006-01-02")+" 09:00", time.Local)
|
2021-08-28 05:06:00 +00:00
|
|
|
|
|
|
|
weekDay := 1
|
|
|
|
|
|
|
|
switch time.Now().Weekday().String() {
|
|
|
|
case "Monday":
|
|
|
|
weekDay = 1
|
|
|
|
case "Tuesday":
|
|
|
|
weekDay = 2
|
|
|
|
case "Wednesday":
|
|
|
|
weekDay = 3
|
|
|
|
case "Thursday":
|
|
|
|
weekDay = 4
|
|
|
|
case "Friday":
|
|
|
|
weekDay = 5
|
|
|
|
case "Saturday":
|
|
|
|
weekDay = 6
|
|
|
|
case "Sunday":
|
|
|
|
weekDay = 7
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
////future:=that.Db.Select("ctg_order_date","*",Map{"category_id":that.RouterString[2],"date[>]":time})
|
|
|
|
date := Slice{}
|
|
|
|
for i := 0; i < 7; i++ {
|
|
|
|
day := weekDay + i + 1
|
|
|
|
|
|
|
|
if day > 7 {
|
|
|
|
day = day - 7
|
|
|
|
}
|
|
|
|
if day == 6 || day == 7 {
|
|
|
|
continue
|
|
|
|
}
|
2021-08-28 22:08:19 +00:00
|
|
|
//fmt.Println(todayAMTime.Unix() + int64(24*60*60*(i+1)))
|
|
|
|
dayAM := that.Db.Get("ctg_order_date", "*", Map{"AND": Map{"category_id": category.GetCeilInt("id"),
|
|
|
|
"date": todayAMTime.Unix() + int64(24*60*60*(i+1))}})
|
2021-08-28 05:06:00 +00:00
|
|
|
if dayAM == nil {
|
2021-09-24 02:49:07 +00:00
|
|
|
dayAM = Map{"name": "9:00-11:30",
|
2021-08-28 05:06:00 +00:00
|
|
|
"date": todayAMTime.Unix() + int64(24*60*60*(i+1)),
|
|
|
|
"create_time": time.Now().Unix(),
|
|
|
|
"modify_time": time.Now().Unix(),
|
|
|
|
"start_sn": category.GetCeilInt("start_sn"),
|
|
|
|
"max_sn": category.GetCeilInt("start_sn") + category.GetCeilInt("am"+ObjToStr(day)),
|
|
|
|
"now_sn": category.GetCeilInt("start_sn"),
|
|
|
|
"category_id": category.GetCeilInt("id"),
|
|
|
|
}
|
|
|
|
dayAM["id"] = that.Db.Insert("ctg_order_date", dayAM)
|
|
|
|
if dayAM.GetCeilInt64("id") == 0 {
|
|
|
|
that.Display(4, "内部错误!")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-28 22:08:19 +00:00
|
|
|
dayPM := that.Db.Get("ctg_order_date", "*", Map{"AND": Map{"category_id": category.GetCeilInt("id"), "date": todayPMTime.Unix() + int64(24*60*60*(i+1))}})
|
2021-09-15 20:33:10 +00:00
|
|
|
//fmt.Println(that.Db.LastQuery, that.Db.LastData, dayPM, that.Db.LastErr)
|
2021-08-28 05:06:00 +00:00
|
|
|
if dayPM == nil {
|
2021-09-15 20:33:10 +00:00
|
|
|
//fmt.Println("dasdasdasda")
|
2021-09-24 02:49:07 +00:00
|
|
|
dayPM = Map{"name": "13:30-16:30",
|
2021-08-28 05:06:00 +00:00
|
|
|
"date": todayPMTime.Unix() + int64(24*60*60*(i+1)),
|
|
|
|
"create_time": time.Now().Unix(),
|
|
|
|
"modify_time": time.Now().Unix(),
|
|
|
|
"start_sn": category.GetCeilInt("start_sn"),
|
|
|
|
"max_sn": category.GetCeilInt("start_sn") + category.GetCeilInt("pm"+ObjToStr(day)),
|
|
|
|
"now_sn": category.GetCeilInt("start_sn"),
|
|
|
|
"category_id": category.GetCeilInt("id"),
|
|
|
|
}
|
|
|
|
dayPM["id"] = that.Db.Insert("ctg_order_date", dayPM)
|
|
|
|
if dayPM.GetCeilInt64("id") == 0 {
|
|
|
|
that.Display(4, "内部错误!")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
date = append(date, Map{"name": "星期" + ObjToStr(day) + "(" + time.Unix(todayPMTime.Unix()+int64(24*60*60*(i+1)), 0).Format("01-02") + ")",
|
|
|
|
"am": dayAM,
|
|
|
|
"pm": dayPM,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
that.Display(0, date)
|
|
|
|
},
|
|
|
|
}
|