Commit 5197a67a by mushishixian

修复判断eccn问题

parent 74cb4a8d
Showing with 46 additions and 5 deletions
......@@ -330,9 +330,13 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
priceRatio.RatioUsd = gjson.Get(value.String(), "ratio_usd").Float()
priceRatioList = append(priceRatioList, priceRatio)
}
var hasSpecialCheck = false
//判断是否有符合的商品名称
goodsNames := gjson.Get(priceRatioCache, "goods_name."+sortString).String()
if goodsNames != "" {
hasSpecialCheck = true
goodsNameList := strings.Split(goodsNames, "€")
//找到有对应的商品名称,那么优先级肯定是最高的了
if php2go.InArray(sku.GoodsName, goodsNameList) {
......@@ -341,8 +345,9 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
//判断是否有符合的标准品牌ID
brandIds := gjson.Get(priceRatioCache, "brand"+sortString).String()
brandIds := gjson.Get(priceRatioCache, "brand."+sortString).String()
if brandIds != "" {
hasSpecialCheck = true
standardBrandIdList := strings.Split(brandIds, "€")
standardBrandId := strconv.Itoa(sku.StandardBrand.StandardBrandId)
//找到有对应的品牌,那么优先级肯定是最高的了
......@@ -352,18 +357,54 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
//判断是否有符合的eccn
eccns := gjson.Get(priceRatioCache, "eccn"+sortString).String()
eccns := gjson.Get(priceRatioCache, "eccn."+sortString).String()
if eccns != "" {
eccnList := strings.Split(eccns, "€")
fmt.Println(eccnList)
//找到有对应的eccn,那么优先级肯定是最高的了
for _, eccn := range eccnList {
if strings.Contains(sku.Eccn, eccn) {
break
//判断是否有百分号匹配
//如果是纯%,那就是不对的,要跳过
if strings.Replace(eccn, "%", "", 10) == "" {
continue
}
if strings.Contains(eccn, "%") {
hasPrefix := strings.HasPrefix(eccn, "%")
hasSuffix := strings.HasSuffix(eccn, "%")
if hasPrefix && hasSuffix {
fmt.Println("前后匹配")
eccn = strings.Replace(eccn, "%", "", 10)
if strings.Contains(sku.Eccn, eccn) {
fmt.Println("前后匹配到")
break
}
}
if hasPrefix && !hasSuffix {
fmt.Println("前匹配")
eccn = strings.Replace(eccn, "%", "", 10)
fmt.Println(sku.Eccn, eccn)
if strings.HasSuffix(sku.Eccn, eccn) {
fmt.Println("前匹配到")
break
}
}
if !hasPrefix && hasSuffix {
fmt.Println("后匹配")
eccn = strings.Replace(eccn, "%", "", 10)
if strings.HasPrefix(sku.Eccn, eccn) {
fmt.Println("后匹配到")
break
}
}
}
}
}
//如果没有设置品牌和商品,那么这个优先级高的就会覆盖下面的了,不需要再去判断品牌和型号了
break
if hasSpecialCheck {
continue
} else {
break
}
}
}
sku.PriceRatio = priceRatioList
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment