- fixed load pending orders.

This commit is contained in:
gazebo
2018-07-25 11:19:23 +08:00
parent 38dc61a0bc
commit f3df85c8e0
4 changed files with 79 additions and 61 deletions

View File

@@ -22,6 +22,7 @@ func NewWaybillManager() *WaybillController {
func (w *WaybillController) LoadPendingWaybills() []*model.Waybill {
db := orm.NewOrm()
var bills []*model.Waybill
tillTime := time.Now().Add(-pendingOrderGapMax)
_, err := db.Raw(`
SELECT t1.*
FROM waybill t1
@@ -29,11 +30,9 @@ func (w *WaybillController) LoadPendingWaybills() []*model.Waybill {
AND t2.vendor_id = t1.order_vendor_id
AND t2.order_created_at >= ?
AND t2.status < ?
WHERE waybill_created_at >= ?
WHERE t1.waybill_created_at >= ?
AND t1.status < ?
ORDER by waybill_created_at
`, time.Now().Add(-pendingOrderGapMax), model.WaybillStatusEndBegin,
time.Now().Add(-pendingOrderGapMax), model.WaybillStatusEndBegin).QueryRows(&bills)
`, tillTime, model.OrderStatusEndBegin, tillTime, model.WaybillStatusEndBegin).QueryRows(&bills)
if err != nil {
globals.SugarLogger.Warnf("LoadPendingWaybills load pending waybills error:%v", err)
return nil