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
22575a47
authored
Jul 14, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
来源返回
parent
494a5de2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
model/ly_sku.go
model/ly_sku.go
View file @
22575a47
...
...
@@ -6,7 +6,7 @@ import (
"github.com/tidwall/gjson"
)
//联营sku结构体
//
联营sku结构体
type
LySku
struct
{
LadderPrice
[]
LadderPrice
`json:"-"`
SpuId
string
`json:"spu_id"`
...
...
@@ -76,6 +76,7 @@ type LySku struct {
DiscountRatio
DiscountRatio
`json:"discount_ratio"`
PriceRatioSort
int
`json:"price_ratio_sort"`
PriceRatio
[]
PriceRatio
`json:"price_ratio"`
Source
int
`json:"source"`
}
type
DiscountRatio
struct
{
...
...
@@ -131,8 +132,12 @@ type StockInfo struct {
Stock
int
`json:"stock" bson:"stock"`
}
//为什么不直接映射到结构,而要用gjson,因为redis存的数据结构不一定正常,可能类型不一致
//
为什么不直接映射到结构,而要用gjson,因为redis存的数据结构不一定正常,可能类型不一致
func
InitSkuData
(
sku
string
)
(
data
LySku
)
{
source
:=
gjson
.
Get
(
sku
,
"source"
)
.
Int
()
data
.
Source
=
int
(
source
)
goodsSn
:=
gjson
.
Get
(
sku
,
"goods_sn"
)
.
String
()
data
.
GoodsSn
=
goodsSn
...
...
@@ -225,7 +230,7 @@ func InitSkuData(sku string) (data LySku) {
return
}
//获取联营商品的阶梯价
//
获取联营商品的阶梯价
func
getLadderPrice
(
ladderPriceStr
string
)
(
ladderPrice
[]
LadderPrice
)
{
ladderPriceArr
:=
gjson
.
Parse
(
ladderPriceStr
)
.
Array
()
for
_
,
price
:=
range
ladderPriceArr
{
...
...
@@ -246,7 +251,7 @@ func getLadderPrice(ladderPriceStr string) (ladderPrice []LadderPrice) {
return
}
//获取原始价格
//
获取原始价格
func
getOriginPrice
(
ladderPriceStr
string
)
(
ladderPrice
[]
OriginPrice
)
{
ladderPriceArr
:=
gjson
.
Parse
(
ladderPriceStr
)
.
Array
()
for
_
,
price
:=
range
ladderPriceArr
{
...
...
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