修改:未支付订单15分钟自动取消,增加库存,购买就减库存

This commit is contained in:
qiyunfanbo126.com 2024-07-17 14:34:25 +08:00
parent 8ef1e5ba09
commit 42eb05c210
3 changed files with 7 additions and 2 deletions

View File

@ -13,7 +13,7 @@ func RegisterCommand(c *command.Command) {
} }
func ClearUnpayOrder() { 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 var orders []ordersmodel.Orders
ordersmodel.GetInstance().GetDb().Where("state = 1 and create_time <= ?", expire).Select("id,product_id").Find(&orders) ordersmodel.GetInstance().GetDb().Where("state = 1 and create_time <= ?", expire).Select("id,product_id").Find(&orders)
var ids = make([]int, 0) var ids = make([]int, 0)

View File

@ -42,7 +42,8 @@ const (
//邮储服务异常 //邮储服务异常
YouChuOrderRefundFail = 2004 YouChuOrderRefundFail = 2004
//用户不存在 //用户不存在
UserNotExist = 2005 UserNotExist = 2005
ProdcutDiscard = 2006
// 更新失败 // 更新失败
InsertUserFail = 3001 InsertUserFail = 3001
@ -81,6 +82,7 @@ var MsgZH = map[int]string{
Fail: "请求失败", Fail: "请求失败",
YouChuCodeFail: "Code解析失败", YouChuCodeFail: "Code解析失败",
YouChuCustNoEmpty: "客户编号为空", YouChuCustNoEmpty: "客户编号为空",
ProdcutDiscard: "产品已下架",
} }
var MsgMap map[string]map[int]string = map[string]map[int]string{"en": MsgZH} var MsgMap map[string]map[int]string = map[string]map[int]string{"en": MsgZH}

View File

@ -43,6 +43,9 @@ func CreateOrderService(userId int, productId int) (code int, data front.InsertO
}() }()
var product productsmodel.Products var product productsmodel.Products
has, err := productsmodel.GetInstance().GetDb().Where("id = ? and status = 1", productId).Get(&product) has, err := productsmodel.GetInstance().GetDb().Where("id = ? and status = 1", productId).Get(&product)
if !has {
return errorcode.SystemError, data
}
if err != nil { if err != nil {
return errorcode.SystemError, data return errorcode.SystemError, data
} }