Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄成意
/
go_sku_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7bf43ffe
authored
Aug 05, 2025
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修改逻辑
parent
0a6d090c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
62 deletions
service/service_price.go
service/service_price.go
View file @
7bf43ffe
...
...
@@ -68,7 +68,6 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
//然后确定排序
sortNumbers
=
sorter
.
IntSliceSortDesc
(
sortNumbers
)
//确定排序以后,就可以进行按排序(从大到小)取系数
outerLoop
:
for
_
,
sortNumber
:=
range
sortNumbers
{
priceRatioSort
=
sortNumber
priceRatioList
=
nil
...
...
@@ -82,17 +81,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
}
}
...
...
@@ -101,12 +100,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
}
}
...
...
@@ -116,10 +112,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
}
}
...
...
@@ -127,11 +121,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
}
...
...
@@ -141,36 +133,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
}
...
...
@@ -555,7 +555,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
...
...
@@ -569,16 +568,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
}
}
...
...
@@ -588,10 +586,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
}
}
...
...
@@ -601,10 +597,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
}
}
...
...
@@ -612,11 +606,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
}
...
...
@@ -626,36 +618,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
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment