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
99d38893
authored
Aug 18, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
价格展示问题
parent
54266907
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
3 deletions
service/service_price.go
service/service_price.go
View file @
99d38893
...
...
@@ -19,6 +19,8 @@ type PriceService struct {
// 构建专营的阶梯价,现在专营只会存一个简单的成本价,阶梯数量是1,所以我这边要根据专营的阶梯系数去构建具体的阶梯价
func
(
ps
*
PriceService
)
GenerateLadderPrice
(
sku
model
.
LySku
)
model
.
LySku
{
//需要展示的价格系数
var
showPriceRatioList
[]
model
.
PriceRatio
//先去找到对应的价格系数
var
ratioDataKey
string
if
sku
.
Moq
<=
50
{
...
...
@@ -167,7 +169,6 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
}
priceRatioSort
=
-
1
}
sku
.
PriceRatio
=
priceRatioList
sku
.
PriceRatioSort
=
priceRatioSort
//这是用来展示在商品服务的价格系数,专营的系数和代购的不一样,所以要转换一下展示形式
...
...
@@ -213,16 +214,21 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
fixedPurchases
=
[]
int
{
moq
,
200
,
500
,
1000
,
2000
}
break
}
for
index
,
purchase
:=
range
fixedPurchases
{
for
index
,
purchase
s
:=
range
fixedPurchases
{
//costLadderPriceRatio这个redis是字典,下标从0开始的,所以要从第5个开始取
ratio
:=
priceRatioList
[
4
+
index
]
.
Ratio
ratioUsd
:=
priceRatioList
[
4
+
index
]
.
RatioUsd
//同时还要构建价格系数展示在商品服务
generatedLadderPrice
=
append
(
generatedLadderPrice
,
model
.
LadderPrice
{
Purchases
:
int64
(
purchase
),
Purchases
:
int64
(
purchase
s
),
PriceCn
:
c
.
MyRound
(
c
.
MulFloat
(
costPriceCn
,
ratio
),
4
),
PriceUs
:
c
.
MyRound
(
c
.
MulFloat
(
costPriceUs
,
ratioUsd
),
4
),
})
showPriceRatioList
=
append
(
showPriceRatioList
,
model
.
PriceRatio
{
Ratio
:
ratio
,
RatioUsd
:
ratioUsd
,
Purchases
:
int64
(
purchases
),
})
}
}
else
{
...
...
@@ -247,6 +253,11 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
PriceCn
:
c
.
MyRound
(
c
.
MulFloat
(
costPriceCn
,
ratio
),
4
),
PriceUs
:
c
.
MyRound
(
c
.
MulFloat
(
costPriceUs
,
ratio
),
4
),
})
showPriceRatioList
=
append
(
showPriceRatioList
,
model
.
PriceRatio
{
Ratio
:
ratio
,
RatioUsd
:
ratio
,
Purchases
:
int64
(
purchases
),
})
}
}
...
...
@@ -254,6 +265,8 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
return
generatedLadderPrice
[
i
]
.
Purchases
<
generatedLadderPrice
[
j
]
.
Purchases
})
sku
.
LadderPrice
=
generatedLadderPrice
sku
.
PriceRatio
=
showPriceRatioList
return
sku
}
fmt
.
Println
(
"是成本价"
)
...
...
@@ -296,6 +309,11 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
PriceCn
:
c
.
MyRound
(
c
.
MulFloat
(
costPriceCn
,
priceCnRatio
),
4
),
PriceUs
:
c
.
MyRound
(
c
.
MulFloat
(
costPriceUs
,
priceUsRatio
),
4
),
})
showPriceRatioList
=
append
(
showPriceRatioList
,
model
.
PriceRatio
{
Ratio
:
priceCnRatio
,
RatioUsd
:
priceUsRatio
,
Purchases
:
int64
(
costPurchases
),
})
}
}
else
{
//价格阶梯数量超过最利润点的层级的情况
...
...
@@ -315,9 +333,15 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
PriceCn
:
c
.
MyRound
(
c
.
MulFloat
(
costPriceCn
,
priceCnRatio
),
4
),
PriceUs
:
c
.
MyRound
(
c
.
MulFloat
(
costPriceUs
,
priceUsRatio
),
4
),
})
showPriceRatioList
=
append
(
showPriceRatioList
,
model
.
PriceRatio
{
Ratio
:
priceCnRatio
,
RatioUsd
:
priceUsRatio
,
Purchases
:
int64
(
costPurchases
),
})
}
}
sku
.
LadderPrice
=
generatedLadderPrice
sku
.
PriceRatio
=
showPriceRatioList
return
sku
}
else
{
//fmt.Println(ladderPriceRatio)
...
...
@@ -344,6 +368,11 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
PriceCn
:
c
.
MyRound
(
c
.
MulFloat
(
ladder
.
PriceCn
,
priceCnRatio
),
4
),
PriceUs
:
c
.
MyRound
(
c
.
MulFloat
(
ladder
.
PriceUs
,
priceUsRatio
),
4
),
})
showPriceRatioList
=
append
(
showPriceRatioList
,
model
.
PriceRatio
{
Ratio
:
priceCnRatio
,
RatioUsd
:
priceUsRatio
,
Purchases
:
int64
(
ladder
.
Purchases
),
})
}
}
else
{
...
...
@@ -360,8 +389,14 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) model.LySku {
PriceCn
:
c
.
MyRound
(
c
.
MulFloat
(
ladder
.
PriceCn
,
priceCnRatio
),
4
),
PriceUs
:
c
.
MyRound
(
c
.
MulFloat
(
ladder
.
PriceUs
,
priceUsRatio
),
4
),
})
showPriceRatioList
=
append
(
showPriceRatioList
,
model
.
PriceRatio
{
Ratio
:
priceCnRatio
,
RatioUsd
:
priceUsRatio
,
Purchases
:
int64
(
ladder
.
Purchases
),
})
}
}
sku
.
PriceRatio
=
showPriceRatioList
sku
.
LadderPrice
=
generatedLadderPrice
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