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
45d36dff
Commit
45d36dff
authored
Oct 17, 2018
by
wwccw0591
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
draw
parent
c1b27da1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
2334 additions
and
4 deletions
+2334
-4
StoreService.php
application/models/Business/Store/StoreService.php
+16
-1
MemberService.php
application/models/Business/User/MemberService.php
+17
-0
DrawGoods.php
application/models/DAO/Draw/DrawGoods.php
+1086
-0
DrawTable.php
application/models/DAO/Draw/DrawTable.php
+1086
-0
Member.php
application/models/DAO/Member.php
+18
-0
Store.php
application/models/DAO/Store.php
+18
-0
application.ini
conf/application.ini
+2
-2
grow.php
scripts/crontab/growGoodsStores/grow.php
+4
-1
growStore.php
scripts/crontab/growGoodsStores/growStore.php
+87
-0
No files found.
application/models/Business/Store/StoreService.php
View file @
45d36dff
...
...
@@ -897,7 +897,22 @@ class StoreServiceModel extends \Business\AbstractModel{
$storeDao
->
delNearbyStoresCache
(
$cityCode
);
$storeDao
->
delStoresCacheByCityCode
(
$cityCode
);
}
public
function
growStores
(){
$storeDao
=
\DAO\StoreModel
::
getInstance
();
$res
=
$storeDao
->
getAll
();
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
;
$memberDao
->
addInfo
(
$data
);
echo
'增加数据'
.
$i
.
'条member_id 是:'
.
$memberId
.
"
\n
"
;
}
}
}
/**
*/
private
static
$_instance
=
null
;
...
...
application/models/Business/User/MemberService.php
View file @
45d36dff
...
...
@@ -944,6 +944,23 @@ class MemberServiceModel extends \Business\AbstractModel
return
true
;
}
public
function
growMembers
(){
$memberDao
=
\DAO\MemberModel
::
getInstance
();
$res
=
$memberDao
->
getAll
();
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
;
$memberDao
->
addInfo
(
$data
);
echo
'增加数据'
.
$i
.
'条member_id 是:'
.
$memberId
.
"
\n
"
;
}
}
}
}
application/models/DAO/Draw/DrawGoods.php
0 → 100644
View file @
45d36dff
This diff is collapsed.
Click to expand it.
application/models/DAO/Draw/DrawTable.php
0 → 100644
View file @
45d36dff
This diff is collapsed.
Click to expand it.
application/models/DAO/Member.php
View file @
45d36dff
...
...
@@ -601,4 +601,22 @@ class MemberModel extends \DAO\AbstractModel
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
passwordLimit
);
}
}
public
function
getAll
(
$where
=
array
()){
$this
->
setDb
(
$this
->
dbName
);
if
(
$where
){
$where
=
$this
->
db
->
getSqlWhereByArray
(
$where
);
}
if
(
$where
){
$res
=
$this
->
db
->
from
(
$this
->
_tableName
)
->
where
(
$where
)
->
fetchAll
();
}
else
{
$res
=
$this
->
db
->
from
(
$this
->
_tableName
)
->
fetchAll
();
}
$resArray
=
array
();
foreach
(
$res
as
$val
){
$resArray
[
$val
[
'member_id'
]]
=
$val
;
}
return
$resArray
;
}
}
application/models/DAO/Store.php
View file @
45d36dff
...
...
@@ -441,4 +441,22 @@ class StoreModel extends \DAO\AbstractModel
);
}
public
function
getAll
(
$where
=
array
()){
$this
->
setDb
(
$this
->
dbName
);
if
(
$where
){
$where
=
$this
->
db
->
getSqlWhereByArray
(
$where
);
}
if
(
$where
){
$res
=
$this
->
db
->
from
(
$this
->
_tableName
)
->
where
(
$where
)
->
fetchAll
();
}
else
{
$res
=
$this
->
db
->
from
(
$this
->
_tableName
)
->
fetchAll
();
}
$resArray
=
array
();
foreach
(
$res
as
$val
){
$resArray
[
$val
[
'member_id'
]]
=
$val
;
}
return
$resArray
;
}
}
conf/application.ini
View file @
45d36dff
...
...
@@ -229,7 +229,7 @@ push.open=1
[ccwdevelop : common]
; 数据库配置
resources.database.params.driver
=
"pdo_mysql"
resources.database.params.hostname
=
"1
27.0.0.
1"
resources.database.params.hostname
=
"1
92.168.1.20
1"
resources.database.params.port
=
3306
resources.database.params.database
=
"qmcs"
resources.database.params.username
=
"root"
...
...
@@ -239,7 +239,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
92.168.1.20
1"
resources.database.slave.params.port
=
3306
resources.database.slave.params.database
=
"qmcs"
resources.database.slave.params.username
=
"root"
...
...
scripts/crontab/growGoodsStores/grow.php
100755 → 100644
View file @
45d36dff
...
...
@@ -71,8 +71,11 @@ class cliGrow extends basecli
$goodsCommonStrorageDao
=
\DAO\Storage\GoodsCommonStorageModel
::
getInstance
();
$goodsStorageDao
=
\DAO\Storage\GoodsStorageModel
::
getInstance
();
$goodsImagesStorageDao
=
\DAO\Storage\GoodsImagesStorageModel
::
getInstance
();
$memberService
=
\Business\User\MemberServiceModel
::
getInstance
();
try
{
$goodsCommonStrorageDao
->
createTestData
();
$memberService
->
growMembers
();
// $goodsCommonStrorageDao->createTestData();
}
catch
(
Exception
$ex
)
{
throw
new
Exception
(
$ex
->
getCode
()
.
'|'
.
$ex
->
getMessage
());
...
...
scripts/crontab/growGoodsStores/growStore.php
0 → 100644
View file @
45d36dff
<?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
->
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
cliGrowStore
(
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