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
95ba672b
Commit
95ba672b
authored
Nov 14, 2018
by
liuyuzhen
Browse files
Options
Browse Files
Download
Plain Diff
首页查询语句优化
parents
7408420a
913fad99
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
200 additions
and
91 deletions
+200
-91
City.php
application/controllers/City.php
+6
-0
StoreService.php
application/models/Business/Store/StoreService.php
+10
-2
MemberService.php
application/models/Business/User/MemberService.php
+5
-1
growStore.php
scripts/crontab/insertDatas/growStore.php
+87
-87
member.php
scripts/crontab/insertDatas/member.php
+88
-0
nginxLogsIndex.php
scripts/crontab/logs/nginxLogsIndex.php
+1
-1
news_server.php
scripts/crontab/push/news_server.php
+3
-0
No files found.
application/controllers/City.php
View file @
95ba672b
...
...
@@ -12,9 +12,15 @@ class CityController extends \Our\Controller_AbstractIndex {
}
public
function
getCityListAction
(){
if
(
$_POST
[
'data'
][
'debug'
]
==
1
){
echo
"开始时间:"
.
microtime
()
.
"
\r\n
"
;
}
$fromWx
=
$this
->
req
[
\Our\NameConst
::
data
][
'fromWx'
];
$addressService
=
\Business\User\AddressServiceModel
::
getInstance
();
$cityList
=
$addressService
->
getCityList
(
$fromWx
);
if
(
$_POST
[
'data'
][
'debug'
]
==
1
){
echo
"结束时间:"
.
microtime
()
.
"
\r\n
"
;
}
$this
->
success
(
$cityList
);
}
}
\ No newline at end of file
application/models/Business/Store/StoreService.php
View file @
95ba672b
...
...
@@ -965,16 +965,23 @@ class StoreServiceModel extends \Business\AbstractModel{
}
}
public
function
growStores
(){
$cityCodes
=
array
(
'010'
,
'021'
,
'022'
,
'023'
,
'852'
,
'853'
,
'0310'
,
'0311'
,
'0312'
,
'0313'
,
'0314'
,
'0315'
,
'0316'
,
'0317'
,
'0318'
,
'0319'
,
'0335'
,
'0570'
,
'0571'
,
'0572'
,
'0573'
,
'0574'
,
'0575'
,
'0576'
,
'0577'
,
'0578'
,
'0579'
,
'0580'
,
'024'
,
'0410'
,
'0411'
,
'0412'
,
'0413'
,
'0414'
,
'0415'
,
'0416'
,
'0417'
,
'0418'
,
'0419'
,
'0421'
,
'0427'
,
'0429'
,
'027'
,
'0710'
,
'0711'
,
'0712'
,
'0713'
,
'0714'
,
'0715'
,
'0716'
,
'0717'
,
'0718'
,
'0719'
,
'0722'
,
'0724'
,
'0728'
,
'025'
,
'0510'
,
'0511'
,
'0512'
,
'0513'
,
'0514'
,
'0515'
,
'0516'
,
'0517'
,
'0517'
,
'0518'
,
'0519'
,
'0523'
,
'0470'
,
'0471'
,
'0472'
,
'0473'
,
'0474'
,
'0475'
,
'0476'
,
'0477'
,
'0478'
,
'0479'
,
'0482'
,
'0483'
,
'0790'
,
'0791'
,
'0792'
,
'0793'
,
'0794'
,
'0795'
,
'0796'
,
'0797'
,
'0798'
,
'0799'
,
'0701'
,
'0350'
,
'0351'
,
'0352'
,
'0353'
,
'0354'
,
'0355'
,
'0356'
,
'0357'
,
'0358'
,
'0359'
,
'0930'
,
'0931'
,
'0932'
,
'0933'
,
'0934'
,
'0935'
,
'0936'
,
'0937'
,
'0938'
,
'0941'
,
'0943'
,
'0530'
,
'0531'
,
'0532'
,
'0533'
,
'0534'
,
'0535'
,
'0536'
,
'0537'
,
'0538'
,
'0539'
,
'0450'
,
'0451'
,
'0452'
,
'0453'
,
'0454'
,
'0455'
,
'0456'
,
'0457'
,
'0458'
,
'0459'
,
'0591'
,
'0592'
,
'0593'
,
'0594'
,
'0595'
,
'0595'
,
'0596'
,
'0597'
,
'0598'
,
'0599'
,
'020'
,
'0751'
,
'0752'
,
'0753'
,
'0754'
,
'0755'
,
'0756'
,
'0757'
,
'0758'
,
'0759'
,
'0760'
,
'0762'
,
'0763'
,
'0765'
,
'0766'
,
'0768'
,
'0769'
,
'0660'
,
'0661'
,
'0662'
,
'0663'
,
'028'
,
'0810'
,
'0811'
,
'0812'
,
'0813'
,
'0814'
,
'0816'
,
'0817'
,
'0818'
,
'0819'
,
'0825'
,
'0826'
,
'0827'
,
'0830'
,
'0831'
,
'0832'
,
'0833'
,
'0834'
,
'0835'
,
'0836'
,
'0837'
,
'0838'
,
'0839'
,
'0840'
,
'0730'
,
'0731'
,
'0732'
,
'0733'
,
'0734'
,
'0735'
,
'0736'
,
'0737'
,
'0738'
,
'0739'
,
'0743'
,
'0744'
,
'0745'
,
'0746'
,
'0370'
,
'0371'
,
'0372'
,
'0373'
,
'0374'
,
'0375'
,
'0376'
,
'0377'
,
'0378'
,
'0379'
,
'0391'
,
'0392'
,
'0393'
,
'0394'
,
'0395'
,
'0396'
,
'0398'
,
'0870'
,
'0871'
,
'0872'
,
'0873'
,
'0874'
,
'0875'
,
'0876'
,
'0877'
,
'0878'
,
'0879'
,
'0691'
,
'0692'
,
'0881'
,
'0883'
,
'0886'
,
'0887'
,
'0888'
,
'0550'
,
'0551'
,
'0552'
,
'0553'
,
'0554'
,
'0555'
,
'0556'
,
'0557'
,
'0558'
,
'0559'
,
'0561'
,
'0562'
,
'0563'
,
'0564'
,
'0565'
,
'0566'
,
'0951'
,
'0952'
,
'0953'
,
'0954'
,
'0431'
,
'0432'
,
'0433'
,
'0434'
,
'0435'
,
'0436'
,
'0437'
,
'0438'
,
'0439'
,
'0440'
,
'0770'
,
'0771'
,
'0772'
,
'0773'
,
'0774'
,
'0775'
,
'0776'
,
'0777'
,
'0778'
,
'0779'
,
'0851'
,
'0852'
,
'0853'
,
'0854'
,
'0855'
,
'0856'
,
'0857'
,
'0858'
,
'0859'
,
'029'
,
'0910'
,
'0911'
,
'0912'
,
'0913'
,
'0914'
,
'0915'
,
'0916'
,
'0917'
,
'0919'
,
'0971'
,
'0972'
,
'0973'
,
'0974'
,
'0975'
,
'0976'
,
'0977'
,
'0890'
,
'0898'
,
'0899'
,
'0891'
,
'0892'
,
'0893'
);
$storeDao
=
\DAO\StoreModel
::
getInstance
();
$memberDao
=
\DAO\MemberModel
::
getInstance
();
//
$memberDao = \DAO\MemberModel::getInstance();
$res
=
$storeDao
->
getAll
();
$drawTableDao
=
\DAO\Draw\DrawTableModel
::
getInstance
();
$drawTableDatas
=
$drawTableDao
->
getAll
();
for
(
$i
=
0
;
$i
<
100000
;
$i
++
){
for
(
$i
=
0
;
$i
<
100000
0
;
$i
++
){
$memberId
=
50000
+
$i
;
$re
=
array_rand
(
$res
);
$reDraw
=
array_rand
(
$drawTableDatas
);
$storeCityCode
=
array_rand
(
$cityCodes
);
$storeCityCode
=
$cityCodes
[
$storeCityCode
];
$temDrawData
=
$drawTableDatas
[
$reDraw
];
while
(
!
$temDrawData
[
'storeName'
]){
$reDraw
=
array_rand
(
$drawTableDatas
);
$temDrawData
=
$drawTableDatas
[
$reDraw
];
}
if
(
!
empty
(
$res
[
$re
])){
$data
=
$res
[
$re
];
$data
[
'store_id'
]
=
$memberId
;
...
...
@@ -987,6 +994,7 @@ class StoreServiceModel extends \Business\AbstractModel{
$data
[
'live_store_name'
]
=
$temDrawData
[
'storeName'
];
$data
[
'live_store_address'
]
=
$temDrawData
[
'storeAddress'
];
$data
[
'store_longitude'
]
=
$temDrawData
[
'positionX'
]
/
100000
;
$data
[
'store_citycode'
]
=
$storeCityCode
;
$data
[
'store_latitude'
]
=
$temDrawData
[
'positionY'
]
/
100000
;
$storeDao
->
add
(
$data
);
echo
'增加数据'
.
$i
.
'条member_id 是:'
.
$memberId
.
"
\n
"
;
...
...
application/models/Business/User/MemberService.php
View file @
95ba672b
...
...
@@ -1069,14 +1069,18 @@ class MemberServiceModel extends \Business\AbstractModel
public
function
growMembers
(){
$memberDao
=
\DAO\MemberModel
::
getInstance
();
$res
=
$memberDao
->
getAll
();
$pre
=
"1780"
;
for
(
$i
=
0
;
$i
<
1000000
;
$i
++
){
$memberId
=
50000
+
$i
;
$re
=
array_rand
(
$res
);
if
(
!
empty
(
$res
[
$re
])){
$data
=
$res
[
$re
];
$data
[
'member_id'
]
=
$memberId
;
$data
[
'member_mobile'
]
=
(
int
)
$data
[
'member_mobile'
]
+
$i
;
$data
[
'store_id'
]
=
$memberId
;
$data
[
'member_mobile'
]
=
$pre
.
(
string
)(
1000000
+
$i
);
$data
[
'store_id'
]
=
$memberId
;
$data
[
'member_passwd'
]
=
'a18ddf021c99cb0d9e3ff3b52815d1de'
;
$data
[
'member_time'
]
=
'1461747049'
;
$memberDao
->
add
(
$data
);
echo
'增加数据'
.
$i
.
'条member_id 是:'
.
$memberId
.
"
\n
"
;
}
...
...
scripts/crontab/
growGoodsStore
s/growStore.php
→
scripts/crontab/
insertData
s/growStore.php
View file @
95ba672b
<?php
/**
* 生成店铺订单索引
* 执行时间:每分钟执行一次
*
* @author chenjiebin <sjlinyu@qq.com>
*/
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
cliGrowStore
extends
basecli
{
const
CLI_ADMIN_ID
=
255
;
private
$bDoUnLock
=
FALSE
;
// 是否允许释放 LOCK 文件
private
$_debug
=
0
;
private
$lockFileName
;
public
$key
=
''
;
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
_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
(
'
growGoodsStores'
);
if
(
!
$this
->
mkdirs
(
$lockDir
))
{
echo
'****create dir fail ****'
;
exit
;
}
$this
->
lockFileName
=
$lockDir
.
DS
.
'cliGrowStore.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
;
file_put_contents
(
$this
->
lockFileName
,
"running"
);
// CLI 独占锁
$storeService
=
\Business\Store\StoreServiceModel
::
getInstance
();
try
{
$storeService
->
growStores
();
// $goodsCommonStrorageDao->createTestData();
}
catch
(
Exception
$ex
)
{
throw
new
Exception
(
$ex
->
getCode
()
.
'|'
.
$ex
->
getMessage
());
}
echo
'店铺生成成功'
.
date
(
'Y-m-d H:i:s'
,
TIMESTAMP
)
.
"
\r\n
"
;
}
}
$oCli
=
new
cliGrowStore
(
TRUE
);
EXIT
;
?>
<?php
/**
* 生成店铺订单索引
* 执行时间:每分钟执行一次
*
* @author chenjiebin <sjlinyu@qq.com>
*/
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
cliGrowStore
extends
basecli
{
const
CLI_ADMIN_ID
=
255
;
private
$bDoUnLock
=
FALSE
;
// 是否允许释放 LOCK 文件
private
$_debug
=
0
;
private
$lockFileName
;
public
$key
=
''
;
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
_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
(
'
insertDatas'
);
if
(
!
$this
->
mkdirs
(
$lockDir
))
{
echo
'****create dir fail ****'
;
exit
;
}
$this
->
lockFileName
=
$lockDir
.
DS
.
'cliGrowStore.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
;
file_put_contents
(
$this
->
lockFileName
,
"running"
);
// CLI 独占锁
$storeService
=
\Business\Store\StoreServiceModel
::
getInstance
();
try
{
$storeService
->
growStores
();
// $goodsCommonStrorageDao->createTestData();
}
catch
(
Exception
$ex
)
{
throw
new
Exception
(
$ex
->
getCode
()
.
'|'
.
$ex
->
getMessage
());
}
echo
'店铺生成成功'
.
date
(
'Y-m-d H:i:s'
,
TIMESTAMP
)
.
"
\r\n
"
;
}
}
$oCli
=
new
cliGrowStore
(
TRUE
);
EXIT
;
?>
scripts/crontab/insertDatas/member.php
0 → 100644
View file @
95ba672b
<?php
/**
* 生成店铺订单索引
* 执行时间:每分钟执行一次
*
* @author chenjiebin <sjlinyu@qq.com>
*/
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
cliMember
extends
basecli
{
const
CLI_ADMIN_ID
=
255
;
private
$bDoUnLock
=
FALSE
;
// 是否允许释放 LOCK 文件
private
$_debug
=
0
;
private
$lockFileName
;
public
$key
=
''
;
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
_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
(
'insertDatas'
);
if
(
!
$this
->
mkdirs
(
$lockDir
))
{
echo
'****create dir fail ****'
;
exit
;
}
$this
->
lockFileName
=
$lockDir
.
DS
.
'member.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
;
file_put_contents
(
$this
->
lockFileName
,
"running"
);
// CLI 独占锁
$memberService
=
\Business\User\MemberServiceModel
::
getInstance
();
try
{
$memberService
->
growMembers
();
// $goodsCommonStrorageDao->createTestData();
}
catch
(
Exception
$ex
)
{
throw
new
Exception
(
$ex
->
getCode
()
.
'|'
.
$ex
->
getMessage
());
}
echo
'店铺生成成功'
.
date
(
'Y-m-d H:i:s'
,
TIMESTAMP
)
.
"
\r\n
"
;
}
}
$oCli
=
new
cliMember
(
TRUE
);
EXIT
;
?>
scripts/crontab/logs/nginxLogsIndex.php
View file @
95ba672b
...
...
@@ -44,7 +44,7 @@ class clinNginxLogsIndex extends basecli
}
}
public
function
getIndex
(
$dayOption
){
$dateStr
=
date
(
'Y
-m-
d'
,
strtotime
(
$dayOption
));
$dateStr
=
date
(
'Y
.m.
d'
,
strtotime
(
$dayOption
));
$indexStr
=
\Our\Common
::
format
(
"nignx-log-"
.
$dateStr
);
return
$indexStr
;
}
...
...
scripts/crontab/push/news_server.php
View file @
95ba672b
...
...
@@ -272,6 +272,9 @@ $tcp_server->on('receive', function($serv, $fd, $from_id, $data) use($conf) {
$data
[
'data'
][
'message'
]
=
unserialize
(
$data
[
'data'
][
'message'
]);
$redis
->
hIncrBy
(
KEY_PRE
.
$data
[
'data'
][
'toId'
],
'unread_message_count'
,
\Our\ApiConst
::
one
);
if
(
!
empty
(
$sendFd
)){
if
(
!
$data
[
'data'
][
'message'
]){
$data
[
'data'
][
'message'
]
=
new
\stdClass
();
}
$serv
->
push
(
$sendFd
,
responseJson
(
$sendFd
,
"fromMsg"
,
"success"
,
$data
[
'data'
]));
$redis
->
hSet
(
KEY_PRE
.
$data
[
'data'
][
'fromId'
],
'sendTime'
,
time
());
}
...
...
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