Commit 44c423c7 by 杨树贤

添加amount字段到红包流水

parent 851fe5ab
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment