修改:未支付订单15分钟自动取消,增加库存,购买就减库存
This commit is contained in:
parent
8ef1e5ba09
commit
42eb05c210
|
@ -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)
|
||||
|
|
|
@ -43,6 +43,7 @@ const (
|
|||
YouChuOrderRefundFail = 2004
|
||||
//用户不存在
|
||||
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}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue