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
54266907
authored
Aug 18, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
优化
parent
f1d51788
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
6 deletions
service/service_ly_common.go
service/service_price.go
service/service_ly_common.go
View file @
54266907
...
...
@@ -2,6 +2,7 @@ package service
import
(
"encoding/json"
"fmt"
"github.com/gomodule/redigo/redis"
_
"github.com/iancoleman/orderedmap"
"github.com/syyongx/php2go"
...
...
@@ -276,6 +277,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
if
ladderPrice
[
0
]
.
PriceCostUs
==
0
&&
ladderPrice
[
0
]
.
PriceCostCn
==
0
{
sku
=
priceService
.
GenerateLadderPrice
(
sku
)
ladderPrice
=
sku
.
LadderPrice
fmt
.
Println
(
ladderPrice
)
}
}
//获取折扣系数
...
...
@@ -283,6 +285,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
data
=
make
([]
model
.
LadderPrice
,
len
(
ladderPrice
))
for
key
,
price
:=
range
ladderPrice
{
price
.
PriceUs
=
priceService
.
TransformSpecialSupplierPrice
(
sku
,
price
.
PriceUs
)
if
price
.
Purchases
==
0
{
continue
}
...
...
@@ -385,7 +388,6 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
if
!
hasCoefficient
{
coefficient
=
defaultCoefficient
}
//下面是计算价格
//价格计算文档 https://docs.qq.com/doc/DR3RJcnNPeUNkWHRk
// 为何是固定的1.13,关税基本不会变,有变的话跟产品沟通手动修改即可
...
...
@@ -393,7 +395,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
for
key
,
price
:=
range
sku
.
LadderPrice
{
//这里有个前置条件处理美金价,因为element(6)存到美金字段里面的是港币,rs(21)存到美金字段里的是人民币,buerklin(1676)是欧元
//所以要全部先转成正确的美金价才能显示,目前先写死汇率,因为目前没有地方能获取实时的各种转美金的汇率
price
.
PriceUs
=
priceService
.
TransformSpecialSupplierPrice
(
sku
.
SupplierId
,
price
.
PriceUs
,
coefficient
.
Ratio
)
price
.
PriceUs
=
priceService
.
TransformSpecialSupplierPrice
(
sku
,
price
.
PriceUs
)
originalPrice
=
append
(
originalPrice
,
model
.
OriginPrice
{
PriceUs
:
price
.
PriceUs
,
Purchases
:
price
.
Purchases
,
...
...
service/service_price.go
View file @
54266907
...
...
@@ -174,7 +174,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
//是否有设置最低利润点阶梯,不足5个阶梯时,最高阶梯对应的最小利润点阶梯
var
ladderPriceMiniProfitLevel
int
fmt
.
Println
(
"是否找到系数"
,
foundRatio
)
fmt
.
Println
(
"系数redis数据为 : "
,
priceRatioCache
)
//
fmt.Println("系数redis数据为 : ", priceRatioCache)
fmt
.
Println
(
"具体系数为 : "
,
priceRatioList
)
if
foundRatio
{
priceRatioSortStr
:=
strconv
.
Itoa
(
priceRatioSort
)
...
...
@@ -603,19 +603,31 @@ func (ps PriceService) GetPriceRatio(sku model.LySku) (model.LySku, []model.Pric
return
sku
,
priceRatioList
}
//
TransformSpecialSupplierPrice
这里有个前置条件处理美金价,因为element(6)存到美金字段里面的是港币,rs(21)存到美金字段里的是人民币,buerklin(1676)是欧元
// 这里有个前置条件处理美金价,因为element(6)存到美金字段里面的是港币,rs(21)存到美金字段里的是人民币,buerklin(1676)是欧元
// 所以要全部先转成正确的美金价才能显示
func
(
ps
*
PriceService
)
TransformSpecialSupplierPrice
(
s
upplierId
int64
,
priceUs
float64
,
usRatio
float64
)
float64
{
func
(
ps
*
PriceService
)
TransformSpecialSupplierPrice
(
s
ku
model
.
LySku
,
priceUs
float64
)
float64
{
//去redis获取价格
redisCon
:=
gredis
.
Conn
(
"default_r"
)
defer
func
()
{
redisCon
.
Close
()
}()
currency
,
_
:=
redis
.
Int
(
redisCon
.
Do
(
"HGET"
,
"magic_cube_supplier_currency"
,
supplierId
))
usRatio
,
_
:=
redis
.
Float64
(
redisCon
.
Do
(
"HGET"
,
"erp_rate"
,
2
))
var
currency
int
//这个供应商把人民币存到美金这个字段了,所以要提前判断和返回
if
sku
.
SupplierId
==
6
{
priceUs
=
c
.
MyRound
(
c
.
DivFloat
(
priceUs
,
usRatio
),
4
)
return
priceUs
}
if
sku
.
SupplierId
!=
17
{
currency
,
_
=
redis
.
Int
(
redisCon
.
Do
(
"HGET"
,
"magic_cube_supplier_currency"
,
sku
.
SupplierId
))
}
else
{
currency
,
_
=
redis
.
Int
(
redisCon
.
Do
(
"HGET"
,
"magic_cube_supplier_currency"
,
sku
.
Canal
))
}
if
currency
>
0
{
//这里进行转换,因为这里都只能取到对应的币种转人民币的比率,我们没有直接各种币种转美金的数据,所以我这边要
//先根据对应币种转人民币,然后根据人民币转美金,才能得到不同币种对应美金的汇率
rmbRatio
,
_
:=
redis
.
Float64
(
redisCon
.
Do
(
"HGET"
,
"erp_rate"
,
currency
))
fmt
.
Println
(
"特殊转换"
,
rmbRatio
)
//人民币汇率转美金汇率
usRatio
=
c
.
MyRound
(
c
.
DivFloat
(
rmbRatio
,
usRatio
),
2
)
priceUs
=
c
.
MyRound
(
c
.
DivFloat
(
priceUs
,
usRatio
),
4
)
...
...
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