From 6fa29524670ee012f8d2c9a062070283d2d2f2ac Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Fri, 14 Jan 2022 21:04:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=8E=E5=8F=B0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Actions/Grid/DealerOrderPaid.php | 62 ++++++++ .../Actions/Grid/DealerOrderShipping.php | 62 ++++++++ .../Controllers/DealerOrderController.php | 132 ++++++++++++++++++ app/Admin/Repositories/DealerOrder.php | 16 +++ app/Admin/routes.php | 3 + app/Enums/DealerOrderStatus.php | 13 ++ app/Models/DealerOrder.php | 5 + app/Services/Dealer/OrderService.php | 2 +- database/seeders/AdAddressSeeder.php | 30 ++++ dcat_admin_ide_helper.php | 60 ++++++-- resources/lang/zh_CN/dealer-order.php | 36 +++++ 11 files changed, 408 insertions(+), 13 deletions(-) create mode 100644 app/Admin/Actions/Grid/DealerOrderPaid.php create mode 100644 app/Admin/Actions/Grid/DealerOrderShipping.php create mode 100644 app/Admin/Controllers/DealerOrderController.php create mode 100644 app/Admin/Repositories/DealerOrder.php create mode 100644 resources/lang/zh_CN/dealer-order.php diff --git a/app/Admin/Actions/Grid/DealerOrderPaid.php b/app/Admin/Actions/Grid/DealerOrderPaid.php new file mode 100644 index 00000000..a70b5edf --- /dev/null +++ b/app/Admin/Actions/Grid/DealerOrderPaid.php @@ -0,0 +1,62 @@ +title) { + return $this->title; + } + return ' 确认收款   '; + } + + /** + * @param Model|Authenticatable|HasPermissions|null $user + * + * @return bool + */ + protected function authorize($user): bool + { + return $user->can('dcat.admin.dealer.paid'); + } + + /** + * Handle the action request. + * + * @param Request $request + * + * @return Response + */ + public function handle(Request $request) + { + $order = DealerOrder::findOrFail($this->getKey()); + try { + DB::beginTransaction(); + (new OrderService())->paidOrder($order); + DB::commit(); + } catch (Throwable $th) { + DB::rollBack(); + report($th); + return $this->response()->error('操作失败,'.$th->getMessage())->refresh(); + } + + return $this->response()->success('操作成功')->refresh(); + } + + /** + * @return string|array|void + */ + public function confirm() + { + return ['确认当前订单已收款?', '确认后将无法逆操作']; + } +} diff --git a/app/Admin/Actions/Grid/DealerOrderShipping.php b/app/Admin/Actions/Grid/DealerOrderShipping.php new file mode 100644 index 00000000..ae2a1f06 --- /dev/null +++ b/app/Admin/Actions/Grid/DealerOrderShipping.php @@ -0,0 +1,62 @@ +title) { + return $this->title; + } + return ' 确认发货   '; + } + + /** + * @param Model|Authenticatable|HasPermissions|null $user + * + * @return bool + */ + protected function authorize($user): bool + { + return $user->can('dcat.admin.dealer.shipping'); + } + + /** + * Handle the action request. + * + * @param Request $request + * + * @return Response + */ + public function handle(Request $request) + { + $order = DealerOrder::findOrFail($this->getKey()); + try { + DB::beginTransaction(); + (new OrderService())->shippingOrder($order); + DB::commit(); + } catch (Throwable $th) { + DB::rollBack(); + report($th); + return $this->response()->error('操作失败,'.$th->getMessage())->refresh(); + } + + return $this->response()->success('操作成功')->refresh(); + } + + /** + * @return string|array|void + */ + public function confirm() + { + return ['确认当前订单已发货?', '确认后将无法逆操作']; + } +} diff --git a/app/Admin/Controllers/DealerOrderController.php b/app/Admin/Controllers/DealerOrderController.php new file mode 100644 index 00000000..42f359bf --- /dev/null +++ b/app/Admin/Controllers/DealerOrderController.php @@ -0,0 +1,132 @@ +column('id')->sortable(); + $grid->column('sn'); + $grid->column('user.phone')->copyable(); + $grid->column('consignor.phone')->display(function ($value) { + return $value??'系统'; + }); + $grid->column('total_amount')->prepend('¥'); + $statusTexts = DealerOrderStatus::texts(); + + $grid->column('order_status')->display(function ($v) { + return $this->order_status; + })->using($statusTexts)->dot([ + DealerOrderStatus::Pending->value => 'primary', + DealerOrderStatus::Paying->value => 'danger', + DealerOrderStatus::Confirming->value => 'warning', + DealerOrderStatus::Paid->value => 'danger', + DealerOrderStatus::Shipped->value => 'warning', + DealerOrderStatus::Completed->value => 'success', + DealerOrderStatus::Cancelled->value => '#b3b9bf', + ]); + // $grid->column('settle_state'); + // $grid->column('pay_info'); + // $grid->column('pay_image'); + // $grid->column('pay_time'); + // $grid->column('paied_time'); + // $grid->column('shipping_time'); + // $grid->column('shippinged_time'); + $grid->column('created_at')->sortable(); + // $grid->column('updated_at')->sortable(); + $grid->actions(function (Grid\Displayers\Actions $actions) { + if ($actions->row->status == DealerOrderStatus::Confirming && Admin::user()->can('dcat.admin.dealers_orders.paid')) { + $actions->append(new DealerOrderPaid()); + } + if ($actions->row->status == DealerOrderStatus::Paid && Admin::user()->can('dcat.admin.dealers_orders.shipping')) { + $actions->append(new DealerOrderShipping()); + } + }); + $grid->filter(function (Grid\Filter $filter) { + $filter->panel(); + // $filter->equal('id'); + }); + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + return Show::make($id, new DealerOrder(), function (Show $show) { + $show->field('id'); + $show->field('sn'); + $show->field('user_id'); + $show->field('consignor_id'); + $show->field('total_amount'); + $show->field('status'); + $show->field('settle_state'); + $show->field('consignee_name'); + $show->field('consignee_telephone'); + $show->field('consignee_zone'); + $show->field('consignee_address'); + $show->field('pay_info'); + $show->field('pay_image'); + $show->field('pay_time'); + $show->field('paied_time'); + $show->field('shipping_time'); + $show->field('shippinged_time'); + $show->field('created_at'); + $show->field('updated_at'); + }); + } + + /** + * Make a form builder. + * + * @return Form + */ + protected function form() + { + return Form::make(new DealerOrder(), function (Form $form) { + $form->display('id'); + $form->text('sn'); + $form->text('user_id'); + $form->text('consignor_id'); + $form->text('total_amount'); + $form->text('status'); + $form->text('settle_state'); + $form->text('consignee_name'); + $form->text('consignee_telephone'); + $form->text('consignee_zone'); + $form->text('consignee_address'); + $form->text('pay_info'); + $form->text('pay_image'); + $form->text('pay_time'); + $form->text('paied_time'); + $form->text('shipping_time'); + $form->text('shippinged_time'); + + $form->display('created_at'); + $form->display('updated_at'); + }); + } +} diff --git a/app/Admin/Repositories/DealerOrder.php b/app/Admin/Repositories/DealerOrder.php new file mode 100644 index 00000000..b7958846 --- /dev/null +++ b/app/Admin/Repositories/DealerOrder.php @@ -0,0 +1,16 @@ +resource('dealer-products', 'DealerProductController')->names('dealer_products'); + $router->resource('dealer-orders', 'DealerOrderController')->only([ + 'index', 'edit', 'update', + ])->names('dealer_orders'); /** api接口 **/ $router->get('api/product-categories', 'ProductCategoryController@categories')->name('api.product_categories'); diff --git a/app/Enums/DealerOrderStatus.php b/app/Enums/DealerOrderStatus.php index 89e96c54..a109c79e 100644 --- a/app/Enums/DealerOrderStatus.php +++ b/app/Enums/DealerOrderStatus.php @@ -10,4 +10,17 @@ enum DealerOrderStatus: int { case Shipped = 4; // 已发货 待收货 case Completed = 9; // 已完成 case Cancelled = 10; // 已取消 + + public static function texts(): array + { + return [ + static::Pending->value => '待确认', + static::Paying->value => '待付款', + static::Confirming->value => '待收款', + static::Paid->value => '待发货', + static::Shipped->value => '待收货', + static::Completed->value => '已完成', + static::Cancelled->value => '已取消', + ]; + } } diff --git a/app/Models/DealerOrder.php b/app/Models/DealerOrder.php index 7fd49d1d..6c9638a7 100644 --- a/app/Models/DealerOrder.php +++ b/app/Models/DealerOrder.php @@ -45,6 +45,11 @@ class DealerOrder extends Model 'shippinged_time', ]; + public function getOrderStatusAttribute() + { + return $this->status->value; + } + /** * 获取待确认订单 */ diff --git a/app/Services/Dealer/OrderService.php b/app/Services/Dealer/OrderService.php index 9584ac75..ddfc768a 100644 --- a/app/Services/Dealer/OrderService.php +++ b/app/Services/Dealer/OrderService.php @@ -107,7 +107,7 @@ class OrderService ]); if (!$order->consignor) {//如果订单分配给公司,则直接确认 - $order->confirmOrder(); + $this->confirmOrder($order); } return $order; diff --git a/database/seeders/AdAddressSeeder.php b/database/seeders/AdAddressSeeder.php index eb788f55..63ba35a0 100644 --- a/database/seeders/AdAddressSeeder.php +++ b/database/seeders/AdAddressSeeder.php @@ -95,6 +95,36 @@ class AdAddressSeeder extends Seeder 'dimensions'=> '600*700', 'is_show'=> true, ], + 'article_banner'=>[ + 'name' =>'文章广告位', + 'dimensions'=> '', + 'is_show'=> true, + ], + 'vip_coupon_banner'=>[ + 'name' =>'会员优惠券广告位', + 'dimensions'=> '750*524', + 'is_show'=> true, + ], + 'mall_notice'=>[ + 'name' =>'商城公告广告位', + 'dimensions'=> '600*700', + 'is_show'=> true, + ], + 'merchant_notice'=>[ + 'name' =>'商户公告广告位', + 'dimensions'=> '600*700', + 'is_show'=> true, + ], + 'homepage_popup'=>[ + 'name' =>'首页弹窗广告位', + 'dimensions'=> '608*735', + 'is_show'=> true, + ], + 'wholesale_homepage_banner'=>[ + 'name' =>'批零首页广告位', + 'dimensions'=> '750*550', + 'is_show'=> true, + ], ] as $key => $values) { AdAddress::firstOrCreate(['key' => $key], $values); } diff --git a/dcat_admin_ide_helper.php b/dcat_admin_ide_helper.php index ce441304..9ee98225 100644 --- a/dcat_admin_ide_helper.php +++ b/dcat_admin_ide_helper.php @@ -107,8 +107,12 @@ namespace Dcat\Admin { * @property Grid\Column|Collection use_day * @property Grid\Column|Collection use_end_at * @property Grid\Column|Collection use_start_at - * @property Grid\Column|Collection price + * @property Grid\Column|Collection lvl + * @property Grid\Column|Collection order_completed_at * @property Grid\Column|Collection product_id + * @property Grid\Column|Collection sales_volume + * @property Grid\Column|Collection total_amount + * @property Grid\Column|Collection price * @property Grid\Column|Collection qty * @property Grid\Column|Collection sale_price * @property Grid\Column|Collection consignee_address @@ -123,11 +127,15 @@ namespace Dcat\Admin { * @property Grid\Column|Collection settle_state * @property Grid\Column|Collection shipping_time * @property Grid\Column|Collection shippinged_time - * @property Grid\Column|Collection total_amount - * @property Grid\Column|Collection lvl * @property Grid\Column|Collection min_order_amount + * @property Grid\Column|Collection price_1st + * @property Grid\Column|Collection price_2st + * @property Grid\Column|Collection price_3st * @property Grid\Column|Collection is_sale + * @property Grid\Column|Collection manager_subsidy * @property Grid\Column|Collection sales_count + * @property Grid\Column|Collection unit + * @property Grid\Column|Collection is_manager * @property Grid\Column|Collection failed_reason * @property Grid\Column|Collection jobable_id * @property Grid\Column|Collection jobable_type @@ -258,6 +266,7 @@ namespace Dcat\Admin { * @property Grid\Column|Collection pre_growth_value * @property Grid\Column|Collection quota_v1 * @property Grid\Column|Collection quota_v2 + * @property Grid\Column|Collection real_inviter_id * @property Grid\Column|Collection vip_id * @property Grid\Column|Collection email * @property Grid\Column|Collection email_verified_at @@ -368,8 +377,12 @@ namespace Dcat\Admin { * @method Grid\Column|Collection use_day(string $label = null) * @method Grid\Column|Collection use_end_at(string $label = null) * @method Grid\Column|Collection use_start_at(string $label = null) - * @method Grid\Column|Collection price(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 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 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 consignee_address(string $label = null) @@ -384,11 +397,15 @@ namespace Dcat\Admin { * @method Grid\Column|Collection settle_state(string $label = null) * @method Grid\Column|Collection shipping_time(string $label = null) * @method Grid\Column|Collection shippinged_time(string $label = null) - * @method Grid\Column|Collection total_amount(string $label = null) - * @method Grid\Column|Collection lvl(string $label = null) * @method Grid\Column|Collection min_order_amount(string $label = null) + * @method Grid\Column|Collection price_1st(string $label = null) + * @method Grid\Column|Collection price_2st(string $label = null) + * @method Grid\Column|Collection price_3st(string $label = null) * @method Grid\Column|Collection is_sale(string $label = null) + * @method Grid\Column|Collection manager_subsidy(string $label = null) * @method Grid\Column|Collection sales_count(string $label = null) + * @method Grid\Column|Collection unit(string $label = null) + * @method Grid\Column|Collection is_manager(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) @@ -519,6 +536,7 @@ namespace Dcat\Admin { * @method Grid\Column|Collection pre_growth_value(string $label = null) * @method Grid\Column|Collection quota_v1(string $label = null) * @method Grid\Column|Collection quota_v2(string $label = null) + * @method Grid\Column|Collection real_inviter_id(string $label = null) * @method Grid\Column|Collection vip_id(string $label = null) * @method Grid\Column|Collection email(string $label = null) * @method Grid\Column|Collection email_verified_at(string $label = null) @@ -634,8 +652,12 @@ namespace Dcat\Admin { * @property Show\Field|Collection use_day * @property Show\Field|Collection use_end_at * @property Show\Field|Collection use_start_at - * @property Show\Field|Collection price + * @property Show\Field|Collection lvl + * @property Show\Field|Collection order_completed_at * @property Show\Field|Collection product_id + * @property Show\Field|Collection sales_volume + * @property Show\Field|Collection total_amount + * @property Show\Field|Collection price * @property Show\Field|Collection qty * @property Show\Field|Collection sale_price * @property Show\Field|Collection consignee_address @@ -650,11 +672,15 @@ namespace Dcat\Admin { * @property Show\Field|Collection settle_state * @property Show\Field|Collection shipping_time * @property Show\Field|Collection shippinged_time - * @property Show\Field|Collection total_amount - * @property Show\Field|Collection lvl * @property Show\Field|Collection min_order_amount + * @property Show\Field|Collection price_1st + * @property Show\Field|Collection price_2st + * @property Show\Field|Collection price_3st * @property Show\Field|Collection is_sale + * @property Show\Field|Collection manager_subsidy * @property Show\Field|Collection sales_count + * @property Show\Field|Collection unit + * @property Show\Field|Collection is_manager * @property Show\Field|Collection failed_reason * @property Show\Field|Collection jobable_id * @property Show\Field|Collection jobable_type @@ -785,6 +811,7 @@ namespace Dcat\Admin { * @property Show\Field|Collection pre_growth_value * @property Show\Field|Collection quota_v1 * @property Show\Field|Collection quota_v2 + * @property Show\Field|Collection real_inviter_id * @property Show\Field|Collection vip_id * @property Show\Field|Collection email * @property Show\Field|Collection email_verified_at @@ -895,8 +922,12 @@ namespace Dcat\Admin { * @method Show\Field|Collection use_day(string $label = null) * @method Show\Field|Collection use_end_at(string $label = null) * @method Show\Field|Collection use_start_at(string $label = null) - * @method Show\Field|Collection price(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 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 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 consignee_address(string $label = null) @@ -911,11 +942,15 @@ namespace Dcat\Admin { * @method Show\Field|Collection settle_state(string $label = null) * @method Show\Field|Collection shipping_time(string $label = null) * @method Show\Field|Collection shippinged_time(string $label = null) - * @method Show\Field|Collection total_amount(string $label = null) - * @method Show\Field|Collection lvl(string $label = null) * @method Show\Field|Collection min_order_amount(string $label = null) + * @method Show\Field|Collection price_1st(string $label = null) + * @method Show\Field|Collection price_2st(string $label = null) + * @method Show\Field|Collection price_3st(string $label = null) * @method Show\Field|Collection is_sale(string $label = null) + * @method Show\Field|Collection manager_subsidy(string $label = null) * @method Show\Field|Collection sales_count(string $label = null) + * @method Show\Field|Collection unit(string $label = null) + * @method Show\Field|Collection is_manager(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) @@ -1046,6 +1081,7 @@ namespace Dcat\Admin { * @method Show\Field|Collection pre_growth_value(string $label = null) * @method Show\Field|Collection quota_v1(string $label = null) * @method Show\Field|Collection quota_v2(string $label = null) + * @method Show\Field|Collection real_inviter_id(string $label = null) * @method Show\Field|Collection vip_id(string $label = null) * @method Show\Field|Collection email(string $label = null) * @method Show\Field|Collection email_verified_at(string $label = null) diff --git a/resources/lang/zh_CN/dealer-order.php b/resources/lang/zh_CN/dealer-order.php new file mode 100644 index 00000000..fea8c0ba --- /dev/null +++ b/resources/lang/zh_CN/dealer-order.php @@ -0,0 +1,36 @@ + [ + 'DealerOrder' => 'DealerOrder', + 'dealer-order' => 'DealerOrder', + ], + 'fields' => [ + 'sn' => '订单编号', + 'user_id' => '下单用户', + 'user'=>[ + 'phone' => '下单用户', + ], + 'consignor_id' => '发货用户', + 'consignor' => [ + 'phone' => '发货用户', + ], + 'total_amount' => '订单价格', + 'status' => '状态', + 'order_status'=>'状态', + 'settle_state' => '结算状态', + 'consignee_name' => '收货人姓名', + 'consignee_telephone' => '收货人联系方式', + 'consignee_zone' => '收货人所在地区', + 'consignee_address' => '收货人详细地址', + 'pay_info' => '收款信息', + 'pay_image' => '打款凭证', + 'pay_time' => '支付时间', + 'paied_time' => '确认收款时间', + 'shipping_time' => '发货时间', + 'shippinged_time' => '确认收货时间', + 'created_at'=>'下单时间', + ], + 'options' => [ + ], +];