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
70e6cabe
authored
Nov 18, 2020
by
huangchengyi
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1.0
parent
a5740bdb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
8 deletions
model/goods.go
service/service_zy.go
model/goods.go
View file @
70e6cabe
...
...
@@ -18,4 +18,10 @@ type LadderPrice struct {
type
LadderPriceLc
struct
{
Purchases
int64
`json:"purchases"`
//购买数量
Price
float64
`json:"price"`
//立创价格,人民币
}
//自营属性列表
type
Attrs
struct
{
AttrName
string
`json:"attr_name"`
//属性名称
AttrValue
string
`json:"attr_value"`
//属性值
}
\ No newline at end of file
service/service_zy.go
View file @
70e6cabe
...
...
@@ -47,9 +47,12 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context,goodsIds []string,goodsR
}
//拼接梯度价格
ladder
_price_a
rr
:=
gjson
.
Get
(
info
,
"ladder_price"
)
.
Array
()
ladder
PriceA
rr
:=
gjson
.
Get
(
info
,
"ladder_price"
)
.
Array
()
ladderPrice
:=
make
([]
model
.
LadderPrice
,
0
)
for
_
,
v
:=
range
ladder_price_arr
{
for
_
,
v
:=
range
ladderPriceArr
{
if
v
.
Get
(
"purchases"
)
.
String
()
==
""
{
continue
;
}
ladderPrice
=
append
(
ladderPrice
,
model
.
LadderPrice
{
Purchases
:
v
.
Get
(
"purchases"
)
.
Int
(),
PriceUs
:
v
.
Get
(
"price_us"
)
.
Float
(),
...
...
@@ -57,6 +60,19 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context,goodsIds []string,goodsR
})
}
//拼接属性
attrJsonArr
:=
gjson
.
Parse
(
gjson
.
Get
(
info
,
"attrs"
)
.
String
())
.
Array
()
attrs
:=
make
([]
model
.
Attrs
,
0
)
for
_
,
d
:=
range
attrJsonArr
{
if
d
.
Get
(
"attr_name"
)
.
String
()
==
""
{
continue
;
}
attrs
=
append
(
attrs
,
model
.
Attrs
{
AttrName
:
d
.
Get
(
"attr_name"
)
.
String
(),
AttrValue
:
d
.
Get
(
"attr_value"
)
.
String
(),
})
}
//数组
A
:=
orderedmap
.
New
()
//初始化有序map,拼接data 数据
A
.
Set
(
"goods_id"
,
common
.
MyInt64
(
goods_id
))
...
...
@@ -74,7 +90,13 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context,goodsIds []string,goodsR
A
.
Set
(
"goods_brief"
,
gjson
.
Get
(
info
,
"goods_brief"
)
.
String
())
//
A
.
Set
(
"moq"
,
gjson
.
Get
(
info
,
"moq"
)
.
Int
())
//
A
.
Set
(
"mpq"
,
gjson
.
Get
(
info
,
"mpq"
)
.
Int
())
//
A
.
Set
(
"ladder_price"
,
ladderPrice
)
//
if
len
(
ladderPrice
)
==
0
{
A
.
Set
(
"ladder_price"
,
""
)
//
}
else
{
A
.
Set
(
"ladder_price"
,
ladderPrice
)
//
}
A
.
Set
(
"update_time"
,
gjson
.
Get
(
info
,
"update_time"
)
.
Int
())
//
A
.
Set
(
"sku_name"
,
strings
.
Trim
(
gjson
.
Get
(
info
,
"sku_name"
)
.
String
(),
" "
))
//
A
.
Set
(
"mpl"
,
gjson
.
Get
(
info
,
"mpl"
)
.
Int
())
//
...
...
@@ -85,7 +107,13 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context,goodsIds []string,goodsR
stock
:=
dbStock
-
lockStock
//当前可购买库存
A
.
Set
(
"stock"
,
stock
)
A
.
Set
(
"attrs"
,
gjson
.
Get
(
info
,
"attrs"
)
.
String
())
//
if
len
(
attrs
)
==
0
{
A
.
Set
(
"attrs"
,
""
)
//属性值
}
else
{
A
.
Set
(
"attrs"
,
attrs
)
//
}
A
.
Set
(
"cost"
,
gjson
.
Get
(
info
,
"cost"
)
.
String
())
//
A
.
Set
(
"new_cost"
,
gjson
.
Get
(
info
,
"new_cost"
)
.
String
())
//
A
.
Set
(
"supplier_stock"
,
gjson
.
Get
(
info
,
"supplier_stock"
)
.
Int
())
//
...
...
@@ -148,8 +176,6 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context,goodsIds []string,goodsR
A
.
Set
(
"pdf"
,
gjson
.
Get
(
info
,
"pdf"
)
.
String
())
}
A
.
Set
(
"scm_brand_name"
,
gjson
.
Get
(
info
,
"scm_brand_name"
)
.
String
())
//
A
.
Set
(
"actual_stock"
,
gjson
.
Get
(
info
,
"actual_stock"
)
.
Int
())
//
A
.
Set
(
"ac_type"
,
gjson
.
Get
(
info
,
"ac_type"
)
.
Int
())
//
...
...
@@ -198,8 +224,7 @@ func (qs *ZiyingService) ZyGoodsDetail(ctx *gin.Context,goodsIds []string,goodsR
A
.
Set
(
"quota_num"
,
gjson
.
Get
(
goods_quota
,
"num"
)
.
Int
())
}
//处理是否能购买
if
gjson
.
Get
(
info
,
"status"
)
.
String
()
!=
"1"
||
len
(
ladder_price_arr
)
==
0
{
if
gjson
.
Get
(
info
,
"status"
)
.
String
()
!=
"1"
||
len
(
ladderPriceArr
)
==
0
{
A
.
Set
(
"is_buy"
,
0
)
}
else
{
A
.
Set
(
"is_buy"
,
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