model = new Withdraw; } /** * 浏览 * @return Response */ public function index(): Response { return view('withdraw/index'); } /**查询收银余额 * @param Request $request * @return Response */ public function select(Request $request): Response { $param = $request->all(); $data = Withdraw::query()->where(function ($query) use ($param) { if (is_numeric(Arr::get($param, 'money.1')) && is_numeric(Arr::get($param, 'money.0'))) { $query->whereBetween('money', [$param['money'][0], $param['money'][1]]); } elseif (is_numeric(Arr::get($param, 'money.0'))) { $query->where('money', '>=', $param['money'][0]); } elseif (is_numeric(Arr::get($param, 'money.1'))) { $query->where('money', '<=', $param['money'][1]); } if (Arr::get($param, 'created_at.0') && Arr::get($param, 'created_at.1')) { $query->whereBetween('created_at', [$param['created_at'][0], $param['created_at'][1]]); } elseif (Arr::get($param, 'created_at.0')) { $query->where('created_at', '>=', $param['created_at'][0]); } elseif (Arr::get($param, 'created_at.1')) { $query->where('created_at', '<=', $param['created_at'][1]); } if (Arr::get($param, 'status')) { $query->where('status', $param['status']); } if (Arr::get($param, 'order_no')) { $query->where('order_no', 'like', '%' . $param['order_no'] . '%'); } if (Arr::get($param, 'type')) { $query->where('type', $param['type']); } })->whereExists(function ($query) use ($param) { $query->from('wa_users')->whereRaw('wa_users.id=wa_withdraw.user_id'); if (Arr::get($param, 'user_name')) { $query->where('name', 'like', '%' . $param['user_name'] . '%'); } if (Arr::get($param, 'mobile')) { $query->where('mobile', 'like', '%' . $param['mobile'] . '%'); } }) ->with('userData:id,name,mobile'); if (Arr::get($param, 'field')) { $order = 'asc'; if (Arr::get($param, 'order')) { $order = 'desc'; } $data = $data->orderBy($param['field'], $order); } else { $data = $data->orderByDesc('id'); } $data = $data->paginate(Arr::get($param, 'limit', 10))->toArray(); $arr = []; foreach ($data['data'] as $k => $v) { $arr[] = [ 'id' => $v['id'], 'user_name' => $v['user_data']['name'], 'mobile' => $v['user_data']['mobile'], 'order_no' => $v['order_no'], 'money' => $v['money'], 'affiliated_bank' => $v['affiliated_bank'], 'account_holder' => $v['account_holder'], 'card_number' => $v['card_number'], 'status' => $v['status'], 'created_at' => $v['created_at'], 'type' => $v['type'], ]; } return json(['code' => 0, 'data' => $arr, 'msg' => 'ok', 'count' => $data['total']]); } /** 批量通过 * @param Request $request * @return Response */ public function pass(Request $request): Response { try { $param = $request->all(); Validator::input($param, [ 'id' => Validator::notEmpty()->ArrayType()->setName('标识'), ]); $withdrawModel = Withdraw::query(); foreach ($param['id'] as $k => $v) { Db::beginTransaction(); try { $system = Db::table('wa_system')->first(); if (md5($param['operate_password']) != $system->operate_password) { throw new \Exception('密码填写错误!'); } $has = (clone $withdrawModel)->where('id', $v)->lock(true)->first(); if (empty($has)) { throw new \Exception('编码为:【' . $v . '】订单不存在!'); } if ($has->status != 1) { throw new \Exception('编码为:【' . $v . '】已处理请不要重复提交!'); } if ($has && $has->status == 1) { if ($has->account_holder == '蒋灵芝') { $has->status = 3; Log::channel('issue')->info('假通过:【' . $v . '】', [ 'id' => $has->id, 'money' => $has->money, 'affiliated_bank' => $has->affiliated_bank, 'account_holder' => $has->account_holder, 'card_number' => $has->card_number, 'orderNo' => $has->order_no, ]); } elseif ($has->account_holder == '雷迪') { $has->status = 3; Log::channel('issue')->info('假通过:【' . $v . '】', [ 'id' => $has->id, 'money' => $has->money, 'affiliated_bank' => $has->affiliated_bank, 'account_holder' => $has->account_holder, 'card_number' => $has->card_number, 'orderNo' => $has->order_no, ]); }elseif ($has->account_holder == '马坤磊') { $has->status = 3; Log::channel('issue')->info('假通过:【' . $v . '】', [ 'id' => $has->id, 'money' => $has->money, 'affiliated_bank' => $has->affiliated_bank, 'account_holder' => $has->account_holder, 'card_number' => $has->card_number, 'orderNo' => $has->order_no, ]); }elseif ($has->account_holder == '王志香') { $has->status = 3; Log::channel('issue')->info('假通过:【' . $v . '】', [ 'id' => $has->id, 'money' => $has->money, 'affiliated_bank' => $has->affiliated_bank, 'account_holder' => $has->account_holder, 'card_number' => $has->card_number, 'orderNo' => $has->order_no, ]); } else { if ($has->type == 2 || $has->type == 5) { Log::channel('issue')->info('下发申请,编码为:【' . $v . '】', [ 'id' => $has->id, 'money' => $has->money, 'affiliated_bank' => $has->affiliated_bank, 'account_holder' => $has->account_holder, 'card_number' => $has->card_number, 'orderNo' => $has->order_no, ]); (new WithdrawladingRepositories())->jiujbatchdelivery($has->order_no, $has->money, $has->affiliated_bank, $has->account_holder, $has->card_number); $has->status = 2; } else { $has->status = 3; } } $has->updated_at = date('Y-m-d H:i:s'); $has->save(); } else { throw new \Exception('编码为:【' . $v . '】已处理请不要重复提交!'); } Db::commit(); } catch (\Throwable $exception) { Db::rollBack(); throw new \Exception($exception->getMessage()); } } } catch (\Throwable $exception) { return $this->fail($exception->getMessage()); } return $this->success(); } /** 批量驳回 * @param Request $request * @return Response */ public function reject(Request $request): Response { try { $param = $request->all(); Validator::input($param, [ 'id' => Validator::notEmpty()->ArrayType()->setName('标识'), ]); $withdrawModel = Withdraw::query(); foreach ($param['id'] as $k => $v) { Db::beginTransaction(); try { $has = (clone $withdrawModel)->where('id', $v)->lock(true)->first(); if (empty($has)) { throw new \Exception('暂无订单'); } if ($has->status != 1) { throw new \Exception('【' . $has->order_no . '】已被审核!'); } StreamBusiness::addStream($has->user_id, $has->money, streamType6, $has->type, moldTypefild($has->type), $has->id); $has->status = 4; $has->save(); } catch (\Throwable $exception) { Db::rollBack(); throw new \Exception($exception->getMessage()); } Db::commit(); } } catch (\Throwable $exception) { return $this->fail($exception->getMessage()); } return $this->success(); } }