This commit is contained in:
苏尹岚
2020-08-12 15:45:40 +08:00
34 changed files with 474 additions and 190 deletions

View File

@@ -1367,3 +1367,32 @@ func GetOrderStoreSkusCount(db *DaoDB, storeID, skuID int, fromTime, toTime time
}
return count, err
}
func GetSupplySupportStoreSkus(db *DaoDB, fromDate, toDate time.Time, fromStoreID, storeID int, percentage float64) (orderSkus []*model.OrderSku, err error) {
sql := `
SELECT c.sku_id,CEIL(c.count) count,CEIL(c.count) * d.jx_price sale_price
FROM
(
SELECT a.sku_id,SUM(a.count * ? ) count FROM order_sku a
JOIN goods_order b ON b.vendor_order_id = a.vendor_order_id AND a.vendor_id = b.vendor_id
WHERE b.order_created_at > ?
AND b.order_created_at < ?
AND a.sku_id <> ?
AND IF(b.store_id = 0,b.jx_store_id,b.store_id) = ?
GROUP BY 1
)c
JOIN store_sku_bind d ON d.store_id = ? AND d.sku_id = c.sku_id AND d.deleted_at = ?
ORDER BY c.count desc
`
sqlParams := []interface{}{
percentage,
fromDate,
toDate,
6039481, //葱姜蒜
fromStoreID,
storeID, utils.DefaultTimeValue,
}
if err = GetRows(db, &orderSkus, sql, sqlParams); err == nil {
return orderSkus, err
}
return orderSkus, err
}