Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
search_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
930b9c90
authored
Jul 06, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
完善json返回
parent
578ce9ad
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
71 deletions
controller/bom_controller.go
model/goods.go
service/goods_service.go
controller/bom_controller.go
View file @
930b9c90
...
...
@@ -9,6 +9,10 @@ import (
//搜索型号
func
AutoSpu
(
c
*
gin
.
Context
)
{
service1
:=
service
.
GoodsService
{}
res1
,
_
:=
service1
.
GetGoodsInfoByApi
(
"1151005920927710088,1150961641855982990,1150961724815213435"
)
c
.
JSON
(
200
,
res1
)
return
goodsName
,
_
:=
c
.
GetPostForm
(
"goods_name"
)
goods
:=
service
.
AutoSpu
(
goodsName
)
var
errCode
int
...
...
model/goods.go
View file @
930b9c90
package
model
type
ApiGoods
struct
{
PickType
int
`json:"pick_type
"`
BarCode
string
`json:"bar_code
"`
GoodsId
string
`json:"goods_id"`
GoodsName
string
`json:"goods_name"`
Goods
Type
int
`json:"goods_type
"`
SupplierId
int
`json:"supplier_id
"`
Moq
int
`json:"moq
"`
M
pq
int
`json:"mp
q"`
Stock
int
`json:"stock
"`
HkDeliveryTime
string
`json:"hk_delivery_time
"`
CnDeliveryTime
string
`json:"cn
_delivery_time"`
LadderPrice
[]
LadderPrice
`json:"ladder_pric
e"`
BrandName
string
`json:"brand_nam
e"`
SupplierName
string
`json:"supplier
_name"`
BrandId
int
`json:"brand_id
"`
ClassId1
int
`json:"class_id1
"`
ClassId
2
int
`json:"class_id2
"`
Encoded
string
`json:"encoded
"`
Packing
string
`json:"packing
"`
GoodsUnit
string
`json:"goods_unit
"`
Goods
Images
string
`json:"goods_images
"`
Goods
Brief
string
`json:"goods_brief
"`
IsBuy
int
`json:"is_bu
y"`
Mpl
int
`json:"mpl
"`
Status
int
`json:"status
"`
Pdf
string
`json:"pdf
"`
Encap
string
`json:"encap
"`
AcType
int
`json:"ac_type
"`
OtherAttrs
OtherAttrs
`json:"other_attrs
"`
UpdateTime
int
`json:"update_time
"`
SkuName
string
`json:"sku_na
me"`
Attrs
Attrs
`json:"attrs
"`
Cost
string
`json:"cost
"`
NewCost
string
`json:"new_cost
"`
SupplierStock
int
`json:"supplier_stock
"`
S
elfSupplierType
int
`json:"self_supplier_type
"`
GoodsUnitName
string
`json:"goods_unit_name
"`
PackingName
string
`json:"packing_name
"`
MpgUnitName
string
`json:"mpg_unit_name
"`
ScmBrandName
string
`json:"scm_brand_name
"`
AllowCoupon
int
`json:"allow_coupon
"`
ClassId1Name
string
`json:"class_id1_name
"`
C
LassId2Name
string
`json:"c_lass_id2
_name"`
SpuId
string
`json:"spu_id,omitempty"`
BatchSn
string
`json:"batch_sn,omitempty"`
Canal
string
`json:"canal,omitempty"`
CpTime
int
`json:"cp_time,omitempty
"`
Coefficient
Coefficient
`json:"coefficient,omitempty"`
OriginalPrice
[]
OriginalPrice
`json:"original_price,omitempty"`
SuppExtendFee
SuppExtendFee
`json:"supp_extend_fee,omitempty"`
ClassId3
int
`json:"class_id3,omitempty"`
SpuName
string
`json:"spu_name,omitempty"`
ImagesL
string
`json:"images_l,omitempty"`
SpuBrief
string
`json:"spu_brief,omitempty"`
SpuDetail
string
`json:"spu_detail,omitempty"`
ClassName3
string
`json:"class_name3,omitempty"`
ErpTax
bool
`json:"erp_tax,omitempty
"`
ScmBrand
ScmBrand
`json:"scm_brand,omitempty"`
PickType
int
`json:"pick_type,omitempty
"`
BarCode
string
`json:"barcode,omitempty
"`
GoodsId
string
`json:"goods_id"`
GoodsName
string
`json:"goods_name"`
Goods
Sn
string
`json:"goods_sn
"`
GoodsType
int
`json:"goods_type
"`
SupplierId
int
`json:"supplier_id
"`
M
oq
int
`json:"mo
q"`
Mpq
int
`json:"mpq
"`
Stock
int
`json:"stock
"`
HkDeliveryTime
string
`json:"hk
_delivery_time"`
CnDeliveryTime
string
`json:"cn_delivery_tim
e"`
LadderPrice
[]
LadderPrice
`json:"ladder_pric
e"`
BrandName
string
`json:"brand
_name"`
SupplierName
string
`json:"supplier_name
"`
BrandId
int
`json:"brand_id
"`
ClassId
1
int
`json:"class_id1
"`
ClassId2
int
`json:"class_id2
"`
Encoded
string
`json:"encoded
"`
Packing
string
`json:"packing,omitempty
"`
Goods
Unit
string
`json:"goods_unit,goods_unit
"`
Goods
Images
string
`json:"goods_images
"`
GoodsBrief
string
`json:"goods_brief,omitempt
y"`
IsBuy
int
`json:"is_buy
"`
Mpl
int
`json:"mpl
"`
Status
int
`json:"status
"`
Pdf
string
`json:"pdf
"`
Encap
string
`json:"encap
"`
AcType
int
`json:"ac_type
"`
OtherAttrs
OtherAttrs
`json:"other_attrs
"`
UpdateTime
int
`json:"update_ti
me"`
SkuName
string
`json:"sku_name,omitempty
"`
Attrs
Attrs
`json:"attrs
"`
Cost
string
`json:"cost,omitempty
"`
NewCost
string
`json:"new_cost,omitempty
"`
S
upplierStock
int
`json:"supplier_stock,omitempty
"`
SelfSupplierType
int
`json:"self_supplier_type,omitempty
"`
GoodsUnitName
string
`json:"goods_unit_name,omitempty
"`
PackingName
string
`json:"packing_name,omitempty
"`
MpgUnitName
string
`json:"mpg_unit_name,omitempty
"`
ScmBrandName
string
`json:"scm_brand_name,omitempty
"`
AllowCoupon
int
`json:"allow_coupon
"`
C
lassId1Name
string
`json:"class_id1
_name"`
CLassId2Name
string
`json:"c_lass_id2_name"`
SpuId
string
`json:"spu_id,omitempty"`
BatchSn
string
`json:"batch_sn,omitempty"`
Canal
string
`json:"canal,omitempty"`
CpTime
int
`json:"cp_time
"`
Coefficient
Coefficient
`json:"coefficient,omitempty"`
OriginalPrice
[]
OriginalPrice
`json:"original_price,omitempty"`
SuppExtendFee
SuppExtendFee
`json:"supp_extend_fee,omitempty"`
ClassId3
int
`json:"class_id3,omitempty"`
SpuName
string
`json:"spu_name,omitempty"`
ImagesL
string
`json:"images_l,omitempty"`
SpuBrief
string
`json:"spu_brief,omitempty"`
SpuDetail
string
`json:"spu_detail,omitempty"`
ClassName3
string
`json:"class_name3,omitempty"`
ErpTax
bool
`json:"erp_tax
"`
ScmBrand
ScmBrand
`json:"scm_brand,omitempty"`
}
type
Attr
struct
{
AttrName
string
AttrValue
string
AttrName
string
`json:"attr_name,omitempty"`
AttrValue
string
`json:"attr_value,omitempty"`
}
type
Attrs
map
[
string
]
Attr
type
OtherAttrs
struct
{
GrossWeight
string
`json:"gross_weight"`
GrossWeight
string
`json:"gross_weight
,omitempty
"`
}
type
LadderPrice
struct
{
Purchases
int
`json:"purchases"`
Purchases
int
`json:"purchases"`
PriceUs
float64
`json:"price_us"`
PriceCn
float64
`json:"price_cn"`
PriceAc
float64
`json:"price_ac"`
...
...
@@ -99,14 +99,14 @@ type SuppExtendFee struct {
Max
int
`json:"max"`
Price
float64
`json:"price"`
}
`json:"cn,omitempty"`
Hk
struct
{
Hk
struct
{
Max
int
`json:"max"`
Price
float64
`json:"price"`
}
`json:"hk,omitempty"`
}
type
ScmBrand
struct
{
ErpBrandName
string
`json:"erp_brand_name"`
ErpBrandId
string
`json:"erp_brand_id"`
ScmBrandId
string
`json:"scm_brand_id"`
ErpBrandName
string
`json:"erp_brand_name
,omitempty
"`
ErpBrandId
string
`json:"erp_brand_id
,omitempty
"`
ScmBrandId
string
`json:"scm_brand_id
,omitempty
"`
}
service/goods_service.go
View file @
930b9c90
...
...
@@ -9,7 +9,6 @@ import (
"gopkg.in/olivere/elastic.v5"
"regexp"
"search_server/model"
"search_server/pkg/common"
"search_server/pkg/config"
"search_server/pkg/es"
"search_server/pkg/gredis"
...
...
@@ -66,6 +65,7 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []*model.Api
goods
.
BarCode
=
data
.
Get
(
"bar_code"
)
.
String
()
goods
.
GoodsId
=
data
.
Get
(
"goods_id"
)
.
String
()
goods
.
GoodsName
=
data
.
Get
(
"goods_name"
)
.
String
()
goods
.
GoodsSn
=
data
.
Get
(
"goods_sn"
)
.
String
()
goods
.
GoodsType
=
int
(
data
.
Get
(
"goods_type"
)
.
Int
())
goods
.
SupplierId
=
int
(
data
.
Get
(
"supplier_id"
)
.
Int
())
goods
.
Mpq
=
int
(
data
.
Get
(
"mpq"
)
.
Int
())
...
...
@@ -133,13 +133,12 @@ func CurlGoodsInfo(goodsIdsStr string, params req.Param) (goodsList []*model.Api
//Attrs
attrMap
:=
make
(
map
[
string
]
model
.
Attr
,
0
)
for
key
,
attr
:=
range
data
.
Get
(
"attrs"
)
.
Array
()
{
for
key
,
attr
:=
range
data
.
Get
(
"attrs"
)
.
Map
()
{
attr
:=
model
.
Attr
{
AttrName
:
attr
.
Get
(
"attr_name"
)
.
String
(),
AttrValue
:
attr
.
Get
(
"attr_value"
)
.
String
(),
}
attrMap
[
common
.
ToString
(
key
)]
=
attr
attrMap
[
key
]
=
attr
}
goods
.
Attrs
=
attrMap
...
...
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