Commit 45274004 by mushishixian

修复eccn

parent e1d1582d
Showing with 26 additions and 12 deletions
...@@ -274,7 +274,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -274,7 +274,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
brandIds := gjson.Get(discountRatio, "brand."+sortString).String() brandIds := gjson.Get(discountRatio, "brand."+sortString).String()
if brandIds != "" { if brandIds != "" {
hasSpecialCheck = true hasSpecialCheck = true
standardBrandIdList := strings.Split(brandIds, "@€@") standardBrandIdList := strings.Split(brandIds, ",")
standardBrandId := strconv.Itoa(sku.StandardBrand.StandardBrandId) standardBrandId := strconv.Itoa(sku.StandardBrand.StandardBrandId)
//找到有对应的品牌,那么优先级肯定是最高的了 //找到有对应的品牌,那么优先级肯定是最高的了
if php2go.InArray(standardBrandId, standardBrandIdList) { if php2go.InArray(standardBrandId, standardBrandIdList) {
...@@ -307,17 +307,11 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -307,17 +307,11 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
var priceRatioSort int var priceRatioSort int
//这个就是最终要获取到的价格系数 //这个就是最终要获取到的价格系数
var priceRatioList []model.PriceRatio var priceRatioList []model.PriceRatio
//是否找到系数的标志位
findedRatio := false
//如果只有默认系数,那么就去找默认系数 //如果只有默认系数,那么就去找默认系数
if isDefaultPriceRatio { if isDefaultPriceRatio {
priceRatioArr := gjson.Get(priceRatioCache, "ladder_price").Array()
for _, value := range priceRatioArr {
priceRatioList = nil
var priceRatio model.PriceRatio
priceRatio.Ratio = gjson.Get(value.String(), "ratio").Float()
priceRatio.RatioUsd = gjson.Get(value.String(), "ratio_usd").Float()
priceRatioList = append(priceRatioList, priceRatio)
}
priceRatioSort = -1
} else { } else {
//拿到系数以后,就要去计算 //拿到系数以后,就要去计算
//拿出里面的所有排序 //拿出里面的所有排序
...@@ -351,6 +345,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -351,6 +345,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
goodsNameList := strings.Split(goodsNames, "@€@") goodsNameList := strings.Split(goodsNames, "@€@")
//找到有对应的商品名称,那么优先级肯定是最高的了 //找到有对应的商品名称,那么优先级肯定是最高的了
if php2go.InArray(sku.GoodsName, goodsNameList) { if php2go.InArray(sku.GoodsName, goodsNameList) {
findedRatio = true
break break
} }
} }
...@@ -359,10 +354,11 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -359,10 +354,11 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
brandIds := gjson.Get(priceRatioCache, "brand."+sortString).String() brandIds := gjson.Get(priceRatioCache, "brand."+sortString).String()
if brandIds != "" { if brandIds != "" {
hasSpecialCheck = true hasSpecialCheck = true
standardBrandIdList := strings.Split(brandIds, "@€@") standardBrandIdList := strings.Split(brandIds, ",")
standardBrandId := strconv.Itoa(sku.StandardBrand.StandardBrandId) standardBrandId := strconv.Itoa(sku.StandardBrand.StandardBrandId)
//找到有对应的品牌,那么优先级肯定是最高的了 //找到有对应的品牌,那么优先级肯定是最高的了
if php2go.InArray(standardBrandId, standardBrandIdList) { if php2go.InArray(standardBrandId, standardBrandIdList) {
findedRatio = true
break break
} }
} }
...@@ -370,7 +366,8 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -370,7 +366,8 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
//判断是否有符合的eccn //判断是否有符合的eccn
eccns := gjson.Get(priceRatioCache, "eccn."+sortString).String() eccns := gjson.Get(priceRatioCache, "eccn."+sortString).String()
if eccns != "" { if eccns != "" {
eccnList := strings.Split(eccns, "@€@") hasSpecialCheck = true
eccnList := strings.Split(eccns, ",")
fmt.Println(eccnList) fmt.Println(eccnList)
//找到有对应的eccn,那么优先级肯定是最高的了 //找到有对应的eccn,那么优先级肯定是最高的了
for _, eccn := range eccnList { for _, eccn := range eccnList {
...@@ -387,6 +384,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -387,6 +384,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
eccn = strings.Replace(eccn, "%", "", 10) eccn = strings.Replace(eccn, "%", "", 10)
if strings.Contains(sku.Eccn, eccn) { if strings.Contains(sku.Eccn, eccn) {
fmt.Println("前后匹配到") fmt.Println("前后匹配到")
findedRatio = true
break break
} }
} }
...@@ -396,6 +394,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -396,6 +394,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
fmt.Println(sku.Eccn, eccn) fmt.Println(sku.Eccn, eccn)
if strings.HasSuffix(sku.Eccn, eccn) { if strings.HasSuffix(sku.Eccn, eccn) {
fmt.Println("前匹配到") fmt.Println("前匹配到")
findedRatio = true
break break
} }
} }
...@@ -404,6 +403,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -404,6 +403,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
eccn = strings.Replace(eccn, "%", "", 10) eccn = strings.Replace(eccn, "%", "", 10)
if strings.HasPrefix(sku.Eccn, eccn) { if strings.HasPrefix(sku.Eccn, eccn) {
fmt.Println("后匹配到") fmt.Println("后匹配到")
findedRatio = true
break break
} }
} }
...@@ -414,8 +414,22 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku { ...@@ -414,8 +414,22 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
if hasSpecialCheck { if hasSpecialCheck {
continue continue
} }
findedRatio = true
break break
} }
//找不到特定的系数,那就去找全局的
if !findedRatio {
priceRatioCache, _ = redis.String(redisCon.Do("GET", "magic_cube_price_rule_channel_default"))
priceRatioArr := gjson.Get(priceRatioCache, "ladder_price").Array()
priceRatioList = nil
for _, value := range priceRatioArr {
var priceRatio model.PriceRatio
priceRatio.Ratio = gjson.Get(value.String(), "ratio").Float()
priceRatio.RatioUsd = gjson.Get(value.String(), "ratio_usd").Float()
priceRatioList = append(priceRatioList, priceRatio)
}
priceRatioSort = -1
}
} }
sku.PriceRatio = priceRatioList sku.PriceRatio = priceRatioList
sku.PriceRatioSort = priceRatioSort sku.PriceRatioSort = priceRatioSort
......
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