- paging added for GetStoreOrderInfo.
- GetStoreOrderCountInfo added.
This commit is contained in:
@@ -12,19 +12,26 @@ import (
|
||||
|
||||
const (
|
||||
maxLastHours = 2 * 24 // 最多只能查询两天内的订单数据
|
||||
defPageSize = 50
|
||||
)
|
||||
|
||||
var (
|
||||
ErrCanNotFindOrder = errors.New("找不到相应订单")
|
||||
)
|
||||
|
||||
func (c *OrderManager) GetStoreOrderInfo(storeID string, lastHours int, fromStatus, toStatus int) (orders []*model.GoodsOrderExt, err error) {
|
||||
func (c *OrderManager) GetStoreOrderInfo(storeID string, lastHours int, fromStatus, toStatus, offset, pageSize int) (orders []*model.GoodsOrderExt, err error) {
|
||||
if lastHours > maxLastHours {
|
||||
lastHours = maxLastHours
|
||||
}
|
||||
if toStatus == 0 {
|
||||
toStatus = fromStatus
|
||||
}
|
||||
if offset < 0 {
|
||||
offset = 0
|
||||
}
|
||||
if pageSize == 0 {
|
||||
pageSize = defPageSize
|
||||
}
|
||||
|
||||
db := orm.NewOrm()
|
||||
_, err = db.Raw(`
|
||||
@@ -34,7 +41,8 @@ func (c *OrderManager) GetStoreOrderInfo(storeID string, lastHours int, fromStat
|
||||
WHERE IF(t1.jx_store_id != 0, t1.jx_store_id, t1.store_id) = ?
|
||||
AND t1.order_created_at >= ?
|
||||
AND t1.Status >= ? AND t1.Status <= ?
|
||||
`, storeID, time.Now().Add(-time.Duration(lastHours)*time.Hour), fromStatus, toStatus).QueryRows(&orders)
|
||||
LIMIT ? OFFSET ?
|
||||
`, storeID, time.Now().Add(-time.Duration(lastHours)*time.Hour), fromStatus, toStatus, pageSize, offset).QueryRows(&orders)
|
||||
if err == nil {
|
||||
return orders, nil
|
||||
}
|
||||
@@ -42,6 +50,26 @@ func (c *OrderManager) GetStoreOrderInfo(storeID string, lastHours int, fromStat
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (c *OrderManager) GetStoreOrderCountInfo(storeID string, lastHours int) (countInfo *model.GoodsOrderCountInfo, err error) {
|
||||
if lastHours > maxLastHours {
|
||||
lastHours = maxLastHours
|
||||
}
|
||||
|
||||
db := orm.NewOrm()
|
||||
_, err = db.Raw(`
|
||||
SELECT t1.status, COUNT(*) count
|
||||
FROM goods_order t1
|
||||
WHERE IF(t1.jx_store_id != 0, t1.jx_store_id, t1.store_id) = ?
|
||||
AND t1.order_created_at >= ?
|
||||
GROUP BY 1
|
||||
`, storeID, time.Now().Add(-time.Duration(lastHours)*time.Hour)).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) GetOrderSkuInfo(vendorOrderID string, vendorID int) (skus []*model.OrderSkuExt, err error) {
|
||||
db := orm.NewOrm()
|
||||
num, err := db.Raw(`
|
||||
|
||||
Reference in New Issue
Block a user