Commit 75315a6a by 杨树贤

修改增加保单只返回成功或者失败,不返回超过限制的提示

parent d420842b
......@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use App\Http\Filters\IntegralBillFilter;
use App\Http\Filters\IntegralFilter;
use App\Models\Integral;
use App\Models\IntegralBill;
use Illuminate\Http\Request;
......@@ -36,23 +37,31 @@ class IntegralBillsController extends Controller
* 创建红包获取记录
* @param Request $request
* @param IntegralBill $integralBill
* @param Integral $integral
* @return array
*/
public function store(Request $request, IntegralBill $integralBill)
public function store(Request $request, IntegralBill $integralBill, Integral $integral)
{
$data = [
'user_id' => $request->user_id,
'integral_id' => $request->integral_id,
'status' => 1,
'user_id' => $request->get('user_id'),
'integral_id' => $request->get('integral_id'),
'add_time' => time(),
];
$res = $integralBill->createIntegralBill($data);
if ($res) {
return $this->Export(0, 'ok');
} else {
return $this->Export(ErrorCode(6, 5), '新增红包获取记录失败');
//先去检测这个操作是否已经达到每个用户每日的限额
$canAdd = $integral->checkIntegralLimit($data['user_id'], $data['integral_id']);
if ($canAdd) {
$res = $integralBill->createIntegralBill($data);
if ($res) {
return $this->Export(0, 'ok');
} else {
return $this->Export(ErrorCode(6, 5), '新增红包获取记录失败');
}
}
// else {
// return $this->Export(ErrorCode(1, 1), '该操作超过限定次数');
// }
return $this->Export(0, 'ok');
}
/**
......
......@@ -11,6 +11,7 @@ use Hhxsv5\LaravelS\Swoole\Task\Task;
use http\Env\Request;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class IntegralBill extends Model
{
......@@ -44,20 +45,23 @@ class IntegralBill extends Model
return ['data' => $bills, 'count' => $count];
}
//这是一个比较重要的方法,这个方法关系着需不需要插入红包获取流水
public function createIntegralBill($data = [])
{
$res = DB::table('integral_bills')->insert($data);
return $res;
// public function addIntegralBill($userId,$integralId)
// {
// $task = new IntegralBillTask($data);
// $result = Task::deliver($task);
// if (!$result) {
// return false;
// }
// }
$integralId = $data['integral_id'];
switch ($integralId) {
case Integral::INTEGRAL_TYPE_UPLOAD_GOODS:
case Integral::INTEGRAL_TYPE_INTEGRAL_CODE:
case Integral::INTEGRAL_TYPE_SHARE:
case Integral::INTEGRAL_TYPE_OFFER:
case Integral::INTEGRAL_TYPE_CHECK_IN:
case Integral::INTEGRAL_TYPE_INVITE_FRIEND:
$task = new IntegralBillTask($data);
$result = Task::deliver($task);
return $result ? true : false;
break;
}
}
//更新用户红包兑换列表
......
4820
\ No newline at end of file
3271
\ No newline at end of file
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