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
de58e26e
authored
Jul 28, 2020
by
孙龙
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'dev' of
http://119.23.72.7/mushishixian/search_server
into dev
parents
795ea649
97e60f9f
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
64 deletions
.gitignore
conf/config_dev.ini
controller/ly_mouser_controller.go
go.mod
service/ly/common.go
service/ly/mouser.go
.gitignore
View file @
de58e26e
...
@@ -15,3 +15,4 @@ cmd.exe~
...
@@ -15,3 +15,4 @@ cmd.exe~
/cmd/*.exe~
/cmd/*.exe~
/cmd/logs
/cmd/logs
/bat/logs/
/bat/logs/
/conf
conf/config_dev.ini
deleted
100644 → 0
View file @
795ea649
[web]
port
=
9000
mode
=
debug
cors_domain
=
http://bom.liexin.com
[message]
api_domain
=
http://api.ichunt.com/msg/sendMessageByAuto
api_md5_str
=
fh6y5t4rr351d2c3bryi
[goods]
api_url
=
http://192.168.2.232:60004
[es]
url
=
http://192.168.2.232:9200
urls
=
http://192.168.2.232:9200,http://192.168.2.232:9200
index_name
=
future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,zhuanmai,peigenesis,powell,rs,buerklin,liexin_ziying
search_supplier
=
future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,peigenesis,powell,rs,buerklin,zhuanmai
hk_delivery_type_supplier
=
future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,peigenesis,powell,rs,buerklin
attr_index
=
goods_map
[database]
user_name
=
root
password
=
root
host
=
192.168.2.239
database
=
test
table_prefix
=
type
=
mysql
[redis]
write_host
=
192.168.1.235:6379
read_host
=
192.168.1.235:6379
write_password
=
icDb29mLy2s
read_password
=
icDb29mLy2s
max_idle
=
10
max_active
=
10
idle_timeout
=
20
[mongo]
host
=
127.0.0.1:27017
database
=
liexin_config
[brand]
#是否开启排除品牌
IS_NOT_TI
=
1
TI_LY_BRAND_IDS
=
23,45069,7754,17484,43215,13421,5220,7636,44534,43556,44543,9429,758,9470,10430,10653,10707,11227,11276,11819,12608,12965,12997,13327,13675,13680,13752
ti_zy_brand_id
=
23
\ No newline at end of file
controller/ly_mouser_controller.go
View file @
de58e26e
...
@@ -34,6 +34,7 @@ func GetMouserData(c *gin.Context) {
...
@@ -34,6 +34,7 @@ func GetMouserData(c *gin.Context) {
errCode
=
1
errCode
=
1
}
}
common
.
PrintDebugHtml
(
"-----执行结束----"
)
//debug
c
.
JSON
(
200
,
common
.
BomResponse
{
c
.
JSON
(
200
,
common
.
BomResponse
{
ErrCode
:
errCode
,
ErrCode
:
errCode
,
ErrMsg
:
"查询成功"
,
ErrMsg
:
"查询成功"
,
...
...
go.mod
View file @
de58e26e
...
@@ -41,6 +41,7 @@ require (
...
@@ -41,6 +41,7 @@ require (
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/olivere/elastic.v5 v5.0.85
gopkg.in/olivere/elastic.v5 v5.0.85
sigs.k8s.io/yaml v1.2.0 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
xorm.io/core v0.7.2-0.20190928055935-90aeac8d08eb
)
)
replace google.golang.org/grpc => google.golang.org/grpc v1.26.0
replace google.golang.org/grpc => google.golang.org/grpc v1.26.0
service/ly/common.go
View file @
de58e26e
...
@@ -40,7 +40,6 @@ func (t *CommonLyService) LyServerRun(){
...
@@ -40,7 +40,6 @@ func (t *CommonLyService) LyServerRun(){
}
}
}
}
/*
/*
联营入口
联营入口
联营大类,包括修改新增 sku es redis ,推送数据到队列让其他go服务更新数据到mysql
联营大类,包括修改新增 sku es redis ,推送数据到队列让其他go服务更新数据到mysql
...
@@ -67,10 +66,6 @@ func (t *CommonLyService) GetSkuByGoodsSn(goodsList map[string]*model.LyClearGoo
...
@@ -67,10 +66,6 @@ func (t *CommonLyService) GetSkuByGoodsSn(goodsList map[string]*model.LyClearGoo
common
.
PrintDebugHtml
(
goodsList
)
common
.
PrintDebugHtml
(
goodsList
)
for
goodsSn
,
info
:=
range
goodsList
{
for
goodsSn
,
info
:=
range
goodsList
{
common
.
PrintDebugHtml
(
goodsSn
+
"_"
+
supplierIdStr
)
snSku
:=
php2go
.
Md5
(
strings
.
ToLower
(
goodsSn
+
"_"
+
supplierIdStr
))
snSku
:=
php2go
.
Md5
(
strings
.
ToLower
(
goodsSn
+
"_"
+
supplierIdStr
))
skuId
,
_
:=
gredis
.
String
(
redisWrite
.
Do
(
"HGET"
,
config
.
Get
(
"redis_all.SKU_UNIQUE_JUDGE"
)
.
String
(),
snSku
))
//查询唯一值,反查sku_id
skuId
,
_
:=
gredis
.
String
(
redisWrite
.
Do
(
"HGET"
,
config
.
Get
(
"redis_all.SKU_UNIQUE_JUDGE"
)
.
String
(),
snSku
))
//查询唯一值,反查sku_id
...
@@ -78,7 +73,7 @@ func (t *CommonLyService) GetSkuByGoodsSn(goodsList map[string]*model.LyClearGoo
...
@@ -78,7 +73,7 @@ func (t *CommonLyService) GetSkuByGoodsSn(goodsList map[string]*model.LyClearGoo
/**********新增sku**************/
/**********新增sku**************/
skuFlag
:=
false
;
//是否新增或者更新db+redis,为true则新增
skuFlag
:=
false
;
//是否新增或者更新db+redis,为true则新增
//
skuId = ""; //debug
skuId
=
""
;
//debug
if
skuId
==
""
{
//redis没有此sku,创建
if
skuId
==
""
{
//redis没有此sku,创建
lock_key
:=
"searchapi_"
+
snSku
;
lock_key
:=
"searchapi_"
+
snSku
;
flag
,
_
:=
redis
.
Bool
(
redisWrite
.
Do
(
"SETNX"
,
lock_key
,
php2go
.
Time
()
+
2
))
flag
,
_
:=
redis
.
Bool
(
redisWrite
.
Do
(
"SETNX"
,
lock_key
,
php2go
.
Time
()
+
2
))
...
@@ -183,10 +178,9 @@ func (t *CommonLyService) writeSkuInfo(skuInfo *model.LyClearGoodsList,skuId str
...
@@ -183,10 +178,9 @@ func (t *CommonLyService) writeSkuInfo(skuInfo *model.LyClearGoodsList,skuId str
defer
redisWrite
.
Close
()
defer
redisWrite
.
Close
()
spuKey
:=
common
.
GetKey
(
skuInfo
.
GoodsName
+
"_"
+
skuInfo
.
BrandName
)
spuKey
:=
common
.
GetKey
(
skuInfo
.
GoodsName
+
"_"
+
skuInfo
.
BrandName
)
spuId
,
_
:=
gredis
.
String
(
redisWrite
.
Do
(
"HGET"
,
config
.
Get
(
"redis_all.S
K
U_UNIQUE_JUDGE"
)
.
String
(),
spuKey
))
spuId
,
_
:=
gredis
.
String
(
redisWrite
.
Do
(
"HGET"
,
config
.
Get
(
"redis_all.S
P
U_UNIQUE_JUDGE"
)
.
String
(),
spuKey
))
common
.
PrintDebugHtml
(
spuKey
)
common
.
PrintDebugHtml
(
"spu唯一值---spu_unique_judge:"
+
spuKey
+
" spu_id:"
+
spuId
)
common
.
PrintDebugHtml
(
spuId
)
if
spuId
==
""
{
//不存在spu,创建新的spu
if
spuId
==
""
{
//不存在spu,创建新的spu
spuId
=
t
.
writeSpuInfo
(
skuInfo
)
spuId
=
t
.
writeSpuInfo
(
skuInfo
)
...
@@ -243,9 +237,13 @@ func (t *CommonLyService) writeSpuInfo(skuInfo *model.LyClearGoodsList) string {
...
@@ -243,9 +237,13 @@ func (t *CommonLyService) writeSpuInfo(skuInfo *model.LyClearGoodsList) string {
brand_key
:=
common
.
GetKey
(
strings
.
ToLower
(
skuInfo
.
BrandName
))
brand_key
:=
common
.
GetKey
(
strings
.
ToLower
(
skuInfo
.
BrandName
))
brandId
,
_
:=
redis
.
Int64
(
redisWrite
.
Do
(
"HGET"
,
config
.
Get
(
"redis_all.BRAND_NAME_ALL"
)
.
String
(),
brand_key
))
brandId
,
_
:=
redis
.
Int64
(
redisWrite
.
Do
(
"HGET"
,
config
.
Get
(
"redis_all.BRAND_NAME_ALL"
)
.
String
(),
brand_key
))
common
.
PrintDebugHtml
(
"品牌更新:"
+
strings
.
ToLower
(
skuInfo
.
BrandName
)
+
" brand_key: "
+
brand_key
+
" 查询得到brand_id:"
+
common
.
MyInt64ToStr
(
brandId
))
if
brandId
==
0
{
if
brandId
==
0
{
brandId
,
_
=
redis
.
Int64
(
redisWrite
.
Do
(
"HGET"
,
config
.
Get
(
"redis_all.SUPPLIER_BRAND_ALL"
)
.
String
(),
brand_key
))
brandId
,
_
=
redis
.
Int64
(
redisWrite
.
Do
(
"HGET"
,
config
.
Get
(
"redis_all.SUPPLIER_BRAND_ALL"
)
.
String
(),
brand_key
))
if
brandId
==
0
{
if
brandId
==
0
{
common
.
PrintDebugHtml
(
"不存在品牌,新增:"
)
brandId
=
t
.
writeBrandInfo
(
skuInfo
)
brandId
=
t
.
writeBrandInfo
(
skuInfo
)
}
}
}
}
...
@@ -268,8 +266,7 @@ func (t *CommonLyService) writeSpuInfo(skuInfo *model.LyClearGoodsList) string {
...
@@ -268,8 +266,7 @@ func (t *CommonLyService) writeSpuInfo(skuInfo *model.LyClearGoodsList) string {
jsonStr
,
_
:=
json
.
Marshal
(
Spuinfo
)
jsonStr
,
_
:=
json
.
Marshal
(
Spuinfo
)
redisWrite
.
Do
(
"HSET"
,
"spu"
,
spuId
,
jsonStr
)
redisWrite
.
Do
(
"HSET"
,
"spu"
,
spuId
,
jsonStr
)
common
.
PrintDebugHtml
(
"新增spu:"
)
common
.
PrintDebugHtml
(
"新增spu:"
+
string
(
jsonStr
))
common
.
PrintDebugHtml
(
jsonStr
)
spuKey
:=
common
.
GetKey
(
skuInfo
.
GoodsName
+
"_"
+
skuInfo
.
BrandName
)
spuKey
:=
common
.
GetKey
(
skuInfo
.
GoodsName
+
"_"
+
skuInfo
.
BrandName
)
redisWrite
.
Do
(
"HSET"
,
config
.
Get
(
"redis_all.SPU_UNIQUE_JUDGE"
)
.
String
(),
spuKey
,
spuId
)
redisWrite
.
Do
(
"HSET"
,
config
.
Get
(
"redis_all.SPU_UNIQUE_JUDGE"
)
.
String
(),
spuKey
,
spuId
)
...
@@ -289,14 +286,14 @@ func (t *CommonLyService) writeBrandInfo(skuInfo *model.LyClearGoodsList) int64
...
@@ -289,14 +286,14 @@ func (t *CommonLyService) writeBrandInfo(skuInfo *model.LyClearGoodsList) int64
defer
redisWrite
.
Close
()
defer
redisWrite
.
Close
()
has
,
err
:=
dbSpu
.
Table
(
"
brand"
)
.
Where
(
"brand_name = ?"
,
skuInfo
.
BrandName
)
.
Cols
(
"
id"
)
.
Get
(
&
brandId
)
has
,
err
:=
dbSpu
.
Table
(
"
lie_brand"
)
.
Where
(
"brand_name = '"
+
skuInfo
.
BrandName
+
"' "
)
.
Cols
(
"brand_
id"
)
.
Get
(
&
brandId
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
err
)
//查询错误
fmt
.
Println
(
err
)
//查询错误
return
0
return
0
}
}
if
has
{
//不存在品牌,则创建品牌
sql
:=
"insert into brand(brand_name,create_time,insert_type) values (?, ?, ?)"
if
!
has
{
//不存在品牌,则创建品牌
sql
:=
"insert into lie_brand(brand_name,create_time,insert_type) values (?, ?, ?)"
results
,
err
:=
dbSpu
.
Exec
(
sql
,
skuInfo
.
BrandName
,
php2go
.
Time
(),
1
)
results
,
err
:=
dbSpu
.
Exec
(
sql
,
skuInfo
.
BrandName
,
php2go
.
Time
(),
1
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
err
)
//查询错误
fmt
.
Println
(
err
)
//查询错误
...
@@ -304,9 +301,10 @@ func (t *CommonLyService) writeBrandInfo(skuInfo *model.LyClearGoodsList) int64
...
@@ -304,9 +301,10 @@ func (t *CommonLyService) writeBrandInfo(skuInfo *model.LyClearGoodsList) int64
}
}
brandId
,
_
=
results
.
LastInsertId
()
brandId
,
_
=
results
.
LastInsertId
()
common
.
PrintDebugHtml
(
"创建品牌:"
)
common
.
PrintDebugHtml
(
"创建品牌:"
+
common
.
MyInt64ToStr
(
brandId
))
common
.
PrintDebugHtml
(
brandId
)
}
}
common
.
PrintDebugHtml
(
"更新品牌到redis:"
+
brandkey
)
//更新redis 品牌数据
//更新redis 品牌数据
redisWrite
.
Do
(
"HSET"
,
config
.
Get
(
"redis_all.BRAND_NAME_ALL"
)
.
String
(),
brandkey
,
brandId
)
redisWrite
.
Do
(
"HSET"
,
config
.
Get
(
"redis_all.BRAND_NAME_ALL"
)
.
String
(),
brandkey
,
brandId
)
redisWrite
.
Do
(
"HSET"
,
config
.
Get
(
"redis_all.BRAND"
)
.
String
(),
brandkey
,
brandId
)
redisWrite
.
Do
(
"HSET"
,
config
.
Get
(
"redis_all.BRAND"
)
.
String
(),
brandkey
,
brandId
)
...
...
service/ly/mouser.go
View file @
de58e26e
...
@@ -30,8 +30,8 @@ func OutLinkMouser(goodsName *string) map[string]*model.LyClearGoodsList {
...
@@ -30,8 +30,8 @@ func OutLinkMouser(goodsName *string) map[string]*model.LyClearGoodsList {
print
(
err
)
print
(
err
)
}
}
result
=
resp
.
String
();
//请求外链拿到结果
result
=
resp
.
String
();
//请求外链拿到结果
common
.
PrintDebugHtml
(
result
)
}
}
common
.
PrintDebugHtml
(
"原始数据:"
+
result
)
productList
:=
make
(
map
[
string
]
*
model
.
LyClearGoodsList
,
0
)
productList
:=
make
(
map
[
string
]
*
model
.
LyClearGoodsList
,
0
)
...
...
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