aa
This commit is contained in:
@@ -264,10 +264,10 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func GetStoreSkus(ctx *jxcontext.Context, storeID int, skuIDs []int, isFocus bool, keyword string, isBySku, isAct bool, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *dao.StoreSkuNamesInfo, err error) {
|
func GetStoreSkus(ctx *jxcontext.Context, storeID int, skuIDs []int, isFocus bool, keyword string, isBySku, isAct bool, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *dao.StoreSkuNamesInfo, err error) {
|
||||||
return GetStoresSkus(ctx, []int{storeID}, skuIDs, isFocus, false, 0, keyword, isBySku, isAct, params, offset, pageSize)
|
return GetStoresSkus(ctx, []int{storeID}, skuIDs, nil, isFocus, false, 0, keyword, isBySku, isAct, params, offset, pageSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool, keyword string, isBySku, isAct, isHighPrice bool, priceType int, actVendorID int, params map[string]interface{}) (sql string, sqlParams []interface{}, err error) {
|
func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, upcs []string, isFocus bool, keyword string, isBySku, isAct, isHighPrice bool, priceType int, actVendorID int, params map[string]interface{}) (sql string, sqlParams []interface{}, err error) {
|
||||||
sql = `
|
sql = `
|
||||||
FROM sku_name t1
|
FROM sku_name t1
|
||||||
JOIN sku t2 FORCE INDEX(PRIMARY) ON t1.id = t2.name_id AND t2.deleted_at = ?/* AND t2.status = ?*/
|
JOIN sku t2 FORCE INDEX(PRIMARY) ON t1.id = t2.name_id AND t2.deleted_at = ?/* AND t2.status = ?*/
|
||||||
@@ -422,6 +422,10 @@ func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool
|
|||||||
sql += " AND IF(INSTR(t3.name,'" + model.ExdStoreName + "') > 0, t2.exd_sku_id <> '', t2.exd_sku_id = '')"
|
sql += " AND IF(INSTR(t3.name,'" + model.ExdStoreName + "') > 0, t2.exd_sku_id <> '', t2.exd_sku_id = '')"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(upcs) > 0 {
|
||||||
|
sql += " AND t1.upc IN (" + dao.GenQuestionMarks(len(upcs)) + ")"
|
||||||
|
sqlParams = append(sqlParams, upcs)
|
||||||
|
}
|
||||||
if len(skuIDs) > 0 {
|
if len(skuIDs) > 0 {
|
||||||
sql += " AND t2.id IN (" + dao.GenQuestionMarks(len(skuIDs)) + ")"
|
sql += " AND t2.id IN (" + dao.GenQuestionMarks(len(skuIDs)) + ")"
|
||||||
sqlParams = append(sqlParams, skuIDs)
|
sqlParams = append(sqlParams, skuIDs)
|
||||||
@@ -486,7 +490,7 @@ func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool
|
|||||||
return sql, sqlParams, err
|
return sql, sqlParams, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetStoresSkus(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus, isHighPrice bool, priceType int, keyword string, isBySku, isAct bool, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *dao.StoreSkuNamesInfo, err error) {
|
func GetStoresSkus(ctx *jxcontext.Context, storeIDs, skuIDs []int, upcs []string, isFocus, isHighPrice bool, priceType int, keyword string, isBySku, isAct bool, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *dao.StoreSkuNamesInfo, err error) {
|
||||||
//权限
|
//权限
|
||||||
if permission.IsRoled(ctx) {
|
if permission.IsRoled(ctx) {
|
||||||
if storeIDsMap, err := permission.GetUserStoresResultMap(ctx.GetUserID()); err == nil {
|
if storeIDsMap, err := permission.GetUserStoresResultMap(ctx.GetUserID()); err == nil {
|
||||||
@@ -509,10 +513,10 @@ func GetStoresSkus(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus, isHi
|
|||||||
storeIDs = storeIDs2
|
storeIDs = storeIDs2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return GetStoresSkusNew(ctx, storeIDs, skuIDs, isFocus, isHighPrice, priceType, keyword, isBySku, isAct, params, offset, pageSize)
|
return GetStoresSkusNew(ctx, storeIDs, skuIDs, upcs, isFocus, isHighPrice, priceType, keyword, isBySku, isAct, params, offset, pageSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus, isHighPrice bool, priceType int, keyword string, isBySku, isAct bool, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *dao.StoreSkuNamesInfo, err error) {
|
func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, upcs []string, isFocus, isHighPrice bool, priceType int, keyword string, isBySku, isAct bool, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *dao.StoreSkuNamesInfo, err error) {
|
||||||
if !isFocus && !isBySku && (len(storeIDs) > 1 || len(storeIDs) == 0) {
|
if !isFocus && !isBySku && (len(storeIDs) > 1 || len(storeIDs) == 0) {
|
||||||
return nil, fmt.Errorf("未关注按SkuName只能查询单店")
|
return nil, fmt.Errorf("未关注按SkuName只能查询单店")
|
||||||
}
|
}
|
||||||
@@ -545,7 +549,7 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus, i
|
|||||||
delete(params, "minimumPrice")
|
delete(params, "minimumPrice")
|
||||||
}
|
}
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
sql, sqlParams, err := getGetStoresSkusBaseSQL(db, storeIDs, skuIDs, isFocus, keyword, isBySku, isAct, isHighPrice, priceType, actVendorID, params)
|
sql, sqlParams, err := getGetStoresSkusBaseSQL(db, storeIDs, skuIDs, upcs, isFocus, keyword, isBySku, isAct, isHighPrice, priceType, actVendorID, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ func (c *StoreSkuController) GetStoreSkus() {
|
|||||||
// @Param keyword query string false "查询关键字(可以为空,为空表示不限制)"
|
// @Param keyword query string false "查询关键字(可以为空,为空表示不限制)"
|
||||||
// @Param nameIDs query string false "SkuName ID列表对象"
|
// @Param nameIDs query string false "SkuName ID列表对象"
|
||||||
// @Param skuIDs query string false "Sku ID列表对象"
|
// @Param skuIDs query string false "Sku ID列表对象"
|
||||||
|
// @Param upcs query string false "upc列表对象"
|
||||||
// @Param name query string false "商品名称(不要求完全一致)"
|
// @Param name query string false "商品名称(不要求完全一致)"
|
||||||
// @Param prefix query string false "商品前缀(不要求完全一致)"
|
// @Param prefix query string false "商品前缀(不要求完全一致)"
|
||||||
// @Param categoryID query int false "商品所属类别ID"
|
// @Param categoryID query int false "商品所属类别ID"
|
||||||
@@ -99,8 +100,9 @@ func (c *StoreSkuController) GetStoreSkus() {
|
|||||||
func (c *StoreSkuController) GetStoresSkus() {
|
func (c *StoreSkuController) GetStoresSkus() {
|
||||||
c.callGetStoresSkus(func(params *tStoreSkuGetStoresSkusParams) (retVal interface{}, errCode string, err error) {
|
c.callGetStoresSkus(func(params *tStoreSkuGetStoresSkusParams) (retVal interface{}, errCode string, err error) {
|
||||||
var storeIDs, skuIDs []int
|
var storeIDs, skuIDs []int
|
||||||
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.SkuIDs, &skuIDs); err == nil {
|
var upcs []string
|
||||||
retVal, err = cms.GetStoresSkus(params.Ctx, storeIDs, skuIDs, params.IsFocus, params.IsHighPrice, params.PriceType, params.Keyword, params.IsBySku, params.IsAct, params.MapData, params.Offset, params.PageSize)
|
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.SkuIDs, &skuIDs, params.Upcs, &upcs); err == nil {
|
||||||
|
retVal, err = cms.GetStoresSkus(params.Ctx, storeIDs, skuIDs, upcs, params.IsFocus, params.IsHighPrice, params.PriceType, params.Keyword, params.IsBySku, params.IsAct, params.MapData, params.Offset, params.PageSize)
|
||||||
}
|
}
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user