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, 'new_state')) { $query->where('new_state', $param['new_state']); } 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, ]); } 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, ]); } 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, ]); } 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, ]); } 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, ]); } 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, ]); } 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, ]); } 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, ]); } 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 == 9 || $has->type == 8 || $has->type == 7 || $has->type == 11 || $has->type == 12 || $has->type == 15 || $has->type == 16) { 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; $has->is_true = 1; } elseif ($has->type == 6) { $usercark = Db::table('wa_user_social_cark')->where('user_id', $has->user_id)->first(); if (empty($usercark)) { throw new \Exception('数据不存在!'); } if ($usercark->status != 3) { throw new \Exception('卡未完成,不能充值!'); } if ($usercark->status == 4) { throw new \Exception('已充值,请更新查看!'); } if ($usercark) { $order_no = date('YmdHis') . mt_rand(1000, 9999); $result = [ 'cardToken' => $usercark->taskId, 'amount' => $has->money, 'cardno' => $usercark->card_num, 'shopno' => '20001032', 'key' => 'A7F232D8364468ED10BC872B4E7EF4D3', 'action' => 'rech_card', 'user_number' => $usercark->id, ]; $info = openssl_encrypt(json_encode($result), 'AES-256-ECB', 'A7F232D8364468ED10BC872B4E7EF4D3', OPENSSL_RAW_DATA); $infodata = base64_encode($info); $arr = [ 'shopno' => '20001032', 'wholeRequestId' => $order_no, 'data' => $infodata, ]; $url = 'https://www.supplicardes.online/api/virtual_card'; $data = Http::post($url, $arr)->array(); Log::channel('kaicard')->info('提现-充值请求', $arr); Log::channel('kaicard')->info('提现-充值返回', $data); if ($data['code'] == 1000) { Db::table('wa_user_social_cark')->where('id', $usercark->id)->update(['status' => 4]); $topup = [ 'login_admin_id' => admin_id(), 'user_id' => $usercark->user_id, 'user_social_cark_id' => $usercark->id, 'money' => $has->money, 'ip' => $request->getRealIp($safe_mode = true), 'updated_at' => date('Y-m-d H:i:s', time()), 'created_at' => date('Y-m-d H:i:s', time()), ]; Db::table('wa_user_topup_log')->insert($topup); } else { throw new \Exception('充值失败:' . $data['msg']); } } else { throw new \Exception('数据错误,不存在卡!'); } $has->status = 3; } 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 xintong(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->new_state != 1) { throw new \Exception('编码为:【' . $v . '】已处理,或者未支付!'); } if ($has && $has->new_state == 1) { $has->new_state = 2; } $has->updated_at = date('Y-m-d H:i:s'); $has->save(); 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->remarks = Arr::get($param, 'remarks', ''); $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(); } }