Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
goods
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
goods
Commits
e5591958
Commit
e5591958
authored
Jun 30, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:es数据结构修改
parent
9750a7c5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
45 deletions
+65
-45
GoodsToEs.php
application/modules/Cli/controllers/GoodsToEs.php
+24
-21
ElasticGoodService.php
application/services/goods/ElasticGoodService.php
+3
-0
GoodsService.php
application/services/goods/GoodsService.php
+38
-24
No files found.
application/modules/Cli/controllers/GoodsToEs.php
View file @
e5591958
...
@@ -70,6 +70,9 @@ class GoodsToEsController extends Cli
...
@@ -70,6 +70,9 @@ class GoodsToEsController extends Cli
//门店信息
//门店信息
$subShopList
=
ShopService
::
getRelationShop
(
$goodsSkuId
);
$subShopList
=
ShopService
::
getRelationShop
(
$goodsSkuId
);
$latitude
=
empty
(
$subShopList
[
0
][
"latitude"
])
?
""
:
$subShopList
[
0
][
"latitude"
];
$longitude
=
empty
(
$subShopList
[
0
][
"longitude"
])
?
""
:
$subShopList
[
0
][
"longitude"
];
if
(
!
empty
(
$longitude
)
||
!
empty
(
$latitude
))
{
$data
=
[
$data
=
[
"goods_sku_id"
=>
$goodsSkuInfo
[
"goods_sku_id"
],
"goods_sku_id"
=>
$goodsSkuInfo
[
"goods_sku_id"
],
"goods_desc_pic_url"
=>
$goodsSkuInfo
[
"desc_pic_url"
],
"goods_desc_pic_url"
=>
$goodsSkuInfo
[
"desc_pic_url"
],
...
@@ -87,11 +90,11 @@ class GoodsToEsController extends Cli
...
@@ -87,11 +90,11 @@ class GoodsToEsController extends Cli
"life_account_name"
=>
empty
(
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_name"
])
?
""
:
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_name"
],
"life_account_name"
=>
empty
(
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_name"
])
?
""
:
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_name"
],
"life_account_icon"
=>
empty
(
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_icon"
])
?
""
:
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_icon"
],
"life_account_icon"
=>
empty
(
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_icon"
])
?
""
:
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_icon"
],
"shop_name"
=>
empty
(
$subShopList
[
0
][
"shop_name"
])
?
""
:
$subShopList
[
0
][
"shop_name"
],
"shop_name"
=>
empty
(
$subShopList
[
0
][
"shop_name"
])
?
""
:
$subShopList
[
0
][
"shop_name"
],
"shop_longitude"
=>
empty
(
$subShopList
[
0
][
"longitude"
])
?
""
:
$subShopList
[
0
][
"longitude"
],
"shop_location"
=>
$latitude
.
","
.
$longitude
,
"shop_latitude"
=>
empty
(
$subShopList
[
0
][
"latitude"
])
?
""
:
$subShopList
[
0
][
"latitude"
],
];
];
return
ElasticGoodService
::
indexDoc
(
$goodsSkuId
,
$data
);
return
ElasticGoodService
::
indexDoc
(
$goodsSkuId
,
$data
);
}
}
}
}
}
}
}
\ No newline at end of file
application/services/goods/ElasticGoodService.php
View file @
e5591958
...
@@ -49,6 +49,9 @@ class ElasticGoodService
...
@@ -49,6 +49,9 @@ class ElasticGoodService
'type'
=>
'text'
,
'type'
=>
'text'
,
'analyzer'
=>
'ik_max_word'
,
'analyzer'
=>
'ik_max_word'
,
],
],
'shop_location'
=>
[
'type'
=>
'geo_point'
,
],
]
]
]
]
];
];
...
...
application/services/goods/GoodsService.php
View file @
e5591958
...
@@ -914,9 +914,12 @@ class GoodsService
...
@@ -914,9 +914,12 @@ class GoodsService
//门店信息
//门店信息
$subShopList
=
ShopService
::
getRelationShop
(
$goodsSkuId
);
$subShopList
=
ShopService
::
getRelationShop
(
$goodsSkuId
);
if
(
!
empty
(
$subShopList
))
{
foreach
(
$subShopList
as
$subShop
)
{
if
(
!
empty
(
$subShop
[
"latitude"
])
&&
!
empty
(
$subShop
[
"longitude"
]))
{
$data
=
[
$data
=
[
"doc"
=>
[
"doc"
=>
[
"
id"
=>
$goodsSkuInfo
[
"goods_sku_id"
],
"goods_sku_
id"
=>
$goodsSkuInfo
[
"goods_sku_id"
],
"goods_desc_pic_url"
=>
$goodsSkuInfo
[
"desc_pic_url"
],
"goods_desc_pic_url"
=>
$goodsSkuInfo
[
"desc_pic_url"
],
"goods_name"
=>
$goodsSkuInfo
[
"goods_name"
],
"goods_name"
=>
$goodsSkuInfo
[
"goods_name"
],
"inventory_rest"
=>
$goodsSkuInfo
[
"inventory_rest"
],
"inventory_rest"
=>
$goodsSkuInfo
[
"inventory_rest"
],
...
@@ -932,11 +935,13 @@ class GoodsService
...
@@ -932,11 +935,13 @@ class GoodsService
"life_account_name"
=>
empty
(
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_name"
])
?
""
:
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_name"
],
"life_account_name"
=>
empty
(
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_name"
])
?
""
:
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_name"
],
"life_account_icon"
=>
empty
(
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_icon"
])
?
""
:
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_icon"
],
"life_account_icon"
=>
empty
(
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_icon"
])
?
""
:
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_icon"
],
"shop_name"
=>
empty
(
$subShopList
[
0
][
"shop_name"
])
?
""
:
$subShopList
[
0
][
"shop_name"
],
"shop_name"
=>
empty
(
$subShopList
[
0
][
"shop_name"
])
?
""
:
$subShopList
[
0
][
"shop_name"
],
"shop_longitude"
=>
empty
(
$subShopList
[
0
][
"longitude"
])
?
""
:
$subShopList
[
0
][
"longitude"
],
"shop_location"
=>
$subShop
[
"latitude"
]
.
","
.
$subShop
[
"longitude"
],
"shop_latitude"
=>
empty
(
$subShopList
[
0
][
"latitude"
])
?
""
:
$subShopList
[
0
][
"latitude"
],
],
],
];
];
return
ElasticGoodService
::
updateDoc
(
$goodsSkuId
,
$data
);
ElasticGoodService
::
updateDoc
(
$goodsSkuId
,
$data
);
}
}
}
}
}
}
}
...
@@ -948,8 +953,15 @@ class GoodsService
...
@@ -948,8 +953,15 @@ class GoodsService
private
static
function
addGoodsInfoToEs
(
$skuParams
)
private
static
function
addGoodsInfoToEs
(
$skuParams
)
{
{
$nameList
=
Category
::
select
(
"name"
,
[
"category_id"
=>
[
$skuParams
[
"category_1_id"
],
$skuParams
[
"category_2_id"
]]]);
$nameList
=
Category
::
select
(
"name"
,
[
"category_id"
=>
[
$skuParams
[
"category_1_id"
],
$skuParams
[
"category_2_id"
]]]);
//生活号信息
$url
=
config
(
'interface'
,
'goods.public.get_life_account_by_id'
);
if
(
empty
(
$url
))
{
throw
new
InterfaceException
([
'cus'
=>
0
]);
}
$lifeAccountRes
=
(
new
Request
())
->
get
(
$url
,
[
"life_account_id"
=>
$skuParams
[
"life_account_id"
]]);
$data
=
[
$data
=
[
"id"
=>
$skuParams
[
"goods_sku_id"
],
"
goods_sku_
id"
=>
$skuParams
[
"goods_sku_id"
],
"goods_desc_pic_url"
=>
$skuParams
[
"desc_pic_url"
],
"goods_desc_pic_url"
=>
$skuParams
[
"desc_pic_url"
],
"goods_name"
=>
$skuParams
[
"goods_name"
],
"goods_name"
=>
$skuParams
[
"goods_name"
],
"inventory_rest"
=>
$skuParams
[
"inventory_rest"
],
"inventory_rest"
=>
$skuParams
[
"inventory_rest"
],
...
@@ -962,6 +974,8 @@ class GoodsService
...
@@ -962,6 +974,8 @@ class GoodsService
"desc"
=>
$skuParams
[
"desc"
],
"desc"
=>
$skuParams
[
"desc"
],
"category_1_name"
=>
$nameList
[
0
],
"category_1_name"
=>
$nameList
[
0
],
"category_2_name"
=>
$nameList
[
1
],
"category_2_name"
=>
$nameList
[
1
],
"life_account_name"
=>
empty
(
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_name"
])
?
""
:
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_name"
],
"life_account_icon"
=>
empty
(
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_icon"
])
?
""
:
$lifeAccountRes
[
"response"
][
"result"
][
"life_account_icon"
],
];
];
$esRes
=
ElasticGoodService
::
indexDoc
(
$skuParams
[
"goods_sku_id"
],
$data
);
$esRes
=
ElasticGoodService
::
indexDoc
(
$skuParams
[
"goods_sku_id"
],
$data
);
if
(
$esRes
[
"result"
]
==
"created"
&&
$esRes
[
"_shards"
][
"successful"
]
==
1
)
{
if
(
$esRes
[
"result"
]
==
"created"
&&
$esRes
[
"_shards"
][
"successful"
]
==
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