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
2e4fd0e5
Commit
2e4fd0e5
authored
Aug 27, 2018
by
liuyuzhen
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master_dev' of git.shenbd.com:qm-develop/shenbd into lyz
parents
bc4bee74
f9664330
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
1015 additions
and
3 deletions
+1015
-3
PathConst.php
application/library/Our/PathConst.php
+1
-0
OrderService.php
application/models/Business/Order/OrderService.php
+1
-1
ShopkeeperService.php
application/models/Business/Store/ShopkeeperService.php
+46
-0
Order.php
application/models/DAO/Order/Order.php
+4
-2
GoodsCommonStorage.php
application/models/DAO/Storage/GoodsCommonStorage.php
+329
-0
GoodsImagesStorage.php
application/models/DAO/Storage/GoodsImagesStorage.php
+52
-0
GoodsStorage.php
application/models/DAO/Storage/GoodsStorage.php
+409
-0
grow.php
scripts/crontab/growGoodsStores/grow.php
+87
-0
orders.php
scripts/crontab/shopkeeper/orders.php
+86
-0
No files found.
application/library/Our/PathConst.php
View file @
2e4fd0e5
...
...
@@ -30,6 +30,7 @@ class PathConst {
const
cutVertical
=
'|'
;
//统计store_member_statistic表最后更新时间
const
orderGoodsCreateTime
=
"/orderGoodsCreateTime.conf"
;
const
orderLastCreateTime
=
"/orderLastCreateTime.conf"
;
const
favoritesStoreFavTimeConf
=
"/favoritesStoreFavTime.conf"
;
const
orderPaymentTimeConf
=
"/orderPaymentTime.conf"
;
...
...
application/models/Business/Order/OrderService.php
View file @
2e4fd0e5
...
...
@@ -240,7 +240,7 @@ class OrderServiceModel extends \Business\AbstractModel
if
(
$res
){
if
(
$memberId
)
{
$orderDao
->
deleteOrderCache
(
$memberId
,
$orderId
);
$memberDao
->
fromOrderStateToOrderState
(
$memberId
,
$order
[
'order_state'
],
ApiConst
::
orderStateCancel
);
//
$memberDao->fromOrderStateToOrderState($memberId,$order['order_state'],ApiConst::orderStateCancel);
}
}
return
$res
;
...
...
application/models/Business/Store/ShopkeeperService.php
View file @
2e4fd0e5
...
...
@@ -468,6 +468,52 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
}
while
(
$storeMemberStatisticData
);
file_put_contents
(
$this
->
baseDir
.
PathConst
::
orderGoodsCreateTime
,
TIMESTAMP
);
}
//创建索引
public
function
createOrdersIndex
()
{
$orderGoodDao
=
\DAO\Order\OrderGoodsModel
::
getInstance
(
DbNameConst
::
salveDBConnectName
);
$orderDao
=
\DAO\Order\OrderModel
::
getInstance
(
DbNameConst
::
salveDBConnectName
);
$gmtCreate
=
file_get_contents
(
$this
->
baseDir
.
PathConst
::
orderLastCreateTime
);
$gmtCreate
=
!
empty
(
$gmtCreate
)
?
$gmtCreate
:
ApiConst
::
zero
;
$beginTime
=
$gmtCreate
;
$this
->
taskIndex
=
PageConst
::
taskPageBegin
;
$this
->
taskSize
=
PageConst
::
taskPageSize
;
do
{
$addDatas
=
array
();
$where
[
'add_time'
]
=
Common
::
format
(
" add_time>=
{
0
}
and add_time<"
,
$beginTime
,
TIMESTAMP
);
$orders
=
$orderDao
->
getList
(
$where
,
$orderDao
->
_primaryKey
,
$this
->
taskIndex
,
$this
->
taskSize
,
$orderField
=
'add_time'
,
$sort
=
'desc'
);
if
(
!
empty
(
$orders
[
'list'
])){
$orderIds
=
array_column
(
$orders
[
'list'
],
$orderDao
->
_primaryKey
);
$resultOrders
=
array
();
foreach
(
$orders
as
$order
){
}
}
$storeMemberStatisticData
=
$orderGoodDao
->
getMemberStoreStaticsByCreateTime
(
$beginTime
,
$this
->
taskIndex
,
$this
->
taskSize
);
$storeMemberStatisticData
=
isset
(
$storeMemberStatisticData
[
'list'
])
?
$storeMemberStatisticData
[
'list'
]
:
false
;
if
(
$storeMemberStatisticData
){
$this
->
taskIndex
++
;
foreach
(
$storeMemberStatisticData
as
$value
){
$addDatas
[
$value
[
'buyerId'
]
.
'-'
.
$value
[
'storeId'
]][
'storeId'
]
=
$value
[
'storeId'
];
$addDatas
[
$value
[
'buyerId'
]
.
'-'
.
$value
[
'storeId'
]][
'memberId'
]
=
$value
[
'buyerId'
];
if
(
isset
(
$addDatas
[
$value
[
'buyerId'
]
.
'-'
.
$value
[
'storeId'
]][
'orderGoodsCount'
])){
$addDatas
[
$value
[
'buyerId'
]
.
'-'
.
$value
[
'storeId'
]][
'orderGoodsCount'
]
+=
$value
[
'goodsNum'
];
}
else
{
$addDatas
[
$value
[
'buyerId'
]
.
'-'
.
$value
[
'storeId'
]][
'orderGoodsCount'
]
=
$value
[
'goodsNum'
];
}
if
(
isset
(
$addDatas
[
$value
[
'buyerId'
]
.
'-'
.
$value
[
'storeId'
]][
'orderTotal'
])){
$addDatas
[
$value
[
'buyerId'
]
.
'-'
.
$value
[
'storeId'
]][
'orderTotal'
]
+=
$value
[
'goodsPrice'
];
}
else
{
$addDatas
[
$value
[
'buyerId'
]
.
'-'
.
$value
[
'storeId'
]][
'orderTotal'
]
=
$value
[
'goodsPrice'
];
}
}
}
$addDatas
=
array_values
(
$addDatas
);
$storeMemberStatisticDao
->
addAll
(
$addDatas
);
}
while
(
$orders
);
file_put_contents
(
$this
->
baseDir
.
PathConst
::
orderLastCreateTime
,
TIMESTAMP
);
}
public
function
reduceRefundModel
(
$storeMemberDatas
){
$convertStoreMember
=
array
();
...
...
application/models/DAO/Order/Order.php
View file @
2e4fd0e5
...
...
@@ -32,7 +32,7 @@ class OrderModel extends \DAO\AbstractModel
*
* @var string
*/
p
rotected
$_primaryKey
=
'order_id'
;
p
ublic
$_primaryKey
=
'order_id'
;
public
$errorMessage
;
public
function
init
()
...
...
@@ -300,7 +300,7 @@ class OrderModel extends \DAO\AbstractModel
$where
=
$this
->
db
->
getSqlWhereByArray
(
$where
);
}
$orders
=
$this
->
lists
(
$where
,
$order
,
$field
,
$pageIndex
,
$pageSize
);
return
$orders
?
$orders
:
array
();
return
$orders
[
'list'
]
?
$orders
:
array
();
}
//待收货获取订单状态信息
...
...
@@ -843,6 +843,8 @@ class OrderModel extends \DAO\AbstractModel
public
function
getCancelUnpayedOrderTimeCache
(){
$res
=
\Redis\Db5\OrderRedisModel
::
getInstance
()
->
tableCacheGet
(
\Our\NameConst
::
cancelUnPayedOrderTimePrefix
);
echo
'abcd'
.
json_encode
(
$res
);
return
\Redis\Db5\OrderRedisModel
::
getInstance
()
->
tableCacheGet
(
\Our\NameConst
::
cancelUnPayedOrderTimePrefix
);
}
...
...
application/models/DAO/Storage/GoodsCommonStorage.php
0 → 100644
View file @
2e4fd0e5
This diff is collapsed.
Click to expand it.
application/models/DAO/Storage/GoodsImagesStorage.php
0 → 100644
View file @
2e4fd0e5
<?php
namespace
DAO\Storage
;
class
GoodsImagesStorageModel
extends
\DAO\AbstractModel
{
/**
* 表名
*
* @var string
*/
protected
$_tableName
=
'han_goods_images_storage'
;
/**
* 主键
*
* @var string
*/
protected
$_primaryKey
=
'goods_image_id'
;
public
function
init
(){
}
public
function
getListByCommonId
(
$goodsCommonId
,
$field
){
$this
->
setDb
();
return
$this
->
db
->
select
(
$field
)
->
from
(
$this
->
_tableName
)
->
where
(
array
(
'goods_commonid'
=>
$goodsCommonId
))
->
fetchAll
();
}
/**
* 类实例
*
* @var \DAO\UserModel
*/
private
static
$_instance
=
null
;
/**
* 获取类实例
*
* @return \DAO\UserModel
*/
public
static
function
getInstance
()
{
if
(
!
(
self
::
$_instance
instanceof
self
))
{
self
::
$_instance
=
new
self
();
}
return
self
::
$_instance
;
}
}
application/models/DAO/Storage/GoodsStorage.php
0 → 100644
View file @
2e4fd0e5
This diff is collapsed.
Click to expand it.
scripts/crontab/growGoodsStores/grow.php
0 → 100644
View file @
2e4fd0e5
<?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
cliGrow
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
(
'shopkeeper'
);
if
(
!
$this
->
mkdirs
(
$lockDir
))
{
echo
'****create dir fail ****'
;
exit
;
}
$this
->
lockFileName
=
$lockDir
.
DS
.
'grow.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 独占锁
$goodsCommonStrorageDao
=
\DAO\Storage\GoodsCommonStorageModel
::
getInstance
();
$goodsStorageDao
=
\DAO\Storage\GoodsStorageModel
::
getInstance
();
$goodsImagesStorageDao
=
\DAO\Storage\GoodsImagesStorageModel
::
getInstance
();
try
{
$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
cliGrow
(
TRUE
);
EXIT
;
?>
scripts/crontab/shopkeeper/orders.php
0 → 100644
View file @
2e4fd0e5
<?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
cliShopkeeperOrders
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
(
'shopkeeper'
);
if
(
!
$this
->
mkdirs
(
$lockDir
))
{
echo
'****create dir fail ****'
;
exit
;
}
$this
->
lockFileName
=
$lockDir
.
DS
.
'orders.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 独占锁
$shopkeeperService
=
\Business\Store\ShopkeeperServiceModel
::
getInstance
();
$shopkeeperService
->
baseDir
=
\Our\Common
::
getConfig
(
'out.config'
);
try
{
$shopkeeperService
->
createOrdersIndex
();
}
catch
(
Exception
$ex
)
{
throw
new
Exception
(
$ex
->
getCode
()
.
'|'
.
$ex
->
getMessage
());
}
echo
'店铺订单索引生成成功'
.
date
(
'Y-m-d H:i:s'
,
TIMESTAMP
)
.
"
\r\n
"
;
}
}
$oCli
=
new
cliShopkeeperOrders
(
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