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
ed04fedb
authored
Apr 22, 2025
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
新增产地判断
parent
150e4f47
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
0 deletions
model/ly_sku.go
pkg/common/function.go
service/service_ly.go
service/service_ly_common.go
model/ly_sku.go
View file @
ed04fedb
...
...
@@ -88,6 +88,8 @@ type LySku struct {
CustomizeRateUs
float64
SpuEccn
string
`json:"spu_eccn"`
CustomPriceList
[]
CustomPrice
`json:"custom_price_list"`
Coo
string
`json:"coo"`
Tariff
float64
`json:"tariff"`
}
type
DiscountRatio
struct
{
...
...
@@ -278,6 +280,8 @@ func InitSkuData(sku string) (data LySku) {
data
.
OriginalPrice
=
getOriginPrice
(
LadderPriceStr
)
data
.
DatabasePrice
=
getDatabasePrice
(
LadderPriceStr
)
data
.
Coo
=
gjson
.
Get
(
sku
,
"coo"
)
.
String
()
return
}
...
...
pkg/common/function.go
View file @
ed04fedb
...
...
@@ -665,3 +665,12 @@ func ConvertToGrams(input string) (float64, error) {
return
0
,
fmt
.
Errorf
(
"未知的重量单位: %s"
,
unit
)
}
}
func
CheckIntSliceContains
(
target
int
,
slice
[]
int
)
bool
{
for
_
,
value
:=
range
slice
{
if
value
==
target
{
return
true
}
}
return
false
}
service/service_ly.go
View file @
ed04fedb
...
...
@@ -246,6 +246,9 @@ func (ls *LyService) LyGoodsDetail(ctx *gin.Context, goodsIds []string, ch chan
var
TagService
TagsService
sku
.
GoodsTag
=
TagService
.
GetTags
(
sku
.
GoodsId
,
0
)
//获取关税以及价格转换
sku
=
ls
.
GetTariffAndPrice
(
sku
)
//用spuInfo补全信息
sku
=
ls
.
CombineSup
(
sku
,
spu
)
//最后一步,将sku的全部信息放到有序map里面
...
...
service/service_ly_common.go
View file @
ed04fedb
...
...
@@ -563,3 +563,40 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
return
sku
}
func
(
ls
*
LyService
)
GetTariffAndPrice
(
sku
model
.
LySku
)
model
.
LySku
{
if
len
(
sku
.
LadderPrice
)
==
0
{
return
sku
}
//判断场地是否是美国,是美国的话,输出关税率以及转换价格
//https://cf.ichunt.net/pages/viewpage.action?pageId=35326045
usLabelList
:=
[]
string
{
"USA"
,
"US"
,
}
usSupplierIdList
:=
[]
int
{
6
,
19
,
7
,
1675
,
}
//先判断供应商对不对
if
!
c
.
CheckIntSliceContains
(
int
(
sku
.
SupplierId
),
usSupplierIdList
)
{
return
sku
}
if
php2go
.
InArray
(
sku
.
Coo
,
usLabelList
)
{
//转换价格
//判断原始人民币有没有价格,没有的话,那就是最终的人民币价格 X 2.25
var
transformedLadderPrice
[]
model
.
LadderPrice
transformedLadderPrice
=
sku
.
LadderPrice
for
index
,
price
:=
range
sku
.
LadderPrice
{
transformedLadderPrice
[
index
]
.
PriceCn
=
c
.
MyRound
(
c
.
MulFloat
(
price
.
PriceCn
,
2.25
),
4
)
transformedLadderPrice
[
index
]
.
PriceAc
=
c
.
MyRound
(
c
.
MulFloat
(
price
.
PriceAc
,
2.25
),
4
)
}
sku
.
Tariff
=
2.25
}
return
sku
}
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