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
b7cbd8c5
Commit
b7cbd8c5
authored
Oct 08, 2018
by
liuyuzhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优惠券过期问题
parent
e6b512d3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
26 deletions
+48
-26
CouponService.php
application/models/Business/Coupon/CouponService.php
+48
-26
No files found.
application/models/Business/Coupon/CouponService.php
View file @
b7cbd8c5
...
@@ -249,14 +249,15 @@ class CouponServiceModel extends \Business\AbstractModel{
...
@@ -249,14 +249,15 @@ class CouponServiceModel extends \Business\AbstractModel{
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
couponNoUsedTicketNum
);
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
couponNoUsedTicketNum
);
}
}
$memberCouponDao
=
\DAO\Coupon\MemberCouponModel
::
getInstance
(
$dbName
);
$memberCouponDao
=
\DAO\Coupon\MemberCouponModel
::
getInstance
(
$dbName
);
/*
if($coupon['is_overlay']){//允许领用多张的优惠券是否存在已经领取的未使用有效优惠券
if
(
$coupon
[
'is_overlay'
]){
//允许领用多张的优惠券是否存在已经领取的未使用有效优惠券
$whereSql = ' member_id ='.$memberId.' and coupon_id='.$coupon['id'].' and out_time > '.time();
$whereSql
=
'
coupon_state = '
.
\Our\ApiConst
::
couponUnused
.
'
member_id ='
.
$memberId
.
' and coupon_id='
.
$coupon
[
'id'
]
.
' and out_time > '
.
time
();
//$memberCoupons = \Our\RedisHelper::cachedFunction(\Redis\Db13\MemberCouponRedisModel::getInstance(), array(&$memberCouponDao, 'getList'),array($whereSql),\Our\ApiConst::oneHour,array($where['couponId']));
//$memberCoupons = \Our\RedisHelper::cachedFunction(\Redis\Db13\MemberCouponRedisModel::getInstance(), array(&$memberCouponDao, 'getList'),array($whereSql),\Our\ApiConst::oneHour,array($where['couponId']));
$memberCoupons
=
$memberCouponDao
->
getList
(
$whereSql
);
$memberCoupons
=
$memberCouponDao
->
getList
(
$whereSql
);
if($memberCoupons&&count($memberCoupons)>
=$coupon['get_ticket_num']
){
if
(
$memberCoupons
&&
count
(
$memberCoupons
)
>
\Our\ApiConst
::
zero
){
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
alreadyGetTheCoupon
);
\Error\ErrorModel
::
throwException
(
\Error\CodeConfigModel
::
alreadyGetTheCoupon
);
}
}
}else{//不允许领用多张的优惠券
}
/*else{//不允许领用多张的优惠券
}*/
}*/
$memberCoupons
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db13\MemberCouponRedisModel
::
getInstance
(),
array
(
&
$memberCouponDao
,
'getList'
),
array
(
array
(
'coupon_id'
=>
$where
[
'couponId'
],
'member_id'
=>
$memberId
)),
\Our\ApiConst
::
oneHour
,
array
(
$memberId
));
$memberCoupons
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db13\MemberCouponRedisModel
::
getInstance
(),
array
(
&
$memberCouponDao
,
'getList'
),
array
(
array
(
'coupon_id'
=>
$where
[
'couponId'
],
'member_id'
=>
$memberId
)),
\Our\ApiConst
::
oneHour
,
array
(
$memberId
));
...
@@ -287,10 +288,22 @@ class CouponServiceModel extends \Business\AbstractModel{
...
@@ -287,10 +288,22 @@ class CouponServiceModel extends \Business\AbstractModel{
public
function
getStoreCoupons
(
$where
,
$memberId
=
null
){
public
function
getStoreCoupons
(
$where
,
$memberId
=
null
){
$couponDao
=
\DAO\Coupon\CouponModel
::
getInstance
();
$couponDao
=
\DAO\Coupon\CouponModel
::
getInstance
();
$couponDao
->
validStoreCouponParam
(
$where
);
$couponDao
->
validStoreCouponParam
(
$where
);
$couponList
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db13\CouponRedisModel
::
getInstance
(),
array
(
&
$this
,
'getStoreCouponsById'
),
array
(
$where
[
'storeId'
],
$memberId
),
\Our\ApiConst
::
oneHour
,
array
(
$where
[
'storeId'
]
.
"_"
.
$memberId
));
$couponList
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db13\CouponRedisModel
::
getInstance
(),
array
(
&
$this
,
'getStoreCouponsById'
),
array
(
$where
[
'storeId'
],
$memberId
,
\Our\ApiConst
::
one
),
\Our\ApiConst
::
oneHour
,
array
(
$where
[
'storeId'
]
.
"_"
.
$memberId
));
if
(
$couponList
){
//var_dump($couponList);
if
(
$couponList
)
{
$couponList
=
array_values
(
$couponList
);
$couponList
=
array_values
(
$couponList
);
$couponList
=
$this
->
sortCouponList
(
$couponList
);
$tempCouponList
=
array
();
foreach
(
$couponList
as
$tempCoupon
){
if
(
$tempCoupon
[
'startTime'
]
<
TIMESTAMP
&&
$tempCoupon
[
'endTime'
]
>=
TIMESTAMP
){
unset
(
$tempCoupon
[
'startTime'
]);
unset
(
$tempCoupon
[
'endTime'
]);
$tempCouponList
[]
=
$tempCoupon
;
}
}
$couponList
=
$tempCouponList
;
if
(
$couponList
){
$couponList
=
$this
->
sortCouponList
(
$couponList
);
}
}
else
{
}
else
{
$couponList
=
array
();
$couponList
=
array
();
}
}
...
@@ -302,28 +315,37 @@ class CouponServiceModel extends \Business\AbstractModel{
...
@@ -302,28 +315,37 @@ class CouponServiceModel extends \Business\AbstractModel{
$couponDao
=
\DAO\Coupon\CouponModel
::
getInstance
();
$couponDao
=
\DAO\Coupon\CouponModel
::
getInstance
();
$couponDao
->
validStoreCouponParam
(
$where
);
$couponDao
->
validStoreCouponParam
(
$where
);
$couponList
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db13\CouponRedisModel
::
getInstance
(),
array
(
&
$this
,
'getStoreCouponsById'
),
array
(
$where
[
'storeId'
],
$memberId
,
\Our\ApiConst
::
one
),
\Our\ApiConst
::
oneHour
,
array
(
$where
[
'storeId'
]
.
"_"
.
$memberId
));
$couponList
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db13\CouponRedisModel
::
getInstance
(),
array
(
&
$this
,
'getStoreCouponsById'
),
array
(
$where
[
'storeId'
],
$memberId
,
\Our\ApiConst
::
one
),
\Our\ApiConst
::
oneHour
,
array
(
$where
[
'storeId'
]
.
"_"
.
$memberId
));
if
(
$couponList
){
if
(
!
$couponList
){
$couponList
=
array_values
(
$couponList
);
return
array
(
'couponsTitle'
=>
array
(),
'coupons'
=>
array
());
$couponList
=
$this
->
sortCouponList
(
$couponList
);
}
if
(
count
(
$couponList
)
>=
\Our\ApiConst
::
defaultCouponTitleLength
){
$couponList
=
array_values
(
$couponList
);
$couponTitleArray
=
array_slice
(
$couponList
,
0
,
\Our\ApiConst
::
defaultCouponTitleLength
);
$tempCouponList
=
array
();
}
else
{
foreach
(
$couponList
as
$tempCoupon
){
$couponTitleArray
=
$couponList
;
if
(
$tempCoupon
[
'startTime'
]
<
TIMESTAMP
&&
$tempCoupon
[
'endTime'
]
>=
TIMESTAMP
){
}
$tempCouponList
[]
=
$tempCoupon
;
$couponTitles
=
array
();
foreach
(
$couponTitleArray
as
$coupon
){
if
(
$coupon
[
'type'
]
==
\Our\ApiConst
::
noLimitCouponType
){
$couponTitles
[]
=
$coupon
[
'title'
]
.
\Our\DescribeConst
::
noLimitGoodsCouponName
;
}
else
if
(
$coupon
[
'type'
]
==
\Our\ApiConst
::
fullMinusCouponType
){
$couponTitles
[]
=
str_replace
(
\Our\DescribeConst
::
available
,
\Our\DescribeConst
::
minus
.
$coupon
[
'title'
],
$coupon
[
'subTitle'
]);
}
else
{
$couponTitles
[]
=
$coupon
[
'subTitle'
];
}
}
}
return
array
(
'couponsTitle'
=>
$couponTitles
,
'coupons'
=>
$couponList
);
}
}
else
{
$couponList
=
$tempCouponList
;
if
(
!
$couponList
){
return
array
(
'couponsTitle'
=>
array
(),
'coupons'
=>
array
());
return
array
(
'couponsTitle'
=>
array
(),
'coupons'
=>
array
());
}
}
$couponList
=
$this
->
sortCouponList
(
$couponList
);
if
(
count
(
$couponList
)
>=
\Our\ApiConst
::
defaultCouponTitleLength
){
$couponTitleArray
=
array_slice
(
$couponList
,
0
,
\Our\ApiConst
::
defaultCouponTitleLength
);
}
else
{
$couponTitleArray
=
$couponList
;
}
$couponTitles
=
array
();
foreach
(
$couponTitleArray
as
$coupon
){
if
(
$coupon
[
'type'
]
==
\Our\ApiConst
::
noLimitCouponType
){
$couponTitles
[]
=
$coupon
[
'title'
]
.
\Our\DescribeConst
::
noLimitGoodsCouponName
;
}
else
if
(
$coupon
[
'type'
]
==
\Our\ApiConst
::
fullMinusCouponType
){
$couponTitles
[]
=
str_replace
(
\Our\DescribeConst
::
available
,
\Our\DescribeConst
::
minus
.
$coupon
[
'title'
],
$coupon
[
'subTitle'
]);
}
else
{
$couponTitles
[]
=
$coupon
[
'subTitle'
];
}
}
return
array
(
'couponsTitle'
=>
$couponTitles
,
'coupons'
=>
$couponList
);
}
}
public
function
validCouponStore
(
$where
){
public
function
validCouponStore
(
$where
){
...
...
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