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
c1c3d29f
authored
Sep 11, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
数据库价格问题
parent
682bd95f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
2 deletions
model/goods.go
model/ly_sku.go
service/service_ly_common.go
service/service_price.go
model/goods.go
View file @
c1c3d29f
...
@@ -27,6 +27,14 @@ type OriginPrice struct {
...
@@ -27,6 +27,14 @@ type OriginPrice struct {
CostPrice
float64
`json:"cost_price"`
CostPrice
float64
`json:"cost_price"`
}
}
type
DatabasePrice
struct
{
Purchases
int64
`json:"purchases"`
//购买数量
PriceUs
float64
`json:"price_us"`
//数量对应的英文价格
PriceCn
float64
`json:"price_cn"`
//数量对应的中文价格
PriceAc
float64
`json:"price_ac,omitempty"`
CostPrice
float64
`json:"cost_price"`
}
// 立创价格梯度
// 立创价格梯度
type
LadderPriceLc
struct
{
type
LadderPriceLc
struct
{
Purchases
int64
`json:"purchases"`
//购买数量
Purchases
int64
`json:"purchases"`
//购买数量
...
...
model/ly_sku.go
View file @
c1c3d29f
...
@@ -236,6 +236,7 @@ func InitSkuData(sku string) (data LySku) {
...
@@ -236,6 +236,7 @@ func InitSkuData(sku string) (data LySku) {
LadderPriceStr
:=
gjson
.
Get
(
sku
,
"ladder_price"
)
.
String
()
LadderPriceStr
:=
gjson
.
Get
(
sku
,
"ladder_price"
)
.
String
()
data
.
LadderPrice
=
getLadderPrice
(
LadderPriceStr
)
data
.
LadderPrice
=
getLadderPrice
(
LadderPriceStr
)
data
.
OriginalPrice
=
getOriginPrice
(
LadderPriceStr
)
data
.
OriginalPrice
=
getOriginPrice
(
LadderPriceStr
)
data
.
DatabasePrice
=
getDatabasePrice
(
LadderPriceStr
)
return
return
}
}
...
@@ -280,3 +281,23 @@ func getOriginPrice(ladderPriceStr string) (ladderPrice []OriginPrice) {
...
@@ -280,3 +281,23 @@ func getOriginPrice(ladderPriceStr string) (ladderPrice []OriginPrice) {
return
return
}
}
// 获取原始价格
func
getDatabasePrice
(
ladderPriceStr
string
)
(
ladderPrice
[]
DatabasePrice
)
{
ladderPriceArr
:=
gjson
.
Parse
(
ladderPriceStr
)
.
Array
()
for
_
,
price
:=
range
ladderPriceArr
{
ladderPrice
=
append
(
ladderPrice
,
DatabasePrice
{
Purchases
:
price
.
Get
(
"purchases"
)
.
Int
(),
PriceUs
:
price
.
Get
(
"price_us"
)
.
Float
(),
PriceCn
:
price
.
Get
(
"price_cn"
)
.
Float
(),
PriceAc
:
price
.
Get
(
"price_ac"
)
.
Float
(),
CostPrice
:
price
.
Get
(
"cost_price"
)
.
Float
(),
})
}
if
len
(
ladderPrice
)
==
0
{
ladderPrice
=
[]
DatabasePrice
{}
return
}
return
}
service/service_ly_common.go
View file @
c1c3d29f
...
@@ -270,6 +270,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
...
@@ -270,6 +270,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
var
data
[]
model
.
LadderPrice
var
data
[]
model
.
LadderPrice
var
originalPrice
[]
model
.
OriginPrice
var
originalPrice
[]
model
.
OriginPrice
sort
.
Sort
(
sorter
.
OriginPriceSorter
(
sku
.
OriginalPrice
))
sort
.
Sort
(
sorter
.
OriginPriceSorter
(
sku
.
OriginalPrice
))
//专卖价格获取
//专卖价格获取
if
sku
.
SupplierId
==
17
{
if
sku
.
SupplierId
==
17
{
ladderPrice
:=
sku
.
LadderPrice
ladderPrice
:=
sku
.
LadderPrice
...
@@ -287,6 +288,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
...
@@ -287,6 +288,7 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
data
=
make
([]
model
.
LadderPrice
,
len
(
ladderPrice
))
data
=
make
([]
model
.
LadderPrice
,
len
(
ladderPrice
))
sku
=
priceService
.
TransformSpecialSupplierPrice
(
sku
)
sku
=
priceService
.
TransformSpecialSupplierPrice
(
sku
)
for
key
,
price
:=
range
ladderPrice
{
for
key
,
price
:=
range
ladderPrice
{
if
price
.
Purchases
==
0
{
if
price
.
Purchases
==
0
{
continue
continue
...
...
service/service_price.go
View file @
c1c3d29f
...
@@ -653,7 +653,6 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku) model.LyS
...
@@ -653,7 +653,6 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku) model.LyS
}
else
{
}
else
{
currencyConfig
,
_
=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"magic_cube_supplier_currency"
,
sku
.
Canal
))
currencyConfig
,
_
=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"magic_cube_supplier_currency"
,
sku
.
Canal
))
}
}
sku
.
DatabasePrice
=
sku
.
OriginalPrice
hasTax
:=
false
hasTax
:=
false
symbol
:=
"$"
symbol
:=
"$"
if
currencyConfig
!=
""
{
if
currencyConfig
!=
""
{
...
@@ -677,9 +676,9 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku) model.LyS
...
@@ -677,9 +676,9 @@ func (ps *PriceService) TransformSpecialSupplierPrice(sku model.LySku) model.LyS
priceUs
=
c
.
MyRound
(
c
.
DivFloat
(
priceUs
,
1.13
),
4
)
priceUs
=
c
.
MyRound
(
c
.
DivFloat
(
priceUs
,
1.13
),
4
)
}
}
sku
.
LadderPrice
[
index
]
.
PriceUs
=
priceUs
sku
.
LadderPrice
[
index
]
.
PriceUs
=
priceUs
sku
.
OriginalPrice
[
index
]
.
PriceUs
=
priceUs
}
}
}
}
sku
.
OriginCurrencySymbol
=
symbol
sku
.
OriginCurrencySymbol
=
symbol
return
sku
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