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
4ea17d0c
Commit
4ea17d0c
authored
Jun 26, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:同步商品数据到es
parent
efab5772
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
48 deletions
+52
-48
.gitignore
.gitignore
+3
-1
GoodsToEs.php
application/modules/Cli/controllers/GoodsToEs.php
+37
-0
InitGoodsToEs.php
application/modules/Cli/controllers/InitGoodsToEs.php
+0
-36
GoodsService.php
application/services/goods/GoodsService.php
+1
-1
cli.php
public/cli.php
+11
-10
No files found.
.gitignore
View file @
4ea17d0c
...
...
@@ -2,4 +2,6 @@ composer.lock
/yaconf/
.idea
.DS_Store
.project
\ No newline at end of file
.project
ROOT_PATH
logs
\ No newline at end of file
application/modules/Cli/controllers/GoodsToEs.php
0 → 100644
View file @
4ea17d0c
<?php
use
App\Base\Cli
;
use
\App\Models\goods\mysql\GoodsSku
;
use
\App\Services\goods\GoodsService
;
use
Api\PhpUtils\Log\DaemonLog
;
use
Api\PhpServices\JwUser\JwUser
;
/**
* 同步商品数据到es
* php public/cli.php goodsToEs index
* Class GoodsToEsController
*/
class
GoodsToEsController
extends
Cli
{
public
function
IndexAction
()
{
$goodsSkuIds
=
$this
->
getGoodsSkuIdList
();
$this
->
toEs
(
$goodsSkuIds
);
}
private
function
getGoodsSkuIdList
()
{
return
GoodsSku
::
select
(
"goods_sku_id"
,
[]);
}
private
function
toEs
(
$goodsSkuIds
)
{
if
(
!
empty
(
$goodsSkuIds
))
{
foreach
(
$goodsSkuIds
as
$goodsSkuId
)
{
echo
"当前正在同步的商品sku_id:
$goodsSkuId
\n
"
;
GoodsService
::
updateGoodsInfoToEs
(
$goodsSkuId
);
}
}
}
}
\ No newline at end of file
application/modules/Cli/controllers/InitGoodsToEs.php
deleted
100644 → 0
View file @
efab5772
<?php
use
App\Base\Cli
;
use
\App\Models\goods\mysql\GoodsSku
;
class
InitGoodsToEsController
extends
Cli
{
/**
* php public/cli.php InitGoodsToEs index
*/
public
function
IndexAction
()
{
$goodsSkuIds
=
GoodsSku
::
select
(
"goods_sku_id"
,
[
"goods_status"
=>
1
]);
$request
=
$this
->
getRequest
();
$params
=
$request
->
getParams
();
$res
=
[
"data"
=>
$params
,
"code"
=>
0
];
$response
=
$this
->
getResponse
();
$response
->
setBody
(
json_encode
(
$res
));
var_dump
(
$goodsSkuIds
);
// $this->getAllGoodsSkuId();
}
public
function
getAllGoodsSkuId
()
{
$goodsSkuIds
=
GoodsSku
::
select
(
"goods_sku_id"
,
[
"goods_status"
=>
1
]);
var_dump
(
$goodsSkuIds
);
exit
;
}
}
\ No newline at end of file
application/services/goods/GoodsService.php
View file @
4ea17d0c
...
...
@@ -856,7 +856,7 @@ class GoodsService
* @return array|callable
* @throws InterfaceException
*/
p
rivate
static
function
updateGoodsInfoToEs
(
$goodsSkuId
)
p
ublic
static
function
updateGoodsInfoToEs
(
$goodsSkuId
)
{
$goodsSkuInfoList
=
GoodsSku
::
getRecordMaster
([
"goods_sku_id"
=>
$goodsSkuId
]);
if
(
!
empty
(
$goodsSkuInfoList
))
{
...
...
public/cli.php
View file @
4ea17d0c
<?php
date_default_timezone_set
(
"PRC"
);
ini_set
(
"display_errors"
,
"On"
);
//打开错误提示
ini_set
(
"error_reporting"
,
E_ALL
);
//显示所有错误
ini_set
(
"error_reporting"
,
E_ALL
);
//显示所有错误
/*
* cli入口脚本
* cli 配置文件:conf/cli.ini
...
...
@@ -10,27 +11,27 @@ ini_set("error_reporting",E_ALL);//显示所有错误
* 调用方式:php cli.php controller action "a=1&b=2"
* 测试脚本:php cli.php test index "a=1&b=2"
*/
if
(
!
substr
(
php_sapi_name
(),
0
,
3
)
==
'cli'
)
{
if
(
!
substr
(
php_sapi_name
(),
0
,
3
)
==
'cli'
)
{
die
;
}
define
(
'APPLICATION_PATH'
,
realpath
(
__DIR__
.
'/../'
));
define
(
'ROOT_PATH'
,
realpath
(
__DIR__
.
'/../'
));
define
(
'APPLICATION_PATH'
,
realpath
(
__DIR__
.
'/../'
));
require
APPLICATION_PATH
.
'/vendor/autoload.php'
;
$application
=
new
Yaf\Application
(
APPLICATION_PATH
.
"/conf/cli.ini"
);
require
APPLICATION_PATH
.
'/application/library/helper.php'
;
$application
=
new
Yaf\Application
(
APPLICATION_PATH
.
"/conf/cli.ini"
);
/**
* 获取模块/控制器/方法
*/
$module
=
"cli"
;
$controller
=
$argv
[
1
]
??
""
;
$method
=
$argv
[
2
]
??
""
;
$param
=
$argv
[
3
]
??
[];
if
(
$param
)
{
$method
=
$argv
[
2
]
??
""
;
$param
=
$argv
[
3
]
??
[];
if
(
$param
)
{
$param
=
convertUrlQuery
(
$param
);
}
$application
->
bootstrap
()
->
getDispatcher
()
->
dispatch
(
new
Yaf\Request\Simple
(
""
,
$module
,
$controller
,
$method
,
$param
)
);
$application
->
bootstrap
()
->
getDispatcher
()
->
dispatch
(
new
Yaf\Request\Simple
(
""
,
$module
,
$controller
,
$method
,
$param
)
);
function
convertUrlQuery
(
$query
)
{
...
...
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