- 将GetStoreOrderCountInfo的实现换成GetStoreOrderCountInfo2一致的(准备之后去掉GetStoreOrderCountInfo2)

- 添加GetStoreAfsOrderCountInfo
This commit is contained in:
gazebo
2019-05-22 09:46:23 +08:00
parent e9602bdb8e
commit 0a5f9c3060
4 changed files with 53 additions and 35 deletions

View File

@@ -37,33 +37,8 @@ type StoresOrderSaleInfo struct {
ActualPayPrice int64 `json:"actualPayPrice"`
}
//此函数会被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 {
lastHours = maxLastHours
} else if lastHours == 0 {
lastHours = defLastHours
}
db := orm.NewOrm()
_, err = db.Raw(`
SELECT 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 >= ? AND t1.lock_status = ?
GROUP BY 1
ORDER BY 1
`, model.VendorIDWSC, storeID, time.Now().Add(-time.Duration(lastHours)*time.Hour), model.OrderStatusUnknown).QueryRows(&countInfo)
if err == nil {
return countInfo, nil
}
globals.SugarLogger.Infof("GetStoreOrderCountInfo storeID:%s failed with error:%v", storeID, err)
return nil, err
}
func (c *OrderManager) GetStoreOrderCountInfo2(ctx *jxcontext.Context, storeID, lastHours int) (countInfo []*model.GoodsOrderCountInfo2, err error) {
globals.SugarLogger.Debugf("GetStoreOrderCountInfo2 storeID:%d", storeID)
func (c *OrderManager) GetStoreOrderCountInfo(ctx *jxcontext.Context, storeID, lastHours int) (countInfo []*model.GoodsOrderCountInfo, err error) {
globals.SugarLogger.Debugf("GetStoreOrderCountInfo storeID:%d", storeID)
if lastHours > maxLastHours {
lastHours = maxLastHours
} else if lastHours == 0 {
@@ -82,7 +57,7 @@ func (c *OrderManager) GetStoreOrderCountInfo2(ctx *jxcontext.Context, storeID,
if err == nil {
return countInfo, nil
}
globals.SugarLogger.Infof("GetStoreOrderCountInfo2 storeID:%d failed with error:%v", storeID, err)
globals.SugarLogger.Infof("GetStoreOrderCountInfo storeID:%d failed with error:%v", storeID, err)
return nil, err
}
@@ -770,3 +745,27 @@ func (c *OrderManager) GetAfsOrderSkuInfo(ctx *jxcontext.Context, afsOrderID str
err = dao.GetRows(dao.GetDB(), &skus, sql, sqlParams...)
return skus, err
}
func (c *OrderManager) GetStoreAfsOrderCountInfo(ctx *jxcontext.Context, storeID, lastHours int) (countInfo []*model.GoodsOrderCountInfo, err error) {
globals.SugarLogger.Debugf("GetStoreAfsOrderCountInfo storeID:%d", storeID)
if lastHours > maxLastHours {
lastHours = maxLastHours
} else if lastHours == 0 {
lastHours = defLastHours
}
db := dao.GetDB()
err = dao.GetRows(db, &countInfo, `
SELECT 0 lock_status, t1.status, COUNT(*) count
FROM afs_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.afs_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("GetStoreAfsOrderCountInfo storeID:%d failed with error:%v", storeID, err)
return nil, err
}