|
|
@ -13,7 +13,7 @@ import ( |
|
|
|
) |
|
|
|
|
|
|
|
func init() { |
|
|
|
go loopUnifiedOrder() |
|
|
|
go loopOrder() |
|
|
|
go utils.HandleTicker(1*time.Hour, HandleReward) // 打赏24小时退款
|
|
|
|
} |
|
|
|
|
|
|
@ -23,7 +23,7 @@ func PutOrderDelayQueue(order *models.UserOrder) { |
|
|
|
orderDelayQueue <- order |
|
|
|
} |
|
|
|
|
|
|
|
func loopUnifiedOrder() { |
|
|
|
func loopOrder() { |
|
|
|
orders, err := models.GetUserOrdersByStatus(0, 3) |
|
|
|
if err != nil { |
|
|
|
panic(err) |
|
|
@ -39,7 +39,7 @@ func loopUnifiedOrder() { |
|
|
|
} |
|
|
|
// 重启
|
|
|
|
time.Sleep(5 * time.Second) |
|
|
|
loopUnifiedOrder() |
|
|
|
loopOrder() |
|
|
|
}() |
|
|
|
for { |
|
|
|
select { |
|
|
@ -49,11 +49,11 @@ func loopUnifiedOrder() { |
|
|
|
} |
|
|
|
if order.ExpireAt <= time.Now().Unix() { // 订单超时
|
|
|
|
if order.Status == 0 { |
|
|
|
err = Close(order.OutTradeNo) // 超时关闭订单
|
|
|
|
if err != nil { |
|
|
|
logger.Error("订单关闭出现错误: 错误原因->", err) |
|
|
|
} |
|
|
|
order.Status = 5 |
|
|
|
//err = Close(order.OutTradeNo) // 超时关闭订单
|
|
|
|
//if err != nil {
|
|
|
|
// logger.Error("订单关闭出现错误: 错误原因->", err)
|
|
|
|
//}
|
|
|
|
//order.Status = 5
|
|
|
|
go HandleFailed(order) |
|
|
|
} |
|
|
|
continue |
|
|
@ -249,6 +249,11 @@ func HandleSuccess(order *models.UserOrder) error { |
|
|
|
func HandleFailed(order *models.UserOrder) error { |
|
|
|
// 退还库存
|
|
|
|
if order.GoodType == 4 { |
|
|
|
err := Close(order.OutTradeNo) |
|
|
|
if err != nil { |
|
|
|
err = fmt.Errorf("直播订单关闭错误: err-> %v, out_trade_no-> %+v", err, order.OutTradeNo) |
|
|
|
return err |
|
|
|
} |
|
|
|
customerOrder := new(models.CustomerOrder) |
|
|
|
exist, err := customerOrder.GetByOutTradeNO(order.OutTradeNo) |
|
|
|
if err != nil || !exist { |
|
|
|