forked from golang/hotime
67 lines
2.0 KiB
Go
67 lines
2.0 KiB
Go
package app
|
|
|
|
import (
|
|
. "../../../hotime"
|
|
. "../../../hotime/common"
|
|
"time"
|
|
)
|
|
|
|
var orderCtr = Ctr{
|
|
"count": func(this *Context) {
|
|
if this.Session("id").ToCeilInt() == 0 {
|
|
this.Display(2, "没有登录!")
|
|
return
|
|
}
|
|
re := Map{}
|
|
re["total"] = this.Db.Count("order", Map{"user_id": this.Session("id").ToCeilInt()})
|
|
re["finish"] = this.Db.Count("order", Map{"AND": Map{"user_id": this.Session("id").ToCeilInt(), "status": 2}})
|
|
re["late"] = this.Db.Count("order", Map{"AND": Map{"user_id": this.Session("id").ToCeilInt(), "status": 3}})
|
|
|
|
this.Display(0, re)
|
|
},
|
|
"add": func(this *Context) {
|
|
if this.Session("id").ToCeilInt() == 0 {
|
|
this.Display(2, "没有登录!")
|
|
return
|
|
}
|
|
ctgOrderDateId := ObjToInt(this.Req.FormValue("ctg_order_date_id"))
|
|
//ctgId:=ObjToInt(this.Req.FormValue("category_id"))
|
|
ctgOrderDate := this.Db.Get("ctg_order_date", "*", Map{"id": ctgOrderDateId})
|
|
|
|
if ctgOrderDate.GetCeilInt64("now_sn")+1 > ctgOrderDate.GetCeilInt64("max_sn") {
|
|
this.Display(5, "当前排号已经用完")
|
|
return
|
|
}
|
|
|
|
data := Map{"create_time": time.Now().Unix(),
|
|
"modify_time": time.Now().Unix(),
|
|
"user_id": this.Session("id").ToCeilInt(),
|
|
"date": ctgOrderDate.GetString("date"),
|
|
"sn": ctgOrderDate.GetCeilInt64("now_sn") + 1,
|
|
"category_id": ctgOrderDate.GetCeilInt("category_id"),
|
|
"admin_id": 1,
|
|
"status": 1,
|
|
}
|
|
|
|
data["id"] = this.Db.Insert("order", data)
|
|
|
|
if data.GetCeilInt("id") == 0 {
|
|
this.Display(5, "预约失败")
|
|
return
|
|
}
|
|
|
|
this.Db.Update("ctg_order_date", Map{"now_sn": ctgOrderDate.GetCeilInt64("now_sn") + 1, "modify_time": time.Now().Unix()}, Map{"id": ctgOrderDate.GetCeilInt("id")})
|
|
this.Display(0, data)
|
|
},
|
|
"search": func(that *Context) {
|
|
if that.Session("id").ToCeilInt() == 0 {
|
|
that.Display(2, "没有登录!")
|
|
return
|
|
}
|
|
|
|
data := that.Db.Select("order", Map{"[><]user": "order.user_id=user.id",
|
|
"[><]category": "order.category_id=category.id"}, "*", Map{"user_id": that.Session("id").ToCeilInt()})
|
|
that.Display(0, data)
|
|
},
|
|
}
|