Commit 7a4fe1f9 by 杨树贤

兑换限制

parent 4b160bdc
......@@ -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) {
......
......@@ -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数据库
......
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