新增逻辑
This commit is contained in:
parent
74ae25bcd0
commit
d002f47478
|
|
@ -1,9 +1,59 @@
|
||||||
package api
|
package api
|
||||||
|
|
||||||
import "pet-house.com/business/models"
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"github.com/kataras/iris/v12"
|
||||||
|
"github.com/kataras/iris/v12/context"
|
||||||
|
"io"
|
||||||
|
"pet-house.com/business/models"
|
||||||
|
"pet-house.com/core/server/database"
|
||||||
|
"pet-house.com/core/server/web/web_iris"
|
||||||
|
)
|
||||||
|
|
||||||
var CarServiceNum = 2
|
var CarServiceNum = 1
|
||||||
|
|
||||||
func GetCarInfo(carId int) models.ServiceCar {
|
func GetCarInfo(carId int) models.ServiceCar {
|
||||||
return CarMap[carId]
|
return CarMap[carId]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CarServiceOrderListRequest struct {
|
||||||
|
Status int //订单状态 0所有 1待服务 2服务中 3已完成
|
||||||
|
PageNo int //页码
|
||||||
|
PageSize int //数据数量
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type CarServiceOrderListResponse struct {
|
||||||
|
OrderDetails []OrderDetail `json:"orderDetails"`
|
||||||
|
PageNo int `json:"pageNo"`
|
||||||
|
PageSize int `json:"pageSize"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// carServiceOrderList 车辆订单列表
|
||||||
|
func (p DefParty) carServiceOrderList() web_iris.Party {
|
||||||
|
return web_iris.Party{Prefix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||||
|
index.Post(CarBase+"/carServiceOrderList", func(ctx *context.Context) {
|
||||||
|
headerBaseInfo := GetHeaderBaseInfo(ctx)
|
||||||
|
body, _ := io.ReadAll(ctx.Request().Body)
|
||||||
|
var carServiceOrderListRequest CarServiceOrderListRequest
|
||||||
|
json.Unmarshal(body, &carServiceOrderListRequest)
|
||||||
|
var serviceCarUser models.ServiceCarUser
|
||||||
|
database.Instance().Model(&models.ServiceCarUser{}).Where("uid = ?", headerBaseInfo.Uid).Find(&serviceCarUser)
|
||||||
|
if serviceCarUser.Id == 0 {
|
||||||
|
CarNotExistError.Fail(ctx, headerBaseInfo)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var orderMains []models.OrderMain
|
||||||
|
if carServiceOrderListRequest.Status == 0 {
|
||||||
|
database.Instance().Model(&models.OrderMain{}).Joins("JOIN car_orders ON order_mains.order_id = car_orders.order_id").Where("car_orders.car_id = ? AND order_mains.status > 0", serviceCarUser.CarId).Offset((carServiceOrderListRequest.PageNo - 1) * carServiceOrderListRequest.PageSize).Limit(carServiceOrderListRequest.PageSize).Find(&orderMains)
|
||||||
|
} else {
|
||||||
|
database.Instance().Model(&models.OrderMain{}).Joins("JOIN car_orders ON order_mains.order_id = car_orders.order_id").Where("car_orders.car_id = ? AND order_mains.status = ?", serviceCarUser.CarId, carServiceOrderListRequest.Status).Offset((carServiceOrderListRequest.PageNo - 1) * carServiceOrderListRequest.PageSize).Limit(carServiceOrderListRequest.PageSize).Find(&orderMains)
|
||||||
|
}
|
||||||
|
var orderDetails []OrderDetail
|
||||||
|
for _, value := range orderMains {
|
||||||
|
orderDetails = append(orderDetails, GetOrderDetail(value.OrderId))
|
||||||
|
}
|
||||||
|
Success(ctx, carServiceOrderListRequest, CarServiceOrderListResponse{orderDetails, carServiceOrderListRequest.PageNo + 1, carServiceOrderListRequest.PageSize})
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,9 @@ var (
|
||||||
NotInServiceExistError = Error{Code: 209, Msg: "不在服务范围"}
|
NotInServiceExistError = Error{Code: 209, Msg: "不在服务范围"}
|
||||||
OrderCreateError = Error{Code: 210, Msg: "订单创建失败"}
|
OrderCreateError = Error{Code: 210, Msg: "订单创建失败"}
|
||||||
LoginError = Error{Code: 211, Msg: "授权登录失败"}
|
LoginError = Error{Code: 211, Msg: "授权登录失败"}
|
||||||
|
OrderError = Error{Code: 212, Msg: "当前订单无法修改"}
|
||||||
|
CarNotExistError = Error{Code: 213, Msg: "当前用户未关联车辆"}
|
||||||
|
OrderExistError = Error{Code: 214, Msg: "订单不存在"}
|
||||||
)
|
)
|
||||||
|
|
||||||
func Success(ctx *context.Context, request any, data any) {
|
func Success(ctx *context.Context, request any, data any) {
|
||||||
|
|
|
||||||
|
|
@ -7,25 +7,35 @@ var GoodsBase = "/goods"
|
||||||
var OrderBase = "/order"
|
var OrderBase = "/order"
|
||||||
var ServiceBase = "/service"
|
var ServiceBase = "/service"
|
||||||
var PetBase = "/pet"
|
var PetBase = "/pet"
|
||||||
|
var CarBase = "/car"
|
||||||
|
|
||||||
func (p DefParty) RegisterList() []web_iris.Party {
|
func (p DefParty) RegisterList() []web_iris.Party {
|
||||||
ps := []web_iris.Party{
|
ps := []web_iris.Party{
|
||||||
|
//用户
|
||||||
p.login(),
|
p.login(),
|
||||||
p.getUserInfo(),
|
p.getUserInfo(),
|
||||||
|
//商品
|
||||||
p.goodsList(),
|
p.goodsList(),
|
||||||
p.goodsDetail(),
|
p.goodsDetail(),
|
||||||
|
//订单
|
||||||
p.orderCreate(),
|
p.orderCreate(),
|
||||||
p.orderServiceTime(),
|
p.orderServiceTime(),
|
||||||
p.orderList(),
|
p.orderList(),
|
||||||
|
p.orderEdit(),
|
||||||
|
p.orderDetail(),
|
||||||
p.orderPay(),
|
p.orderPay(),
|
||||||
|
//宠物
|
||||||
p.petList(),
|
p.petList(),
|
||||||
p.petInfo(),
|
p.petInfo(),
|
||||||
p.petTypeList(),
|
p.petTypeList(),
|
||||||
p.petAddOrEdit(),
|
p.petAddOrEdit(),
|
||||||
p.delPet(),
|
p.delPet(),
|
||||||
|
//服务地址
|
||||||
p.serviceAddrList(),
|
p.serviceAddrList(),
|
||||||
p.serviceAddOrEdit(),
|
p.serviceAddOrEdit(),
|
||||||
p.serviceAreaAddrList(),
|
p.serviceAreaAddrList(),
|
||||||
|
//车辆
|
||||||
|
p.carServiceOrderList(),
|
||||||
p.index(),
|
p.index(),
|
||||||
}
|
}
|
||||||
return ps
|
return ps
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"pet-house.com/core/server/database"
|
"pet-house.com/core/server/database"
|
||||||
"pet-house.com/core/server/web/web_iris"
|
"pet-house.com/core/server/web/web_iris"
|
||||||
"pet-house.com/core/server/zap_server"
|
"pet-house.com/core/server/zap_server"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -29,6 +30,8 @@ type OrderCreateResponse struct {
|
||||||
OrderDetail OrderDetail `json:"orderDetail"`
|
OrderDetail OrderDetail `json:"orderDetail"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var orderLock sync.Mutex
|
||||||
|
|
||||||
// 创建
|
// 创建
|
||||||
func (p DefParty) orderCreate() web_iris.Party {
|
func (p DefParty) orderCreate() web_iris.Party {
|
||||||
return web_iris.Party{Prefix: p.Prefix, PartyFunc: func(index iris.Party) {
|
return web_iris.Party{Prefix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||||
|
|
@ -48,11 +51,17 @@ func (p DefParty) orderCreate() web_iris.Party {
|
||||||
ServiceAddrNotExistError.Fail(ctx, nil)
|
ServiceAddrNotExistError.Fail(ctx, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
haveReserve := checkOrderServiceTime(orderCreateRequest.ServiceTime)
|
||||||
|
if haveReserve {
|
||||||
|
OrderCreateError.DefFail(ctx, orderCreateRequest, "当前时间点不可预约")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
orderLock.Lock()
|
||||||
orderId := NextId.Generate().String()
|
orderId := NextId.Generate().String()
|
||||||
orderMain := models.OrderMain{
|
orderMain := models.OrderMain{
|
||||||
OrderId: orderId,
|
OrderId: orderId,
|
||||||
Uid: headerBaseInfo.Uid,
|
Uid: headerBaseInfo.Uid,
|
||||||
Status: 1,
|
Status: 0,
|
||||||
ServiceTime: orderCreateRequest.ServiceTime,
|
ServiceTime: orderCreateRequest.ServiceTime,
|
||||||
ServiceAddrId: orderCreateRequest.ServiceAddrId,
|
ServiceAddrId: orderCreateRequest.ServiceAddrId,
|
||||||
ServiceRemark: "",
|
ServiceRemark: "",
|
||||||
|
|
@ -85,14 +94,23 @@ func (p DefParty) orderCreate() web_iris.Party {
|
||||||
db2 := tx.Model(&models.OrderMain{}).Create(&orderMain)
|
db2 := tx.Model(&models.OrderMain{}).Create(&orderMain)
|
||||||
if db.Error != nil || db1.Error != nil || db2.Error != nil {
|
if db.Error != nil || db1.Error != nil || db2.Error != nil {
|
||||||
tx.Callback()
|
tx.Callback()
|
||||||
|
orderLock.Unlock()
|
||||||
zap_server.ZAPLOG.Error("订单插入失败", zap.Any("db", db.Error), zap.Any("db1", db1.Error), zap.Any("db2", db2.Error))
|
zap_server.ZAPLOG.Error("订单插入失败", zap.Any("db", db.Error), zap.Any("db1", db1.Error), zap.Any("db2", db2.Error))
|
||||||
OrderCreateError.Fail(ctx, orderCreateRequest)
|
OrderCreateError.Fail(ctx, orderCreateRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
orderLock.Unlock()
|
||||||
|
Success(ctx, orderCreateRequest, OrderCreateResponse{GetOrderDetail(orderMain.OrderId)})
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetOrderDetail(orderId string) OrderDetail {
|
||||||
|
var orderMain models.OrderMain
|
||||||
|
database.Instance().Model(&models.OrderMain{}).Where("order_id = ?", orderId).Find(&orderMain)
|
||||||
var findUserServiceAddr models.UserServiceAddr
|
var findUserServiceAddr models.UserServiceAddr
|
||||||
database.Instance().Model(&models.UserServiceAddr{}).Where("id = ? and uid = ?", orderMain.ServiceAddrId, headerBaseInfo.Uid).Find(&findUserServiceAddr)
|
database.Instance().Model(&models.UserServiceAddr{}).Where("id = ?", orderMain.ServiceAddrId).Find(&findUserServiceAddr)
|
||||||
orderDetail := OrderDetail{
|
orderDetail := OrderDetail{
|
||||||
OrderId: orderMain.OrderId,
|
OrderId: orderMain.OrderId,
|
||||||
Status: orderMain.Status,
|
Status: orderMain.Status,
|
||||||
|
|
@ -102,6 +120,8 @@ func (p DefParty) orderCreate() web_iris.Party {
|
||||||
CreateTime: orderMain.CreateTime.String(),
|
CreateTime: orderMain.CreateTime.String(),
|
||||||
}
|
}
|
||||||
var subOrderList []SubOrder
|
var subOrderList []SubOrder
|
||||||
|
var orderSubList []models.OrderSub
|
||||||
|
database.Instance().Model(&models.OrderSub{}).Where("main_order_id = ? ", orderMain.OrderId).Find(&orderSubList)
|
||||||
for _, orderSub := range orderSubList {
|
for _, orderSub := range orderSubList {
|
||||||
var orderDetailList []models.OrderDetail
|
var orderDetailList []models.OrderDetail
|
||||||
database.Instance().Model(&models.OrderDetail{}).Where("sub_order_id = ? ", orderSub.OrderId).Find(&orderDetailList)
|
database.Instance().Model(&models.OrderDetail{}).Where("sub_order_id = ? ", orderSub.OrderId).Find(&orderDetailList)
|
||||||
|
|
@ -113,18 +133,37 @@ func (p DefParty) orderCreate() web_iris.Party {
|
||||||
orderSub := SubOrder{
|
orderSub := SubOrder{
|
||||||
OrderId: orderSub.OrderId,
|
OrderId: orderSub.OrderId,
|
||||||
Status: orderSub.Status,
|
Status: orderSub.Status,
|
||||||
UserPetInfo: GetUserPet(headerBaseInfo.Uid, orderSub.PetId),
|
UserPetInfo: GetUserPet(orderMain.Uid, orderSub.PetId),
|
||||||
TotalAmount: orderSub.TotalAmount,
|
TotalAmount: orderSub.TotalAmount,
|
||||||
PayAmount: orderSub.PayAmount,
|
PayAmount: orderSub.PayAmount,
|
||||||
Goods: goods,
|
Goods: goods,
|
||||||
}
|
}
|
||||||
subOrderList = append(subOrderList, orderSub)
|
subOrderList = append(subOrderList, orderSub)
|
||||||
}
|
}
|
||||||
|
var carOrder models.CarOrder
|
||||||
|
database.Instance().Model(&models.CarOrder{}).Where("order_id = ?", orderMain.OrderId).Find(&carOrder)
|
||||||
|
if carOrder.Id > 0 {
|
||||||
|
car := CarMap[carOrder.CarId]
|
||||||
|
orderDetail.ServiceCar = &car
|
||||||
|
} else {
|
||||||
|
orderDetail.ServiceCar = &models.ServiceCar{}
|
||||||
|
}
|
||||||
orderDetail.CreateTime = time.DateTime
|
orderDetail.CreateTime = time.DateTime
|
||||||
orderDetail.SubOrderList = subOrderList
|
orderDetail.SubOrderList = subOrderList
|
||||||
Success(ctx, orderCreateRequest, OrderCreateResponse{orderDetail})
|
return orderDetail
|
||||||
})
|
}
|
||||||
}}
|
|
||||||
|
func checkOrderServiceTime(serviceTime string) bool {
|
||||||
|
type orderMainTmp struct {
|
||||||
|
ServiceTime string
|
||||||
|
}
|
||||||
|
var orderMainTmpList []orderMainTmp
|
||||||
|
database.Instance().Model(&models.OrderMain{}).Where("service_time = ?", serviceTime).Find(&orderMainTmpList)
|
||||||
|
//时间点订单数量<服务车辆*车辆单次服务数量 才可接受预约
|
||||||
|
if len(orderMainTmpList) > 0 {
|
||||||
|
return len(orderMainTmpList) >= len(CarMap)*CarServiceNum
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
type OrderListRequest struct {
|
type OrderListRequest struct {
|
||||||
|
|
@ -135,7 +174,7 @@ type OrderListRequest struct {
|
||||||
|
|
||||||
type SubOrder struct {
|
type SubOrder struct {
|
||||||
OrderId string `json:"orderId"` //子订单ID
|
OrderId string `json:"orderId"` //子订单ID
|
||||||
Status int `json:"status"` //子订单状态 1待服务 2服务中 3已完成 4已取消
|
Status int `json:"status"` //子订单状态 0待派单 1待服务 2服务中 3已完成 4已取消
|
||||||
UserPetInfo UserPetInfo `json:"userPetInfo"` //用户宠物信息
|
UserPetInfo UserPetInfo `json:"userPetInfo"` //用户宠物信息
|
||||||
TotalAmount int32 `json:"totalAmount"` //总金额 单位:分
|
TotalAmount int32 `json:"totalAmount"` //总金额 单位:分
|
||||||
PayAmount int32 `json:"payAmount"` //实际支付金额 单位:分
|
PayAmount int32 `json:"payAmount"` //实际支付金额 单位:分
|
||||||
|
|
@ -144,16 +183,17 @@ type SubOrder struct {
|
||||||
|
|
||||||
type OrderDetail struct {
|
type OrderDetail struct {
|
||||||
OrderId string `json:"orderId"` //主订单号
|
OrderId string `json:"orderId"` //主订单号
|
||||||
Status int `json:"status"` //主订单状态 1待服务 2服务中 3已完成
|
Status int `json:"status"` //主订单状态 0待派单 1待服务 2服务中 3已完成 4已取消
|
||||||
ServiceTime string `json:"serviceTime"` //服务时间
|
ServiceTime string `json:"serviceTime"` //服务时间
|
||||||
ServiceAddr models.UserServiceAddr `json:"serviceAddr"` //服务地址信息
|
ServiceAddr models.UserServiceAddr `json:"serviceAddr"` //服务地址信息
|
||||||
ServiceRemark string `json:"serviceRemark"` //服务备注
|
ServiceRemark string `json:"serviceRemark"` //服务备注
|
||||||
CreateTime string `json:"createTime"` //创建时间
|
CreateTime string `json:"createTime"` //创建时间
|
||||||
SubOrderList []SubOrder `json:"subOrderList"` //子订单列表
|
SubOrderList []SubOrder `json:"subOrderList"` //子订单列表
|
||||||
|
ServiceCar *models.ServiceCar `json:"serviceCar"` //服务车辆 只有主订单状态为 1 2 3的时候才会存在
|
||||||
}
|
}
|
||||||
|
|
||||||
type OrderListResponse struct {
|
type OrderListResponse struct {
|
||||||
OrderDetail []OrderDetail `json:"orderDetail"` //订单列表
|
OrderDetails []OrderDetail `json:"orderDetails"` //订单列表
|
||||||
PageNo int `json:"pageNo"` //页码
|
PageNo int `json:"pageNo"` //页码
|
||||||
PageSize int `json:"pageSize"` //数据数量
|
PageSize int `json:"pageSize"` //数据数量
|
||||||
}
|
}
|
||||||
|
|
@ -213,8 +253,8 @@ func (p DefParty) orderList() web_iris.Party {
|
||||||
orderDetails = append(orderDetails, orderListResponse)
|
orderDetails = append(orderDetails, orderListResponse)
|
||||||
}
|
}
|
||||||
var orderListResponse = OrderListResponse{
|
var orderListResponse = OrderListResponse{
|
||||||
OrderDetail: orderDetails,
|
OrderDetails: orderDetails,
|
||||||
PageNo: orderListRequest.PageNo,
|
PageNo: orderListRequest.PageNo + 1,
|
||||||
PageSize: orderListRequest.PageSize,
|
PageSize: orderListRequest.PageSize,
|
||||||
}
|
}
|
||||||
Success(ctx, orderListRequest, orderListResponse)
|
Success(ctx, orderListRequest, orderListResponse)
|
||||||
|
|
@ -248,7 +288,7 @@ func (p DefParty) orderServiceTime() web_iris.Party {
|
||||||
orderTimeNum[value.ServiceTime] = orderTimeNum[value.ServiceTime] + 1
|
orderTimeNum[value.ServiceTime] = orderTimeNum[value.ServiceTime] + 1
|
||||||
}
|
}
|
||||||
carNum := len(CarMap)
|
carNum := len(CarMap)
|
||||||
daysMap := utils.GetStrDays(7, 30, ReserveMap, orderTimeMap, carNum, orderTimeNum, 2)
|
daysMap := utils.GetStrDays(7, 60, ReserveMap, orderTimeMap, carNum, orderTimeNum, CarServiceNum)
|
||||||
var dayHoursMap = make(map[string][]TimeObject)
|
var dayHoursMap = make(map[string][]TimeObject)
|
||||||
for day, values := range daysMap {
|
for day, values := range daysMap {
|
||||||
key := day
|
key := day
|
||||||
|
|
@ -272,6 +312,62 @@ func (p DefParty) orderServiceTime() web_iris.Party {
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type OrderEditRequest struct {
|
||||||
|
OrderId string //订单ID
|
||||||
|
Status int //订单状态 4取消
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改订单
|
||||||
|
func (p DefParty) orderEdit() web_iris.Party {
|
||||||
|
return web_iris.Party{Prefix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||||
|
index.Post(OrderBase+"/orderEdit", func(ctx *context.Context) {
|
||||||
|
headerBaseInfo := GetHeaderBaseInfo(ctx)
|
||||||
|
body, _ := io.ReadAll(ctx.Request().Body)
|
||||||
|
var orderEditRequest OrderEditRequest
|
||||||
|
json.Unmarshal(body, &orderEditRequest)
|
||||||
|
var orderMain models.OrderMain
|
||||||
|
var orderSub models.OrderSub
|
||||||
|
database.Instance().Model(&models.OrderSub{}).Where("order_id = ?", orderEditRequest.OrderId).Find(&orderSub)
|
||||||
|
database.Instance().Model(&models.OrderMain{}).Where("order_id = ?", orderSub.MainOrderId).Find(&orderMain)
|
||||||
|
if orderMain.Uid != headerBaseInfo.Uid {
|
||||||
|
OrderError.Fail(ctx, orderEditRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if orderSub.Status > 0 || orderEditRequest.Status == 0 {
|
||||||
|
OrderError.Fail(ctx, orderEditRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
orderSub.Status = orderEditRequest.Status
|
||||||
|
updateValues := map[string]interface{}{
|
||||||
|
"Status": orderSub.Status,
|
||||||
|
}
|
||||||
|
database.Instance().Model(&orderSub).Updates(&updateValues)
|
||||||
|
Success(ctx, orderEditRequest, GetOrderDetail(orderMain.OrderId))
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
type OrderDetailRequest struct {
|
||||||
|
OrderId string
|
||||||
|
}
|
||||||
|
|
||||||
|
// 订单详情
|
||||||
|
func (p DefParty) orderDetail() web_iris.Party {
|
||||||
|
return web_iris.Party{Prefix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||||
|
index.Post(OrderBase+"/orderDetail", func(ctx *context.Context) {
|
||||||
|
body, _ := io.ReadAll(ctx.Request().Body)
|
||||||
|
var orderDetailRequest OrderDetailRequest
|
||||||
|
json.Unmarshal(body, &orderDetailRequest)
|
||||||
|
orderDetail := GetOrderDetail(orderDetailRequest.OrderId)
|
||||||
|
if len(orderDetail.OrderId) == 0 {
|
||||||
|
OrderExistError.Fail(ctx, orderDetailRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Success(ctx, orderDetailRequest, orderDetail)
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
// 支付
|
// 支付
|
||||||
func (p DefParty) orderPay() web_iris.Party {
|
func (p DefParty) orderPay() web_iris.Party {
|
||||||
return web_iris.Party{Prefix: p.Prefix, PartyFunc: func(index iris.Party) {
|
return web_iris.Party{Prefix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ type CarOrder struct {
|
||||||
type ServiceCarUser struct {
|
type ServiceCarUser struct {
|
||||||
Id int `gorm:"primaryKey;autoIncrement" json:"id"` //id
|
Id int `gorm:"primaryKey;autoIncrement" json:"id"` //id
|
||||||
CarId int `gorm:"index;not null" json:"carId"` //车ID
|
CarId int `gorm:"index;not null" json:"carId"` //车ID
|
||||||
Uid int64 `gorm:"index;not null" json:"uid"` //用户ID
|
Uid int64 `gorm:"index;unique;not null" json:"uid"` //用户ID
|
||||||
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"-"` //创建时间
|
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"-"` //创建时间
|
||||||
UpdateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP" json:"-"` //更新时间
|
UpdateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP" json:"-"` //更新时间
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,18 +20,18 @@ type TimeObject struct {
|
||||||
Y bool `json:"y"`
|
Y bool `json:"y"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetStrDays(day int, hour int, reserveMap map[string]models.ReserveTimeFilter, orderTimeMap map[string]string, carNum int, orderNumMap map[string]int, carServiceNum 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) map[string][]TimeObject {
|
||||||
// 获取当前时间
|
// 获取当前时间
|
||||||
currentTime := time.Now()
|
currentTime := time.Now()
|
||||||
// 计算半小时后的时间
|
// 计算半小时后的时间
|
||||||
halfHourLater := currentTime.Add(time.Duration(hour) * time.Minute)
|
halfHourLater := currentTime.Add(time.Duration(minute) * time.Minute)
|
||||||
|
|
||||||
// 计算下一个整点时间
|
// 计算下一个整点时间
|
||||||
nextHour := time.Date(
|
nextHour := time.Date(
|
||||||
halfHourLater.Year(),
|
halfHourLater.Year(),
|
||||||
halfHourLater.Month(),
|
halfHourLater.Month(),
|
||||||
halfHourLater.Day(),
|
halfHourLater.Day(),
|
||||||
halfHourLater.Hour()+1, // 下一个整点小时
|
halfHourLater.Hour(), // 下一个整点小时
|
||||||
0, // 下一个整点分钟数为0
|
0, // 下一个整点分钟数为0
|
||||||
0, // 下一个整点秒数为0
|
0, // 下一个整点秒数为0
|
||||||
0, // 下一个整点纳秒数为0
|
0, // 下一个整点纳秒数为0
|
||||||
|
|
@ -93,7 +93,7 @@ func GetStrDays(day int, hour int, reserveMap map[string]models.ReserveTimeFilte
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
nextHour = nextHour.Add(30 * time.Minute) // 下一个整点半时间
|
nextHour = nextHour.Add(time.Duration(minute) * time.Minute) // 下一个整点半时间
|
||||||
}
|
}
|
||||||
return dayHoursMap
|
return dayHoursMap
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue