Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
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
hujun
tl_estate
Commits
29fe079f
Commit
29fe079f
authored
Mar 12, 2019
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
key
parent
a509916e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
21 deletions
+19
-21
CouponService.php
application/api/service/CouponService.php
+15
-18
CouponNoEncodingUntils.php
application/api/untils/CouponNoEncodingUntils.php
+3
-2
CCoupon.php
application/model/CCoupon.php
+1
-1
No files found.
application/api/service/CouponService.php
View file @
29fe079f
<?php
namespace
app\api\service
;
use
app\api\untils\CouponNoEncodingUntils
;
use
app\extra\RedisExt
;
use
app\model\CActivity
;
use
app\model\CCoupon
;
...
...
@@ -79,12 +80,14 @@ class CouponService{
$save_data
[
'status'
]
=
0
;
$save_data
[
'create_time'
]
=
date
(
'Y-m-d H:i:s'
);
$this
->
m_coupon
->
startTrans
();
$coupon_untils
=
new
CouponNoEncodingUntils
();
foreach
(
$activity_data
as
$k
=>
$v
)
{
$save_data
[
'activity_id'
]
=
$v
[
'id'
];
$save_data
[
'rule_no'
]
=
mt_rand
(
100
,
100000
);
$insert_status
=
$this
->
m_coupon
->
insertData
(
$save_data
);
if
(
$insert_status
)
{
$this
->
m_activity
->
plusGetNumber
(
$v
[
'id'
]);
//增加用户领取数量
$insert_id
=
$this
->
m_coupon
->
insertData
(
$save_data
);
if
(
$insert_id
)
{
$rule_no
=
$coupon_untils
->
encryptionCouponNo
(
$insert_id
);
$this
->
m_coupon
->
updateData
([
'rule_no'
=>
$rule_no
],
[
'id'
=>
$insert_id
]);
$this
->
m_activity
->
plusGetNumber
(
$v
[
'id'
]);
//增加用户领取数量
}
}
$this
->
redis_
->
del
(
$key
);
...
...
@@ -100,29 +103,23 @@ class CouponService{
/**
* 查询奖励动作
*
* @param
int
$return_action @奖励动作 0首次登陆 1邀请登陆 2邀请成交
* @param $return_action @奖励动作 0首次登陆 1邀请登陆 2邀请成交
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
selectActivity
(
int
$return_action
)
{
public
function
selectActivity
(
$return_action
)
{
$field
=
'id,return_type,money,activity_start_time,activity_end_time,use_period,total,available,total'
;
$field
.=
',available,get_number'
;
$where
[
'total'
]
=
[
'>'
,
0
];
//奖励动作 0首次登陆 1邀请登陆 2邀请成交
switch
(
$return_action
)
{
case
1
:
$return_action
=
1
;
break
;
case
2
:
$return_action
=
2
;
break
;
default
:
$return_action
=
0
;
if
(
is_array
(
$return_action
))
{
$where
[
'return_action'
]
=
[
'in'
,
$return_action
];
}
else
{
$where
[
'return_action'
]
=
$return_action
;
}
$where
[
'total'
]
=
[
'>'
,
0
];
$where
[
'return_action'
]
=
$return_action
;
$where
[
'status'
]
=
0
;
//0正常 1手动停止 2数量为空 3时间过期 4删除 5未开始
$where
[
'activity_start_time'
]
=
[
'<>'
,
'0000-00-00 00:00:00'
];
$where
[
'activity_end_time'
]
=
[
'<>'
,
'0000-00-00 00:00:00'
];
...
...
application/api/untils/CouponNoEncodingUntils.php
View file @
29fe079f
...
...
@@ -15,12 +15,12 @@ class CouponNoEncodingUntils{
}
public
function
encryptionCouponNo
(
$couponNo
){
$couponNo
=
$this
->
reverse
(
$couponNo
.
"1"
);
$couponNo
=
$this
->
reverse
(
$couponNo
);
return
$couponNo
^
self
::
OR_NOT_VALUE
;
}
public
function
decryptionCouponNo
(
$couponNo
){
$couponNo
=
$couponNo
^
self
::
OR_NOT_VALUE
;
return
substr
(
$couponNo
,
-
1
);
return
$this
->
reverse
(
$couponNo
);
}
}
\ No newline at end of file
application/model/CCoupon.php
View file @
29fe079f
...
...
@@ -94,7 +94,7 @@ class CCoupon extends BaseModel
if
(
is_array
(
$data
[
0
]))
{
$result
=
$this
->
db_
->
insertAll
(
$data
);
}
else
{
$result
=
$this
->
db_
->
insert
(
$data
);
$result
=
$this
->
db_
->
insert
GetId
(
$data
);
}
return
$result
;
}
...
...
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