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
d0f2e6bf
authored
Nov 30, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
自定义汇率
parent
56155c8e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
1 deletions
model/ly_sku.go
service/service_ly_common.go
service/service_price.go
model/ly_sku.go
View file @
d0f2e6bf
...
@@ -81,6 +81,8 @@ type LySku struct {
...
@@ -81,6 +81,8 @@ type LySku struct {
PriceRatio
[]
PriceRatio
`json:"price_ratio"`
PriceRatio
[]
PriceRatio
`json:"price_ratio"`
Source
int
`json:"source"`
Source
int
`json:"source"`
OriginCurrencySymbol
string
`json:"origin_currency_symbol,omitempty"`
OriginCurrencySymbol
string
`json:"origin_currency_symbol,omitempty"`
CustomizeRateRMB
float64
CustomizeRateUs
float64
}
}
type
DiscountRatio
struct
{
type
DiscountRatio
struct
{
...
...
service/service_ly_common.go
View file @
d0f2e6bf
...
@@ -451,7 +451,13 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
...
@@ -451,7 +451,13 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
if
sku
.
SupplierId
==
1688
{
if
sku
.
SupplierId
==
1688
{
priceCostCn
=
c
.
MulFloat
(
price
.
PriceCn
,
1
)
priceCostCn
=
c
.
MulFloat
(
price
.
PriceCn
,
1
)
}
else
{
}
else
{
usdRatio
,
_
:=
redis
.
Float64
(
redisCon
.
Do
(
"HGET"
,
"erp_rate"
,
2
))
//这里是去取实时美金汇率,并且计算人民币价格
var
usdRatio
float64
if
sku
.
CustomizeRateRMB
!=
0
{
usdRatio
=
sku
.
CustomizeRateRMB
}
else
{
usdRatio
,
_
=
redis
.
Float64
(
redisCon
.
Do
(
"HGET"
,
"erp_rate"
,
2
))
}
priceCostCn
=
c
.
MulFloat
(
price
.
PriceUs
,
usdRatio
,
tax
)
priceCostCn
=
c
.
MulFloat
(
price
.
PriceUs
,
usdRatio
,
tax
)
}
}
priceCostCn
=
c
.
MulFloat
(
c
.
MyRound
(
priceCostCn
,
4
),
sku
.
DiscountRatio
.
Ratio
)
priceCostCn
=
c
.
MulFloat
(
c
.
MyRound
(
priceCostCn
,
4
),
sku
.
DiscountRatio
.
Ratio
)
...
...
service/service_price.go
View file @
d0f2e6bf
...
@@ -663,6 +663,28 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku) model.LyS
...
@@ -663,6 +663,28 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku) model.LyS
}
}
hasTax
=
gjson
.
Get
(
currencyConfig
,
"has_tax"
)
.
Bool
()
hasTax
=
gjson
.
Get
(
currencyConfig
,
"has_tax"
)
.
Bool
()
symbol
=
gjson
.
Get
(
currencyConfig
,
"symbol"
)
.
String
()
symbol
=
gjson
.
Get
(
currencyConfig
,
"symbol"
)
.
String
()
//自定义汇率优先级最高
customizeRateRmb
:=
gjson
.
Get
(
currencyConfig
,
"customize_rate_rmb"
)
.
Float
()
customizeRateUsd
:=
gjson
.
Get
(
currencyConfig
,
"customize_rate_usd"
)
.
Float
()
if
customizeRateUsd
!=
0
{
for
index
,
price
:=
range
sku
.
LadderPrice
{
priceUs
:=
price
.
PriceUs
priceUs
=
c
.
MyRound
(
c
.
MulFloat
(
priceUs
,
customizeRateUsd
),
4
)
if
hasTax
{
priceUs
=
c
.
MyRound
(
c
.
DivFloat
(
priceUs
,
1.13
),
4
)
}
sku
.
LadderPrice
[
index
]
.
PriceUs
=
priceUs
sku
.
OriginalPrice
[
index
]
.
PriceUs
=
priceUs
}
}
if
customizeRateRmb
!=
0
{
//因为计算人民币价格的逻辑不在这里,所以记录下来,提供给计算人民币价格的逻辑
sku
.
CustomizeRateRMB
=
customizeRateRmb
}
if
customizeRateUsd
==
0
{
//这里进行转换,因为这里都只能取到对应的币种转人民币的比率,我们没有直接各种币种转美金的数据,所以我这边要
//这里进行转换,因为这里都只能取到对应的币种转人民币的比率,我们没有直接各种币种转美金的数据,所以我这边要
//先根据对应币种转人民币,然后根据人民币转美金,才能得到不同币种对应美金的汇率
//先根据对应币种转人民币,然后根据人民币转美金,才能得到不同币种对应美金的汇率
rmbRatio
,
_
:=
redis
.
Float64
(
redisCon
.
Do
(
"HGET"
,
"erp_rate"
,
currency
))
rmbRatio
,
_
:=
redis
.
Float64
(
redisCon
.
Do
(
"HGET"
,
"erp_rate"
,
currency
))
...
@@ -680,6 +702,8 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku) model.LyS
...
@@ -680,6 +702,8 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku) model.LyS
sku
.
OriginalPrice
[
index
]
.
PriceUs
=
priceUs
sku
.
OriginalPrice
[
index
]
.
PriceUs
=
priceUs
}
}
}
}
}
sku
.
OriginCurrencySymbol
=
symbol
sku
.
OriginCurrencySymbol
=
symbol
return
sku
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