diff --git a/app/Admin/Actions/Show/DealerWalletPay.php b/app/Admin/Actions/Show/DealerWalletPay.php
new file mode 100644
index 00000000..32b4f7b6
--- /dev/null
+++ b/app/Admin/Actions/Show/DealerWalletPay.php
@@ -0,0 +1,32 @@
+ 打款';
+
+ /**
+ * 按钮样式定义,默认 btn btn-white waves-effect
+ *
+ * @var string
+ */
+ protected $style = 'btn-danger';
+
+ public function render()
+ {
+ $form = DealerWalletPayForm::make()->payload(['id'=>$this->getKey()]);
+ return Modal::make()
+ ->lg()
+ ->title($this->title)
+ ->body($form)
+ ->button("style}\">{$this->title} ");
+ }
+}
diff --git a/app/Admin/Actions/Show/DealerWalletRefuse.php b/app/Admin/Actions/Show/DealerWalletRefuse.php
new file mode 100644
index 00000000..134c99c2
--- /dev/null
+++ b/app/Admin/Actions/Show/DealerWalletRefuse.php
@@ -0,0 +1,32 @@
+ 拒绝';
+
+ /**
+ * 按钮样式定义,默认 btn btn-white waves-effect
+ *
+ * @var string
+ */
+ protected $style = 'btn-warning';
+
+ public function render()
+ {
+ $form = DealerWalletRefuseForm::make()->payload(['id'=>$this->getKey()]);
+ return Modal::make()
+ ->lg()
+ ->title($this->title)
+ ->body($form)
+ ->button("style}\">{$this->title} ");
+ }
+}
diff --git a/app/Admin/Controllers/DealerWalletToBankLogController.php b/app/Admin/Controllers/DealerWalletToBankLogController.php
new file mode 100644
index 00000000..255276e9
--- /dev/null
+++ b/app/Admin/Controllers/DealerWalletToBankLogController.php
@@ -0,0 +1,172 @@
+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',
+ ]);
+ $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(' 显示 ');
+ }
+ });
+
+ $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');
+ });
+ }
+}
diff --git a/app/Admin/Forms/DealerWalletPay.php b/app/Admin/Forms/DealerWalletPay.php
new file mode 100644
index 00000000..1435d19c
--- /dev/null
+++ b/app/Admin/Forms/DealerWalletPay.php
@@ -0,0 +1,69 @@
+can('dcat.admin.dealer_wallet_to_bank_logs.verify');
+ }
+
+ /**
+ * Handle the form request.
+ *
+ * @param array $input
+ *
+ * @return mixed
+ */
+ public function handle(array $input)
+ {
+ $id = $this->payload['id'] ?? 0;
+
+ try {
+ DB::beginTransaction();
+ $log = DealerWalletToBankLog::findOrFail($id);
+ $log->update([
+ 'pay_info' => $log->getPayInfo(),
+ 'pay_image' => $input['pay_image']??null,
+ 'status' => DealerWalletToBankLog::STATUS_AGREE,
+ ]);
+ DB::commit();
+ } catch (Throwable $th) {
+ DB::rollBack();
+ report($th);
+ return $this->response()->error('操作失败:'.$th->getMessage());
+ }
+
+ return $this->response()
+ ->success(__('admin.update_succeeded'))
+ ->refresh();
+ }
+
+ /**
+ * Build a form here.
+ */
+ public function form()
+ {
+ $this->image('pay_image')
+ ->move('dealer-pay/'.Carbon::now()->toDateString())
+ ->saveFullUrl()
+ ->removable(false)
+ ->autoUpload();
+ }
+}
diff --git a/app/Admin/Forms/DealerWalletRefuse.php b/app/Admin/Forms/DealerWalletRefuse.php
new file mode 100644
index 00000000..d441b990
--- /dev/null
+++ b/app/Admin/Forms/DealerWalletRefuse.php
@@ -0,0 +1,68 @@
+can('dcat.admin.dealer_wallet_to_bank_logs.verify');
+ }
+
+ /**
+ * Handle the form request.
+ *
+ * @param array $input
+ *
+ * @return mixed
+ */
+ public function handle(array $input)
+ {
+ $id = $this->payload['id'] ?? 0;
+
+ try {
+ DB::beginTransaction();
+ $log = DealerWalletToBankLog::findOrFail($id);
+ $log->update([
+ 'remark' => $input['remark']??'',
+ 'status' => DealerWalletToBankLog::STATUS_REFUSE,
+ ]);
+ //打回余额
+ $walletService = new WalletService();
+ $walletService->changeBalance($log->user, $log->amount, DealerWalletAction::WithdrawFiled, '提现-失败', $log);
+ DB::commit();
+ } catch (Throwable $th) {
+ DB::rollBack();
+ report($th);
+ return $this->response()->error('操作失败:'.$th->getMessage());
+ }
+
+ return $this->response()
+ ->success(__('admin.update_succeeded'))
+ ->refresh();
+ }
+
+ /**
+ * Build a form here.
+ */
+ public function form()
+ {
+ $this->text('remarks', '备注')->required();
+ }
+}
diff --git a/app/Admin/Repositories/DealerWalletToBankLog.php b/app/Admin/Repositories/DealerWalletToBankLog.php
new file mode 100644
index 00000000..d30887c6
--- /dev/null
+++ b/app/Admin/Repositories/DealerWalletToBankLog.php
@@ -0,0 +1,16 @@
+get('dealer-manage-subsidy-logs', 'DealerManageSubsidyLogController@index')->name('dealer_manage_subsidy_logs.index');
$router->get('dealer-purchase-logs', 'DealerPurchaseLogController@index')->name('dealer_purchase_logs.index');
+ //批零余额提现
+ $router->resource('dealer-wallet-to-bank-logs', 'DealerWalletToBankLogController')->only([
+ 'index', 'show',
+ ])->names('dealer_wallet_to_bank_logs');
+
/** api接口 **/
$router->get('api/product-categories', 'ProductCategoryController@categories')->name('api.product_categories');
$router->get('api/product-group-details', 'ProductGroupController@details')->name('api.product_group_details');
diff --git a/app/Endpoint/Api/Http/Controllers/Dealer/WalletController.php b/app/Endpoint/Api/Http/Controllers/Dealer/WalletController.php
index 690267e9..12932100 100644
--- a/app/Endpoint/Api/Http/Controllers/Dealer/WalletController.php
+++ b/app/Endpoint/Api/Http/Controllers/Dealer/WalletController.php
@@ -46,7 +46,7 @@ class WalletController extends Controller
$user = $request->user();
$amount = Arr::get($input, 'amount', 0);
- if (is_null($user->dealer->pay_info)) {
+ if (empty($user->dealer->pay_info)) {
throw new BizException('请先绑定设置收款信息');
}
//校验是否关闭提现
@@ -58,7 +58,6 @@ class WalletController extends Controller
if (bcdiv($amount, 100, 2) < app_settings('dealer.withdraw_threshold_amount', 0)) {
throw new BizException('提现金额需大于'.app_settings('dealer.withdraw_threshold_amount', 0).'元');
}
-
try {
DB::beginTransaction();
@@ -70,14 +69,14 @@ class WalletController extends Controller
//生成提现记录
$log = DealerWalletToBankLog::create([
'user_id' =>$user->id,
- 'amount'=> $amount,
+ 'amount'=> bcdiv($amount, 100, 2),
'rate' => $rate,
- 'service_amount' => $serviceAmount,
- 'account_amount' => $amount-$serviceAmount,
+ 'service_amount' => bcdiv($serviceAmount, 100, 2),
+ 'account_amount' => bcdiv($amount-$serviceAmount, 100, 2),
]);
//减去用户可提金额
- $walletService->changeBalance($user, -$amount, DealerWalletAction::WithdrawBank, '提现', $log);
+ $walletService->changeBalance($user, -bcdiv($amount, 100, 2), DealerWalletAction::WithdrawBank, '提现', $log);
DB::commit();
} catch (BizException $th) {
DB::rollBack();
diff --git a/app/Enums/DealerWalletAction.php b/app/Enums/DealerWalletAction.php
index 2aedb7d3..fdcec0eb 100644
--- a/app/Enums/DealerWalletAction.php
+++ b/app/Enums/DealerWalletAction.php
@@ -4,4 +4,5 @@ namespace App\Enums;
enum DealerWalletAction: int {
case WithdrawBank = 4;
+ case WithdrawFiled = 6;
}
diff --git a/database/seeders/AdminMenuSeeder.php b/database/seeders/AdminMenuSeeder.php
index 957a4399..6f0a37bd 100644
--- a/database/seeders/AdminMenuSeeder.php
+++ b/database/seeders/AdminMenuSeeder.php
@@ -349,6 +349,11 @@ class AdminMenuSeeder extends Seeder
'icon' => '',
'uri'=>'dealer-manager-sales-logs',
],
+ [
+ 'title' =>'余额提现',
+ 'icon' =>'',
+ 'uri'=>'dealer-wallet-to-bank-logs',
+ ],
],
],
[
diff --git a/dcat_admin_ide_helper.php b/dcat_admin_ide_helper.php
index ecd9147a..6bc8486a 100644
--- a/dcat_admin_ide_helper.php
+++ b/dcat_admin_ide_helper.php
@@ -162,6 +162,10 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection change_sales_value
* @property Grid\Column|Collection before_lvl
* @property Grid\Column|Collection change_lvl
+ * @property Grid\Column|Collection account_amount
+ * @property Grid\Column|Collection rate
+ * @property Grid\Column|Collection service_amount
+ * @property Grid\Column|Collection withdrawable
* @property Grid\Column|Collection bonds
* @property Grid\Column|Collection contracted_lvl_at
* @property Grid\Column|Collection self_sales_value
@@ -300,10 +304,6 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection phone_verified_at
* @property Grid\Column|Collection register_ip
* @property Grid\Column|Collection status_remark
- * @property Grid\Column|Collection account_amount
- * @property Grid\Column|Collection rate
- * @property Grid\Column|Collection service_amount
- * @property Grid\Column|Collection withdrawable
*
* @method Grid\Column|Collection created_at(string $label = null)
* @method Grid\Column|Collection dimensions(string $label = null)
@@ -456,6 +456,10 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection change_sales_value(string $label = null)
* @method Grid\Column|Collection before_lvl(string $label = null)
* @method Grid\Column|Collection change_lvl(string $label = null)
+ * @method Grid\Column|Collection account_amount(string $label = null)
+ * @method Grid\Column|Collection rate(string $label = null)
+ * @method Grid\Column|Collection service_amount(string $label = null)
+ * @method Grid\Column|Collection withdrawable(string $label = null)
* @method Grid\Column|Collection bonds(string $label = null)
* @method Grid\Column|Collection contracted_lvl_at(string $label = null)
* @method Grid\Column|Collection self_sales_value(string $label = null)
@@ -594,10 +598,6 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection phone_verified_at(string $label = null)
* @method Grid\Column|Collection register_ip(string $label = null)
* @method Grid\Column|Collection status_remark(string $label = null)
- * @method Grid\Column|Collection account_amount(string $label = null)
- * @method Grid\Column|Collection rate(string $label = null)
- * @method Grid\Column|Collection service_amount(string $label = null)
- * @method Grid\Column|Collection withdrawable(string $label = null)
*/
class Grid {}
@@ -755,6 +755,10 @@ namespace Dcat\Admin {
* @property Show\Field|Collection change_sales_value
* @property Show\Field|Collection before_lvl
* @property Show\Field|Collection change_lvl
+ * @property Show\Field|Collection account_amount
+ * @property Show\Field|Collection rate
+ * @property Show\Field|Collection service_amount
+ * @property Show\Field|Collection withdrawable
* @property Show\Field|Collection bonds
* @property Show\Field|Collection contracted_lvl_at
* @property Show\Field|Collection self_sales_value
@@ -893,10 +897,6 @@ namespace Dcat\Admin {
* @property Show\Field|Collection phone_verified_at
* @property Show\Field|Collection register_ip
* @property Show\Field|Collection status_remark
- * @property Show\Field|Collection account_amount
- * @property Show\Field|Collection rate
- * @property Show\Field|Collection service_amount
- * @property Show\Field|Collection withdrawable
*
* @method Show\Field|Collection created_at(string $label = null)
* @method Show\Field|Collection dimensions(string $label = null)
@@ -1049,6 +1049,10 @@ namespace Dcat\Admin {
* @method Show\Field|Collection change_sales_value(string $label = null)
* @method Show\Field|Collection before_lvl(string $label = null)
* @method Show\Field|Collection change_lvl(string $label = null)
+ * @method Show\Field|Collection account_amount(string $label = null)
+ * @method Show\Field|Collection rate(string $label = null)
+ * @method Show\Field|Collection service_amount(string $label = null)
+ * @method Show\Field|Collection withdrawable(string $label = null)
* @method Show\Field|Collection bonds(string $label = null)
* @method Show\Field|Collection contracted_lvl_at(string $label = null)
* @method Show\Field|Collection self_sales_value(string $label = null)
@@ -1187,10 +1191,6 @@ namespace Dcat\Admin {
* @method Show\Field|Collection phone_verified_at(string $label = null)
* @method Show\Field|Collection register_ip(string $label = null)
* @method Show\Field|Collection status_remark(string $label = null)
- * @method Show\Field|Collection account_amount(string $label = null)
- * @method Show\Field|Collection rate(string $label = null)
- * @method Show\Field|Collection service_amount(string $label = null)
- * @method Show\Field|Collection withdrawable(string $label = null)
*/
class Show {}
diff --git a/resources/lang/zh_CN/dealer-wallet-to-bank-log.php b/resources/lang/zh_CN/dealer-wallet-to-bank-log.php
new file mode 100644
index 00000000..22108113
--- /dev/null
+++ b/resources/lang/zh_CN/dealer-wallet-to-bank-log.php
@@ -0,0 +1,23 @@
+ [
+ 'DealerWalletToBankLog' => '余额提现',
+ 'dealer-wallet-to-bank-logs' => '余额提现',
+ ],
+ 'fields' => [
+ 'user_id' => '用户',
+ 'user'=>[
+ 'phone' => '手机号',
+ ],
+ 'pay_image' => '打款凭证',
+ 'amount' => '提现金额',
+ 'rate' => '费率',
+ 'service_amount' => '手续费',
+ 'account_amount' => '到账金额',
+ 'status' => '状态',
+ 'remarks' => '备注',
+ ],
+ 'options' => [
+ ],
+];