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
7caddd79
Commit
7caddd79
authored
Aug 27, 2018
by
liuyuzhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优惠券缓存和店铺分类缓存
parent
020874c9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
4 deletions
+23
-4
CouponService.php
application/models/Business/Coupon/CouponService.php
+22
-4
Coupon.php
application/models/DAO/Coupon/Coupon.php
+1
-0
No files found.
application/models/Business/Coupon/CouponService.php
View file @
7caddd79
...
@@ -118,7 +118,7 @@ class CouponServiceModel extends \Business\AbstractModel{
...
@@ -118,7 +118,7 @@ class CouponServiceModel extends \Business\AbstractModel{
$whereSql
=
' coupon_state ='
.
\Our\ApiConst
::
couponUnused
.
' and member_id ='
.
$memberId
.
' and out_time > '
.
time
();
$whereSql
=
' coupon_state ='
.
\Our\ApiConst
::
couponUnused
.
' and member_id ='
.
$memberId
.
' and out_time > '
.
time
();
$memberCoupons
=
$memberCouponDao
->
getList
(
$whereSql
);
$memberCoupons
=
$memberCouponDao
->
getList
(
$whereSql
);
}
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
);
$memberCoupons
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db13\MemberCouponRedisModel
::
getInstance
(),
array
(
&
$memberCouponDao
,
'getList'
),
array
(
array
(
'coupon_id'
=>
$where
[
'couponId'
],
'member_id'
=>
$memberId
)),
\Our\ApiConst
::
oneHour
,
array
(
$where
[
'couponId'
])
);
}
}
if
(
$memberCoupons
&&
count
(
$memberCoupons
)
>
0
){
if
(
$memberCoupons
&&
count
(
$memberCoupons
)
>
0
){
$result
[
'isGet'
]
=
\Our\ApiConst
::
one
;
$result
[
'isGet'
]
=
\Our\ApiConst
::
one
;
...
@@ -167,6 +167,8 @@ class CouponServiceModel extends \Business\AbstractModel{
...
@@ -167,6 +167,8 @@ class CouponServiceModel extends \Business\AbstractModel{
return
true
;
return
true
;
}
}
public
function
receiveCouponBatch
(
$coupons
,
$memberId
,
$orderId
=
\Our\ApiConst
::
zero
){
public
function
receiveCouponBatch
(
$coupons
,
$memberId
,
$orderId
=
\Our\ApiConst
::
zero
){
$dbName
=
\Our\DbNameConst
::
masterDBConnectName
;
$dbName
=
\Our\DbNameConst
::
masterDBConnectName
;
$couponDao
=
\DAO\Coupon\CouponModel
::
getInstance
(
$dbName
);
$couponDao
=
\DAO\Coupon\CouponModel
::
getInstance
(
$dbName
);
...
@@ -256,7 +258,7 @@ class CouponServiceModel extends \Business\AbstractModel{
...
@@ -256,7 +258,7 @@ class CouponServiceModel extends \Business\AbstractModel{
public
function
getStorePromotionCouponTitles
(
$where
){
public
function
getStorePromotionCouponTitles
(
$where
){
$this
->
validCouponStore
(
$where
);
$this
->
validCouponStore
(
$where
);
$couponDao
=
\DAO\Coupon\CouponModel
::
getInstance
();
$couponDao
=
\DAO\Coupon\CouponModel
::
getInstance
();
$couponTitles
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db13\CouponRedisModel
::
getInstance
(),
array
(
&
$couponDao
,
'getStorePromotionCouponList'
),
array
(
$where
[
'storeId'
]),
\Our\ApiConst
::
oneHour
);
$couponTitles
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db13\CouponRedisModel
::
getInstance
(),
array
(
&
$couponDao
,
'getStorePromotionCouponList'
),
array
(
$where
[
'storeId'
]),
\Our\ApiConst
::
oneHour
,
array
(
$where
[
'storeId'
])
);
return
$couponTitles
;
return
$couponTitles
;
}
}
...
@@ -266,7 +268,7 @@ class CouponServiceModel extends \Business\AbstractModel{
...
@@ -266,7 +268,7 @@ 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
);
$couponList
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db13\CouponRedisModel
::
getInstance
(),
array
(
&
$this
,
'getStoreCouponsById'
),
array
(
$where
[
'storeId'
],
$memberId
),
\Our\ApiConst
::
oneHour
,
array
(
$where
[
'storeId'
])
);
if
(
$couponList
){
if
(
$couponList
){
$couponList
=
array_values
(
$couponList
);
$couponList
=
array_values
(
$couponList
);
}
}
...
@@ -277,7 +279,7 @@ class CouponServiceModel extends \Business\AbstractModel{
...
@@ -277,7 +279,7 @@ class CouponServiceModel extends \Business\AbstractModel{
$this
->
validCouponStore
(
$where
);
$this
->
validCouponStore
(
$where
);
$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
,
true
),
\Our\ApiConst
::
oneHour
);
$couponList
=
\Our\RedisHelper
::
cachedFunction
(
\Redis\Db13\CouponRedisModel
::
getInstance
(),
array
(
&
$this
,
'getStoreCouponsById'
),
array
(
$where
[
'storeId'
],
$memberId
,
true
),
\Our\ApiConst
::
oneHour
,
array
(
$where
[
'storeId'
])
);
if
(
$couponList
){
if
(
$couponList
){
$couponList
=
array_values
(
$couponList
);
$couponList
=
array_values
(
$couponList
);
if
(
count
(
$couponList
)
>=
\Our\ApiConst
::
defaultCouponTitleLength
){
if
(
count
(
$couponList
)
>=
\Our\ApiConst
::
defaultCouponTitleLength
){
...
@@ -356,6 +358,22 @@ class CouponServiceModel extends \Business\AbstractModel{
...
@@ -356,6 +358,22 @@ class CouponServiceModel extends \Business\AbstractModel{
return
$couponList
;
return
$couponList
;
}
}
/**
* 删除店铺优惠券缓存
* @param $storeId 店铺ID
* @param bool $couponId 指定优惠券ID
* @throws \Our\Exception
*/
public
function
deleteCouponCache
(
$storeId
,
$couponId
=
false
){
$couponDao
=
\DAO\Coupon\CouponModel
::
getInstance
();
$memberCouponDao
=
\DAO\Coupon\MemberCouponModel
::
getInstance
();
if
(
$couponId
){
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db13\MemberCouponRedisModel
::
getInstance
(),
array
(
&
$memberCouponDao
,
'getList'
),
array
(),
array
(
$couponId
));
}
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db13\CouponRedisModel
::
getInstance
(),
array
(
&
$couponDao
,
'getStorePromotionCouponList'
),
array
(),
array
(
$storeId
));
\Our\RedisHelper
::
delCachedFunction
(
\Redis\Db13\CouponRedisModel
::
getInstance
(),
array
(
&
$this
,
'getStoreCouponsById'
),
array
(),
array
(
$storeId
));
}
/**
/**
* 类实例
* 类实例
*/
*/
...
...
application/models/DAO/Coupon/Coupon.php
View file @
7caddd79
...
@@ -394,6 +394,7 @@ class CouponModel extends \DAO\AbstractModel {
...
@@ -394,6 +394,7 @@ class CouponModel extends \DAO\AbstractModel {
return
false
;
return
false
;
}
}
/**
/**
* 满额赠礼品券
* 满额赠礼品券
* @param $coupon
* @param $coupon
...
...
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