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
6a1c7316
authored
Jun 25, 2023
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修复调试
parent
77eed07c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
8 deletions
service/service_price.go
service/service_price.go
View file @
6a1c7316
package
service
package
service
import
(
import
(
"fmt"
"github.com/gomodule/redigo/redis"
"github.com/gomodule/redigo/redis"
"github.com/tidwall/gjson"
"github.com/tidwall/gjson"
"go_sku_server/model"
"go_sku_server/model"
...
@@ -61,7 +60,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) (generatedLadderPri
...
@@ -61,7 +60,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) (generatedLadderPri
if
isCostPrice
{
if
isCostPrice
{
costPriceCn
:=
sku
.
LadderPrice
[
0
]
.
PriceCn
costPriceCn
:=
sku
.
LadderPrice
[
0
]
.
PriceCn
costPriceUs
:=
sku
.
LadderPrice
[
0
]
.
PriceUs
costPriceUs
:=
sku
.
LadderPrice
[
0
]
.
PriceUs
fmt
.
Println
(
"人民币和美金的成本价分别为 : "
,
costPriceCn
,
costPriceUs
)
//
fmt.Println("人民币和美金的成本价分别为 : ", costPriceCn, costPriceUs)
//先去判断起订量,如果起订量小于50,就要走固定配置的阶梯价格系数
//先去判断起订量,如果起订量小于50,就要走固定配置的阶梯价格系数
if
sku
.
Moq
<=
50
{
if
sku
.
Moq
<=
50
{
moq
:=
int
(
sku
.
Moq
)
moq
:=
int
(
sku
.
Moq
)
...
@@ -116,8 +115,8 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) (generatedLadderPri
...
@@ -116,8 +115,8 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) (generatedLadderPri
}
}
costLadderCount
++
costLadderCount
++
}
}
fmt
.
Println
(
"阶梯数量为 : "
,
costLadderCount
)
//
fmt.Println("阶梯数量为 : ", costLadderCount)
fmt
.
Println
(
"设置的利润阶梯为 : "
,
ladderPriceMiniProfitLevel
)
//
fmt.Println("设置的利润阶梯为 : ", ladderPriceMiniProfitLevel)
if
costLadderCount
<=
ladderPriceMiniProfitLevel
{
if
costLadderCount
<=
ladderPriceMiniProfitLevel
{
for
i
:=
1
;
i
<=
costLadderCount
;
i
++
{
for
i
:=
1
;
i
<=
costLadderCount
;
i
++
{
priceRatioAndPurchases
:=
costLadderPriceRatio
[
strconv
.
Itoa
(
i
)]
priceRatioAndPurchases
:=
costLadderPriceRatio
[
strconv
.
Itoa
(
i
)]
...
@@ -137,7 +136,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) (generatedLadderPri
...
@@ -137,7 +136,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) (generatedLadderPri
costMapIndex
=
1
costMapIndex
=
1
}
}
priceRatioAndPurchases
=
costLadderPriceRatio
[
strconv
.
Itoa
(
costMapIndex
)]
priceRatioAndPurchases
=
costLadderPriceRatio
[
strconv
.
Itoa
(
costMapIndex
)]
fmt
.
Println
(
"获取到的阶梯系数为 : "
,
priceRatioAndPurchases
)
//
fmt.Println("获取到的阶梯系数为 : ", priceRatioAndPurchases)
priceCnRatio
:=
priceRatioAndPurchases
.
Get
(
"price"
)
.
Float
()
priceCnRatio
:=
priceRatioAndPurchases
.
Get
(
"price"
)
.
Float
()
priceUsRatio
:=
priceRatioAndPurchases
.
Get
(
"price_usd"
)
.
Float
()
priceUsRatio
:=
priceRatioAndPurchases
.
Get
(
"price_usd"
)
.
Float
()
// 阶梯价格系数正序取
// 阶梯价格系数正序取
...
@@ -174,7 +173,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) (generatedLadderPri
...
@@ -174,7 +173,7 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) (generatedLadderPri
return
generatedLadderPrice
,
showPriceRatio
return
generatedLadderPrice
,
showPriceRatio
}
else
{
}
else
{
ladderPriceRatio
:=
gjson
.
Get
(
priceRatio
,
"ladder_price_egt50_lt200"
)
.
Map
()
ladderPriceRatio
:=
gjson
.
Get
(
priceRatio
,
"ladder_price_egt50_lt200"
)
.
Map
()
fmt
.
Println
(
ladderPriceRatio
)
//
fmt.Println(ladderPriceRatio)
ladderCount
:=
len
(
sku
.
LadderPrice
)
ladderCount
:=
len
(
sku
.
LadderPrice
)
//走阶梯价
//走阶梯价
if
ladderCount
<=
ladderPriceMiniProfitLevel
{
if
ladderCount
<=
ladderPriceMiniProfitLevel
{
...
@@ -187,9 +186,9 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) (generatedLadderPri
...
@@ -187,9 +186,9 @@ func (ps *PriceService) GenerateLadderPrice(sku model.LySku) (generatedLadderPri
if
costMapIndex
<=
0
{
if
costMapIndex
<=
0
{
costMapIndex
=
1
costMapIndex
=
1
}
}
fmt
.
Println
(
costMapIndex
)
//
fmt.Println(costMapIndex)
priceRatio
:=
ladderPriceRatio
[
strconv
.
Itoa
(
costMapIndex
)]
priceRatio
:=
ladderPriceRatio
[
strconv
.
Itoa
(
costMapIndex
)]
fmt
.
Println
(
"获取到的阶梯系数为 : "
,
priceRatio
)
//
fmt.Println("获取到的阶梯系数为 : ", priceRatio)
priceCnRatio
:=
priceRatio
.
Get
(
"ratio"
)
.
Float
()
priceCnRatio
:=
priceRatio
.
Get
(
"ratio"
)
.
Float
()
priceUsRatio
:=
priceRatio
.
Get
(
"ratio_usd"
)
.
Float
()
priceUsRatio
:=
priceRatio
.
Get
(
"ratio_usd"
)
.
Float
()
showPriceRatio
=
append
(
showPriceRatio
,
model
.
PriceRatio
{
Ratio
:
priceCnRatio
,
RatioUsd
:
priceUsRatio
})
showPriceRatio
=
append
(
showPriceRatio
,
model
.
PriceRatio
{
Ratio
:
priceCnRatio
,
RatioUsd
:
priceUsRatio
})
...
...
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