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
c0ebea20
authored
Jul 16, 2020
by
huangchengyi
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1.0
parent
457e3ddb
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
16 deletions
cmd/test1.go
model/ly.go
service/common_ly_service.go
cmd/test1.go
View file @
c0ebea20
...
...
@@ -4,8 +4,6 @@ import (
"flag"
"os"
"search_server/boot"
"search_server/pkg/es"
"strings"
)
func
main
()
{
...
...
@@ -34,16 +32,16 @@ func main() {
//os.Exit(1)
//dd := service.OutLink("LM358","-1")
lines
:=
[]
string
{
`{"index":{"_index":"hcy1","_type":"goods","_id":"s1"} }`
,
`{"name":"john doe","age":25 }`
,
`{"index":{"_index":"hcy1","_type":"goods","_id":"s2"} }`
,
`{"name":"mary smith","age":32 }`
,
}
param
:=
strings
.
Join
(
lines
,
"
\n
"
)
+
"
\n
"
result
,
err
:=
es
.
BulkES
(
param
)
println
(
result
,
err
)
//
lines := []string{
//
`{"index":{"_index":"hcy1","_type":"goods","_id":"s1"} }`,
//
`{"name":"john doe","age":25 }`,
//
`{"index":{"_index":"hcy1","_type":"goods","_id":"s2"} }`,
//
`{"name":"mary smith","age":32 }`,
//
}
//
param := strings.Join(lines, "\n")+"\n"
//
//
result,err := es.BulkES(param)
//
println(result,err)
os
.
Exit
(
1
)
}
...
...
model/ly.go
View file @
c0ebea20
...
...
@@ -2,6 +2,7 @@ package model
//联营请求外链后格式化数据
type
LyClearGoodsList
struct
{
GoodsId
string
`json:"goods_name"`
//型号id
GoodsName
string
`json:"goods_name"`
//型号名称
BrandName
string
`json:"brand_name"`
//品牌名称
Desc
string
`json:"desc"`
//描述
...
...
@@ -10,6 +11,7 @@ type LyClearGoodsList struct {
Url
string
`json:"url"`
//sku对应供应商的商品详情
GoodsImg
string
`json:"goods_img"`
//sku图片
Cat
string
`json:"cat"`
//分类
Encoded
string
`json:"encoded"`
//内部编码
RestrictionMessage
string
`json:"RestrictionMessage"`
//额外购买限制内容,如 ‘当前商品不在本地区销售’
Increment
int64
`json:"increment"`
//最小包装量、倍数 =Mpq
SinglePrice
float64
`json:"single_price"`
//最小单价
...
...
service/common_ly_service.go
View file @
c0ebea20
...
...
@@ -21,9 +21,7 @@ type CommonLyService struct {
supplier_over_time
map
[
string
]
int64
supplierId
int64
//调用当前方法的供应商ID
supplierName
string
//调用当前方法的供应商名称
skuEsUpdataList
[]
map
[
string
]
interface
{}
//组装批量更新es数据
spuId
string
//spuId
skuId
string
//skuId
skuEsUpdataList
[]
string
//组装批量更新es数据
}
//初始化类
...
...
@@ -207,7 +205,57 @@ func (t *CommonLyService) writeBrandInfo(skuInfo *model.LyClearGoodsList) int64
/*
组装推送到es数据
*/
func
esSkuInfo
(
skuInfo
*
model
.
LyClearGoodsList
,
brandId
*
string
)
{
func
(
t
*
CommonLyService
)
EsSkuInfo
(
skuInfo
*
model
.
LyClearGoodsList
,
spuId
*
string
,
brandId
*
string
)
{
sort
:=
1
;
//排序
if
skuInfo
.
SinglePrice
>
0
&&
skuInfo
.
Stock
>
0
&&
skuInfo
.
Stock
>=
skuInfo
.
Increment
&&
skuInfo
.
Stock
>=
skuInfo
.
Moq
{
sort
=
31
;
}
else
if
skuInfo
.
SinglePrice
>
0
&&
skuInfo
.
Stock
>
0
{
sort
=
30
;
}
else
if
skuInfo
.
SinglePrice
>
0
{
sort
=
28
;
}
else
if
skuInfo
.
Stock
>
0
{
sort
=
29
;
}
stock_sort
:=
1
;
if
skuInfo
.
Stock
>
0
{
stock_sort
=
3
;
}
single_price_sort
:=
1
;
if
skuInfo
.
SinglePrice
>
0
{
single_price_sort
=
3
;
}
nowTime
:=
php2go
.
Time
()
param
:=
map
[
string
]
interface
{}{
"goods_id"
:
skuInfo
.
GoodsId
,
"goods_name"
:
skuInfo
.
GoodsName
,
"auto_goods_name"
:
php2go
.
Strtoupper
(
skuInfo
.
GoodsName
),
"brand_id"
:*
brandId
,
"brand_name"
:
skuInfo
.
BrandName
,
"supplier_name"
:
t
.
supplierName
,
"class_id1"
:
0
,
"class_id2"
:
0
,
"class_id3"
:
0
,
"spu_id"
:*
spuId
,
"sale_time"
:
nowTime
,
"create_time"
:
nowTime
,
"update_time"
:
nowTime
,
"single_price"
:
skuInfo
.
SinglePrice
,
"stock"
:
skuInfo
.
Stock
,
"goods_status"
:
1
,
"status"
:
1
,
"sort"
:
sort
,
"encoded"
:
""
,
"encap"
:
""
,
"canal_new"
:
""
,
"stock_sort"
:
stock_sort
,
//主要为库存为0的往后排服务
"single_price_sort"
:
single_price_sort
,
//主要为单价为0的往后排服务
}
paramjson
,
_
:=
json
.
Marshal
(
param
)
_
=
append
(
t
.
skuEsUpdataList
,
`{"index":{"_index":"`
+
t
.
supplierName
+
`","_type":"goods","_id":"`
+
skuInfo
.
GoodsId
+
`"}}`
)
_
=
append
(
t
.
skuEsUpdataList
,
string
(
paramjson
))
}
...
...
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