From a3874baa05e2a182804558d1f4396a28b5987cd4 Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Thu, 20 Jan 2022 10:03:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=8E=E5=8F=B0=E8=B5=84?= =?UTF-8?q?=E9=87=91=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/DealerEarningController.php | 123 ++++++++++++++ app/Admin/Repositories/DealerEarning.php | 16 ++ app/Admin/routes.php | 3 + .../Dealer/DealerEarningResource.php | 4 +- .../Dealer/DealerEarningSimpleResource.php | 2 +- app/Models/DealerEarning.php | 5 + database/seeders/AdminMenuSeeder.php | 2 +- dcat_admin_ide_helper.php | 152 ++++++++++++++---- resources/lang/zh_CN/dealer-earning.php | 33 ++++ 9 files changed, 304 insertions(+), 36 deletions(-) create mode 100644 app/Admin/Controllers/DealerEarningController.php create mode 100644 app/Admin/Repositories/DealerEarning.php create mode 100644 resources/lang/zh_CN/dealer-earning.php diff --git a/app/Admin/Controllers/DealerEarningController.php b/app/Admin/Controllers/DealerEarningController.php new file mode 100644 index 00000000..969b6367 --- /dev/null +++ b/app/Admin/Controllers/DealerEarningController.php @@ -0,0 +1,123 @@ +column('id')->sortable(); + $grid->column('user.phone'); + $grid->column('type_name')->display(function () { + return $this->type_name; + })->label(); + // $grid->column('earningable_type'); + // $grid->column('earningable_id'); + $grid->column('lvl')->display(function () { + return $this->lvl_text; + }); + $grid->column('is_manager')->bool(); + $grid->column('total_amount')->prepend('¥'); + $grid->column('fee_rate')->append('%'); + $grid->column('fee')->prepend('¥'); + $grid->column('total_earnings')->prepend('¥'); + $grid->column('payer_id'); + // $grid->column('pay_info'); + $grid->column('pay_at'); + $grid->column('settle_at'); + $grid->column('status_format')->display(function ($value) { + return $this->status_format; + })->using([ + -1=>'待结算', + 0=>'待打款', + 1=>'待收款', + 2=>'已完成', + ])->dot(); + + $grid->column('remark'); + // $grid->column('pay_image'); + $grid->column('created_at')->sortable(); + + $grid->filter(function (Grid\Filter $filter) { + $filter->panel(); + $filter->equal('user.phone')->width(3); + }); + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + return Show::make($id, new DealerEarning(), function (Show $show) { + $show->field('id'); + $show->field('user_id'); + $show->field('earningable_type'); + $show->field('earningable_id'); + $show->field('lvl'); + $show->field('is_manager'); + $show->field('total_amount'); + $show->field('total_earnings'); + $show->field('fee'); + $show->field('fee_rate'); + $show->field('payer_id'); + $show->field('pay_info'); + $show->field('pay_at'); + $show->field('settle_at'); + $show->field('status'); + $show->field('remark'); + $show->field('pay_image'); + $show->field('created_at'); + $show->field('updated_at'); + }); + } + + /** + * Make a form builder. + * + * @return Form + */ + protected function form() + { + return Form::make(new DealerEarning(), function (Form $form) { + $form->display('id'); + $form->text('user_id'); + $form->text('earningable_type'); + $form->text('earningable_id'); + $form->text('lvl'); + $form->text('is_manager'); + $form->text('total_amount'); + $form->text('total_earnings'); + $form->text('fee'); + $form->text('fee_rate'); + $form->text('payer_id'); + $form->text('pay_info'); + $form->text('pay_at'); + $form->text('settle_at'); + $form->text('status'); + $form->text('remark'); + $form->text('pay_image'); + + $form->display('created_at'); + $form->display('updated_at'); + }); + } +} diff --git a/app/Admin/Repositories/DealerEarning.php b/app/Admin/Repositories/DealerEarning.php new file mode 100644 index 00000000..49460d67 --- /dev/null +++ b/app/Admin/Repositories/DealerEarning.php @@ -0,0 +1,16 @@ +names('dealers'); + //渠道补贴 + $router->get('dealer-earnings-channel', 'DealerEarningController@index')->name('dealer_earnings.channel'); + /** 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/Resources/Dealer/DealerEarningResource.php b/app/Endpoint/Api/Http/Resources/Dealer/DealerEarningResource.php index e34ff284..243153e2 100644 --- a/app/Endpoint/Api/Http/Resources/Dealer/DealerEarningResource.php +++ b/app/Endpoint/Api/Http/Resources/Dealer/DealerEarningResource.php @@ -19,12 +19,12 @@ class DealerEarningResource extends JsonResource 'id' => $this->id, 'type' => $this->type_name, 'created_at' => $this->created_at->toDateTimeString(), - 'settle_at' => $this->settle_at->toDateTimeString(), + 'settle_at' => $this->settle_at?->toDateTimeString(), 'total_amount' => $this->total_amount, 'fee_rate' => $this->fee_rate, 'fee' => $this->fee, 'total_earnings'=> $this->total_earnings, - 'status' => $this->settle_at ? $this->status : -1, + 'status' => $this->status_format, 'status_name' => $this->status_name, 'remark' => $this->remark, 'pay_info' => $this->getPayInfo(), diff --git a/app/Endpoint/Api/Http/Resources/Dealer/DealerEarningSimpleResource.php b/app/Endpoint/Api/Http/Resources/Dealer/DealerEarningSimpleResource.php index 789ae160..d8ae05c1 100644 --- a/app/Endpoint/Api/Http/Resources/Dealer/DealerEarningSimpleResource.php +++ b/app/Endpoint/Api/Http/Resources/Dealer/DealerEarningSimpleResource.php @@ -19,7 +19,7 @@ class DealerEarningSimpleResource extends JsonResource 'type' => $this->type_name, 'created_at' => $this->created_at->toDateTimeString(), 'total_earnings'=> $this->total_earnings, - 'status' => $this->settle_at ? $this->status : -1, + 'status' => $this->status_format, 'status_name' => $this->status_name, 'is_payer' => $this->payer_id ? ($this->payer_id == $request->user()->id) : false, // 'settle_at' diff --git a/app/Models/DealerEarning.php b/app/Models/DealerEarning.php index d5790f87..5a9548bb 100644 --- a/app/Models/DealerEarning.php +++ b/app/Models/DealerEarning.php @@ -134,6 +134,11 @@ class DealerEarning extends Model } } + public function getStatusFormatAttribute() + { + return $this->settle_at ? $this->status->value : -1; + } + public function getTypeNameAttribute() { $name = '未知'; diff --git a/database/seeders/AdminMenuSeeder.php b/database/seeders/AdminMenuSeeder.php index b301a6cc..6e615323 100644 --- a/database/seeders/AdminMenuSeeder.php +++ b/database/seeders/AdminMenuSeeder.php @@ -312,7 +312,7 @@ class AdminMenuSeeder extends Seeder [ 'title' =>'渠道补贴', 'icon'=>'', - 'uri' => '', + 'uri' => 'dealer-earnings-channel?type=channel', ], [ 'title' =>'进货补贴', diff --git a/dcat_admin_ide_helper.php b/dcat_admin_ide_helper.php index 7afd9eda..06b2f6f0 100644 --- a/dcat_admin_ide_helper.php +++ b/dcat_admin_ide_helper.php @@ -109,20 +109,37 @@ namespace Dcat\Admin { * @property Grid\Column|Collection use_start_at * @property Grid\Column|Collection lvl * @property Grid\Column|Collection order_completed_at + * @property Grid\Column|Collection remark + * @property Grid\Column|Collection total_amount + * @property Grid\Column|Collection earningable_id + * @property Grid\Column|Collection earningable_type + * @property Grid\Column|Collection fee + * @property Grid\Column|Collection fee_rate + * @property Grid\Column|Collection is_manager + * @property Grid\Column|Collection pay_at + * @property Grid\Column|Collection pay_image + * @property Grid\Column|Collection pay_info + * @property Grid\Column|Collection payer_id + * @property Grid\Column|Collection settle_at + * @property Grid\Column|Collection total_earnings + * @property Grid\Column|Collection end_at + * @property Grid\Column|Collection is_settle + * @property Grid\Column|Collection real_amount + * @property Grid\Column|Collection start_at * @property Grid\Column|Collection product_id * @property Grid\Column|Collection sales_volume - * @property Grid\Column|Collection total_amount + * @property Grid\Column|Collection last_consignor_id + * @property Grid\Column|Collection new_consignor_id * @property Grid\Column|Collection price * @property Grid\Column|Collection qty * @property Grid\Column|Collection sale_price + * @property Grid\Column|Collection allocated_at * @property Grid\Column|Collection consignee_address * @property Grid\Column|Collection consignee_name * @property Grid\Column|Collection consignee_telephone * @property Grid\Column|Collection consignee_zone * @property Grid\Column|Collection consignor_id * @property Grid\Column|Collection paied_time - * @property Grid\Column|Collection pay_image - * @property Grid\Column|Collection pay_info * @property Grid\Column|Collection pay_time * @property Grid\Column|Collection settle_state * @property Grid\Column|Collection shipping_time @@ -136,12 +153,19 @@ namespace Dcat\Admin { * @property Grid\Column|Collection sales_count * @property Grid\Column|Collection unit * @property Grid\Column|Collection path - * @property Grid\Column|Collection remark - * @property Grid\Column|Collection is_manager + * @property Grid\Column|Collection subsidy_rate + * @property Grid\Column|Collection total_purchase_amount + * @property Grid\Column|Collection total_subsidy + * @property Grid\Column|Collection change_amount + * @property Grid\Column|Collection change_from_purchase_subsidy_id + * @property Grid\Column|Collection purchase_subsidy_id + * @property Grid\Column|Collection before_lvl + * @property Grid\Column|Collection change_lvl + * @property Grid\Column|Collection bonds + * @property Grid\Column|Collection contracted_lvl_at * @property Grid\Column|Collection failed_reason * @property Grid\Column|Collection jobable_id * @property Grid\Column|Collection jobable_type - * @property Grid\Column|Collection change_amount * @property Grid\Column|Collection change_revenue * @property Grid\Column|Collection change_sales_value * @property Grid\Column|Collection pre_income_id @@ -190,10 +214,8 @@ namespace Dcat\Admin { * @property Grid\Column|Collection max * @property Grid\Column|Collection auto_complete_at * @property Grid\Column|Collection is_change - * @property Grid\Column|Collection is_settle * @property Grid\Column|Collection note * @property Grid\Column|Collection out_trade_no - * @property Grid\Column|Collection pay_at * @property Grid\Column|Collection pay_sn * @property Grid\Column|Collection pay_way * @property Grid\Column|Collection products_total_amount @@ -379,20 +401,37 @@ namespace Dcat\Admin { * @method Grid\Column|Collection use_start_at(string $label = null) * @method Grid\Column|Collection lvl(string $label = null) * @method Grid\Column|Collection order_completed_at(string $label = null) + * @method Grid\Column|Collection remark(string $label = null) + * @method Grid\Column|Collection total_amount(string $label = null) + * @method Grid\Column|Collection earningable_id(string $label = null) + * @method Grid\Column|Collection earningable_type(string $label = null) + * @method Grid\Column|Collection fee(string $label = null) + * @method Grid\Column|Collection fee_rate(string $label = null) + * @method Grid\Column|Collection is_manager(string $label = null) + * @method Grid\Column|Collection pay_at(string $label = null) + * @method Grid\Column|Collection pay_image(string $label = null) + * @method Grid\Column|Collection pay_info(string $label = null) + * @method Grid\Column|Collection payer_id(string $label = null) + * @method Grid\Column|Collection settle_at(string $label = null) + * @method Grid\Column|Collection total_earnings(string $label = null) + * @method Grid\Column|Collection end_at(string $label = null) + * @method Grid\Column|Collection is_settle(string $label = null) + * @method Grid\Column|Collection real_amount(string $label = null) + * @method Grid\Column|Collection start_at(string $label = null) * @method Grid\Column|Collection product_id(string $label = null) * @method Grid\Column|Collection sales_volume(string $label = null) - * @method Grid\Column|Collection total_amount(string $label = null) + * @method Grid\Column|Collection last_consignor_id(string $label = null) + * @method Grid\Column|Collection new_consignor_id(string $label = null) * @method Grid\Column|Collection price(string $label = null) * @method Grid\Column|Collection qty(string $label = null) * @method Grid\Column|Collection sale_price(string $label = null) + * @method Grid\Column|Collection allocated_at(string $label = null) * @method Grid\Column|Collection consignee_address(string $label = null) * @method Grid\Column|Collection consignee_name(string $label = null) * @method Grid\Column|Collection consignee_telephone(string $label = null) * @method Grid\Column|Collection consignee_zone(string $label = null) * @method Grid\Column|Collection consignor_id(string $label = null) * @method Grid\Column|Collection paied_time(string $label = null) - * @method Grid\Column|Collection pay_image(string $label = null) - * @method Grid\Column|Collection pay_info(string $label = null) * @method Grid\Column|Collection pay_time(string $label = null) * @method Grid\Column|Collection settle_state(string $label = null) * @method Grid\Column|Collection shipping_time(string $label = null) @@ -406,12 +445,19 @@ namespace Dcat\Admin { * @method Grid\Column|Collection sales_count(string $label = null) * @method Grid\Column|Collection unit(string $label = null) * @method Grid\Column|Collection path(string $label = null) - * @method Grid\Column|Collection remark(string $label = null) - * @method Grid\Column|Collection is_manager(string $label = null) + * @method Grid\Column|Collection subsidy_rate(string $label = null) + * @method Grid\Column|Collection total_purchase_amount(string $label = null) + * @method Grid\Column|Collection total_subsidy(string $label = null) + * @method Grid\Column|Collection change_amount(string $label = null) + * @method Grid\Column|Collection change_from_purchase_subsidy_id(string $label = null) + * @method Grid\Column|Collection purchase_subsidy_id(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 bonds(string $label = null) + * @method Grid\Column|Collection contracted_lvl_at(string $label = null) * @method Grid\Column|Collection failed_reason(string $label = null) * @method Grid\Column|Collection jobable_id(string $label = null) * @method Grid\Column|Collection jobable_type(string $label = null) - * @method Grid\Column|Collection change_amount(string $label = null) * @method Grid\Column|Collection change_revenue(string $label = null) * @method Grid\Column|Collection change_sales_value(string $label = null) * @method Grid\Column|Collection pre_income_id(string $label = null) @@ -460,10 +506,8 @@ namespace Dcat\Admin { * @method Grid\Column|Collection max(string $label = null) * @method Grid\Column|Collection auto_complete_at(string $label = null) * @method Grid\Column|Collection is_change(string $label = null) - * @method Grid\Column|Collection is_settle(string $label = null) * @method Grid\Column|Collection note(string $label = null) * @method Grid\Column|Collection out_trade_no(string $label = null) - * @method Grid\Column|Collection pay_at(string $label = null) * @method Grid\Column|Collection pay_sn(string $label = null) * @method Grid\Column|Collection pay_way(string $label = null) * @method Grid\Column|Collection products_total_amount(string $label = null) @@ -654,20 +698,37 @@ namespace Dcat\Admin { * @property Show\Field|Collection use_start_at * @property Show\Field|Collection lvl * @property Show\Field|Collection order_completed_at + * @property Show\Field|Collection remark + * @property Show\Field|Collection total_amount + * @property Show\Field|Collection earningable_id + * @property Show\Field|Collection earningable_type + * @property Show\Field|Collection fee + * @property Show\Field|Collection fee_rate + * @property Show\Field|Collection is_manager + * @property Show\Field|Collection pay_at + * @property Show\Field|Collection pay_image + * @property Show\Field|Collection pay_info + * @property Show\Field|Collection payer_id + * @property Show\Field|Collection settle_at + * @property Show\Field|Collection total_earnings + * @property Show\Field|Collection end_at + * @property Show\Field|Collection is_settle + * @property Show\Field|Collection real_amount + * @property Show\Field|Collection start_at * @property Show\Field|Collection product_id * @property Show\Field|Collection sales_volume - * @property Show\Field|Collection total_amount + * @property Show\Field|Collection last_consignor_id + * @property Show\Field|Collection new_consignor_id * @property Show\Field|Collection price * @property Show\Field|Collection qty * @property Show\Field|Collection sale_price + * @property Show\Field|Collection allocated_at * @property Show\Field|Collection consignee_address * @property Show\Field|Collection consignee_name * @property Show\Field|Collection consignee_telephone * @property Show\Field|Collection consignee_zone * @property Show\Field|Collection consignor_id * @property Show\Field|Collection paied_time - * @property Show\Field|Collection pay_image - * @property Show\Field|Collection pay_info * @property Show\Field|Collection pay_time * @property Show\Field|Collection settle_state * @property Show\Field|Collection shipping_time @@ -681,12 +742,19 @@ namespace Dcat\Admin { * @property Show\Field|Collection sales_count * @property Show\Field|Collection unit * @property Show\Field|Collection path - * @property Show\Field|Collection remark - * @property Show\Field|Collection is_manager + * @property Show\Field|Collection subsidy_rate + * @property Show\Field|Collection total_purchase_amount + * @property Show\Field|Collection total_subsidy + * @property Show\Field|Collection change_amount + * @property Show\Field|Collection change_from_purchase_subsidy_id + * @property Show\Field|Collection purchase_subsidy_id + * @property Show\Field|Collection before_lvl + * @property Show\Field|Collection change_lvl + * @property Show\Field|Collection bonds + * @property Show\Field|Collection contracted_lvl_at * @property Show\Field|Collection failed_reason * @property Show\Field|Collection jobable_id * @property Show\Field|Collection jobable_type - * @property Show\Field|Collection change_amount * @property Show\Field|Collection change_revenue * @property Show\Field|Collection change_sales_value * @property Show\Field|Collection pre_income_id @@ -735,10 +803,8 @@ namespace Dcat\Admin { * @property Show\Field|Collection max * @property Show\Field|Collection auto_complete_at * @property Show\Field|Collection is_change - * @property Show\Field|Collection is_settle * @property Show\Field|Collection note * @property Show\Field|Collection out_trade_no - * @property Show\Field|Collection pay_at * @property Show\Field|Collection pay_sn * @property Show\Field|Collection pay_way * @property Show\Field|Collection products_total_amount @@ -924,20 +990,37 @@ namespace Dcat\Admin { * @method Show\Field|Collection use_start_at(string $label = null) * @method Show\Field|Collection lvl(string $label = null) * @method Show\Field|Collection order_completed_at(string $label = null) + * @method Show\Field|Collection remark(string $label = null) + * @method Show\Field|Collection total_amount(string $label = null) + * @method Show\Field|Collection earningable_id(string $label = null) + * @method Show\Field|Collection earningable_type(string $label = null) + * @method Show\Field|Collection fee(string $label = null) + * @method Show\Field|Collection fee_rate(string $label = null) + * @method Show\Field|Collection is_manager(string $label = null) + * @method Show\Field|Collection pay_at(string $label = null) + * @method Show\Field|Collection pay_image(string $label = null) + * @method Show\Field|Collection pay_info(string $label = null) + * @method Show\Field|Collection payer_id(string $label = null) + * @method Show\Field|Collection settle_at(string $label = null) + * @method Show\Field|Collection total_earnings(string $label = null) + * @method Show\Field|Collection end_at(string $label = null) + * @method Show\Field|Collection is_settle(string $label = null) + * @method Show\Field|Collection real_amount(string $label = null) + * @method Show\Field|Collection start_at(string $label = null) * @method Show\Field|Collection product_id(string $label = null) * @method Show\Field|Collection sales_volume(string $label = null) - * @method Show\Field|Collection total_amount(string $label = null) + * @method Show\Field|Collection last_consignor_id(string $label = null) + * @method Show\Field|Collection new_consignor_id(string $label = null) * @method Show\Field|Collection price(string $label = null) * @method Show\Field|Collection qty(string $label = null) * @method Show\Field|Collection sale_price(string $label = null) + * @method Show\Field|Collection allocated_at(string $label = null) * @method Show\Field|Collection consignee_address(string $label = null) * @method Show\Field|Collection consignee_name(string $label = null) * @method Show\Field|Collection consignee_telephone(string $label = null) * @method Show\Field|Collection consignee_zone(string $label = null) * @method Show\Field|Collection consignor_id(string $label = null) * @method Show\Field|Collection paied_time(string $label = null) - * @method Show\Field|Collection pay_image(string $label = null) - * @method Show\Field|Collection pay_info(string $label = null) * @method Show\Field|Collection pay_time(string $label = null) * @method Show\Field|Collection settle_state(string $label = null) * @method Show\Field|Collection shipping_time(string $label = null) @@ -951,12 +1034,19 @@ namespace Dcat\Admin { * @method Show\Field|Collection sales_count(string $label = null) * @method Show\Field|Collection unit(string $label = null) * @method Show\Field|Collection path(string $label = null) - * @method Show\Field|Collection remark(string $label = null) - * @method Show\Field|Collection is_manager(string $label = null) + * @method Show\Field|Collection subsidy_rate(string $label = null) + * @method Show\Field|Collection total_purchase_amount(string $label = null) + * @method Show\Field|Collection total_subsidy(string $label = null) + * @method Show\Field|Collection change_amount(string $label = null) + * @method Show\Field|Collection change_from_purchase_subsidy_id(string $label = null) + * @method Show\Field|Collection purchase_subsidy_id(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 bonds(string $label = null) + * @method Show\Field|Collection contracted_lvl_at(string $label = null) * @method Show\Field|Collection failed_reason(string $label = null) * @method Show\Field|Collection jobable_id(string $label = null) * @method Show\Field|Collection jobable_type(string $label = null) - * @method Show\Field|Collection change_amount(string $label = null) * @method Show\Field|Collection change_revenue(string $label = null) * @method Show\Field|Collection change_sales_value(string $label = null) * @method Show\Field|Collection pre_income_id(string $label = null) @@ -1005,10 +1095,8 @@ namespace Dcat\Admin { * @method Show\Field|Collection max(string $label = null) * @method Show\Field|Collection auto_complete_at(string $label = null) * @method Show\Field|Collection is_change(string $label = null) - * @method Show\Field|Collection is_settle(string $label = null) * @method Show\Field|Collection note(string $label = null) * @method Show\Field|Collection out_trade_no(string $label = null) - * @method Show\Field|Collection pay_at(string $label = null) * @method Show\Field|Collection pay_sn(string $label = null) * @method Show\Field|Collection pay_way(string $label = null) * @method Show\Field|Collection products_total_amount(string $label = null) diff --git a/resources/lang/zh_CN/dealer-earning.php b/resources/lang/zh_CN/dealer-earning.php new file mode 100644 index 00000000..5cc89b99 --- /dev/null +++ b/resources/lang/zh_CN/dealer-earning.php @@ -0,0 +1,33 @@ + [ + 'DealerEarning' => '资金明细', + 'dealer-earnings' => '资金明细', + ], + 'fields' => [ + 'user_id' => '用户', + 'user'=>[ + 'phone' => '手机号', + ], + 'earningable_type' => 'earningable_type', + 'earningable_id' => 'earningable_id', + 'type_name' => '资金类型', + 'lvl' => '经销商等级', + 'is_manager' => '管理者', + 'total_amount' => '总金额', + 'total_earnings' => '总收入', + 'fee' => '手续费', + 'fee_rate' => '手续费率', + 'payer_id' => '付款人', + 'pay_info' => '收款信息', + 'pay_at' => '付款时间', + 'settle_at' => '结算时间', + 'status' => '状态', + 'status_format' => '状态', + 'remark' => '备注', + 'pay_image' => '打款凭证', + ], + 'options' => [ + ], +];