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
84928268
Commit
84928268
authored
Jun 16, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:es
parent
84f303fe
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
37 deletions
+44
-37
ElasticService.php
application/services/goods/ElasticService.php
+12
-15
GoodsService.php
application/services/goods/GoodsService.php
+18
-11
ElasticUtil.php
vendor/api/php_utils/src/Elastic/ElasticUtil.php
+6
-3
InstalledVersions.php
vendor/composer/InstalledVersions.php
+3
-3
installed.json
vendor/composer/installed.json
+2
-2
installed.php
vendor/composer/installed.php
+3
-3
No files found.
application/services/goods/ElasticService.php
View file @
84928268
...
@@ -34,9 +34,7 @@ class ElasticService
...
@@ -34,9 +34,7 @@ class ElasticService
*/
*/
public
static
function
indexDoc
(
$index
,
$id
,
$data
)
public
static
function
indexDoc
(
$index
,
$id
,
$data
)
{
{
$hostStr
=
config
(
"elasticsearch"
,
"goods.host"
);
$elasticClient
=
ElasticUtil
::
getInstance
();
$hosts
=
explode
(
","
,
$hostStr
);
$elasticClient
=
ElasticUtil
::
getInstance
(
$hosts
);
return
$elasticClient
->
indexDoc
(
$index
,
$data
,
$id
);
return
$elasticClient
->
indexDoc
(
$index
,
$data
,
$id
);
}
}
...
@@ -69,24 +67,23 @@ class ElasticService
...
@@ -69,24 +67,23 @@ class ElasticService
var_export
(
$res
);
var_export
(
$res
);
}
}
public
static
function
searchDoc
(
$index
)
public
static
function
searchDoc
(
$index
,
$searchContent
,
$sortType
,
$from
=
0
,
$size
=
10
)
{
{
$elasticClient
=
ElasticUtil
::
getInstance
();
$data
=
[
$data
=
[
'query'
=>
[
"size"
=>
$size
,
'match'
=>
[
"from"
=>
$from
,
'test_field'
=>
'中国'
"query"
=>
[
"match"
=>
[
"test_field"
=>
"中国"
]
]
],
],
'highlight'
=>
[
"sort"
=>
[
'pre_tags'
=>
[
'<tag1>'
,
'<tag2>'
],
"match"
=>
[
'post_tags'
=>
[
'</tag1>'
,
'</tag2>'
],
"test_field"
=>
"中国"
"fields"
=>
[
'test_field'
=>
new
\stdClass
()
]
]
]
]
,
];
];
$elasticClient
=
ElasticUtil
::
getInstance
();
$res
=
$elasticClient
->
searchDoc
(
$index
,
$data
);
$res
=
$elasticClient
->
searchDoc
(
$index
,
$data
);
var_export
(
$res
);
var_export
(
$res
);
}
}
...
...
application/services/goods/GoodsService.php
View file @
84928268
...
@@ -141,8 +141,8 @@ class GoodsService
...
@@ -141,8 +141,8 @@ class GoodsService
"rule_refund"
=>
$skuData
[
"rule_refund"
],
"rule_refund"
=>
$skuData
[
"rule_refund"
],
"inventory_total"
=>
$skuData
[
"inventory_total"
],
"inventory_total"
=>
$skuData
[
"inventory_total"
],
"inventory_rest"
=>
$skuData
[
"inventory_total"
],
"inventory_rest"
=>
$skuData
[
"inventory_total"
],
"original_price"
=>
$skuData
[
"original_price"
],
"original_price"
=>
$skuData
[
"original_price"
]
*
100
,
"price"
=>
$skuData
[
"price"
],
"price"
=>
$skuData
[
"price"
]
*
100
,
];
];
if
(
!
empty
(
$skuData
[
"setmeal"
]))
{
if
(
!
empty
(
$skuData
[
"setmeal"
]))
{
$skuParams
[
"setmeal"
]
=
$skuData
[
"setmeal"
];
$skuParams
[
"setmeal"
]
=
$skuData
[
"setmeal"
];
...
@@ -423,7 +423,7 @@ class GoodsService
...
@@ -423,7 +423,7 @@ class GoodsService
$skuParams
[
"setmeal"
]
=
$params
[
"setmeal"
];
$skuParams
[
"setmeal"
]
=
$params
[
"setmeal"
];
}
}
//同步到es
//同步到es
self
::
g
oodsInfoToEs
(
$skuData
,
$skuParams
);
self
::
updateG
oodsInfoToEs
(
$skuData
,
$skuParams
);
return
GoodsSku
::
save
(
$skuParams
,
[
"goods_sku_id"
=>
$goodsSkuId
]);
return
GoodsSku
::
save
(
$skuParams
,
[
"goods_sku_id"
=>
$goodsSkuId
]);
}
}
...
@@ -534,24 +534,30 @@ class GoodsService
...
@@ -534,24 +534,30 @@ class GoodsService
}
}
/**
* 更新到es
* @param $skuData
* @param $skuParams
* @return array|callable
*/
private
static
function
updateGoodsInfoToEs
(
$skuData
,
$skuParams
)
private
static
function
updateGoodsInfoToEs
(
$skuData
,
$skuParams
)
{
{
$index
=
"bp_goods"
;
$index
=
"bp_goods"
;
$data
=
[
$data
=
[
"doc"
=>
[
"doc"
=>
[
"id"
=>
$skuData
[
"goods_sku_id"
],
"id"
=>
$skuData
[
"goods_sku_id"
],
"goods_pic"
=>
$skuParams
[
"url"
],
"goods_pic"
=>
$skuParams
[
"url"
],
"name"
=>
$skuParams
[
"name"
],
"name"
=>
$skuParams
[
"name"
],
"inventory_rest"
=>
$skuParams
[
"inventory_rest"
],
"inventory_rest"
=>
$skuParams
[
"inventory_rest"
],
"total_amount_sold"
=>
$skuData
[
"total_amount_sold"
],
"total_amount_sold"
=>
$skuData
[
"total_amount_sold"
],
"original_price"
=>
$skuParams
[
"original_price"
],
"original_price"
=>
$skuParams
[
"original_price"
]
/
100
,
"price"
=>
$skuParams
[
"price"
],
"price"
=>
$skuParams
[
"price"
]
/
100
,
"price_sort"
=>
$skuParams
[
"price"
],
"status"
=>
$skuData
[
"status"
],
"status"
=>
$skuData
[
"status"
],
"online_status"
=>
$skuData
[
"online_status"
],
"online_status"
=>
$skuData
[
"online_status"
],
],
],
];
];
$esRes
=
ElasticService
::
updateDoc
(
$index
,
$skuData
[
"goods_sku_id"
],
$data
);
return
ElasticService
::
updateDoc
(
$index
,
$skuData
[
"goods_sku_id"
],
$data
);
var_dump
(
$esRes
);
exit
;
}
}
/**
/**
...
@@ -563,14 +569,15 @@ class GoodsService
...
@@ -563,14 +569,15 @@ class GoodsService
{
{
$index
=
"bp_goods"
;
$index
=
"bp_goods"
;
$data
=
[
$data
=
[
"doc"
=>
[
"doc"
=>
[
"id"
=>
$skuParams
[
"goods_sku_id"
],
"id"
=>
$skuParams
[
"goods_sku_id"
],
"goods_pic"
=>
$skuParams
[
"url"
],
"goods_pic"
=>
$skuParams
[
"url"
],
"name"
=>
$skuParams
[
"name"
],
"name"
=>
$skuParams
[
"name"
],
"inventory_rest"
=>
$skuParams
[
"inventory_rest"
],
"inventory_rest"
=>
$skuParams
[
"inventory_rest"
],
"total_amount_sold"
=>
0
,
"total_amount_sold"
=>
0
,
"original_price"
=>
$skuParams
[
"original_price"
],
"original_price"
=>
$skuParams
[
"original_price"
]
/
100
,
"price"
=>
$skuParams
[
"price"
],
"price"
=>
$skuParams
[
"price"
]
/
100
,
"price_sort"
=>
$skuParams
[
"price"
],
"status"
=>
GoodsSku
::
STATUS_AUDIT
,
"status"
=>
GoodsSku
::
STATUS_AUDIT
,
"online_status"
=>
GoodsSku
::
ONLINE_STATUS_NO_ONLINE
,
"online_status"
=>
GoodsSku
::
ONLINE_STATUS_NO_ONLINE
,
],
],
...
...
vendor/api/php_utils/src/Elastic/ElasticUtil.php
View file @
84928268
...
@@ -20,8 +20,11 @@ final class ElasticUtil
...
@@ -20,8 +20,11 @@ final class ElasticUtil
* ElasticUtil constructor.
* ElasticUtil constructor.
* @param $hosts
* @param $hosts
*/
*/
public
function
__construct
(
$hosts
)
public
function
__construct
()
{
{
$hostStr
=
config
(
"elasticsearch"
,
"goods.host"
);
$hosts
=
explode
(
","
,
$hostStr
);
$this
->
client
=
ClientBuilder
::
create
()
->
setHosts
(
$hosts
)
->
build
();
$this
->
client
=
ClientBuilder
::
create
()
->
setHosts
(
$hosts
)
->
build
();
}
}
...
@@ -29,10 +32,10 @@ final class ElasticUtil
...
@@ -29,10 +32,10 @@ final class ElasticUtil
* @param $hosts
* @param $hosts
* @return ElasticUtil
* @return ElasticUtil
*/
*/
public
static
function
getInstance
(
$hosts
)
:
ElasticUtil
public
static
function
getInstance
()
:
ElasticUtil
{
{
if
(
empty
(
self
::
$instance
))
{
if
(
empty
(
self
::
$instance
))
{
self
::
$instance
=
new
self
(
$hosts
);
self
::
$instance
=
new
self
();
}
}
return
self
::
$instance
;
return
self
::
$instance
;
}
}
...
...
vendor/composer/InstalledVersions.php
View file @
84928268
...
@@ -32,7 +32,7 @@ private static $installed = array (
...
@@ -32,7 +32,7 @@ private static $installed = array (
'aliases'
=>
'aliases'
=>
array
(
array
(
),
),
'reference'
=>
'
d4137182c34400313923cd9c6371f57874a58299
'
,
'reference'
=>
'
84f303fe12b697c338160072ef8b501de5add893
'
,
'name'
=>
'yidian/yaf_demo'
,
'name'
=>
'yidian/yaf_demo'
,
),
),
'versions'
=>
'versions'
=>
...
@@ -55,7 +55,7 @@ private static $installed = array (
...
@@ -55,7 +55,7 @@ private static $installed = array (
array
(
array
(
0
=>
'9999999-dev'
,
0
=>
'9999999-dev'
,
),
),
'reference'
=>
'
94bec4fc5b52829a32f22a40d283faa4f2b596d
e'
,
'reference'
=>
'
c0936cac091daea86ee8a035a53d3da53c4a6f6
e'
,
),
),
'catfan/medoo'
=>
'catfan/medoo'
=>
array
(
array
(
...
@@ -193,7 +193,7 @@ private static $installed = array (
...
@@ -193,7 +193,7 @@ private static $installed = array (
'aliases'
=>
'aliases'
=>
array
(
array
(
),
),
'reference'
=>
'
d4137182c34400313923cd9c6371f57874a58299
'
,
'reference'
=>
'
84f303fe12b697c338160072ef8b501de5add893
'
,
),
),
),
),
);
);
...
...
vendor/composer/installed.json
View file @
84928268
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
"source"
:
{
"source"
:
{
"type"
:
"git"
,
"type"
:
"git"
,
"url"
:
"https://git.yidian-inc.com:8021/bp/php_utils.git"
,
"url"
:
"https://git.yidian-inc.com:8021/bp/php_utils.git"
,
"reference"
:
"
94bec4fc5b52829a32f22a40d283faa4f2b596d
e"
"reference"
:
"
c0936cac091daea86ee8a035a53d3da53c4a6f6
e"
},
},
"require"
:
{
"require"
:
{
"catfan/medoo"
:
"1.7.10"
,
"catfan/medoo"
:
"1.7.10"
,
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
"mongodb/mongodb"
:
"1.4.3"
,
"mongodb/mongodb"
:
"1.4.3"
,
"php"
:
">=7.2"
"php"
:
">=7.2"
},
},
"time"
:
"2021-06-16T
09:15:06
+00:00"
,
"time"
:
"2021-06-16T
10:54:38
+00:00"
,
"default-branch"
:
true
,
"default-branch"
:
true
,
"type"
:
"library"
,
"type"
:
"library"
,
"installation-source"
:
"source"
,
"installation-source"
:
"source"
,
...
...
vendor/composer/installed.php
View file @
84928268
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
'aliases'
=>
'aliases'
=>
array
(
array
(
),
),
'reference'
=>
'
d4137182c34400313923cd9c6371f57874a58299
'
,
'reference'
=>
'
84f303fe12b697c338160072ef8b501de5add893
'
,
'name'
=>
'yidian/yaf_demo'
,
'name'
=>
'yidian/yaf_demo'
,
),
),
'versions'
=>
'versions'
=>
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
array
(
array
(
0
=>
'9999999-dev'
,
0
=>
'9999999-dev'
,
),
),
'reference'
=>
'
94bec4fc5b52829a32f22a40d283faa4f2b596d
e'
,
'reference'
=>
'
c0936cac091daea86ee8a035a53d3da53c4a6f6
e'
,
),
),
'catfan/medoo'
=>
'catfan/medoo'
=>
array
(
array
(
...
@@ -167,7 +167,7 @@
...
@@ -167,7 +167,7 @@
'aliases'
=>
'aliases'
=>
array
(
array
(
),
),
'reference'
=>
'
d4137182c34400313923cd9c6371f57874a58299
'
,
'reference'
=>
'
84f303fe12b697c338160072ef8b501de5add893
'
,
),
),
),
),
);
);
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