获取购物车

This commit is contained in:
苏尹岚
2020-08-18 10:45:52 +08:00
parent 927c261f0d
commit 1517ea4520
3 changed files with 17 additions and 6 deletions

View File

@@ -1346,9 +1346,17 @@ func GetAfsOrdersByPage(db *DaoDB, vendorOrderID, afsOrderID, userID string, fro
return afsOrderList, totalCount, err
}
func GetSupplySupportStoreSkus(db *DaoDB, fromDate, toDate time.Time, fromStoreID, storeID int, percentage float64) (orderSkus []*model.OrderSku, err error) {
type GetSupplySupportStoreSkusResult struct {
SkuID int `orm:"column(sku_id)" json:"skuID"`
Count int `json:"count"`
SalePrice int `json:"salePrice"`
Stock int `json:"stock"`
model.SkuName
}
func GetSupplySupportStoreSkus(db *DaoDB, fromDate, toDate time.Time, fromStoreID, storeID int, percentage float64) (getSupplySupportStoreSkusResult []*GetSupplySupportStoreSkusResult, err error) {
sql := `
SELECT c.sku_id,CEIL(c.count) count,CEIL(c.count) * d.jx_price sale_price
SELECT c.sku_id,CEIL(c.count) count,CEIL(c.count) * d.jx_price sale_price, d.stock, f.*
FROM
(
SELECT a.sku_id,SUM(a.count * ? ) count FROM order_sku a
@@ -1360,6 +1368,8 @@ func GetSupplySupportStoreSkus(db *DaoDB, fromDate, toDate time.Time, fromStoreI
GROUP BY 1
)c
JOIN store_sku_bind d ON d.store_id = ? AND d.sku_id = c.sku_id AND d.deleted_at = ?
JOIN sku e ON e.id = d.sku_id
JOIN sku_name f ON f.id = e.name_id
ORDER BY c.count desc
`
sqlParams := []interface{}{
@@ -1370,8 +1380,8 @@ func GetSupplySupportStoreSkus(db *DaoDB, fromDate, toDate time.Time, fromStoreI
fromStoreID,
storeID, utils.DefaultTimeValue,
}
if err = GetRows(db, &orderSkus, sql, sqlParams); err == nil {
return orderSkus, err
if err = GetRows(db, &getSupplySupportStoreSkusResult, sql, sqlParams); err == nil {
return getSupplySupportStoreSkusResult, err
}
return orderSkus, err
return getSupplySupportStoreSkusResult, err
}