| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- <?php
- namespace plugin\admin\app\controller;
- use app\api\repositories\MoneyLogRepositories;
- use app\business\StreamBusiness;
- use Illuminate\Support\Arr;
- use plugin\admin\app\repositories\WithdrawladingRepositories;
- use plugin\admin\app\repositories\WithdrawRepositories;
- use plugin\admin\app\repositories\WithdrawTwoRepositories;
- use Respect\Validation\Validator;
- use support\Db;
- use support\Log;
- use support\Request;
- use support\Response;
- use plugin\admin\app\model\Withdraw;
- use plugin\admin\app\controller\Crud;
- use support\exception\BusinessException;
- /**
- * 提现列表
- */
- class WithdrawController extends Crud
- {
- /**
- * @var Withdraw
- */
- protected $model = null;
- /**
- * 构造函数
- * @return void
- */
- public function __construct()
- {
- $this->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();
- }
- }
|