推荐商品
This commit is contained in:
@@ -2121,6 +2121,14 @@ func ReCalculateJxPrice(ctx *jxcontext.Context, storeIDs []int) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func GetTopSkusByStoreIDs(ctx *jxcontext.Context, storeIDs []int) (hint string, err error) {
|
||||
return hint, err
|
||||
func GetTopSkusByStoreIDs(ctx *jxcontext.Context, storeIDs []int) (skuAndName []*model.SkuAndName, err error) {
|
||||
if len(storeIDs) == 0 {
|
||||
return skuAndName, err
|
||||
}
|
||||
db := dao.GetDB()
|
||||
skuAndName, err = dao.GetTopSkusByStoreIDs(db, storeIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return skuAndName, err
|
||||
}
|
||||
|
||||
@@ -663,6 +663,36 @@ func GetStoreSkusByNameIDs(db *DaoDB, storeIDs []int, nameID int) (skuList []*St
|
||||
return skuList, err
|
||||
}
|
||||
|
||||
func GetTopSkusByStoreIDs(db *DaoDB, storeIDs []int) (skuAndName []*model.SkuAndName, err error) {
|
||||
sql := `
|
||||
SELECT *
|
||||
FROM(
|
||||
SELECT SUM(b.count) count,b.sku_id
|
||||
FROM goods_order a
|
||||
JOIN order_sku b ON a.vendor_order_id = b.vendor_order_id
|
||||
JOIN sku c ON b.sku_id = c.id AND c.deleted_at = ?
|
||||
WHERE 1=1
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if len(storeIDs) > 0 {
|
||||
sql += " AND a.store_id in(" + GenQuestionMarks(len(storeIDs)) + ")"
|
||||
sqlParams = append(sqlParams, storeIDs)
|
||||
}
|
||||
sql += `
|
||||
AND b.sale_price > ?
|
||||
GROUP BY b.sku_id)t1
|
||||
JOIN sku t2 ON t1.sku_id = t2.id
|
||||
JOIN sku_name t3 ON t2.name_id = t3.id
|
||||
ORDER BY t1.count DESC
|
||||
LIMIT ?
|
||||
`
|
||||
sqlParams = append(sqlParams, 100, 30)
|
||||
err = GetRows(db, &skuAndName, sql, sqlParams...)
|
||||
return skuAndName, err
|
||||
}
|
||||
|
||||
func SetStoreSkuBindVendorPrice(storeSkuBind *model.StoreSkuBind, vendorID int, vendorPrice int) {
|
||||
switch vendorID {
|
||||
case model.VendorIDJD:
|
||||
|
||||
@@ -1584,6 +1584,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"],
|
||||
beego.ControllerComments{
|
||||
Method: "GetTopSkusByStoreIDs",
|
||||
Router: `/GetTopSkusByStoreIDs`,
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"],
|
||||
beego.ControllerComments{
|
||||
Method: "GetVendorStoreSkusInfo",
|
||||
|
||||
Reference in New Issue
Block a user