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 }