查询未拣货订单商品统计

This commit is contained in:
苏尹岚
2020-02-21 16:14:16 +08:00
parent 05eb9b6a8e
commit f054243c77
4 changed files with 53 additions and 0 deletions

View File

@@ -47,6 +47,12 @@ type StoresOrderSaleInfo struct {
EarningPrice int64 `json:"earningPrice"` // 预估结算给门店老板的钱
}
type OrderSkusAccept struct {
model.SkuAndName
SumWeight int `json:"sumWeight"`
SumCount int `json:"sumCount"`
}
func (c *OrderManager) GetStoreOrderCountInfo(ctx *jxcontext.Context, storeID, lastHours int, isIncludeFake bool) (countInfo []*model.GoodsOrderCountInfo, err error) {
globals.SugarLogger.Debugf("GetStoreOrderCountInfo storeID:%d", storeID)
if lastHours > maxLastHours {
@@ -1138,3 +1144,25 @@ func (c *OrderManager) RefreshOrderFinancial(ctx *jxcontext.Context, fromTime, t
}
return hint, err
}
func GetOrdersAccept(ctx *jxcontext.Context, storeID int) (result []*OrderSkusAccept, err error) {
db := dao.GetDB()
sql := `
SELECT SUM(a.count) sum_count, SUM(a.weight*a.count) sum_weight, c.*, d.name, d.unit, d.prefix
FROM order_sku a
JOIN goods_order b ON b.vendor_order_id = a.vendor_order_id AND b.vendor_id = a.vendor_id
JOIN sku c ON c.id = a.sku_id
JOIN sku_name d ON d.id = c.name_id
WHERE IF(b.store_id = 0,b.jx_store_id,b.store_id) = ?
AND b.status = ?
AND b.order_created_at <= NOW() AND b.order_created_at >= ?
GROUP BY 3
`
sqlParams := []interface{}{
storeID,
model.OrderStatusAccepted,
time.Now().AddDate(0, 0, -1),
}
err = dao.GetRows(db, &result, sql, sqlParams)
return result, err
}