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
894646fe
Commit
894646fe
authored
Jan 24, 2019
by
liuyuzhengrace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
计算免费月份数据
parent
f73df66e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
175 additions
and
129 deletions
+175
-129
StoreUtil.php
application/library/Store/StoreUtil.php
+101
-93
StoreClassChargeLog.php
application/models/DAO/GoodsClass/StoreClassChargeLog.php
+26
-24
QmStoreClass.php
application/models/DAO/QmStoreClass.php
+14
-12
StoreClassPayLog.php
application/models/DAO/Store/StoreClassPayLog.php
+34
-0
No files found.
application/library/Store/StoreUtil.php
View file @
894646fe
This diff is collapsed.
Click to expand it.
application/models/DAO/GoodsClass/StoreClassChargeLog.php
View file @
894646fe
...
...
@@ -29,33 +29,35 @@ class StoreClassChargeLogModel extends \DAO\AbstractModel{
return
$this
->
db
->
select
(
$field
)
->
from
(
$this
->
_tableName
)
->
where
(
$where
)
->
fetchAll
();
}
/**
* 计算分类对应
* @param $class
* @param $storeEndTime
* @param int $month
* @return array|bool
*/
public
function
getFreeChargeMoney
(
$class
,
$storeEndTime
,
$month
=
1
){
if
(
$month
<=
0
){
return
false
;
}
$currentTime
=
mktime
(
23
,
59
,
59
,
date
(
'm'
),
date
(
'd'
),
date
(
'Y'
));
$tempOldTime
=
max
(
array
(
$storeEndTime
,
$class
[
'deadline'
]));
$oldTime
=
mktime
(
23
,
59
,
59
,
date
(
'm'
,
$tempOldTime
),
date
(
'd'
,
$tempOldTime
),
date
(
'Y'
,
$tempOldTime
));
$currExpTime
=
$oldTime
;
if
(
$currentTime
>
$oldTime
){
$currExpTime
=
$currentTime
;
public
function
insertBatch
(
$datas
){
$this
->
setDb
(
\Our\DbNameConst
::
masterDBConnectName
);
$error
=
0
;
$baseSql
=
"insert IGNORE into
{
$this
->
_tableName
}
(gc_id,store_id,old_end_time,new_start_time,new_end_time,service_fee,gmt_create,gmt_update,pay_sn,curr_month_fee,pre_month_fee,service_fee_sign) values"
;
$insertAllSql
=
$baseSql
;
for
(
$i
=
0
;
$i
<
count
(
$datas
);
$i
++
)
{
$addSql
=
\Our\Common
::
format
(
"('
{
0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11
}
'),"
,
$datas
[
$i
][
'gc_id'
],
$datas
[
$i
][
'store_id'
],
$datas
[
$i
][
'old_end_time'
],
$datas
[
$i
][
'new_start_time'
],
$datas
[
$i
][
'new_end_time'
],
$datas
[
$i
][
'service_fee'
],
$datas
[
$i
][
'gmt_create'
],
$datas
[
$i
][
'gmt_update'
],
$datas
[
$i
][
'pay_sn'
],
$datas
[
$i
][
'curr_month_fee'
],
$datas
[
$i
][
'pre_month_fee'
],
$datas
[
$i
][
'service_fee_sign'
]);
$insertAllSql
.=
$addSql
;
if
(
$i
%
1000
==
0
&&
$i
!=
0
)
{
$insertAllSql
=
rtrim
(
$insertAllSql
,
','
);
$one
=
$this
->
db
->
insert
(
$this
->
_tableName
)
->
query
(
$insertAllSql
);
if
(
!
$one
)
{
$error
++
;
}
$insertAllSql
=
$baseSql
;
}
}
$currentMonthEnd
=
mktime
(
0
,
0
,
0
,(
date
(
'm'
,
$currExpTime
)
+
1
),
1
,
date
(
'Y'
,
$currExpTime
))
-
1
;
$endTime
=
mktime
(
0
,
0
,
0
,(
date
(
'm'
,
$currExpTime
)
+
1
+
$month
),
1
,
date
(
'Y'
,
$currExpTime
))
-
1
;
if
(
$currentMonthEnd
>
$currExpTime
){
$endTime
=
$currentMonthEnd
;
if
(
$month
>
1
)
{
$e
ndTime
=
mktime
(
0
,
0
,
0
,(
date
(
'm'
,
$currExpTime
)
+
$month
),
1
,
date
(
'Y'
,
$currExpTime
))
-
1
;
if
(
$insertAllSql
!=
$baseSql
)
{
$insertAllSql
=
rtrim
(
$insertAllSql
,
','
)
;
$one
=
$this
->
db
->
insert
(
$this
->
_tableName
)
->
query
(
$insertAllSql
);
if
(
!
$one
)
{
$e
rror
++
;
}
}
return
array
(
'service_fee'
=>
0
,
'old_end_time'
=>
$tempOldTime
,
'new_start_time'
=>
$currExpTime
+
1
,
'new_end_time'
=>
$endTime
,
'curr_month_fee'
=>
0
,
'pre_month_fee'
=>
0
);
if
(
$error
>
0
)
{
return
false
;
}
return
true
;
}
/**
...
...
application/models/DAO/QmStoreClass.php
View file @
894646fe
...
...
@@ -29,7 +29,7 @@ class QmStoreClassModel extends \DAO\AbstractModel{
public
function
selectByWhere
(
$where
=
null
,
$field
=
'*'
,
$limit
=
false
){
$this
->
setDb
();
$this
->
setDb
(
$this
->
dbName
);
if
(
is_array
(
$where
)){
$where
=
$this
->
db
->
getSqlWhereByArray
(
$where
);
}
...
...
@@ -41,6 +41,7 @@ class QmStoreClassModel extends \DAO\AbstractModel{
return
$result
;
}
public
function
delSignScopeCache
(
$storeId
){
$result
=
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db6\QmStoreClassRedisModel
::
getInstance
(),
array
(
&
$this
,
'selectByWhere'
),
array
(),
array
(
$storeId
));
return
$result
;
...
...
@@ -80,6 +81,14 @@ class QmStoreClassModel extends \DAO\AbstractModel{
return
$list
;
}
public
function
update
(
$data
,
$where
){
$this
->
setDb
(
\Our\DbNameConst
::
masterDBConnectName
);
$result
=
$this
->
db
->
update
(
$this
->
_tableName
)
->
rows
(
$data
)
->
where
(
$where
)
->
execute
();
return
$result
;
}
/**
* 类实例
*/
...
...
@@ -88,21 +97,21 @@ class QmStoreClassModel extends \DAO\AbstractModel{
/**
* 获取类实例
*/
public
static
function
getInstance
()
{
public
static
function
getInstance
(
$dbName
=
\Our\DbNameConst
::
salveDBConnectName
)
{
if
(
!
(
self
::
$_instance
instanceof
self
))
{
self
::
$_instance
=
new
self
();
self
::
$_instance
=
new
self
(
$dbName
);
}
return
self
::
$_instance
;
}
public
function
getStoreClasses
(
$where
,
$field
=
'*'
){
$this
->
setDb
();
$this
->
setDb
(
$this
->
dbName
);
$result
=
$this
->
db
->
select
(
$field
)
->
from
(
$this
->
_tableName
)
->
where
(
$where
)
->
fetchAll
();
return
$result
;
}
public
function
getStoreSignClasses
(
$where
,
$field
=
"*"
){
$this
->
setDb
();
$this
->
setDb
(
$this
->
dbName
);
if
(
is_array
(
$where
)){
$where
=
$this
->
db
->
getSqlWhereByArray
(
$where
);
}
...
...
@@ -137,11 +146,4 @@ class QmStoreClassModel extends \DAO\AbstractModel{
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db6\QmStoreClassRedisModel
::
getInstance
(),
array
(
&
$this
,
'getStoreClasses'
),
array
(),
array
(
$cityCode
));
}
public
function
update
(
$data
,
$where
){
$this
->
setDb
(
\Our\DbNameConst
::
masterDBConnectName
);
$result
=
$this
->
db
->
update
(
$this
->
_tableName
)
->
rows
(
$data
)
->
where
(
$where
)
->
execute
();
return
$result
;
}
}
\ No newline at end of file
application/models/DAO/Store/StoreClassPayLog.php
View file @
894646fe
...
...
@@ -31,6 +31,40 @@ class StoreClassPayLogModel extends \DAO\AbstractModel
$this
->
setDb
(
$this
->
dbName
);
return
$this
->
db
->
select
(
$field
)
->
from
(
$this
->
_tableName
)
->
where
(
$where
)
->
fetchOne
();
}
public
function
insertBatch
(
$datas
){
$this
->
setDb
(
\Our\DbNameConst
::
masterDBConnectName
);
$error
=
0
;
$baseSql
=
"insert IGNORE into
{
$this
->
_tableName
}
(store_id,pay_state,pay_sn,pay_content,gmt_create,pay_time,pay_amount,pay_type,gmt_update) values"
;
$insertAllSql
=
$baseSql
;
for
(
$i
=
0
;
$i
<
count
(
$datas
);
$i
++
)
{
$addSql
=
\Our\Common
::
format
(
"('
{
0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8
}
'),"
,
$datas
[
$i
][
'store_id'
],
$datas
[
$i
][
'pay_state'
],
$datas
[
$i
][
'pay_sn'
],
$datas
[
$i
][
'pay_content'
],
$datas
[
$i
][
'gmt_create'
],
$datas
[
$i
][
'pay_time'
],
$datas
[
$i
][
'pay_amount'
],
$datas
[
$i
][
'pay_type'
],
$datas
[
$i
][
'gmt_update'
]);
$insertAllSql
.=
$addSql
;
if
(
$i
%
1000
==
0
&&
$i
!=
0
)
{
$insertAllSql
=
rtrim
(
$insertAllSql
,
','
);
$one
=
$this
->
db
->
insert
(
$this
->
_tableName
)
->
query
(
$insertAllSql
);
if
(
!
$one
)
{
$error
++
;
}
$insertAllSql
=
$baseSql
;
}
}
if
(
$insertAllSql
!=
$baseSql
)
{
$insertAllSql
=
rtrim
(
$insertAllSql
,
','
);
$one
=
$this
->
db
->
insert
(
$this
->
_tableName
)
->
query
(
$insertAllSql
);
if
(
!
$one
)
{
$error
++
;
}
}
if
(
$error
>
0
)
{
return
false
;
}
return
true
;
}
/**
* 类实例
*
...
...
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