update
This commit is contained in:
parent
346412fef8
commit
e0d302c5f5
|
|
@ -62,6 +62,7 @@ func (p DefParty) RegisterList() []web_iris.Party {
|
|||
//系统
|
||||
p.systemConfigInfo(),
|
||||
p.systemBanners(),
|
||||
p.getPayoff(),
|
||||
}
|
||||
return ps
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,9 +95,9 @@ func (p DefParty) orderCreatePreCheck() web_iris.Party {
|
|||
}
|
||||
}
|
||||
var systemConfigPay models.SystemConfig
|
||||
database.Instance().Model(&models.SystemConfig{}).Where("config_type = 3").Order(clause.OrderByColumn{Column: clause.Column{Name: "sort"}, Desc: true}).Limit(1).Find(&systemConfigPay)
|
||||
database.Instance().Model(&models.SystemConfig{}).Where("config_type = 4").Order(clause.OrderByColumn{Column: clause.Column{Name: "sort"}, Desc: true}).Limit(1).Find(&systemConfigPay)
|
||||
if systemConfigPay.Name == "payOff" {
|
||||
orderCreatePreCheckResponse.PayType = 0
|
||||
orderCreatePreCheckResponse.PayType = 1
|
||||
}
|
||||
|
||||
Success(ctx, orderCreateRequest, orderCreatePreCheckResponse)
|
||||
|
|
@ -486,6 +486,7 @@ func GetOrderDetail(orderId string) OrderDetail {
|
|||
Discount: float64(orderSub.Discount),
|
||||
Goods: goods,
|
||||
Coupons: nil,
|
||||
CouponsAmount: "0",
|
||||
}
|
||||
if coupons.Id > 0 {
|
||||
orderSubR1.Coupons = &models.Coupons{
|
||||
|
|
@ -545,7 +546,7 @@ func GetOrderDetail(orderId string) OrderDetail {
|
|||
}
|
||||
|
||||
func checkOrderServiceTime(serviceTime string, projectionServiceTime int) bool {
|
||||
type orderMainTmp struct {
|
||||
/*type orderMainTmp struct {
|
||||
ServiceTime string
|
||||
ProjectionServiceTime int
|
||||
}
|
||||
|
|
@ -564,7 +565,7 @@ func checkOrderServiceTime(serviceTime string, projectionServiceTime int) bool {
|
|||
//时间点订单数量<服务车辆*车辆单次服务数量 才可接受预约
|
||||
if len(orderMainTmpList) > 0 {
|
||||
return len(orderMainTmpList) >= len(CarMap)*CarServiceNum
|
||||
}
|
||||
}*/
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
@ -806,9 +807,10 @@ func (p DefParty) orderServiceTime() web_iris.Party {
|
|||
var orderMainTmp1 []struct {
|
||||
ServiceTime string
|
||||
Count int
|
||||
ProjectionServiceTime int
|
||||
}
|
||||
err := database.Instance().Raw(`
|
||||
SELECT service_time, COUNT(1) AS count
|
||||
SELECT service_time, COUNT(1) AS count, projection_service_time
|
||||
FROM order_mains
|
||||
WHERE service_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
||||
AND order_status != 3
|
||||
|
|
@ -825,8 +827,10 @@ func (p DefParty) orderServiceTime() web_iris.Party {
|
|||
var orderTimeMap = make(map[string]string)
|
||||
var orderTimeNum = make(map[string]int)
|
||||
var orderTimeCount = make(map[string]int)
|
||||
var orderProjectionTime = make(map[string]int)
|
||||
for _, val := range orderMainTmp1 {
|
||||
orderTimeCount[val.ServiceTime] = val.Count
|
||||
orderProjectionTime[val.ServiceTime] = val.ProjectionServiceTime
|
||||
}
|
||||
|
||||
for _, value := range orderMainTmpList {
|
||||
|
|
@ -838,15 +842,18 @@ func (p DefParty) orderServiceTime() web_iris.Party {
|
|||
lastDate := date.Add(time.Minute * time.Duration(value.ProjectionServiceTime))
|
||||
for t := date; t.Before(lastDate); t = t.Add(time.Hour) {
|
||||
timeStr := t.Format("2006-01-02 15:04")
|
||||
if timeStr != value.ServiceTime {
|
||||
orderTimeMap[timeStr] = timeStr
|
||||
orderTimeNum[timeStr] = orderTimeNum[timeStr] + 1
|
||||
orderTimeCount[timeStr] = orderTimeCount[timeStr] + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
serviceTime := AddrServiceMap[orderServiceTimeRequest.ServiceAddrId]
|
||||
times := strings.Split(serviceTime.Times, ",")
|
||||
carNum := len(CarMap)
|
||||
daysMap := utils.GetStrDays(7, 60, ReserveMap, orderTimeMap, carNum, orderTimeNum, CarServiceNum, times, orderTimeCount)
|
||||
daysMap := utils.GetStrDays(7, 60, ReserveMap, orderTimeMap, carNum, orderTimeNum, CarServiceNum, times, orderTimeCount, orderProjectionTime)
|
||||
var dayHoursMap = make(map[string][]TimeObject)
|
||||
for day, values := range daysMap {
|
||||
key := day
|
||||
|
|
|
|||
|
|
@ -42,3 +42,18 @@ func (p DefParty) systemBanners() web_iris.Party {
|
|||
})
|
||||
}}
|
||||
}
|
||||
|
||||
type PayoffResponse struct {
|
||||
Payoff bool `json:"payoff"`
|
||||
}
|
||||
|
||||
// 获取支付开关
|
||||
func (p DefParty) getPayoff() web_iris.Party {
|
||||
return web_iris.Party{Prefix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||
index.Post(System+"/getPayoff", func(ctx *context.Context) {
|
||||
var systemConfigPayOnOff models.SystemConfig
|
||||
database.Instance().Model(&models.SystemConfig{}).Where("config_type = 4").Order(clause.OrderByColumn{Column: clause.Column{Name: "sort"}, Desc: true}).Limit(1).Find(&systemConfigPayOnOff)
|
||||
Success(ctx, nil, PayoffResponse{systemConfigPayOnOff.Name == "payOff"})
|
||||
})
|
||||
}}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ type TimeObject struct {
|
|||
Y bool `json:"y"`
|
||||
}
|
||||
|
||||
func GetStrDays(day int, minute int, reserveMap map[string]models.ReserveTimeFilter, orderTimeMap map[string]string, carNum int, orderNumMap map[string]int, carServiceNum int, times []string, orderTimeCount map[string]int) map[string][]TimeObject {
|
||||
func GetStrDays(day int, minute int, reserveMap map[string]models.ReserveTimeFilter, orderTimeMap map[string]string, carNum int, orderNumMap map[string]int, carServiceNum int, times []string, orderTimeCount map[string]int, projectionTime map[string]int) map[string][]TimeObject {
|
||||
// 获取当前时间
|
||||
currentTime := time.Now()
|
||||
// 计算半小时后的时间
|
||||
|
|
@ -51,14 +51,12 @@ func GetStrDays(day int, minute int, reserveMap map[string]models.ReserveTimeFil
|
|||
serviceDaysMap[dayTime] = dayTime
|
||||
}
|
||||
for nextHour.Before(oneWeekLater) {
|
||||
//且不存在过滤时间中
|
||||
_, existsDay := reserveMap[nextHour.Format("2006-01-02")]
|
||||
_, existsHour := reserveMap[nextHour.Format("15")]
|
||||
_, existOrderTime := orderTimeMap[nextHour.Format("2006-01-02 15:04")]
|
||||
orderNum, existOrderNum := orderNumMap[nextHour.Format("2006-01-02 15:04")]
|
||||
if (nextHour.Hour() >= workStart && nextHour.Hour() < workEnd) && (!existsDay && !existsHour) && !existOrderTime {
|
||||
key := nextHour.Format("2006-01-02")
|
||||
key1 := nextHour.Format("2006-01-02 15:04")
|
||||
if nextHour.Hour() < workStart || nextHour.Hour() > workEnd {
|
||||
nextHour = nextHour.Add(time.Duration(minute) * time.Minute)
|
||||
continue
|
||||
}
|
||||
if _, ok := serviceDaysMap[key1]; len(serviceDaysMap) > 0 && !ok {
|
||||
//不存在服务配置中返回false
|
||||
dayHoursMap[key] = append(dayHoursMap[key], TimeObject{
|
||||
|
|
@ -68,6 +66,12 @@ func GetStrDays(day int, minute int, reserveMap map[string]models.ReserveTimeFil
|
|||
nextHour = nextHour.Add(time.Duration(minute) * time.Minute)
|
||||
continue
|
||||
}
|
||||
//且不存在过滤时间中
|
||||
_, existsDay := reserveMap[nextHour.Format("2006-01-02")]
|
||||
_, existsHour := reserveMap[nextHour.Format("15")]
|
||||
_, existOrderTime := orderTimeMap[nextHour.Format("2006-01-02 15:04")]
|
||||
orderNum, existOrderNum := orderNumMap[nextHour.Format("2006-01-02 15:04")]
|
||||
if (!existsDay && !existsHour) && !existOrderTime {
|
||||
if _, ok := dayHoursMap[key]; ok {
|
||||
dayHoursMap[key] = append(dayHoursMap[key], TimeObject{
|
||||
Time: nextHour.Format("15:04"),
|
||||
|
|
@ -98,8 +102,9 @@ func GetStrDays(day int, minute int, reserveMap map[string]models.ReserveTimeFil
|
|||
} else if nextHour.Hour() >= workStart && nextHour.Hour() < workEnd {
|
||||
//查看当前时间对应的订单数量
|
||||
orderCount := orderTimeCount[key1]
|
||||
//预约时间对应的订单数<车辆数量 当前时间可以预约
|
||||
if orderCount < carNum*carServiceNum {
|
||||
time := projectionTime[key1]
|
||||
//预约时间对应的订单数<车辆数量 当前时间可以预约 且是1笔订单
|
||||
if orderCount < carNum*carServiceNum && time > 60 {
|
||||
dayHoursMap[key] = append(dayHoursMap[key], TimeObject{
|
||||
Time: nextHour.Format("15:04"),
|
||||
Y: true,
|
||||
|
|
|
|||
Loading…
Reference in New Issue