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
44c423c7
authored
Sep 03, 2019
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
添加amount字段到红包流水
parent
851fe5ab
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
app/Models/Invite.php
app/Tasks/IntegralBillTask.php
app/Models/Invite.php
View file @
44c423c7
...
...
@@ -41,6 +41,11 @@ class Invite extends Model
public
function
addInvite
(
$data
)
{
$result
=
DB
::
transaction
(
function
()
use
(
$data
)
{
//还要去获取此时邀请能获得的金额,因为以后邀请这类操作的金额可能会变动
$amount
=
DB
::
table
(
'integrals'
)
->
where
(
'id'
,
Integral
::
INTEGRAL_TYPE_INVITE_FRIEND
)
->
value
(
'amount'
);
$data
[
'amount'
]
=
$amount
;
$result
=
DB
::
table
(
'invites'
)
->
insert
(
$data
);
if
(
!
$result
)
{
return
false
;
...
...
app/Tasks/IntegralBillTask.php
View file @
44c423c7
...
...
@@ -27,10 +27,18 @@ class IntegralBillTask extends Task
DB
::
transaction
(
function
()
{
$userId
=
$this
->
data
[
'user_id'
];
$integralId
=
$this
->
data
[
'integral_id'
];
//还要去获取此时邀请能获得的金额,因为以后邀请这类操作的金额可能会变动
$integral
=
new
Integral
();
$res
=
$integral
->
getIntegral
(
$integralId
);
if
(
!
$res
)
{
throw
new
\Exception
(
"获取红包信息失败,红包id是
$integralId
"
);
}
$amount
=
$res
->
amount
;
//数据库里面插入数据
$data
=
[
'user_id'
=>
$userId
,
'integral_id'
=>
$integralId
,
'amount'
=>
$amount
,
'status'
=>
1
,
'add_time'
=>
$this
->
data
[
'add_time'
],
];
...
...
@@ -55,13 +63,6 @@ class IntegralBillTask extends Task
}
}
//将用户的累计可兑换金额写进redis里面的ic_user里面去
$integral
=
new
Integral
();
$res
=
$integral
->
getIntegral
(
$integralId
);
if
(
!
$res
)
{
throw
new
\Exception
(
"获取红包信息失败,红包id是
$integralId
"
);
}
$amount
=
$res
->
amount
;
$redis
=
new
RedisModel
();
$user
=
json_decode
(
$redis
->
hget
(
'ic_user'
,
$userId
),
true
);
$data
=
(
array
)
$userIntegral
->
getUserIntegral
(
$userId
);
...
...
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