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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
15 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,22 +663,46 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku) model.LyS
...
@@ -663,22 +663,46 @@ 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
()
//这里进行转换,因为这里都只能取到对应的币种转人民币的比率,我们没有直接各种币种转美金的数据,所以我这边要
//先根据对应币种转人民币,然后根据人民币转美金,才能得到不同币种对应美金的汇率
//自定义汇率优先级最高
rmbRatio
,
_
:=
redis
.
Float64
(
redisCon
.
Do
(
"HGET"
,
"erp_rate"
,
currency
))
customizeRateRmb
:=
gjson
.
Get
(
currencyConfig
,
"customize_rate_rmb"
)
.
Float
()
//fmt.Println("特殊转换", rmbRatio)
customizeRateUsd
:=
gjson
.
Get
(
currencyConfig
,
"customize_rate_usd"
)
.
Float
()
//fmt.Println(rmbRatio, usRatio)
if
customizeRateUsd
!=
0
{
//人民币汇率转美金汇率
for
index
,
price
:=
range
sku
.
LadderPrice
{
usRatio
=
c
.
MyRound
(
c
.
DivFloat
(
rmbRatio
,
usRatio
),
10
)
priceUs
:=
price
.
PriceUs
for
index
,
price
:=
range
sku
.
LadderPrice
{
priceUs
=
c
.
MyRound
(
c
.
MulFloat
(
priceUs
,
customizeRateUsd
),
4
)
priceUs
:=
price
.
PriceUs
if
hasTax
{
priceUs
=
c
.
MyRound
(
c
.
MulFloat
(
priceUs
,
usRatio
),
4
)
priceUs
=
c
.
MyRound
(
c
.
DivFloat
(
priceUs
,
1.13
),
4
)
if
hasTax
{
}
priceUs
=
c
.
MyRound
(
c
.
DivFloat
(
priceUs
,
1.13
),
4
)
sku
.
LadderPrice
[
index
]
.
PriceUs
=
priceUs
sku
.
OriginalPrice
[
index
]
.
PriceUs
=
priceUs
}
}
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
))
//fmt.Println("特殊转换", rmbRatio)
//fmt.Println(rmbRatio, usRatio)
//人民币汇率转美金汇率
usRatio
=
c
.
MyRound
(
c
.
DivFloat
(
rmbRatio
,
usRatio
),
10
)
for
index
,
price
:=
range
sku
.
LadderPrice
{
priceUs
:=
price
.
PriceUs
priceUs
=
c
.
MyRound
(
c
.
MulFloat
(
priceUs
,
usRatio
),
4
)
if
hasTax
{
priceUs
=
c
.
MyRound
(
c
.
DivFloat
(
priceUs
,
1.13
),
4
)
}
sku
.
LadderPrice
[
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