Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
ic_server_welfare
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7a4fe1f9
authored
Oct 11, 2019
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
兑换限制
parent
4b160bdc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
app/Models/UserExchange.php
app/Tasks/IntegralBillTask.php
app/Models/UserExchange.php
View file @
7a4fe1f9
...
...
@@ -80,7 +80,8 @@ class UserExchange extends Model
$exchange
=
DB
::
table
(
'user_exchanges'
)
->
where
(
'id'
,
$id
)
->
first
();
$exchange
=
(
array
)
$exchange
;
//如果是通过的操作,则直接调用ExchangeTask,否则自己写数据库改变状态
if
(
$data
[
'status'
]
==
1
&&
$exchange
[
'amount'
]
<=
200
)
{
//要原来的兑换为0才能进行兑换操作
if
(
$data
[
'status'
]
==
1
&&
$exchange
[
'status'
]
==
0
&&
$exchange
[
'amount'
]
<=
200
)
{
$task
=
new
ExchangesTask
(
$exchange
,
$exchange
,
$data
[
'audit_id'
]);
$result
=
Task
::
deliver
(
$task
);
if
(
!
$result
)
{
...
...
app/Tasks/IntegralBillTask.php
View file @
7a4fe1f9
...
...
@@ -25,6 +25,7 @@ class IntegralBillTask extends Task
{
try
{
DB
::
transaction
(
function
()
{
//判断是否可以增加红包金额
$userId
=
$this
->
data
[
'user_id'
];
$integralId
=
$this
->
data
[
'integral_id'
];
//还要去获取此时邀请能获得的金额,因为以后邀请这类操作的金额可能会变动
...
...
@@ -62,10 +63,13 @@ class IntegralBillTask extends Task
throw
new
\Exception
(
"初始化用户红包详情失败,用户id是
$userId
"
);
}
}
//判断是否能增加红包金额,如果不能直接返回成功
if
(
$data
[
'status'
]
!=
1
)
{
return
false
;
}
//将用户的累计可兑换金额写进redis里面的ic_user里面去
$redis
=
new
RedisModel
();
$user
=
json_decode
(
$redis
->
hget
(
'ic_user'
,
$userId
),
true
);
$data
=
(
array
)
$userIntegral
->
getUserIntegral
(
$userId
);
$user
[
'integral'
]
=
number_format
(
$data
[
'integral'
]
+
$amount
,
2
);
$result
=
$redis
->
hset
(
'ic_user'
,
$userId
,
json_encode
(
$user
));
//还要写进user_integrals数据库
...
...
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