From 54a082f8f15d7784699186f6b766fd6a07b47f69 Mon Sep 17 00:00:00 2001 From: yiyan Date: Sun, 29 Dec 2024 20:51:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/api/order.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/business/api/order.go b/business/api/order.go index 02ced43..8aa0ee6 100644 --- a/business/api/order.go +++ b/business/api/order.go @@ -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 }