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
1071482a
authored
Jul 03, 2023
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
起订量小于50取利润系数问题
parent
a3041195
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
7 deletions
service/service_ly_common.go
service/service_price.go
service/service_ly_common.go
View file @
1071482a
...
@@ -251,12 +251,12 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
...
@@ -251,12 +251,12 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
//先去读取成本折扣系数
//先去读取成本折扣系数
//找一个标志位,因为默认的全局折扣系数的数据格式和非全局的是不一样的
//找一个标志位,因为默认的全局折扣系数的数据格式和非全局的是不一样的
isDefaultDiscoutRatio
:=
false
isDefaultDiscou
n
tRatio
:=
false
discountRatio
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"magic_cube_channel_discount_daigou"
,
sku
.
SupplierId
))
discountRatio
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"magic_cube_channel_discount_daigou"
,
sku
.
SupplierId
))
checkNullRation
:=
gjson
.
Get
(
discountRatio
,
"ration"
)
.
String
()
checkNullRation
:=
gjson
.
Get
(
discountRatio
,
"ration"
)
.
String
()
//如果这个渠道没有对应的折扣系数,那么就去读取全局的
//如果这个渠道没有对应的折扣系数,那么就去读取全局的
if
discountRatio
==
""
||
checkNullRation
==
"{}"
{
if
discountRatio
==
""
||
checkNullRation
==
"{}"
{
isDefaultDiscoutRatio
=
true
isDefaultDiscou
n
tRatio
=
true
discountRatio
,
_
=
redis
.
String
(
redisCon
.
Do
(
"GET"
,
"magic_cube_channel_discount_default_daigou"
))
discountRatio
,
_
=
redis
.
String
(
redisCon
.
Do
(
"GET"
,
"magic_cube_channel_discount_default_daigou"
))
}
}
var
cnDiscountRatio
float64
var
cnDiscountRatio
float64
...
@@ -264,7 +264,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
...
@@ -264,7 +264,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
//是否找到对应的折扣系数,找不到就去找默认
//是否找到对应的折扣系数,找不到就去找默认
findedDiscountRatio
:=
false
findedDiscountRatio
:=
false
//如果有默认系数,那么就去找默认系数
//如果有默认系数,那么就去找默认系数
if
isDefaultDiscoutRatio
{
if
isDefaultDiscou
n
tRatio
{
}
else
{
}
else
{
//拿到系数以后,就要去计算
//拿到系数以后,就要去计算
//拿出里面的所有排序,以人民币系数为准
//拿出里面的所有排序,以人民币系数为准
...
...
service/service_price.go
View file @
1071482a
...
@@ -65,22 +65,50 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) (generatedLadderPri
...
@@ -65,22 +65,50 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) (generatedLadderPri
if
sku
.
Moq
<=
50
{
if
sku
.
Moq
<=
50
{
moq
:=
int
(
sku
.
Moq
)
moq
:=
int
(
sku
.
Moq
)
fixedRatio
:=
make
(
map
[
int
]
float64
)
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
//var fixedRatioSlice map[int]float64
switch
{
switch
{
case
sku
.
Moq
<
10
:
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
}
fixedRatio
=
map
[
int
]
float64
{
moq
:
1.11
,
30
:
1.1
,
100
:
1.09
,
300
:
1.08
,
1000
:
1.07
}
break
break
case
sku
.
Moq
<
30
:
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
}
fixedRatio
=
map
[
int
]
float64
{
moq
:
1.11
,
50
:
1.1
,
200
:
1.09
,
500
:
1.08
,
1000
:
1.07
}
break
break
default
:
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
}
fixedRatio
=
map
[
int
]
float64
{
moq
:
1.11
,
200
:
1.1
,
500
:
1.09
,
1000
:
1.08
,
2000
:
1.07
}
break
break
}
}
//然后根据一开始只有一个的阶梯价去生成阶梯价格
//然后根据一开始只有一个的阶梯价去生成阶梯价格
for
purchases
,
ratio
:=
range
fixedRatio
{
for
purchases
,
ratio
:=
range
fixedRatio
{
//同时还要构建价格系数展示在商品服务
//同时还要构建价格系数展示在商品服务
...
@@ -91,6 +119,8 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) (generatedLadderPri
...
@@ -91,6 +119,8 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) (generatedLadderPri
PriceUs
:
c
.
MyRound
(
c
.
MulFloat
(
costPriceUs
,
ratio
),
4
),
PriceUs
:
c
.
MyRound
(
c
.
MulFloat
(
costPriceUs
,
ratio
),
4
),
})
})
}
}
}
sort
.
Slice
(
showPriceRatio
,
func
(
i
,
j
int
)
bool
{
sort
.
Slice
(
showPriceRatio
,
func
(
i
,
j
int
)
bool
{
return
showPriceRatio
[
i
]
.
Ratio
>
showPriceRatio
[
j
]
.
Ratio
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