Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
my-yaf-project
Project
Project
Details
Activity
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
chenchuanwen
my-yaf-project
Commits
b8bf90e2
Commit
b8bf90e2
authored
Nov 29, 2018
by
wwccw0591
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upd
parent
3968e722
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
103 additions
and
0 deletions
+103
-0
storeStat.php
scripts/crontab/store/storeStat.php
+103
-0
No files found.
scripts/crontab/store/storeStat.php
0 → 100644
View file @
b8bf90e2
<?php
define
(
"APPLICATION_PATH"
,
realpath
(
dirname
(
__FILE__
)
.
'/../../../'
));
//指向public的上一级
require
APPLICATION_PATH
.
'/scripts/crontab/baseCli.php'
;
require
APPLICATION_PATH
.
'/scripts/crontab/common.php'
;
error_reporting
(
E_ALL
^
E_NOTICE
);
/**
* 店铺数据统计
* 执行时间:每分钟执行一次
* Class cliStoreStoreStat
* User: King <358887571@qq.com>
* Date: 2018/11/30 0030
* Time: 下午 3:00
*
*/
class
cliStoreStoreStat
extends
basecli
{
const
CLI_ADMIN_ID
=
255
;
private
$bDoUnLock
=
FALSE
;
// 是否允许释放 LOCK 文件
private
$_debug
=
0
;
private
$lockFileName
;
private
function
mkdirs
(
$dir
,
$mode
=
0777
)
{
if
(
is_dir
(
$dir
)
||
@
mkdir
(
$dir
,
$mode
)){
return
TRUE
;
}
if
(
!
$this
->
mkdirs
(
dirname
(
$dir
),
$mode
)){
return
FALSE
;
}
return
@
mkdir
(
$dir
,
$mode
);
}
/**
* 析构
*/
public
function
__destruct
()
{
parent
::
__destruct
();
if
(
$this
->
bDoUnLock
)
{
@
unlink
(
$this
->
lockFileName
);
}
}
/**
* 自动统计商品
* User: linqin <358887571@qq.com>
* Date: 2018/11/27 0027
* Time: 下午 3:23
*/
protected
function
autoStatGoods
(){
$service
=
\Business\Store\StoreServiceModel
::
getInstance
(
\Our\DbNameConst
::
masterDBConnectName
);
$service
->
baseDir
=
\Our\Common
::
getConfig
(
'out.config'
);
echo
"update store stat
\n
"
;
if
(
$service
->
updateStatStore
())
{
//更新商品基础信息
echo
"update store others
\n
"
;
//$goodsService->updateStatGoodsSell();
}
}
protected
function
_runCli
()
{
$this
->
_debug
=
isset
(
$this
->
aArgv
[
1
])
?
intval
(
$this
->
aArgv
[
1
])
:
0
;
if
(
$this
->
_debug
)
{
echo
"*** Debug mode ***
\n
"
;
}
// Step: 02 检查是否已有相同CLI在运行中
$lockDir
=
$this
->
_getBaseFileName
(
'goods'
);
if
(
!
$this
->
mkdirs
(
$lockDir
)){
echo
'****create dir fail ****'
;
exit
;
}
$this
->
lockFileName
=
$lockDir
.
DS
.
'stat.locks'
;
if
(
file_exists
(
$this
->
lockFileName
)
)
{
$stat
=
stat
(
$this
->
lockFileName
);
if
(
(
TIMESTAMP
-
$stat
[
'mtime'
])
>
1800
)
{
echo
"文件被锁超过1800秒,被强制删除"
;
@
unlink
(
$this
->
lockFileName
);
}
else
{
$this
->
halt
(
'['
.
date
(
'Y-m-d H:i:s'
)
.
'] The CLI is running'
.
"
\n
"
);
}
}
$this
->
bDoUnLock
=
true
;
if
(
APP_ENV
==
'pre'
||
APP_ENV
==
'product'
){
file_put_contents
(
$this
->
lockFileName
,
"running"
);
// CLI 独占锁
}
$this
->
autoStatGoods
();
echo
date
(
'Y-m-d H:i:s'
,
TIMESTAMP
)
.
'定单关闭消息成功'
.
"
\r\n
"
;
}
}
$oCli
=
new
cliStoreStoreStat
(
TRUE
);
EXIT
;
?>
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