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
88cd3dfe
authored
Aug 01, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
来源返回
parent
4c8751dd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
7 deletions
service/service_price.go
service/service_price.go
View file @
88cd3dfe
...
...
@@ -13,8 +13,8 @@ import (
type
PriceService
struct
{
}
//这里有个前置条件处理美金价,因为element(6)存到美金字段里面的是港币,rs(21)存到美金字段里的是人民币,buerklin(1676)是欧元
//所以要全部先转成正确的美金价才能显示,目前先写死汇率,因为目前没有地方能获取实时的各种转美金的汇率
//
这里有个前置条件处理美金价,因为element(6)存到美金字段里面的是港币,rs(21)存到美金字段里的是人民币,buerklin(1676)是欧元
//
所以要全部先转成正确的美金价才能显示,目前先写死汇率,因为目前没有地方能获取实时的各种转美金的汇率
func
(
ls
*
LyService
)
TransformSpecialSupplierPrice
(
supplierId
int64
,
priceUs
float64
,
usRatio
float64
)
float64
{
switch
supplierId
{
case
6
:
...
...
@@ -38,7 +38,7 @@ func (ls *LyService) TransformSpecialSupplierPrice(supplierId int64, priceUs flo
return
priceUs
}
//构建专营的阶梯价,现在专营只会存一个简单的成本价,阶梯数量是1,所以我这边要根据专营的阶梯系数去构建具体的阶梯价
//
构建专营的阶梯价,现在专营只会存一个简单的成本价,阶梯数量是1,所以我这边要根据专营的阶梯系数去构建具体的阶梯价
func
(
ps
*
PriceService
)
GenerateLadderPrice
(
sku
model
.
LySku
)
(
generatedLadderPrice
[]
model
.
LadderPrice
,
showPriceRatio
[]
model
.
PriceRatio
)
{
//先直接获取成本价原始值,判断第一个阶梯的阶梯数量是否为0,如果是0,那么代表是要走成本价生成,如果不是0,那么就要走阶梯价生成
firstLadderPurchases
:=
sku
.
LadderPrice
[
0
]
.
Purchases
...
...
@@ -65,22 +65,50 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) (generatedLadderPri
if
sku
.
Moq
<=
50
{
moq
:=
int
(
sku
.
Moq
)
fixedRatio
:=
make
(
map
[
int
]
float64
)
//当起订量是小于等于50的时候,阶梯数量和阶梯数是固定的,但是具体的利润还是要去取配置的值,因为固定死的阶梯数量是5,所以这边要直接取魔方配置9个的后5个
costLadderPriceRatio
:=
gjson
.
Get
(
priceRatio
,
"cost_ladder_price_egt50_lt200"
)
.
Map
()
if
len
(
costLadderPriceRatio
)
==
9
{
//priceRatioAndPurchases := costLadderPriceRatio[strconv.Itoa(i)]
//priceCnRatio := priceRatioAndPurchases.Get("price").Float()
var
fixedPurchases
[]
int
switch
{
case
sku
.
Moq
<
10
:
fixedPurchases
=
[]
int
{
moq
,
30
,
100
,
300
,
1000
}
break
case
sku
.
Moq
<
30
:
fixedPurchases
=
[]
int
{
moq
,
50
,
200
,
500
,
1000
}
break
default
:
fixedPurchases
=
[]
int
{
moq
,
200
,
500
,
1000
,
2000
}
break
}
for
index
,
purchase
:=
range
fixedPurchases
{
//costLadderPriceRatio这个redis是字典,下标从1开始的,所以要从第5个开始取
ratio
:=
costLadderPriceRatio
[
strconv
.
Itoa
(
5
+
index
)]
.
Get
(
"price"
)
.
Float
()
ratioUsd
:=
costLadderPriceRatio
[
strconv
.
Itoa
(
5
+
index
)]
.
Get
(
"price_us"
)
.
Float
()
//同时还要构建价格系数展示在商品服务
showPriceRatio
=
append
(
showPriceRatio
,
model
.
PriceRatio
{
Ratio
:
ratio
,
RatioUsd
:
ratioUsd
})
generatedLadderPrice
=
append
(
generatedLadderPrice
,
model
.
LadderPrice
{
Purchases
:
int64
(
purchase
),
PriceCn
:
c
.
MyRound
(
c
.
MulFloat
(
costPriceCn
,
ratio
),
4
),
PriceUs
:
c
.
MyRound
(
c
.
MulFloat
(
costPriceUs
,
ratioUsd
),
4
),
})
}
}
else
{
//如果魔方不是9个阶梯,那么就是魔方配置出问题了,还是要走固定的配置(主要是为了防止卖亏)
//var fixedRatioSlice map[int]float64
switch
{
case
sku
.
Moq
<
10
:
//fixedRatio = map[int]float64{moq: 1.07, 30: 1.08, 100: 1.09, 300: 1.1, 1000: 1.11}
fixedRatio
=
map
[
int
]
float64
{
moq
:
1.11
,
30
:
1.1
,
100
:
1.09
,
300
:
1.08
,
1000
:
1.07
}
break
case
sku
.
Moq
<
30
:
//fixedRatio = map[int]float64{moq: 1.07, 50: 1.08, 200: 1.09, 500: 1.1, 1000: 1.11}
fixedRatio
=
map
[
int
]
float64
{
moq
:
1.11
,
50
:
1.1
,
200
:
1.09
,
500
:
1.08
,
1000
:
1.07
}
break
default
:
//fixedRatio = map[int]float64{moq: 1.07, 200: 1.08, 500: 1.09, 1000: 1.1, 2000: 1.11}
fixedRatio
=
map
[
int
]
float64
{
moq
:
1.11
,
200
:
1.1
,
500
:
1.09
,
1000
:
1.08
,
2000
:
1.07
}
break
}
//然后根据一开始只有一个的阶梯价去生成阶梯价格
for
purchases
,
ratio
:=
range
fixedRatio
{
//同时还要构建价格系数展示在商品服务
...
...
@@ -91,6 +119,8 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) (generatedLadderPri
PriceUs
:
c
.
MyRound
(
c
.
MulFloat
(
costPriceUs
,
ratio
),
4
),
})
}
}
sort
.
Slice
(
showPriceRatio
,
func
(
i
,
j
int
)
bool
{
return
showPriceRatio
[
i
]
.
Ratio
>
showPriceRatio
[
j
]
.
Ratio
})
...
...
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