根据时间,日期,比例返回要加入购物车的商品

This commit is contained in:
苏尹岚
2020-08-07 09:39:39 +08:00
parent b998498ae3
commit ed8b123e1f
3 changed files with 33 additions and 9 deletions

View File

@@ -1346,9 +1346,32 @@ func GetAfsOrdersByPage(db *DaoDB, vendorOrderID, afsOrderID, userID string, fro
return afsOrderList, totalCount, err
}
func GetSupplySupportStoreSkus(db *DaoDB, fromDate, toDate time.Time, fromStoreID, storeID int) (storeSkuBind []*model.StoreSkuBind, err error) {
// sql := `
// `
return storeSkuBind, 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
}