- GetStoreOrderCountInfo2
This commit is contained in:
@@ -148,7 +148,7 @@ func (c *OrderManager) OnOrderStatusChanged(orderStatus *model.OrderStatus) (err
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
isDuplicated, err := c.addOrderStatus(orderStatus, db)
|
||||
isDuplicated, _, err := c.addOrderStatus(orderStatus, db)
|
||||
if err == nil {
|
||||
dao.Commit(db)
|
||||
if !isDuplicated {
|
||||
@@ -161,7 +161,7 @@ func (c *OrderManager) OnOrderStatusChanged(orderStatus *model.OrderStatus) (err
|
||||
}
|
||||
|
||||
func (c *OrderManager) OnOrderMsg(order *model.GoodsOrder, vendorStatus, remark string) (err error) {
|
||||
_, err = c.addOrderStatus(&model.OrderStatus{
|
||||
_, _, err = c.addOrderStatus(&model.OrderStatus{
|
||||
VendorOrderID: order.VendorOrderID,
|
||||
VendorID: order.VendorID,
|
||||
OrderType: model.OrderTypeOrder,
|
||||
@@ -345,13 +345,13 @@ func (c *OrderManager) updateOrderOtherInfo(order *model.GoodsOrder, db *dao.Dao
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *OrderManager) addOrderStatus(orderStatus *model.OrderStatus, db *dao.DaoDB) (isDuplicated bool, err error) {
|
||||
func (c *OrderManager) addOrderStatus(orderStatus *model.OrderStatus, db *dao.DaoDB) (isDuplicated bool, order *model.GoodsOrder, err error) {
|
||||
if db == nil {
|
||||
db = dao.GetDB()
|
||||
}
|
||||
isDuplicated, err = addOrderOrWaybillStatus(orderStatus, db)
|
||||
if err == nil && !isDuplicated && model.IsOrderImportantStatus(orderStatus.Status) {
|
||||
order := &model.GoodsOrder{
|
||||
order = &model.GoodsOrder{
|
||||
VendorOrderID: orderStatus.VendorOrderID,
|
||||
VendorID: orderStatus.VendorID,
|
||||
}
|
||||
@@ -396,7 +396,7 @@ func (c *OrderManager) addOrderStatus(orderStatus *model.OrderStatus, db *dao.Da
|
||||
}
|
||||
}
|
||||
}
|
||||
return isDuplicated, err
|
||||
return isDuplicated, order, err
|
||||
}
|
||||
|
||||
func (c *OrderManager) loadOrder(vendorOrderID, vendorOrderID2 string, vendorID int) (order *model.GoodsOrder, err error) {
|
||||
|
||||
@@ -27,6 +27,7 @@ type tWaybillExt struct {
|
||||
StoreID int `json:"storeID" orm:"column(store_id)"`
|
||||
}
|
||||
|
||||
//此函数会被GetStoreOrderCountInfo2取代
|
||||
func (c *OrderManager) GetStoreOrderCountInfo(ctx *jxcontext.Context, storeID string, lastHours int) (countInfo []*model.GoodsOrderCountInfo, err error) {
|
||||
globals.SugarLogger.Debugf("GetStoreOrderCountInfo storeID:%s", storeID)
|
||||
if lastHours > maxLastHours {
|
||||
@@ -51,6 +52,30 @@ func (c *OrderManager) GetStoreOrderCountInfo(ctx *jxcontext.Context, storeID st
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (c *OrderManager) GetStoreOrderCountInfo2(ctx *jxcontext.Context, storeID, lastHours int) (countInfo []*model.GoodsOrderCountInfo2, err error) {
|
||||
globals.SugarLogger.Debugf("GetStoreOrderCountInfo2 storeID:%s", storeID)
|
||||
if lastHours > maxLastHours {
|
||||
lastHours = maxLastHours
|
||||
} else if lastHours == 0 {
|
||||
lastHours = defLastHours
|
||||
}
|
||||
|
||||
db := dao.GetDB()
|
||||
err = dao.GetRows(db, &countInfo, `
|
||||
SELECT t1.lock_status, t1.status, COUNT(*) count
|
||||
FROM goods_order t1
|
||||
WHERE t1.vendor_id <> 2 AND IF(t1.vendor_id = ?, t1.store_id, IF(t1.jx_store_id != 0, t1.jx_store_id, t1.store_id) ) = ?
|
||||
AND t1.order_created_at >= ?
|
||||
GROUP BY 1,2
|
||||
ORDER BY 1,2
|
||||
`, model.VendorIDWSC, storeID, time.Now().Add(-time.Duration(lastHours)*time.Hour))
|
||||
if err == nil {
|
||||
return countInfo, nil
|
||||
}
|
||||
globals.SugarLogger.Infof("GetStoreOrderCountInfo2 storeID:%s failed with error:%v", storeID, err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (c *OrderManager) GetOrderSkuInfo(ctx *jxcontext.Context, vendorOrderID string, vendorID int) (skus []*model.OrderSkuExt, err error) {
|
||||
globals.SugarLogger.Debugf("GetOrderSkuInfo orderID:%s", vendorOrderID)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user