diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 86aa69558..b5b91d2d3 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -4246,6 +4246,7 @@ type JdPage struct { Lat string `json:"lat"` Lng string `json:"lng"` DistrictName string `json:"district_name"` + BrandName string `json:"brand_name"` } type MtPage struct { @@ -4268,6 +4269,7 @@ type MtPage struct { Lat string `json:"lat"` Lng string `json:"lng"` DistrictName string `json:"district_name"` + BrandName string `json:"brand_name"` } func RefreshPageStore() { @@ -4389,19 +4391,50 @@ func RefreshPageStore() { jds2 []*JdPage mts2 []*MtPage ) + trySplitBrand := func(name string) (brandName string) { + var ( + splitStr = []string{ + "-", "(", "(", "•", + } + ) + for _, v := range splitStr { + if strings.Index(name, v) != -1 { + return name[:strings.Index(name, v)] + } else { + continue + } + } + return "无" + } sql7 := ` SELECT * FROM jingdong_showd WHERE brand_name = '' OR brand_name IS NULL OR brand_name = '无' ` dao.GetRows(db, &jds2, sql7) if len(jds2) > 0 { - + for _, v := range jds2 { + sql := ` + UPDATE jingdong_showd SET brand_name = ? WHERE id = ? + ` + sqlparams := []interface{}{ + trySplitBrand(v.Name), v.ID, + } + dao.ExecuteSQL(db, sql, sqlparams) + } } sql8 := ` SELECT * FROM meituan_showd WHERE brand_name = '' OR brand_name IS NULL OR brand_name = '无' ` dao.GetRows(db, &mts2, sql8) if len(mts2) > 0 { - + for _, v := range mts2 { + sql := ` + UPDATE meituan_showd SET brand_name = ? WHERE id = ? + ` + sqlparams := []interface{}{ + trySplitBrand(v.Name), v.ID, + } + dao.ExecuteSQL(db, sql, sqlparams) + } } sql9 := ` TRUNCATE page_brand` dao.ExecuteSQL(db, sql9) @@ -4724,6 +4757,12 @@ func QueryPageSkus(ctx *jxcontext.Context, vendorID int, vendorStoreIDs []string } func GetPageBrands(ctx *jxcontext.Context) (brands []*model.PageBrand, err error) { - + var ( + db = dao.GetDB() + ) + sql := ` + SELECT * FROM page_brand + ` + dao.GetRow(db, &brands, sql) return brands, err }