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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
34 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,8 +11,9 @@ 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
Increment
int64
`json:"increment"`
//最小包装量、倍数 =Mpq
SinglePrice
float64
`json:"single_price"`
//最小单价
Stock
int64
`json:"increment"`
//库存
Moq
int64
`json:"moq"`
//最小起订量、起订量
...
...
@@ -51,7 +53,7 @@ Array
)
*/
type
SUPPLIER_REDIS_INFO_
struct
{
SupplierId
int64
`json:"supplier_id"`
//供应商id
SupplierId
int64
`json:"supplier_id"`
//供应商id
SupplierNickname
string
`json:"supplier_nickname"`
//供应商名称
AdText
string
`json:"ad_text"`
//供应商描述
CnDelivery
string
`json:"cn_delivery"`
//国内交货时间
...
...
@@ -117,22 +119,22 @@ Array
)
*/
type
LySkuInfo
struct
{
SpuId
string
`json:"spu_id"`
//spu_id
Encoded
string
`json:"encoded"`
Moq
int64
`json:"moq"`
Mpq
int64
`json:"mpq"`
OldGoodsId
int64
`json:"old_goods_id"`
GoodsType
int
`json:"goods_type"`
GoodsStatus
int
`json:"goods_status"`
BatchSn
string
`json:"batch_sn"`
Stock
int64
`json:"stock"`
UpdateTime
int64
`json:"update_time"`
GoodsImages
string
`json:"goods_images"`
Canal
string
`json:"canal"`
SupplierId
int64
`json:"supplier_id"`
IsExpire
string
`json:"is_expire"`
HkDeliveryTime
string
`json:"hk_delivery_time"`
CnDeliveryTime
string
`json:"cn_delivery_time"`
SpuId
string
`json:"spu_id"`
//spu_id
Encoded
string
`json:"encoded"`
Moq
int64
`json:"moq"`
Mpq
int64
`json:"mpq"`
OldGoodsId
int64
`json:"old_goods_id"`
GoodsType
int
`json:"goods_type"`
GoodsStatus
int
`json:"goods_status"`
BatchSn
string
`json:"batch_sn"`
Stock
int64
`json:"stock"`
UpdateTime
int64
`json:"update_time"`
GoodsImages
string
`json:"goods_images"`
Canal
string
`json:"canal"`
SupplierId
int64
`json:"supplier_id"`
IsExpire
string
`json:"is_expire"`
HkDeliveryTime
string
`json:"hk_delivery_time"`
CnDeliveryTime
string
`json:"cn_delivery_time"`
LadderPrice
[]
*
TierItem
`json:"ladder_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