239 lines
9.9 KiB
PHP
239 lines
9.9 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\Admin\Actions\Grid\Exports\DealerWalletWithdraw;
|
|
use App\Admin\Actions\Show\DealerWalletPay;
|
|
use App\Admin\Actions\Show\DealerWalletRefuse;
|
|
use App\Admin\Repositories\DealerWalletToBankLog;
|
|
use App\Models\DealerWalletToBankLog as DealerWalletToBankLogModel;
|
|
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
|
use Dcat\Admin\Admin;
|
|
use Dcat\Admin\Form;
|
|
use Dcat\Admin\Grid;
|
|
use Dcat\Admin\Http\Controllers\AdminController;
|
|
use Dcat\Admin\Show;
|
|
use Illuminate\Http\Request;
|
|
|
|
class DealerWalletToBankLogController extends AdminController
|
|
{
|
|
/**
|
|
* Make a grid builder.
|
|
*
|
|
* @return Grid
|
|
*/
|
|
protected function grid()
|
|
{
|
|
$builder = DealerWalletToBankLog::with(['user']);
|
|
return Grid::make($builder, function (Grid $grid) {
|
|
$grid->tools(function (Grid\Tools $tools) {
|
|
$tools->append(new DealerWalletWithdraw());
|
|
});
|
|
$grid->column('id')->sortable();
|
|
$grid->column('user.phone');
|
|
$grid->column('amount')->prepend('¥');
|
|
$grid->column('rate')->append('%');
|
|
$grid->column('service_amount')->prepend('¥');
|
|
$grid->column('account_amount')->prepend('¥');
|
|
$grid->column('status')->using([
|
|
DealerWalletToBankLogModel::STATUS_PENDING=>'待处理',
|
|
DealerWalletToBankLogModel::STATUS_AGREE=>'同意',
|
|
DealerWalletToBankLogModel::STATUS_REFUSE=>'拒绝',
|
|
])->dot([
|
|
0=>'primary',
|
|
1=>'success',
|
|
2=>'danger',
|
|
])->filter(Grid\Column\Filter\In::make([
|
|
DealerWalletToBankLogModel::STATUS_PENDING=>'待处理',
|
|
DealerWalletToBankLogModel::STATUS_AGREE=>'同意',
|
|
DealerWalletToBankLogModel::STATUS_REFUSE=>'拒绝',
|
|
]));
|
|
$grid->column('remarks');
|
|
$grid->column('created_at')->sortable();
|
|
// $grid->column('updated_at')
|
|
$grid->model()->orderBy('status', 'asc');
|
|
$grid->model()->orderBy('created_at', 'desc');
|
|
|
|
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
|
if (Admin::user()->can('dcat.admin.dealer_wallet_to_bank_logs.show')) {
|
|
$actions->append('<a style="cursor: pointer;" target="_blank" href="'.admin_route('dealer_wallet_to_bank_logs.show', ['dealer_wallet_to_bank_log'=>$actions->row]).'"><i class="feather icon-eye"></i> 显示 </a>');
|
|
}
|
|
});
|
|
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
$filter->panel();
|
|
// $filter->equal('status')->select([
|
|
// DealerWalletToBankLogModel::STATUS_PENDING=>'待处理',
|
|
// DealerWalletToBankLogModel::STATUS_AGREE=>'已同意',
|
|
// DealerWalletToBankLogModel::STATUS_REFUSE=>'已拒绝',
|
|
// ])->width(3);
|
|
$filter->equal('user.phone')->width(3);
|
|
$filter->between('created_at')->dateTime()->width(7);
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a show builder.
|
|
*
|
|
* @param mixed $id
|
|
*
|
|
* @return Show
|
|
*/
|
|
protected function detail($id)
|
|
{
|
|
$builder = DealerWalletToBankLog::with(['user']);
|
|
return Show::make($id, $builder, function (Show $show) {
|
|
$show->field('id');
|
|
$show->field('user.phone');
|
|
$show->field('amount')->prepend('¥');
|
|
$show->field('rate')->append('%');
|
|
$show->field('service_amount')->prepend('¥');
|
|
$show->field('account_amount')->prepend('¥');
|
|
$show->field('status')->using([
|
|
DealerWalletToBankLogModel::STATUS_PENDING=>'待处理',
|
|
DealerWalletToBankLogModel::STATUS_AGREE=>'同意',
|
|
DealerWalletToBankLogModel::STATUS_REFUSE=>'拒绝',
|
|
])->dot([
|
|
0=>'primary',
|
|
1=>'success',
|
|
2=>'danger',
|
|
]);
|
|
$show->field('pay_image')->image();
|
|
$show->field('remarks');
|
|
$show->divider('收款信息-银行');
|
|
$show->field('bank_user_name', '银行-收款人')->as(function () {
|
|
$payInfo = $this->getPayInfo();
|
|
return $payInfo['bank']['user_name'] ?? '';
|
|
});
|
|
$show->field('bank_bank_name', '银行-名称')->as(function () {
|
|
$payInfo = $this->getPayInfo();
|
|
return $payInfo['bank']['bank_name'] ?? '';
|
|
});
|
|
$show->field('bank_bank_number', '银行-卡号')->as(function () {
|
|
$payInfo = $this->getPayInfo();
|
|
return $payInfo['bank']['bank_number'] ?? '';
|
|
});
|
|
$show->field('bank_bank_description', '银行-开户行')->as(function () {
|
|
$payInfo = $this->getPayInfo();
|
|
return $payInfo['bank']['bank_description'] ?? '';
|
|
});
|
|
$show->divider('收款信息-支付宝');
|
|
$show->field('alipay_user_name', '支付宝-真实名称')->as(function () {
|
|
$payInfo = $this->getPayInfo();
|
|
return $payInfo['alipay']['user_name'] ?? '';
|
|
});
|
|
$show->field('alipay_ali_name', '支付宝-账户')->as(function () {
|
|
$payInfo = $this->getPayInfo();
|
|
return $payInfo['alipay']['ali_name'] ?? '';
|
|
});
|
|
$show->field('alipay_image', '支付宝-收款码')->as(function () {
|
|
$payInfo = $this->getPayInfo();
|
|
return $payInfo['alipay']['image'] ?? '';
|
|
})->image();
|
|
$show->divider('收款信息-微信');
|
|
$show->field('wechat_user_name', '微信-真实名称')->as(function () {
|
|
$payInfo = $this->getPayInfo();
|
|
return $payInfo['wechat']['user_name'] ?? '';
|
|
});
|
|
$show->field('wechat_wechat_name', '微信-ID')->as(function () {
|
|
$payInfo = $this->getPayInfo();
|
|
return $payInfo['wechat']['wechat_name'] ?? '';
|
|
});
|
|
$show->field('wechat_image', '微信-收款码')->as(function () {
|
|
$payInfo = $this->getPayInfo();
|
|
return $payInfo['wechat']['image'] ?? '';
|
|
})->image();
|
|
$show->field('created_at');
|
|
|
|
$show->panel()
|
|
->tools(function (Show\Tools $tools) use ($show) {
|
|
$tools->disableEdit();
|
|
$tools->disableDelete();
|
|
if ($show->model()->isPending() && Admin::user()->can('dcat.admin.dealer_wallet_to_bank_logs.verify')) {
|
|
$tools->append(new DealerWalletRefuse());
|
|
$tools->append(new DealerWalletPay());
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a form builder.
|
|
*
|
|
* @return Form
|
|
*/
|
|
protected function form()
|
|
{
|
|
return Form::make(new DealerWalletToBankLog(), function (Form $form) {
|
|
$form->display('id');
|
|
$form->text('user_id');
|
|
$form->text('amount');
|
|
$form->text('rate');
|
|
$form->text('service_amount');
|
|
$form->text('account_amount');
|
|
$form->text('status');
|
|
$form->text('remarks');
|
|
|
|
$form->display('created_at');
|
|
$form->display('updated_at');
|
|
});
|
|
}
|
|
|
|
public function export(Request $request)
|
|
{
|
|
return response()->streamDownload(function () use ($request) {
|
|
$writer = WriterEntityFactory::createXLSXWriter();
|
|
$writer->openToBrowser('打款单'.date('Ymd').'.xlsx');
|
|
$writer->addRow(WriterEntityFactory::createRowFromArray([
|
|
'提现手机号', '打款金额', '状态', '收款人', '收款银行', '收款账号', '开户行', '提现时间',
|
|
]));
|
|
$query = DealerWalletToBankLogModel::with('dealer', 'user');
|
|
foreach ($request->input() as $key => $value) {
|
|
switch ($key) {
|
|
case 'created_at':
|
|
if ($value['start'] || $value['end']) {
|
|
$query->whereBetween('created_at', $value);
|
|
}
|
|
break;
|
|
case 'status':
|
|
if ($value) {
|
|
$query->where('status', $value);
|
|
}
|
|
break;
|
|
case 'user':
|
|
if (is_array($value)) {
|
|
foreach ($value as $kk =>$vv) {
|
|
$query->whereHas($key, function ($q) use ($kk, $vv) {
|
|
if ($vv) {
|
|
$q->where($kk, $vv);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
$statusArr = [
|
|
DealerWalletToBankLogModel::STATUS_PENDING=>'待处理',
|
|
DealerWalletToBankLogModel::STATUS_AGREE=>'同意',
|
|
DealerWalletToBankLogModel::STATUS_REFUSE=>'拒绝',
|
|
];
|
|
foreach ($query->cursor() as $log) {
|
|
$payInfo = $log->getPayInfo();
|
|
$writer->addRow(WriterEntityFactory::createRowFromArray([
|
|
$log->user->phone,
|
|
$log->account_amount,
|
|
$statusArr[$log->status],
|
|
$payInfo ? $payInfo['bank']['user_name'] : '',
|
|
$payInfo ? $payInfo['bank']['bank_name'] : '',
|
|
$payInfo ? $payInfo['bank']['bank_number'] : '',
|
|
$payInfo ? $payInfo['bank']['bank_description'] : '',
|
|
$log->created_at->toDateTimeString(),
|
|
]));
|
|
};
|
|
$writer->close();
|
|
});
|
|
}
|
|
}
|