Commit f024c72d by 杨树贤

Merge branch 'ysx-售价组的或判断改成与判断-20250805' into dev

parents 766455de 7bf43ffe
......@@ -67,7 +67,6 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
//然后确定排序
sortNumbers = sorter.IntSliceSortDesc(sortNumbers)
//确定排序以后,就可以进行按排序(从大到小)取系数
outerLoop:
for _, sortNumber := range sortNumbers {
priceRatioSort = sortNumber
priceRatioList = nil
......@@ -81,17 +80,17 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
priceRatio.Purchases = gjson.Get(value.String(), "purchases").Int()
priceRatioList = append(priceRatioList, priceRatio)
}
//是否满足特定条件的判断
//是否满足特定条件的判断
var hasSpecialCheck = false
conditionsMet := true
//判断是否有符合的商品名称
goodsNames := gjson.Get(priceRatioCache, "goods_name."+sortString).String()
if goodsNames != "" {
hasSpecialCheck = true
goodsNameList := strings.Split(goodsNames, "@€@")
//找到有对应的商品名称,那么优先级肯定是最高的了
if php2go.InArray(sku.GoodsName, goodsNameList) {
foundRatio = true
break
if !php2go.InArray(sku.GoodsName, goodsNameList) {
conditionsMet = false
}
}
......@@ -100,12 +99,9 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
if brandIds != "" {
hasSpecialCheck = true
standardBrandIdList := strings.Split(brandIds, ",")
//fmt.Println(standardBrandIdList)
standardBrandId := strconv.Itoa(sku.StandardBrand.StandardBrandId)
//找到有对应的品牌,那么优先级肯定是最高的了
if php2go.InArray(standardBrandId, standardBrandIdList) {
foundRatio = true
break
if !php2go.InArray(standardBrandId, standardBrandIdList) {
conditionsMet = false
}
}
......@@ -115,10 +111,8 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
hasSpecialCheck = true
classIdList := strings.Split(classIds, ",")
classId := strconv.Itoa(sku.ClassID2)
//找到有对应的分类ID,那么优先级肯定是最高的了
if php2go.InArray(classId, classIdList) {
foundRatio = true
break
if !php2go.InArray(classId, classIdList) {
conditionsMet = false
}
}
......@@ -126,11 +120,9 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
eccns := gjson.Get(priceRatioCache, "eccn."+sortString).String()
if eccns != "" {
hasSpecialCheck = true
eccnMatched := false
eccnList := strings.Split(eccns, ",")
//找到有对应的eccn,那么优先级肯定是最高的了
for _, eccn := range eccnList {
//判断是否有百分号匹配
//如果是纯%,那就是不对的,要跳过
if strings.Replace(eccn, "%", "", 10) == "" {
continue
}
......@@ -140,36 +132,44 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
if hasPrefix && hasSuffix {
eccn = strings.Replace(eccn, "%", "", 10)
if strings.Contains(sku.Eccn, eccn) {
foundRatio = true
break outerLoop
eccnMatched = true
break
}
}
if hasPrefix && !hasSuffix {
} else if hasPrefix {
eccn = strings.Replace(eccn, "%", "", 10)
if strings.HasSuffix(sku.Eccn, eccn) {
foundRatio = true
break outerLoop
eccnMatched = true
break
}
}
if !hasPrefix && hasSuffix {
} else if hasSuffix {
eccn = strings.Replace(eccn, "%", "", 10)
if strings.HasPrefix(sku.Eccn, eccn) {
foundRatio = true
break outerLoop
eccnMatched = true
break
}
}
} else {
if sku.Eccn == eccn {
foundRatio = true
break outerLoop
eccnMatched = true
break
}
}
}
if !eccnMatched {
conditionsMet = false
}
}
//如果没有设置品牌和商品,那么这个优先级高的就会覆盖下面的了,不需要再去判断品牌和型号了
if hasSpecialCheck {
continue
if conditionsMet {
foundRatio = true
break
} else {
continue
}
}
// 如果没有设置任何特殊条件,则默认匹配
foundRatio = true
break
}
......@@ -554,7 +554,6 @@ func (ps PriceService) GetPriceRatio(sku model.LySku) (model.LySku, []model.Pric
//然后确定排序
sortNumbers = sorter.IntSliceSortDesc(sortNumbers)
//确定排序以后,就可以进行按排序(从大到小)取系数
outerLoop:
for _, sortNumber := range sortNumbers {
priceRatioSort = sortNumber
priceRatioList = nil
......@@ -568,16 +567,15 @@ func (ps PriceService) GetPriceRatio(sku model.LySku) (model.LySku, []model.Pric
}
var hasSpecialCheck = false
conditionsMet := true
//判断是否有符合的商品名称
goodsNames := gjson.Get(priceRatioCache, "goods_name."+sortString).String()
if goodsNames != "" {
hasSpecialCheck = true
goodsNameList := strings.Split(goodsNames, "@€@")
//找到有对应的商品名称,那么优先级肯定是最高的了
if php2go.InArray(sku.GoodsName, goodsNameList) {
foundRatio = true
break
if !php2go.InArray(sku.GoodsName, goodsNameList) {
conditionsMet = false
}
}
......@@ -587,10 +585,8 @@ func (ps PriceService) GetPriceRatio(sku model.LySku) (model.LySku, []model.Pric
hasSpecialCheck = true
standardBrandIdList := strings.Split(brandIds, ",")
standardBrandId := strconv.Itoa(sku.StandardBrand.StandardBrandId)
//找到有对应的品牌,那么优先级肯定是最高的了
if php2go.InArray(standardBrandId, standardBrandIdList) {
foundRatio = true
break
if !php2go.InArray(standardBrandId, standardBrandIdList) {
conditionsMet = false
}
}
......@@ -600,10 +596,8 @@ func (ps PriceService) GetPriceRatio(sku model.LySku) (model.LySku, []model.Pric
hasSpecialCheck = true
classIdList := strings.Split(classIds, ",")
classId := strconv.Itoa(sku.ClassID2)
//找到有对应的分类ID,那么优先级肯定是最高的了
if php2go.InArray(classId, classIdList) {
foundRatio = true
break
if !php2go.InArray(classId, classIdList) {
conditionsMet = false
}
}
......@@ -611,11 +605,9 @@ func (ps PriceService) GetPriceRatio(sku model.LySku) (model.LySku, []model.Pric
eccns := gjson.Get(priceRatioCache, "eccn."+sortString).String()
if eccns != "" {
hasSpecialCheck = true
eccnMatched := false
eccnList := strings.Split(eccns, ",")
//找到有对应的eccn,那么优先级肯定是最高的了
for _, eccn := range eccnList {
//判断是否有百分号匹配
//如果是纯%,那就是不对的,要跳过
if strings.Replace(eccn, "%", "", 10) == "" {
continue
}
......@@ -625,36 +617,44 @@ func (ps PriceService) GetPriceRatio(sku model.LySku) (model.LySku, []model.Pric
if hasPrefix && hasSuffix {
eccn = strings.Replace(eccn, "%", "", 10)
if strings.Contains(sku.Eccn, eccn) {
foundRatio = true
break outerLoop
eccnMatched = true
break
}
}
if hasPrefix && !hasSuffix {
} else if hasPrefix {
eccn = strings.Replace(eccn, "%", "", 10)
if strings.HasSuffix(sku.Eccn, eccn) {
foundRatio = true
break outerLoop
eccnMatched = true
break
}
}
if !hasPrefix && hasSuffix {
} else if hasSuffix {
eccn = strings.Replace(eccn, "%", "", 10)
if strings.HasPrefix(sku.Eccn, eccn) {
foundRatio = true
break outerLoop
eccnMatched = true
break
}
}
} else {
if sku.Eccn == eccn {
foundRatio = true
break outerLoop
eccnMatched = true
break
}
}
}
if !eccnMatched {
conditionsMet = false
}
}
//如果没有设置品牌和商品,那么这个优先级高的就会覆盖下面的了,不需要再去判断品牌和型号了
if hasSpecialCheck {
continue
if conditionsMet {
foundRatio = true
break
} else {
continue
}
}
// 如果没有设置任何特殊条件,则默认匹配
foundRatio = true
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