From 42eb05c210643fa2c8a25b5cdbacb2e368c09ed4 Mon Sep 17 00:00:00 2001 From: "qiyunfanbo126.com" <815699> Date: Wed, 17 Jul 2024 14:34:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9:=E6=9C=AA=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E8=AE=A2=E5=8D=9515=E5=88=86=E9=92=9F=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8F=96=E6=B6=88=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=BA=93=E5=AD=98?= =?UTF-8?q?=EF=BC=8C=E8=B4=AD=E4=B9=B0=E5=B0=B1=E5=87=8F=E5=BA=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/console/command.go | 2 +- app/constants/errorcode/error_code.go | 4 +++- app/services/OrderService.go | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/console/command.go b/app/console/command.go index 944d6ca..ae94f39 100644 --- a/app/console/command.go +++ b/app/console/command.go @@ -13,7 +13,7 @@ func RegisterCommand(c *command.Command) { } func ClearUnpayOrder() { - var expire = time.Now().Add(-1 * time.Minute).Format(time.DateTime) + var expire = time.Now().Add(-15 * time.Minute).Format(time.DateTime) var orders []ordersmodel.Orders ordersmodel.GetInstance().GetDb().Where("state = 1 and create_time <= ?", expire).Select("id,product_id").Find(&orders) var ids = make([]int, 0) diff --git a/app/constants/errorcode/error_code.go b/app/constants/errorcode/error_code.go index 777775b..d49b67b 100644 --- a/app/constants/errorcode/error_code.go +++ b/app/constants/errorcode/error_code.go @@ -42,7 +42,8 @@ const ( //邮储服务异常 YouChuOrderRefundFail = 2004 //用户不存在 - UserNotExist = 2005 + UserNotExist = 2005 + ProdcutDiscard = 2006 // 更新失败 InsertUserFail = 3001 @@ -81,6 +82,7 @@ var MsgZH = map[int]string{ Fail: "请求失败", YouChuCodeFail: "Code解析失败", YouChuCustNoEmpty: "客户编号为空", + ProdcutDiscard: "产品已下架", } var MsgMap map[string]map[int]string = map[string]map[int]string{"en": MsgZH} diff --git a/app/services/OrderService.go b/app/services/OrderService.go index 5c275a0..dac7836 100644 --- a/app/services/OrderService.go +++ b/app/services/OrderService.go @@ -43,6 +43,9 @@ func CreateOrderService(userId int, productId int) (code int, data front.InsertO }() var product productsmodel.Products has, err := productsmodel.GetInstance().GetDb().Where("id = ? and status = 1", productId).Get(&product) + if !has { + return errorcode.SystemError, data + } if err != nil { return errorcode.SystemError, data }