diff --git a/app/AdminAgent/Controllers/WalletController.php b/app/AdminAgent/Controllers/WalletController.php index a10d99a..f0b001b 100644 --- a/app/AdminAgent/Controllers/WalletController.php +++ b/app/AdminAgent/Controllers/WalletController.php @@ -87,6 +87,7 @@ HTML; }) ->body( Grid::make(new Withdrawal(), function (Grid $grid) { + $grid->model()->where(['user_id' => Admin::user()->id,'user_type' => DemandTraits::$col[0]]); $grid->disableActions(); //$grid->disable(); $grid->column('id')->sortable(); diff --git a/app/AdminSupplier/Controllers/WalletController.php b/app/AdminSupplier/Controllers/WalletController.php new file mode 100644 index 0000000..5719119 --- /dev/null +++ b/app/AdminSupplier/Controllers/WalletController.php @@ -0,0 +1,140 @@ +body( + << + + + HTML + + ) + ->body($this->build()) + ->body(function (Row $row) { + + $row->column(4, function (Column $column){ + $column->row(Card::make('当前余额', function () { + $balance = Admin::user()->balance ?? 0; + return << +

$balance

+ +HTML; + })); + }); + + $row->column(4, function (Column $column){ + $column->row(Card::make('已提现', function () { + $price = \App\Models\Withdrawal::query() + ->where([ + 'user_id' => Admin::user()->id, + 'user_type' => DemandTraits::$col[1], + 'status' => WithdrawalTraits::$state[3] + ]) + ->sum('price'); + return << +

$price

+ +HTML; + })); + + }); + + $row->column(4, function (Column $column) { + $column->row(Card::make('提现中', function () { + $price = \App\Models\Withdrawal::query() + ->where([ + 'user_id' => Admin::user()->id, + 'user_type' => DemandTraits::$col[1], + 'status' => WithdrawalTraits::$state[0] + ]) + ->sum('price'); + return << +

$price

+ +HTML; + })); + + }); + + }) + ->body( + Grid::make(new Withdrawal(), function (Grid $grid) { + $grid->model()->where(['user_id' => Admin::user()->id,'user_type' => DemandTraits::$col[1]]); + $grid->disableActions(); + //$grid->disable(); + $grid->column('id')->sortable(); + $grid->column('price','提现金额'); + $grid->column('pay_type','提现方式')->using(WithdrawalTraits::$userTypeText); + //$grid->column('pay_id'); + $grid->column('status','状态')->using(WithdrawalTraits::$stateText)->dot([ + + 1 => Admin::color()->yellow(), + 2 => 'danger', + 3 => 'success', + 4 => Admin::color()->info(), + + ]); + $grid->column('created_at'); + $grid->column('updated_at')->sortable(); + $grid->disableCreateButton(); + $grid->disableRowSelector(); + $grid->filter(function (Grid\Filter $filter) { + $filter->equal('id')->width(3); + $filter->equal('status','状态')->select(WithdrawalTraits::$stateTextSelect)->width(2); + }); + }) + + ); + } + + protected function build() + { + Form::dialog('支付宝提现') + ->click('.alipay-create-form') // 绑定点击按钮 + ->url('/withdrawak_alipay/create') // 表单页面链接,此参数会被按钮中的 “data-url” 属性替换。。 + ->width('700px') // 指定弹窗宽度,可填写百分比,默认 720px + ->height('650px') // 指定弹窗高度,可填写百分比,默认 690px + ->success('Dcat.reload()'); // 新增成功后刷新页面 + + Form::dialog('银行卡提现') + ->click('.bank-create-form') // 绑定点击按钮 + ->url('/withdrawak_bank/create') // 表单页面链接,此参数会被按钮中的 “data-url” 属性替换。。 + ->width('700px') // 指定弹窗宽度,可填写百分比,默认 720px + ->height('650px') // 指定弹窗高度,可填写百分比,默认 690px + ->success('Dcat.reload()'); // 新增成功后刷新页面 + + return " +
+ 支付宝提现    + 银行卡提现    +
"; + } +} diff --git a/app/AdminSupplier/Controllers/WithdrawalAlipayController.php b/app/AdminSupplier/Controllers/WithdrawalAlipayController.php new file mode 100755 index 0000000..2bf7206 --- /dev/null +++ b/app/AdminSupplier/Controllers/WithdrawalAlipayController.php @@ -0,0 +1,64 @@ +display('id'); + $form->decimal('price','提现金额')->required(); + $form->text('account')->required(); + $form->text('name')->required(); + $form->image('qrcode')->required(); + $form->hidden('withdrawal_id'); + + $form->saving(function (Form $form) { + $user = Agent::query()->where('id', Admin::user()->id)->lockForUpdate()->first(); + if ($form->price > $user->balance) { + return $form->response()->error('余额不足,当前可用余额为'.$user->balance); + } + + $user->balance = bcsub($user->balance,$form->price,6); + $user->save(); + + $withdrawal = new Withdrawal(); + $withdrawal->user_id = Admin::user()->id; + $withdrawal->user_type = DemandTraits::$col[1]; + $withdrawal->price = request('price',0); + //$withdrawal->pay_id = $form->getKey(); + $withdrawal->pay_type = WithdrawalTraits::$userType[0]; + $withdrawal->save(); + + $form->withdrawal_id = $withdrawal->id; + $form->deleteInput('price'); + }); + + $form->saved(function (Form $form) { + $withdrawal = Withdrawal::find($form->withdrawal_id); + $withdrawal->pay_id = $form->getKey(); + $withdrawal->save(); + }); + }); + } +} diff --git a/app/AdminSupplier/Controllers/WithdrawalBankController.php b/app/AdminSupplier/Controllers/WithdrawalBankController.php new file mode 100755 index 0000000..13fa16b --- /dev/null +++ b/app/AdminSupplier/Controllers/WithdrawalBankController.php @@ -0,0 +1,64 @@ +display('id'); + $form->decimal('price','提现金额')->required(); + $form->text('name')->required(); + $form->text('card_number')->required(); + $form->text('account_name')->required(); + $form->text('branch')->required(); + $form->hidden('withdrawal_id'); + + $form->saving(function (Form $form) { + $user = Agent::query()->where('id', Admin::user()->id)->lockForUpdate()->first(); + if ($form->price > $user->balance) { + return $form->response()->error('余额不足,当前可用余额为'.$user->balance); + } + + $user->balance = bcsub($user->balance,$form->price,6); + $user->save(); + + $withdrawal = new Withdrawal(); + $withdrawal->user_id = Admin::user()->id; + $withdrawal->user_type = DemandTraits::$col[1]; + $withdrawal->price = request('price',0); + //$withdrawal->pay_id = $form->getKey(); + $withdrawal->pay_type = WithdrawalTraits::$userType[1]; + $withdrawal->save(); + + $form->withdrawal_id = $withdrawal->id; + $form->deleteInput('price'); + }); + + $form->saved(function (Form $form) { + $withdrawal = Withdrawal::find($form->withdrawal_id); + $withdrawal->pay_id = $form->getKey(); + $withdrawal->save(); + }); + }); + } +} diff --git a/app/AdminSupplier/Repositories/Withdrawal.php b/app/AdminSupplier/Repositories/Withdrawal.php new file mode 100755 index 0000000..acf7f66 --- /dev/null +++ b/app/AdminSupplier/Repositories/Withdrawal.php @@ -0,0 +1,16 @@ +resource('workorder', 'WorkorderController'); + $router->resource('wallet', 'WalletController'); + $router->resource('withdrawak_alipay', 'WithdrawalAlipayController'); + $router->resource('withdrawak_bank', 'WithdrawalBankController'); //api $router->any('send_text', 'WorkorderController@sendText'); $router->any('send_image', 'WorkorderController@sendImage');