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
62eb144e
Commit
62eb144e
authored
Aug 24, 2018
by
wwccw0591
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
订单统计
parent
acf61a63
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
366 deletions
+57
-366
ApiConst.php___jb_old___
application/library/Our/ApiConst.php___jb_old___
+0
-365
ShopkeeperService.php
application/models/Business/Store/ShopkeeperService.php
+23
-1
StoreStatisticsDay.php
application/models/DAO/Store/StoreStatisticsDay.php
+34
-0
No files found.
application/library/Our/ApiConst.php___jb_old___
deleted
100644 → 0
View file @
acf61a63
This diff is collapsed.
Click to expand it.
application/models/Business/Store/ShopkeeperService.php
View file @
62eb144e
...
...
@@ -417,7 +417,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
$favoritesStoreDao
=
\DAO\FavoritesStoreModel
::
getInstance
();
$res
=
file_get_contents
(
$this
->
baseDir
.
PathConst
::
favoritesStoreFavTimeConf
);
$this
->
lastFavId
=
!
empty
(
$res
)
?
$res
:
ApiConst
::
zero
;
$where
[
'fav_time'
]
=
Common
::
format
(
"fav_time >=
{
0
}
and fav_time <
{
1
}
"
,
$this
->
lastFavId
,
TIMESTAMP
);
$where
=
Common
::
format
(
"fav_time >=
{
0
}
and fav_time <
{
1
}
"
,
$this
->
lastFavId
,
TIMESTAMP
);
$res
=
$favoritesStoreDao
->
getAllByWhere
(
$where
,
$favoritesStoreDao
->
favoriteMemberCountField
);
$results
=
array
();
if
(
!
empty
(
$res
))
{
...
...
@@ -468,12 +468,33 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
}
while
(
$storeMemberStatisticData
);
file_put_contents
(
$this
->
baseDir
.
PathConst
::
orderGoodsCreateTime
,
TIMESTAMP
);
}
public
function
reduceRefundModel
(
$storeMemberDatas
){
$convertStoreMember
=
array
();
if
(
$storeMemberDatas
){
foreach
(
$storeMemberDatas
as
$order
){
if
(
isset
(
$convertStoreMember
[
$order
[
'storeId'
]])){
$convertStoreMember
[
$order
[
'storeId'
]][
'orderCount'
]
=
$convertStoreMember
[
$order
[
'storeId'
]][
'orderCount'
]
-
ApiConst
::
one
;
$convertStoreMember
[
$order
[
'storeId'
]][
'orderTotal'
]
=
$convertStoreMember
[
$order
[
'storeId'
]][
'orderTotal'
]
+
$order
[
'refundAmount'
];
}
else
{
$convertStoreMember
[
$order
[
'storeId'
]][
'orderCount'
]
=
ApiConst
::
one
;
$convertStoreMember
[
$order
[
'storeId'
]][
'orderTotal'
]
=
$order
[
'refundAmount'
];
$convertStoreMember
[
$order
[
'storeId'
]][
'gmtCreate'
]
=
isset
(
$order
[
'gmtUpdate'
])
?
date
(
$order
[
'gmtUpdate'
])
:
date
(
'Y-m-d'
,
TIMESTAMP
);
}
}
$convertStoreMember
=
array_values
(
$convertStoreMember
);
$storeStatisticDayDao
=
\DAO\Store\StoreStatisticsDayModel
::
getInstance
(
DbNameConst
::
masterDBConnectName
);
$storeStatisticDayDao
->
addAllReduce
(
$convertStoreMember
);
}
}
//任务脚本
public
function
reduceStoreMemberStatics
()
{
$refundReturnDao
=
\DAO\Order\RefundReturnModel
::
getInstance
(
DbNameConst
::
salveDBConnectName
);
$storeMemberStatisticDao
=
\DAO\StoreMemberStatisticsModel
::
getInstance
(
DbNameConst
::
masterDBConnectName
);
$gmtUpdate
=
file_get_contents
(
$this
->
baseDir
.
PathConst
::
refundRetrunGmtUpdate
);
$gmtUpdate
=
$gmtUpdate
?
$gmtUpdate
:
ApiConst
::
zero
;
$this
->
taskIndex
=
PageConst
::
taskPageBegin
;
...
...
@@ -501,6 +522,7 @@ class ShopkeeperServiceModel extends \Business\AbstractModel
}
$addDatas
=
array_values
(
$addDatas
);
$storeMemberStatisticDao
->
addAllReduce
(
$addDatas
);
$this
->
reduceRefundModel
(
$storeMemberStatisticData
);
}
while
(
$storeMemberStatisticData
);
file_put_contents
(
$this
->
baseDir
.
PathConst
::
refundRetrunGmtUpdate
,
TIMESTAMP
);
...
...
application/models/DAO/Store/StoreStatisticsDay.php
View file @
62eb144e
...
...
@@ -113,6 +113,40 @@ class StoreStatisticsDayModel extends \DAO\AbstractModel {
}
}
//插入数据大量
public
function
addAllReduce
(
$datas
)
{
$this
->
setDb
(
DbNameConst
::
masterDBConnectName
);
$error
=
0
;
$baseSql
=
"insert into
{
$this
->
_tableName
}
(store_id,order_count,order_total,gmt_create) values"
;
$extentSql
=
" ON DUPLICATE KEY UPDATE order_count=order_goods_count-values(order_goods_count),order_total=order_total-values(order_total)"
;
$insertAllSql
=
$baseSql
;
for
(
$i
=
0
;
$i
<
count
(
$datas
);
$i
++
)
{
$addSql
=
\Our\Common
::
format
(
"(
{
0},{1},{2},{3
}
),"
,
$datas
[
$i
][
'storeId'
],
$datas
[
$i
][
'orderCount'
],
$datas
[
$i
][
'orderTotal'
],
datas
[
$i
][
'gmtCreate'
]);
$insertAllSql
.=
$addSql
;
if
(
$i
%
1000
==
0
&&
$i
!=
0
)
{
$insertAllSql
=
rtrim
(
$insertAllSql
,
','
);
$insertSql
=
$insertAllSql
.
$extentSql
;
$one
=
$this
->
db
->
insert
(
$this
->
_tableName
)
->
query
(
$insertSql
);
if
(
!
$one
)
{
$error
++
;
}
$insertAllSql
=
$baseSql
;
}
}
if
(
$insertAllSql
!=
$baseSql
)
{
$insertAllSql
=
rtrim
(
$insertAllSql
,
','
);
$insertSql
=
$insertAllSql
.
$extentSql
;
$one
=
$this
->
db
->
insert
(
$this
->
_tableName
)
->
query
(
$insertSql
);
if
(
!
$one
)
{
$error
++
;
}
}
if
(
$error
>
0
)
{
$dataJson
=
json_encode
(
$datas
);
throw
new
Exception
(
'插入han_store_member_statistics失败,'
.
$dataJson
,
4
);
}
}
//插入数据大量
public
function
addAll
(
$datas
)
{
$this
->
setDb
(
DbNameConst
::
masterDBConnectName
);
...
...
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