接口更新

This commit is contained in:
yiyan 2024-12-29 20:51:14 +08:00
parent da28f930a9
commit 54a082f8f1
1 changed files with 16 additions and 5 deletions

View File

@ -58,9 +58,15 @@ func (p DefParty) orderCreatePreCheck() web_iris.Party {
database.Instance().Model(&models.User{}).Where("id = ?", headerBaseInfo.Uid).Find(&userInfo)
var goodsDiscountAmount = 0
var goodsNotDiscountAmount = 0
var projectionServiceTime = 0
for _, value := range orderCreateRequest.PetGoodsInfos {
for _, gid := range value.GoodsIds {
goods := GoodsMap[gid]
if goods.Time != "/" && len(goods.Time) > 0 {
goodsTime, _ := strconv.Atoi(goods.Time)
projectionServiceTime += goodsTime
}
if value.Cid > 0 {
var userCouponsInfo models.UserCoupons
database.Instance().Model(&models.UserCoupons{}).Where("id = ?", value.Cid).Order(clause.OrderByColumn{Column: clause.Column{Name: "update_time"}, Desc: true}).Find(&userCouponsInfo)
@ -78,6 +84,11 @@ func (p DefParty) orderCreatePreCheck() web_iris.Party {
}
}
}
haveReserve := checkOrderServiceTime(orderCreateRequest.ServiceTime, projectionServiceTime)
if haveReserve {
OrderCreateError.DefFail(ctx, orderCreateRequest, "当前订单预估服务时长预计:"+strconv.Itoa(projectionServiceTime)+"分钟,服务时间过长,请更换时间段预约或联系客服协助预约")
return
}
orderCreatePreCheckResponse := OrderCreatePreCheckResponse{
HasAlert: false,
PayType: 0,
@ -150,11 +161,11 @@ func (p DefParty) orderCreate() web_iris.Party {
}
}
}
haveReserve := checkOrderServiceTime(orderCreateRequest.ServiceTime, projectionServiceTime)
/*haveReserve := checkOrderServiceTime(orderCreateRequest.ServiceTime, projectionServiceTime)
if haveReserve {
OrderCreateError.DefFail(ctx, orderCreateRequest, "当前订单预估服务时长预计:"+strconv.Itoa(projectionServiceTime)+"分钟,服务时间过长,请更换时间段预约或联系客服协助预约")
return
}
}*/
for _, value := range orderCreateRequest.PetGoodsInfos {
userPet := GetUserPet(headerBaseInfo.Uid, value.PetId)
if userPet.PetInfo.Vaccine == 0 {
@ -534,7 +545,7 @@ func GetOrderDetail(orderId string) OrderDetail {
}
func checkOrderServiceTime(serviceTime string, projectionServiceTime int) bool {
/*type orderMainTmp struct {
type orderMainTmp struct {
ServiceTime string
ProjectionServiceTime int
}
@ -552,8 +563,8 @@ func checkOrderServiceTime(serviceTime string, projectionServiceTime int) bool {
database.Instance().Model(&models.OrderMain{}).Where("service_time >= ? and service_time < DATE_FORMAT(DATE_ADD('"+serviceTime+"', INTERVAL "+strconv.Itoa(projectionServiceTime)+" MINUTE), '%Y-%m-%d %H:%i') and order_status != 3 and order_status != 4 and status = 1", serviceTime).Find(&orderMainTmpList)
//时间点订单数量<服务车辆*车辆单次服务数量 才可接受预约
if len(orderMainTmpList) > 0 {
return len(orderMainTmpList) >= len(CarMap)*CarServiceNum
}*/
return len(orderMainTmpList) < len(CarMap)*CarServiceNum
}
return false
}