- param isBySku added for GetSkuNames

This commit is contained in:
gazebo
2019-03-07 09:54:37 +08:00
parent 83be4fb716
commit 123ffd4353
2 changed files with 10 additions and 6 deletions

View File

@@ -192,7 +192,7 @@ func DeleteCategoryMap(ctx *jxcontext.Context, db *dao.DaoDB, categoryID int) (n
})
}
func GetSkuNames(ctx *jxcontext.Context, keyword string, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *SkuNamesInfo, err error) {
func GetSkuNames(ctx *jxcontext.Context, keyword string, isBySku bool, params map[string]interface{}, offset, pageSize int) (skuNamesInfo *SkuNamesInfo, err error) {
db := dao.GetDB()
sql := `
FROM sku_name t1
@@ -346,8 +346,11 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, params map[string]inter
t1.status,
t1.is_spu,
t1.img_hash_code,
t1.upc
`
t1.upc`
if isBySku {
sql += `,
t2.id`
}
sqlData := `
SELECT
SQL_CALC_FOUND_ROWS
@@ -476,7 +479,7 @@ func AddSkuName(ctx *jxcontext.Context, skuNameExt *model.SkuNameExt, userName s
}
}
dao.Commit(db)
tmpInfo, err := GetSkuNames(ctx, "", utils.Params2Map("nameID", skuNameExt.SkuName.ID), 0, 1)
tmpInfo, err := GetSkuNames(ctx, "", false, utils.Params2Map("nameID", skuNameExt.SkuName.ID), 0, 1)
if err != nil {
return nil, err
}
@@ -597,7 +600,7 @@ func AddSku(ctx *jxcontext.Context, nameID int, sku *model.Sku, userName string)
sku.NameID = nameID
sku.JdID = jxutils.GenFakeID()
if err = dao.CreateEntity(db, sku); err == nil {
result, err2 := GetSkuNames(ctx, "", utils.Params2Map("skuID", sku.ID), 0, 0)
result, err2 := GetSkuNames(ctx, "", false, utils.Params2Map("skuID", sku.ID), 0, 0)
if err = err2; err == nil {
if result.TotalCount == 1 {
outSkuNameExt = result.SkuNames[0]

View File

@@ -147,12 +147,13 @@ func (c *SkuController) SyncCategory() {
// @Param toStatus query int false "查询起始状态0下架1正常"
// @Param offset query int false "门店列表起始序号以0开始缺省为0"
// @Param pageSize query int false "门店列表页大小缺省为50-1表示全部"
// @Param isBySku query bool false "是否将sku拆开缺省为false"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetSkuNames [get]
func (c *SkuController) GetSkuNames() {
c.callGetSkuNames(func(params *tSkuGetSkuNamesParams) (retVal interface{}, errCode string, err error) {
retVal, err = cms.GetSkuNames(params.Ctx, params.Keyword, params.MapData, params.Offset, params.PageSize)
retVal, err = cms.GetSkuNames(params.Ctx, params.Keyword, params.IsBySku, params.MapData, params.Offset, params.PageSize)
return retVal, "", err
})
}