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
c7df24ca
Commit
c7df24ca
authored
Dec 17, 2018
by
liuyuzhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
会员IP更新定时器
parent
f966639e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
104 additions
and
6 deletions
+104
-6
MemberService.php
application/models/Business/User/MemberService.php
+17
-1
application.ini
conf/application.ini
+5
-5
updateMemberAreaInfo.php
scripts/crontab/user/updateMemberAreaInfo.php
+82
-0
No files found.
application/models/Business/User/MemberService.php
View file @
c7df24ca
...
...
@@ -1125,6 +1125,22 @@ class MemberServiceModel extends \Business\AbstractModel
}
public
function
updateMemberAreaInfo
(){
$currentTime
=
TIMESTAMP
;
$startTime
=
$currentTime
-
\Our\ApiConst
::
oneDaySecond
;
if
(
$currentTime
<
1545235200
){
$startTime
=
0
;
}
$whereSql
=
\Our\Common
::
format
(
"member_provinceid = '0' and member_cityid = '0' and register_ip !='' and (member_time between '
{
0
}
' and '
{
1
}
') "
,
$startTime
,
$currentTime
);
$memberDao
=
\DAO\MemberModel
::
getInstance
();
$memberList
=
$memberDao
->
getList
(
$whereSql
,
'member_id,register_ip'
);
if
(
$memberList
){
foreach
(
$memberList
as
$member
){
$ip
=
$member
[
'register_ip'
];
$updateData
=
\Area\AreaUtil
::
getInstance
()
->
getIpCityInfo
(
$ip
);
$memberDao
->
saveInfo
(
$updateData
,
$member
[
'member_id'
]);
}
}
}
}
conf/application.ini
View file @
c7df24ca
...
...
@@ -106,10 +106,10 @@ elastic.master.scheme="http";
password.key='~!@#$`1234qwertasdfgzxcvb';
; 生 产环境配置
[
pre
: common]
[
lyztest
: common]
; 数据库配置
resources.database.params.driver
=
"pdo_mysql"
resources.database.params.hostname
=
"1
27.0.0.1
"
resources.database.params.hostname
=
"1
06.14.14.233
"
resources.database.params.port
=
3306
resources.database.params.database
=
"qmcs"
resources.database.params.username
=
"root"
...
...
@@ -120,7 +120,7 @@ resources.database.params.driver_options.1002 = "SET NAMES utf8"
; 从库配置
resources.database.slave.params.driver
=
"pdo_mysql"
resources.database.slave.params.hostname
=
"1
27.0.0.1
"
resources.database.slave.params.hostname
=
"1
06.14.14.233
"
resources.database.slave.params.port
=
3306
resources.database.slave.params.database
=
"qmcs"
resources.database.slave.params.username
=
"root"
...
...
@@ -140,7 +140,7 @@ resources.database.drawSource.params.driver_options.1002 = "SET NAMES utf8"
; mongodb
resources.database.mongo.params.driver
=
"scram"
resources.database.mongo.params.hostname
=
"1
27.0.0.1
"
resources.database.mongo.params.hostname
=
"1
06.14.14.233
"
resources.database.mongo.params.port
=
27017
resources.database.mongo.params.database
=
"qmcs"
resources.database.mongo.params.username
=
"qmcs"
...
...
@@ -399,7 +399,7 @@ elastic.master.host="192.168.1.201"
elastic.master.port
=
"9200"
elastic.master.scheme
=
"http"
;
[lyztest : common]
[lyztest
1
: common]
; 数据库配置
resources.database.params.driver
=
"pdo_mysql"
resources.database.params.hostname
=
"127.0.0.1"
...
...
scripts/crontab/user/updateMemberAreaInfo.php
0 → 100644
View file @
c7df24ca
<?php
/**
* User: liuyuzhen
* Date: 2018/12/17
* Time: 14:25
* Description:
*/
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
cliUpdateMemberAreaInfo
extends
basecli
{
const
CLI_ADMIN_ID
=
255
;
private
$bDoUnLock
=
FALSE
;
// 是否允许释放 LOCK 文件
private
$_debug
=
0
;
private
$lockFileName
;
private
$fromState
;
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
);
}
}
protected
function
updateMemberAreaInfo
(){
\Business\User\MemberServiceModel
::
getInstance
()
->
updateMemberAreaInfo
();
}
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
(
'updateMemberAreaInfo'
);
if
(
!
$this
->
mkdirs
(
$lockDir
)){
echo
'****create dir fail ****'
;
exit
;
}
$this
->
lockFileName
=
$lockDir
.
'.locks'
;
if
(
file_exists
(
$this
->
lockFileName
)
)
{
$stat
=
stat
(
$this
->
lockFileName
);
if
(
(
TIMESTAMP
-
$stat
[
'mtime'
])
>
24
*
60
*
60
*
2
)
{
echo
"文件被锁超过2天,被强制删除"
;
@
unlink
(
$this
->
lockFileName
);
}
else
{
$this
->
halt
(
'['
.
date
(
'Y-m-d H:i:s'
)
.
'] The CLI is running'
.
"
\n
"
);
}
}
$this
->
bDoUnLock
=
true
;
file_put_contents
(
$this
->
lockFileName
,
"running"
);
// CLI 独占锁
$this
->
updateMemberAreaInfo
();
echo
'会员IP更新成功'
.
"
\r\n
"
;
}
}
$oCli
=
new
cliUpdateMemberAreaInfo
(
TRUE
);
EXIT
;
\ No newline at end of file
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