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
9bfa6db8
authored
Mar 13, 2023
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
返回更多额外的信息
parent
434aa3a2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
9 deletions
model/ly_sku.go
service/service_ly_common.go
model/ly_sku.go
View file @
9bfa6db8
...
...
@@ -72,6 +72,19 @@ type LySku struct {
GoodsTag
GoodsTag
`json:"goods_tag"`
StockInfo
interface
{}
`json:"stock_info"`
Eccn
string
`json:"eccn"`
DiscountRatio
DiscountRatio
`json:"discount_ratio"`
PriceRatioSort
int
`json:"price_ratio_sort"`
PriceRatio
[]
PriceRatio
`json:"price_ratio"`
}
type
DiscountRatio
struct
{
Ratio
float64
`json:"ratio"`
RatioUsd
float64
`json:"ratio_usd"`
}
type
PriceRatio
struct
{
Ratio
float64
`json:"ratio"`
RatioUsd
float64
`json:"ratio_usd"`
}
type
PriceActivity
struct
{
...
...
service/service_ly_common.go
View file @
9bfa6db8
...
...
@@ -280,6 +280,8 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
cnDiscountRatio
+=
1
usDiscountRatio
+=
1
sku
.
DiscountRatio
.
Ratio
=
cnDiscountRatio
sku
.
DiscountRatio
.
RatioUsd
=
usDiscountRatio
//再去找售价组系数
//找一个标志位,因为默认的全局折扣系数的数据格式和非全局的是不一样的
...
...
@@ -290,22 +292,21 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
isDefaultPriceRatio
=
true
priceRatioCache
,
_
=
redis
.
String
(
redisCon
.
Do
(
"GET"
,
"magic_cube_price_rule_channel_default"
))
}
type
PriceRatio
struct
{
Ratio
float64
RatioUsd
float64
}
var
priceRatioSort
int
//这个就是最终要获取到的价格系数
var
priceRatioList
[]
PriceRatio
var
priceRatioList
[]
model
.
PriceRatio
//如果只有默认系数,那么就去找默认系数
if
isDefaultPriceRatio
{
priceRatioArr
:=
gjson
.
Get
(
priceRatioCache
,
"ladder_price"
)
.
Array
()
for
_
,
value
:=
range
priceRatioArr
{
priceRatioList
=
nil
var
priceRatio
PriceRatio
var
priceRatio
model
.
PriceRatio
priceRatio
.
Ratio
=
gjson
.
Get
(
value
.
String
(),
"ratio"
)
.
Float
()
priceRatio
.
RatioUsd
=
gjson
.
Get
(
value
.
String
(),
"ratio_usd"
)
.
Float
()
priceRatioList
=
append
(
priceRatioList
,
priceRatio
)
}
priceRatioSort
=
-
1
}
else
{
//拿到系数以后,就要去计算
//拿出里面的所有排序
...
...
@@ -319,11 +320,12 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
sortNumbers
=
sorter
.
IntSliceSortDesc
(
sortNumbers
)
//确定排序以后,就可以进行按排序(从大到小)取系数
for
_
,
sortNumber
:=
range
sortNumbers
{
priceRatioSort
=
sortNumber
priceRatioList
=
nil
sortString
:=
strconv
.
Itoa
(
sortNumber
)
priceRatioArr
:=
gjson
.
Get
(
priceRatioCache
,
"ladder_price."
+
sortString
)
.
Array
()
for
_
,
value
:=
range
priceRatioArr
{
var
priceRatio
PriceRatio
var
priceRatio
model
.
PriceRatio
priceRatio
.
Ratio
=
gjson
.
Get
(
value
.
String
(),
"ratio"
)
.
Float
()
priceRatio
.
RatioUsd
=
gjson
.
Get
(
value
.
String
(),
"ratio_usd"
)
.
Float
()
priceRatioList
=
append
(
priceRatioList
,
priceRatio
)
...
...
@@ -358,6 +360,8 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
}
}
}
sku
.
PriceRatio
=
priceRatioList
sku
.
PriceRatioSort
=
priceRatioSort
//这里是供应商系数,先保留这块逻辑
ratio
,
_
:=
redis
.
String
(
redisCon
.
Do
(
"HGET"
,
"pool_supplier_ratio"
,
sku
.
SupplierId
))
...
...
@@ -422,11 +426,11 @@ func (ls *LyService) GetCoefficientAndPrice(sku model.LySku) model.LySku {
data
[
key
]
.
Purchases
=
price
.
Purchases
//找出对应的阶梯,从$priceRatioList找到对应的售价组系数
//这个是为了怕后台存的数据格式不对导致无法获取到对应的系数
var
priceRatio
PriceRatio
var
priceRatio
model
.
PriceRatio
if
len
(
priceRatioList
)
>
key
{
priceRatio
=
priceRatioList
[
key
]
}
else
{
priceRatio
=
PriceRatio
{
priceRatio
=
model
.
PriceRatio
{
Ratio
:
1
,
RatioUsd
:
1
,
}
...
...
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