Commit 7bf43ffe by 杨树贤

修改逻辑

parent 0a6d090c
Showing with 62 additions and 62 deletions
...@@ -68,7 +68,6 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -68,7 +68,6 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
//然后确定排序 //然后确定排序
sortNumbers = sorter.IntSliceSortDesc(sortNumbers) sortNumbers = sorter.IntSliceSortDesc(sortNumbers)
//确定排序以后,就可以进行按排序(从大到小)取系数 //确定排序以后,就可以进行按排序(从大到小)取系数
outerLoop:
for _, sortNumber := range sortNumbers { for _, sortNumber := range sortNumbers {
priceRatioSort = sortNumber priceRatioSort = sortNumber
priceRatioList = nil priceRatioList = nil
...@@ -82,17 +81,17 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -82,17 +81,17 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
priceRatio.Purchases = gjson.Get(value.String(), "purchases").Int() priceRatio.Purchases = gjson.Get(value.String(), "purchases").Int()
priceRatioList = append(priceRatioList, priceRatio) priceRatioList = append(priceRatioList, priceRatio)
} }
//是否满足特定条件的判断 //是否满足特定条件的判断
var hasSpecialCheck = false var hasSpecialCheck = false
conditionsMet := true
//判断是否有符合的商品名称 //判断是否有符合的商品名称
goodsNames := gjson.Get(priceRatioCache, "goods_name."+sortString).String() goodsNames := gjson.Get(priceRatioCache, "goods_name."+sortString).String()
if goodsNames != "" { if goodsNames != "" {
hasSpecialCheck = true hasSpecialCheck = true
goodsNameList := strings.Split(goodsNames, "@€@") goodsNameList := strings.Split(goodsNames, "@€@")
//找到有对应的商品名称,那么优先级肯定是最高的了 if !php2go.InArray(sku.GoodsName, goodsNameList) {
if php2go.InArray(sku.GoodsName, goodsNameList) { conditionsMet = false
foundRatio = true
break
} }
} }
...@@ -101,12 +100,9 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -101,12 +100,9 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
if brandIds != "" { if brandIds != "" {
hasSpecialCheck = true hasSpecialCheck = true
standardBrandIdList := strings.Split(brandIds, ",") standardBrandIdList := strings.Split(brandIds, ",")
//fmt.Println(standardBrandIdList)
standardBrandId := strconv.Itoa(sku.StandardBrand.StandardBrandId) standardBrandId := strconv.Itoa(sku.StandardBrand.StandardBrandId)
//找到有对应的品牌,那么优先级肯定是最高的了 if !php2go.InArray(standardBrandId, standardBrandIdList) {
if php2go.InArray(standardBrandId, standardBrandIdList) { conditionsMet = false
foundRatio = true
break
} }
} }
...@@ -116,10 +112,8 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -116,10 +112,8 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
hasSpecialCheck = true hasSpecialCheck = true
classIdList := strings.Split(classIds, ",") classIdList := strings.Split(classIds, ",")
classId := strconv.Itoa(sku.ClassID2) classId := strconv.Itoa(sku.ClassID2)
//找到有对应的分类ID,那么优先级肯定是最高的了 if !php2go.InArray(classId, classIdList) {
if php2go.InArray(classId, classIdList) { conditionsMet = false
foundRatio = true
break
} }
} }
...@@ -127,11 +121,9 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -127,11 +121,9 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
eccns := gjson.Get(priceRatioCache, "eccn."+sortString).String() eccns := gjson.Get(priceRatioCache, "eccn."+sortString).String()
if eccns != "" { if eccns != "" {
hasSpecialCheck = true hasSpecialCheck = true
eccnMatched := false
eccnList := strings.Split(eccns, ",") eccnList := strings.Split(eccns, ",")
//找到有对应的eccn,那么优先级肯定是最高的了
for _, eccn := range eccnList { for _, eccn := range eccnList {
//判断是否有百分号匹配
//如果是纯%,那就是不对的,要跳过
if strings.Replace(eccn, "%", "", 10) == "" { if strings.Replace(eccn, "%", "", 10) == "" {
continue continue
} }
...@@ -141,36 +133,44 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku { ...@@ -141,36 +133,44 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
if hasPrefix && hasSuffix { if hasPrefix && hasSuffix {
eccn = strings.Replace(eccn, "%", "", 10) eccn = strings.Replace(eccn, "%", "", 10)
if strings.Contains(sku.Eccn, eccn) { if strings.Contains(sku.Eccn, eccn) {
foundRatio = true eccnMatched = true
break outerLoop break
} }
} } else if hasPrefix {
if hasPrefix && !hasSuffix {
eccn = strings.Replace(eccn, "%", "", 10) eccn = strings.Replace(eccn, "%", "", 10)
if strings.HasSuffix(sku.Eccn, eccn) { if strings.HasSuffix(sku.Eccn, eccn) {
foundRatio = true eccnMatched = true
break outerLoop break
} }
} } else if hasSuffix {
if !hasPrefix && hasSuffix {
eccn = strings.Replace(eccn, "%", "", 10) eccn = strings.Replace(eccn, "%", "", 10)
if strings.HasPrefix(sku.Eccn, eccn) { if strings.HasPrefix(sku.Eccn, eccn) {
foundRatio = true eccnMatched = true
break outerLoop break
} }
} }
} else { } else {
if sku.Eccn == eccn { if sku.Eccn == eccn {
foundRatio = true eccnMatched = true
break outerLoop break
} }
} }
} }
if !eccnMatched {
conditionsMet = false
}
} }
//如果没有设置品牌和商品,那么这个优先级高的就会覆盖下面的了,不需要再去判断品牌和型号了
if hasSpecialCheck { if hasSpecialCheck {
continue if conditionsMet {
foundRatio = true
break
} else {
continue
}
} }
// 如果没有设置任何特殊条件,则默认匹配
foundRatio = true foundRatio = true
break break
} }
...@@ -555,7 +555,6 @@ func (ps PriceService) GetPriceRatio(sku model.LySku) (model.LySku, []model.Pric ...@@ -555,7 +555,6 @@ func (ps PriceService) GetPriceRatio(sku model.LySku) (model.LySku, []model.Pric
//然后确定排序 //然后确定排序
sortNumbers = sorter.IntSliceSortDesc(sortNumbers) sortNumbers = sorter.IntSliceSortDesc(sortNumbers)
//确定排序以后,就可以进行按排序(从大到小)取系数 //确定排序以后,就可以进行按排序(从大到小)取系数
outerLoop:
for _, sortNumber := range sortNumbers { for _, sortNumber := range sortNumbers {
priceRatioSort = sortNumber priceRatioSort = sortNumber
priceRatioList = nil priceRatioList = nil
...@@ -569,16 +568,15 @@ func (ps PriceService) GetPriceRatio(sku model.LySku) (model.LySku, []model.Pric ...@@ -569,16 +568,15 @@ func (ps PriceService) GetPriceRatio(sku model.LySku) (model.LySku, []model.Pric
} }
var hasSpecialCheck = false var hasSpecialCheck = false
conditionsMet := true
//判断是否有符合的商品名称 //判断是否有符合的商品名称
goodsNames := gjson.Get(priceRatioCache, "goods_name."+sortString).String() goodsNames := gjson.Get(priceRatioCache, "goods_name."+sortString).String()
if goodsNames != "" { if goodsNames != "" {
hasSpecialCheck = true hasSpecialCheck = true
goodsNameList := strings.Split(goodsNames, "@€@") goodsNameList := strings.Split(goodsNames, "@€@")
//找到有对应的商品名称,那么优先级肯定是最高的了 if !php2go.InArray(sku.GoodsName, goodsNameList) {
if php2go.InArray(sku.GoodsName, goodsNameList) { conditionsMet = false
foundRatio = true
break
} }
} }
...@@ -588,10 +586,8 @@ func (ps PriceService) GetPriceRatio(sku model.LySku) (model.LySku, []model.Pric ...@@ -588,10 +586,8 @@ func (ps PriceService) GetPriceRatio(sku model.LySku) (model.LySku, []model.Pric
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) { conditionsMet = false
foundRatio = true
break
} }
} }
...@@ -601,10 +597,8 @@ func (ps PriceService) GetPriceRatio(sku model.LySku) (model.LySku, []model.Pric ...@@ -601,10 +597,8 @@ func (ps PriceService) GetPriceRatio(sku model.LySku) (model.LySku, []model.Pric
hasSpecialCheck = true hasSpecialCheck = true
classIdList := strings.Split(classIds, ",") classIdList := strings.Split(classIds, ",")
classId := strconv.Itoa(sku.ClassID2) classId := strconv.Itoa(sku.ClassID2)
//找到有对应的分类ID,那么优先级肯定是最高的了 if !php2go.InArray(classId, classIdList) {
if php2go.InArray(classId, classIdList) { conditionsMet = false
foundRatio = true
break
} }
} }
...@@ -612,11 +606,9 @@ func (ps PriceService) GetPriceRatio(sku model.LySku) (model.LySku, []model.Pric ...@@ -612,11 +606,9 @@ func (ps PriceService) GetPriceRatio(sku model.LySku) (model.LySku, []model.Pric
eccns := gjson.Get(priceRatioCache, "eccn."+sortString).String() eccns := gjson.Get(priceRatioCache, "eccn."+sortString).String()
if eccns != "" { if eccns != "" {
hasSpecialCheck = true hasSpecialCheck = true
eccnMatched := false
eccnList := strings.Split(eccns, ",") eccnList := strings.Split(eccns, ",")
//找到有对应的eccn,那么优先级肯定是最高的了
for _, eccn := range eccnList { for _, eccn := range eccnList {
//判断是否有百分号匹配
//如果是纯%,那就是不对的,要跳过
if strings.Replace(eccn, "%", "", 10) == "" { if strings.Replace(eccn, "%", "", 10) == "" {
continue continue
} }
...@@ -626,36 +618,44 @@ func (ps PriceService) GetPriceRatio(sku model.LySku) (model.LySku, []model.Pric ...@@ -626,36 +618,44 @@ func (ps PriceService) GetPriceRatio(sku model.LySku) (model.LySku, []model.Pric
if hasPrefix && hasSuffix { if hasPrefix && hasSuffix {
eccn = strings.Replace(eccn, "%", "", 10) eccn = strings.Replace(eccn, "%", "", 10)
if strings.Contains(sku.Eccn, eccn) { if strings.Contains(sku.Eccn, eccn) {
foundRatio = true eccnMatched = true
break outerLoop break
} }
} } else if hasPrefix {
if hasPrefix && !hasSuffix {
eccn = strings.Replace(eccn, "%", "", 10) eccn = strings.Replace(eccn, "%", "", 10)
if strings.HasSuffix(sku.Eccn, eccn) { if strings.HasSuffix(sku.Eccn, eccn) {
foundRatio = true eccnMatched = true
break outerLoop break
} }
} } else if hasSuffix {
if !hasPrefix && hasSuffix {
eccn = strings.Replace(eccn, "%", "", 10) eccn = strings.Replace(eccn, "%", "", 10)
if strings.HasPrefix(sku.Eccn, eccn) { if strings.HasPrefix(sku.Eccn, eccn) {
foundRatio = true eccnMatched = true
break outerLoop break
} }
} }
} else { } else {
if sku.Eccn == eccn { if sku.Eccn == eccn {
foundRatio = true eccnMatched = true
break outerLoop break
} }
} }
} }
if !eccnMatched {
conditionsMet = false
}
} }
//如果没有设置品牌和商品,那么这个优先级高的就会覆盖下面的了,不需要再去判断品牌和型号了
if hasSpecialCheck { if hasSpecialCheck {
continue if conditionsMet {
foundRatio = true
break
} else {
continue
}
} }
// 如果没有设置任何特殊条件,则默认匹配
foundRatio = true foundRatio = true
break break
} }
......
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