diff --git a/app/Actions/Dealer/CalculateManageSubsidiesOfCurrentPeriod.php b/app/Actions/Dealer/CalculateManageSubsidiesOfCurrentPeriod.php deleted file mode 100644 index ed7a0902..00000000 --- a/app/Actions/Dealer/CalculateManageSubsidiesOfCurrentPeriod.php +++ /dev/null @@ -1,30 +0,0 @@ -day >= 20) { - $startAt = $tz->copy()->setDay(20)->startOfDay(); - } elseif ($tz->day >= 5) { - $startAt = $tz->copy()->setDay(5)->startOfDay(); - } else { - $startAt = $tz->copy()->subMonthNoOverflow()->setDay(20)->startOfDay(); - } - - $total = DealerManageSubsidyLog::where('order_completed_at', '>=', $startAt)->where('user_id', $dealer->user_id)->sum('total_amount'); - - return bcmul($total, '1', 2); - } -} diff --git a/app/Actions/Dealer/CalculatePurchaseAmount.php b/app/Actions/Dealer/CalculatePurchaseAmount.php deleted file mode 100644 index 9aca8883..00000000 --- a/app/Actions/Dealer/CalculatePurchaseAmount.php +++ /dev/null @@ -1,35 +0,0 @@ -whereBetween('order_completed_at', [$start, $end]); - } else { - $query->when($start, function ($query, $start) { - $query->where('order_completed_at', '>=', $start); - })->when($end, function ($query, $end) { - $query->where('order_completed_at', '<=', $end); - }); - } - - return $query->where('path', 'like', "{$dealer->userInfo->full_path}%")->sum('total_amount'); - } -} diff --git a/app/Actions/Dealer/CalculatePurchaseAmountOfCurrentPeriod.php b/app/Actions/Dealer/CalculatePurchaseAmountOfCurrentPeriod.php deleted file mode 100644 index d4d86243..00000000 --- a/app/Actions/Dealer/CalculatePurchaseAmountOfCurrentPeriod.php +++ /dev/null @@ -1,32 +0,0 @@ -day >= 20) { - $startAt = $tz->setDay(20)->startOfDay(); - } else { - $startAt = $tz->subMonthNoOverflow()->setDay(20)->startOfDay(); - } - - return bcmul($this->calculatePurchaseAmount->handle($dealer, $startAt), '1', 2); - } -} diff --git a/app/Admin/Actions/Grid/DealerBonds.php b/app/Admin/Actions/Grid/DealerBonds.php deleted file mode 100644 index 20d8034e..00000000 --- a/app/Admin/Actions/Grid/DealerBonds.php +++ /dev/null @@ -1,38 +0,0 @@ -title) { - return $this->title; - } - return ' 保证金   '; - } - - /** - * @param Model|Authenticatable|HasPermissions|null $user - * - * @return bool - */ - protected function authorize($user): bool - { - return $user->can('dcat.admin.dealers.bonds'); - } - - public function render() - { - $form = DealerBondsForm::make()->payload(['id'=>$this->getKey()]); - return Modal::make() - ->lg() - ->title($this->title()) - ->body($form) - ->button($this->title()); - } -} diff --git a/app/Admin/Actions/Grid/DealerChannelSubsidyBatchPay.php b/app/Admin/Actions/Grid/DealerChannelSubsidyBatchPay.php deleted file mode 100644 index 372217f9..00000000 --- a/app/Admin/Actions/Grid/DealerChannelSubsidyBatchPay.php +++ /dev/null @@ -1,53 +0,0 @@ - 付款'; - - /** - * @param Model|Authenticatable|HasPermissions|null $user - * - * @return bool - */ - protected function authorize($user): bool - { - return $user->can('dcat.admin.dealer_channel_subsidies.batch_pay'); - } - - // 确认弹窗信息 - public function confirm() - { - return '您确定要支付选中的渠道补贴吗?'; - } - - // 处理请求 - public function handle(Request $request) - { - try { - DB::transaction(function () { - foreach ($this->getKey() as $id) { - $dealerEarning = DealerEarning::lockForUpdate()->channelSubsidy()->withoutPayer()->find($id); - - if (! $dealerEarning?->isSettled() || ! $dealerEarning?->isPending()) { - continue; - } - - (new DealerEarningService())->pay($dealerEarning); - } - }); - } catch (Throwable $e) { - return $this->response()->error('操作失败:'.$e->getMessage())->refresh(); - } - - return $this->response()->success('操作成功')->refresh(); - } -} diff --git a/app/Admin/Actions/Grid/DealerChannelSubsidyPay.php b/app/Admin/Actions/Grid/DealerChannelSubsidyPay.php deleted file mode 100644 index 4566557f..00000000 --- a/app/Admin/Actions/Grid/DealerChannelSubsidyPay.php +++ /dev/null @@ -1,44 +0,0 @@ - 付款'; - - /** - * @param Model|Authenticatable|HasPermissions|null $user - * - * @return bool - */ - protected function authorize($user): bool - { - return $user->can('dcat.admin.dealer_channel_subsidies.pay'); - } - - // 确认弹窗信息 - public function confirm() - { - return '您确定要支付选中的渠道补贴吗?'; - } - - // 处理请求 - public function handle(Request $request) - { - DB::transaction(function () { - $id = $this->getKey(); - - $dealerEarning = DealerEarning::lockForUpdate()->channelSubsidy()->withoutPayer()->find($id); - - (new DealerEarningService())->pay($dealerEarning); - }); - - return $this->response()->success('操作成功')->refresh(); - } -} diff --git a/app/Admin/Actions/Grid/DealerDeliveryShipping.php b/app/Admin/Actions/Grid/DealerDeliveryShipping.php deleted file mode 100644 index 93434970..00000000 --- a/app/Admin/Actions/Grid/DealerDeliveryShipping.php +++ /dev/null @@ -1,67 +0,0 @@ -title) { - return $this->title; - } - return ' 确认发货   '; - } - - /** - * @param Model|Authenticatable|HasPermissions|null $user - * - * @return bool - */ - protected function authorize($user): bool - { - return true; - return $user->can('dcat.admin.dealer_delivery_bills.shipping'); - } - - /** - * Handle the action request. - * - * @param Request $request - * - * @return Response - */ - public function handle(Request $request) - { - $order = DealerDeliveryBill::findOrFail($this->getKey()); - try { - DB::beginTransaction(); - - $order->update([ - 'status' => DealerDeliveryBillStatus::Shippinged, - ]); - - 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/DealerEditLvl.php b/app/Admin/Actions/Grid/DealerEditLvl.php deleted file mode 100644 index 69ca8638..00000000 --- a/app/Admin/Actions/Grid/DealerEditLvl.php +++ /dev/null @@ -1,38 +0,0 @@ -title) { - return $this->title; - } - return ' 修改等级  '; - } - - /** - * @param Model|Authenticatable|HasPermissions|null $user - * - * @return bool - */ - protected function authorize($user): bool - { - return $user->can('dcat.admin.dealers.edit_lvl'); - } - - public function render() - { - $form = DealerEditLvlForm::make()->payload(['id'=>$this->getKey()]); - return Modal::make() - ->lg() - ->title($this->title()) - ->body($form) - ->button($this->title()); - } -} diff --git a/app/Admin/Actions/Grid/DealerEditProduct.php b/app/Admin/Actions/Grid/DealerEditProduct.php deleted file mode 100644 index 86a583b4..00000000 --- a/app/Admin/Actions/Grid/DealerEditProduct.php +++ /dev/null @@ -1,40 +0,0 @@ -title) { - return $this->title; - } - return ' 修改库存  '; - } - - /** - * @param Model|Authenticatable|HasPermissions|null $user - * - * @return bool - */ - protected function authorize($user): bool - { - return $user->can('dcat.admin.dealers.edit_product'); - } - - public function render() - { - $form = DealerEditProductForm::make()->payload(['id'=>$this->primaryKey]); - // $grid = DealerUserProductSimpleTable::make(['id'=>$this->primaryKey]); - return Modal::make() - ->lg() - ->title($this->title()) - ->body($form) - ->button($this->title()); - } -} diff --git a/app/Admin/Actions/Grid/DealerManageSubsidyBatchPay.php b/app/Admin/Actions/Grid/DealerManageSubsidyBatchPay.php deleted file mode 100644 index de1253db..00000000 --- a/app/Admin/Actions/Grid/DealerManageSubsidyBatchPay.php +++ /dev/null @@ -1,53 +0,0 @@ - 付款'; - - /** - * @param Model|Authenticatable|HasPermissions|null $user - * - * @return bool - */ - protected function authorize($user): bool - { - return $user->can('dcat.admin.dealer_manage_subsidies.batch_pay'); - } - - // 确认弹窗信息 - public function confirm() - { - return '您确定要支付选中的管理津贴吗?'; - } - - // 处理请求 - public function handle(Request $request) - { - try { - DB::transaction(function () { - foreach ($this->getKey() as $id) { - $dealerManageSubsidy = DealerManageSubsidy::lockForUpdate()->settled()->find($id); - - if ($dealerManageSubsidy?->isPending()) { - (new DealerEarningService())->pay( - $dealerManageSubsidy->earning->setRelation('earningable', $dealerManageSubsidy) - ); - } - } - }); - } catch (Throwable $e) { - return $this->response()->error('操作失败:'.$e->getMessage())->refresh(); - } - - return $this->response()->success('操作成功')->refresh(); - } -} diff --git a/app/Admin/Actions/Grid/DealerManageSubsidyPay.php b/app/Admin/Actions/Grid/DealerManageSubsidyPay.php deleted file mode 100644 index b4300891..00000000 --- a/app/Admin/Actions/Grid/DealerManageSubsidyPay.php +++ /dev/null @@ -1,46 +0,0 @@ - 付款'; - - /** - * @param Model|Authenticatable|HasPermissions|null $user - * - * @return bool - */ - protected function authorize($user): bool - { - return $user->can('dcat.admin.dealer_manage_subsidies.pay'); - } - - // 确认弹窗信息 - public function confirm() - { - return '您确定要支付选中的管理津贴吗?'; - } - - // 处理请求 - public function handle(Request $request) - { - DB::transaction(function () { - $id = $this->getKey(); - - $dealerManageSubsidy = DealerManageSubsidy::lockForUpdate()->settled()->findOrFail($id); - - (new DealerEarningService())->pay( - $dealerManageSubsidy->earning->setRelation('earningable', $dealerManageSubsidy) - ); - }); - - return $this->response()->success('操作成功')->refresh(); - } -} diff --git a/app/Admin/Actions/Grid/DealerManagerSubsidyBatchPay.php b/app/Admin/Actions/Grid/DealerManagerSubsidyBatchPay.php deleted file mode 100644 index 10457f03..00000000 --- a/app/Admin/Actions/Grid/DealerManagerSubsidyBatchPay.php +++ /dev/null @@ -1,53 +0,0 @@ - 付款'; - - /** - * @param Model|Authenticatable|HasPermissions|null $user - * - * @return bool - */ - protected function authorize($user): bool - { - return $user->can('dcat.admin.dealer_manager_subsidies.batch_pay'); - } - - // 确认弹窗信息 - public function confirm() - { - return '您确定要支付选中的管理者津贴吗?'; - } - - // 处理请求 - public function handle(Request $request) - { - try { - DB::transaction(function () { - foreach ($this->getKey() as $id) { - $dealerManagerSubsidy = DealerManagerSubsidy::lockForUpdate()->settled()->find($id); - - if ($dealerManagerSubsidy?->isPending()) { - (new DealerEarningService())->pay( - $dealerManagerSubsidy->earning->setRelation('earningable', $dealerManagerSubsidy) - ); - } - } - }); - } catch (Throwable $e) { - return $this->response()->error('操作失败:'.$e->getMessage())->refresh(); - } - - return $this->response()->success('操作成功')->refresh(); - } -} diff --git a/app/Admin/Actions/Grid/DealerManagerSubsidyPay.php b/app/Admin/Actions/Grid/DealerManagerSubsidyPay.php deleted file mode 100644 index b0dfb63b..00000000 --- a/app/Admin/Actions/Grid/DealerManagerSubsidyPay.php +++ /dev/null @@ -1,46 +0,0 @@ - 付款'; - - /** - * @param Model|Authenticatable|HasPermissions|null $user - * - * @return bool - */ - protected function authorize($user): bool - { - return $user->can('dcat.admin.dealer_manager_subsidies.pay'); - } - - // 确认弹窗信息 - public function confirm() - { - return '您确定要支付选中的管理者津贴吗?'; - } - - // 处理请求 - public function handle(Request $request) - { - DB::transaction(function () { - $id = $this->getKey(); - - $dealerManagerSubsidy = DealerManagerSubsidy::lockForUpdate()->settled()->findOrFail($id); - - (new DealerEarningService())->pay( - $dealerManagerSubsidy->earning->setRelation('earningable', $dealerManagerSubsidy) - ); - }); - - return $this->response()->success('操作成功')->refresh(); - } -} diff --git a/app/Admin/Actions/Grid/DealerOrderAllocate.php b/app/Admin/Actions/Grid/DealerOrderAllocate.php deleted file mode 100644 index ed2a97f6..00000000 --- a/app/Admin/Actions/Grid/DealerOrderAllocate.php +++ /dev/null @@ -1,62 +0,0 @@ -title) { - return $this->title; - } - return ' 分配订单   '; - } - - /** - * @param Model|Authenticatable|HasPermissions|null $user - * - * @return bool - */ - protected function authorize($user): bool - { - return $user->can('dcat.admin.dealer_orders.allocate'); - } - - /** - * Handle the action request. - * - * @param Request $request - * - * @return Response - */ - public function handle(Request $request) - { - $order = DealerOrder::findOrFail($this->getKey()); - try { - DB::beginTransaction(); - (new OrderService())->updateOrderConsignor($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/DealerOrderCancel.php b/app/Admin/Actions/Grid/DealerOrderCancel.php deleted file mode 100644 index bd06b1c6..00000000 --- a/app/Admin/Actions/Grid/DealerOrderCancel.php +++ /dev/null @@ -1,62 +0,0 @@ -title) { - return $this->title; - } - return ' 取消订单   '; - } - - /** - * @param Model|Authenticatable|HasPermissions|null $user - * - * @return bool - */ - protected function authorize($user): bool - { - return $user->can('dcat.admin.dealer_orders.cancel'); - } - - /** - * Handle the action request. - * - * @param Request $request - * - * @return Response - */ - public function handle(Request $request) - { - $order = DealerOrder::findOrFail($this->getKey()); - try { - DB::beginTransaction(); - (new OrderService())->cancelOrder($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/DealerOrderPaid.php b/app/Admin/Actions/Grid/DealerOrderPaid.php deleted file mode 100644 index bbd52c70..00000000 --- a/app/Admin/Actions/Grid/DealerOrderPaid.php +++ /dev/null @@ -1,62 +0,0 @@ -title) { - return $this->title; - } - return ' 确认收款   '; - } - - /** - * @param Model|Authenticatable|HasPermissions|null $user - * - * @return bool - */ - protected function authorize($user): bool - { - return $user->can('dcat.admin.dealer_orders.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/DealerOrderRefuse.php b/app/Admin/Actions/Grid/DealerOrderRefuse.php deleted file mode 100644 index 1b186e2a..00000000 --- a/app/Admin/Actions/Grid/DealerOrderRefuse.php +++ /dev/null @@ -1,21 +0,0 @@ -payload(['id' => $this->getKey()]); - - return Modal::make() - ->lg() - ->title('拒绝收款') - ->body($form) - ->button(' 拒绝收款   '); - } -} diff --git a/app/Admin/Actions/Grid/DealerOrderShipping.php b/app/Admin/Actions/Grid/DealerOrderShipping.php deleted file mode 100644 index 65b75f10..00000000 --- a/app/Admin/Actions/Grid/DealerOrderShipping.php +++ /dev/null @@ -1,70 +0,0 @@ -title) { - return $this->title; - } - return ' 确认发货   '; - } - - /** - * @param Model|Authenticatable|HasPermissions|null $user - * - * @return bool - */ - protected function authorize($user): bool - { - return $user->can('dcat.admin.dealer_orders.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 (QueryException $e) { - DB::rollBack(); - if (strpos($e->getMessage(), 'Numeric value out of range') !== false) { - $e = new BizException('当前可发货库存不足'); - } - return $this->response()->error('操作失败,'.$e->getMessage())->refresh(); - } 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/DealerProductLvlRule.php b/app/Admin/Actions/Grid/DealerProductLvlRule.php deleted file mode 100644 index 1ff22d20..00000000 --- a/app/Admin/Actions/Grid/DealerProductLvlRule.php +++ /dev/null @@ -1,38 +0,0 @@ -title) { - return $this->title; - } - return ' 等级规则   '; - } - - /** - * @param Model|Authenticatable|HasPermissions|null $user - * - * @return bool - */ - protected function authorize($user): bool - { - return $user->can('dcat.admin.dealer_products.lvl_rules'); - } - - public function render() - { - $form = DealerProductLvlRuleForm::make()->payload(['id'=>$this->getKey()]); - return Modal::make() - ->lg() - ->title($this->title()) - ->body($form) - ->button($this->title()); - } -} diff --git a/app/Admin/Actions/Grid/DealerProductManageRule.php b/app/Admin/Actions/Grid/DealerProductManageRule.php deleted file mode 100644 index f1ebdf26..00000000 --- a/app/Admin/Actions/Grid/DealerProductManageRule.php +++ /dev/null @@ -1,38 +0,0 @@ -title) { - return $this->title; - } - return ' 管理规则   '; - } - - /** - * @param Model|Authenticatable|HasPermissions|null $user - * - * @return bool - */ - protected function authorize($user): bool - { - return $user->can('dcat.admin.dealer_products.manage_rules'); - } - - public function render() - { - $form = DealerProductManageRuleForm::make()->payload(['id'=>$this->getKey()]); - return Modal::make() - ->lg() - ->title($this->title()) - ->body($form) - ->button($this->title()); - } -} diff --git a/app/Admin/Actions/Grid/DealerProductSaleRule.php b/app/Admin/Actions/Grid/DealerProductSaleRule.php deleted file mode 100644 index 58cad4c2..00000000 --- a/app/Admin/Actions/Grid/DealerProductSaleRule.php +++ /dev/null @@ -1,38 +0,0 @@ -title) { - return $this->title; - } - return ' 销售规则   '; - } - - /** - * @param Model|Authenticatable|HasPermissions|null $user - * - * @return bool - */ - protected function authorize($user): bool - { - return $user->can('dcat.admin.dealer_products.sale_rules'); - } - - public function render() - { - $form = DealerProductSaleRuleForm::make()->payload(['id'=>$this->getKey()]); - return Modal::make() - ->lg() - ->title($this->title()) - ->body($form) - ->button($this->title()); - } -} diff --git a/app/Admin/Actions/Grid/DealerPurchaseSubsidyBatchPay.php b/app/Admin/Actions/Grid/DealerPurchaseSubsidyBatchPay.php deleted file mode 100644 index 59d95980..00000000 --- a/app/Admin/Actions/Grid/DealerPurchaseSubsidyBatchPay.php +++ /dev/null @@ -1,53 +0,0 @@ - 付款'; - - /** - * @param Model|Authenticatable|HasPermissions|null $user - * - * @return bool - */ - protected function authorize($user): bool - { - return $user->can('dcat.admin.dealer_purchase_subsidies.batch_pay'); - } - - // 确认弹窗信息 - public function confirm() - { - return '您确定要支付选中的进货补贴吗?'; - } - - // 处理请求 - public function handle(Request $request) - { - try { - DB::transaction(function () { - foreach ($this->getKey() as $id) { - $dealerPurchaseSubsidy = DealerPurchaseSubsidy::lockForUpdate()->settleCompleted()->find($id); - - if ($dealerPurchaseSubsidy?->isPending()) { - (new DealerEarningService())->pay( - $dealerPurchaseSubsidy->earning->setRelation('earningable', $dealerPurchaseSubsidy) - ); - } - } - }); - } catch (Throwable $e) { - return $this->response()->error('操作失败:'.$e->getMessage())->refresh(); - } - - return $this->response()->success('操作成功')->refresh(); - } -} diff --git a/app/Admin/Actions/Grid/DealerPurchaseSubsidyPay.php b/app/Admin/Actions/Grid/DealerPurchaseSubsidyPay.php deleted file mode 100644 index 5f3f714b..00000000 --- a/app/Admin/Actions/Grid/DealerPurchaseSubsidyPay.php +++ /dev/null @@ -1,46 +0,0 @@ - 付款'; - - /** - * @param Model|Authenticatable|HasPermissions|null $user - * - * @return bool - */ - protected function authorize($user): bool - { - return $user->can('dcat.admin.dealer_purchase_subsidies.pay'); - } - - // 确认弹窗信息 - public function confirm() - { - return '您确定要支付选中的进货补贴吗?'; - } - - // 处理请求 - public function handle(Request $request) - { - DB::transaction(function () { - $id = $this->getKey(); - - $dealerPurchaseSubsidy = DealerPurchaseSubsidy::lockForUpdate()->settleCompleted()->findOrFail($id); - - (new DealerEarningService())->pay( - $dealerPurchaseSubsidy->earning->setRelation('earningable', $dealerPurchaseSubsidy) - ); - }); - - return $this->response()->success('操作成功')->refresh(); - } -} diff --git a/app/Admin/Actions/Grid/DealerWalletChange.php b/app/Admin/Actions/Grid/DealerWalletChange.php deleted file mode 100644 index 0ea43526..00000000 --- a/app/Admin/Actions/Grid/DealerWalletChange.php +++ /dev/null @@ -1,36 +0,0 @@ - 变更余额  '; - } - - /** - * @param Model|Authenticatable|HasPermissions|null $user - * - * @return bool - */ - protected function authorize($user): bool - { - return $user->can('dcat.admin.dealers.wallet_change'); - } - - public function render() - { - $form = DealerWalletChangeForm::make()->payload(['id'=>$this->getKey()]); - - return Modal::make() - ->lg() - ->title($this->title()) - ->body($form) - ->button($this->title()); - } -} diff --git a/app/Admin/Actions/Grid/Exports/DealerWalletWithdraw.php b/app/Admin/Actions/Grid/Exports/DealerWalletWithdraw.php deleted file mode 100644 index a923b25f..00000000 --- a/app/Admin/Actions/Grid/Exports/DealerWalletWithdraw.php +++ /dev/null @@ -1,44 +0,0 @@ -title) { - return $this->title; - } - return ' 导出打款单  '; - } - - /** - * @param Model|Authenticatable|HasPermissions|null $user - * - * @return bool - */ - protected function authorize($user): bool - { - return $user->can('dcat.admin.dealer_wallet_to_bank_logs.export'); - } - - /** - * Handle the action request. - * - * @param Request $request - * - * @return Response - */ - public function handle(Request $request) - { - $last_path_arr = parse_url(session('admin.prev.url')); - return $this->response()->download(admin_route('dealer_wallet_to_bank_logs.export').'?'.($last_path_arr['query']??'')); - } -} diff --git a/app/Admin/Actions/Show/DealerEarningPay.php b/app/Admin/Actions/Show/DealerEarningPay.php deleted file mode 100644 index 913bf386..00000000 --- a/app/Admin/Actions/Show/DealerEarningPay.php +++ /dev/null @@ -1,100 +0,0 @@ - 打款'; - - /** - * 按钮样式定义,默认 btn btn-white waves-effect - * - * @var string - */ - protected $style = 'btn btn-sm btn-danger'; - - // public function render() - // { - // $form = DealerEarningPayForm::make()->payload(['id'=>$this->getKey()]); - // return Modal::make() - // ->lg() - // ->title($this->title) - // ->body($form) - // ->button("style}\">{$this->title}  "); - // } - - public function handle(Request $request) - { - // 获取主键 - $key = $this->getKey(); - - try { - DB::beginTransaction(); - $earning = DealerEarning::findOrFail($key); - $earning->update([ - 'pay_way' => DealerEarning::PAY_WAY_WALLET, - 'pay_info' => $earning->getPayInfo(), - 'pay_at' => now(), - 'status' => DealerEarningStatus::Completed, - ]); - //打款到余额; - $walletService = new WalletService(); - switch ($earning->earningable_type) { - case (new DealerManagerSubsidy())->getMorphClass(): - $action = DealerWalletAction::ManagerSubsidyIn; - break; - case (new DealerManageSubsidy())->getMorphClass(): - $action = DealerWalletAction::ManageSubsidyIn; - break; - case (new DealerChannelSubsidyLog())->getMorphClass(): - $action = DealerWalletAction::ChannelSubsidyIn; - break; - default: - $action = DealerWalletAction::PurchaseSubsidyIn; - break; - } - $walletService->changeBalance($earning->user, $earning->total_earnings, $action, '收入-'.$earning->earningable_type_text, $earning); - DB::commit(); - } catch (Throwable $th) { - DB::rollBack(); - report($th); - return $this->response()->error('操作失败:'.$th->getMessage()); - } - - return $this->response() - ->success(__('admin.update_succeeded')) - ->refresh(); - } - - public function html() - { - return parent::html().'  '; - } - - /** - * 确认弹窗信息,如不需要可以删除此方法 - * - * @return string|array|void - */ - public function confirm() - { - return ['是否确认打款?', '该操作不可逆,确认后将打款到余额。']; - } -} diff --git a/app/Admin/Actions/Show/DealerOrderRemark.php b/app/Admin/Actions/Show/DealerOrderRemark.php deleted file mode 100644 index 1bdbd565..00000000 --- a/app/Admin/Actions/Show/DealerOrderRemark.php +++ /dev/null @@ -1,32 +0,0 @@ - 备注'; - - /** - * 按钮样式定义,默认 btn btn-white waves-effect - * - * @var string - */ - protected $style = 'btn-success'; - - public function render() - { - $form = DealerOrderRemarkForm::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/DealerWalletPay.php b/app/Admin/Actions/Show/DealerWalletPay.php deleted file mode 100644 index 8ef3873d..00000000 --- a/app/Admin/Actions/Show/DealerWalletPay.php +++ /dev/null @@ -1,32 +0,0 @@ - 打款'; - - /** - * 按钮样式定义,默认 btn btn-white waves-effect - * - * @var string - */ - protected $style = 'btn-danger mr-1'; - - 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 deleted file mode 100644 index e3a7b6f7..00000000 --- a/app/Admin/Actions/Show/DealerWalletRefuse.php +++ /dev/null @@ -1,32 +0,0 @@ - 拒绝'; - - /** - * 按钮样式定义,默认 btn btn-white waves-effect - * - * @var string - */ - protected $style = 'btn-warning mr-1'; - - 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/DealerChannelSubsidyController.php b/app/Admin/Controllers/DealerChannelSubsidyController.php deleted file mode 100644 index 1bec7053..00000000 --- a/app/Admin/Controllers/DealerChannelSubsidyController.php +++ /dev/null @@ -1,125 +0,0 @@ -model()->channelSubsidy()->withoutPayer()->orderBy('id', 'desc'); - - $grid->column('id')->sortable(); - $grid->column('user.phone', '手机号'); - $grid->column('user.userInfo.nickname', '昵称'); - $grid->column('lvl', '经销商等级')->display(function () { - return $this->lvl->text(); - }); - $grid->column('total_amount', '补贴金额')->prepend('¥'); - $grid->column('fee', '手续费')->prepend('¥')->help('手续费=补贴金额*手续费率'); - $grid->column('fee_rate', '手续费率')->append('%'); - $grid->column('total_earnings', '总收入')->prepend('¥')->help('总收入=补贴金额-手续费'); - $grid->column('remark', '备注')->display('查看') // 设置按钮名称 - ->expand(function () { - $card = new Card(null, nl2br($this->remark)); - - return "
$card
"; - }); - $grid->column('settle_at', '结算时间')->display(function () { - return $this->settle_at?->toDateTimeString(); - })->sortable(); - $grid->column('status', '状态')->display(function ($v) { - return "  {$v->text()}"; - }); - $grid->column('pay_at', '付款时间')->display(function () { - return $this->pay_at?->toDateTimeString(); - })->sortable(); - $grid->column('created_at', '创建时间')->display(function () { - return $this->created_at?->toDateTimeString(); - }); - - // $grid->showRowSelector(); - // $grid->tools(function ($tools) { - // $tools->batch(function ($batch) { - // $batch->disableDelete(); - - // if (Admin::user()->can('dcat.admin.dealer_channel_subsidies.batch_pay')) { - // $batch->add(new DealerChannelSubsidyBatchPay()); - // } - // }); - // }); - - $grid->disableActions(); - // $grid->actions(function (Grid\Displayers\Actions $actions) { - // if ( - // $actions->row->isSettled() && - // $actions->row->isPending() && - // Admin::user()->can('dcat.admin.dealer_channel_subsidies.pay') - // ) { - // $actions->append(new DealerChannelSubsidyPay()); - // } - // }); - - $grid->filter(function (Grid\Filter $filter) { - $filter->panel(); - - $filter->equal('user.phone', '手机号')->width(3); - $filter->equal('status', '状态')->select([ - DealerEarningStatus::Pending->value => '待付款', - DealerEarningStatus::Completed->value => '已完成', - ])->width(3); - $filter->between('settle_at', '结算时间')->datetime()->width(6); - }); - - $grid->header(function ($collection) use ($grid) { - return tap(new Row(), function ($row) use ($grid) { - $query = DealerEarningModel::query(); - - $grid->model()->getQueries()->unique()->each(function ($value) use (&$query) { - if (in_array($value['method'], ['paginate', 'get', 'orderBy', 'orderByDesc'], true)) { - return; - } - - $query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []); - }); - - $totalAmount = (clone $query)->sum('total_amount'); - $totalFee = (clone $query)->sum('fee'); - - $row->column(3, new InfoBox('补贴金额', $totalAmount, 'fa fa-cny')); - $row->column(3, new InfoBox('手续费', $totalFee, 'fa fa-cny')); - }); - }); - }); - } -} diff --git a/app/Admin/Controllers/DealerController.php b/app/Admin/Controllers/DealerController.php deleted file mode 100644 index 6ad4341a..00000000 --- a/app/Admin/Controllers/DealerController.php +++ /dev/null @@ -1,242 +0,0 @@ -column('id')->sortable(); - $grid->column('user.phone')->copyable(); - $grid->column('userInfo.nickname'); - $grid->column('userInfo.inviterInfo.user.phone')->copyable(); - $grid->column('userInfo.realInviterInfo.user.phone')->copyable(); - // $grid->column('user_id'); - - $lvlTexts = DealerLvl::texts(); - $grid->column('lvl')->display(function () { - return $this->lvl->text(); - })->filter(Grid\Column\Filter\In::make($lvlTexts))->modal(function ($modal) { - // $modal->title('消费值'); - return DealerSubordinateCard::make(['id'=>$this->user_id]); - })->setHeaderAttributes(['style' => 'color:#5b69bc']); - $grid->column('wallet.balance')->display(function ($value) { - return $value ?? 0; - })->prepend('¥'); - $grid->column('is_sale') - ->if(function () { - return Admin::user()->can('dcat.admin.dealers.update'); - }) - ->then(function (Column $column) { - $column->switch(); - }) - ->else(function (Column $column) { - $column->bool(); - }); - $grid->column('is_manager') - ->if(function () { - return Admin::user()->can('dcat.admin.dealers.update'); - }) - ->then(function (Column $column) { - $column->switch(); - }) - ->else(function (Column $column) { - $column->bool(); - }); - $grid->column('bonds')->prepend('¥')->filter( - Grid\Column\Filter\Between::make() - ); - // $grid->column('created_at')->sortable(); - - $grid->actions(function (Grid\Displayers\Actions $actions) { - if (Admin::user()->can('dcat.admin.dealers.show')) { - $actions->append(' 显示   '); - } - if (Admin::user()->can('dcat.admin.dealers.edit_lvl')) { - $actions->append(new DealerEditLvl()); - } - if (Admin::user()->can('dcat.admin.dealers.wallet_change')) { - $actions->append(new DealerWalletChange()); - } - if ($actions->row->lvl->value >= DealerLvl::Special->value && Admin::user()->can('dcat.admin.dealers.bonds')) { - $actions->append(new DealerBonds()); - } - $actions->append((new DealerEditProduct())->setKey($actions->row->user_id)); - }); - - $grid->filter(function (Grid\Filter $filter) { - $filter->panel(); - $filter->equal('user.phone')->width(3); - $filter->equal('userInfo.inviterInfo.user.phone')->width(3); - $filter->equal('userInfo.realInviterInfo.user.phone')->width(3); - $filter->equal('userInfo.nickname')->width(4); - }); - }); - } - - /** - * Make a show builder. - * - * @param mixed $id - * - * @return Show - */ - protected function detail($id) - { - return function (Row $row) use ($id) { - $row->column(5, function ($column) use ($id) { - $builder = Dealer::with(['user', 'userInfo', 'userInfo.inviterInfo.user']); - $column->row(Show::make($id, $builder, function (Show $show) { - // $show->field('id'); - $show->field('user.phone'); - $show->field('userInfo.nickname')->as(function () { - return $this->userInfo->nickname; - }); - $show->field('lvl')->as(function () { - return $this->lvl->text(); - }); - $show->field('is_sale')->as(function ($val) { - return $val ? '是' : '否'; - }); - $show->field('is_manager')->as(function ($val) { - return $val ? '是' : '否'; - }); - - $show->divider('收款信息-银行'); - $show->field('bank_user_name', '银行-收款人')->as(function () { - $payInfo = $this->pay_info; - return $payInfo['bank']['user_name'] ?? ''; - }); - $show->field('bank_bank_name', '银行-名称')->as(function () { - $payInfo = $this->pay_info; - return $payInfo['bank']['bank_name'] ?? ''; - }); - $show->field('bank_bank_number', '银行-卡号')->as(function () { - $payInfo = $this->pay_info; - return $payInfo['bank']['bank_number'] ?? ''; - }); - $show->field('bank_bank_description', '银行-开户行')->as(function () { - $payInfo = $this->pay_info; - return $payInfo['bank']['bank_description'] ?? ''; - }); - $show->divider('收款信息-支付宝'); - $show->field('alipay_user_name', '支付宝-真实名称')->as(function () { - $payInfo = $this->pay_info; - return $payInfo['alipay']['user_name'] ?? ''; - }); - $show->field('alipay_ali_name', '支付宝-账户')->as(function () { - $payInfo = $this->pay_info; - return $payInfo['alipay']['ali_name'] ?? ''; - }); - $show->field('alipay_image', '支付宝-收款码')->as(function () { - $payInfo = $this->pay_info; - return $payInfo['alipay']['image'] ?? ''; - })->image(); - $show->divider('收款信息-微信'); - $show->field('wechat_user_name', '微信-真实名称')->as(function () { - $payInfo = $this->pay_info; - return $payInfo['wechat']['user_name'] ?? ''; - }); - $show->field('wechat_wechat_name', '微信-ID')->as(function () { - $payInfo = $this->pay_info; - return $payInfo['wechat']['wechat_name'] ?? ''; - }); - $show->field('wechat_image', '微信-收款码')->as(function () { - $payInfo = $this->pay_info; - return $payInfo['wechat']['image'] ?? ''; - })->image(); - - // $show->field('pay_info'); - $show->field('created_at'); - $show->panel() - ->tools(function (Show\Tools $tools) use ($show) { - $tools->disableEdit(); - $tools->disableDelete(); - }); - })); - }); - $row->column(7, function ($column) use ($id) { - $dealer = DealerModel::findOrFail($id); - $tab = Tab::make(); - // 资金记录 - $tab->add('资金记录', new DealerEarningSimpleTable(['id'=>$dealer->user_id])); - // 剩余库存 - $builder = DealerUserProduct::query(); - $builder->with(['product'])->where('user_id', $dealer->user_id); - $productGrid = Grid::make($builder, function (Grid $grid) { - $grid->column('product.name', '商品名称'); - $grid->column('product.cover', '商品封面')->image(80, 80); - $grid->column('stock', '库存'); - $grid->column('deposit_stock', '云库存'); - $grid->column('created_at', '创建时间'); - $grid->column('logs', '库存记录')->display('查看')->modal(function ($modal) { - $modal->title('商品'); - return DealerUserProductLogSimpleTable::make(['product_id'=>$this->product_id, 'id'=> $this->user_id]); - }); - // $grid->withBorder(); - $grid->model()->orderBy('created_at', 'desc'); - $grid->disableRefreshButton(); - $grid->disableActions(); - $grid->disablePagination(); - }); - - $tab->add('剩余库存', $productGrid); - - $tab->add('余额记录', new DealerWalletLogSimpleTable(['id'=>$dealer->user_id])); - // $tab->add('升级记录', ''); - // 上级列表 - // $tab->add('上级列表', ''); - $column->row(Box::make('用户记录', $tab)); - }); - }; - } - - /** - * Make a form builder. - * - * @return Form - */ - protected function form() - { - return Form::make(new Dealer(), function (Form $form) { - $form->display('id'); - // $form->text('user_id'); - // $form->text('lvl'); - $form->text('is_sale'); - $form->text('is_manager'); - // $form->text('pay_info'); - - $form->display('created_at'); - $form->display('updated_at'); - }); - } -} diff --git a/app/Admin/Controllers/DealerDeliveryBillController.php b/app/Admin/Controllers/DealerDeliveryBillController.php deleted file mode 100644 index 3e2bea28..00000000 --- a/app/Admin/Controllers/DealerDeliveryBillController.php +++ /dev/null @@ -1,139 +0,0 @@ -model()->orderBy('id', 'desc'); - - $grid->column('id')->sortable(); - $grid->column('sn', '提货单号'); - $grid->column('user.phone', '手机号'); - $grid->column('user.userInfo.nickname', '昵称'); - $grid->column('shipping_fee', '运费')->prepend('¥'); - $grid->column('pay_way', '支付方式')->display(function ($v) { - return $v?->text(); - })->circleDot(PayWay::colors()); - $grid->column('pay_at', '付款时间')->display(function ($v) { - return $v?->toDateTimeString(); - }); - $grid->column('status', '状态')->display(function ($v) { - return $v?->text(); - })->circleDot(DealerDeliveryBillStatus::colors()); - $grid->column('created_at', '创建时间')->display(function ($v) { - return $v?->toDateTimeString(); - }); - - $grid->actions(function (Grid\Displayers\Actions $actions) { - if (Admin::user()->can('dcat.admin.dealer_orders.show')) { - $actions->append(' 显示   '); - } - - if ($actions->row->isPaid()) { - $actions->append(new DealerDeliveryShipping()); - } - }); - - $grid->filter(function (Grid\Filter $filter) { - $filter->panel(); - $filter->like('sn', '提货单号')->width(4); - $filter->like('user.phone', '手机号')->width(4); - $filter->equal('status', '状态')->select(DealerDeliveryBillStatus::texts())->width(4); - $filter->between('pay_at', '付款时间')->dateTime()->width(4); - $filter->between('created_at', '创建时间')->dateTime()->width(4); - }); - }); - } - - /** - * Make a show builder. - * - * @param mixed $id - * - * @return Show - */ - protected function detail($id) - { - return function (Row $row) use ($id) { - $row->column(5, function ($column) use ($id) { - $builder = DealerDeliveryBill::with(['user.userInfo']); - - $column->row(Show::make($id, $builder, function (Show $show) { - $show->field('sn', '提货单号'); - $show->field('user.phone', '手机号'); - $show->field('user.user_info.nickname', '昵称'); - $show->field('shipping_fee', '运费'); - $show->field('remark', '备注'); - $show->field('status', '状态')->as(function () { - return $this->status?->text(); - })->circleDot(DealerDeliveryBillStatus::colors()); - $show->field('created_at')->as(function ($v) { - return $this->created_at->toDateTimeString(); - }); - - $show->divider(); - $show->field('consignee_name', '收货人'); - $show->field('consignee_telephone', '联系方式'); - $show->field('consignee', '收货地址')->as(function () { - return $this->consignee_zone . ' '. $this->consignee_address; - }); - - $show->divider(); - $show->field('pay_sn', '支付单号'); - $show->field('pay_way', '支付方式')->as(function () { - return $this->pay_way?->text(); - })->circleDot(PayWay::colors()); - $show->field('pay_at', '付款时间')->as(function () { - return $this->pay_at?->toDateTimeString(); - }); - $show->field('out_trade_no', '外部交易号'); - - - $show->panel() - ->tools(function (Show\Tools $tools) use ($show) { - $tools->disableEdit(); - $tools->disableDelete(); - }); - })); - }); - $row->column(7, function ($column) use ($id) { - $repository = DealerDeliveryProduct::with(['product']); - - $column->row(Box::make('提货单商品', Grid::make($repository, function (Grid $grid) use ($id) { - $grid->model()->where('delivery_bill_id', $id); - - $grid->column('product.name', '名称'); - $grid->column('product.cover', '封面')->image(50, 50); - $grid->column('qty', '数量'); - $grid->disableActions(); - $grid->disablePagination(); - $grid->disableRefreshButton(); - }))); - }); - }; - } -} diff --git a/app/Admin/Controllers/DealerEarningController.php b/app/Admin/Controllers/DealerEarningController.php deleted file mode 100644 index 9f937172..00000000 --- a/app/Admin/Controllers/DealerEarningController.php +++ /dev/null @@ -1,321 +0,0 @@ -setResource('dealer-earnings'); - $grid->model()->orderBy('id', 'desc'); //默认ID倒叙 - - $grid->column('id')->sortable(); - $grid->column('user.phone'); - $grid->column('user.userInfo.nickname', '昵称'); - $grid->column('lvl')->display(function () { - return $this->lvl->text(); - }); - $grid->column('earningable_type', '资金类型')->display(function () { - return $this->earningable_type_text; - })->label([ - (new DealerManageSubsidy())->getMorphClass() => 'primary', - (new DealerManagerSubsidy())->getMorphClass() => 'success', - (new DealerPurchaseSubsidy())->getMorphClass() => 'danger', - (new DealerChannelSubsidyLog())->getMorphClass() => 'warning', - ])->filter(Grid\Column\Filter\In::make([ - (new DealerManagerSubsidy())->getMorphClass() =>'管理者补贴', - (new DealerManageSubsidy())->getMorphClass() => '管理补贴', - (new DealerChannelSubsidyLog())->getMorphClass() => '渠道补贴', - (new DealerPurchaseSubsidy())->getMorphClass() => '进货补贴', - ])); - $grid->column('total_amount')->prepend('¥'); - $grid->column('fee_rate')->append('%'); - $grid->column('fee')->prepend('¥'); - $grid->column('total_earnings')->prepend('¥'); - $grid->column('remark')->display('查看') // 设置按钮名称 - ->expand(function () { - $card = new Card(null, nl2br($this->remark)); - - return "
$card
"; - }); - $grid->column('status', '状态')->display(function ($v) { - if (! $this->isSettled()) { - return "  待结算"; - } - - return "  {$v->text()}"; - })->filter(DealerEarningStatusIn::make([ - -1 => '待结算', - 0 => '待打款', - 1 => '待收款', - 5 => '已完成', - ])); - $grid->column('settle_at'); - $grid->column('payer_id')->display(function () { - return $this->payer_id ? $this->payer?->phone : '公司'; - }); - $grid->column('pay_way', '支付方式')->display(function ($v) { - return $v?->text(); - })->circleDot(PayWay::colors()); - $grid->column('pay_at'); - $grid->column('created_at')->sortable(); - $grid->actions(function (Grid\Displayers\Actions $actions) { - $actions->append(' 显示   '); - }); - - $grid->header(function ($collection) use ($grid) { - return tap(new Row(), function ($row) use ($grid) { - $query = DealerEarningModel::query(); - - // 拿到表格筛选 where 条件数组进行遍历 - $grid->model()->getQueries()->unique()->each(function ($value) use (&$query) { - if (in_array($value['method'], ['paginate', 'get', 'orderBy', 'orderByDesc'], true)) { - return; - } - - $query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []); - }); - - // 查出统计数据 - $totalAmount = (clone $query)->sum('total_amount'); - - $row->column(3, new InfoBox('金额', $totalAmount, 'fa fa-cny')); - $row->column(3, new InfoBox('手续费', (clone $query)->sum('fee'), 'fa fa-cny')); - }); - }); - - $grid->filter(function (Grid\Filter $filter) { - $filter->panel(); - $filter->equal('user.phone')->width(3); - $filter->between('settle_at')->dateTime()->width(6); - }); - }); - } - - /** - * Make a show builder. - * - * @param mixed $id - * - * @return Show - */ - protected function detail($id) - { - return function (Row $row) use ($id) { - $row->column(5, function ($column) use ($id) { - $builder = DealerEarning::with(['user.userInfo', 'payer']); - $column->row(Show::make($id, $builder, function (Show $show) { - $show->field('id'); - $show->field('user.phone'); - $show->field('user.user_info.nickname', '昵称'); - $show->field('lvl')->as(function () { - return $this->lvl->text(); - }); - $show->field('earningable_type', '资金类型')->as(function () { - return $this->earningable_type_text; - })->label(); - $show->field('total_amount')->prepend('¥'); - $show->field('fee_rate')->append('%'); - $show->field('fee')->prepend('¥'); - $show->field('total_earnings')->prepend('¥'); - $show->field('payer.phone', '打款人')->as(function () { - return $this->payer_id ? $this->payer?->phone : '公司'; - }); - $show->field('pay_way', '打款方式')->as(function () { - return $this->pay_way?->text(); - })->circleDot(PayWay::colors()); - $show->field('pay_at', '打款时间')->as(function () { - return $this->pay_at?->toDateTimeString(); - }); - $show->field('pay_image')->image(); - $show->field('settle_at'); - $show->field('remark')->unescape()->as(function () { - return nl2br($this->remark); - }); - $show->field('status', '状态')->unescape()->as(function () { - if (! $this->isSettled()) { - return "  待结算"; - } - - return "  {$this->status->text()}"; - }); - $show->field('created_at'); - - // 非(待结算)显示收款人信息 - if ($show->model()->isSettled()) { - $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->panel() - ->tools(function (Show\Tools $tools) use ($show) { - $tools->disableEdit(); - $tools->disableDelete(); - // if ($show->model()->status == DealerEarningStatus::Pending && Admin::user()->can('dcat.admin.dealer_earnings.pay')) { - // if (!$show->model()->payer_id || $show->model()->payer_id == 1) { - // $tools->append(new DealerEarningPay()); - // } - // } - }); - })); - }); - $row->column(7, function ($column) use ($id) { - $earning = DealerEarningModel::with('earningable')->findOrFail($id); - $grid = '暂无记录'; - switch (get_class($earning->earningable)) { - case DealerManagerSubsidy::class://管理者补贴 - $builder = DealerManagerSalesLog::with(['order', 'product'])->where('user_id', $earning->earningable->user_id)->whereBetween('order_completed_at', [$earning->earningable->start_at, $earning->earningable->end_at]); - $grid = Grid::make($builder, function (Grid $grid) { - $grid->column('id'); - $grid->column('order.sn', '订单编号'); - $grid->column('product.name', '商品名称'); - $grid->column('sales_volume', '销量'); - $grid->column('order_completed_at', '结算时间'); - $grid->disableCreateButton(); - $grid->disableActions(); - }); - break; - case DealerManageSubsidy::class://管理补贴 - $builder = DealerManageSubsidyLog::with(['order', 'product'])->where('user_id', $earning->earningable->user_id)->whereBetween('order_completed_at', [$earning->earningable->start_at, $earning->earningable->end_at]); - $grid = Grid::make($builder, function (Grid $grid) { - $grid->column('id'); - $grid->column('order.sn', '订单编号'); - $grid->column('product.name', '商品名称'); - $grid->column('sales_volume', '销量'); - $grid->column('total_amount', '金额'); - $grid->column('order_completed_at', '结算时间'); - $grid->disableCreateButton(); - $grid->disableActions(); - // $grid->disablePagination(); - }); - break; - case DealerPurchaseSubsidy::class://进货补贴 - $builder = DealerPurchaseSubsidyLog::where('purchase_subsidy_id', $earning->earningable_id); - $grid = Grid::make($builder, function (Grid $grid) { - $grid->column('id'); - $grid->column('change_amount', '变更金额'); - $grid->column('remark', '备注'); - $grid->column('created_at', '结算时间'); - $grid->disableCreateButton(); - $grid->disableActions(); - $grid->disablePagination(); - }); - break; - } - $column->row(Box::make('明细记录', $grid)); - }); - }; - } - - /** - * 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/Controllers/DealerManageSubsidyController.php b/app/Admin/Controllers/DealerManageSubsidyController.php deleted file mode 100644 index 47255cea..00000000 --- a/app/Admin/Controllers/DealerManageSubsidyController.php +++ /dev/null @@ -1,129 +0,0 @@ -model()->settled()->orderBy('id', 'desc'); - - $grid->column('settle_period', '结算周期')->display(function () { - return $this->start_at->rawFormat('Y/m/d') . '-' . $this->end_at->rawFormat('Y/m/d'); - })->link(function () { - return admin_route('dealer_manage_subsidy_logs.index', [ - 'user[phone]' => $this->user?->phone, - 'order_completed_at[start]' => $this->start_at->toDateTimeString(), - 'order_completed_at[end]' => $this->end_at->toDateTimeString(), - ]); - }); - $grid->column('user.phone', '手机号'); - $grid->column('userinfo.nickname', '昵称'); - $grid->column('lvl', '经销商等级')->display(function () { - return $this->lvl->text(); - }); - $grid->column('total_amount', '津贴总额')->prepend('¥'); - $grid->column('fee', '手续费')->prepend('¥')->help('手续费=津贴总额*手续费率'); - $grid->column('real_amount', '总收入')->prepend('¥')->help('总收入=津贴总额-手续费'); - $grid->column('fee_rate', '手续费率')->append('%'); - $grid->column('remark', '备注')->display('查看') // 设置按钮名称 - ->expand(function () { - $card = new Card(null, nl2br($this->remark)); - - return "
$card
"; - }); - $grid->column('status', '状态')->display(function ($v) { - return $v->text(); - })->circleDot(DealerManageSubsidyStatus::colors()); - $grid->column('earning.pay_at', '付款时间'); - - $grid->showRowSelector(); - - $grid->tools(function ($tools) { - $tools->batch(function ($batch) { - $batch->disableDelete(); - - if (Admin::user()->can('dcat.admin.dealer_manage_subsidies.batch_pay')) { - $batch->add(new DealerManageSubsidyBatchPay()); - } - }); - }); - - $grid->actions(function (Grid\Displayers\Actions $actions) { - if ($actions->row->isPending() && Admin::user()->can('dcat.admin.dealer_manage_subsidies.pay')) { - $actions->append(new DealerManageSubsidyPay()); - } - }); - - $grid->filter(function (Grid\Filter $filter) { - $filter->panel(); - - $filter->equal('user.phone', '手机号')->width(3); - $filter->equal('status', '状态')->select(DealerManageSubsidyStatus::texts())->width(3); - $filter->whereBetween('settle_period', function ($query) { - $start = $this->input['start'] ?? null; - $end = $this->input['end'] ?? null; - - $query->when($start, function ($query, $start) { - $query->where('start_at', '>=', "{$start} 00:00:00"); - }); - - $query->when($end, function ($query, $end) { - $query->where('end_at', '<=', "{$end} 23:59:59"); - }); - }, '结算周期')->date()->width(6); - }); - - $grid->header(function ($collection) use ($grid) { - return tap(new Row(), function ($row) use ($grid) { - $query = DealerManageSubsidyModel::query(); - - $grid->model()->getQueries()->unique()->each(function ($value) use (&$query) { - if (in_array($value['method'], ['paginate', 'get', 'orderBy', 'orderByDesc'], true)) { - return; - } - - $query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []); - }); - - $totalAmount = (clone $query)->sum('total_amount'); - $totalFee = (clone $query)->sum('fee'); - - $row->column(3, new InfoBox('津贴总额', $totalAmount, 'fa fa-cny')); - $row->column(3, new InfoBox('手续费', $totalFee, 'fa fa-cny')); - }); - }); - }); - } -} diff --git a/app/Admin/Controllers/DealerManageSubsidyLogController.php b/app/Admin/Controllers/DealerManageSubsidyLogController.php deleted file mode 100644 index 6057badc..00000000 --- a/app/Admin/Controllers/DealerManageSubsidyLogController.php +++ /dev/null @@ -1,134 +0,0 @@ -model()->orderBy('id', 'desc');//默认ID倒叙 - - $grid->column('id')->sortable(); - $grid->column('user.phone', '手机号')->copyable(); - $grid->column('lvl', '等级')->display(function () { - return $this->lvl->text(); - }); - $grid->column('order.sn', '订单编号'); - $grid->column('product.name', '商品名称'); - $grid->column('sales_volume', '销量'); - $grid->column('total_amount', '金额'); - $grid->column('order_completed_at', '结算时间')->sortable(); - $grid->column('created_at')->sortable(); - - $grid->disableCreateButton(); - $grid->disableActions(); - $grid->header(function ($collection) use ($grid) { - return tap(new Row(), function ($row) use ($grid) { - $query = DealerManageSubsidyLogModel::query(); - - $grid->model()->getQueries()->unique()->each(function ($value) use (&$query) { - if (in_array($value['method'], ['paginate', 'get', 'orderBy', 'orderByDesc'], true)) { - return; - } - - $query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []); - }); - - $row->column(3, new InfoBox('津贴总额', (clone $query)->sum('total_amount'), 'fa fa-cny')); - }); - $query = DealerManageSubsidyLogModel::query(); - - // 拿到表格筛选 where 条件数组进行遍历 - $grid->model()->getQueries()->unique()->each(function ($value) use (&$query) { - if (in_array($value['method'], ['paginate', 'get', 'orderBy', 'orderByDesc'], true)) { - return; - } - - $query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []); - }); - - // 查出统计数据 - $totalAmount = (clone $query)->sum('total_amount'); - // 自定义组件 - return "
金额:".$totalAmount.' 元
'; - }); - $grid->filter(function (Grid\Filter $filter) { - $filter->panel(false); - $filter->equal('user.phone', '手机号')->width(3); - $filter->between('order_completed_at', '结算时间')->dateTime()->width(7); - }); - }); - } - - /** - * Make a show builder. - * - * @param mixed $id - * - * @return Show - */ - protected function detail($id) - { - return Show::make($id, new DealerManageSubsidyLog(), function (Show $show) { - $show->field('id'); - $show->field('user_id'); - $show->field('lvl'); - $show->field('order_id'); - $show->field('product_id'); - $show->field('sales_volume'); - $show->field('total_amount'); - $show->field('order_completed_at'); - $show->field('created_at'); - $show->field('updated_at'); - }); - } - - /** - * Make a form builder. - * - * @return Form - */ - protected function form() - { - return Form::make(new DealerManageSubsidyLog(), function (Form $form) { - $form->display('id'); - $form->text('user_id'); - $form->text('lvl'); - $form->text('order_id'); - $form->text('product_id'); - $form->text('sales_volume'); - $form->text('total_amount'); - $form->text('order_completed_at'); - - $form->display('created_at'); - $form->display('updated_at'); - }); - } -} diff --git a/app/Admin/Controllers/DealerManagerSalesLogController.php b/app/Admin/Controllers/DealerManagerSalesLogController.php deleted file mode 100644 index 5febbe09..00000000 --- a/app/Admin/Controllers/DealerManagerSalesLogController.php +++ /dev/null @@ -1,117 +0,0 @@ -model()->orderBy('id', 'desc');//默认ID倒叙 - $grid->column('id')->sortable(); - $grid->column('user.phone', '手机号')->copyable(); - $grid->column('lvl', '等级')->display(function () { - return $this->lvl->text(); - }); - $grid->column('order.sn', '订单编号'); - $grid->column('product.name', '商品名称'); - $grid->column('sales_volume', '销量'); - $grid->column('order_completed_at', '结算时间')->sortable(); - $grid->column('created_at')->sortable(); - - $grid->disableCreateButton(); - $grid->disableActions(); - - $grid->header(function ($collection) use ($grid) { - $query = DealerManagerSalesLogModel::query()->with(['product']) - ->select(['product_id', DB::raw('sum(sales_volume) as sales_volume')]); - - // 拿到表格筛选 where 条件数组进行遍历 - $grid->model()->getQueries()->unique()->each(function ($value) use (&$query) { - if (in_array($value['method'], ['paginate', 'get', 'orderBy', 'orderByDesc'], true)) { - return; - } - - $query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []); - }); - - // 查出统计数据 - $text = ''; - foreach ($query->groupBy('product_id')->get() as $log) { - if ($text !== '') { - $text .= '
'; - } - $text .= $log->product->name.'销量:'.$log->sales_volume; - } - - // 自定义组件 - return "
".$text.'
'; - }); - - - $grid->filter(function (Grid\Filter $filter) { - $filter->panel(false); - $filter->equal('user.phone', '手机号')->width(4); - $filter->between('order_completed_at', '结算时间')->dateTime()->width(4); - $filter->between('created_at', '创建时间')->dateTime()->width(4); - }); - }); - } - - /** - * Make a show builder. - * - * @param mixed $id - * - * @return Show - */ - protected function detail($id) - { - return Show::make($id, new DealerManagerSalesLog(), function (Show $show) { - $show->field('id'); - $show->field('user_id'); - $show->field('order_id'); - $show->field('product_id'); - $show->field('lvl'); - $show->field('sales_volume'); - $show->field('order_completed_at'); - $show->field('created_at'); - $show->field('updated_at'); - }); - } - - /** - * Make a form builder. - * - * @return Form - */ - protected function form() - { - return Form::make(new DealerManagerSalesLog(), function (Form $form) { - $form->display('id'); - $form->text('user_id'); - $form->text('order_id'); - $form->text('product_id'); - $form->text('lvl'); - $form->text('sales_volume'); - $form->text('order_completed_at'); - - $form->display('created_at'); - $form->display('updated_at'); - }); - } -} diff --git a/app/Admin/Controllers/DealerManagerSubsidyController.php b/app/Admin/Controllers/DealerManagerSubsidyController.php deleted file mode 100644 index 56c71fa5..00000000 --- a/app/Admin/Controllers/DealerManagerSubsidyController.php +++ /dev/null @@ -1,130 +0,0 @@ -model()->settled()->orderBy('id', 'desc'); - - $grid->column('settle_period', '结算周期')->display(function () { - return $this->start_at->rawFormat('Y/m/d') . '-' . $this->end_at->rawFormat('Y/m/d'); - })->link(function () { - return admin_route('dealer_manager_sales_logs.index', [ - 'user[phone]' => $this->user?->phone, - 'order_completed_at[start]' => $this->start_at->toDateTimeString(), - 'order_completed_at[end]' => $this->end_at->toDateTimeString(), - ]); - }); - $grid->column('user.phone', '手机号'); - $grid->column('userinfo.nickname', '昵称'); - $grid->column('is_manager', '管理者')->bool(); - $grid->column('lvl', '经销商等级')->display(function () { - return $this->lvl->text(); - }); - $grid->column('total_amount', '津贴总额')->prepend('¥'); - $grid->column('fee', '手续费')->prepend('¥')->help('手续费=津贴总额*手续费率'); - $grid->column('real_amount', '总收入')->prepend('¥')->help('总收入=津贴总额-手续费'); - $grid->column('fee_rate', '手续费率')->append('%'); - $grid->column('remark', '备注')->display('查看') // 设置按钮名称 - ->expand(function () { - $card = new Card(null, nl2br($this->remark)); - - return "
$card
"; - }); - $grid->column('status', '状态')->display(function ($v) { - return $v->text(); - })->circleDot(DealerManagerSubsidyStatus::colors()); - $grid->column('earning.pay_at', '付款时间'); - - $grid->showRowSelector(); - - $grid->tools(function ($tools) { - $tools->batch(function ($batch) { - $batch->disableDelete(); - - if (Admin::user()->can('dcat.admin.dealer_manager_subsidies.batch_pay')) { - $batch->add(new DealerManagerSubsidyBatchPay()); - } - }); - }); - - $grid->actions(function (Grid\Displayers\Actions $actions) { - if ($actions->row->isPending() && Admin::user()->can('dcat.admin.dealer_manager_subsidies.pay')) { - $actions->append(new DealerManagerSubsidyPay()); - } - }); - - $grid->filter(function (Grid\Filter $filter) { - $filter->panel(); - - $filter->equal('user.phone', '手机号')->width(3); - $filter->equal('status', '状态')->select(DealerManagerSubsidyStatus::texts())->width(3); - $filter->whereBetween('settle_period', function ($query) { - $start = $this->input['start'] ?? null; - $end = $this->input['end'] ?? null; - - $query->when($start, function ($query, $start) { - $query->where('start_at', '>=', "{$start} 00:00:00"); - }); - - $query->when($end, function ($query, $end) { - $query->where('end_at', '<=', "{$end} 23:59:59"); - }); - }, '结算周期')->date()->width(6); - }); - - $grid->header(function ($collection) use ($grid) { - return tap(new Row(), function ($row) use ($grid) { - $query = DealerManagerSubsidyModel::query(); - - $grid->model()->getQueries()->unique()->each(function ($value) use (&$query) { - if (in_array($value['method'], ['paginate', 'get', 'orderBy', 'orderByDesc'], true)) { - return; - } - - $query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []); - }); - - $totalAmount = (clone $query)->sum('total_amount'); - $totalFee = (clone $query)->sum('fee'); - - $row->column(3, new InfoBox('津贴总额', $totalAmount, 'fa fa-cny')); - $row->column(3, new InfoBox('手续费', $totalFee, 'fa fa-cny')); - }); - }); - }); - } -} diff --git a/app/Admin/Controllers/DealerOrderController.php b/app/Admin/Controllers/DealerOrderController.php deleted file mode 100644 index 1d121d5b..00000000 --- a/app/Admin/Controllers/DealerOrderController.php +++ /dev/null @@ -1,309 +0,0 @@ -model()->where(function ($query) { - return $query->where('consignor_id', 1)->orWhereNull('consignor_id'); - }); - } - $grid->setResource('dealer-orders'); - $grid->column('id')->sortable(); - $grid->column('sn'); - $grid->column('user.phone')->copyable(); - $grid->column('userInfo.nickname'); - $grid->column('consignor.phone')->display(function ($value) { - return $value ?? '系统'; - }); - $grid->column('total_amount')->prepend('¥'); - $statusTexts = DealerOrderStatus::texts(); - - $grid->column('pay_way')->display(function ($v) { - return $v?->text(); - })->circleDot(PayWay::colors())->filter(DealerOrderPayWayIn::make([ - PayWay::Offline->value => '线下', - PayWay::Wallet->value => '钱包', - PayWay::WxpayH5->value => '微信支付', - ])); - - $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', - ])->filter(Grid\Column\Filter\In::make($statusTexts)->setColumnName('status')); - // $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->model()->orderBy('created_at', 'desc'); - // $grid->column('updated_at')->sortable(); - $grid->actions(function (Grid\Displayers\Actions $actions) { - if (Admin::user()->can('dcat.admin.dealer_orders.show')) { - $actions->append(' 显示   '); - // $actions->disableView(false); - } - if (!(empty($actions->row->consignor) || $actions->row->consignor_id == 1) && $actions->row->isPending() && Admin::user()->can('dcat.admin.dealer_orders.allocate')) { - $actions->append(new DealerOrderAllocate()); - } - - if ((empty($actions->row->consignor))) { - if ($actions->row->isPay() && Admin::user()->can('dcat.admin.dealer_orders.paid')) { - $actions->append(new DealerOrderPaid()); - } - - if ( - $actions->row->isPay() && - $actions->row->isPayWayOffline() && - Admin::user()->can('dcat.admin.dealer_orders.refuse') - ) { - $actions->append(new DealerOrderRefuse()); - } - - if ($actions->row->isPaid() && Admin::user()->can('dcat.admin.dealer_orders.shipping')) { - $actions->append(new DealerOrderShipping()); - } - } - if (( - $actions->row->isPending() //待确认 - || $actions->row->isPendinged() //待付款 - || $actions->row->isPay()//待收款 - ) && Admin::user()->can('dcat.admin.dealer_orders.cancel')) { - $actions->append(new DealerOrderCancel()); - } - }); - $grid->filter(function (Grid\Filter $filter) { - $filter->panel(); - $filter->like('user.phone')->width(3); - $filter->like('consignor.phone')->width(3); - $filter->like('sn')->width(3); - $filter->between('paied_time')->dateTime()->width(5); - $filter->between('created_at')->dateTime()->width(5); - // $filter->equal('id'); - }); - }); - } - - /** - * Make a show builder. - * - * @param mixed $id - * - * @return Show - */ - protected function detail($id) - { - return function (Row $row) use ($id) { - $row->column(5, function ($column) use ($id) { - $builder = DealerOrder::with(['user', 'userInfo', 'consignor']); - $column->row(Show::make($id, $builder, function (Show $show) { - $show->field('sn'); - $show->field('created_at'); - $show->field('order_status')->as(function ($v) { - return $this->order_status; - })->using(DealerOrderStatus::texts())->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', - ]); - $show->field('user.phone'); - $show->field('user_info.nickname'); - $show->field('consignor.phone')->as(function ($value) { - return $value ?? '系统'; - }); - $show->field('pay_way', '支付方式')->as(function () { - return $this->pay_way?->text(); - })->circleDot(PayWay::colors()); - $show->field('pay_sn', '支付流水号'); - $show->field('pay_time', '支付时间'); - $show->field('paied_time'); - if ($show->model()->isPayWayWxpay()) { - $show->field('out_trade_no', '外部交易号'); - } elseif ($show->model()->isPayWayOffline()) { - $show->field('pay_image')->image(); - } - $show->field('remark'); - $show->divider(); - $show->field('consignee_name'); - $show->field('consignee_telephone'); - $show->field('consignee', '收货地址')->as(function () { - return $this->consignee_zone . ' '. $this->consignee_address; - }); - - if ( - $show->model()->isPayWayOffline() && - !in_array($show->model()->order_status, [ - DealerOrderStatus::Pending->value, DealerOrderStatus::Cancelled->value, - ]) - ) { - $show->divider('收款信息-银行'); - $show->field('bank_user_name', '银行-收款人')->as(function () { - $payInfo = $this->getConsignorPayInfo(); - return $payInfo['bank']['user_name'] ?? ''; - }); - $show->field('bank_bank_name', '银行-名称')->as(function () { - $payInfo = $this->getConsignorPayInfo(); - return $payInfo['bank']['bank_name'] ?? ''; - }); - $show->field('bank_bank_number', '银行-卡号')->as(function () { - $payInfo = $this->getConsignorPayInfo(); - return $payInfo['bank']['bank_number'] ?? ''; - }); - $show->field('bank_bank_description', '银行-开户行')->as(function () { - $payInfo = $this->getConsignorPayInfo(); - return $payInfo['bank']['bank_description'] ?? ''; - }); - $show->divider('收款信息-支付宝'); - $show->field('alipay_user_name', '支付宝-真实名称')->as(function () { - $payInfo = $this->getConsignorPayInfo(); - return $payInfo['alipay']['user_name'] ?? ''; - }); - $show->field('alipay_ali_name', '支付宝-账户')->as(function () { - $payInfo = $this->getConsignorPayInfo(); - return $payInfo['alipay']['ali_name'] ?? ''; - }); - $show->field('alipay_image', '支付宝-收款码')->as(function () { - $payInfo = $this->getConsignorPayInfo(); - return $payInfo['alipay']['image'] ?? ''; - })->image(); - $show->divider('收款信息-微信'); - $show->field('wechat_user_name', '微信-真实名称')->as(function () { - $payInfo = $this->getConsignorPayInfo(); - return $payInfo['wechat']['user_name'] ?? ''; - }); - $show->field('wechat_wechat_name', '微信-ID')->as(function () { - $payInfo = $this->getConsignorPayInfo(); - return $payInfo['wechat']['wechat_name'] ?? ''; - }); - $show->field('wechat_image', '微信-收款码')->as(function () { - $payInfo = $this->getConsignorPayInfo(); - return $payInfo['wechat']['image'] ?? ''; - })->image(); - } - - $show->panel() - ->tools(function (Show\Tools $tools) use ($show) { - $tools->disableEdit(); - $tools->disableDelete(); - if (Admin::user()->can('dcat.admin.dealer_orders.remark')) { - $tools->append(new DealerOrderRemark()); - } - }); - })); - }); - $row->column(7, function ($column) use ($id) { - $builder = DealerOrderProduct::where('order_id', $id); - $productGrid = Grid::make($builder, function (Grid $grid) { - $grid->column('name'); - $grid->column('cover', '封面')->image(50, 50); - $grid->column('price', '标价')->prepend('¥'); - $grid->column('sale_price', '实际售价')->prepend('¥'); - $grid->column('qty', '数量'); - $grid->column('deposit_qty', '云数量'); - $grid->disableActions(); - $grid->disablePagination(); - $grid->disableRefreshButton(); - }); - $column->row(Box::make('订单商品', $productGrid)); - //显示渠道补贴明细 - // $channelSubsidy = ''; - $builder = DealerChannelSubsidyLog::with(['user', 'earning'])->where('order_id', $id); - $channelSubsidy = Grid::make($builder, function (Grid $grid) { - $grid->column('user.phone', '手机号'); - $grid->column('lvl', '等级')->display(function () { - return $this->lvl->text(); - }); - $grid->column('total_amount', '补贴金额'); - $grid->column('remark', '备注'); - $grid->column('earning.id', '操作')->display(function () { - return '查看'; - })->link(function ($value) { - return admin_route('dealer_earnings.show', ['dealer_earning'=>$this->earning->id]); - }); - $grid->disableActions(); - $grid->disablePagination(); - $grid->disableRefreshButton(); - }); - $column->row(Box::make('渠道补贴', $channelSubsidy)); - }); - }; - } - - /** - * 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/Controllers/DealerProductController.php b/app/Admin/Controllers/DealerProductController.php deleted file mode 100644 index cf9a2285..00000000 --- a/app/Admin/Controllers/DealerProductController.php +++ /dev/null @@ -1,137 +0,0 @@ -column('id')->sortable(); - $grid->column('name'); - $grid->column('unit')->label(); - // $grid->column('subtitle'); - $grid->column('cover')->image(80, 80); - // $grid->column('images'); - // $grid->column('description'); - $grid->column('price')->prepend('¥'); - $grid->column('manager_subsidy')->prepend('¥'); - // $grid->column('stock'); - // $grid->column('sales_count'); - $grid->column('is_sale')->if(function () { - return Admin::user()->can('dcat.admin.dealer_products.edit'); - }) - ->then(function (Column $column) { - $column->switch(); - }) - ->else(function (Column $column) { - $column->bool(); - }); - $grid->column('created_at')->sortable(); - /** 操作 **/ - //新增 - if (Admin::user()->can('dcat.admin.dealer_products.create')) { - $grid->disableCreateButton(false); - } - //修改 - // $grid->showQuickEditButton(Admin::user()->can('dcat.admin.product_spus.edit')); - //删除以及自定义操作 - $grid->actions(function (Grid\Displayers\Actions $actions) { - $actions->disableEdit(Admin::user()->cannot('dcat.admin.dealer_products.edit')); - $actions->disableDelete(Admin::user()->cannot('dcat.admin.dealer_products.destroy')); - if (Admin::user()->can('dcat.admin.dealers_products.lvl_rules')) { - $actions->append(new DealerProductLvlRuleAction()); - } - if (Admin::user()->can('dcat.admin.dealers_products.sale_rules')) { - $actions->append(new DealerProductSaleRuleAction()); - } - if (Admin::user()->can('dcat.admin.dealers_products.manage_rules')) { - $actions->append(new DealerProductManageRuleAction()); - } - }); - $grid->filter(function (Grid\Filter $filter) { - $filter->panel(); - $filter->equal('name')->width(3); - }); - }); - } - - /** - * Make a show builder. - * - * @param mixed $id - * - * @return Show - */ - protected function detail($id) - { - return Show::make($id, new DealerProduct(), function (Show $show) { - $show->field('id'); - $show->field('name'); - $show->field('subtitle'); - $show->field('cover'); - $show->field('images'); - $show->field('description'); - $show->field('price'); - $show->field('stock'); - $show->field('sales_count'); - $show->field('is_sale'); - $show->field('created_at'); - $show->field('updated_at'); - }); - } - - /** - * Make a form builder. - * - * @return Form - */ - protected function form() - { - return Form::make(new DealerProduct(), function (Form $form) { - $form->display('id'); - $form->text('name')->required(); - $form->text('unit')->required(); - // $form->text('subtitle'); - $form->divider(); - $form->image('cover') - ->move('dealer-products/cover/'.Carbon::now()->toDateString()) - ->saveFullUrl() - ->removable(false) - ->retainable() - ->autoUpload()->retainable(); - $form->multipleImage('images') - ->move('dealer-products/'.Carbon::now()->toDateString()) - ->saveFullUrl() - ->removable(false) - ->retainable() - ->autoUpload()->retainable(); - $form->editor('description'); - $form->currency('price')->symbol('¥')->required(); - $form->currency('manager_subsidy')->symbol('¥')->required(); - // $form->text('stock'); - // $form->text('sales_count'); - $form->switch('is_sale'); - - $form->display('created_at'); - $form->display('updated_at'); - }); - } -} diff --git a/app/Admin/Controllers/DealerPurchaseLogController.php b/app/Admin/Controllers/DealerPurchaseLogController.php deleted file mode 100644 index 2f2962b5..00000000 --- a/app/Admin/Controllers/DealerPurchaseLogController.php +++ /dev/null @@ -1,129 +0,0 @@ -first(); - if ($user) { - $grid->model()->where('path', 'like', '%-'.$user->id.'-%'); - } else { - //不存的手机号查询数据置为空 - $grid->model()->where('id', 0); - } - } - $grid->model()->orderBy('id', 'desc');//默认ID倒叙 - $grid->column('id')->sortable(); - $grid->column('user.phone', '手机号')->copyable(); - $grid->column('lvl', '等级')->display(function () { - return $this->lvl->text(); - }); - $grid->column('order.sn', '订单编号'); - $grid->column('total_amount'); - $grid->column('remark'); - $grid->column('order_completed_at', '结算时间')->sortable(); - $grid->column('created_at')->sortable(); - - $grid->header(function ($collection) use ($grid) { - return tap(new Row(), function ($row) use ($grid) { - $query = DealerPurchaseLogModel::query(); - - $grid->model()->getQueries()->unique()->each(function ($value) use (&$query) { - if (in_array($value['method'], ['paginate', 'get', 'orderBy', 'orderByDesc'], true)) { - return; - } - - $query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []); - }); - - $row->column(3, new InfoBox('进货业绩', (clone $query)->sum('total_amount'), 'fa fa-cny')); - }); - }); - - $grid->filter(function (Grid\Filter $filter) { - $filter->panel(false); - $filter->equal('user_phone', '手机号')->ignore()->width(4); - $filter->between('order_completed_at', '结算时间')->dateTime()->width(4); - $filter->between('created_at', '创建时间')->dateTime()->width(4); - - // $filter->equal('user.phone', '手机号')->width(3); - }); - }); - } - - /** - * Make a show builder. - * - * @param mixed $id - * - * @return Show - */ - protected function detail($id) - { - return Show::make($id, new DealerPurchaseLog(), function (Show $show) { - $show->field('id'); - $show->field('user_id'); - $show->field('order_id'); - $show->field('lvl'); - $show->field('total_amount'); - $show->field('remark'); - $show->field('order_completed_at'); - $show->field('created_at'); - $show->field('updated_at'); - }); - } - - /** - * Make a form builder. - * - * @return Form - */ - protected function form() - { - return Form::make(new DealerPurchaseLog(), function (Form $form) { - $form->display('id'); - $form->text('user_id'); - $form->text('order_id'); - $form->text('lvl'); - $form->text('total_amount'); - $form->text('remark'); - $form->text('order_completed_at'); - - $form->display('created_at'); - $form->display('updated_at'); - }); - } -} diff --git a/app/Admin/Controllers/DealerPurchaseSubsidyController.php b/app/Admin/Controllers/DealerPurchaseSubsidyController.php deleted file mode 100644 index 7b738f88..00000000 --- a/app/Admin/Controllers/DealerPurchaseSubsidyController.php +++ /dev/null @@ -1,188 +0,0 @@ -model()->settleCompleted()->orderBy('id', 'desc');//默认ID倒叙 - - $grid->column('settle_period', '结算周期')->display(function () { - return $this->start_at->rawFormat('Y/m/d') . '-' . $this->end_at->rawFormat('Y/m/d'); - })->link(function () { - return admin_route('dealer_purchase_logs.index', [ - 'user_phone' => $this->user?->phone, - 'order_completed_at[start]' => $this->start_at->toDateTimeString(), - 'order_completed_at[end]' => $this->end_at->toDateTimeString(), - ]); - }); - $grid->column('user.phone', '手机号')->copyable(); - $grid->column('user.userInfo.nickname', '昵称'); - $grid->column('lvl', '等级')->display(function () { - return $this->lvl->text(); - }); - $grid->column('total_purchase_amount', '进货业绩')->prepend('¥'); - $grid->column('subsidy_rate', '补贴比例')->append('%'); - $grid->column('total_subsidy', '补贴总额')->prepend('¥')->help('补贴总额=进货业绩*补贴比例'); - $grid->column('total_amount', '应得补贴')->prepend('¥'); - $grid->column('fee_rate', '手续费率')->append('%'); - $grid->column('fee', '手续费')->prepend('¥')->help('手续费=应得补贴*手续费率'); - $grid->column('status', '状态')->display(function ($v) { - return $v->text(); - })->circleDot(DealerPurchaseSubsidyStatus::colors()); - - $grid->showRowSelector(); - $grid->tools(function ($tools) { - $tools->batch(function ($batch) { - $batch->disableDelete(); - - if (Admin::user()->can('dcat.admin.dealer_purchase_subsidies.batch_pay')) { - $batch->add(new DealerPurchaseSubsidyBatchPay()); - } - }); - }); - - $grid->actions(function (Grid\Displayers\Actions $actions) { - if (Admin::user()->can('dcat.admin.dealer_purchase_subsidies.show')) { - $actions->append(' 显示   '); - } - - if ($actions->row->isPending() && Admin::user()->can('dcat.admin.dealer_purchase_subsidies.pay')) { - $actions->append(new DealerPurchaseSubsidyPay()); - } - }); - - $grid->header(function ($collection) use ($grid) { - return tap(new Row(), function ($row) use ($grid) { - $query = DealerPurchaseSubsidyModel::query(); - - $grid->model()->getQueries()->unique()->each(function ($value) use (&$query) { - if (in_array($value['method'], ['paginate', 'get', 'orderBy', 'orderByDesc'], true)) { - return; - } - - $query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []); - }); - - $row->column(3, new InfoBox('进货业绩', (clone $query)->sum('total_purchase_amount'), 'fa fa-cny')); - $row->column(3, new InfoBox('补贴金额', (clone $query)->sum('total_amount'), 'fa fa-cny')); - $row->column(3, new InfoBox('手续费', (clone $query)->sum('fee'), 'fa fa-cny')); - }); - }); - - $grid->filter(function (Grid\Filter $filter) { - $filter->panel(); - - $filter->equal('user.phone', '手机号')->width(3); - $filter->equal('status', '状态')->select(DealerPurchaseSubsidyStatus::texts())->width(3); - $filter->whereBetween('settle_period', function ($query) { - $start = $this->input['start'] ?? null; - $end = $this->input['end'] ?? null; - - $query->when($start, function ($query, $start) { - $query->where('start_at', '>=', "{$start} 00:00:00"); - }); - - $query->when($end, function ($query, $end) { - $query->where('end_at', '<=', "{$end} 23:59:59"); - }); - }, '结算周期')->date()->width(6); - }); - }); - } - - /** - * Make a show builder. - * - * @param mixed $id - * - * @return Show - */ - protected function detail($id) - { - $row = new Row(); - - $row->column(5, function ($column) use ($id) { - $builder = DealerPurchaseSubsidy::with(['user.userInfo']); - - $column->row(Show::make($id, $builder, function (Show $show) { - $show->field('id'); - $show->field('settle_period', '结算周期')->as(function () { - return $this->start_at->rawFormat('Y/m/d') . '-' . $this->end_at->rawFormat('Y/m/d'); - }); - $show->field('user.phone', '手机号'); - $show->field('user.user_info.nickname', '昵称'); - $show->field('lvl', '经销商等级')->as(function () { - return $this->lvl->text(); - }); - $show->field('total_purchase_amount', '进货业绩')->prepend('¥'); - $show->field('subsidy_rate', '补贴比例')->append('%'); - $show->field('total_subsidy', '补贴总额')->prepend('¥'); - $show->field('total_amount', '应得补贴')->prepend('¥'); - $show->field('fee_rate', '手续费率')->append('%'); - $show->field('fee', '手续费')->prepend('¥'); - $show->field('real_amount', '实得补贴')->prepend('¥'); - $show->field('status', '状态')->as(function () { - return $this->status?->text(); - })->circleDot(DealerPurchaseSubsidyStatus::colors()); - - $show->panel() - ->tools(function (Show\Tools $tools) use ($show) { - $tools->disableEdit(); - $tools->disableDelete(); - }); - })); - }); - $row->column(7, function ($column) use ($id) { - $dealerPurchaseSubsidyLogBox = Box::make('补贴明细', Grid::make(DealerPurchaseSubsidyLog::class, function (Grid $grid) use ($id) { - $grid->model()->where('purchase_subsidy_id', $id); - - $grid->column('id'); - $grid->column('change_amount', '变更金额'); - $grid->column('remark', '备注'); - $grid->column('created_at', '结算时间'); - $grid->disableCreateButton(); - $grid->disableActions(); - $grid->disableRefreshButton(); - })); - - $column->row($dealerPurchaseSubsidyLogBox); - }); - - return $row; - } -} diff --git a/app/Admin/Controllers/DealerWalletToBankLogController.php b/app/Admin/Controllers/DealerWalletToBankLogController.php deleted file mode 100644 index 86e11098..00000000 --- a/app/Admin/Controllers/DealerWalletToBankLogController.php +++ /dev/null @@ -1,243 +0,0 @@ -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('manager_id')->display(function () { - if ($this->manager) { - $href = admin_route('dealers.show', ['dealer_user' => $this->manager->id]); - - return "{$this->manager->userInfo->nickname}"; - } - }); - $grid->column('status')->display(function ($v) { - $text = $v->text(); - $background = $v->color(); - - return "  {$text}"; - })->filter(Grid\Column\Filter\In::make(Arr::except(DealerWalletToBankLogStatus::texts(), [ - DealerWalletToBankLogStatus::Failed->value, - DealerWalletToBankLogStatus::Passed->value, - DealerWalletToBankLogStatus::Paying->value, - ]))); - $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('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', 'manager.userInfo']); - 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('manager_id')->unescape()->as(function () { - if ($this->manager) { - $href = admin_route('dealers.show', ['dealer_user' => $this->manager->id]); - - return "{$this->manager->userInfo->nickname}"; - } - }); - $show->field('status')->unescape()->as(function ($v) { - $text = $this->status->text(); - $background = $this->status->color(); - - return "  {$text}"; - }); - $show->field('pay_image')->image(); - $show->field('remarks'); - if ($show->model()->isFailed()) { - $show->field('failed_reason'); - } - $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 (in_array($show->model()->status, [DealerWalletToBankLogStatus::Pending, DealerWalletToBankLogStatus::Failed]) && 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; - } - } - - foreach ($query->cursor() as $log) { - $payInfo = $log->getPayInfo(); - $writer->addRow(WriterEntityFactory::createRowFromArray([ - $log->user->phone, - $log->account_amount, - $log->status->text(), - $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(); - }); - } -} diff --git a/app/Admin/Controllers/HomeController.php b/app/Admin/Controllers/HomeController.php index 7b2f259e..f504d6fd 100644 --- a/app/Admin/Controllers/HomeController.php +++ b/app/Admin/Controllers/HomeController.php @@ -8,13 +8,10 @@ use App\Admin\Metrics\Orders; use App\Admin\Metrics\StatisticsTotal; use App\Admin\Metrics\Users; use App\Http\Controllers\Controller; -use App\Models\Admin\Layout\Menu as ActiveMenu; -use App\Models\Admin\Menu; use Dcat\Admin\Admin; use Dcat\Admin\Layout\Column; use Dcat\Admin\Layout\Content; use Dcat\Admin\Layout\Row; -use Illuminate\Http\Request; class HomeController extends Controller { @@ -44,18 +41,4 @@ class HomeController extends Controller }); }); } - - // public function test(Request $request) - // { - // $menus = (new Menu())->fetchAll(); - // $activeMenu = new ActiveMenu(); - // foreach ($menus as $menu) { - // dump([ - // 'title' => $menu->title, - // 'uri' => $menu->uri, - // ]); - // dump($activeMenu->isActive($menu->toArray(), 'dealer-earnings-manage?filter-earningable_type%5B0%5D=dealer_manage_subsidy&_pjax=%23pjax-container&page=2')); - // } - // dd(123465); - // } } diff --git a/app/Admin/Controllers/SettingController.php b/app/Admin/Controllers/SettingController.php index 045c6c9f..c8333ef9 100644 --- a/app/Admin/Controllers/SettingController.php +++ b/app/Admin/Controllers/SettingController.php @@ -5,8 +5,6 @@ namespace App\Admin\Controllers; use App\Admin\Forms\Settings\Android; use App\Admin\Forms\Settings\App; use App\Admin\Forms\Settings\Custom; -use App\Admin\Forms\Settings\Dealer; -use App\Admin\Forms\Settings\Distribution; use App\Admin\Forms\Settings\Ios; use App\Admin\Forms\Settings\Kuaidi100; use App\Admin\Forms\Settings\Unipush; @@ -112,8 +110,6 @@ class SettingController extends AdminController switch ($type) { case 'app': $tab->add('系统配置', new App(), true); - // $tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution'])); - $tab->addLink('经销商配置', admin_route('settings.index', ['type'=>'dealer'])); $tab->addLink('提现配置', admin_route('settings.index', ['type'=>'withdraw'])); $tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios'])); $tab->addLink('Android配置', admin_route('settings.index', ['type'=>'ios'])); @@ -123,19 +119,6 @@ class SettingController extends AdminController break; case 'distribution': $tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app'])); - $tab->add('会员奖励配置', new Distribution(), true); - $tab->addLink('经销商配置', admin_route('settings.index', ['type'=>'dealer'])); - $tab->addLink('提现配置', admin_route('settings.index', ['type'=>'withdraw'])); - $tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios'])); - $tab->addLink('Android配置', admin_route('settings.index', ['type'=>'android'])); - $tab->addLink('快递100配置', admin_route('settings.index', ['type'=>'kuaidi100'])); - $tab->addLink('Uni-push配置', admin_route('settings.index', ['type'=>'unipush'])); - $tab->addLink('自定义配置', admin_route('settings.index', ['type'=>'custom'])); - break; - case 'dealer': - $tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app'])); - // $tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution'])); - $tab->add('经销商配置', new Dealer(), true); $tab->addLink('提现配置', admin_route('settings.index', ['type'=>'withdraw'])); $tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios'])); $tab->addLink('Android配置', admin_route('settings.index', ['type'=>'android'])); @@ -145,8 +128,6 @@ class SettingController extends AdminController break; case 'withdraw': $tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app'])); - // $tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution'])); - $tab->addLink('经销商配置', admin_route('settings.index', ['type'=>'dealer'])); $tab->add('提现配置', new Withdraw(), true); $tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios'])); $tab->addLink('Android配置', admin_route('settings.index', ['type'=>'android'])); @@ -156,8 +137,6 @@ class SettingController extends AdminController break; case 'ios': $tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app'])); - // $tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution'])); - $tab->addLink('经销商配置', admin_route('settings.index', ['type'=>'dealer'])); $tab->addLink('提现配置', admin_route('settings.index', ['type'=>'withdraw'])); $tab->add('Ios配置', new Ios(), true); $tab->addLink('Android配置', admin_route('settings.index', ['type'=>'android'])); @@ -167,8 +146,6 @@ class SettingController extends AdminController break; case 'android': $tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app'])); - // $tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution'])); - $tab->addLink('经销商配置', admin_route('settings.index', ['type'=>'dealer'])); $tab->addLink('提现配置', admin_route('settings.index', ['type'=>'withdraw'])); $tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios'])); $tab->add('Android配置', new Android(), true); @@ -178,8 +155,6 @@ class SettingController extends AdminController break; case 'kuaidi100': $tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app'])); - // $tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution'])); - $tab->addLink('经销商配置', admin_route('settings.index', ['type'=>'dealer'])); $tab->addLink('提现配置', admin_route('settings.index', ['type'=>'withdraw'])); $tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios'])); $tab->addLink('Android配置', admin_route('settings.index', ['type'=>'android'])); @@ -189,8 +164,6 @@ class SettingController extends AdminController break; case 'unipush': $tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app'])); - // $tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution'])); - $tab->addLink('经销商配置', admin_route('settings.index', ['type'=>'dealer'])); $tab->addLink('提现配置', admin_route('settings.index', ['type'=>'withdraw'])); $tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios'])); $tab->addLink('Android配置', admin_route('settings.index', ['type'=>'android'])); @@ -200,8 +173,6 @@ class SettingController extends AdminController break; case 'custom': $tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app'])); - // $tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution'])); - $tab->addLink('经销商配置', admin_route('settings.index', ['type'=>'dealer'])); $tab->addLink('提现配置', admin_route('settings.index', ['type'=>'withdraw'])); $tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios'])); $tab->addLink('Android配置', admin_route('settings.index', ['type'=>'android'])); diff --git a/app/Admin/Controllers/UserController.php b/app/Admin/Controllers/UserController.php index 2a50508d..92e6f9b6 100644 --- a/app/Admin/Controllers/UserController.php +++ b/app/Admin/Controllers/UserController.php @@ -21,7 +21,6 @@ use App\Admin\Renderable\UserSalesValueLogSimpleTable; use App\Admin\Renderable\UserWalletLogSimpleTable; use App\Admin\Repositories\User; use App\Exceptions\BizException; -use App\Models\DealerOrder; use App\Models\Order; use App\Models\User as UserModel; use App\Models\UserInfo; @@ -287,10 +286,6 @@ class UserController extends AdminController if (Order::where('user_id', $user->id)->exists()) { throw new BizException('该用户存在商城订单'); } - //判断是否有批零订单 - if (DealerOrder::where('user_id', $user->id)->orWhere('consignor_id', $user->id)->exists()) { - throw new BizException('该用户存在批零订单'); - } //抹除用户手机号 $user->update([ 'phone'=>null, diff --git a/app/Admin/Forms/DealerBonds.php b/app/Admin/Forms/DealerBonds.php deleted file mode 100644 index 0af4cbfc..00000000 --- a/app/Admin/Forms/DealerBonds.php +++ /dev/null @@ -1,71 +0,0 @@ -can('dcat.admin.dealers.bonds'); - } - - /** - * Handle the form request. - * - * @param array $input - * - * @return mixed - */ - public function handle(array $input) - { - $id = $this->payload['id'] ?? 0; - - try { - DB::beginTransaction(); - $dealer = Dealer::findOrFail($id); - $dealer->update([ - 'bonds'=>$input['bonds'], - ]); - 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->currency('bonds')->required(); - } - - public function default() - { - $id = $this->payload['id'] ?? 0; - $dealer = Dealer::findOrFail($id); - return [ - 'bonds'=>$dealer->bonds, - ]; - } -} diff --git a/app/Admin/Forms/DealerEarningPay.php b/app/Admin/Forms/DealerEarningPay.php deleted file mode 100644 index cd670344..00000000 --- a/app/Admin/Forms/DealerEarningPay.php +++ /dev/null @@ -1,95 +0,0 @@ -can('dcat.admin.dealer_earnings.pay'); - } - - /** - * Handle the form request. - * - * @param array $input - * - * @return mixed - */ - public function handle(array $input) - { - $id = $this->payload['id'] ?? 0; - - try { - DB::beginTransaction(); - $earning = DealerEarning::findOrFail($id); - $earning->update([ - 'pay_way' => DealerEarning::PAY_WAY_WALLET, - 'pay_info' => $earning->getPayInfo(), - 'pay_image' => $input['pay_image'] ?? null, - 'pay_at' => now(), - 'status' => DealerEarningStatus::Completed, - ]); - //打款到余额; - $walletService = new WalletService(); - switch ($earning->earningable_type) { - case (new DealerManagerSubsidy())->getMorphClass(): - $action = DealerWalletAction::ManagerSubsidyIn; - break; - case (new DealerManageSubsidy())->getMorphClass(): - $action = DealerWalletAction::ManageSubsidyIn; - break; - case (new DealerChannelSubsidyLog())->getMorphClass(): - $action = DealerWalletAction::ChannelSubsidyIn; - break; - default: - $action = DealerWalletAction::PurchaseSubsidyIn; - break; - } - - $walletService->changeBalance($earning->user, $earning->total_earnings, $action, '收入-'.$earning->earningable_type_text, $earning); - 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/DealerEditLvl.php b/app/Admin/Forms/DealerEditLvl.php deleted file mode 100644 index 856ccfcb..00000000 --- a/app/Admin/Forms/DealerEditLvl.php +++ /dev/null @@ -1,86 +0,0 @@ -can('dcat.admin.dealers.edit_lvl'); - } - - /** - * Handle the form request. - * - * @param array $input - * - * @return mixed - */ - public function handle(array $input) - { - $id = $this->payload['id'] ?? 0; - $dealer = Dealer::findOrFail($id); - if ($dealer?->lvl->value >= $input['lvl']) { - throw new BizException('请选择大于当前的等级'); - } - try { - DB::beginTransaction(); - //执行自己升级 - $dealer->upgrade(DealerLvl::from($input['lvl']), '后台修改等级'); - //执行上级尝试升级 - foreach ($dealer->getDealers() as $parentDealer) { - $parentDealer->attemptUpgrade(); - } - // $dealer->update([ - // 'lvl'=>$input['lvl'], - // ]); - - 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() - { - // dd(UserInfo::$agentLevelTexts); - $this->select('lvl', '经销商级别')->options(DealerLvl::texts()) - ->help('请选择大于当前的身份') - ->required(); - } - - public function default() - { - $id = $this->payload['id'] ?? 0; - $dealer = Dealer::findOrFail($id); - return [ - 'lvl' => $dealer->lvl->value, - ]; - } -} diff --git a/app/Admin/Forms/DealerEditProduct.php b/app/Admin/Forms/DealerEditProduct.php deleted file mode 100644 index c0016985..00000000 --- a/app/Admin/Forms/DealerEditProduct.php +++ /dev/null @@ -1,102 +0,0 @@ -can('dcat.admin.dealers.edit_product'); - } - - /** - * Handle the form request. - * - * @param array $input - * - * @return mixed - */ - public function handle(array $input) - { - $id = $this->payload['id'] ?? 0; - try { - DB::beginTransaction(); - $product = DealerUserProduct::where([ - 'user_id' => $id, - 'product_id'=>$input['product_id'], - ])->first(); - switch ($input['type']) { - case DealerUserProductLog::TYPE_ADMIN_IN: - if (!$product) { - $product = DealerUserProduct::create([ - 'user_id' => $id, - 'product_id'=>$input['product_id'], - ]); - } - $product->increment('stock', $input['qty']); - break; - case DealerUserProductLog::TYPE_ADMIN_OUT: - if (!$product) { - throw new BizException('库存不足'); - } - $product->decrement('stock', $input['qty']); - break; - } - DealerUserProductLog::create([ - 'user_id'=> $id, - 'product_id'=> $input['product_id'], - 'type' => $input['type'], - 'qty'=>$input['qty'], - 'remark'=>'后台改动:'.$input['remark'] ?? null, - ]); - DB::commit(); - } catch (QueryException $e) { - DB::rollBack(); - if (strpos($e->getMessage(), 'Numeric value out of range') !== false) { - $e = new BizException('库存不足'); - } - throw $e; - } 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->radio('type', '操作')->options([ - DealerUserProductLog::TYPE_ADMIN_IN =>'添加', - DealerUserProductLog::TYPE_ADMIN_OUT=>'扣减', - ])->required(); - $this->select('product_id', '商品')->options(DealerProduct::all()->pluck('name', 'id')) - ->required(); - $this->number('qty', '数量')->default(1)->min(1); - $this->text('remark', '备注')->default('调整库存'); - } -} diff --git a/app/Admin/Forms/DealerOrderRefuse.php b/app/Admin/Forms/DealerOrderRefuse.php deleted file mode 100644 index e852922c..00000000 --- a/app/Admin/Forms/DealerOrderRefuse.php +++ /dev/null @@ -1,88 +0,0 @@ -payload['id'] ?? null; - - DB::beginTransaction(); - - $order = DealerOrder::lockForUpdate()->findOrFail($id); - - if (! $order->isPayWayOffline()) { - throw new BizException('订单付款方式不是线下打款'); - } - - if (! $order->isPay()) { - throw new BizException('无法收款:订单状态异常,请刷新后再试'); - } - - $order->update([ - 'status' => DealerOrderStatus::Paying, - //置空已支付的信息 - 'pay_way'=> null, - 'pay_image'=> null, - 'pay_info' => null, - 'pay_time' => null, - ]); - - $order->refuseLogs()->create([ - 'reason' => $input['reason'], - ]); - - DB::commit(); - } catch (Throwable $e) { - DB::rollBack(); - - report($e); - - return $this->response()->error('操作失败,'.$e->getMessage())->refresh(); - } - - return $this - ->response() - ->success('操作成功') - ->refresh(); - } - - /** - * Build a form here. - */ - public function form() - { - $this->textarea('reason', '原因')->required()->rules('required|max:255'); - } - - /** - * The data of the form. - * - * @return array - */ - public function default() - { - return [ - 'reason' => '', - ]; - } -} diff --git a/app/Admin/Forms/DealerOrderRemark.php b/app/Admin/Forms/DealerOrderRemark.php deleted file mode 100644 index c082aa4f..00000000 --- a/app/Admin/Forms/DealerOrderRemark.php +++ /dev/null @@ -1,70 +0,0 @@ -can('dcat.admin.dealer_orders.remark'); - } - - /** - * Handle the form request. - * - * @param array $input - * - * @return mixed - */ - public function handle(array $input) - { - $orderId = $this->payload['id'] ?? 0; - $order = DealerOrder::findOrFail($orderId); - - $remark = $input['remark']??''; - // try { - // DB::beginTransaction(); - $order->update([ - 'remark'=> $remark, - ]); - // DB::commit(); - // } catch (Throwable $th) { - // DB::rollBack(); - // report($th); - // throw new BizException('操作失败:'.$th->getMessage()); - // } - return $this->response() - ->success(__('admin.update_succeeded')) - ->refresh(); - } - - /** - * Build a form here. - */ - public function form() - { - $orderId = $this->payload['id'] ?? 0; - $order = DealerOrder::findOrFail($orderId); - - $this->text('remark')->required()->value($order->remark); - - $this->disableResetButton(); - } -} diff --git a/app/Admin/Forms/DealerProductLvlRule.php b/app/Admin/Forms/DealerProductLvlRule.php deleted file mode 100644 index f209ef19..00000000 --- a/app/Admin/Forms/DealerProductLvlRule.php +++ /dev/null @@ -1,110 +0,0 @@ -can('dcat.admin.dealer_products.lvl_rules'); - } - - /** - * Handle the form request. - * - * @param array $input - * - * @return mixed - */ - public function handle(array $input) - { - $productId = $this->payload['id'] ?? 0; - - $product = DealerProduct::findOrFail($productId); - $lvlRules = []; - $delRules = []; - foreach ($input['lvlRules'] as $rule) { - if ($rule['_remove_'] == 1) { - $delRules[] = $rule['id']; - } else { - if (is_null($rule['id'])) { - $lvlRules[] = new DealerProductLvlRuleModel($rule); - } else { - $_rule = DealerProductLvlRuleModel::find($rule['id']); - $_rule['lvl'] = $rule['lvl']; - $_rule['sale_price'] = $rule['sale_price']; - // $_rule['min_order_amount'] = $rule['min_order_amount']; - $lvlRules[] = $_rule; - } - } - } - - try { - DB::beginTransaction(); - $product->lvlRules()->saveMany($lvlRules); - - DealerProductLvlRuleModel::whereIn('id', $delRules)->delete(); - DB::commit(); - } catch (Throwable $th) { - DB::rollBack(); - report($th); - return $this->response()->error('操作失败:'.$th->getMessage())->refresh(); - } - - return $this->response() - ->success(__('admin.update_succeeded')) - ->refresh(); - } - - /** - * Build a form here. - */ - public function form() - { - $this->hasMany('lvlRules', '等级规则', function (NestedForm $form) { - $form->select('lvl')->options([ - 2 => '金牌经销商', - 3 => '特邀经销商', - 4 => '签约经销商', - 5 => '二级经销商', - 6 => '一级经销商', - ]); - $form->currency('sale_price', '等级进货单价')->symbol('¥'); - // $form->currency('min_order_amount', '等级单次最低进货价')->symbol('¥'); - }); - } - - /** - * The data of the form. - * - * @return array - */ - public function default() - { - $productId = $this->payload['id'] ?? 0; - - $product = DealerProduct::findOrFail($productId); - return [ - 'lvlRules' => $product->lvlRules, - // 'email' => 'John.Doe@gmail.com', - ]; - } -} diff --git a/app/Admin/Forms/DealerProductManageRule.php b/app/Admin/Forms/DealerProductManageRule.php deleted file mode 100644 index 7db29624..00000000 --- a/app/Admin/Forms/DealerProductManageRule.php +++ /dev/null @@ -1,109 +0,0 @@ -can('dcat.admin.dealer_products.manage_rules'); - } - - /** - * Handle the form request. - * - * @param array $input - * - * @return mixed - */ - public function handle(array $input) - { - $productId = $this->payload['id'] ?? 0; - - $product = DealerProduct::findOrFail($productId); - $manageRules = []; - $delRules = []; - foreach ($input['manageRules'] as $rule) { - if ($rule['_remove_'] == 1) { - $delRules[] = $rule['id']; - } else { - if (is_null($rule['id'])) { - $manageRules[] = new DealerProductManageRuleModel($rule); - } else { - $_rule = DealerProductManageRuleModel::find($rule['id']); - $_rule['lvl'] = $rule['lvl']; - $_rule['price_1st'] = $rule['price_1st']; - $_rule['price_2st'] = $rule['price_2st']; - $_rule['price_3st'] = $rule['price_3st']; - $manageRules[] = $_rule; - } - } - } - - try { - DB::beginTransaction(); - $product->lvlRules()->saveMany($manageRules); - - DealerProductManageRuleModel::whereIn('id', $delRules)->delete(); - DB::commit(); - } catch (Throwable $th) { - DB::rollBack(); - report($th); - return $this->response()->error('操作失败:'.$th->getMessage())->refresh(); - } - - return $this->response() - ->success(__('admin.update_succeeded')) - ->refresh(); - } - - /** - * Build a form here. - */ - public function form() - { - $this->hasMany('manageRules', '管理规则', function (NestedForm $form) { - $form->select('lvl')->options([ - 5 => '二级经销商', - 6 => '一级经销商', - ]); - $form->currency('price_1st', '价格1')->symbol('¥')->required(); - $form->currency('price_2st', '价格2')->symbol('¥')->required(); - $form->currency('price_3st', '价格3')->symbol('¥')->required(); - }); - } - - /** - * The data of the form. - * - * @return array - */ - public function default() - { - $productId = $this->payload['id'] ?? 0; - - $product = DealerProduct::findOrFail($productId); - return [ - 'manageRules' => $product->manageRules, - // 'email' => 'John.Doe@gmail.com', - ]; - } -} diff --git a/app/Admin/Forms/DealerProductSaleRule.php b/app/Admin/Forms/DealerProductSaleRule.php deleted file mode 100644 index 5700bf97..00000000 --- a/app/Admin/Forms/DealerProductSaleRule.php +++ /dev/null @@ -1,101 +0,0 @@ -can('dcat.admin.dealer_products.sale_rules'); - } - - /** - * Handle the form request. - * - * @param array $input - * - * @return mixed - */ - public function handle(array $input) - { - $productId = $this->payload['id'] ?? 0; - - $product = DealerProduct::findOrFail($productId); - $saleRules = []; - $delRules = []; - foreach ($input['saleRules'] as $rule) { - if ($rule['_remove_'] == 1) { - $delRules[] = $rule['id']; - } else { - if (is_null($rule['id'])) { - $saleRules[] = new DealerProductSaleRuleModel($rule); - } else { - $_rule = DealerProductSaleRuleModel::find($rule['id']); - $_rule['qty'] = $rule['qty']; - $_rule['price'] = $rule['price']; - $saleRules[] = $_rule; - } - } - } - - try { - DB::beginTransaction(); - $product->saleRules()->saveMany($saleRules); - - DealerProductSaleRuleModel::whereIn('id', $delRules)->delete(); - DB::commit(); - } catch (Throwable $th) { - DB::rollBack(); - report($th); - return $this->response()->error('操作失败:'.$th->getMessage())->refresh(); - } - - return $this->response() - ->success(__('admin.update_succeeded')) - ->refresh(); - } - - /** - * Build a form here. - */ - public function form() - { - $this->hasMany('saleRules', '销售规则', function (NestedForm $form) { - $form->number('qty', '达到数量')->min(0); - $form->currency('price', '进货单价')->symbol('¥'); - }); - } - - /** - * The data of the form. - * - * @return array - */ - public function default() - { - $productId = $this->payload['id'] ?? 0; - - $product = DealerProduct::findOrFail($productId); - return [ - 'saleRules' => $product->saleRules, - ]; - } -} diff --git a/app/Admin/Forms/DealerWalletChange.php b/app/Admin/Forms/DealerWalletChange.php deleted file mode 100644 index badd8da6..00000000 --- a/app/Admin/Forms/DealerWalletChange.php +++ /dev/null @@ -1,90 +0,0 @@ -can('dcat.admin.dealers.wallet_change'); - } - - /** - * Handle the form request. - * - * @param array $input - * - * @return mixed - */ - public function handle(array $input) - { - if (bccomp($input['change_balance'], '0', 2) <= 0) { - return $this->response()->error('金额必须大于0'); - } - - $dealer = Dealer::findOrFail($this->payload['id']); - - $action = DealerWalletAction::from($input['action']); - - try { - DB::beginTransaction(); - - (new WalletService())->changeBalance( - $dealer->user, - match ($action) { - DealerWalletAction::Recharge => bcmul($input['change_balance'], '1', 2), - DealerWalletAction::Deduct => bcmul($input['change_balance'], '-1', 2), - }, - $action, - $input['remarks'], - Admin::user() - ); - - 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->radio('action', '操作') - ->options([ - DealerWalletAction::Recharge->value => '充值', - DealerWalletAction::Deduct->value => '扣除', - ]) - ->default(DealerWalletAction::Recharge->value) - ->required(); - $this->currency('change_balance', '金额')->symbol('¥')->required(); - $this->textarea('remarks', '备注')->required(); - $this->confirm('是否确认充值?', '提交后该动作无法逆转'); - } -} diff --git a/app/Admin/Forms/DealerWalletPay.php b/app/Admin/Forms/DealerWalletPay.php deleted file mode 100644 index e85dc869..00000000 --- a/app/Admin/Forms/DealerWalletPay.php +++ /dev/null @@ -1,80 +0,0 @@ -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::lockForUpdate()->findOrFail($id); - - if (! in_array($log->status, [DealerWalletToBankLogStatus::Pending, DealerWalletToBankLogStatus::Failed])) { - throw new BizException('提现记录状态异常'); - } - - $log->pay_info = $log->user->dealer->pay_info; - $log->pay_image = $input['pay_image'] ?? null; - $log->pay_way = DealerWalletToBankLogPayWay::Offline; - $log->pay_at = now(); - $log->status = DealerWalletToBankLogStatus::Success; - $log->save(); - - 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 deleted file mode 100644 index 973d727b..00000000 --- a/app/Admin/Forms/DealerWalletRefuse.php +++ /dev/null @@ -1,69 +0,0 @@ -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' => DealerWalletToBankLogStatus::Refused, - ]); - //打回余额 - $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/Forms/Settings/Dealer.php b/app/Admin/Forms/Settings/Dealer.php deleted file mode 100644 index 46ffb3e3..00000000 --- a/app/Admin/Forms/Settings/Dealer.php +++ /dev/null @@ -1,166 +0,0 @@ -updateOrCreate([ - 'key' => 'dealer', - ], ['value' => $input]); - - //清配置缓存 - app(SettingService::class)->cleanCache('dealer'); - - return $this - ->response() - ->success('配置更新成功!') - ->refresh(); - } - - /** - * Build a form here. - */ - public function form() - { - $this->switch('wxpay_switch', '微信支付'); - $this->currency('delivery_bill_shipping_fee', '云仓运费')->symbol('¥'); - $this->currency('fee_rate', '手续费比例(百分比)')->symbol('%'); - $this->number('withdraw_threshold_amount', '起提金额(元)'); - $this->currency('withdraw_fee_rate', '提现费率')->symbol('%'); - $this->number('withdraw_days', '提现间隔'); - - $this->currency('upgrade_amount_'.DealerLvl::Gold->value, '金牌升级门槛')->symbol('¥'); - $this->currency('upgrade_amount_'.DealerLvl::Special->value, '特邀升级门槛')->symbol('¥'); - $this->currency('upgrade_amount_'.DealerLvl::Contracted->value, '签约升级门槛')->symbol('¥'); - - $this->currency('min_order_amount_'.DealerLvl::Gold->value, '金牌单次进货最低金额')->symbol('¥'); - $this->currency('min_order_amount_'.DealerLvl::Special->value, '特邀单次进货最低金额')->symbol('¥'); - $this->currency('min_order_amount_'.DealerLvl::Contracted->value, '签约单次进货最低金额')->symbol('¥'); - $this->currency('min_order_amount_'.DealerLvl::Secondary->value, '二级签约单次进货最低金额')->symbol('¥'); - $this->currency('min_order_amount_'.DealerLvl::Top->value, '一级签约单次进货最低金额')->symbol('¥'); - - $this->number('order_auto_allocate_times', '订单自动分配时间(分)')->min(1); - - $this->divider('签约->签约->签约'); - $this->currency('channel_rules.'.DealerLvl::Contracted->value.'_'.DealerLvl::Contracted->value.'.'.DealerLvl::Contracted->value.'_0', '签约0')->symbol('¥'); - $this->currency('channel_rules.'.DealerLvl::Contracted->value.'_'.DealerLvl::Contracted->value.'.'.DealerLvl::Contracted->value.'_1', '签约1')->symbol('¥'); - $this->divider('签约->特邀->签约->签约'); - $this->currency('channel_rules.'.DealerLvl::Contracted->value.'_'.DealerLvl::Special->value.'.'.DealerLvl::Special->value.'_0', '特邀0')->symbol('¥'); - $this->currency('channel_rules.'.DealerLvl::Contracted->value.'_'.DealerLvl::Special->value.'.'.DealerLvl::Contracted->value.'_1', '签约1')->symbol('¥'); - $this->currency('channel_rules.'.DealerLvl::Contracted->value.'_'.DealerLvl::Special->value.'.'.DealerLvl::Contracted->value.'_2', '签约2')->symbol('¥'); - $this->divider('特邀->特邀->特邀'); - $this->currency('channel_rules.'.DealerLvl::Special->value.'_'.DealerLvl::Special->value.'.'.DealerLvl::Special->value.'_0', '特邀0')->symbol('¥'); - $this->currency('channel_rules.'.DealerLvl::Special->value.'_'.DealerLvl::Special->value.'.'.DealerLvl::Special->value.'_1', '特邀1')->symbol('¥'); - $this->divider('特邀->金牌->特邀->特邀'); - $this->currency('channel_rules.'.DealerLvl::Special->value.'_'.DealerLvl::Gold->value.'.'.DealerLvl::Gold->value.'_0', '金牌0')->symbol('¥'); - $this->currency('channel_rules.'.DealerLvl::Special->value.'_'.DealerLvl::Gold->value.'.'.DealerLvl::Special->value.'_1', '特邀1')->symbol('¥'); - $this->currency('channel_rules.'.DealerLvl::Special->value.'_'.DealerLvl::Gold->value.'.'.DealerLvl::Special->value.'_2', '特邀2')->symbol('¥'); - $this->divider('金牌->金牌'); - $this->currency('channel_rules.'.DealerLvl::Gold->value.'_'.DealerLvl::Gold->value.'.'.DealerLvl::Gold->value.'_0', '金牌0')->symbol('¥'); - - - // $this->embeds('channel_rules.'.DealerLvl::Contracted->value.'_'.DealerLvl::Contracted->value, '渠道补贴规则(签约->签约->签约)', function ($form) { - // $form->currency(DealerLvl::Contracted->value.'_0', '签约0')->symbol('¥'); - // $form->currency(DealerLvl::Contracted->value.'_1', '签约1')->symbol('¥'); - // }); - // $this->embeds('channel_rules.'.DealerLvl::Contracted->value.'_'.DealerLvl::Special->value, '渠道补贴规则(签约->特邀->签约->签约)', function ($form) { - // $form->currency(DealerLvl::Special->value.'_0', '特邀0')->symbol('¥'); - // $form->currency(DealerLvl::Contracted->value.'_1', '签约1')->symbol('¥'); - // $form->currency(DealerLvl::Contracted->value.'_2', '签约2')->symbol('¥'); - // }); - // $this->embeds('channel_rules.'.DealerLvl::Special->value.'_'.DealerLvl::Special->value, '渠道补贴规则(特邀->特邀->特邀)', function ($form) { - // $form->currency(DealerLvl::Special->value.'_0', '特邀0')->symbol('¥'); - // $form->currency(DealerLvl::Special->value.'_1', '特邀1')->symbol('¥'); - // }); - // $this->embeds('channel_rules.'.DealerLvl::Special->value.'_'.DealerLvl::Gold->value, '渠道补贴规则(特邀->金牌->特邀->特邀)', function ($form) { - // $form->currency(DealerLvl::Gold->value.'_0', '金牌0')->symbol('¥'); - // $form->currency(DealerLvl::Special->value.'_1', '特邀1')->symbol('¥'); - // $form->currency(DealerLvl::Special->value.'_2', '特邀2')->symbol('¥'); - // }); - // $this->embeds('channel_rules.'.DealerLvl::Gold->value.'_'.DealerLvl::Gold->value, '渠道补贴规则(金牌->金牌)', function ($form) { - // $form->currency(DealerLvl::Gold->value.'_0', '金牌0')->symbol('¥'); - // }); - - $this->table('purchase_rules', '进货补贴规则', function ($table) { - $table->number('price', '阶梯(万)'); - $table->currency('rate', '比例(百分比)')->symbol('%'); - })->disableCreate()->disableDelete(); - // $this->embeds('pay_info', '公司收款信息', function ($form) { - $this->divider('银行账号收款'); - $this->text('bank.user_name', '收款人名称'); - $this->text('bank.bank_name', '银行名称'); - $this->text('bank.bank_number', '银行卡号'); - $this->text('bank.bank_description', '开户行'); - $this->divider('支付宝收款'); - $this->text('alipay.user_name', '收款人名称'); - $this->text('alipay.ali_name', '收款账号'); - $this->image('alipay.image', '收款码') - ->move('dealer/settings/'.Carbon::now()->toDateString()) - ->saveFullUrl() - ->removable(false) - ->retainable() - ->autoUpload(); - $this->divider('微信收款'); - $this->text('wechat.user_name', '收款人名称'); - $this->text('wechat.wechat_name', '微信ID'); - $this->image('wechat.image', '收款码') - ->move('dealer/settings/'.Carbon::now()->toDateString()) - ->saveFullUrl() - ->removable(false) - ->retainable() - ->autoUpload(); - - // })->saving(function ($v) { - // // 转化为json格式存储 - // dd($v); - // return json_encode($v); - // })->customFormat(function () use ($dealerSettings) { - // return $dealerSettings['pay_info']??[]; - // }); - } - - public function default() - { - $dealerSettings = (array) Setting::where('key', 'dealer')->value('value'); - return [ - 'wxpay_switch'=> $dealerSettings['wxpay_switch'] ?? 1, - 'delivery_bill_shipping_fee'=> $dealerSettings['delivery_bill_shipping_fee'] ?? 0, - 'fee_rate'=> $dealerSettings['fee_rate'] ?? '', - 'withdraw_threshold_amount'=> $dealerSettings['withdraw_threshold_amount'] ?? 0, - 'withdraw_fee_rate'=> $dealerSettings['withdraw_fee_rate'] ?? 0, - 'withdraw_days'=> $dealerSettings['withdraw_days'] ?? 7, - 'order_auto_allocate_times'=> $dealerSettings['order_auto_allocate_times'] ?? 1, - 'upgrade_amount_'.DealerLvl::Contracted->value => $dealerSettings['upgrade_amount_'.DealerLvl::Contracted->value] ?? '', - 'upgrade_amount_'.DealerLvl::Special->value => $dealerSettings['upgrade_amount_'.DealerLvl::Special->value] ?? '', - 'upgrade_amount_'.DealerLvl::Gold->value => $dealerSettings['upgrade_amount_'.DealerLvl::Gold->value] ?? '', - - 'min_order_amount_'.DealerLvl::Gold->value => $dealerSettings['min_order_amount_'.DealerLvl::Gold->value] ?? '', - 'min_order_amount_'.DealerLvl::Special->value => $dealerSettings['min_order_amount_'.DealerLvl::Special->value] ?? '', - 'min_order_amount_'.DealerLvl::Contracted->value => $dealerSettings['min_order_amount_'.DealerLvl::Contracted->value] ?? '', - 'min_order_amount_'.DealerLvl::Secondary->value => $dealerSettings['min_order_amount_'.DealerLvl::Secondary->value] ?? '', - 'min_order_amount_'.DealerLvl::Top->value => $dealerSettings['min_order_amount_'.DealerLvl::Top->value] ?? '', - - 'bank'=>$dealerSettings['bank'] ?? [], - 'alipay'=>$dealerSettings['alipay'] ?? [], - 'wechat' =>$dealerSettings['wechat'] ?? [], - 'purchase_rules'=>$dealerSettings['purchase_rules'] ?? [], - 'channel_rules'=>$dealerSettings['channel_rules'] ?? [], - ]; - } -} diff --git a/app/Admin/Imports/DealerOrderImport.php b/app/Admin/Imports/DealerOrderImport.php deleted file mode 100644 index 2b77547d..00000000 --- a/app/Admin/Imports/DealerOrderImport.php +++ /dev/null @@ -1,722 +0,0 @@ -getCellAtIndex(0)?->getValue(); - if (empty($phone)) { - throw new ImportException('未输入下单用户手机号'); - } - //获取下单盒数; - $qty = $row->getCellAtIndex(1)?->getValue(); - if (empty($qty)) { - throw new ImportException('未输入下单盒数'); - } - //获取下单金额; - $totalAmount = $row->getCellAtIndex(2)?->getValue(); - if (empty($totalAmount)) { - throw new ImportException('未输入下单金额'); - } - //获取目标等级 - $toLv = $row->getCellAtIndex(3)?->getValue(); - if (empty($toLv)) { - throw new ImportException('未输入目标等级'); - } - - $productId = $row->getCellAtIndex(4)?->getValue(); - if (empty($productId)) { - $productId = 1; - } - - $user = User::where('phone', $phone)->first(); - dump('手机号:'.$phone.'开始执行'); - if ($user) { - $orderService = new OrderService(); - - $product = DealerProduct::findOrFail($productId); - $shippingAddress = $user->shippingAddresses()->orderBy('is_default', 'desc')->first(); - try { - DB::beginTransaction(); - //执行自己升级 - if ($toLv < 4) { - $user->dealer->upgrade(DealerLvl::from($toLv), '0217后台修改等级'); - //执行上级尝试升级 - foreach ($user->dealer->getDealers() as $parentDealer) { - $parentDealer->attemptUpgrade(); - } - } else { - /**下单 -start **/ - //没有地址 - if (!$shippingAddress) { - $shippingAddress = $user->shippingAddresses()->create([ - 'zone_id'=>3, - 'zone'=>'北京市 北京市 东城区', - 'consignee'=>'测试', - 'telephone'=>'18888888888', - 'address'=>'1', - 'is_default'=>true, - ]); - } - $order = $orderService->quickCreateOrder($user, $product, $qty, $shippingAddress->id); - //重新按新规则给一次发货人 - if ($order->consignor_id) { - $order->update([ - 'consignor_id'=>$this->getConsignor($user, $order->total_amount)?->user_id, - ]); - $order->refresh(); - if (!($order->consignor_id > 1)) {//如果是null或者1 - //确认接单 - $order = $orderService->confirmOrder($order); - } - } - /**下单 -end **/ - dump('下单:'.$order->sn); - /**更新订单状态 -start **/ - //【金牌】,【特邀】订单需要发货人有对应的库存,否则往上丢 - if (in_array($toLv, [ - '2', '3', - ])) { - do { - if ($order->consignor_id > 1) { - $userProduct = DealerUserProduct::where('user_id', $order->consignor_id)->where('stock', '>', 0)->first(); - if (!$userProduct) { - //没找到库存商品,则继续往上丢 - $order = $this->updateOrderConsignor($order); - $order->refresh(); - } else { - // if ($userProduct->stock < $qty) { - // //记录手机号 - // } - } - } else { - break; - } - } while (!$userProduct); - } - if ($order->isPending()) { - //确认接单 - $order = $orderService->confirmOrder($order); - } - //确认打款 - $order = $orderService->payOrder($order, 'offline'); - //确认收款 - $order = $orderService->paidOrder($order); - - //如果目标等级是【金牌】【特邀】则只到【待发货】。其余订单走到【已完成】 - if (!in_array($toLv, [ - '2', '3', - ])) { - //确认发货 - $order = $orderService->shippingOrder($order); - //确认收货 - $order = $orderService->shippingedOrder($order); - } - - /**更新订单状态 -end **/ - - //执行升级结算订单 - $this->handleDealerOrder($order); - } - DB::commit(); - } catch (QueryException $e) { - DB::rollBack(); - if (strpos($e->getMessage(), 'Numeric value out of range') !== false) { - $e = new BizException('当前可发货库存不足'); - } - throw $e; - } catch (Throwable $th) { - DB::rollBack(); - report($th); - throw new BizException($th->getMessage()); - } - } else { - throw new ImportException('未找到用户:'.$phone); - } - } - - /** - * 更新订单发货人 - * - * @return DealerOrder - */ - public function updateOrderConsignor(DealerOrder $order) - { - //只处理当前订单有发货人的情况 - if ($order->consignor) { - $consignor = $this->getConsignor($order->user, $order->total_amount, $order->consignor); - $oldConsignor = $order->consignor; - $order->update([ - 'allocated_at' => now(), - 'consignor_id' => $consignor?->user_id, - ]); - //记录分配日志 - DealerOrderAllocateLog::create([ - 'order_id'=>$order->id, - 'last_consignor_id'=>$oldConsignor->id, - 'new_consignor_id' =>$order->consignor_id, - ]); - } - return $order; - } - - private function getConsignor(User $user, $totalAmount, ?User $lastConsignor = null) - { - $rules = [ - [ - 'amount' => '2640', - 'lvl' => DealerLvl::Contracted, - ], - [ - 'amount' => '860', - 'lvl' => DealerLvl::Special, - ], - [ - 'amount' => '630', - 'lvl' => DealerLvl::Gold, - ], - ]; - $lvl = $user->dealer->lvl; - //计算通过这个订单可能升级成为的身份 - foreach ($rules as $rule) { - if ($totalAmount >= $rule['amount'] && $lvl->value < $rule['lvl']->value) { - $lvl = $rule['lvl']; - } - } - //如果是签约单,直接抛到公司后台发货 - if ($lvl->value >= DealerLvl::Contracted->value) { - return null; - } - //新逻辑 - $consignor = null; - $_lastConsignor = $lastConsignor; - do { - $query = User::with(['userInfo', 'dealer']); - if ($_lastConsignor) { - $query->where('id', $_lastConsignor->userInfo->real_inviter_id); - } else { - $query->where('id', $user->userInfo->real_inviter_id); - } - $consignor = $query->first(); - if ($consignor) {//找到老上级 - if ($consignor->dealer->is_sale == true && $consignor->dealer->lvl->value > $lvl->value) { - break; - } else { - $_lastConsignor = $consignor; - $consignor = null; - } - } else {//如果找不到人了 - $consignor = $lastConsignor; - break; - } - } while (empty($consignor)); - - return $consignor?->userInfo; - } - - /** - * 处理经销商订单 - * - * @param \App\Models\DealerOrder $dealerOrder - * @return void - */ - protected function handleDealerOrder(DealerOrder $dealerOrder) - { - $tz = now()->toDateTimeString(); - - // 上级经销商 - $ancestors = $dealerOrder->dealer->getDealers(); - - // 签约经销商的进货日志 - $this->handlePurchaseLogsOfContractedDealer($dealerOrder, $tz); - - // 一级签约经销商和二级经销商的管理津贴 - $this->handleManageSubsidyLogs($dealerOrder, $ancestors, $tz); - - // 管理者的销售业绩 - $this->handleManagerSalesLogs($dealerOrder, $ancestors, $tz); - - // 渠道补贴 - $this->handleChannelSubsidy($dealerOrder); - - if ($dealerOrder->dealer->wasChanged('lvl')) { - $dealers = [ - $dealerOrder->dealer, - ...$ancestors, - ]; - - foreach ($dealers as $dealer) { - $dealer->attemptUpgrade(); - } - } - - // 将订单标记为已处理 - $dealerOrder->forceFill([ - 'settle_state' => DealerOrderSettleState::Processed, - ])->save(); - } - - /** - * 计算渠道补贴 - * - * @param \App\Models\DealerOrder $dealerOrder - * @return void - */ - protected function handleChannelSubsidy(DealerOrder $dealerOrder) - { - $lvl = $dealerOrder->dealer->lvl; - - $lvlValue = [ - DealerLvl::Contracted->value => '2640', - DealerLvl::Special->value => '860', - DealerLvl::Gold->value => '630', - - ]; - - if ($dealerOrder->total_amount >= $lvlValue[DealerLvl::Contracted->value]) { - // 升级为签约 - if ($lvl->value < DealerLvl::Contracted->value) { - $lvl = DealerLvl::Contracted; - } - } elseif ($dealerOrder->total_amount >= $lvlValue[DealerLvl::Special->value]) { - // 升级为特约 - if ($lvl->value < DealerLvl::Special->value) { - $lvl = DealerLvl::Special; - } - } elseif ($dealerOrder->total_amount >= $lvlValue[DealerLvl::Gold->value]) { - // 升级为金牌 - if ($lvl->value < DealerLvl::Gold->value) { - $lvl = DealerLvl::Gold; - } - } - - // 如果经销商等级小于金牌,则没有渠道补贴 - if ($lvl->value < DealerLvl::Gold->value) { - return; - } - - [$dealers, $rule] = $this->mapDealersAndRuleOfChannel($dealerOrder->dealer, $lvl); - - if ($lvl->value >= DealerLvl::Contracted->value) { - $upgradeAmount = $lvlValue[DealerLvl::Contracted->value]; - } else { - $upgradeAmount = $lvlValue[$lvl->value]; - } - - // 手续费比例 - $feeRate = app_settings('dealer.fee_rate'); - - foreach ($dealers as $key => $dealer) { - $ruleKey = $dealer->lvl->value.'_'.$key; - - if ($dealer->lvl->value >= DealerLvl::Contracted->value) { - $ruleKey = DealerLvl::Contracted->value.'_'.$key; - } - - // 补贴金额 - $subsidyAmount = $rule[$ruleKey]; - - $totalAmount = bcmul($subsidyAmount, $dealerOrder->total_amount, 10); - $totalAmount = bcdiv($totalAmount, $upgradeAmount, 3); - $totalAmount = round($totalAmount, 2); - - $channelSubsidyLog = DealerChannelSubsidyLog::create([ - 'user_id' => $dealer->user_id, - 'lvl' => $dealer->lvl, - 'order_id' => $dealerOrder->id, - 'total_amount' => $totalAmount, - 'order_id' => $dealerOrder->id, - 'remark' => "补贴总额={$dealerOrder->total_amount}/{$upgradeAmount}*{$subsidyAmount}", - ]); - - $fee = bcmul($channelSubsidyLog->total_amount, bcdiv($feeRate, '100', 5), 3); - $fee = round($fee, 2); - - $channelSubsidyLog->earning()->create([ - 'user_id' => $channelSubsidyLog->user_id, - 'lvl' => $channelSubsidyLog->lvl, - 'total_amount' => $channelSubsidyLog->total_amount, - 'total_earnings' => bcsub($channelSubsidyLog->total_amount, $fee, 2), - 'fee' => $fee, - 'fee_rate' => $feeRate, - 'payer_id' => $dealerOrder->consignor_id, - 'status' => DealerEarningStatus::Pending, - 'remark' => "订单号: {$dealerOrder->sn}", - ]); - } - - $dealerOrder->dealer->upgrade($lvl, '进货升级'); - } - - /** - * 获取渠道补贴经销商和补贴规则 - * - * @param \App\Models\Dealer $dealer - * @param \App\Enums\DealerLvl $lvl - * @return array - */ - protected function mapDealersAndRuleOfChannel(Dealer $dealer, DealerLvl $lvl): array - { - // 渠道补贴经销商 - $dealers = []; - // 渠道补贴规则 - $rule = null; - // 是否升级 - $isUp = $lvl->value > $dealer->lvl->value; - // 最后参与渠道补贴的经销商 - $last = null; - // 前一个直属邀请人 - $previous = null; - - while (true) { - if ($previous) { - $_dealer = $previous->userInfo->realInviterInfo?->dealer; - $_dealer?->setRelation('userInfo', $previous->userInfo->realInviterInfo); - } else { - $_dealer = $dealer->userInfo->realInviterInfo?->dealer; - $_dealer?->setRelation('userInfo', $dealer->userInfo->realInviterInfo); - } - - $previous = $_dealer; - - if ($_dealer === null) { - break; - } - - // 如果经销商等级小于金牌, 那么跳过 - if ($_dealer->lvl->value < DealerLvl::Gold->value) { - continue; - } - - if ($lvl->value >= DealerLvl::Contracted->value) { - if ($last === null) { - if ($_dealer->lvl->value >= DealerLvl::Contracted->value) { - // 渠道补贴规则: 签约 -> 签约 -> 签约 - $rule = [ - DealerLvl::Contracted->value.'_0' => '396', - DealerLvl::Contracted->value.'_1' => '79', - ]; - - $dealers[] = $_dealer; - - $last = $_dealer; - } elseif ($isUp && $_dealer->isSpecialDealer()) { - // 渠道补贴规则: 签约 -> 特邀 -> 签约 -> 签约 - $rule = [ - DealerLvl::Special->value.'_0' => '264', - DealerLvl::Contracted->value.'_1' => '132', - DealerLvl::Contracted->value.'_2' => '79', - ]; - - $dealers[] = $_dealer; - - $last = $_dealer; - } - } elseif ($_dealer->lvl->value >= DealerLvl::Contracted->value) { - $dealers[] = $_dealer; - - // 如果最后参与渠道补贴的经销商是签约, 那么已经找到所有参与渠道补贴的经销商 - if ($last->lvl->value >= DealerLvl::Contracted->value) { - break; - } - - $last = $_dealer; - } - } elseif ($lvl === DealerLvl::Special) { - if ($_dealer->lvl->value > DealerLvl::Special->value) { - break; - } - - if ($last === null) { - if ($_dealer->isSpecialDealer()) { - // 渠道补贴规则: 特邀 -> 特邀 -> 特邀 - $rule = [ - DealerLvl::Special->value.'_0' => '80', - DealerLvl::Special->value.'_1' => '20', - ]; - - $dealers[] = $_dealer; - - $last = $_dealer; - } elseif ($isUp && $_dealer->isGoldDealer()) { - // 渠道补贴规则: 特邀 -> 金牌 -> 特邀 -> 特邀 - $rule = [ - DealerLvl::Gold->value.'_0' => '50', - DealerLvl::Special->value.'_1' => '30', - DealerLvl::Special->value.'_2' => '20', - ]; - - $dealers[] = $_dealer; - - $last = $_dealer; - } - } elseif ($_dealer->isSpecialDealer()) { - $dealers[] = $_dealer; - - if ($last->isSpecialDealer()) { - break; - } - - $last = $_dealer; - } - } elseif ($lvl === DealerLvl::Gold) { - if ($_dealer->lvl->value >= DealerLvl::Gold->value) { - if ($_dealer->isGoldDealer()) { - // 渠道补贴规则: 金牌 -> 金牌 - $rule = [ - DealerLvl::Gold->value.'_0' => '75', - ]; - - $dealers[] = $_dealer; - } - - break; - } - } - } - - return [$dealers, $rule]; - } - - /** - * 生成签约经销商的进货日志 - * - * @param \App\Models\DealerOrder $dealerOrder - * @param array $dealers - * @param string $tz - * @return void - */ - protected function handlePurchaseLogsOfContractedDealer(DealerOrder $dealerOrder, string $tz) - { - if (! $this->isContractedDealerToPurchase($dealerOrder)) { - return; - } - - $dealer = $dealerOrder->userInfo->dealer; - - // 采购业绩是否算自己的业绩 - $valid = $dealer->lvl->value >= DealerLvl::Contracted->value; - - $log = new DealerPurchaseLog([ - 'user_id' => $dealer->user_id, - 'lvl' => $dealer->lvl, - 'order_id' => $dealerOrder->id, - 'total_amount' => $dealerOrder->total_amount, - 'path' => $valid ? $dealerOrder->userInfo->full_path : $dealerOrder->userInfo->path, - 'remark' => $valid ? null : '升级签约', - ]); - $log->setCreatedAt($tz); - $log->setUpdatedAt($tz); - $log->save(); - } - - /** - * 分配一级签约经销商和二级经销商的管理津贴 - * - * @param \App\Models\DealerOrder $dealerOrder - * @param array $dealers - * @param string $tz - * @return void - */ - protected function handleManageSubsidyLogs(DealerOrder $dealerOrder, array $dealers, string $tz) - { - if (! $this->isContractedDealerToPurchase($dealerOrder)) { - return; - } - - $logs = []; - - foreach ($dealerOrder->products as $product) { - if ($product->productManageSubsidyRules->isEmpty()) { - continue; - } - - // 管理津贴分配规则 - $rules = $product->productManageSubsidyRules->keyBy('lvl'); - - $last = null; - $ranking = 0; - - foreach ($dealers as $dealer) { - if (! in_array($dealer->lvl, [DealerLvl::Secondary, DealerLvl::Top])) { - continue; - } - - // 如果当前经销商等级没有对应的管理津贴分配规则,则忽略 - if (is_null($rule = $rules->get($dealer->lvl->value))) { - continue; - } - - // 同等级管理津贴最多给三次 - if ($last === null || $dealer->lvl->value > $last->lvl->value) { - if ($ranking < 3 && $dealer->lvl === DealerLvl::Top) { - if ($secondarySubsidyRule = $rules->get(DealerLvl::Secondary->value)) { - $key = 'price_'.(1 + $ranking).'st'; - - $secondarySubsidy = $secondarySubsidyRule->{$key}; - - if (bccomp($secondarySubsidy, '0') === 1) { - $logs[] = [ - 'user_id' => $dealer->user_id, - 'order_id' => $product->order_id, - 'product_id' => $product->product_id, - 'lvl' => $dealer->lvl, - 'sales_volume' => $product->qty, - 'total_amount' => bcmul($product->qty, $secondarySubsidy, 2), - 'created_at' => $tz, - 'updated_at' => $tz, - ]; - } - } - } - - $ranking = 1; - } elseif ($ranking < 3 && $dealer->lvl->value === $last->lvl->value) { - $ranking++; - } else { - continue; - } - - $subsidy = $rule->{"price_{$ranking}st"}; - - if (bccomp($subsidy, '0') === 1) { - $logs[] = [ - 'user_id' => $dealer->user_id, - 'order_id' => $product->order_id, - 'product_id' => $product->product_id, - 'lvl' => $dealer->lvl, - 'sales_volume' => $product->qty, - 'total_amount' => bcmul($product->qty, $subsidy, 2), - 'created_at' => $tz, - 'updated_at' => $tz, - ]; - } - - $last = $dealer; - } - } - - DealerManageSubsidyLog::insert($logs); - } - - /** - * 过滤出可能会享受管理津贴的经销商(每个等级最多3人) - * - * @param array $dealers - * @return array - */ - protected function mapManageSubsidyDealers(array $dealers): array - { - $map = []; - $last = null; - $ranking = 1; - - foreach ($dealers as $dealer) { - if ($last === null || $dealer->lvl->value > $last->lvl->value) { - $last = $dealer; - $map[] = $last; - $ranking = 1; - } elseif ($ranking < 3 && $dealer->lvl->value === $last->lvl->value) { - $last = $dealer; - $map[] = $last; - $ranking++; - } - } - - return $map; - } - - /** - * 生成管理者的销售业绩 - * - * @param \App\Models\DealerOrder $dealerOrder - * @param array $dealers - * @param string $tz - * @return void - */ - protected function handleManagerSalesLogs(DealerOrder $dealerOrder, array $dealers, string $tz): void - { - if (! $this->isContractedDealerToPurchase($dealerOrder)) { - return; - } - - if (is_null($manager = $this->firstManager($dealers))) { - return; - } - - $logs = []; - - foreach ($dealerOrder->products as $product) { - $logs[] = [ - 'user_id' => $manager->user_id, - 'lvl' => $manager->lvl, - 'order_id' => $product->order_id, - 'product_id' => $product->product_id, - 'sales_volume' => $product->qty, - 'created_at' => $tz, - 'updated_at' => $tz, - ]; - } - - DealerManagerSalesLog::insert($logs); - } - - /** - * 从给定的经销商中获取第一个管理者 - * - * @param array $dealers - * @return \App\Models\Dealer|null - */ - protected function firstManager(array $dealers): ?Dealer - { - foreach ($dealers as $dealer) { - if ($dealer->is_manager) { - return $dealer; - } - } - return null; - } - - /** - * 确认是否是签约经销商进货 - * - * @param DealerOrder $dealerOrder - * @return bool - */ - protected function isContractedDealerToPurchase(DealerOrder $dealerOrder): bool - { - $dealer = $dealerOrder->userInfo->dealer; - - if ($dealer->lvl->value < DealerLvl::Contracted->value) { - if ($dealerOrder->total_amount < '2640') { - return false; - } - } - - return true; - } -} diff --git a/app/Admin/Metrics/StatisticsTotal.php b/app/Admin/Metrics/StatisticsTotal.php index ca6649a6..16a095a4 100644 --- a/app/Admin/Metrics/StatisticsTotal.php +++ b/app/Admin/Metrics/StatisticsTotal.php @@ -3,7 +3,6 @@ namespace App\Admin\Metrics; use App\Models\Balance; -use App\Models\DealerWallet; use App\Models\DistributionPreIncome; use App\Models\UserInfo; use App\Models\Wallet; @@ -41,7 +40,6 @@ class StatisticsTotal extends RadialBar 'total_distribution'=> DistributionPreIncome::unsettlement()->sum('total_revenue'), 'total_quota_v2' => UserInfo::sum('quota_v2'), 'total_quota_v1' => UserInfo::sum('quota_v1'), - 'total_dealer_wallet' => bcdiv(DealerWallet::sum('balance'), 1, 2), ]); } @@ -84,10 +82,6 @@ class StatisticsTotal extends RadialBar

{$content['total_quota_v1']}

老配额 -
-

{$content['total_dealer_wallet']}

- 批零余额 -
HTML ); diff --git a/app/Admin/Renderable/DealerEarningSimpleTable.php b/app/Admin/Renderable/DealerEarningSimpleTable.php deleted file mode 100644 index 85b628b8..00000000 --- a/app/Admin/Renderable/DealerEarningSimpleTable.php +++ /dev/null @@ -1,68 +0,0 @@ -payload['id'] ?? 0; - $builder = DealerEarning::query(); - // dd($userId); - $builder->with(['user', 'payer'])->where(function ($q) use ($userId) { - return $q->where('user_id', $userId)->orWhere('payer_id', $userId); - }); - return Grid::make($builder, function (Grid $grid) { - $grid->column('user.phone', '收款人'); - $grid->column('payer_id', '付款人')->display(function () { - return $this->payer_id ? $this->payer?->phone : '公司'; - }); - $grid->column('earningable_type', '资金类型')->display(function () { - return $this->earningable_type_text; - })->label([ - (new DealerManageSubsidy())->getMorphClass() => 'primary', - (new DealerManagerSubsidy())->getMorphClass() => 'success', - (new DealerPurchaseSubsidy())->getMorphClass() => 'danger', - (new DealerChannelSubsidyLog())->getMorphClass() => 'warning', - ]); - $grid->column('remark', '备注')->display('详情') // 设置按钮名称 - ->expand(function () { - // 这里返回 content 字段内容,并用 Card 包裹起来 - $card = new Card(null, $this->remark); - - return "
$card
"; - }); - $grid->column('lvl')->display(function () { - return $this->lvl->text(); - }); - // $grid->column('total_amount', '总金额')->prepend('¥'); - // $grid->column('fee_rate', '手续费率')->append('%'); - // $grid->column('fee', '手续费')->prepend('¥'); - $grid->column('total_earnings', '实际金额')->prepend('¥'); - $grid->column('status', '状态')->display(function ($v) { - if (! $this->isSettled()) { - return "  待结算"; - } - - return "  {$v->text()}"; - }); - $grid->column('created_at', '创建时间'); - $grid->column('id', '操作')->display('查看')->link(function ($value) { - return admin_route('dealer_earnings.show', ['dealer_earning' => $this->id]); - }); - // $grid->withBorder(); - $grid->model()->orderBy('created_at', 'desc'); - $grid->disableRefreshButton(); - $grid->disableActions(); - }); - } -} diff --git a/app/Admin/Renderable/DealerSubordinateCard.php b/app/Admin/Renderable/DealerSubordinateCard.php deleted file mode 100644 index 6f35767f..00000000 --- a/app/Admin/Renderable/DealerSubordinateCard.php +++ /dev/null @@ -1,59 +0,0 @@ -id; - // dd($id); - $query = DB::table('users') - ->join('user_infos', 'users.id', '=', 'user_infos.user_id') - ->join('dealers', 'users.id', '=', 'dealers.user_id'); - $userInfo = UserInfo::where('user_id', $id)->first(); - // 查询数据逻辑 - $data = [ - 'top'=> (clone $query)->whereNotNull('users.phone')->where('dealers.lvl', 6)->where('user_infos.path', 'like', $userInfo->full_path.'%')->count(), - 'secondary'=> (clone $query)->whereNotNull('users.phone')->where('dealers.lvl', 5)->where('user_infos.path', 'like', $userInfo->full_path.'%')->count(), - 'contracted'=> (clone $query)->whereNotNull('users.phone')->where('dealers.lvl', 4)->where('user_infos.path', 'like', $userInfo->full_path.'%')->count(), - 'special'=> (clone $query)->whereNotNull('users.phone')->where('dealers.lvl', 3)->where('user_infos.path', 'like', $userInfo->full_path.'%')->count(), - 'gold'=> (clone $query)->whereNotNull('users.phone')->where('dealers.lvl', 2)->where('user_infos.path', 'like', $userInfo->full_path.'%')->count(), - ]; - - // 这里可以返回内置组件,也可以返回视图文件或HTML字符串 - return - << - -
-

{$data['top']}

- 一级经销商 -
-
-

{$data['secondary']}

- 二级经销商 -
-
-

{$data['contracted']}

- 签约经销商 -
- -
-
-

{$data['special']}

- 特邀经销商 -
-
-

{$data['gold']}

- 金牌经销商 -
-
-HTML; - } -} diff --git a/app/Admin/Renderable/DealerUserProductLogSimpleTable.php b/app/Admin/Renderable/DealerUserProductLogSimpleTable.php deleted file mode 100644 index f64a63e6..00000000 --- a/app/Admin/Renderable/DealerUserProductLogSimpleTable.php +++ /dev/null @@ -1,36 +0,0 @@ -payload['id'] ?? 0; - $productId = $this->payload['product_id'] ?? 0; - - $builder = DealerUserProductLog::query(); - $builder->with(['product'])->where(['user_id'=>$userId, 'product_id'=>$productId]); - return Grid::make($builder, function (Grid $grid) { - $grid->column('product.name', '商品名称'); - $grid->column('remark', '备注'); - $grid->column('is_deposit', '范围')->using([ - 0=>'本地库存', - 1=>'云库存', - ]); - $grid->column('qty', '变动数量')->display(function () { - return $this->qty_format.$this->product?->unit; - }); - $grid->column('created_at', '创建时间'); - - // $grid->withBorder(); - $grid->model()->orderBy('id', 'desc'); - $grid->disableRefreshButton(); - $grid->disableActions(); - }); - } -} diff --git a/app/Admin/Renderable/DealerUserProductSimpleTable.php b/app/Admin/Renderable/DealerUserProductSimpleTable.php deleted file mode 100644 index dc8e9386..00000000 --- a/app/Admin/Renderable/DealerUserProductSimpleTable.php +++ /dev/null @@ -1,28 +0,0 @@ -payload['id'] ?? 0; - $builder = DealerUserProduct::query(); - $builder->with(['product'])->where('user_id', $userId); - return Grid::make($builder, function (Grid $grid) { - $grid->column('product.name', '商品名称'); - $grid->column('product.cover', '商品封面')->image(80, 80); - $grid->column('stock', '剩余库存'); - $grid->column('created_at', '创建时间'); - // $grid->withBorder(); - $grid->model()->orderBy('created_at', 'desc'); - $grid->disableRefreshButton(); - $grid->disableActions(); - $grid->disablePagination(); - }); - } -} diff --git a/app/Admin/Renderable/DealerWalletLogSimpleTable.php b/app/Admin/Renderable/DealerWalletLogSimpleTable.php deleted file mode 100644 index e03e4b40..00000000 --- a/app/Admin/Renderable/DealerWalletLogSimpleTable.php +++ /dev/null @@ -1,27 +0,0 @@ -payload['id']??0; - $builder = DealerWalletLog::query(); - $builder->where('user_id', $userId); - return Grid::make($builder, function (Grid $grid) { - $grid->column('remarks', '备注'); - $grid->column('change_balance', '变动金额(元)')->prepend('¥'); - $grid->column('before_balance', '变动前(元)')->prepend('¥'); - $grid->column('created_at', '变动时间'); - // $grid->withBorder(); - $grid->model()->orderBy('created_at', 'desc'); - $grid->disableRefreshButton(); - $grid->disableActions(); - }); - } -} diff --git a/app/Admin/Renderable/Grid/Filter/DealerEarningStatusIn.php b/app/Admin/Renderable/Grid/Filter/DealerEarningStatusIn.php deleted file mode 100644 index 62e57565..00000000 --- a/app/Admin/Renderable/Grid/Filter/DealerEarningStatusIn.php +++ /dev/null @@ -1,80 +0,0 @@ -options = $options; - - $this->class = [ - 'all' => uniqid('column-filter-all-'), - 'item' => uniqid('column-filter-item-'), - ]; - } - - /** - * Add a binding to the query. - * - * @param array $value - * @param Model $model - */ - public function addBinding($value, Model $model) - { - if (empty($value)) { - return; - } - $all = [-1, 0, 1, 5]; - - if (array_diff($all, $value)) {//无差别则直接跳过 - //判断查询的状态有哪些; - $model->where(function ($query) use ($value) { - foreach ($value as $status) { - switch ($status) { - case -1: - $query->orWhereNull('settle_at'); - break; - case 0: - $query->orWhere(function ($q) { - return $q->whereNotNull('settle_at')->where('status', 0); - }); - break; - case 1: - $query->orWhere('status', 1); - break; - case 5: - $query->orWhere('status', 5); - break; - } - } - }); - } - } - - /** - * Render this filter. - * - * @return string - */ - public function render() - { - return $this->renderCheckbox(); - } -} diff --git a/app/Admin/Renderable/Grid/Filter/DealerOrderPayWayIn.php b/app/Admin/Renderable/Grid/Filter/DealerOrderPayWayIn.php deleted file mode 100644 index f8e87f17..00000000 --- a/app/Admin/Renderable/Grid/Filter/DealerOrderPayWayIn.php +++ /dev/null @@ -1,77 +0,0 @@ -options = $options; - - $this->class = [ - 'all' => uniqid('column-filter-all-'), - 'item' => uniqid('column-filter-item-'), - ]; - } - - /** - * Add a binding to the query. - * - * @param array $value - * @param Model $model - */ - public function addBinding($value, Model $model) - { - if (empty($value)) { - return; - } - $all = [ - PayWay::Offline->value => '线下打款', - PayWay::Wallet->value => '余额支付', - PayWay::WxpayH5->value => '微信支付', - ''=>'Unknown', - ]; - - if (array_diff($all, $value)) {//无差别则直接跳过 - //判断查询的状态有哪些; - $model->where(function ($query) use ($value) { - foreach ($value as $payWay) { - switch ($payWay) { - case '': - $query->orWhereNull('pay_way'); - break; - default: - $query->orWhere('pay_way', $payWay); - } - } - }); - } - } - - /** - * Render this filter. - * - * @return string - */ - public function render() - { - return $this->renderCheckbox(); - } -} diff --git a/app/Admin/Repositories/Dealer.php b/app/Admin/Repositories/Dealer.php deleted file mode 100644 index 1284ddfe..00000000 --- a/app/Admin/Repositories/Dealer.php +++ /dev/null @@ -1,16 +0,0 @@ -isSettled()) { - throw new BizException('经销商收益还未结算'); - } - - if (! $dealerEarning->isPending()) { - throw new BizException('经销商收益状态不是待付款'); - } - - switch (Relation::getMorphedModel($dealerEarning->earningable_type)) { - // 管理津贴 - case DealerManageSubsidy::class: - if (! $dealerEarning->earningable->isPending()) { - throw new BizException('管理津贴状态不是待付款'); - } - - $dealerEarning->earningable->update([ - 'status' => DealerManageSubsidyStatus::Completed, - ]); - - (new WalletService())->changeBalance( - $dealerEarning->user, - $dealerEarning->total_earnings, - DealerWalletAction::ManageSubsidyIn, - '收入-管理津贴', - $dealerEarning - ); - break; - - // 管理者津贴 - case DealerManagerSubsidy::class: - if (! $dealerEarning->earningable->isPending()) { - throw new BizException('管理者津贴状态不是待付款'); - } - - $dealerEarning->earningable->update([ - 'status' => DealerManagerSubsidyStatus::Completed, - ]); - - (new WalletService())->changeBalance( - $dealerEarning->user, - $dealerEarning->total_earnings, - DealerWalletAction::ManagerSubsidyIn, - '收入-管理者津贴', - $dealerEarning - ); - break; - - // 管理者津贴 - case DealerPurchaseSubsidy::class: - if (! $dealerEarning->earningable->isPending()) { - throw new BizException('进货补贴状态不是待付款'); - } - - $dealerEarning->earningable->update([ - 'status' => DealerPurchaseSubsidyStatus::Completed, - ]); - - (new WalletService())->changeBalance( - $dealerEarning->user, - $dealerEarning->total_earnings, - DealerWalletAction::PurchaseSubsidyIn, - '收入-进货补贴', - $dealerEarning - ); - break; - - case DealerChannelSubsidyLog::class: - (new WalletService())->changeBalance( - $dealerEarning->user, - $dealerEarning->total_earnings, - DealerWalletAction::ChannelSubsidyIn, - '收入-渠道补贴', - $dealerEarning - ); - break; - - default: - throw new BizException('经销商收入异常'); - break; - } - - $dealerEarning->update([ - 'pay_way' => DealerEarning::PAY_WAY_WALLET, - 'pay_at' => now(), - 'pay_info' => null, - 'status' => DealerEarningStatus::Completed, - ]); - } -} diff --git a/app/Admin/routes.php b/app/Admin/routes.php index f64b00ce..60095f2d 100644 --- a/app/Admin/routes.php +++ b/app/Admin/routes.php @@ -170,50 +170,6 @@ Route::group([ $router->get('monthly-statistics', 'MonthlyStatisticsController@index')->name('monthly-statistics.index'); - //经销商 - $router->resource('dealer-products', 'DealerProductController')->names('dealer_products'); - $router->resource('dealer-orders', 'DealerOrderController')->only([ - 'index', 'show', 'edit', 'update', - ])->names('dealer_orders'); - $router->get('dealer-manager-orders', 'DealerOrderController@index')->name('dealer_orders.manager'); - $router->resource('dealer-users', 'DealerController')->only([ - 'index', 'show', 'edit', 'update', - ])->names('dealers'); - - //渠道补贴 - $router->resource('dealer-earnings', 'DealerEarningController')->only([ - 'index', 'show', - ])->names('dealer_earnings'); - $router->get('dealer-earnings-channel', 'DealerEarningController@index')->name('dealer_earnings.channel'); - $router->get('dealer-earnings-manage', 'DealerEarningController@index')->name('dealer_earnings.manage'); - $router->get('dealer-earnings-manager', 'DealerEarningController@index')->name('dealer_earnings.manager'); - $router->get('dealer-earnings-purchase', 'DealerEarningController@index')->name('dealer_earnings.purchase'); - - // 签约渠道补贴 - $router->get('dealer-channel-subsidies', 'DealerChannelSubsidyController@index')->name('dealer_channel_subsidies.index'); - - // 管理者津贴 - $router->get('dealer-manager-subsidies', 'DealerManagerSubsidyController@index')->name('dealer_manager_subsidies.index'); - $router->get('dealer-manager-sales-logs', 'DealerManagerSalesLogController@index')->name('dealer_manager_sales_logs.index'); - - // 管理津贴 - $router->get('dealer-manage-subsidies', 'DealerManageSubsidyController@index')->name('dealer_manage_subsidies.index'); - $router->get('dealer-manage-subsidy-logs', 'DealerManageSubsidyLogController@index')->name('dealer_manage_subsidy_logs.index'); - - $router->get('dealer-purchase-subsidies', 'DealerPurchaseSubsidyController@index')->name('dealer_purchase_subsidies.index'); - $router->get('dealer-purchase-subsidies/{dealer_purchase_subsidy}', 'DealerPurchaseSubsidyController@show')->name('dealer_purchase_subsidies.show'); - $router->get('dealer-purchase-logs', 'DealerPurchaseLogController@index')->name('dealer_purchase_logs.index'); - - //批零余额提现 - $router->get('dealer-wallet-to-bank-logs/export', 'DealerWalletToBankLogController@export')->name('dealer_wallet_to_bank_logs.export'); - $router->resource('dealer-wallet-to-bank-logs', 'DealerWalletToBankLogController')->only([ - 'index', 'show', - ])->names('dealer_wallet_to_bank_logs'); - - // - $router->get('dealer-delivery-bills', 'DealerDeliveryBillController@index')->name('dealer_delivery_bills.index'); - $router->get('dealer-delivery-bills/{dealer_delivery_bill}', 'DealerDeliveryBillController@show')->name('dealer_delivery_bills.show'); - //商城端-砍价活动 $router->resource('bargain-activities', 'BargainActivityController')->names('bargain_activities'); $router->resource('bargain-orders', 'BargainOrderController')->only(['index', 'show'])->names('bargain_orders'); diff --git a/app/Console/Commands/Dealer/ChannelSubsidySettleCommand.php b/app/Console/Commands/Dealer/ChannelSubsidySettleCommand.php deleted file mode 100644 index 2945cd53..00000000 --- a/app/Console/Commands/Dealer/ChannelSubsidySettleCommand.php +++ /dev/null @@ -1,68 +0,0 @@ -withoutPayer()->onlyPending()->chunkById(200, function ($earnings) use (&$page) { - $earnings->load(['earningable', 'user']); - - foreach ($earnings as $earning) { - try { - DB::beginTransaction(); - - $earning->update([ - 'settle_at' => now(), - ]); - - (new DealerEarningService())->pay($earning); - - DB::commit(); - } catch (Throwable $e) { - DB::rollBack(); - - report($e); - } - } - - $page++; - }); - - if ($page === 0) { - sleep(60); - } else { - sleep(30); - } - } - } -} diff --git a/app/Console/Commands/Dealer/ImportDealerOrder.php b/app/Console/Commands/Dealer/ImportDealerOrder.php deleted file mode 100644 index 2efc0497..00000000 --- a/app/Console/Commands/Dealer/ImportDealerOrder.php +++ /dev/null @@ -1,47 +0,0 @@ -hasArgument('fileUri')) { - $this->fileUri = $this->argument('fileUri'); - } - $import = new DealerOrderImport(); - $res = $import->readFileByUrl($this->fileUri); - - ImportJobLog::insert(array_map(function ($value) { - return array_merge($value, [ - 'job_id'=> 0, - 'created_at' => now(), - 'updated_at' => now(), - ]); - }, $res['errors'])); - } -} diff --git a/app/Console/Commands/Dealer/ManageSubsidySettleCommand.php b/app/Console/Commands/Dealer/ManageSubsidySettleCommand.php deleted file mode 100644 index 19096c5e..00000000 --- a/app/Console/Commands/Dealer/ManageSubsidySettleCommand.php +++ /dev/null @@ -1,284 +0,0 @@ -day >= 20) { - // 结算当月5号-19号的管理津贴 - $startAt = $tz->copy()->setDay(5)->startOfDay(); - $endAt = $tz->copy()->setDay(19)->endOfDay(); - } elseif ($tz->day >= 5) { - // 结算上月20号-到当月4号的管理津贴 - $startAt = $tz->copy()->subMonthNoOverflow()->set('day', 20)->startOfDay(); - $endAt = $tz->copy()->set('day', 4)->endOfDay(); - } else { - // 结算上月5号-到19号的管理津贴 - $startAt = $tz->copy()->subMonthNoOverflow()->setDay(5)->startOfDay(); - $endAt = $tz->copy()->subMonthNoOverflow()->setDay(19)->endOfDay(); - } - - $head = '【'.$startAt->format('Y/m/d').'-'.$endAt->format('Y/m/d').'】'; - - $ordersCount = DealerOrder::onlyPaidSuccessfully() - ->where('settle_state', '!=', DealerOrderSettleState::Completed) - ->whereNotNull('paied_time') - ->where('paied_time', '<=', $endAt) - ->count(); - - if ($ordersCount > 0) { - return $this->warn("{$head} 订单还没有结算完成!"); - } - - $this->info("{$head}------------[开始]管理津贴结算------------".PHP_EOL); - - $this->info("{$head}管理津贴初始化..."); - $this->initializeManageSubsidies($startAt, $endAt, 500); - $this->info("{$head}管理津贴初始化完成".PHP_EOL); - - $this->info("{$head}管理津贴结算..."); - $this->settleManageSubsidies($startAt, $endAt); - $this->info("{$head}管理津贴结算完成".PHP_EOL); - - $this->info("{$head}Done! 总耗时: ".$this->formatDuration($tz->diffInMilliseconds(now(), false))); - $this->info("{$head}------------[结束]管理津贴结算------------".PHP_EOL); - - return 0; - } - - /** - * 初始化管理津贴 - * - * @param \Illuminate\Support\Carbon $startAt - * @param \Illuminate\Support\Carbon $endAt - * @param int $count - * @return void - */ - protected function initializeManageSubsidies(Carbon $startAt, Carbon $endAt, $count = 200): void - { - $feeRate = app_settings('dealer.fee_rate'); - - $lastId = $this->getLastDealerId($startAt, $endAt); - - do { - $dealers = Dealer::where('lvl', '>=', DealerLvl::Secondary) - ->where('contracted_lvl_at', '<=', $endAt) - ->forPageAfterId($count, $lastId, 'id') - ->get(); - - $dealersCount = $dealers->count(); - - if ($dealersCount == 0) { - break; - } - - $tz = now()->toDateTimeString(); - $manageSubsidies = []; - - foreach ($dealers as $dealer) { - $manageSubsidies[] = [ - 'user_id' => $dealer->user_id, - 'total_amount' => 0, - 'real_amount' => 0, - 'fee' => 0, - 'fee_rate' => $feeRate, - 'start_at' => $startAt, - 'end_at' => $endAt, - 'lvl' => $dealer->lvl, - 'is_manager' => $dealer->is_manager, - 'status' => DealerManageSubsidyStatus::Pending, - 'is_settle' => false, - 'created_at' => $tz, - 'updated_at' => $tz, - ]; - - $lastId = $dealer->id; - } - - DealerManageSubsidy::insert($manageSubsidies); - - unset($dealers, $manageSubsidies); - } while ($dealersCount == $count); - } - - /** - * 结算管理津贴 - * - * @param \Illuminate\Support\Carbon $startAt - * @param \Illuminate\Support\Carbon $endAt - * @return void - */ - protected function settleManageSubsidies(Carbon $startAt, Carbon $endAt) - { - DealerManageSubsidy::where('start_at', $startAt)->where('end_at', $endAt)->where('is_settle', false)->chunkById(500, function ($subsidies) { - foreach ($subsidies as $subsidy) { - DB::transaction(function () use ($subsidy) { - $this->settleManageSubsidy($subsidy); - }); - } - }); - } - - /** - * 结算单挑管理津贴 - * - * @param \App\Models\DealerManageSubsidy - * @return void - */ - protected function settleManageSubsidy(DealerManageSubsidy $subsidy) - { - [$totalAmount, $remark] = $this->calculateTotalAmount($subsidy); - - $feeRate = bcdiv($subsidy->fee_rate, '100', 5); - - $fee = bcmul($totalAmount, $feeRate, 3); - $fee = round($fee, 2); - - if (bccomp($totalAmount, '0', 2) === 0) { - $subsidy->status = DealerManageSubsidyStatus::Completed; - } - - $subsidy->total_amount = $totalAmount; - $subsidy->real_amount = bcsub($totalAmount, $fee, 2); - $subsidy->fee = $fee; - $subsidy->remark = $remark; - $subsidy->is_settle = true; - $subsidy->save(); - - if (! $subsidy->isCompleted()) { - $subsidy->earning()->create([ - 'user_id' => $subsidy->user_id, - 'lvl' => $subsidy->lvl, - 'total_amount' => $subsidy->total_amount, - 'total_earnings' => $subsidy->real_amount, - 'fee' => $subsidy->fee, - 'fee_rate' => $subsidy->fee_rate, - 'settle_at' => now(), - 'status' => DealerEarningStatus::Pending, - 'remark' => sprintf( - "%s - %s\n%s", - $subsidy->start_at->format('Y/m/d'), - $subsidy->end_at->format('Y/m/d'), - $remark - ), - ]); - } - } - - /** - * 计算补贴总金额 - * - * @param \App\Models\DealerManageSubsidy - * @return void - */ - protected function calculateTotalAmount(DealerManageSubsidy $subsidy): array - { - $subsidyLogs = DealerManageSubsidyLog::select([ - 'product_id', - DB::raw('sum(sales_volume) as sales_volume'), - DB::raw('sum(total_amount) as total_amount'), - ])->where( - 'user_id', $subsidy->user_id - )->whereBetween( - 'order_completed_at', [$subsidy->start_at, $subsidy->end_at] - )->groupBy('product_id')->get(); - - // 补贴总金额 - $totalAmount = 0; - // 备注信息 - $remark = ''; - - foreach ($subsidyLogs as $subsidyLog) { - $totalAmount = bcadd($totalAmount, $subsidyLog->total_amount, 2); - - if ($remark !== '') { - $remark .= "\n"; - } - - $remark .= "{$subsidyLog->product->name}\n销量: {$subsidyLog->sales_volume}\n补贴金额: {$subsidyLog->total_amount}"; - } - - return [$totalAmount, $remark]; - } - - /** - * 获取给定时间端内的最后一个经销商补贴所属经销商的ID - * - * @param \Illuminate\Support\Carbon $startAt - * @param \Illuminate\Support\Carbon $endAt - * @return int|null - */ - protected function getLastDealerId(Carbon $startAt, Carbon $endAt): ?int - { - $lastManageSubsidy = DealerManageSubsidy::where('start_at', $startAt) - ->where('end_at', $endAt) - ->latest('id') - ->first(); - - return $lastManageSubsidy?->dealer?->id; - } - - /** - * 格式化时间 - * - * @param float $milliseconds - * @return string - */ - protected function formatDuration($milliseconds): string - { - if ($milliseconds < 0.01) { - return round($milliseconds * 1000) . 'μs'; - } elseif ($milliseconds >= 1000) { - return round($milliseconds / 1000, 2) . 's'; - } - - return $milliseconds . 'ms'; - } -} diff --git a/app/Console/Commands/Dealer/ManagerSubsidySettleCommand.php b/app/Console/Commands/Dealer/ManagerSubsidySettleCommand.php deleted file mode 100644 index 9960310b..00000000 --- a/app/Console/Commands/Dealer/ManagerSubsidySettleCommand.php +++ /dev/null @@ -1,256 +0,0 @@ -copy()->subMonthNoOverflow()->startOfMonth(); - $endAt = $startAt->copy()->endOfMonth(); - - $head = '【'.$startAt->format('Y/m/d').'-'.$endAt->format('Y/m/d').'】'; - - $ordersCount = DealerOrder::onlyPaidSuccessfully() - ->where('settle_state', '!=', DealerOrderSettleState::Completed) - ->whereNotNull('paied_time') - ->where('paied_time', '<=', $endAt) - ->count(); - - if ($ordersCount > 0) { - return $this->warn("{$head} 订单还没有结算完成!"); - } - - $this->info("{$head}------------[开始]管理者津贴结算------------".PHP_EOL); - - $this->info("{$head}管理者津贴初始化..."); - $this->initializeManagerSubsidies($startAt, $endAt, 500); - $this->info("{$head}管理者津贴初始化完成".PHP_EOL); - - $this->info("{$head}管理者津贴结算..."); - $this->settleManagerSubsidies($startAt, $endAt); - $this->info("{$head}管理者津贴结算完成".PHP_EOL); - - $this->info("{$head}Done! 总耗时: ".$this->formatDuration($tz->diffInMilliseconds(now(), false))); - $this->info("{$head}------------[结束]管理者津贴结算------------".PHP_EOL); - - return 0; - } - - /** - * 初始化管理者津贴 - * - * @param \Illuminate\Support\Carbon $startAt - * @param \Illuminate\Support\Carbon $endAt - * @param int $count - * @return void - */ - protected function initializeManagerSubsidies(Carbon $startAt, Carbon $endAt, $count = 200): void - { - $feeRate = app_settings('dealer.fee_rate'); - - $lastId = $this->getLastDealerId($startAt, $endAt); - - do { - $dealers = Dealer::where('is_manager', true) - ->forPageAfterId($count, $lastId, 'id') - ->get(); - - $dealersCount = $dealers->count(); - - if ($dealersCount == 0) { - break; - } - - $tz = now()->toDateTimeString(); - $managerSubsidies = []; - - foreach ($dealers as $dealer) { - $managerSubsidies[] = [ - 'user_id' => $dealer->user_id, - 'total_amount' => 0, - 'real_amount' => 0, - 'fee' => 0, - 'fee_rate' => $feeRate, - 'start_at' => $startAt, - 'end_at' => $endAt, - 'lvl' => $dealer->lvl, - 'is_manager' => $dealer->is_manager, - 'status' => DealerManagerSubsidyStatus::Pending, - 'is_settle' => false, - 'created_at' => $tz, - 'updated_at' => $tz, - ]; - - $lastId = $dealer->id; - } - - DealerManagerSubsidy::insert($managerSubsidies); - - unset($dealers, $managerSubsidies); - } while ($dealersCount == $count); - } - - /** - * 结算管理者津贴 - * - * @param \Illuminate\Support\Carbon $startAt - * @param \Illuminate\Support\Carbon $endAt - * @return void - */ - protected function settleManagerSubsidies(Carbon $startAt, Carbon $endAt) - { - DealerManagerSubsidy::where('start_at', $startAt)->where('end_at', $endAt)->where('is_settle', false)->chunkById(500, function ($subsidies) { - foreach ($subsidies as $subsidy) { - DB::transaction(function () use ($subsidy) { - $this->settleManagerSubsidy($subsidy); - }); - } - }); - } - - /** - * 结算管理者津贴 - * - * @param \App\Models\DealerManagerSubsidy - * @return void - */ - protected function settleManagerSubsidy(DealerManagerSubsidy $subsidy) - { - [$totalAmount, $remark] = $this->calculateTotalAmount($subsidy); - - $feeRate = bcdiv($subsidy->fee_rate, '100', 5); - - $fee = bcmul($totalAmount, $feeRate, 3); - $fee = round($fee, 2); - - if (bccomp($totalAmount, '0', 2) === 0) { - $subsidy->status = DealerManagerSubsidyStatus::Completed; - } - - $subsidy->total_amount = $totalAmount; - $subsidy->real_amount = bcsub($totalAmount, $fee, 2); - $subsidy->fee = $fee; - $subsidy->remark = $remark; - $subsidy->is_settle = true; - $subsidy->save(); - - if (! $subsidy->isCompleted()) { - $subsidy->earning()->create([ - 'user_id' => $subsidy->user_id, - 'lvl' => $subsidy->lvl, - 'total_amount' => $subsidy->total_amount, - 'total_earnings' => $subsidy->real_amount, - 'fee' => $subsidy->fee, - 'fee_rate' => $subsidy->fee_rate, - 'settle_at' => now(), - 'status' => DealerEarningStatus::Pending, - 'remark' => sprintf( - "%s - %s\n%s", - $subsidy->start_at->format('Y/m/d'), - $subsidy->end_at->format('Y/m/d'), - $remark - ), - ]); - } - } - - /** - * 计算补贴总金额 - * - * @param \App\Models\Dealer - * @return array - */ - protected function calculateTotalAmount(DealerManagerSubsidy $subsidy): array - { - $salesLogs = DealerManagerSalesLog::with(['product']) - ->select(['product_id', DB::raw('sum(sales_volume) as sales_volume')]) - ->where('user_id', $subsidy->user_id) - ->whereBetween('order_completed_at', [$subsidy->start_at, $subsidy->end_at]) - ->groupBy('product_id') - ->get(); - - // 补贴总额 - $totalAmount = 0; - // 备注信息 - $remark = ''; - - foreach ($salesLogs as $salesLog) { - $amount = bcmul($salesLog->sales_volume, $salesLog->product->manager_subsidy, 2); - $totalAmount = bcadd($totalAmount, $amount, 2); - - if ($remark !== '') { - $remark .= "\n"; - } - - $remark .= "{$salesLog->product->name}\n销量: {$salesLog->sales_volume}\n补贴金额: {$amount}"; - } - return [$totalAmount, $remark]; - } - - /** - * 获取给定时间端内的最后一个经销商补贴所属经销商的ID - * - * @param \Illuminate\Support\Carbon $startAt - * @param \Illuminate\Support\Carbon $endAt - * @return int|null - */ - protected function getLastDealerId(Carbon $startAt, Carbon $endAt): ?int - { - $lastManagerSubsidy = DealerManagerSubsidy::where('start_at', $startAt) - ->where('end_at', $endAt) - ->latest('id') - ->first(); - - return $lastManagerSubsidy?->dealer?->id; - } - - /** - * 格式化时间 - * - * @param float $milliseconds - * @return string - */ - protected function formatDuration($milliseconds): string - { - if ($milliseconds < 0.01) { - return round($milliseconds * 1000) . 'μs'; - } elseif ($milliseconds >= 1000) { - return round($milliseconds / 1000, 2) . 's'; - } - - return $milliseconds . 'ms'; - } -} diff --git a/app/Console/Commands/Dealer/OrderAutoAllocate.php b/app/Console/Commands/Dealer/OrderAutoAllocate.php deleted file mode 100644 index 7fe18a25..00000000 --- a/app/Console/Commands/Dealer/OrderAutoAllocate.php +++ /dev/null @@ -1,69 +0,0 @@ -where('consignor_id', '>', 1) // 到1用户或者公司的订单不需要再分配 - ->where('allocated_at', '<', now()->subMinutes(app_settings('dealer.order_auto_allocate_times'))) - ->chunkById(200, function ($orders) use (&$page) { - $orders->load([ - 'consignor', - ]); - $orderService = new OrderService(); - foreach ($orders as $order) { - try { - DB::beginTransaction(); - $orderService->updateOrderConsignor($order); - DB::commit(); - } catch (Throwable $th) { - DB::rollBack(); - report($th); - } - } - - $page++; - }); - - if ($page === 0) { - sleep(60); - } elseif ($page === 1) { - sleep(30); - } else { - sleep(15); - } - } - } -} diff --git a/app/Console/Commands/Dealer/OrderProcessCommand.php b/app/Console/Commands/Dealer/OrderProcessCommand.php deleted file mode 100644 index 98d84e28..00000000 --- a/app/Console/Commands/Dealer/OrderProcessCommand.php +++ /dev/null @@ -1,556 +0,0 @@ -chunkById(200, function ($orders) use (&$page) { - $orders->load([ - 'userInfo', - 'dealer.userInfo', - 'products.productManageSubsidyRules', - ]); - - foreach ($orders as $order) { - try { - DB::transaction(function () use ($order) { - $this->handleDealerOrder($order); - }); - } catch (Throwable $e) { - report($e); - } - } - - $page += 1; - }, 'paied_time'); - - if ($page === 0) { - sleep(60); - } else { - sleep(5); - } - }; - - return 0; - } - - /** - * 处理经销商订单 - * - * @param \App\Models\DealerOrder $dealerOrder - * @return void - */ - protected function handleDealerOrder(DealerOrder $dealerOrder) - { - $tz = now()->toDateTimeString(); - - // 上级经销商 - $ancestors = $dealerOrder->dealer->getDealers(); - - // 签约经销商的进货日志 - $this->handlePurchaseLogsOfContractedDealer($dealerOrder, $tz); - - // 一级签约经销商和二级经销商的管理津贴 - $this->handleManageSubsidyLogs($dealerOrder, $ancestors, $tz); - - // 管理者的销售业绩 - $this->handleManagerSalesLogs($dealerOrder, $ancestors, $tz); - - // 渠道补贴 - $this->handleChannelSubsidy($dealerOrder); - - if ($dealerOrder->dealer->wasChanged('lvl')) { - $dealers = [ - $dealerOrder->dealer, - ...$ancestors, - ]; - - foreach ($dealers as $dealer) { - $dealer->attemptUpgrade(); - } - } - - // 将订单标记为已处理 - $dealerOrder->forceFill([ - 'settle_state' => DealerOrderSettleState::Processed, - ])->save(); - } - - /** - * 计算渠道补贴 - * - * @param \App\Models\DealerOrder $dealerOrder - * @return void - */ - protected function handleChannelSubsidy(DealerOrder $dealerOrder) - { - $lvl = $dealerOrder->dealer->lvl; - - if ($dealerOrder->total_amount >= app_settings('dealer.upgrade_amount_'.DealerLvl::Contracted->value)) { - // 升级为签约 - if ($lvl->value < DealerLvl::Contracted->value) { - $lvl = DealerLvl::Contracted; - } - } elseif ($dealerOrder->total_amount >= app_settings('dealer.upgrade_amount_'.DealerLvl::Special->value)) { - // 升级为特约 - if ($lvl->value < DealerLvl::Special->value) { - $lvl = DealerLvl::Special; - } - } elseif ($dealerOrder->total_amount >= app_settings('dealer.upgrade_amount_'.DealerLvl::Gold->value)) { - // 升级为金牌 - if ($lvl->value < DealerLvl::Gold->value) { - $lvl = DealerLvl::Gold; - } - } - - // 如果经销商等级小于金牌,则没有渠道补贴 - if ($lvl->value < DealerLvl::Gold->value) { - return; - } - - [$dealers, $rule] = $this->mapDealersAndRuleOfChannel($dealerOrder->dealer, $lvl); - - if ($lvl->value >= DealerLvl::Contracted->value) { - $upgradeAmount = app_settings('dealer.upgrade_amount_'.DealerLvl::Contracted->value); - } else { - $upgradeAmount = app_settings('dealer.upgrade_amount_'.$lvl->value); - } - - // 手续费比例 - $feeRate = app_settings('dealer.fee_rate'); - - foreach ($dealers as $key => $dealer) { - $ruleKey = $dealer->lvl->value.'_'.$key; - - if ($dealer->lvl->value >= DealerLvl::Contracted->value) { - $ruleKey = DealerLvl::Contracted->value.'_'.$key; - } - - // 补贴金额 - $subsidyAmount = $rule[$ruleKey]; - - $totalAmount = bcmul($subsidyAmount, $dealerOrder->total_amount, 10); - $totalAmount = bcdiv($totalAmount, $upgradeAmount, 3); - $totalAmount = round($totalAmount, 2); - - $channelSubsidyLog = DealerChannelSubsidyLog::create([ - 'user_id' => $dealer->user_id, - 'lvl' => $dealer->lvl, - 'order_id' => $dealerOrder->id, - 'total_amount' => $totalAmount, - 'order_id' => $dealerOrder->id, - 'remark' => "补贴总额={$dealerOrder->total_amount}/{$upgradeAmount}*{$subsidyAmount}", - ]); - - $fee = bcmul($channelSubsidyLog->total_amount, bcdiv($feeRate, '100', 5), 3); - $fee = round($fee, 2); - - $channelSubsidyLog->earning()->create([ - 'user_id' => $channelSubsidyLog->user_id, - 'lvl' => $channelSubsidyLog->lvl, - 'total_amount' => $channelSubsidyLog->total_amount, - 'total_earnings' => bcsub($channelSubsidyLog->total_amount, $fee, 2), - 'fee' => $fee, - 'fee_rate' => $feeRate, - 'payer_id' => $dealerOrder->consignor_id, - 'status' => DealerEarningStatus::Pending, - 'remark' => "订单号: {$dealerOrder->sn}", - ]); - } - - $dealerOrder->dealer->upgrade($lvl, '进货升级'); - } - - /** - * 获取渠道补贴经销商和补贴规则 - * - * @param \App\Models\Dealer $dealer - * @param \App\Enums\DealerLvl $lvl - * @return array - */ - protected function mapDealersAndRuleOfChannel(Dealer $dealer, DealerLvl $lvl): array - { - // 渠道补贴经销商 - $dealers = []; - // 渠道补贴规则 - $rule = null; - // 是否升级 - $isUp = $lvl->value > $dealer->lvl->value; - // 最后参与渠道补贴的经销商 - $last = null; - // 前一个直属邀请人 - $previous = null; - - while (true) { - if ($previous) { - $_dealer = $previous->userInfo->realInviterInfo?->dealer; - $_dealer?->setRelation('userInfo', $previous->userInfo->realInviterInfo); - } else { - $_dealer = $dealer->userInfo->realInviterInfo?->dealer; - $_dealer?->setRelation('userInfo', $dealer->userInfo->realInviterInfo); - } - - $previous = $_dealer; - - if ($_dealer === null) { - break; - } - - // 如果经销商等级小于金牌, 那么跳过 - if ($_dealer->lvl->value < DealerLvl::Gold->value) { - continue; - } - - if ($lvl->value >= DealerLvl::Contracted->value) { - if ($last === null) { - if ($_dealer->lvl->value >= DealerLvl::Contracted->value) { - // 渠道补贴规则: 签约 -> 签约 -> 签约 - $rule = app_settings(sprintf( - 'dealer.channel_rules.%s_%s', - DealerLvl::Contracted->value, - DealerLvl::Contracted->value - )); - - $dealers[] = $_dealer; - - $last = $_dealer; - } elseif ($isUp && $_dealer->isSpecialDealer()) { - // 渠道补贴规则: 签约 -> 特邀 -> 签约 -> 签约 - $rule = app_settings(sprintf( - 'dealer.channel_rules.%s_%s', - DealerLvl::Contracted->value, - DealerLvl::Special->value - )); - - $dealers[] = $_dealer; - - $last = $_dealer; - } - } elseif ($_dealer->lvl->value >= DealerLvl::Contracted->value) { - $dealers[] = $_dealer; - - // 如果最后参与渠道补贴的经销商是签约, 那么已经找到所有参与渠道补贴的经销商 - if ($last->lvl->value >= DealerLvl::Contracted->value) { - break; - } - - $last = $_dealer; - } - } elseif ($lvl === DealerLvl::Special) { - if ($_dealer->lvl->value > DealerLvl::Special->value) { - break; - } - - if ($last === null) { - if ($_dealer->isSpecialDealer()) { - // 渠道补贴规则: 特邀 -> 特邀 -> 特邀 - $rule = app_settings(sprintf( - 'dealer.channel_rules.%s_%s', - DealerLvl::Special->value, - DealerLvl::Special->value - )); - - $dealers[] = $_dealer; - - $last = $_dealer; - } elseif ($isUp && $_dealer->isGoldDealer()) { - // 渠道补贴规则: 特邀 -> 金牌 -> 特邀 -> 特邀 - $rule = app_settings(sprintf( - 'dealer.channel_rules.%s_%s', - DealerLvl::Special->value, - DealerLvl::Gold->value - )); - - $dealers[] = $_dealer; - - $last = $_dealer; - } - } elseif ($_dealer->isSpecialDealer()) { - $dealers[] = $_dealer; - - if ($last->isSpecialDealer()) { - break; - } - - $last = $_dealer; - } - } elseif ($lvl === DealerLvl::Gold) { - if ($_dealer->lvl->value >= DealerLvl::Gold->value) { - if ($_dealer->isGoldDealer()) { - // 渠道补贴规则: 金牌 -> 金牌 - $rule = app_settings(sprintf( - 'dealer.channel_rules.%s_%s', - DealerLvl::Gold->value, - DealerLvl::Gold->value - )); - - $dealers[] = $_dealer; - } - - break; - } - } - } - - return [$dealers, $rule]; - } - - /** - * 生成签约经销商的进货日志 - * - * @param \App\Models\DealerOrder $dealerOrder - * @param array $dealers - * @param string $tz - * @return void - */ - protected function handlePurchaseLogsOfContractedDealer(DealerOrder $dealerOrder, string $tz) - { - if (! $this->isContractedDealerToPurchase($dealerOrder)) { - return; - } - - $dealer = $dealerOrder->userInfo->dealer; - - // 采购业绩是否算自己的业绩 - $valid = $dealer->lvl->value >= DealerLvl::Contracted->value; - - $log = new DealerPurchaseLog([ - 'user_id' => $dealer->user_id, - 'lvl' => $dealer->lvl, - 'order_id' => $dealerOrder->id, - 'total_amount' => $dealerOrder->total_amount, - 'path' => $valid ? $dealerOrder->userInfo->full_path : $dealerOrder->userInfo->path, - 'remark' => $valid ? null : '升级签约', - ]); - $log->setCreatedAt($tz); - $log->setUpdatedAt($tz); - $log->save(); - } - - /** - * 分配一级签约经销商和二级经销商的管理津贴 - * - * @param \App\Models\DealerOrder $dealerOrder - * @param array $dealers - * @param string $tz - * @return void - */ - protected function handleManageSubsidyLogs(DealerOrder $dealerOrder, array $dealers, string $tz) - { - if (! $this->isContractedDealerToPurchase($dealerOrder)) { - return; - } - - $logs = []; - - foreach ($dealerOrder->products as $product) { - if ($product->productManageSubsidyRules->isEmpty()) { - continue; - } - - // 管理津贴分配规则 - $rules = $product->productManageSubsidyRules->keyBy('lvl'); - - $last = null; - $ranking = 0; - - foreach ($dealers as $dealer) { - if (! in_array($dealer->lvl, [DealerLvl::Secondary, DealerLvl::Top])) { - continue; - } - - // 如果当前经销商等级没有对应的管理津贴分配规则,则忽略 - if (is_null($rule = $rules->get($dealer->lvl->value))) { - continue; - } - - $qty = $product->qty + $product->deposit_qty; - - // 同等级管理津贴最多给三次 - if ($last === null || $dealer->lvl->value > $last->lvl->value) { - if ($ranking < 3 && $dealer->lvl === DealerLvl::Top) { - if ($secondarySubsidyRule = $rules->get(DealerLvl::Secondary->value)) { - $key = 'price_'.(1 + $ranking).'st'; - - $secondarySubsidy = $secondarySubsidyRule->{$key}; - - if (bccomp($secondarySubsidy, '0') === 1) { - $logs[] = [ - 'user_id' => $dealer->user_id, - 'order_id' => $product->order_id, - 'product_id' => $product->product_id, - 'lvl' => $dealer->lvl, - 'sales_volume' => $qty, - 'total_amount' => bcmul($qty, $secondarySubsidy, 2), - 'created_at' => $tz, - 'updated_at' => $tz, - ]; - } - } - } - - $ranking = 1; - } elseif ($ranking < 3 && $dealer->lvl->value === $last->lvl->value) { - $ranking++; - } else { - continue; - } - - $subsidy = $rule->{"price_{$ranking}st"}; - - if (bccomp($subsidy, '0') === 1) { - $logs[] = [ - 'user_id' => $dealer->user_id, - 'order_id' => $product->order_id, - 'product_id' => $product->product_id, - 'lvl' => $dealer->lvl, - 'sales_volume' => $qty, - 'total_amount' => bcmul($qty, $subsidy, 2), - 'created_at' => $tz, - 'updated_at' => $tz, - ]; - } - - $last = $dealer; - } - } - - DealerManageSubsidyLog::insert($logs); - } - - /** - * 过滤出可能会享受管理津贴的经销商(每个等级最多3人) - * - * @param array $dealers - * @return array - */ - protected function mapManageSubsidyDealers(array $dealers): array - { - $map = []; - $last = null; - $ranking = 1; - - foreach ($dealers as $dealer) { - if ($last === null || $dealer->lvl->value > $last->lvl->value) { - $last = $dealer; - $map[] = $last; - $ranking = 1; - } elseif ($ranking < 3 && $dealer->lvl->value === $last->lvl->value) { - $last = $dealer; - $map[] = $last; - $ranking++; - } - } - - return $map; - } - - /** - * 生成管理者的销售业绩 - * - * @param \App\Models\DealerOrder $dealerOrder - * @param array $dealers - * @param string $tz - * @return void - */ - protected function handleManagerSalesLogs(DealerOrder $dealerOrder, array $dealers, string $tz): void - { - if (! $this->isContractedDealerToPurchase($dealerOrder)) { - return; - } - - if (is_null($manager = $this->firstManager($dealers))) { - return; - } - - $logs = []; - - foreach ($dealerOrder->products as $product) { - $qty = $product->qty + $product->deposit_qty; - - $logs[] = [ - 'user_id' => $manager->user_id, - 'lvl' => $manager->lvl, - 'order_id' => $product->order_id, - 'product_id' => $product->product_id, - 'sales_volume' => $qty, - 'created_at' => $tz, - 'updated_at' => $tz, - ]; - } - - DealerManagerSalesLog::insert($logs); - } - - /** - * 从给定的经销商中获取第一个管理者 - * - * @param array $dealers - * @return \App\Models\Dealer|null - */ - protected function firstManager(array $dealers): ?Dealer - { - foreach ($dealers as $dealer) { - if ($dealer->is_manager) { - return $dealer; - } - } - return null; - } - - /** - * 确认是否是签约经销商进货 - * - * @param DealerOrder $dealerOrder - * @return bool - */ - protected function isContractedDealerToPurchase(DealerOrder $dealerOrder): bool - { - $dealer = $dealerOrder->userInfo->dealer; - - if ($dealer->lvl->value < DealerLvl::Contracted->value) { - if ($dealerOrder->total_amount < app_settings('dealer.upgrade_amount_'.DealerLvl::Contracted->value)) { - return false; - } - } - - return true; - } -} diff --git a/app/Console/Commands/Dealer/OrderSettleCommand.php b/app/Console/Commands/Dealer/OrderSettleCommand.php deleted file mode 100644 index 6257965e..00000000 --- a/app/Console/Commands/Dealer/OrderSettleCommand.php +++ /dev/null @@ -1,204 +0,0 @@ -where('settle_state', DealerOrderSettleState::Processed) - ->whereNotNull('paied_time') - ->chunkById(200, function ($orders) use (&$page) { - $orders->load('dealer.userInfo'); - - foreach ($orders as $order) { - try { - DB::beginTransaction(); - - $this->handleDealerOrder($order); - - DB::commit(); - } catch (Throwable $e) { - DB::rollBack(); - - report($e); - } - } - - $page++; - }); - - if ($page === 0) { - sleep(60); - } else { - sleep(30); - } - } - } - - /** - * 处理经销商订单 - * - * @param \App\Models\DealerOrder $order - * @return void - */ - protected function handleDealerOrder(DealerOrder $order) - { - $this->handleManagerSalesLogs($order); - - $this->handleManageSubsidyLogs($order); - - $this->handleChannelSubsidyLogs($order); - - $this->handlePurchaseLogs($order); - - $this->handleOrder($order); - } - - protected function handleManagerSalesLogs(DealerOrder $order) - { - DealerManagerSalesLog::where('order_id', $order->id)->update([ - 'order_completed_at' => $this->getOrderCompletedAt($order), - ]); - } - - protected function handleManageSubsidyLogs(DealerOrder $order) - { - DealerManageSubsidyLog::where('order_id', $order->id)->update([ - 'order_completed_at' => $this->getOrderCompletedAt($order), - ]); - } - - protected function handleChannelSubsidyLogs(DealerOrder $order) - { - $channelSubsidyLogIds = DealerChannelSubsidyLog::where('order_id', $order->id)->get('id')->toArray(); - - DealerChannelSubsidyLog::whereIn('id', $channelSubsidyLogIds)->update([ - 'order_completed_at' => $this->getOrderCompletedAt($order), - ]); - - if ($order->consignor_id !== null) { - DealerEarning::where('earningable_type', 'dealer_channel_subsidy_log')->whereIn('earningable_id', $channelSubsidyLogIds)->update([ - 'settle_at' => now(), - ]); - } - } - - protected function handlePurchaseLogs(DealerOrder $order) - { - DealerPurchaseLog::where('order_id', $order->id)->update([ - 'order_completed_at' => $this->getOrderCompletedAt($order), - ]); - } - - protected function handleOrder(DealerOrder $order) - { - $salesValue = $order->total_amount; - - if (bccomp($salesValue, '0', 2) < 1) { - return; - } - - $salesValueLogs = []; - - if (bccomp($salesValue, '0', 2) === 1) { - $ts = now()->toDateTimeString(); - - $order->dealer->update([ - 'self_sales_value' => DB::raw("self_sales_value+{$salesValue}"), - ]); - - $salesValueLogs[] = [ - 'user_id' => $order->user_id, - 'loggable_type' => $order->getMorphClass(), - 'loggable_id' => $order->id, - 'type' => DealerSalesValueLogType::Personal, - 'change_sales_value' => $salesValue, - 'remark' => '个人进货', - 'created_at' => $ts, - 'updated_at' => $ts, - ]; - - if (count($pids = $order->dealer->userInfo->parent_ids) > 0) { - foreach ($order->dealer->userInfo->parent_ids as $pid) { - $salesValueLogs[] = [ - 'user_id' => $pid, - 'loggable_type' => $order->getMorphClass(), - 'loggable_id' => $order->id, - 'type' => DealerSalesValueLogType::Team, - 'change_sales_value' => $salesValue, - 'remarks' => '团队成员进货', - 'created_at' => $ts, - 'updated_at' => $ts, - ]; - } - - // 更新上级的团队团队业绩 - Dealer::whereIn('user_id', $pids)->update([ - 'team_sales_value' => DB::raw("team_sales_value + {$salesValue}"), - ]); - } - } - - // 保存销售值日志 - DealerSalesValueLog::insert($salesValueLogs); - - // 将订单标记未已结算 - $order->forceFill([ - 'settle_state' => DealerOrderSettleState::Completed, - ])->save(); - } - - /** - * 获取订单完成时间 - * - * @param DealerOrder $order - * @return Carbon - */ - protected function getOrderCompletedAt(DealerOrder $order): Carbon - { - if ($order->paied_time->lt('2022-04-19 11:00:00')) { - return now(); - } - - return $order->paied_time; - } -} diff --git a/app/Console/Commands/Dealer/PurchaseSubsidySettleCommand.php b/app/Console/Commands/Dealer/PurchaseSubsidySettleCommand.php deleted file mode 100644 index 2a392ca7..00000000 --- a/app/Console/Commands/Dealer/PurchaseSubsidySettleCommand.php +++ /dev/null @@ -1,401 +0,0 @@ -calculatePurchaseAmount = $calculatePurchaseAmount; - } - - /** - * Execute the console command. - * - * @return int - */ - public function handle() - { - $tz = now(); - - if ($tz->day >= 20) { - // 上月20号-当月19号的进货业绩 - $startAt = $tz->copy()->subMonthNoOverflow()->setDay(20)->startOfDay(); - $endAt = $tz->copy()->setDay(19)->endOfDay(); - } else { - // 上上月20号-上月19号的进货业绩 - $startAt = $tz->copy()->subMonthsNoOverflow(2)->setDay(20)->startOfDay(); - $endAt = $tz->copy()->subMonthNoOverflow()->setDay(19)->endOfDay(); - } - - $head = '【'.$startAt->format('Y/m/d').'-'.$endAt->format('Y/m/d').'】'; - - $ordersCount = DealerOrder::onlyPaidSuccessfully() - ->where('settle_state', '!=', DealerOrderSettleState::Completed) - ->whereNotNull('paied_time') - ->where('paied_time', '<=', $endAt) - ->count(); - - if ($ordersCount > 0) { - return $this->warn("{$head} 订单还没有结算完成!"); - } - - $this->info("{$head}------------[开始]进货补贴结算------------"); - - $this->info("{$head}进货补贴初始化..."); - $this->initializePurchaseSubsidies($startAt, $endAt, 200); - $this->info("{$head}进货补贴初始化完成".PHP_EOL); - - $this->info("{$head}扣除上级的进货补贴..."); - $this->deductPurchaseSubsidies($startAt, $endAt, 200); - $this->info("{$head}扣除上级的进货补贴完成".PHP_EOL); - - $this->info("{$head}计算手续费..."); - $this->calculateFeeOfPurchaseSubsidies($startAt, $endAt, 200); - $this->info("{$head}计算手续费完成".PHP_EOL); - - $this->info("{$head}Done! 总耗时: ".$this->formatDuration($tz->diffInMilliseconds(now(), false))); - - $this->info("{$head}------------[结束]进货补贴结算------------".PHP_EOL); - - return 0; - } - - /** - * 计算进货补贴手续费 - * - * @param \Illuminate\Support\Carbon $startAt - * @param \Illuminate\Support\Carbon $endAt - * @param int $count - * @return void - */ - protected function calculateFeeOfPurchaseSubsidies(Carbon $startAt, Carbon $endAt, int $count = 200): void - { - DealerPurchaseSubsidy::where([ - 'start_at' => $startAt, - 'end_at' => $endAt, - 'settle_state' => DealerPurchaseSubsidySettleState::Processed, - ])->chunkById($count, function ($purchaseSubsidies) { - foreach ($purchaseSubsidies as $purchaseSubsidy) { - DB::transaction(function () use ($purchaseSubsidy) { - $this->calculateFeeOfPurchaseSubsidy($purchaseSubsidy); - }); - } - }); - } - - /** - * 计算进货补贴手续费 - * - * @param \App\Models\DealerPurchaseSubsidy $purchaseSubsidy - * @return void - */ - protected function calculateFeeOfPurchaseSubsidy(DealerPurchaseSubsidy $purchaseSubsidy) - { - if (bccomp($purchaseSubsidy->total_amount, '0') === 1) { - $feeRate = bcdiv($purchaseSubsidy->fee_rate, '100', 5); - - $fee = bcmul($purchaseSubsidy->total_amount, $feeRate, 3); - $fee = round($fee, 2); - - $purchaseSubsidy->fee = $fee; - $purchaseSubsidy->real_amount = bcsub($purchaseSubsidy->total_amount, $fee, 2); - } else { - $purchaseSubsidy->status = DealerPurchaseSubsidyStatus::Completed; - } - $purchaseSubsidy->settle_state = DealerPurchaseSubsidySettleState::Completed; - $purchaseSubsidy->save(); - - if (! $purchaseSubsidy->isCompleted()) { - $remark = sprintf( - "%s - %s\n销售业绩: %s\n补贴比例: %s%%", - $purchaseSubsidy->start_at->format('Y/m/d'), - $purchaseSubsidy->end_at->format('Y/m/d'), - $purchaseSubsidy->total_purchase_amount, - $purchaseSubsidy->subsidy_rate - ); - - $purchaseSubsidy->earning()->create([ - 'user_id' => $purchaseSubsidy->user_id, - 'lvl' => $purchaseSubsidy->lvl, - 'total_amount' => $purchaseSubsidy->total_amount, - 'total_earnings' => $purchaseSubsidy->real_amount, - 'fee' => $purchaseSubsidy->fee, - 'fee_rate' => $purchaseSubsidy->fee_rate, - 'settle_at' => now(), - 'status' => DealerEarningStatus::Pending, - 'remark' => $remark, - ]); - } - } - - /** - * 扣除上级的进货补贴 - * - * @param \Illuminate\Support\Carbon $startAt - * @param \Illuminate\Support\Carbon $endAt - * @param int $count - * @return void - */ - protected function deductPurchaseSubsidies(Carbon $startAt, Carbon $endAt, int $count = 200): void - { - DealerPurchaseSubsidy::where([ - 'start_at' => $startAt, - 'end_at' => $endAt, - 'settle_state' => DealerPurchaseSubsidySettleState::Pending, - ])->chunkById($count, function ($purchaseSubsidies) { - foreach ($purchaseSubsidies as $purchaseSubsidy) { - DB::transaction(function () use ($purchaseSubsidy) { - $this->deductPurchaseSubsidy($purchaseSubsidy); - }); - } - }); - } - - /** - * 扣除上级的采购补贴总额 - * - * @param \AppModels\DealerPurchaseSubsidy $purchaseSubsidy - * @return void - */ - protected function deductPurchaseSubsidy(DealerPurchaseSubsidy $purchaseSubsidy) - { - // 扣除上级的进货补贴 - if ($purchaseSubsidy->payer_id && bccomp($purchaseSubsidy->total_subsidy, '0', 2) === 1) { - $payerPurchaseSubsidy = DealerPurchaseSubsidy::where([ - 'user_id' => $purchaseSubsidy->payer_id, - 'start_at' => $purchaseSubsidy->start_at, - 'end_at' => $purchaseSubsidy->end_at, - ])->first(); - - if ($payerPurchaseSubsidy) { - $payerPurchaseSubsidy->decrement('total_amount', $purchaseSubsidy->total_subsidy); - - $payerPurchaseSubsidy->logs()->create([ - 'purchase_subsidy_id' => $payerPurchaseSubsidy->id, - 'change_from_purchase_subsidy_id' => $purchaseSubsidy->id, - 'change_amount' => bcmul($purchaseSubsidy->total_subsidy, '-1', 2), - 'remark' => '扣除下级的进货补贴', - ]); - } - } - - $purchaseSubsidy->update([ - 'settle_state' => DealerPurchaseSubsidySettleState::Processed, - ]); - } - - /** - * 初始化进货补贴 - * - * @param \Illuminate\Support\Carbon $startAt - * @param \Illuminate\Support\Carbon $endAt - * @param int $count - * @return void - */ - protected function initializePurchaseSubsidies(Carbon $startAt, Carbon $endAt, int $count = 200) - { - // 手续费比例 - $feeRate = app_settings('dealer.fee_rate'); - // 采购补贴规则 - $purchaseRules = (array) app_settings('dealer.purchase_rules'); - - $lastId = $this->getLastDealerId($startAt, $endAt); - - do { - $dealers = Dealer::with(['userInfo']) - ->where('contracted_lvl_at', '<=', $endAt) - ->where('lvl', '>=', DealerLvl::Contracted->value) - ->forPageAfterId($count, $lastId, 'id') - ->get(); - - $dealersCount = $dealers->count(); - - if ($dealersCount == 0) { - break; - } - - foreach ($dealers as $dealer) { - DB::transaction(function () use ($dealer, $startAt, $endAt, $feeRate, $purchaseRules) { - $this->initializePurchaseSubsidy($dealer, $startAt, $endAt, $feeRate, $purchaseRules); - }); - - $lastId = $dealer->id; - } - - unset($dealers); - } while ($dealersCount == $count); - } - - /** - * 初始化进货补贴 - * - * @param Dealer $dealer - * @param Carbon $startAt - * @param Carbon $endAt - * @param float $feeRate - * @param array $purchaseRules - * @return void - */ - protected function initializePurchaseSubsidy(Dealer $dealer, Carbon $startAt, Carbon $endAt, $feeRate, array $purchaseRules) - { - // 进货总额 - $totalPurchaseAmount = $this->calculatePurchaseAmount->handle($dealer, $startAt, $endAt); - - // 如果没有进货总额,则返回 - if (bccomp($totalPurchaseAmount, '0', 2) <= 0) { - return; - } - - // 进货补贴比例 - $subsidyRate = $this->filterSubsidyRate($totalPurchaseAmount, $purchaseRules); - - // 补贴总额 - $totalSubsidy = bcmul($totalPurchaseAmount, bcdiv($subsidyRate, '100', 5), 3); - $totalSubsidy = round($totalSubsidy, 2); - - $purchaseSubsidy = DealerPurchaseSubsidy::create([ - 'user_id' => $dealer->user_id, - 'payer_id' => $this->nearestContractedDealer($dealer, $endAt)?->user_id, - 'lvl' => $dealer->lvl, - 'total_purchase_amount' => $totalPurchaseAmount, - 'subsidy_rate' => $subsidyRate, - 'total_subsidy' => $totalSubsidy, - 'total_amount' => $totalSubsidy, - 'real_amount' => 0, - 'fee' => 0, - 'fee_rate' => $feeRate, - 'start_at' => $startAt, - 'end_at' => $endAt, - 'settle_state' => DealerPurchaseSubsidySettleState::Pending, - 'status' => DealerPurchaseSubsidyStatus::Pending, - ]); - - if (bccomp($purchaseSubsidy->total_subsidy, '0', 2) === 1) { - $purchaseSubsidy->logs()->create([ - 'purchase_subsidy_id' => $purchaseSubsidy->id, - 'change_from_purchase_subsidy_id' => null, - 'change_amount' => $purchaseSubsidy->total_subsidy, - 'remark' => '进货补贴总额', - ]); - } - } - - /** - * 进货补贴比例 - * - * @param float $totalPurchaseAmount - * @param array $purchaseRules - * @return float - */ - protected function filterSubsidyRate($totalPurchaseAmount, array $purchaseRules) - { - $rate = '0'; - - foreach ($purchaseRules as $rule) { - if (bccomp($totalPurchaseAmount, bcmul($rule['price'], '10000'), 2) === -1) { - continue; - } - - if (bccomp($rule['rate'], $rate, 5) === 1) { - $rate = $rule['rate']; - } - } - - return $rate; - } - - /** - * 获取最近的上级签约经销商 - * - * @param \App\Models\Dealer $dealer - * @param \Illuminate\Support\Carbon $startAt - * @return \App\Models\Dealer|null - */ - protected function nearestContractedDealer(Dealer $dealer, Carbon $endAt): ?Dealer - { - foreach ($dealer->getDealers() as $_dealer) { - // 如果当前经销商等级小于签约,则跳过 - if ($_dealer->lvl->value < DealerLvl::Contracted->value) { - continue; - } - - if ($_dealer->contracted_lvl_at?->lte($endAt)) { - return $_dealer; - } - } - - return null; - } - - /** - * 获取给定时间端内的最后一个进货补贴所属经销商的ID - * - * @param \Illuminate\Support\Carbon $startAt - * @param \Illuminate\Support\Carbon $endAt - * @return int|null - */ - protected function getLastDealerId(Carbon $startAt, Carbon $endAt): ?int - { - $lastPurchaseSubsidy = DealerPurchaseSubsidy::where('start_at', $startAt) - ->where('end_at', $endAt) - ->latest('id') - ->first(); - - return $lastPurchaseSubsidy?->dealer?->id; - } - - /** - * 格式化时间 - * - * @param float $milliseconds - * @return string - */ - protected function formatDuration($milliseconds): string - { - if ($milliseconds < 0.01) { - return round($milliseconds * 1000) . 'μs'; - } elseif ($milliseconds >= 1000) { - return round($milliseconds / 1000, 2) . 's'; - } - - return $milliseconds . 'ms'; - } -} diff --git a/app/Console/Commands/Dealer/WalletToBankCommand.php b/app/Console/Commands/Dealer/WalletToBankCommand.php deleted file mode 100644 index 4feaeffb..00000000 --- a/app/Console/Commands/Dealer/WalletToBankCommand.php +++ /dev/null @@ -1,92 +0,0 @@ -chunkById(1, function ($logs) use ($yeePayService) { - foreach ($logs as $log) { - try { - $result = $yeePayService->request('accountpay.behalf.Pay', [ - 'payerOutUserId' => '21102510220227100003' ?: config('services.yeepay.partner_id'), - 'merchOrderNo' => $log->pay_sn, - 'tradeName' => '批零提现', - 'payeeUserName' => data_get($log->pay_info, 'bank.user_name'), - 'bankCardNo' => data_get($log->pay_info, 'bank.bank_number'), - 'bankCode' => Bank::tryFromBankName(data_get($log->pay_info, 'bank.bank_name'))?->name, - 'bankCardType' => 'DEBIT_CARD', - 'amount' => $log->account_amount, - 'feeRole' => 'PAYER', - 'tradeMemo' => '批零提现', - 'context' => json_encode(['type' => 'dealer_wallet_to_bank']), - ]); - - // 如果交易超时,重新发起支付 - if ($result['resultCode'] === 'TIME_OUT') { - continue; - } - - if ($result['orderStatus'] === 'SUCCESS') { - $log->update([ - 'status' => DealerWalletToBankLogStatus::Success, - 'pay_at' => now(), - 'failed_reason' => null, - ]); - } elseif ($result['orderStatus'] === 'FAIL') { - $log->update([ - 'status' => DealerWalletToBankLogStatus::Failed, - 'failed_reason' => '交易失败', - ]); - } else { - $log->update([ - 'status' => DealerWalletToBankLogStatus::Paying, - 'failed_reason' => null, - ]); - } - } catch (YeePayException $e) { - $log->update([ - 'status' => DealerWalletToBankLogStatus::Failed, - 'failed_reason' => $e->getMessage(), - ]); - } catch (Throwable $e) { - throw $e; - } - } - }); - - sleep(60); - } - } -} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 6eec529e..762e9ac6 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -24,17 +24,6 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule) { - $schedule->command('dealer:manage-subsidy-settle') - ->twiceMonthly(5, 20, '2:00') - ->runInBackground(); - - $schedule->command('dealer:purchase-subsidy-settle') - ->monthlyOn(20, '3:00') - ->runInBackground(); - - $schedule->command('dealer:manager-subsidy-settle') - ->monthlyOn(1, '3:00') - ->runInBackground(); } /** diff --git a/app/Constants/Device.php b/app/Constants/Device.php index 64d9210f..8df33c8a 100644 --- a/app/Constants/Device.php +++ b/app/Constants/Device.php @@ -9,7 +9,4 @@ class Device // 商户端 public const MERCHANT = 'merchant'; - - // 经销商端 - public const DEALER = 'dealer'; } diff --git a/app/Endpoint/Api/Filters/DealerDeliveryBillFilter.php b/app/Endpoint/Api/Filters/DealerDeliveryBillFilter.php deleted file mode 100644 index 52c8eef3..00000000 --- a/app/Endpoint/Api/Filters/DealerDeliveryBillFilter.php +++ /dev/null @@ -1,26 +0,0 @@ -where('status', DealerDeliveryBillStatus::Pending); - break; - - case 'paid': - $this->where('status', DealerDeliveryBillStatus::Paid); - break; - - case 'cancelled': - $this->where('status', DealerDeliveryBillStatus::Cancelled); - break; - } - } -} diff --git a/app/Endpoint/Api/Filters/DealerOrderFilter.php b/app/Endpoint/Api/Filters/DealerOrderFilter.php deleted file mode 100644 index b77c5f21..00000000 --- a/app/Endpoint/Api/Filters/DealerOrderFilter.php +++ /dev/null @@ -1,37 +0,0 @@ -onlyPending(); - break; - case 'wait_pay'://待付款 - $this->onlyPendinged(); - break; - case 'wait_paid'://待收款 - $this->onlyPaid(); - break; - case 'wait_shipping'://待发货 - $this->onlyShipping(); - break; - case 'wait_shippinged'://待收货 - $this->onlyShippinged(); - break; - case 'completed'://已完成 - $this->onlyCompleted(); - break; - case 'cancelled'://已取消 - $this->onlyCancelled(); - break; - default: - break; - } - } -} diff --git a/app/Endpoint/Api/Filters/DealerUserProductLogFilter.php b/app/Endpoint/Api/Filters/DealerUserProductLogFilter.php deleted file mode 100644 index c9b324ea..00000000 --- a/app/Endpoint/Api/Filters/DealerUserProductLogFilter.php +++ /dev/null @@ -1,13 +0,0 @@ -where('product_id', $productId); - } -} diff --git a/app/Endpoint/Api/Filters/DealerWalletLogFilter.php b/app/Endpoint/Api/Filters/DealerWalletLogFilter.php deleted file mode 100644 index 269cb2c6..00000000 --- a/app/Endpoint/Api/Filters/DealerWalletLogFilter.php +++ /dev/null @@ -1,17 +0,0 @@ -onlyTransfer(); - break; - } - } -} diff --git a/app/Endpoint/Api/Http/Controllers/Auth/LoginController.php b/app/Endpoint/Api/Http/Controllers/Auth/LoginController.php index e4b63c4b..92c78270 100644 --- a/app/Endpoint/Api/Http/Controllers/Auth/LoginController.php +++ b/app/Endpoint/Api/Http/Controllers/Auth/LoginController.php @@ -60,16 +60,6 @@ class LoginController extends Controller throw new BizException('账户没有权限'); } - // 清理此用户的商户端令牌 - $user->tokens()->where('name', $device)->delete(); - // 颁发新的商户端令牌 - $token = $user->createToken($device); - break; - case Device::DEALER: - if (!$user->isDealer()) { - throw new BizException('账户没有权限'); - } - // 清理此用户的商户端令牌 $user->tokens()->where('name', $device)->delete(); // 颁发新的商户端令牌 diff --git a/app/Endpoint/Api/Http/Controllers/Auth/LogoutController.php b/app/Endpoint/Api/Http/Controllers/Auth/LogoutController.php index 5410db39..c9e72e0e 100644 --- a/app/Endpoint/Api/Http/Controllers/Auth/LogoutController.php +++ b/app/Endpoint/Api/Http/Controllers/Auth/LogoutController.php @@ -30,8 +30,6 @@ class LogoutController extends Controller 'm_cid' => null, ]); break; - case Device::DEALER: - break; default: // 解绑用户商城端cid $cid->update([ diff --git a/app/Endpoint/Api/Http/Controllers/Auth/RegisterController.php b/app/Endpoint/Api/Http/Controllers/Auth/RegisterController.php index f998428a..01516ed9 100644 --- a/app/Endpoint/Api/Http/Controllers/Auth/RegisterController.php +++ b/app/Endpoint/Api/Http/Controllers/Auth/RegisterController.php @@ -59,19 +59,7 @@ class RegisterController extends Controller throw new BizException(__('Registration failed, please try again')); } - // 获取登录设备 - $device = $request->header('client-app', Device::UNIAPP); - - switch ($device) { - case Device::DEALER: - $token = $user->createToken(Device::DEALER); - break; - default: - $token = $user->createToken(Device::UNIAPP, ['mall']); - break; - } - - // $token = $user->createToken(Device::UNIAPP, ['mall']); + $token = $user->createToken(Device::UNIAPP, ['mall']); return response()->json([ 'token' => $token->plainTextToken, diff --git a/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php b/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php index 322982e0..c1b8df99 100644 --- a/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php +++ b/app/Endpoint/Api/Http/Controllers/Auth/SocialiteAuthController.php @@ -237,17 +237,7 @@ class SocialiteAuthController extends Controller throw new BizException(__('Registration failed, please try again')); } - // 获取登录设备 - $device = $request->header('client-app', Device::UNIAPP); - - switch ($device) { - case Device::DEALER: - $token = $user->createToken(Device::DEALER); - break; - default: - $token = $user->createToken(Device::UNIAPP, ['mall']); - break; - } + $token = $user->createToken(Device::UNIAPP, ['mall']); } //解绑对应三方以前的关系 SocialiteUser::where([ @@ -285,16 +275,6 @@ class SocialiteAuthController extends Controller throw new BizException('账户没有权限'); } - // 清理此用户的商户端令牌 - $user->tokens()->where('name', $device)->delete(); - // 颁发新的商户端令牌 - $token = $user->createToken($device); - break; - case Device::DEALER: - if (!$user->isDealer()) { - throw new BizException('账户没有权限'); - } - // 清理此用户的商户端令牌 $user->tokens()->where('name', $device)->delete(); // 颁发新的商户端令牌 diff --git a/app/Endpoint/Api/Http/Controllers/Dealer/ConfigurationController.php b/app/Endpoint/Api/Http/Controllers/Dealer/ConfigurationController.php deleted file mode 100644 index 043e88b9..00000000 --- a/app/Endpoint/Api/Http/Controllers/Dealer/ConfigurationController.php +++ /dev/null @@ -1,18 +0,0 @@ -json([ - 'wxpay_switch' => app_settings('dealer.wxpay_switch', 0), - 'delivery_bill_shipping_fee' => app_settings('dealer.delivery_bill_shipping_fee', 0), - 'withdraw_fee_rate' => app_settings('dealer.withdraw_fee_rate', 0), - ]); - } -} diff --git a/app/Endpoint/Api/Http/Controllers/Dealer/DealerDeliveryBillController.php b/app/Endpoint/Api/Http/Controllers/Dealer/DealerDeliveryBillController.php deleted file mode 100644 index 49240e0b..00000000 --- a/app/Endpoint/Api/Http/Controllers/Dealer/DealerDeliveryBillController.php +++ /dev/null @@ -1,178 +0,0 @@ -user()->dealerDeliveryBills() - ->filter($request->all()) - ->latest('id') - ->simplePaginate($perPage); - - return DealerDeliveryBillResource::collection($deliveryBills); - } - - /** - * 创建提货单 - * - * @param \Illuminate\Http\Request $request - * @param \App\Services\Dealer\DealerDeliveryBillService $dealerDeliveryBillService - * @return \Illuminate\Http\JsonResponse - */ - public function store(Request $request, DealerDeliveryBillService $dealerDeliveryBillService) - { - $input = $request->validate([ - 'shipping_address_id' => ['bail', 'required'], - 'products' => ['bail', 'required', 'array'], - 'products.*.id' => ['bail', 'required', 'int'], - 'products.*.qty' => ['bail', 'required', 'int', 'min:1'], - 'remark' => ['bail', 'nullable', 'string', 'max:255'], - ], [], [ - 'shipping_address_id' => '收货地址', - 'products' => '商品', - 'remark' => '备注', - ]); - - $user = $request->user(); - - $shippingAddress = $user->shippingAddresses()->findOrFail($input['shipping_address_id']); - - try { - DB::beginTransaction(); - - $deliveryBill = $dealerDeliveryBillService->create( - $user, - $input['products'], - [ - 'name' => $shippingAddress->consignee, - 'telephone' => $shippingAddress->telephone, - 'zone' => $shippingAddress->zone, - 'address' => $shippingAddress->address, - ], - $input['remark'] ?? null - ); - - DB::commit(); - } catch (Throwable $e) { - DB::rollBack(); - - throw $e; - } - - $deliveryBill->load(['deliveryProducts.product']); - - return DealerDeliveryBillResource::make($deliveryBill); - } - - /** - * 提货单详情 - * - * @param int $id - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\JsonResponse - */ - public function show($id, Request $request) - { - $deliveryBill = $request->user()->dealerDeliveryBills()->findOrFail($id); - $deliveryBill->load(['deliveryProducts.product']); - - return DealerDeliveryBillResource::make($deliveryBill); - } - - /** - * 提货单支付 - * - * @param int $id - * @param \Illuminate\Http\Request $request - * @param \App\Services\Dealer\DealerDeliveryBillService $dealerDeliveryBillService - * @return \Illuminate\Http\JsonResponse - */ - public function pay($id, Request $request, DealerDeliveryBillService $dealerDeliveryBillService) - { - $input = $request->validate([ - 'pay_way' => ['bail', 'required', 'string'], - 'pay_password' => ['bail', 'required_if:pay_way,wallet'], - 'products'=> ['array'], - ], [ - 'pay_password.required_if' => '支付密码 不能为空。', - ], [ - 'pay_way' => '支付方式', - 'pay_password' => '支付密码', - ]); - - $payWay = PayWay::tryFrom($input['pay_way']); - - if (! in_array($payWay, [PayWay::Wallet, PayWay::WxpayH5, PayWay::WxpayJsApi])) { - throw new BizException('支付方式 非法'); - } - - $user = $request->user(); - - $deliveryBill = $user->dealerDeliveryBills()->findOrFail($id); - - if ($payWay === PayWay::Wallet && !$user->wallet?->verifyPassword($input['pay_password'])) { - throw new PayPasswordIncorrectException(); - } - - try { - DB::beginTransaction(); - - $data = $dealerDeliveryBillService->pay($deliveryBill, $payWay); - - DB::commit(); - } catch (BizException $e) { - DB::rollBack(); - - throw $e; - } catch (Throwable $e) { - DB::rollBack(); - - report($e); - - throw new BizException('支付失败,请重试'); - } - - return response()->json($data); - } - - /** - * 取消提货单 - * - * @param int $id - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\JsonResponse - */ - public function cancel($id, Request $request) - { - $user = $request->user(); - - DB::transaction(function () use ($id, $user) { - (new DealerDeliveryBillService())->cancel( - $user->dealerDeliveryBills()->lockForUpdate()->findOrFail($id) - ); - }); - - return response()->noContent(); - } -} diff --git a/app/Endpoint/Api/Http/Controllers/Dealer/EarningController.php b/app/Endpoint/Api/Http/Controllers/Dealer/EarningController.php deleted file mode 100644 index dd027fad..00000000 --- a/app/Endpoint/Api/Http/Controllers/Dealer/EarningController.php +++ /dev/null @@ -1,184 +0,0 @@ -input('cate', '');//获取订单类别 - $user = $request->user(); - switch ($cate) { - case 'pending':// - $query = $user->dealerPayEarnings()->with('user')->onlyPending()->whereNotNull('settle_at'); - break; - case 'paid': - $query = $user->dealerEarnings()->onlyPaid()->whereNotNull('settle_at'); - break; - default://全部 - $query = DealerEarning::with('user')->where(function ($q) use ($user) { - return $q->where('user_id', $user->id)->orWhere('payer_id', $user->id); - }); - break; - } - - $earnings = $query->latest('id')->simplePaginate(Paginator::resolvePerPage('per_page', 20, 50)); - return DealerEarningSimpleResource::collection($earnings); - } - - /** - * 详情 - * - * @param [type] $id - * @param Request $request - * @return void - */ - public function show($id, Request $request) - { - $user = $request->user(); - $earning = DealerEarning::with(['user', 'user.userInfo'])->where(function ($q) use ($user) { - return $q->where('user_id', $user->id)->orWhere('payer_id', $user->id); - })->with('earningable')->findOrFail($id); - return DealerEarningResource::make($earning); - } - - /** - * 确认打款 - * - * @param [type] $id - * @param Request $request - * @return void - */ - public function payEarning($id, Request $request) - { - $earning = DealerEarning::findOrFail($id); - $user = $request->user(); - if (!$earning->isPayer($user->id)) { - throw new BizException('无法操作该订单'); - } - - $input = $request->validate([ - 'pay_way' => ['bail', 'string'], - 'pay_image' => ['bail', 'required_if:pay_way,offline', 'string'], - 'pay_password' => ['bail', 'required_if:pay_way,wallet'], - ], [ - 'pay_image.required_if' => '打款凭证 不能为空。', - 'pay_password.required_if' => '支付密码 不能为空。', - ], [ - 'pay_image' => '打款凭证', - 'pay_way' => '支付方式', - 'pay_password' => '支付密码', - ]); - - $payWay = $input['pay_way'] ?? DealerEarning::PAY_WAY_OFFLINE; - - if ( - $payWay === DealerEarning::PAY_WAY_WALLET && - !$user->wallet?->verifyPassword($input['pay_password']) - ) { - throw new PayPasswordIncorrectException(); - } - - if ($earning->isPending()) { - try { - DB::beginTransaction(); - switch ($payWay) { - case DealerEarning::PAY_WAY_WALLET: - //支付余额 - $walletService = new WalletService(); - - // 扣除打款人余额 - $walletService->changeBalance( - $user, - bcmul($earning->total_earnings, '-1', 2), - DealerWalletAction::EarningOut, - "渠道补贴:【{$earning->remark}】", - $earning - ); - - // 增加收款人余额 - if ($earning->user) { - $walletService->changeBalance( - $earning->user, - $earning->total_earnings, - DealerWalletAction::EarningIn, - "渠道补贴:【{$earning->remark}】", - $earning - ); - } - - $earning->update([ - 'status' => DealerEarningStatus::Completed, - 'pay_way' => DealerEarning::PAY_WAY_WALLET, - 'pay_info' => $earning->getPayInfo(), - 'pay_at' => now(), - ]); - - break; - case DealerEarning::PAY_WAY_OFFLINE: - $earning->update([ - 'status' => DealerEarningStatus::Paid, - 'pay_way' => DealerEarning::PAY_WAY_OFFLINE, - 'pay_info' => $earning->getPayInfo(), - 'pay_image'=> $input['pay_image'], - 'pay_at' => now(), - ]); - break; - default: - throw new BizException('支付方式不存在'); - break; - } - DB::commit(); - } catch (BizException $e) { - throw $e; - } catch (Throwable $th) { - DB::rollBack(); - report($th); - throw new BizException('系统错误,请稍后再试'); - } - } - return response()->noContent(); - } - - /** - * 确认收款 - * - * @param [type] $id - * @param Request $request - */ - public function confirmEarning($id, Request $request) - { - $earning = DealerEarning::findOrFail($id); - - if (!$earning->isUser($request->user()->id)) { - throw new BizException('无法操作该订单'); - } - - if ($earning->isPaid()) { - $earning->update([ - 'status' => DealerEarningStatus::Completed, - ]); - } - return response()->noContent(); - } -} diff --git a/app/Endpoint/Api/Http/Controllers/Dealer/FansController.php b/app/Endpoint/Api/Http/Controllers/Dealer/FansController.php deleted file mode 100644 index 113a85c8..00000000 --- a/app/Endpoint/Api/Http/Controllers/Dealer/FansController.php +++ /dev/null @@ -1,55 +0,0 @@ -user(); - - return response()->json([ - 'fans_num'=> $user->fans()->count(), - 'unsettled_purchase_amount' => '0.00', - 'current_period_purchase_amount'=> $calculatePurchaseAmountOfCurrentPeriod->handle($user->dealer), - ]); - } - - public function index(Request $request) - { - $perPage = PaginatorHelper::resolvePerPage('per_page', 20, 50); - - $fans = $request->user()->fans() - ->with(['userInfo', 'dealer']) - ->latest('id') - ->simplePaginate($perPage); - - return DealerFansResource::collection($fans); - } - - public function show( - $id, - CalculatePurchaseAmountOfCurrentPeriod $calculatePurchaseAmountOfCurrentPeriod - ) { - $dealer = Dealer::where('user_id', $id)->firstOrFail(); - - return response()->json([ - 'total_purchase_amount' => $calculatePurchaseAmountOfCurrentPeriod->handle($dealer), - ]); - } -} diff --git a/app/Endpoint/Api/Http/Controllers/Dealer/ManageSubsidyController.php b/app/Endpoint/Api/Http/Controllers/Dealer/ManageSubsidyController.php deleted file mode 100644 index bd7a33b5..00000000 --- a/app/Endpoint/Api/Http/Controllers/Dealer/ManageSubsidyController.php +++ /dev/null @@ -1,31 +0,0 @@ -user(); - - return response()->json([ - // 未结算的管理津贴 - 'unsettled_manage_subsidies' => '0.00', - // 本期已结算的管理津贴 - 'current_period_manage_subsidies'=> $calculateManageSubsidiesOfCurrentPeriod->handle($user->dealer), - ]); - } -} diff --git a/app/Endpoint/Api/Http/Controllers/Dealer/ManageSubsidyLogController.php b/app/Endpoint/Api/Http/Controllers/Dealer/ManageSubsidyLogController.php deleted file mode 100644 index 9efb07d8..00000000 --- a/app/Endpoint/Api/Http/Controllers/Dealer/ManageSubsidyLogController.php +++ /dev/null @@ -1,44 +0,0 @@ -day >= 20) { - // 结算当月20号开始的管理津贴 - $startAt = $tz->copy()->setDay(20)->startOfDay(); - } elseif ($tz->day >= 5) { - // 结算当月5号开始的管理津贴 - $startAt = $tz->copy()->setDay(5)->startOfDay(); - } else { - // 结算上月20号开始的管理津贴 - $startAt = $tz->copy()->subMonthNoOverflow()->setDay(20)->startOfDay(); - } - - $manageSubsidyLogs = DealerManageSubsidyLog::with(['product', 'order.user']) - ->where('order_completed_at', '>=', $startAt) - ->where('user_id', $request->user()->id) - ->latest('order_completed_at') - ->simplePaginate($perPage); - - return DealerManageSubsidyLogResource::collection($manageSubsidyLogs); - } -} diff --git a/app/Endpoint/Api/Http/Controllers/Dealer/OrderController.php b/app/Endpoint/Api/Http/Controllers/Dealer/OrderController.php deleted file mode 100644 index a026543c..00000000 --- a/app/Endpoint/Api/Http/Controllers/Dealer/OrderController.php +++ /dev/null @@ -1,479 +0,0 @@ -input('cate', 'purchase');//获取订单类别 - $user = $request->user(); - switch ($cate) { - case 'consignor'://发货单 - $query = $user->dealerConsignOrders(); - break; - default://采购单 - $query = $user->dealerOrders(); - break; - } - $perPage = PaginatorHelper::resolvePerPage('per_page', 20, 50); - - $orders = $query->with('products') - ->filter($request->all()) - ->latest('id') - ->simplePaginate($perPage); - - return OrderSimpleResource::collection($orders); - } - - public function store(Request $request, OrderService $orderService) - { - $input = $request->validate([ - 'shipping_address_id' => ['bail', 'required', 'int'], - 'product_id'=>['bail', 'required', 'int', 'min:0'], - 'num'=>['bail', 'required', 'int', 'min:1'], - ], [], [ - 'product_id' => '商品', - 'num' => '数量', - 'shipping_address_id' => '收货地址', - ]); - $product = DealerProduct::online()->findOrFail($input['product_id']); - try { - DB::beginTransaction(); - $order = $orderService->quickCreateOrder($request->user(), $product, $input['num'], $input['shipping_address_id']); - DB::commit(); - } catch (BizException $e) { - DB::rollBack(); - throw $e; - } catch (Throwable $th) { - DB::rollBack(); - report($th); - throw new BizException('下单失败,请稍后再试'); - } - - return OrderResource::make($order); - } - - /** - * 确认订单 - * - * @param Request $request - * @param OrderService $orderService - */ - public function checkOrder(Request $request, OrderService $orderService) - { - $input = $request->validate([ - 'shopping_cart' => ['bail', 'required', 'array'], - ], [], [ - 'shopping_cart'=>'购物车商品', - ]); - $user = $request->user(); - $shoppingCartItems = $user->dealerShoppingCartItems()->findMany($input['shopping_cart']); - $shoppingCartItems->load('product'); - $totalQty = $shoppingCartItems->sum('quantity'); - $data = []; - $totalAmount = 0; - foreach ($shoppingCartItems as $item) { - $dealerPrice = $orderService->getSalePrice($user, $item->product, $totalQty); - $data[] = [ - 'id' => $item->id, - 'name' => $item->name, - 'cover' => $item->cover, - 'sell_price' => $item->sell_price, - 'dealer_price' => $dealerPrice, - 'quantity' => $item->quantity, - ]; - $totalAmount += $dealerPrice; - } - return response()->json(['data'=>$data, 'to_lvl'=>$orderService->willBecome($user, $totalAmount)]); - } - - /** - * 新下单接口 - */ - public function newStore(Request $request, OrderService $orderService) - { - $isQuick = $request->filled('product'); - - $rules = $isQuick ? [ - 'product.id' => ['bail', 'required', 'int'], - 'product.quantity' => ['bail', 'required', 'int', 'min:1'], - 'shipping_address_id' => ['bail', 'required', 'int'], - ] : [ - 'shopping_cart' => ['bail', 'required', 'array'], - 'shipping_address_id' => ['bail', 'required', 'int'], - ]; - - $input = $request->validate($rules, [], [ - 'product.id' => '商品', - 'product.quantity' => '数量', - 'shopping_cart' => '购物车商品', - 'shipping_address_id' => '收货地址', - ]); - - try { - DB::beginTransaction(); - - if ($isQuick) { - $product = DealerProduct::online()->findOrFail($input['product']['id']); - $order = $orderService->quickCreateOrder($request->user(), $product, $input['product']['quantity'], $input['shipping_address_id']); - } else { - $order = $orderService->cartCreateOrder($request->user(), $input['shopping_cart'], $input['shipping_address_id']); - } - - DB::commit(); - } catch (BizException $e) { - DB::rollBack(); - throw $e; - } catch (Throwable $th) { - DB::rollBack(); - report($th); - throw new BizException('下单失败,请稍后再试'); - } - - return OrderResource::make($order); - } - - public function show($id, Request $request) - { - $order = DealerOrder::findOrFail($id); - $userId = $request->user()->id; - //既不是采购人,也不是发货人 - if (!$order->canCurd($userId)) { - throw new BizException('订单未找到'); - } - - $refuseLog = $order->isPendinged() ? $order->refuseLogs()->latest('id')->first() : null; - - $data = OrderResource::make($order)->toArray($request); - $data['refuse_reason'] = $refuseLog?->reason; - - $data['to_lvl'] = (new OrderService())->willBecome($request->user(), $order->total_amount); - - return response()->json($data); - } - - /** - * 计算订单价格 - * - * @return void - */ - public function totalAmount(Request $request, OrderService $orderService) - { - $input = $request->validate([ - 'product_id'=>['bail', 'required', 'int', 'min:0'], - 'num'=>['bail', 'required', 'int', 'min:1'], - ]); - - $product = DealerProduct::online()->findOrFail($input['product_id']); - $user = $request->user(); - - $totalAmount = $orderService->totalAmount($user, $product, $input['num']); - - return response()->json([ - 'total_amount'=> $totalAmount, - 'to_lvl'=>$orderService->willBecome($user, $totalAmount), - ]); - } - - /** - * 确认接单 - * - * @param [type] $id - * @param Request $request - * @return void - */ - public function confirmOrder($id, Request $request, OrderService $orderService) - { - $order = DealerOrder::findOrFail($id); - $userId = $request->user()->id; - //不是发货人 - if (!$order->isConsignor($userId)) { - throw new BizException('订单未找到'); - } - - $orderService->confirmOrder($order); - return response()->noContent(); - } - - /** - * 确认打款 - * - * @return void - */ - public function payOrder($id, Request $request, OrderService $orderService) - { - $input = $request->validate([ - 'pay_image' => ['bail', 'string'], - 'pay_way' => ['bail', 'string'], - 'pay_password' => ['bail', 'required_if:pay_way,wallet'], - 'products'=> ['array'], - ], [ - 'pay_password.required_if' => '支付密码 不能为空。', - ], [ - 'pay_image' => '打款凭证', - 'pay_way' => '支付方式', - 'pay_password' => '支付密码', - ]); - $payWay = PayWay::tryFrom($input['pay_way'] ?? 'offline'); - - if (! in_array($payWay, [PayWay::Offline, PayWay::Wallet, PayWay::WxpayH5, PayWay::WxpayJsApi])) { - throw new BizException('支付方式 非法'); - } - - $user = $request->user(); - - $order = $user->dealerOrders()->findOrFail($id); - - switch ($payWay) { - case PayWay::Wallet: - if (! $user->wallet?->verifyPassword($input['pay_password'])) { - throw new PayPasswordIncorrectException(); - } - - break; - - case PayWay::WxpayH5: - case PayWay::WxpayJsApi: - if ($order->consignor !== null) { - throw new BizException('订单不是签约订单'); - } - - break; - } - - try { - DB::beginTransaction(); - - - //签约单-处理云库存 - if ($order->consignor === null) { - //处理云库存设置,如果没有设置则默认云仓库为0。 - $products = $input['products'] ?? []; - if ($products) { - $num = 0; - foreach ($order->products as $product) { - //更新云库存 - if (isset($products[$product->id]) && ($product->qty + $product->deposit_qty) >= $products[$product->id]) { - DealerOrderProduct::where('id', $product->id)->update([ - 'qty' => $products[$product->id], - 'deposit_qty' =>($product->qty + $product->deposit_qty) - $products[$product->id], - ]); - $num += $products[$product->id]; - } - } - if ($num < 20) { - throw new BizException('首次发货最少20盒'); - } - } - } - - $data = $orderService->pay($order, $payWay, $input['pay_image'] ?? null); - - DB::commit(); - } catch (Throwable $e) { - DB::rollBack(); - - report($e); - - if (! $e instanceof BizException) { - $e = new BizException('操作失败,请刷新后再试'); - } - - throw $e; - } - - return response()->json($data); - } - - /** - * 确认收款 - * - * @return void - */ - public function paidOrder($id, Request $request, OrderService $orderService) - { - $order = DealerOrder::findOrFail($id); - $userId = $request->user()->id; - //不是发货人 - if (!$order->isConsignor($userId)) { - throw new BizException('订单未找到'); - } - try { - DB::beginTransaction(); - $orderService->paidOrder($order);//确认收款 - //3-14号取消确认收款后自动发货 - // $orderService->shippingOrder($order);//确认发货 - DB::commit(); - } catch (QueryException $e) { - DB::rollBack(); - if (strpos($e->getMessage(), 'Numeric value out of range') !== false) { - $e = new BizException('当前可发货库存不足'); - } - throw $e; - } catch (Throwable $th) { - DB::rollBack(); - report($th); - throw new BizException('操作失败,请刷新后再试'); - } - return response()->noContent(); - } - - /** - * 确认发货 - * - * @param [type] $id - * @param Request $request - * @param OrderService $orderService - * @return void - */ - public function shippingOrder($id, Request $request, OrderService $orderService) - { - $order = DealerOrder::findOrFail($id); - $user = $request->user(); - //不是发货人 - if (!$order->isConsignor($user->id)) { - throw new BizException('订单未找到'); - } - $deliveryBill = null; - try { - DB::beginTransaction(); - //如果发货人是签约经销商, 则可以使用云仓库发货 - if ($user->dealer->lvl?->value >= DealerLvl::Contracted->value) { - $deliveryBill = $orderService->shippingOrderByDeposit($order); - if ($deliveryBill) { - $order->refresh(); - //扣除本地库存 - $orderService->orderOutQty($order); - } else { - $orderService->shippingOrder($order);//确认发货 - } - } else { - $orderService->shippingOrder($order);//确认发货 - } - DB::commit(); - } catch (BizException $e) { - DB::rollBack(); - $e = new BizException($e->getMessage()); - throw $e; - } catch (QueryException $e) { - DB::rollBack(); - if (strpos($e->getMessage(), 'Numeric value out of range') !== false) { - $e = new BizException('当前可发货库存不足'); - } - throw $e; - } catch (Throwable $th) { - DB::rollBack(); - report($th); - throw new BizException('操作失败,请刷新后再试'); - } - - return response()->json([ - 'delivery_bill_id'=>$deliveryBill?->id, - ]); - } - - /** - * 确认收货 - * - * @return void - */ - public function shippingedOrder($id, Request $request, OrderService $orderService) - { - $order = DealerOrder::findOrFail($id); - $user = $request->user(); - //不是收货人 - if (!$order->isUser($user->id)) { - throw new BizException('订单未找到'); - } - try { - DB::beginTransaction(); - $orderService->shippingedOrder($order); - DB::commit(); - } catch (Throwable $th) { - DB::rollBack(); - report($th); - throw new BizException('操作失败,请刷新后再试'); - } - return response()->noContent(); - } - - /** - * 取消订单 - * - * @param [type] $id - * @param Request $request - * @return void - */ - public function cancelOrder($id, Request $request, OrderService $orderService) - { - $order = DealerOrder::findOrFail($id); - $userId = $request->user()->id; - if (!$order->isUser($userId)) { - throw new BizException('订单未找到'); - } - try { - DB::beginTransaction(); - $orderService->cancelOrder($order); - DB::commit(); - } catch (Throwable $th) { - DB::rollBack(); - report($th); - throw new BizException('操作失败,请刷新后再试'); - } - return response()->noContent(); - } - - /** - * 放弃接单/转让订单 - * - * @param [type] $id - * @param Request $request - * @param OrderService $orderService - * @return void - */ - public function transferOrder($id, Request $request, OrderService $orderService) - { - $order = DealerOrder::findOrFail($id); - $userId = $request->user()->id; - //不是发货人 - if (!$order->isConsignor($userId)) { - throw new BizException('订单未找到'); - } - if (!$order->isPending()) { - throw new BizException('订单状态异常,请刷新后再试'); - } - try { - DB::beginTransaction(); - $orderService->updateOrderConsignor($order); - DB::commit(); - } catch (Throwable $th) { - DB::rollBack(); - report($th); - throw new BizException('操作失败,请刷新后再试'); - } - - return response()->noContent(); - } -} diff --git a/app/Endpoint/Api/Http/Controllers/Dealer/ProductController.php b/app/Endpoint/Api/Http/Controllers/Dealer/ProductController.php deleted file mode 100644 index fd96da94..00000000 --- a/app/Endpoint/Api/Http/Controllers/Dealer/ProductController.php +++ /dev/null @@ -1,33 +0,0 @@ -input(); - - $products = DealerProduct::select(['id', 'name', 'cover', 'price', 'is_sale']) - ->online() - ->simplePaginate(Paginator::resolvePerPage('per_page', 20, 50)); - return ProductSimpleResource::collection($products); - } - - public function show($id, Request $request) - { - $product = DealerProduct::with(['saleRules', 'lvlRules'])->online()->findOrFail($id); - return ProductResource::make($product); - } -} diff --git a/app/Endpoint/Api/Http/Controllers/Dealer/PurchaseSubsidyController.php b/app/Endpoint/Api/Http/Controllers/Dealer/PurchaseSubsidyController.php deleted file mode 100644 index 966cd654..00000000 --- a/app/Endpoint/Api/Http/Controllers/Dealer/PurchaseSubsidyController.php +++ /dev/null @@ -1,26 +0,0 @@ -where('user_id', $request->user()->id) - ->latest('id') - ->simplePaginate(Paginator::resolvePerPage('per_page', 20, 50)); - - return DealerPurchaseSubsidyResource::collection($purchaseSubsidies); - } -} diff --git a/app/Endpoint/Api/Http/Controllers/Dealer/PurchaseSubsidyLogController.php b/app/Endpoint/Api/Http/Controllers/Dealer/PurchaseSubsidyLogController.php deleted file mode 100644 index c0f97cb6..00000000 --- a/app/Endpoint/Api/Http/Controllers/Dealer/PurchaseSubsidyLogController.php +++ /dev/null @@ -1,28 +0,0 @@ -where('user_id', $request->user()->id)->find($id); - - if ($purchaseSubsidy) { - return DealerPurchaseSubsidyLogResource::collection( - $purchaseSubsidy->logs()->oldest('id')->get() - ); - } - - return response()->json([]); - } -} diff --git a/app/Endpoint/Api/Http/Controllers/Dealer/ShoppingCartItemController.php b/app/Endpoint/Api/Http/Controllers/Dealer/ShoppingCartItemController.php deleted file mode 100644 index 085001f3..00000000 --- a/app/Endpoint/Api/Http/Controllers/Dealer/ShoppingCartItemController.php +++ /dev/null @@ -1,101 +0,0 @@ -user(); - $items = $user->dealerShoppingCartItems()->latest('id')->get(); - $items->load('product'); - $totalQty = $items->sum('quantity'); - $data = []; - foreach ($items as $item) { - $data[] = [ - 'id'=>$item->id, - 'name' =>$item->name, - 'cover'=>$item->cover, - 'sell_price'=>$item->sell_price, - 'dealer_price' =>$orderService->getSalePrice($user, $item->product, $totalQty), - 'quantity'=>$item->quantity, - ]; - } - - return response()->json(['data'=>$data]); - } - - /** - * 加入购物车 - */ - public function store(Request $request) - { - $input = $request->validate([ - 'product_id' => ['bail', 'required', 'int'], - 'quantity' => ['bail', 'required', 'int', 'min:1'], - ]); - - $product = DealerProduct::online()->findOrFail($input['product_id']); - - $shoppingCartItem = $request->user()->dealerShoppingCartItems()->firstOrCreate([ - 'product_id' => $product->id, - ], [ - 'name' => $product->name, - 'cover' => $product->cover, - 'sell_price' => $product->price, - 'quantity' => $input['quantity'], - ]); - if (!$shoppingCartItem->wasRecentlyCreated) { - $shoppingCartItem->increment('quantity', $input['quantity']); - } - - return response()->noContent(); - } - - /** - * 购物车变动 - */ - public function update($id, Request $request) - { - $input = $request->validate([ - 'quantity' => ['bail', 'required', 'int', 'min:1'], - ]); - - $shoppingCartItem = $request->user()->dealerShoppingCartItems()->findOrFail($id); - - $product = DealerProduct::online()->findOrFail($shoppingCartItem->product_id); - - $shoppingCartItem->update(array_merge($input, [ - 'name' => $product->name, - 'cover' => $product->cover, - 'sell_price' => $product->price, - ])); - - return response()->noContent(); - } - - /** - * 移出购物车 - */ - public function delete(Request $request) - { - $input = $request->validate([ - 'ids' => ['bail', 'required', 'array'], - ]); - - $request->user()->dealerShoppingCartItems()->whereIn('id', $input['ids'])->delete(); - - return response()->noContent(); - } -} diff --git a/app/Endpoint/Api/Http/Controllers/Dealer/UserController.php b/app/Endpoint/Api/Http/Controllers/Dealer/UserController.php deleted file mode 100644 index eb6ef697..00000000 --- a/app/Endpoint/Api/Http/Controllers/Dealer/UserController.php +++ /dev/null @@ -1,69 +0,0 @@ -user(); - - $user->dealer->setRelation('userInfo', $user->userInfo); - - $dealerResource = DealerResource::make($user->dealer)->toArray($request); - $dealerResource['guanli_values'] = $calculateManageSubsidiesOfCurrentPeriod->handle($user->dealer); - $dealerResource['archived_purchase_amount'] = $user->dealer->archived_purchase_amount; - $dealerResource['total_purchase_amount'] = $calculatePurchaseAmountOfCurrentPeriod->handle($user->dealer); - - return response()->json([ - 'id' => $user->id, - 'phone' => $user->phone, - 'dealer'=> $dealerResource, - 'dealer_wallet' => $user->dealerWallet?->balance, - 'user_info' => UserInfoResource::make($user->userInfo), - 'has_password' => (bool) $user->wallet?->password, - ]); - } - - public function updatePayInfo(Request $request) - { - $input = $request->validate([ - 'pay_info' => ['bail', 'required', 'array'], - ]); - - $request->user()->dealer->update([ - 'pay_info'=>$input['pay_info'], - ]); - - return response()->noContent(); - } - - public function changeSaleStatus(Request $request) - { - $input = $request->validate([ - 'is_sale' => ['bail', 'required', 'boolean'], - ]); - $request->user()->dealer->update([ - 'is_sale'=>!$input['is_sale'], - ]); - return response()->noContent(); - } -} diff --git a/app/Endpoint/Api/Http/Controllers/Dealer/UserProductController.php b/app/Endpoint/Api/Http/Controllers/Dealer/UserProductController.php deleted file mode 100644 index 693fd92b..00000000 --- a/app/Endpoint/Api/Http/Controllers/Dealer/UserProductController.php +++ /dev/null @@ -1,142 +0,0 @@ -user()->dealerProducts() - ->with('product') - ->orderBy('product_id', 'asc') - ->simplePaginate(Paginator::resolvePerPage('per_page', 20, 50)); - return UserProductResource::collection($list); - } - - public function show($id, Request $request) - { - $product = $request->user()->dealerProducts() - ->with('product') - ->where('product_id', $id) - ->first(); - return UserProductResource::make($product); - } - - public function logs(Request $request) - { - $list = $request->user()->dealerProductLogs()->filter($request->all()) - ->with('product') - ->orderBy('id', 'desc') - ->simplePaginate(Paginator::resolvePerPage('per_page', 20, 50)); - return UserProductLogResource::collection($list); - } - - /** - * 线下去库存 - * - * @param Request $request - * @return void - */ - public function offlineOutQty(Request $request) - { - $input = $request->validate([ - 'product_id'=>['bail', 'required', 'int', 'min:0'], - 'num'=>['bail', 'required', 'int', 'min:1'], - 'remark'=> ['bail', 'string', 'max:200'], - ], [], [ - 'product_id' => '商品', - 'num' => '数量', - 'remark'=>'备注', - ]); - $product = $request->user()->dealerProducts() - ->where('product_id', $input['product_id']) - ->first(); - if (!$product) { - throw new BizException('您还没有该商品'); - } - try { - DB::beginTransaction(); - $product->decrement('stock', $input['num']); - - DealerUserProductLog::create([ - 'user_id'=> $request->user()->id, - 'product_id'=> $input['product_id'], - 'type' => DealerUserProductLog::TYPE_OFFLINE_OUT, - 'qty'=>$input['num'], - 'remark'=>$input['remark'] ?? null, - ]); - DB::commit(); - } catch (QueryException $e) { - DB::rollBack(); - if (strpos($e->getMessage(), 'Numeric value out of range') !== false) { - $e = new BizException('库存不足'); - } - throw $e; - } catch (Throwable $th) { - DB::rollBack(); - report($th); - throw new BizException('系统繁忙,请稍后再试'); - } - return response()->noContent(); - } - - /** - * 撤销线下去库存 - * - */ - public function revokeQtyLog(DealerUserProductLog $log, Request $request) - { - //判断是否是自己的日志 - if ($log->user_id != $request->user()->id) { - throw new BizException('日志未找到'); - } - //是否可以撤销 - if (!$log->canRevoke()) { - throw new BizException('该日志无法撤销'); - } - - $product = $request->user()->dealerProducts() - ->where('product_id', $log->product_id) - ->first(); - if (!$product) { - throw new BizException('您还没有该商品'); - } - - try { - DB::beginTransaction(); - - $product->increment('stock', $log->qty); - - $revokeLog = DealerUserProductLog::create([ - 'user_id'=> $request->user()->id, - 'product_id'=> $log->product_id, - 'type' => DealerUserProductLog::TYPE_REVOKE_IN, - 'qty' => $log->qty, - 'remark'=> '撤销回滚', - ]); - - $log->update([ - 'revoke_id' => $revokeLog->id, - ]); - - DB::commit(); - } catch (Throwable $th) { - DB::rollBack(); - report($th); - throw new BizException('系统繁忙,请稍后再试'); - } - - return response()->noContent(); - } -} diff --git a/app/Endpoint/Api/Http/Controllers/Dealer/WalletController.php b/app/Endpoint/Api/Http/Controllers/Dealer/WalletController.php deleted file mode 100644 index d6949cea..00000000 --- a/app/Endpoint/Api/Http/Controllers/Dealer/WalletController.php +++ /dev/null @@ -1,185 +0,0 @@ -user()->dealerWalletLogs() - ->filter($request->all()) - ->latest('id') - ->simplePaginate($perPage)); - } - - /** - * 提现到银行 - * - * @return void - */ - public function walletToBank(Request $request, WalletService $walletService) - { - $input = $request->validate([ - 'amount' => ['bail', 'required', 'int', 'min:1'], - 'pay_password' => ['bail', 'required', 'string'], - ], [], [ - 'amount' => '提现金额', - 'pay_password' => '支付密码', - ]); - - $user = $request->user(); - $amount = Arr::get($input, 'amount', 0); - //验证支付密码 - if (! $user->wallet?->verifyPassword($input['pay_password'] ?? '')) { - throw new PayPasswordIncorrectException(); - } - - if (empty($user->dealer->pay_info)) { - throw new BizException('请先绑定设置收款信息'); - } - //校验是否关闭提现 - if (!$user->dealerWallet?->withdrawable) { - throw new BizException('账户已被限制提现'); - } - - //检测是否可以提现 - if (!$user->dealer->canWithdraw()) { - throw new BizException('每次提现需要间隔'.app_settings('dealer.withdraw_days', 7).'天'); - } - - // 校验提现门槛 - 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(); - - $rate = app_settings('dealer.withdraw_fee_rate', '0.00');//手续费率 - // $rate = 0; - //计算手续费(四舍五入) - $serviceAmount = round(bcdiv($rate, 100, 4) * $amount); - - //生成提现记录 - $log = DealerWalletToBankLog::create([ - 'user_id' =>$user->id, - 'amount'=> bcdiv($amount, 100, 2), - 'rate' => $rate, - 'service_amount' => bcdiv($serviceAmount, 100, 2), - 'account_amount' => bcdiv($amount - $serviceAmount, 100, 2), - 'manager_id' => $user->dealer->firstManager()?->user_id, - ]); - - //减去用户可提金额 - $walletService->changeBalance($user, -bcdiv($amount, 100, 2), DealerWalletAction::WithdrawBank, '提现', $log); - DB::commit(); - } catch (BizException $th) { - DB::rollBack(); - throw new BizException($th->getMessage()); - } catch (Throwable $th) { - DB::rollBack(); - report($th); - throw new BizException('系统繁忙,请稍后再试'); - } - return response()->noContent(); - } - - /** - * 余额转账 - * - * @return void - */ - public function walletTransfer(Request $request, WalletService $walletService) - { - $input = $request->validate([ - 'phone' => ['bail', 'required', new PhoneNumber()], - 'amount' => ['bail', 'required', 'int', 'min:1'], - 'pay_password' => ['bail', 'required', 'filled', 'string', 'size:6'], - ]); - - $user = $request->user(); - - //校验是否关闭 - if (!$user->dealerWallet?->withdrawable) { - throw new BizException('账户已被限制转账'); - } - - //判断转账对象是否存在 - $toUser = User::where('phone', '=', $input['phone'])->first(); - if (is_null($toUser)) { - throw new BizException('转账对象不存在'); - } - //校验安全密码 - if (! $user->wallet?->verifyPassword($input['pay_password'])) { - throw new PayPasswordIncorrectException(); - } - - try { - DB::beginTransaction(); - //转出对象 - $log = $walletService->changeBalance($user, -Arr::get($input, 'amount', 0), DealerWalletAction::TransferOut, '转出-'.$toUser->phone.($toUser->userInfo?->nickname ? '【'.$toUser->userInfo->nickname.'】' : '')); - //转入对象 - $walletService->changeBalance($toUser, Arr::get($input, 'amount', 0), DealerWalletAction::TransferIn, $user->phone.($user->userInfo?->nickname ? '【'.$user->userInfo->nickname.'】' : '').'-转入', $log); - - DB::commit(); - } catch (Throwable $th) { - DB::rollBack(); - report($th); - throw new BizException('转账失败,请稍后再试'); - } - - return response()->noContent(); - } - - /** - * 提现记录 - * - * @return void - */ - public function walletToBankLogs(Request $request) - { - $perPage = PaginatorHelper::resolvePerPage('per_page', 20, 50); - - $logs = $request->user()->dealerWalletToBankLogs() - ->latest('id') - ->simplePaginate($perPage); - - return WalletToBankLogSimpleResource::collection($logs); - } - - /** - * 提现记录详情 - * - * @param [type] $id - * @param Request $request - * @return void - */ - public function walletToBankLogShow($id, Request $request) - { - $log = $request->user()->dealerWalletToBankLogs()->findOrFail($id); - return WalletToBankLogResource::make($log); - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/DealerDeliveryBillResource.php b/app/Endpoint/Api/Http/Resources/Dealer/DealerDeliveryBillResource.php deleted file mode 100644 index 83089e86..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/DealerDeliveryBillResource.php +++ /dev/null @@ -1,34 +0,0 @@ - $this->id, - 'sn' => $this->sn, - 'shipping_fee' => $this->shipping_fee, - 'remark' => $this->remark, - 'consignee_name' => $this->consignee_name, - 'consignee_telephone' => $this->consignee_telephone, - 'consignee_zone' => $this->consignee_zone, - 'consignee_address' => $this->consignee_address, - 'delivery_products' => DealerDeliveryProductResource::collection($this->whenLoaded('deliveryProducts')), - 'pay_sn' => $this->pay_sn, - 'pay_way' => $this->pay_way, - 'pay_at' => $this->pay_at?->toDateTimeString(), - 'status' => $this->status, - 'created_at' => $this->created_at->toDateTimeString(), - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/DealerDeliveryProductResource.php b/app/Endpoint/Api/Http/Resources/Dealer/DealerDeliveryProductResource.php deleted file mode 100644 index dee14701..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/DealerDeliveryProductResource.php +++ /dev/null @@ -1,24 +0,0 @@ - $this->product->id, - 'name' => $this->product->name, - 'cover' => $this->product->cover, - 'qty' => $this->qty, - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/DealerEarningResource.php b/app/Endpoint/Api/Http/Resources/Dealer/DealerEarningResource.php deleted file mode 100644 index df0d5b12..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/DealerEarningResource.php +++ /dev/null @@ -1,42 +0,0 @@ -getPurchaseSubsidyLogs(); - return [ - 'id' => $this->id, - 'type' => $this->earningable_type_text, - 'created_at' => $this->created_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->status_format, - 'status_name' => $this->status_name, - 'remark' => $this->remark, - 'pay_way' => $this->pay_way ?? '', - 'pay_info' => $this->getPayInfo(), - 'pay_image' => $this->pay_image, - 'pay_at' => $this->pay_at?->toDateTimeString(), - 'is_payer' => $this->payer_id ? ($this->payer_id == $request->user()->id) : false, - 'purchase_subsidy_logs' => $purchaseSubsidyLogs ? DealerEarningSubsidyLogResource::collection($purchaseSubsidyLogs) : null, - 'beneficiary' => $this->user ? [ - 'nickname' => $this->user->userInfo?->nickname ?? '', - 'phone'=>$this->user->phone ?? '', - ] : null, - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/DealerEarningSimpleResource.php b/app/Endpoint/Api/Http/Resources/Dealer/DealerEarningSimpleResource.php deleted file mode 100644 index 9427bf80..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/DealerEarningSimpleResource.php +++ /dev/null @@ -1,31 +0,0 @@ - $this->id, - 'type' => $this->earningable_type_text, - 'created_at' => $this->created_at->toDateTimeString(), - 'total_earnings'=> $this->total_earnings, - 'status' => $this->status_format, - 'status_name' => $this->status_name, - 'is_payer' => $this->payer_id ? ($this->payer_id == $request->user()->id) : false, - 'beneficiary_phone' => (string) $this->whenLoaded('user', function () { - return $this->user?->phone ?? ''; - }, ''), - // 'settle_at' - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/DealerEarningSubsidyLogResource.php b/app/Endpoint/Api/Http/Resources/Dealer/DealerEarningSubsidyLogResource.php deleted file mode 100644 index 2feb303e..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/DealerEarningSubsidyLogResource.php +++ /dev/null @@ -1,23 +0,0 @@ - $this->changeAmount, - 'remark' => $this->remark, - // 'settle_at' - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/DealerFansResource.php b/app/Endpoint/Api/Http/Resources/Dealer/DealerFansResource.php deleted file mode 100644 index 3c8b9ab7..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/DealerFansResource.php +++ /dev/null @@ -1,34 +0,0 @@ - $this->id, - 'phone' => $this->phone, - 'nickname' => (string) $this->whenLoaded('userInfo', function () { - return $this->userInfo->nickname; - }, ''), - 'avatar' => (string) $this->whenLoaded('userInfo', function () { - return $this->userInfo->avatar; - }, ''), - 'team_sales_value' => (string) $this->whenLoaded('dealer', function () { - return $this->dealer->team_sales_value; - }, 0), - 'lvl_name' => (string) $this->whenLoaded('dealer', function () { - return $this->dealer->lvl->text(); - }, '未知'), - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/DealerManageSubsidyLogResource.php b/app/Endpoint/Api/Http/Resources/Dealer/DealerManageSubsidyLogResource.php deleted file mode 100644 index 3f2e7542..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/DealerManageSubsidyLogResource.php +++ /dev/null @@ -1,24 +0,0 @@ - OrderSimpleResource::make($this->whenLoaded('order')), - 'product' => ProductSimpleResource::make($this->whenLoaded('product')), - 'sales_volume' => $this->sales_volume, - 'total_amount' => $this->total_amount, - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/DealerPurchaseSubsidyLogResource.php b/app/Endpoint/Api/Http/Resources/Dealer/DealerPurchaseSubsidyLogResource.php deleted file mode 100644 index 22901450..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/DealerPurchaseSubsidyLogResource.php +++ /dev/null @@ -1,22 +0,0 @@ - $this->change_amount, - 'remark' => $this->remark, - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/DealerPurchaseSubsidyResource.php b/app/Endpoint/Api/Http/Resources/Dealer/DealerPurchaseSubsidyResource.php deleted file mode 100644 index 5fc14bae..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/DealerPurchaseSubsidyResource.php +++ /dev/null @@ -1,27 +0,0 @@ - $this->id, - 'total_purchase_amount' => $this->total_purchase_amount, - 'total_subsidy' => $this->total_subsidy, - 'total_amount' => $this->total_amount, - 'fee' => $this->fee, - 'start_date' => $this->start_at->rawFormat('Y/m/d'), - 'end_date' => $this->end_at->rawFormat('Y/m/d'), - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/DealerResource.php b/app/Endpoint/Api/Http/Resources/Dealer/DealerResource.php deleted file mode 100644 index 2297d458..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/DealerResource.php +++ /dev/null @@ -1,28 +0,0 @@ - $this->lvl, - 'lvl_icon' => $this->lvl->icon(), - 'lvl_name'=> $this->lvl->text(), - 'is_sale' => $this->is_sale, - 'guanli_values'=> bcdiv($this->calculate_total_amount, '1', 2), //预计管理津贴 - 'team_sales_value' => $this->team_sales_value, // 团队业绩 - 'pay_info'=>$this->pay_info ?: null, - 'can_withdraw'=> $this->canWithdraw(), - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/OrderProductResource.php b/app/Endpoint/Api/Http/Resources/Dealer/OrderProductResource.php deleted file mode 100644 index 727db3a9..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/OrderProductResource.php +++ /dev/null @@ -1,27 +0,0 @@ - $this->id, - 'name' => $this->name, - 'cover'=> $this->cover, - 'price'=>$this->price, - 'sale_price' =>$this->sale_price, - 'qty' =>$this->qty, - 'deposit_qty'=> $this->deposit_qty, - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/OrderResource.php b/app/Endpoint/Api/Http/Resources/Dealer/OrderResource.php deleted file mode 100644 index 33c9f828..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/OrderResource.php +++ /dev/null @@ -1,40 +0,0 @@ - $this->id, - 'sn' =>$this->sn, - 'product'=>OrderProductResource::collection($this->products), - 'total_amount' => $this->total_amount, - 'created_at' => $this->created_at->toDateTimeString(), - 'status' => $this->status, - 'pay_way' => (string) $this->pay_way?->label(), - 'pay_info' => $this->getConsignorPayInfo(), - 'pay_image'=> $this->pay_image, - 'is_consignor' => $request->user()->id == $this->consignor_id, //是否发货人身份 - 'consignee_name'=>$this->consignee_name, - 'consignee_telephone'=>$this->consignee_telephone, - 'consignee_zone' => $this->consignee_zone, - 'consignee_address' => $this->consignee_address, - - //新增接单人信息返回 - 'consignor'=> $this->consignor ? [ - 'consignor_name' => $this->consignor->userInfo?->nickname ?? '', - 'consignor_phone'=>$this->consignor->phone ?? '', - ] : null, - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/OrderSimpleResource.php b/app/Endpoint/Api/Http/Resources/Dealer/OrderSimpleResource.php deleted file mode 100644 index ae509660..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/OrderSimpleResource.php +++ /dev/null @@ -1,28 +0,0 @@ - $this->id, - 'sn' =>$this->sn, - 'total_amount' => $this->total_amount, - 'created_at' => $this->created_at->toDateTimeString(), - 'status' => $this->status, - 'is_consignor' => $request->user()->id == $this->consignor_id, //是否发货人身份 - 'products' => OrderProductResource::collection($this->whenLoaded('products')), - 'user' => UserResource::make($this->whenLoaded('user')), - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/ProductLvlRuleResource.php b/app/Endpoint/Api/Http/Resources/Dealer/ProductLvlRuleResource.php deleted file mode 100644 index 1130756a..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/ProductLvlRuleResource.php +++ /dev/null @@ -1,23 +0,0 @@ - $this->lvl, - 'sale_price' => $this->sale_price, - 'min_order_amount' => app_settings('dealer.min_order_amount_'.$this->lvl, 0), - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/ProductResource.php b/app/Endpoint/Api/Http/Resources/Dealer/ProductResource.php deleted file mode 100644 index 1c819f4c..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/ProductResource.php +++ /dev/null @@ -1,30 +0,0 @@ - $this->id, - 'name' => $this->name, - 'unit' => $this->unit, - 'cover' => (string) $this->cover, - 'images' => $this->images, - 'price' => (string) $this->price, - 'is_online' => $this->isOnline(), - 'description' => (string) $this->description, - 'lvl_rules' => ProductLvlRuleResource::collection($this->whenLoaded('lvlRules')), - 'sale_rules' => ProductSaleRuleResource::collection($this->whenLoaded('saleRules')), - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/ProductSaleRuleResource.php b/app/Endpoint/Api/Http/Resources/Dealer/ProductSaleRuleResource.php deleted file mode 100644 index 747e6528..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/ProductSaleRuleResource.php +++ /dev/null @@ -1,22 +0,0 @@ - $this->qty, - 'price'=>$this->price, - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/ProductSimpleResource.php b/app/Endpoint/Api/Http/Resources/Dealer/ProductSimpleResource.php deleted file mode 100644 index 471a2edc..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/ProductSimpleResource.php +++ /dev/null @@ -1,25 +0,0 @@ - $this->id, - 'name' => $this->name, - 'cover' => (string) $this->cover, - 'price' => (string) $this->price, - 'is_online' => $this->isOnline(), - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/UserInfoResource.php b/app/Endpoint/Api/Http/Resources/Dealer/UserInfoResource.php deleted file mode 100644 index 26dbc982..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/UserInfoResource.php +++ /dev/null @@ -1,25 +0,0 @@ - (string) $this->nickname, - 'avatar' => (string) $this->avatar, - 'gender' => (string) $this->gender, - 'birthday' => (string) $this->birthday?->toDateString(), - 'code' => (string) $this->code, - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/UserProductLogResource.php b/app/Endpoint/Api/Http/Resources/Dealer/UserProductLogResource.php deleted file mode 100644 index 5d0e44ef..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/UserProductLogResource.php +++ /dev/null @@ -1,27 +0,0 @@ - $this->id, - 'product_name'=> $this->product?->name, - 'remark' => $this->remark, - 'is_deposit' => $this->is_deposit, - 'qty' => $this->qty_format.$this->product?->unit, - 'created_at' => $this->created_at->toDateTimeString(), - 'can_revoke' => $this->canRevoke(), - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/UserProductResource.php b/app/Endpoint/Api/Http/Resources/Dealer/UserProductResource.php deleted file mode 100644 index 16aa30eb..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/UserProductResource.php +++ /dev/null @@ -1,26 +0,0 @@ - $this->product_id, - 'name' => $this->product?->name, - 'cover' => (string) $this->product?->cover, - 'price' => (string) $this->product?->price, - 'stock' => (int) $this->stock, - 'deposit_stock'=> (int) $this->deposit_stock, - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/UserResource.php b/app/Endpoint/Api/Http/Resources/Dealer/UserResource.php deleted file mode 100644 index fd30cf4f..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/UserResource.php +++ /dev/null @@ -1,26 +0,0 @@ - $this->id, - 'phone' => $this->phone, - 'nickname' => (string) $this->userInfo->nickname, - 'avatar' => (string) $this->userInfo->avatar, - 'gender' => (string) $this->userInfo->gender, - 'code' => (string) $this->userInfo->code, - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/WalletLogResource.php b/app/Endpoint/Api/Http/Resources/Dealer/WalletLogResource.php deleted file mode 100644 index 1679192c..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/WalletLogResource.php +++ /dev/null @@ -1,23 +0,0 @@ - $this->remarks, - 'created_at' => $this->created_at->format('y-m-d H:i'), - 'change_balance' => $this->change_balance, - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/WalletToBankLogResource.php b/app/Endpoint/Api/Http/Resources/Dealer/WalletToBankLogResource.php deleted file mode 100644 index 0a73d002..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/WalletToBankLogResource.php +++ /dev/null @@ -1,27 +0,0 @@ - $this->amount, - 'service_amount' => $this->service_amount, - 'created_at' => $this->created_at->toDateTimeString(), - 'status' => $this->status, - 'remarks' => $this->remarks, - 'pay_info' => $this->getPayInfo(), - 'pay_image' => $this->pay_image, - ]; - } -} diff --git a/app/Endpoint/Api/Http/Resources/Dealer/WalletToBankLogSimpleResource.php b/app/Endpoint/Api/Http/Resources/Dealer/WalletToBankLogSimpleResource.php deleted file mode 100644 index a55c2a31..00000000 --- a/app/Endpoint/Api/Http/Resources/Dealer/WalletToBankLogSimpleResource.php +++ /dev/null @@ -1,26 +0,0 @@ - $this->id, - 'amount' => $this->amount, - 'service_amount' => $this->service_amount, - 'created_at' => $this->created_at->toDateTimeString(), - 'status' => $this->status, - 'remarks' => $this->remarks, - ]; - } -} diff --git a/app/Endpoint/Api/routes.php b/app/Endpoint/Api/routes.php index e39c1f7b..bb6134c7 100644 --- a/app/Endpoint/Api/routes.php +++ b/app/Endpoint/Api/routes.php @@ -17,7 +17,6 @@ use App\Endpoint\Api\Http\Controllers\Auth\RegisterController; use App\Endpoint\Api\Http\Controllers\Auth\ResetPasswordController; use App\Endpoint\Api\Http\Controllers\CaptchaController; use App\Endpoint\Api\Http\Controllers\ClickController; -use App\Endpoint\Api\Http\Controllers\Dealer; use App\Endpoint\Api\Http\Controllers\Merchant; use App\Endpoint\Api\Http\Controllers\MessageController; use App\Endpoint\Api\Http\Controllers\Order\OrderController; @@ -241,96 +240,4 @@ Route::group([ // 老配额领取记录 Route::get('quota-v1-logs', [Merchant\QuotaLogController::class, 'quotaV1Logs']); }); - - - // 批零配置 - Route::get('dealer/configurations', [Dealer\ConfigurationController::class, 'index']); - //商品列表 - Route::get('/dealer/products', [Dealer\ProductController::class, 'index']); - //商品详情 - Route::get('/dealer/products/{id}', [Dealer\ProductController::class, 'show']); - - Route::group([ - 'prefix'=>'dealer', - 'middleware' => [ - 'guard:api', - 'ability:dealer', - ], - ], function () { - //个人信息 - Route::get('me', [Dealer\UserController::class, 'show']); - Route::put('pay-info', [Dealer\UserController::class, 'updatePayInfo']); - Route::put('sale-status', [Dealer\UserController::class, 'changeSaleStatus']); - //业绩统计 - Route::get('fans/statistics', [Dealer\FansController::class, 'statistics']); - Route::get('fans', [Dealer\FansController::class, 'index']); - Route::get('fans/{fan}', [Dealer\FansController::class, 'show']); - - //我的库存 - Route::get('user-products', [Dealer\UserProductController::class, 'index']); - Route::get('user-products/{product}', [Dealer\UserProductController::class, 'show']); - Route::get('user-products-logs', [Dealer\UserProductController::class, 'logs']); - Route::post('user-products/offline-out', [Dealer\UserProductController::class, 'offlineOutQty']); - Route::post('user-products/offline-out-revoke/{log}', [Dealer\UserProductController::class, 'revokeQtyLog']); - - //购物车 - Route::apiResource('shopping-cart-items', Dealer\ShoppingCartItemController::class)->only( - ['index', 'store', 'update'] - ); - Route::delete('shopping-cart-items', [Dealer\ShoppingCartItemController::class, 'delete']); - - Route::get('orders-check', [Dealer\OrderController::class, 'checkOrder']); - //计算商品下单价格 - Route::get('orders/total-amount', [Dealer\OrderController::class, 'totalAmount']); - //订单列表 - Route::get('orders', [Dealer\OrderController::class, 'index']); - //下单 - Route::post('orders', [Dealer\OrderController::class, 'store']); - Route::post('orders-new', [Dealer\OrderController::class, 'newStore']); - //订单详情 - Route::get('orders/{order}', [Dealer\OrderController::class, 'show']); - - //确认接单 - Route::post('orders/{order}/confirm', [Dealer\OrderController::class, 'confirmOrder']); - //确认打款 - Route::post('orders/{order}/pay', [Dealer\OrderController::class, 'payOrder']); - //确认收款+发货 - Route::post('orders/{order}/paid', [Dealer\OrderController::class, 'paidOrder']); - //确认发货 - Route::post('orders/{order}/shipping', [Dealer\OrderController::class, 'shippingOrder']); - //确认收货 - Route::post('orders/{order}/shippinged', [Dealer\OrderController::class, 'shippingedOrder']); - //取消订单 - Route::post('orders/{order}/cancel', [Dealer\OrderController::class, 'cancelOrder']); - //发货人转让订单 - Route::post('orders/{order}/transfer', [Dealer\OrderController::class, 'transferOrder']); - - //资金列表 - Route::get('earnings', [Dealer\EarningController::class, 'index']); - Route::get('earnings/{earning}', [Dealer\EarningController::class, 'show']); - Route::post('earnings/{earning}/pay', [Dealer\EarningController::class, 'payEarning']); - Route::post('earnings/{earning}/confirm', [Dealer\EarningController::class, 'confirmEarning']); - //余额提现 - Route::get('wallet', [Dealer\WalletController::class, 'index']); - Route::post('wallet/transfer', [Dealer\WalletController::class, 'walletTransfer']); - Route::post('wallet/withdraw', [Dealer\WalletController::class, 'walletToBank']); - Route::get('wallet/withdraw-logs', [Dealer\WalletController::class, 'walletToBankLogs']); - Route::get('wallet/withdraw-logs/{withdraw_log}', [Dealer\WalletController::class, 'walletToBankLogShow']); - - // 进货补贴 - Route::get('purchase-subsidies', [Dealer\PurchaseSubsidyController::class, 'index']); - // 进货补贴流水 - Route::get('purchase-subsidies/{purchase_subsidy}/logs', [Dealer\PurchaseSubsidyLogController::class, 'index']); - // 管理津贴统计 - Route::get('manage-subsidy-statistics', [Dealer\ManageSubsidyController::class, 'statistics']); - // 管理津贴流水 - Route::get('manage-subsidy-logs', [Dealer\ManageSubsidyLogController::class, 'index']); - - // 云仓库 - Route::get('delivery-bills', [Dealer\DealerDeliveryBillController::class, 'index']); - Route::post('delivery-bills', [Dealer\DealerDeliveryBillController::class, 'store']); - Route::get('delivery-bills/{delivery_bill}', [Dealer\DealerDeliveryBillController::class, 'show']); - Route::post('delivery-bills/{delivery_bill}/pay', [Dealer\DealerDeliveryBillController::class, 'pay']); - Route::post('delivery-bills/{delivery_bill}/cancel', [Dealer\DealerDeliveryBillController::class, 'cancel']); - }); }); diff --git a/app/Endpoint/Callback/Http/Controllers/YeePayNotifyController.php b/app/Endpoint/Callback/Http/Controllers/YeePayNotifyController.php index 87739334..a32cfe5c 100644 --- a/app/Endpoint/Callback/Http/Controllers/YeePayNotifyController.php +++ b/app/Endpoint/Callback/Http/Controllers/YeePayNotifyController.php @@ -2,9 +2,7 @@ namespace App\Endpoint\Callback\Http\Controllers; -use App\Enums\DealerWalletToBankLogStatus; use App\Enums\WalletToBankLogStatus; -use App\Models\DealerWalletToBankLog; use App\Models\WalletToBankLog; use App\Services\YeePayService; use Exception; @@ -74,29 +72,6 @@ class YeePayNotifyController extends Controller 'failed_reason' => $request->input('resultMessage').'#'.$resultCode, ]); } - } elseif ($contextType === 'dealer_wallet_to_bank') { - $log = DealerWalletToBankLog::where('pay_sn', $orderNo)->first(); - - if ($log === null) { - return; - } - - if ($log->status !== DealerWalletToBankLogStatus::Paying) { - return; - } - - if ($orderStatus === 'SUCCESS') { - $log->update([ - 'status' => DealerWalletToBankLogStatus::Success, - 'pay_at' => Carbon::parse($request->input('finishTime')), - 'failed_reason' => null, - ]); - } elseif ($orderStatus === 'FAIL') { - $log->update([ - 'status' => DealerWalletToBankLogStatus::Failed, - 'failed_reason' => $request->input('resultMessage').'#'.$resultCode, - ]); - } } } diff --git a/app/Enums/DealerDeliveryBillStatus.php b/app/Enums/DealerDeliveryBillStatus.php deleted file mode 100644 index 7c0ee7d3..00000000 --- a/app/Enums/DealerDeliveryBillStatus.php +++ /dev/null @@ -1,35 +0,0 @@ -value]; - } - - public static function colors() - { - return [ - static::Pending->value => '#5b69bc', - static::Paid->value => '#21b978', - static::Shippinged->value => '#21b978', - static::Cancelled->value => '#b3b9bf', - ]; - } - - public static function texts() - { - return [ - static::Pending->value => '待付款', - static::Paid->value => '已付款', - static::Shippinged->value => '已发货', - static::Cancelled->value => '已取消', - ]; - } -} diff --git a/app/Enums/DealerEarningStatus.php b/app/Enums/DealerEarningStatus.php deleted file mode 100644 index 2b8a9b5e..00000000 --- a/app/Enums/DealerEarningStatus.php +++ /dev/null @@ -1,37 +0,0 @@ -value] ?? '#5b69bc'; - } - - public function text() - { - return static::texts()[$this->value]; - } - - public static function colors() - { - return [ - static::Pending->value => '#5b69bc', - static::Paid->value => '#3085d6', - static::Completed->value => '#21b978', - ]; - } - - public static function texts() - { - return [ - static::Pending->value => '待打款', - static::Paid->value => '待收款', - static::Completed->value => '已完成', - ]; - } -} diff --git a/app/Enums/DealerLvl.php b/app/Enums/DealerLvl.php deleted file mode 100644 index 69f8424d..00000000 --- a/app/Enums/DealerLvl.php +++ /dev/null @@ -1,69 +0,0 @@ - 0, - static::Gold => 2, - static::Special => 3, - static::Contracted => 4, - static::Secondary => 5, - static::Top => 6, - }; - } - - /** - * @return string - */ - public function icon() - { - return match ($this) { - static::Secondary => 'https://cdn.zichunsheng.cn/statics/icons/dealer_lvl_5.png', - static::Top => 'https://cdn.zichunsheng.cn/statics/icons/dealer_lvl_6.png', - default => '', - }; - } - - /** - * @return string - */ - public function text() - { - return match ($this) { - static::None => '普通用户', - static::Gold => '金牌经销商', - static::Special => '特邀经销商', - static::Contracted => '签约经销商', - static::Secondary => '签约经销商II', - static::Top => '签约经销商I', - }; - } - - /** - * @return string - */ - public static function texts(): array - { - return [ - static::None->value => '普通用户', - static::Gold->value => '金牌经销商', - static::Special->value => '特邀经销商', - static::Contracted->value => '签约经销商', - static::Secondary->value => '签约经销商II', - static::Top->value => '签约经销商I', - ]; - } -} diff --git a/app/Enums/DealerManageSubsidyStatus.php b/app/Enums/DealerManageSubsidyStatus.php deleted file mode 100644 index 51367fcc..00000000 --- a/app/Enums/DealerManageSubsidyStatus.php +++ /dev/null @@ -1,29 +0,0 @@ -value] ?? 'Unknown'; - } - - public static function colors(): array - { - return [ - static::Pending->value => '#5b69bc', - static::Completed->value => '#21b978', - ]; - } - - public static function texts(): array - { - return [ - static::Pending->value => '待付款', - static::Completed->value => '已付款', - ]; - } -} diff --git a/app/Enums/DealerManagerSubsidyStatus.php b/app/Enums/DealerManagerSubsidyStatus.php deleted file mode 100644 index 8ee0229a..00000000 --- a/app/Enums/DealerManagerSubsidyStatus.php +++ /dev/null @@ -1,37 +0,0 @@ - '#5b69bc', - static::Completed => '#21b978', - }; - } - - public function text(): string - { - return static::texts()[$this->value] ?? 'Unknown'; - } - - public static function colors(): array - { - return [ - static::Pending->value => '#5b69bc', - static::Completed->value => '#21b978', - ]; - } - - public static function texts(): array - { - return [ - static::Pending->value => '待付款', - static::Completed->value => '已付款', - ]; - } -} diff --git a/app/Enums/DealerOrderSettleState.php b/app/Enums/DealerOrderSettleState.php deleted file mode 100644 index 08654fd7..00000000 --- a/app/Enums/DealerOrderSettleState.php +++ /dev/null @@ -1,9 +0,0 @@ -value => '待确认', - static::Paying->value => '待付款', - static::Confirming->value => '待收款', - static::Paid->value => '待发货', - static::Shipped->value => '待收货', - static::Completed->value => '已完成', - static::Cancelled->value => '已取消', - ]; - } -} diff --git a/app/Enums/DealerPurchaseSubsidySettleState.php b/app/Enums/DealerPurchaseSubsidySettleState.php deleted file mode 100644 index 2514477b..00000000 --- a/app/Enums/DealerPurchaseSubsidySettleState.php +++ /dev/null @@ -1,9 +0,0 @@ -value] ?? 'Unknown'; - } - - public static function colors(): array - { - return [ - static::Pending->value => '#5b69bc', - static::Completed->value => '#21b978', - ]; - } - - public static function texts(): array - { - return [ - static::Pending->value => '待付款', - static::Completed->value => '已完成', - ]; - } -} diff --git a/app/Enums/DealerSalesValueLogType.php b/app/Enums/DealerSalesValueLogType.php deleted file mode 100644 index c0adf619..00000000 --- a/app/Enums/DealerSalesValueLogType.php +++ /dev/null @@ -1,8 +0,0 @@ - '#5b69bc', - static::Behalf => '#21b978', - }; - } - - /** - * @return string - */ - public function text(): string - { - return static::texts()[$this->value]; - } - - /** - * @return array - */ - public static function texts(): array - { - return [ - static::Offline->value => '线下', - static::Behalf->value => '代付', - ]; - } -} diff --git a/app/Enums/DealerWalletToBankLogStatus.php b/app/Enums/DealerWalletToBankLogStatus.php deleted file mode 100644 index ccfc4cb1..00000000 --- a/app/Enums/DealerWalletToBankLogStatus.php +++ /dev/null @@ -1,50 +0,0 @@ - '#5b69bc', - static::Passed => '#dda451', - static::Paying => '#3085d6', - static::Success => '#21b978', - static::Failed => '#ea5455', - static::Refused => '#b3b9bf', - }; - } - - /** - * @return string - */ - public function text(): string - { - return static::texts()[$this->value]; - } - - /** - * @return array - */ - public static function texts(): array - { - return [ - static::Pending->value => '待处理', - static::Passed->value => '待付款', - static::Paying->value => '付款中', - static::Success->value => '成功', - static::Failed->value => '失败', - static::Refused->value => '拒绝', - ]; - } -} diff --git a/app/Models/Dealer.php b/app/Models/Dealer.php deleted file mode 100644 index 612e3753..00000000 --- a/app/Models/Dealer.php +++ /dev/null @@ -1,355 +0,0 @@ - DealerLvl::None, - 'is_sale' => true, - 'is_manager' => false, - 'self_sales_value' => 0, - 'team_sales_value' => 0, - ]; - - protected $casts = [ - 'lvl' => DealerLvl::class, - 'is_sale' => 'bool', - 'is_manager' => 'bool', - 'pay_info' => JsonArray::class, - 'contracted_lvl_at' => 'datetime', - ]; - - protected $fillable = [ - 'user_id', - 'lvl', - 'is_sale', - 'is_manager', - 'pay_info', - 'contracted_lvl_at', - 'bonds', - 'self_sales_value', - 'team_sales_value', - ]; - - public function user() - { - return $this->belongsTo(User::class, 'user_id'); - } - - /** - * 属于此经销商的用户信息 - */ - public function userInfo() - { - return $this->hasOne(UserInfo::class, 'user_id', 'user_id'); - } - - public function wallet() - { - return $this->hasOne(DealerWallet::class, 'user_id', 'user_id'); - } - - /** - * 属于此经销商的管理者津贴 - */ - public function managerSalesLogs() - { - return $this->hasMany(DealerManagerSalesLog::class, 'user_id', 'user_id'); - } - - /** - * 属于此经销商的管理者津贴 - */ - public function manageSubsidyLogs() - { - return $this->hasMany(DealerManageSubsidyLog::class, 'user_id', 'user_id'); - } - - /** - * 属于此经销商的升级日志 - */ - public function upgradeLogs() - { - return $this->hasMany(DealerUpgradeLog::class, 'user_id', 'user_id'); - } - - /** - * 属于此经销商的进货补贴 - */ - public function purchaseSubsidies() - { - return $this->hasMany(DealerPurchaseSubsidy::class, 'user_id', 'user_id'); - } - - public function getLvlTextAttribute() - { - return $this->lvl->text(); - } - - /** - * 确认此经销商是否是金牌经销商 - * - * @return boolean - */ - public function isGoldDealer() - { - return $this->lvl === DealerLvl::Gold; - } - - /** - * 确认此经销商是否是特邀经销商 - * - * @return boolean - */ - public function isSpecialDealer() - { - return $this->lvl === DealerLvl::Special; - } - - /** - * 获取此用户的所有上级经销商 - * - * @return array - */ - public function getDealers() - { - if (empty($pids = $this->userInfo->parent_ids)) { - return []; - } - - $ancestors = UserInfo::with(['dealer']) - ->whereIn('user_id', $pids) - ->latest('depth') - ->get(['user_id']); - - return $ancestors->map(function ($item) { - return $item->dealer; - })->all(); - } - - /** - * 获取经销商最近的管理者 - * - * @return static|null - */ - public function firstManager(): ?static - { - if (empty($pids = $this->userInfo->parent_ids)) { - return null; - } - - $manager = UserInfo::whereHas('dealer', function ($builder) { - $builder->where('is_manager', true); - })->whereIn('user_id', $pids)->latest('depth')->first(); - - return $manager?->dealer; - } - - /** - * 获取直属金牌经销商数量 - * - * @return int - */ - public function getDirectGoldDealersCount(): int - { - return static::whereHas('userInfo', function ($query) { - $query->where('inviter_id', $this->user_id); - })->where('lvl', '>=', DealerLvl::Gold)->count(); - } - - /** - * 获取直属的特邀经销商数量 - * - * @return int - */ - public function getDirectSpecialDealersCount(): int - { - return static::whereHas('userInfo', function ($query) { - $query->where('inviter_id', $this->user_id); - })->where('lvl', '>=', DealerLvl::Special)->count(); - } - - /** - * 获取直属的签约经销商数量 - * - * @return int - */ - public function getDirectContractedDealersCount(): int - { - return static::whereHas('userInfo', function ($query) { - $query->where('inviter_id', $this->user_id); - })->where('lvl', '>=', DealerLvl::Contracted)->count(); - } - - /** - * 获取非直属的签约经销商数量 - * - * @return int - */ - public function getIndirectContractedDealersCount(): int - { - $path = $this->userInfo->full_path; - - return static::whereHas('userInfo', function ($query) use ($path) { - $query->where('inviter_id', '!=', $this->user_id)->where('path', 'like', "{$path}%"); - })->where('lvl', '>=', DealerLvl::Contracted)->count(); - } - - /** - * 获取直属的二级经销商数量 - * - * @return int - */ - public function getSecondaryDealersCountOnDifferentLines(): int - { - $path = $this->userInfo->full_path; - - $dealers = static::whereHas('userInfo', function ($query) use ($path) { - $query->where('path', 'like', "{$path}%"); - })->where('lvl', '>=', DealerLvl::Secondary)->get(); - - $dealers->load('userInfo:user_id,path'); - - $lines = []; - - foreach ($dealers as $dealer) { - preg_match("#\A{$path}\d+-#", $dealer->userInfo->full_path, $matches); - - $line = $matches[0]; - - if (! isset($lines[$line])) { - $lines[$line] = 1; - } - } - - return count($lines); - } - - /** - * 尝试升级 - * - * @return void - */ - public function attemptUpgrade() - { - $lvl = $this->lvl; - - if (in_array($lvl, [DealerLvl::None, DealerLvl::Top])) { - return; - } - - $remark = ''; - - if ($lvl === DealerLvl::Gold && $this->getDirectGoldDealersCount() >= 5) { - $lvl = DealerLvl::Special; - - $remark .= '有5个直推金牌'; - } - - if ($lvl === DealerLvl::Special && $this->getDirectSpecialDealersCount() >= 4) { - $lvl = DealerLvl::Contracted; - - if ($remark !== '') { - $remark .= ';'; - } - - $remark .= '有4个直推特邀'; - } - - if ($lvl === DealerLvl::Contracted) { - // 直推签约经销商数量 - $directDealersCount = $this->getDirectContractedDealersCount(); - // 非直推签约经销商数量 - $indirectDealersCount = $this->getIndirectContractedDealersCount(); - - if ($directDealersCount >= 5 && $indirectDealersCount >= 4) { - $lvl = DealerLvl::Secondary; - $remark .= "有{$directDealersCount}个直推签约,{$indirectDealersCount}个间接签约"; - } elseif ($directDealersCount >= 4 && $indirectDealersCount >= 5) { - $lvl = DealerLvl::Secondary; - $remark .= "有{$directDealersCount}个直推签约,{$indirectDealersCount}个间接签约"; - } elseif ($directDealersCount >= 3 && $indirectDealersCount >= 6) { - $lvl = DealerLvl::Secondary; - $remark .= "有{$directDealersCount}个直推签约,{$indirectDealersCount}个间接签约"; - } - } - - if ($lvl === DealerLvl::Secondary && $this->getSecondaryDealersCountOnDifferentLines() >= 4) { - $lvl = DealerLvl::Top; - - if ($remark !== '') { - $remark .= ';'; - } - - $remark .= '有4个二级经销商'; - } - - $this->upgrade($lvl, $remark); - } - - /** - * 直接升级 - * - * @param \App\Enums\DealerLvl $lvl - * @param string|null $remark - * @return void - */ - public function upgrade(DealerLvl $lvl, ?string $remark = null) - { - if ($this->lvl->value >= $lvl->value) { - return; - } - - $before = $this->lvl; - - if ($lvl->value < DealerLvl::Contracted->value) { - $this->contracted_lvl_at = null; - } elseif ($lvl->value >= DealerLvl::Contracted->value && $this->contracted_lvl_at === null) { - $this->contracted_lvl_at = now(); - } - - $this->lvl = $lvl; - $this->save(); - - $this->upgradeLogs()->create([ - 'before_lvl' => $before, - 'change_lvl' => $lvl, - 'remark' => $remark, - ]); - - // 变更代理等级 - $mapAgentLvl = $this->lvl->agentLvl(); - - if ($this->userInfo->agent_level < $mapAgentLvl) { - $this->userInfo->changeAgentLvl($mapAgentLvl, '经销商享商城权益'); - } - } - - /** - * 获取已结算的进货业绩 - * - * @return string - */ - public function getArchivedPurchaseAmountAttribute() - { - return Cache::remember('dealer_archived_purchase_amount_v2:'.$this->user_id, 3600, function () { - return bcmul($this->purchaseSubsidies()->sum('total_purchase_amount'), '1', 2); - }); - } - - public function canWithdraw() - { - return true; - // $days = app_settings('dealer.withdraw_days', 7); - // return DealerWalletToBankLog::where('user_id', $this->user_id)->where('created_at', '>', now()->subDays($days))->doesntExist(); - } -} diff --git a/app/Models/DealerChannelSubsidyLog.php b/app/Models/DealerChannelSubsidyLog.php deleted file mode 100644 index 822d30c5..00000000 --- a/app/Models/DealerChannelSubsidyLog.php +++ /dev/null @@ -1,33 +0,0 @@ - DealerLvl::class, - 'order_completed_at' => 'datetime', - ]; - - protected $fillable = [ - 'user_id', - 'order_id', - 'lvl', - 'total_amount', - 'order_completed_at', - 'remark', - ]; - - public function earning() - { - return $this->morphOne(DealerEarning::class, 'earningable'); - } - - public function user() - { - return $this->belongsTo(User::class, 'user_id'); - } -} diff --git a/app/Models/DealerDeliveryBill.php b/app/Models/DealerDeliveryBill.php deleted file mode 100644 index 2e5f012f..00000000 --- a/app/Models/DealerDeliveryBill.php +++ /dev/null @@ -1,84 +0,0 @@ - DealerDeliveryBillStatus::Pending, - ]; - - protected $casts = [ - 'status' => DealerDeliveryBillStatus::class, - 'pay_way' => PayWay::class, - 'pay_at' => 'datetime', - ]; - - protected $fillable = [ - 'sn', - 'user_id', - 'order_id', - 'shipping_fee', - 'remark', - 'consignee_name', - 'consignee_telephone', - 'consignee_zone', - 'consignee_address', - 'pay_sn', - 'pay_way', - 'out_trade_no', - 'pay_at', - 'status', - ]; - - /** - * {@inheritdoc} - */ - protected static function booted() - { - parent::creating(function ($bill) { - if ($bill->sn === null) { - do { - $bill->sn = serial_number(); - } while (static::where('sn', $bill->sn)->exists()); - } - }); - } - - public function user() - { - return $this->belongsTo(User::class, 'user_id'); - } - - public function order() - { - return $this->hasOne(DealerOrder::class, 'order_id'); - } - - public function payLogs() - { - return $this->morphMany(PayLog::class, 'payable'); - } - - public function deliveryProducts() - { - return $this->hasMany(DealerDeliveryProduct::class, 'delivery_bill_id'); - } - - public function isPending() - { - return $this->status === DealerDeliveryBillStatus::Pending; - } - - public function isPaid() - { - return $this->status === DealerDeliveryBillStatus::Paid; - } -} diff --git a/app/Models/DealerDeliveryProduct.php b/app/Models/DealerDeliveryProduct.php deleted file mode 100644 index 6917bd4e..00000000 --- a/app/Models/DealerDeliveryProduct.php +++ /dev/null @@ -1,13 +0,0 @@ -belongsTo(DealerProduct::class, 'product_id'); - } -} diff --git a/app/Models/DealerEarning.php b/app/Models/DealerEarning.php deleted file mode 100644 index efc2e305..00000000 --- a/app/Models/DealerEarning.php +++ /dev/null @@ -1,241 +0,0 @@ - DealerEarningStatus::Pending, - ]; - - public const PAY_WAY_WALLET = 'wallet'; // 余额 - public const PAY_WAY_OFFLINE = 'offline'; // 线下支付 - - protected $casts = [ - 'lvl' => DealerLvl::class, - 'status' => DealerEarningStatus::class, - 'pay_way' => PayWay::class, - 'pay_at' => 'datetime', - 'settle_at'=> 'datetime', - 'pay_info' => JsonArray::class, - ]; - - protected $fillable = [ - 'user_id', - 'earningable_type', - 'earningable_id', - 'lvl', - 'total_amount', - 'total_earnings', - 'fee', - 'fee_rate', - 'payer_id', - 'pay_info', - 'pay_image', - 'pay_at', - 'settle_at', - 'status', - 'remark', - 'pay_way', - ]; - - public static $payWayText = [ - self::PAY_WAY_WALLET => '余额支付', - self::PAY_WAY_OFFLINE => '线下打款', - ]; - - public function user() - { - return $this->belongsTo(User::class, 'user_id'); - } - - public function payer() - { - return $this->belongsTo(User::class, 'payer_id'); - } - - public function earningable() - { - return $this->morphTo(); - } - - /** - * 仅查询渠道补贴收益 - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeWithoutPayer($query) - { - return $query->whereNull('payer_id'); - } - - /** - * 仅查询渠道补贴收益 - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeChannelSubsidy($query) - { - return $query->where('earningable_type', (new DealerChannelSubsidyLog())->getMorphClass()); - } - - /** - * 待打款 - * - * @param [type] $query - */ - public function scopeOnlyPending($query) - { - return $query->where('status', DealerEarningStatus::Pending); - } - - /** - * 待收款 - * - * @param [type] $query - */ - public function scopeOnlyPaid($query) - { - // return $query->where('status', DealerEarningStatus::Paid); - return $query->whereIn('status', [ - DealerEarningStatus::Pending, - DealerEarningStatus::Paid, - ]); - } - - /** - * 确认此收益是否结算 - * - * @return boolean - */ - public function isSettled(): bool - { - return $this->settle_at !== null; - } - - /** - * 待打款状态 - * - * @return boolean - */ - public function isPending() - { - return $this->status == DealerEarningStatus::Pending; - } - - /** - * 待收款 - * - * @return boolean - */ - public function isPaid() - { - return $this->status == DealerEarningStatus::Paid; - } - - /** - * 是否自己的 - * - * @param [type] $userId - * @return boolean - */ - public function isUser($userId) - { - return $this->user_id == $userId; - } - - /** - * 是否是支付人 - * - * @param [type] $userId - * @return boolean - */ - public function isPayer($userId) - { - return $this->payer_id ? ($this->payer_id == $userId) : false; - } - - public function getStatusNameAttribute() - { - if ($this->settle_at) { - return $this->status->text(); - } else { - return '待结算'; - } - } - - public function getStatusFormatAttribute() - { - return $this->settle_at ? $this->status->value : -1; - } - - public function getEarningableTypeTextAttribute() - { - $text = '其它'; - - switch (Relation::getMorphedModel($this->attributes['earningable_type'])) { - // 管理津贴 - case DealerManageSubsidy::class: - $text = '管理津贴'; - break; - - // 管理者津贴 - case DealerManagerSubsidy::class: - $text = '管理者津贴'; - break; - - // 进货津贴 - case DealerPurchaseSubsidy::class: - $text = '进货补贴'; - break; - - case DealerChannelSubsidyLog::class: - $text = '渠道补贴'; - break; - } - - return $text; - } - - /** - * 获取用户的打款信息 - * - * @return void - */ - public function getPayInfo() - { - if ($this->isPending()) {//待打款订单显示发货人收款信息 - $payInfo = $this->user->dealer->pay_info; - } else { - $payInfo = $this->pay_info; - } - return $payInfo ?: null; - } - - /** - * 获取进货补贴的日志 - * - * @return void - */ - public function getPurchaseSubsidyLogs() - { - if ($this->earningable_type == (new DealerPurchaseSubsidy())->getMorphClass()) { - return $this->earningable?->logs; - } - return null; - } -} diff --git a/app/Models/DealerManageSubsidy.php b/app/Models/DealerManageSubsidy.php deleted file mode 100644 index fd7b74f0..00000000 --- a/app/Models/DealerManageSubsidy.php +++ /dev/null @@ -1,89 +0,0 @@ - DealerLvl::None, - 'is_manager' => false, - 'is_settle' => false, - ]; - - protected $casts = [ - 'lvl' => DealerLvl::class, - 'is_manager' => 'bool', - 'start_at' => 'datetime', - 'end_at' => 'datetime', - 'status' => DealerManageSubsidyStatus::class, - 'is_settle' => 'bool', - ]; - - protected $fillable = [ - 'user_id', - 'lvl', - 'is_manager', - 'total_amount', - 'real_amount', - 'fee', - 'fee_rate', - 'start_at', - 'end_at', - 'status', - 'remark', - 'is_settle', - ]; - - /** - * 仅查询已结算的管理津贴 - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeSettled($query) - { - return $query->where('is_settle', true); - } - - /** - * 此管理津贴所属的经销商 - */ - public function dealer() - { - return $this->belongsTo(Dealer::class, 'user_id', 'user_id'); - } - - public function user() - { - return $this->belongsTo(User::class, 'user_id'); - } - - public function userinfo() - { - return $this->belongsTo(UserInfo::class, 'user_id', 'user_id'); - } - - public function earning() - { - return $this->morphOne(DealerEarning::class, 'earningable'); - } - - /** - * 仅查询待付款的管理津贴 - * - * @return bool - */ - public function isPending(): bool - { - return $this->is_settle && $this->status === DealerManageSubsidyStatus::Pending; - } - - public function isCompleted() - { - return $this->status === DealerManageSubsidyStatus::Completed; - } -} diff --git a/app/Models/DealerManageSubsidyLog.php b/app/Models/DealerManageSubsidyLog.php deleted file mode 100644 index 8f16b994..00000000 --- a/app/Models/DealerManageSubsidyLog.php +++ /dev/null @@ -1,56 +0,0 @@ - DealerLvl::class, - 'order_completed_at' => 'datetime', - ]; - - protected $fillable = [ - 'user_id', - 'lvl', - 'order_id', - 'product_id', - 'sales_volume', - 'total_amount', - 'order_completed_at', - ]; - - public function user() - { - return $this->belongsTo(User::class, 'user_id'); - } - - /** - * 此管理津贴所属的经销商 - */ - public function dealer() - { - return $this->belongsTo(Dealer::class, 'user_id', 'user_id'); - } - - /** - * 此津贴所属订单 - */ - public function order() - { - return $this->belongsTo(DealerOrder::class, 'order_id'); - } - - /** - * 此管理津贴所属的商品 - */ - public function product() - { - return $this->belongsTo(DealerProduct::class, 'product_id'); - } -} diff --git a/app/Models/DealerManagerSalesLog.php b/app/Models/DealerManagerSalesLog.php deleted file mode 100644 index cc57ac8a..00000000 --- a/app/Models/DealerManagerSalesLog.php +++ /dev/null @@ -1,50 +0,0 @@ - DealerLvl::class, - 'order_completed_at' => 'datetime', - ]; - - protected $fillable = [ - 'user_id', - 'order_id', - 'product_id', - 'lvl', - 'sales_volume', - 'order_completed_at', - ]; - - public function user() - { - return $this->belongsTo(User::class, 'user_id'); - } - - /** - * 此津贴所属订单 - */ - public function order() - { - return $this->belongsTo(DealerOrder::class, 'order_id'); - } - - /** - * 此商品销售业绩所属的商品 - */ - public function product() - { - return $this->belongsTo(DealerProduct::class, 'product_id'); - } -} diff --git a/app/Models/DealerManagerSubsidy.php b/app/Models/DealerManagerSubsidy.php deleted file mode 100644 index 42d1e89e..00000000 --- a/app/Models/DealerManagerSubsidy.php +++ /dev/null @@ -1,89 +0,0 @@ - DealerLvl::None, - 'is_manager' => false, - 'is_settle' => false, - ]; - - protected $casts = [ - 'lvl' => DealerLvl::class, - 'is_manager' => 'bool', - 'start_at' => 'datetime', - 'end_at' => 'datetime', - 'status' => DealerManagerSubsidyStatus::class, - 'is_settle' => 'bool', - ]; - - protected $fillable = [ - 'user_id', - 'lvl', - 'is_manager', - 'total_amount', - 'real_amount', - 'fee', - 'fee_rate', - 'start_at', - 'end_at', - 'status', - 'remark', - 'is_settle', - ]; - - /** - * 仅查询已结算的订单 - * - * @param \Illuminate\Database\Eloquent\Builder $query - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeSettled($query) - { - return $query->where('is_settle', true); - } - - public function user() - { - return $this->belongsTo(User::class, 'user_id'); - } - - public function userinfo() - { - return $this->belongsTo(UserInfo::class, 'user_id', 'user_id'); - } - - /** - * 此管理津贴所属的经销商 - */ - public function dealer() - { - return $this->belongsTo(Dealer::class, 'user_id', 'user_id'); - } - - public function earning() - { - return $this->morphOne(DealerEarning::class, 'earningable'); - } - - /** - * 仅查询待付款的管理津贴 - * - * @return bool - */ - public function isPending(): bool - { - return $this->is_settle && $this->status === DealerManagerSubsidyStatus::Pending; - } - - public function isCompleted() - { - return $this->status === DealerManagerSubsidyStatus::Completed; - } -} diff --git a/app/Models/DealerOrder.php b/app/Models/DealerOrder.php deleted file mode 100644 index d645bc76..00000000 --- a/app/Models/DealerOrder.php +++ /dev/null @@ -1,335 +0,0 @@ - DealerOrderStatus::Pending, - 'settle_state' => DealerOrderSettleState::Pending, - ]; - - protected $casts = [ - 'status' => DealerOrderStatus::class, - 'settle_state' => DealerOrderSettleState::class, - 'pay_info'=>JsonArray::class, - 'pay_way' => PayWay::class, - 'pay_time'=> 'datetime', - 'paied_time'=>'datetime', - 'shipping_time'=>'datetime', - 'shippinged_time'=>'datetime', - 'allocated_at'=>'datetime', - ]; - - protected $fillable = [ - 'status', - 'pay_info', - 'pay_image', - 'consignor_id', - 'settle_state', - 'consignee_name', - 'consignee_telephone', - 'consignee_zone', - 'consignee_address', - 'pay_way', - 'pay_time', - 'paied_time', - 'shipping_time', - 'shippinged_time', - 'allocated_at', //分配时间 - 'remark', - 'pay_sn', - 'out_trade_no', - 'local_status', - 'deposit_status', - ]; - - /** - * 只查询付款成功的订单 - */ - public function scopeOnlyPaidSuccessfully($builder) - { - return $builder->whereIn('status', [ - DealerOrderStatus::Paid, - DealerOrderStatus::Shipped, - DealerOrderStatus::Completed, - ]); - } - - /** - * 仅获取待结算的已付款订单 - */ - public function scopeSettlePending($query) - { - return $query->onlyPaidSuccessfully() - ->whereNotNull('paied_time') - ->where('settle_state', DealerOrderSettleState::Pending); - } - - /** - * 获取待确认订单 - */ - public function scopeOnlyPending($query) - { - return $query->where('status', DealerOrderStatus::Pending); - } - - /** - * 已确认/待付款 - */ - public function scopeOnlyPendinged($query) - { - return $query->where('status', DealerOrderStatus::Paying); - } - - /** - * 待收款 - */ - public function scopeOnlyPaid($query) - { - return $query->where('status', DealerOrderStatus::Confirming); - } - - /** - * 待发货 - */ - public function scopeOnlyShipping($query) - { - return $query->where('status', DealerOrderStatus::Paid); - } - - /** - * 已发货/待收货 - */ - public function scopeOnlyShippinged($query) - { - // return $query->whereIn('status', [ - // DealerOrderStatus::Confirming, DealerOrderStatus::Paid, DealerOrderStatus::Shipped, - // ]); - return $query->where('status', DealerOrderStatus::Shipped); - } - - /** - * 已完成 - */ - public function scopeOnlyCompleted($query) - { - return $query->where('status', DealerOrderStatus::Completed); - } - - /** - * 已取消 - */ - public function scopeOnlyCancelled($query) - { - return $query->where('status', DealerOrderStatus::Cancelled); - } - - public function dealerDeliveryBill() - { - return $this->belongsTo(DealerDeliveryBill::class, 'order_id'); - } - - /** - * 此订单所属的用户的信息 - */ - public function userInfo() - { - return $this->belongsTo(UserInfo::class, 'user_id', 'user_id'); - } - - /** - * 此订单所属的经销商 - */ - public function dealer() - { - return $this->belongsTo(Dealer::class, 'user_id', 'user_id'); - } - - /** - * 属于此订单的商品 - */ - public function products() - { - return $this->hasMany(DealerOrderProduct::class, 'order_id'); - } - - public function user() - { - return $this->belongsTo(User::class, 'user_id'); - } - - public function consignor() - { - return $this->belongsTo(User::class, 'consignor_id'); - } - - public function refuseLogs() - { - return $this->hasMany(DealerOrderRefuseLog::class, 'order_id'); - } - - /** - * 属于此订单的支付记录 - */ - public function payLogs() - { - return $this->morphMany(PayLog::class, 'payable'); - } - - public function isUser($userId) - { - return $this->user_id == $userId; - } - - public function isConsignor($userId) - { - return $this->consignor_id == $userId; - } - - public function getOrderStatusAttribute() - { - return $this->status->value; - } - - /** - * 是否待确认订单 - * - * @return boolean - */ - public function isPending() - { - return $this->status == DealerOrderStatus::Pending; - } - - /** - * 是否待打款订单 - * - * @return boolean - */ - public function isPendinged() - { - return $this->status == DealerOrderStatus::Paying; - } - - /** - * 是待确认打款订单 - * - * @return boolean - */ - public function isPay() - { - return $this->status == DealerOrderStatus::Confirming; - } - - /** - * 是已确认收款的订单 - * - * @return boolean - */ - public function isPaid() - { - return $this->status == DealerOrderStatus::Paid; - } - - /** - * 是否待收货订单 - * - * @return boolean - */ - public function isShipping() - { - return $this->status == DealerOrderStatus::Shipped; - } - - /** - * 是否已取消 - * - * @return boolean - */ - public function isCancelled() - { - return $this->status == DealerOrderStatus::Cancelled; - } - - /** - * 支付方式是否是线下打款 - * - * @return bool - */ - public function isPayWayOffline(): bool - { - return $this->pay_way === PayWay::Offline; - } - - /** - * 支付方式是否是余额支付 - * - * @return bool - */ - public function isPayWayWallet(): bool - { - return $this->pay_way === PayWay::Wallet; - } - - /** - * 支付方式是否是微信支付 - * - * @return bool - */ - public function isPayWayWxpay(): bool - { - return in_array($this->pay_way, [ - PayWay::WxpayH5, - PayWay::WxpayJsApi, - ]); - } - - /** - * 能否操作 - * - * @param [type] $userId - * @return boolean - */ - public function canCurd($userId) - { - return $this->isUser($userId) || $this->isConsignor($userId); - } - - /** - * 获取发货人的打款信息 - * - * @return void - */ - public function getConsignorPayInfo() - { - if ($this->isPendinged()) {//待打款订单显示发货人收款信息 - if ($this->consignor?->dealer) { - $payInfo = $this->consignor->dealer->pay_info; - } else { - $payInfo = [ - //todo-公司的收款信息 - 'bank'=>app_settings('dealer.bank'), - 'alipay'=>app_settings('dealer.alipay'), - 'wechat'=>app_settings('dealer.wechat'), - ]; - } - } elseif ($this->isPending() || $this->isCancelled()) {//如果是已取消订单或者待确认订单不显示收款信息 - $payInfo = []; - } else { - $payInfo = $this->pay_info; - } - return $payInfo ?: null; - } -} diff --git a/app/Models/DealerOrderAllocateLog.php b/app/Models/DealerOrderAllocateLog.php deleted file mode 100644 index 45f72ee1..00000000 --- a/app/Models/DealerOrderAllocateLog.php +++ /dev/null @@ -1,19 +0,0 @@ -hasMany(DealerProductManageRule::class, 'product_id', 'product_id'); - } -} diff --git a/app/Models/DealerOrderRefuseLog.php b/app/Models/DealerOrderRefuseLog.php deleted file mode 100644 index 6a475d69..00000000 --- a/app/Models/DealerOrderRefuseLog.php +++ /dev/null @@ -1,16 +0,0 @@ - JsonArray::class, - 'is_sale' => 'bool', - ]; - - public function scopeOnline($query) - { - return $query->where('is_sale', true); - } - - public function lvlRules() - { - return $this->hasMany(DealerProductLvlRule::class, 'product_id'); - } - - public function saleRules() - { - return $this->hasMany(DealerProductSaleRule::class, 'product_id')->orderBy('qty', 'desc'); - } - - public function manageRules() - { - return $this->hasMany(DealerProductManageRule::class, 'product_id'); - } - - public function isOnline() - { - return $this->is_sale; - } -} diff --git a/app/Models/DealerProductLvlRule.php b/app/Models/DealerProductLvlRule.php deleted file mode 100644 index 450f62ef..00000000 --- a/app/Models/DealerProductLvlRule.php +++ /dev/null @@ -1,15 +0,0 @@ - DealerLvl::class, - 'order_completed_at' => 'datetime', - ]; - - protected $fillable = [ - 'user_id', - 'lvl', - 'order_id', - 'total_amount', - 'path', - 'remark', - 'order_completed_at', - ]; - - public function user() - { - return $this->belongsTo(User::class, 'user_id'); - } - - public function order() - { - return $this->belongsTo(DealerOrder::class, 'order_id'); - } -} diff --git a/app/Models/DealerPurchaseSubsidy.php b/app/Models/DealerPurchaseSubsidy.php deleted file mode 100644 index bf0b3089..00000000 --- a/app/Models/DealerPurchaseSubsidy.php +++ /dev/null @@ -1,88 +0,0 @@ - DealerLvl::None, - 'settle_state' => DealerPurchaseSubsidySettleState::Pending, - 'status' => DealerPurchaseSubsidyStatus::Pending, - ]; - - protected $casts = [ - 'lvl' => DealerLvl::class, - 'start_at' => 'datetime', - 'end_at' => 'datetime', - 'settle_state' => DealerPurchaseSubsidySettleState::class, - 'status' => DealerPurchaseSubsidyStatus::class, - ]; - - protected $fillable = [ - 'user_id', - 'payer_id', - 'lvl', - 'total_purchase_amount', - 'subsidy_rate', - 'total_subsidy', - 'total_amount', - 'real_amount', - 'fee', - 'fee_rate', - 'start_at', - 'end_at', - 'settle_state', - 'status', - 'remark', - ]; - - /** - * 仅查询结算完成的进货补贴 - */ - public function scopeSettleCompleted($query) - { - return $query->where('settle_state', DealerPurchaseSubsidySettleState::Completed); - } - - public function user() - { - return $this->belongsTo(User::class, 'user_id'); - } - - public function dealer() - { - return $this->belongsTo(Dealer::class, 'user_id', 'user_id'); - } - - public function logs() - { - return $this->hasMany(DealerPurchaseSubsidyLog::class, 'purchase_subsidy_id'); - } - - public function earning() - { - return $this->morphOne(DealerEarning::class, 'earningable'); - } - - /** - * 仅查询待付款的管理津贴 - * - * @return bool - */ - public function isPending(): bool - { - return $this->settle_state === DealerPurchaseSubsidySettleState::Completed - && $this->status === DealerPurchaseSubsidyStatus::Pending; - } - - public function isCompleted() - { - return $this->settle_state === DealerPurchaseSubsidySettleState::Completed - && $this->status === DealerPurchaseSubsidyStatus::Completed; - } -} diff --git a/app/Models/DealerPurchaseSubsidyLog.php b/app/Models/DealerPurchaseSubsidyLog.php deleted file mode 100644 index 0dd60ca1..00000000 --- a/app/Models/DealerPurchaseSubsidyLog.php +++ /dev/null @@ -1,18 +0,0 @@ - DealerSalesValueLogType::Personal, - ]; - - protected $casts = [ - 'type' => DealerSalesValueLogType::class, - ]; - - protected $fillable = [ - 'user_id', - 'loggable_type', - 'loggable_id', - 'type', - 'change_sales_value', - 'remark', - ]; -} diff --git a/app/Models/DealerShoppingCartItem.php b/app/Models/DealerShoppingCartItem.php deleted file mode 100644 index 49c2d434..00000000 --- a/app/Models/DealerShoppingCartItem.php +++ /dev/null @@ -1,25 +0,0 @@ -belongsTo(DealerProduct::class, 'product_id'); - } -} diff --git a/app/Models/DealerUpgradeLog.php b/app/Models/DealerUpgradeLog.php deleted file mode 100644 index 56ef885c..00000000 --- a/app/Models/DealerUpgradeLog.php +++ /dev/null @@ -1,21 +0,0 @@ - DealerLvl::class, - 'change_lvl' => DealerLvl::class, - ]; - - protected $fillable = [ - 'user_id', - 'before_lvl', - 'change_lvl', - 'remark', - ]; -} diff --git a/app/Models/DealerUserProduct.php b/app/Models/DealerUserProduct.php deleted file mode 100644 index b7cb17b5..00000000 --- a/app/Models/DealerUserProduct.php +++ /dev/null @@ -1,30 +0,0 @@ - 0, - 'deposit_stock' => 0, - ]; - - protected $fillable = [ - 'user_id', - 'product_id', - 'stock', - 'deposit_stock', - ]; - - public function product() - { - return $this->belongsTo(DealerProduct::class, 'product_id'); - } -} diff --git a/app/Models/DealerUserProductLog.php b/app/Models/DealerUserProductLog.php deleted file mode 100644 index 4b869ad0..00000000 --- a/app/Models/DealerUserProductLog.php +++ /dev/null @@ -1,71 +0,0 @@ - false, - ]; - - protected $casts = [ - 'is_deposit' => 'bool', - ]; - - protected $fillable = [ - 'user_id', - 'product_id', - 'type', - 'qty', - 'remark', - 'revoke_id', - 'is_deposit', - ]; - - public function product() - { - return $this->belongsTo(DealerProduct::class, 'product_id'); - } - - public function canRevoke() - { - return ($this->type == static::TYPE_OFFLINE_OUT) && ($this->revoke_id == 0); - } - - public function getQtyFormatAttribute() - { - $symbok = in_array($this->type, [ - DealerUserProductLog::TYPE_ORDER_IN, - DealerUserProductLog::TYPE_ADMIN_IN, - DealerUserProductLog::TYPE_REVOKE_IN, - DealerUserProductLog::TYPE_TRANSFER_IN, - DealerUserProductLog::TYPE_DEPOSIT_TRANSFER_REVOKE, - DealerUserProductLog::TYPE_ORDER_OUT_REVOKE, - ]) ? '+' : '-'; - - return $symbok . $this->attributes['qty']; - } -} diff --git a/app/Models/DealerWallet.php b/app/Models/DealerWallet.php deleted file mode 100644 index a8baf0d8..00000000 --- a/app/Models/DealerWallet.php +++ /dev/null @@ -1,36 +0,0 @@ - 0, - 'total_revenue' => 0, - 'total_expenses' => 0, - 'withdrawable' => true, - ]; - - /** - * @var array - */ - protected $casts = [ - 'withdrawable' => 'bool', - ]; - - /** - * @var array - */ - protected $fillable = [ - 'user_id', - 'balance', - 'total_expenses', - 'total_revenue', - 'withdrawable', - ]; -} diff --git a/app/Models/DealerWalletLog.php b/app/Models/DealerWalletLog.php deleted file mode 100644 index 8dfafef9..00000000 --- a/app/Models/DealerWalletLog.php +++ /dev/null @@ -1,49 +0,0 @@ - DealerWalletAction::class, - ]; - - /** - * @var array - */ - protected $fillable = [ - 'user_id', - 'loggable_id', - 'loggable_type', - 'action', - 'before_balance', - 'change_balance', - 'remarks', - ]; - - /** - * 此余额日志关联的用户 - */ - public function user() - { - return $this->belongsTo(User::class); - } - - public function scopeOnlyTransfer($query) - { - return $query->whereIn('action', [ - DealerWalletAction::TransferIn, - DealerWalletAction::TransferOut, - ]); - } -} diff --git a/app/Models/DealerWalletToBankLog.php b/app/Models/DealerWalletToBankLog.php deleted file mode 100644 index 5b434676..00000000 --- a/app/Models/DealerWalletToBankLog.php +++ /dev/null @@ -1,97 +0,0 @@ - DealerWalletToBankLogPayWay::Offline, - 'status' => DealerWalletToBankLogStatus::Pending, - ]; - - protected $casts = [ - 'pay_info' => JsonArray::class, - 'pay_at' => 'datetime', - 'pay_way' => DealerWalletToBankLogPayWay::class, - 'status' => DealerWalletToBankLogStatus::class, - ]; - - /** - * @var array - */ - protected $fillable = [ - 'user_id', - 'amount', - 'status', - 'remarks', - 'rate', - 'service_amount', - 'account_amount', - 'pay_info', - 'pay_image', - 'pay_sn', - 'pay_way', - 'pay_at', - 'failed_reason', - 'manager_id', - ]; - - /** - * 提现记录所属用户 - * - */ - public function user() - { - return $this->belongsTo(User::class); - } - - public function dealer() - { - return $this->belongsTo(Dealer::class, 'user_id', 'user_id'); - } - - public function manager() - { - return $this->belongsTo(Dealer::class, 'manager_id', 'user_id'); - } - - /** - * 待打款状态 - * - * @return boolean - */ - public function isPending() - { - return $this->status === DealerWalletToBankLogStatus::Pending; - } - - public function isFailed() - { - return $this->status === DealerWalletToBankLogStatus::Failed; - } - - /** - * 获取用户的打款信息 - * - * @return void - */ - public function getPayInfo() - { - if ($this->isPending() || $this->isFailed()) {//待打款订单显示发货人收款信息 - $payInfo = $this->user->dealer->pay_info; - } else { - $payInfo = $this->pay_info; - } - return $payInfo ?: null; - } -} diff --git a/app/Models/User.php b/app/Models/User.php index 9b92f2eb..0495215b 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -2,7 +2,6 @@ namespace App\Models; -use App\Exceptions\BizException; use Dcat\Admin\Traits\HasDateTimeFormatter; use Illuminate\Auth\Authenticatable; use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract; @@ -72,10 +71,6 @@ class User extends Model implements AuthorizableContract, AuthenticatableContrac $user->wallet()->create(); //初始化余额 $user->balance()->create(); - //初始化经销商信息 - $user->dealer()->create(); - //初始化经销商余额 - $user->dealerWallet()->create(); }); } @@ -105,15 +100,6 @@ class User extends Model implements AuthorizableContract, AuthenticatableContrac return $this->hasMany(ShoppingCartItem::class); } - /** - * 属于此用户的批零购物车商品 - * - */ - public function dealerShoppingCartItems() - { - return $this->hasMany(DealerShoppingCartItem::class); - } - /** * 属于此用户的收货地址 */ @@ -154,86 +140,6 @@ class User extends Model implements AuthorizableContract, AuthenticatableContrac return $this->hasOne(UserCid::class, 'user_id'); } - /** - * 属于此用户得经销商身份 - * - * @return void - */ - public function dealer() - { - return $this->hasOne(Dealer::class, 'user_id'); - } - - /** - * 属于此用户得经销商余额 - */ - public function dealerWallet() - { - return $this->hasOne(DealerWallet::class, 'user_id'); - } - - /** - * 属于此用户得经销商余额日志 - */ - public function dealerWalletLogs() - { - return $this->hasMany(DealerWalletLog::class, 'user_id'); - } - - /** - * - * 属于此用户的经销商余额提现日志 - */ - public function dealerWalletToBankLogs() - { - return $this->hasMany(DealerWalletToBankLog::class, 'user_id'); - } - - /** - * 经销商订购订单 - * - */ - public function dealerOrders() - { - return $this->hasMany(DealerOrder::class, 'user_id'); - } - - /** - * 经销商提货单 - * - */ - public function dealerDeliveryBills() - { - return $this->hasMany(DealerDeliveryBill::class, 'user_id'); - } - - /** - * 经销商的发货订单 - * - */ - public function dealerConsignOrders() - { - return $this->hasMany(DealerOrder::class, 'consignor_id'); - } - - /** - * 经销商商品库存 - * - */ - public function dealerProducts() - { - return $this->hasMany(DealerUserProduct::class, 'user_id'); - } - - /** - * 经销商商品库存 - * - */ - public function dealerProductLogs() - { - return $this->hasMany(DealerUserProductLog::class, 'user_id'); - } - public function socialites() { return $this->hasMany(SocialiteUser::class, 'user_id'); @@ -253,31 +159,6 @@ class User extends Model implements AuthorizableContract, AuthenticatableContrac return $this->userInfo?->growth_value >= config('agent.upgrade_rules.vip.sales_value'); } - /** - * 确认这个用户是否是经销商 - * - * @return boolean - */ - public function isDealer(): bool - { - return $this->dealer ? true : false; - } - - /** - * 用户收益记录 - * - * @return void - */ - public function dealerEarnings() - { - return $this->hasMany(DealerEarning::class, 'user_id'); - } - - public function dealerPayEarnings() - { - return $this->hasMany(DealerEarning::class, 'payer_id'); - } - /** * 属于此用户的售后订单 */ diff --git a/app/Models/UserInfo.php b/app/Models/UserInfo.php index 7e443486..0e232375 100644 --- a/app/Models/UserInfo.php +++ b/app/Models/UserInfo.php @@ -197,14 +197,6 @@ class UserInfo extends Model return $this->hasMany(AgentUpgradeLog::class, 'user_id', 'user_id'); } - /** - * 属于此用户的经销商信息 - */ - public function dealer() - { - return $this->hasOne(Dealer::class, 'user_id', 'user_id'); - } - /** * 获取此用户的直推店铺总数 */ diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index e7d0002d..683294d3 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -22,8 +22,7 @@ class AppServiceProvider extends ServiceProvider * @var array */ public $singletons = [ - \App\Actions\Dealer\CalculatePurchaseAmount::class => \App\Actions\Dealer\CalculatePurchaseAmount::class, - \App\Actions\Dealer\CalculatePurchaseAmountOfCurrentPeriod::class => \App\Actions\Dealer\CalculatePurchaseAmountOfCurrentPeriod::class, + // ]; /** @@ -58,15 +57,6 @@ class AppServiceProvider extends ServiceProvider 'distribution_pre_income' => \App\Models\DistributionPreIncome::class, 'admin_users' => \App\Models\Admin\Administrator::class, 'quota_v1_send_logs' => \App\Models\QuotaV1SendLog::class, - 'dealer_order' => \App\Models\DealerOrder::class, - 'dealer_manager_subsidy' => \App\Models\DealerManagerSubsidy::class, - 'dealer_manage_subsidy' => \App\Models\DealerManageSubsidy::class, - 'dealer_channel_subsidy_log' => \App\Models\DealerChannelSubsidyLog::class, - 'dealer_purchase_subsidy' => \App\Models\DealerPurchaseSubsidy::class, - 'dealer_wallet_to_bank_log' => \App\Models\DealerWalletToBankLog::class, - 'dealer_earnings'=> \App\Models\DealerEarning::class, - 'dealer_wallet_log'=> \App\Models\DealerWalletLog::class, - 'dealer_delivery_bill'=> \App\Models\DealerDeliveryBill::class, ]); JsonResource::withoutWrapping(); diff --git a/app/Services/Dealer/DealerDeliveryBillService.php b/app/Services/Dealer/DealerDeliveryBillService.php deleted file mode 100644 index dca2a9dc..00000000 --- a/app/Services/Dealer/DealerDeliveryBillService.php +++ /dev/null @@ -1,259 +0,0 @@ -count()) { - throw new BizException('提货单商品已丢失'); - } - - // 经销商的商品库存 - $dealerProducts = $user->dealerProducts() - ->whereIn('product_id', $deliveryProductIds) - ->get(); - - // 创建提货单 - $deliveryBill = DealerDeliveryBill::create([ - 'user_id' => $user->id, - 'shipping_fee' => app_settings('dealer.delivery_bill_shipping_fee', 0), - 'remark' => $remark, - 'consignee_name' => $consignee['name'], - 'consignee_telephone' => $consignee['telephone'], - 'consignee_zone' => $consignee['zone'], - 'consignee_address' => $consignee['address'], - 'status' => DealerDeliveryBillStatus::Pending, - 'order_id' => $dealerOrder?->id, - ]); - - $mapProducts = $products->keyBy('id'); - $mapDealerProducts = $dealerProducts->keyBy('product_id'); - - $dealerProductLogs = []; - $deliveryBillProducts = []; - - foreach ($deliveryProducts as $deliveryProduct) { - $product = Arr::get($mapProducts, $deliveryProduct['id']); - $dealerProduct = Arr::get($mapDealerProducts, $product->id); - - if ($dealerProduct?->deposit_stock < $deliveryProduct['qty']) { - throw new BizException("{$product->name} 库存不足"); - } - - $dealerProduct->decrement('deposit_stock', $deliveryProduct['qty']); - - $dealerProductLogs[] = [ - 'user_id' => $dealerProduct->user_id, - 'product_id' => $dealerProduct->product_id, - 'type' => DealerUserProductLog::TYPE_DEPOSIT_TRANSFER_OUT, - 'qty' => $deliveryProduct['qty'], - 'remark' => "提货单【{$deliveryBill->sn}】", - 'is_deposit' => true, - 'created_at' => $deliveryBill->created_at, - 'updated_at' => $deliveryBill->updated_at, - ]; - - $deliveryBillProducts[] = [ - 'delivery_bill_id' => $deliveryBill->id, - 'product_id' => $product->id, - 'qty' => $deliveryProduct['qty'], - 'created_at' => $deliveryBill->created_at, - 'updated_at' => $deliveryBill->updated_at, - ]; - } - - DealerUserProductLog::insert($dealerProductLogs); - - DealerDeliveryProduct::insert($deliveryBillProducts); - - return $deliveryBill; - } - - /** - * 提货单付款 - * - * @param \App\Models\DealerDeliveryBill $deliveryBill - * @param \App\Enums\PayWay $payWay - * @return array - * - * @throws \App\Exceptions\BizException - */ - public function pay(DealerDeliveryBill $deliveryBill, PayWay $payWay): array - { - if (! $deliveryBill->isPending()) { - throw new BizException('提货单状态不是待付款'); - } - - $method = match ($payWay) { - PayWay::Wallet => 'payUsingWallet', - PayWay::WxpayH5, PayWay::WxpayJsApi => 'payUsingWxpay', - default => 'payUsingDefault', - }; - - if (! method_exists($this, $method)) { - throw new BizException('交易非法'); - } - - $payLog = $deliveryBill->payLogs()->create([ - 'pay_way' => $payWay, - ]); - - return [ - 'pay_way' => $payLog->pay_way, - 'data' => $this->{$method}($deliveryBill, $payLog), - ]; - } - - /** - * 取消提货单 - * - * @param DealerDeliveryBill $deliveryBill - * @return void - */ - public function cancel(DealerDeliveryBill $deliveryBill) - { - if (! $deliveryBill->isPending()) { - throw new BizException('提货单状态不是待付款'); - } - - $deliveryBill->update([ - 'status' => DealerDeliveryBillStatus::Cancelled, - ]); - - $dealerProductLogs = []; - - foreach ($deliveryBill->deliveryProducts as $deliveryProduct) { - DealerUserProduct::where([ - 'user_id' => $deliveryBill->user_id, - 'product_id' => $deliveryProduct->product_id, - ])->update([ - 'deposit_stock' => DB::raw("deposit_stock + {$deliveryProduct->qty}"), - ]); - - $dealerProductLogs[] = [ - 'user_id' => $deliveryBill->user_id, - 'product_id' => $deliveryProduct->product_id, - 'type' => DealerUserProductLog::TYPE_DEPOSIT_TRANSFER_REVOKE, - 'qty' => $deliveryProduct->qty, - 'remark' => "撤销提货单【{$deliveryBill->sn}】", - 'is_deposit' => true, - 'created_at' => $deliveryBill->updated_at, - 'updated_at' => $deliveryBill->updated_at, - ]; - } - - //撤回已发货的本地库存 - if ($deliveryBill->order_id) { - $dealerOrder = DealerOrder::with('products')->find($deliveryBill->order_id); - foreach ($dealerOrder->products as $product) { - if ($product->qty > 0 && $dealerOrder->local_status == 1) { - $userProduct = $dealerOrder->consignor->dealerProducts()->firstOrCreate([ - 'product_id'=> $product->product_id, - ]); - $userProduct->increment('stock', $product->qty); - $dealerProductLogs[] = [ - 'user_id' => $dealerOrder->consignor_id, - 'product_id' => $product->product_id, - 'type' => DealerUserProductLog::TYPE_ORDER_OUT_REVOKE, - 'qty' => $product->qty, - 'remark' => "撤销订单发货【{$dealerOrder->sn}】", - 'is_deposit' => false, - 'created_at' => $deliveryBill->updated_at, - 'updated_at' => $deliveryBill->updated_at, - ]; - } - //将云仓发货的数量挪回来 - DealerOrderProduct::where('id', $product->id)->update([ - 'qty' => $product->qty + $product->deposit_qty, - 'deposit_qty' => 0, - ]); - } - $dealerOrder->update([ - 'local_status'=>0, - ]); - } - - DealerUserProductLog::insert($dealerProductLogs); - } - - /** - * 使用余额支付 - * - * @param \App\Models\DealerDeliveryBill $deliveryBill - * @param \App\Models\PayLog $payLog - * @return void - */ - protected function payUsingWallet(DealerDeliveryBill $deliveryBill, PayLog $payLog) - { - (new WalletService())->changeBalance( - $deliveryBill->user, - bcmul($deliveryBill->shipping_fee, '-1', 2), - DealerWalletAction::DeliveryBillPaid, - "提货单号:{$deliveryBill->sn}", - $deliveryBill - ); - - (new PayService())->handleSuccess($payLog, [ - 'pay_at' => now(), - ]); - } - - /** - * 使用微信支付 - * - * @param \App\Models\DealerDeliveryBill $deliveryBill - * @param \App\Models\PayLog $payLog - * @return array - */ - protected function payUsingWxpay(DealerDeliveryBill $deliveryBill, PayLog $payLog): array - { - if (is_null($tradeType = WxpayTradeType::tryFromPayWay($payLog->pay_way))) { - throw new BizException('支付方式 非法'); - } - - $params = [ - 'body' => app_settings('app.app_name').'-批零订单', - 'out_trade_no' => $payLog->pay_sn, - 'total_fee' => bcmul($deliveryBill->shipping_fee, '100'), - 'trade_type' => $tradeType->value, - ]; - - return (new WxpayService())->pay($params, 'yzk_h5'); - } -} diff --git a/app/Services/Dealer/OrderService.php b/app/Services/Dealer/OrderService.php deleted file mode 100644 index 4a665c9f..00000000 --- a/app/Services/Dealer/OrderService.php +++ /dev/null @@ -1,783 +0,0 @@ -price; - if ($user->dealer) { - foreach ($product->lvlRules as $rule) { - if ($rule->lvl == $user->dealer->lvl->value) { - $salePrice = $rule->sale_price; - break; - } - } - } - //获取销售规则,判断当前用户购买数量价格 - foreach ($product->saleRules as $rule) { - if ($number >= $rule->qty) { - if ($salePrice > $rule->price) { - $salePrice = $rule->price; - } - break; - } - } - return $salePrice; - } - - /** - * 计算订单价格 - * - * @param DealerProduct $product - * @param integer $number - * @return string - */ - public function totalAmount(User $user, DealerProduct $product, int $number = 0, ?int $allNumber = null) - { - return bcmul($this->getSalePrice($user, $product, $allNumber ?? $number), $number, 2); - } - - /** - * 计算即将成为的身份 - * - * @param User $user - * @param [float] $totalAmount - * @return DealerLvl - */ - public function willBecome(User $user, $totalAmount): DealerLvl - { - $rules = [ - [ - 'amount' => app_settings('dealer.upgrade_amount_'.DealerLvl::Contracted->value), - 'lvl' => DealerLvl::Contracted, - ], - [ - 'amount' => app_settings('dealer.upgrade_amount_'.DealerLvl::Special->value), - 'lvl' => DealerLvl::Special, - ], - [ - 'amount' => app_settings('dealer.upgrade_amount_'.DealerLvl::Gold->value), - 'lvl' => DealerLvl::Gold, - ], - ]; - $lvl = $user->dealer->lvl; - //计算通过这个订单可能升级成为的身份 - foreach ($rules as $rule) { - if ($totalAmount >= $rule['amount'] && $lvl->value < $rule['lvl']->value) { - $lvl = $rule['lvl']; - } - } - return $lvl; - } - - /** - * 快捷创建订单(单个商品下单) - * - * @param User $user - * @param DealerProduct $product - * @param integer $number - * @param integer $shippingAddressId - * @return DealerOrder $order - */ - public function quickCreateOrder(User $user, DealerProduct $product, int $number = 0, int $shippingAddressId) - { - $totalAmount = $this->totalAmount($user, $product, $number); - // foreach ($product->lvlRules as $rule) { - // $min_order_amount = app_settings('min_order_amount'.$rule->lvl); - // if ($user->dealer && $rule->lvl == $user->dealer->lvl->value && $totalAmount < $min_order_amount) { - // throw new BizException('当前单次补货价格不能低于'.$min_order_amount.'元'); - // } - // } - - $order = $this->createOrder($user, $totalAmount, $shippingAddressId); - - //保存订单商品-----一个订单对应一个商品 - $order->products()->create([ - 'order_id' => $order->id, - 'product_id'=> $product->id, - 'name'=> $product->name, - 'subtitle'=> $product->subtitle, - 'cover'=> $product->cover, - 'price' => $product->price, - 'sale_price'=> bcdiv($totalAmount, $number, 2), - 'qty'=> $number, - ]); - - if (!$order->consignor) {//如果订单分配给公司,则直接确认 - $this->confirmOrder($order); - } - - return $order; - } - - /** - * 购物车创建订单 - * - * @param User $user - * @param [type] $cartIds - * @param integer $shippingAddressId - * @return DealerOrder $order - */ - public function cartCreateOrder(User $user, $cartIds, int $shippingAddressId) - { - //获取购物车商品 - $shoppingCartItems = $user->dealerShoppingCartItems()->findMany($cartIds); - if ($shoppingCartItems->count() !== count($cartIds)) { - throw new BizException('购物车商品已丢失'); - } - $shoppingCartItems->load('product'); - $totalQty = $shoppingCartItems->sum('quantity'); - $totalAmount = 0; - $orderProducts = []; - foreach ($shoppingCartItems as $item) { - if (!$item->product->isOnline()) { - throw new BizException('购物车商品已失效'); - } - //计算订单价格 - $totalAmount += $this->totalAmount($user, $item->product, $item->quantity, $totalQty); - //组装订单商品 - $orderProducts[] = [ - 'product_id' => $item->product_id, - 'name'=> $item->name, - 'subtitle' => $item->product->subtitle, - 'cover' => $item->cover, - 'price' => $item->sell_price, - 'sale_price' => $this->getSalePrice($user, $item->product, $totalQty), - 'qty' => $item->quantity, - ]; - } - - $order = $this->createOrder($user, $totalAmount, $shippingAddressId); - - DealerOrderProduct::insert(array_map(function ($product) use ($order) { - return array_merge($product, [ - 'order_id'=>$order->id, - 'created_at'=> $order->created_at, - 'updated_at'=> $order->updated_at, - ]); - }, $orderProducts)); - - //清除购物车对应商品 - $user->dealerShoppingCartItems()->whereIn('id', $cartIds)->delete(); - - if (!$order->consignor) {//如果订单分配给公司,则直接确认 - $this->confirmOrder($order); - } - - return $order; - } - - /** - * 创建订单 - * - * @param User $user - * @param [type] $totalAmount - * @param integer $shippingAddressId - * @return DealerOrder $order - */ - protected function createOrder(User $user, $totalAmount, int $shippingAddressId) - { - //判断是否满足当前等级最低补货价 - $min_order_amount = app_settings('dealer.min_order_amount_'.$user->dealer?->lvl->value, 0); - if ($user->dealer && $totalAmount < $min_order_amount) { - throw new BizException('当前单次补货价格不能低于'.$min_order_amount.'元'); - } - //找到发货人 - $consignor = $this->getConsignor($user, $totalAmount); - - //找到收货地址 - $shippingAddress = $this->getShippingAddress($user, $shippingAddressId); - - //保存订单 - $order = new DealerOrder(); - do { - try { - $order->sn = serial_number(); - $order->user_id = $user->id; - $order->consignor_id = $consignor?->user_id; - $order->total_amount = $totalAmount; - $order->consignee_name = $shippingAddress->consignee; - $order->consignee_telephone = $shippingAddress->telephone; - $order->consignee_zone = $shippingAddress->zone; - $order->consignee_address = $shippingAddress->address; - $order->allocated_at = now();//记录分配时间 - $order->save(); - break; - } catch (QueryException $e) { - if (strpos($e->getMessage(), 'Duplicate entry') === false) { - throw $e; - } - } - } while (true); - - return $order; - } - - /** - * 确认接单 - * - * @param DealerOrder $order - * @return DealerOrder $order - */ - public function confirmOrder(DealerOrder $order) - { - if (!$order->isPending()) { - throw new BizException('无法接单:订单状态异常,请刷新后再试'); - } - $order->update([ - 'status' => DealerOrderStatus::Paying, - ]); - return $order; - } - - /** - * 确认打款 - * - * @return DealerOrder $order - */ - public function payOrder(DealerOrder $order, string $payWay, ?string $payImage = null) - { - if (empty($payWay)) { - throw new BizException('请选择付款方式'); - } - if (!$order->isPendinged()) { - throw new BizException('无法付款:订单状态异常,请刷新后再试'); - } - switch ($payWay) { - case PayWay::Wallet->value: - /** 付款以及完成确认收款动作 **/ - $walletService = new WalletService(); - //付款 - $walletService->changeBalance($order->user, 0 - $order->total_amount, DealerWalletAction::OrderPaid, '订单:'.$order->sn, $order); - $order->update([ - 'status'=>DealerOrderStatus::Confirming, - 'pay_time' => now(), - 'pay_way' => PayWay::Wallet, - ]); - //收款 - if ($order->consignor) { - $walletService->changeBalance($order->consignor, $order->total_amount, DealerWalletAction::OrderIncome, '订单:'.$order->sn, $order); - } - $this->paidOrder($order); - break; - case PayWay::Offline->value: - $order->update([ - 'status' => DealerOrderStatus::Confirming, - 'pay_image' => $payImage, - 'pay_info' => $order->getConsignorPayInfo() ?? null, - 'pay_time' => now(), - 'pay_way' => PayWay::Offline, - ]); - break; - } - return $order; - } - - /** - * 支付订单 - * - * @param DealerOrder $order - * @param \App\Enums\PayWay $payWay - * @param string|null $payImage - * @return array - * - * @throws \App\Exceptions\BizException - */ - public function pay(DealerOrder $order, PayWay $payWay, ?string $payImage = null): array - { - if (! $order->isPendinged()) { - throw new BizException('订单状态不是待付款'); - } - - $payLog = $order->payLogs()->create([ - 'pay_way' => $payWay, - ]); - - $data = [ - 'pay_sn' => $payLog->pay_sn, - ]; - - switch ($payLog->pay_way) { - case PayWay::Offline: - (new PayService())->handleSuccess($payLog, [ - 'pay_image' => $payImage, - 'pay_info' => $order->getConsignorPayInfo() ?? null, - 'pay_at' => now(), - ]); - - $data = null; - - break; - - case PayWay::Wallet: - $walletService = new WalletService(); - - // 扣除打款人余额 - $walletService->changeBalance( - $order->user, - bcmul($order->total_amount, '-1', 2), - DealerWalletAction::OrderPaid, - "订单:{$order->sn}", - $order - ); - - // 增加收款人余额 - if ($order->consignor) { - $walletService->changeBalance( - $order->consignor, - $order->total_amount, - DealerWalletAction::OrderIncome, - "订单:{$order->sn}", - $order - ); - } - - (new PayService())->handleSuccess($payLog, [ - 'pay_at' => now(), - ]); - - $data = null; - - break; - - case PayWay::WxpayH5: - case PayWay::WxpayJsApi: - if (is_null($tradeType = WxpayTradeType::tryFromPayWay($payLog->pay_way))) { - throw new BizException('支付方式 非法'); - } - - $params = [ - 'body' => app_settings('app.app_name').'-批零订单', - 'out_trade_no' => $payLog->pay_sn, - 'total_fee' => bcmul($order->total_amount, '100'), - 'trade_type' => $tradeType->value, - ]; - - $data = (new WxpayService())->pay($params, 'yzk_h5'); - - break; - - default: - throw new BizException('支付方式不支持'); - break; - } - - return [ - 'pay_way' => $payLog->pay_way, - 'data' => $data, - ]; - } - - /** - * 确认收款 - * - * @param DealerOrder $order - * @return DealerOrder $order - */ - public function paidOrder(DealerOrder $order) - { - if (!$order->isPay()) { - throw new BizException('无法收款:订单状态异常,请刷新后再试'); - } - $order->update([ - 'status' => DealerOrderStatus::Paid, - 'paied_time' => now(), - ]); - //签约单,云库存直接发货 - if ($order->consignor === null) { - $this->orderInDepositstock($order); - } - return $order; - } - - /** - * 确认发货 - * - * @param DealerOrder $order - * @param string $action - * @return DealerOrder $order - */ - public function shippingOrder(DealerOrder $order, ?string $action = 'qty') - { - if (!$order->isPaid()) { - throw new BizException('无法发货:订单状态异常,请刷新后再试'); - } - //扣减发货人库存 - if ($order->consignor) { - if ($action == 'deposit_qty') { - $this->orderOutDepositQty($order); - } else { - $this->orderOutQty($order); - } - } - - $order->update([ - 'status' => DealerOrderStatus::Shipped, - 'shipping_time' => now(), - ]); - return $order; - } - - /** - * 使用云仓发货 - */ - public function shippingOrderByDeposit(DealerOrder $order) - { - $depositProducts = []; - $deliveryBill = null; - //判断这个订单是否已经有待支付的云仓发货单 - if ($deliveryBill = DealerDeliveryBill::where([ - 'user_id' => $order->consignor_id, - 'order_id' => $order->id, - 'status' => DealerDeliveryBillStatus::Pending, - ])->first()) { - return $deliveryBill; - } - //判断本地库存是否足够,不足则生成云仓提货单,并唤起支付。 - foreach ($order->products as $product) { - //记录需要生成云仓发货单的商品信息以及数量 - if ($_userProduct = DealerUserProduct::where([ - 'user_id'=>$order->consignor_id, - 'product_id'=>$product->product_id, - ])->first()) { - if ($product->qty > $_userProduct->stock) { - if ($product->qty > $_userProduct->stock + $_userProduct->deposit_stock) { - throw new BizException('当前可发货库存不足'); - } - //记录 - $depositProducts[$product->id] = [ - 'id'=> $product->product_id, - 'qty'=> $product->qty - $_userProduct->stock, - ]; - } - } else { - throw new BizException('当前可发货库存不足'); - } - } - - if ($depositProducts) { - $dealerDeliveryBillService = new DealerDeliveryBillService(); - $deliveryBill = $dealerDeliveryBillService->create($order->consignor, $depositProducts, [ - 'name'=>$order->consignee_name, - 'telephone'=>$order->consignee_telephone, - 'zone'=>$order->consignee_zone, - 'address'=>$order->consignee_address, - ], '订单发货:【'.$order->sn.'】', $order); - //更新订单相关的库存发货情况 - if ($order) { - foreach ($order->products as $product) { - if (isset($depositProducts[$product->id])) { - DealerOrderProduct::where('id', $product->id)->update([ - 'qty' => $product->qty - $depositProducts[$product->id]['qty'], - 'deposit_qty' => $depositProducts[$product->id]['qty'], - ]); - } - } - } - } - return $deliveryBill; - } - - public function shippingedOrder(DealerOrder $order, ?string $action = 'qty') - { - if (!$order->isShipping()) { - throw new BizException('无法收货:订单状态异常,请刷新后再试'); - } - //增加自己的库存 - $this->orderInQty($order); - - $order->update([ - 'status' => DealerOrderStatus::Completed, - 'shippinged_time' => now(), - ]); - return $order; - } - - public function cancelOrder(DealerOrder $order) - { - if (!($order->isPending() || $order->isPendinged() || $order->isPay())) { - throw new BizException('无法取消:订单状态异常,请刷新后再试'); - } - $order->update([ - 'status' => DealerOrderStatus::Cancelled, - ]); - return $order; - } - - /** - * 更新订单发货人 - * - * @return void - */ - public function updateOrderConsignor(DealerOrder $order) - { - //只处理当前订单有发货人的情况 - if ($order->consignor) { - $consignor = $this->getConsignor($order->user, $order->total_amount, $order->consignor); - $oldConsignor = $order->consignor; - $order->update([ - 'allocated_at' => now(), - 'consignor_id' => $consignor?->user_id, - ]); - //记录分配日志 - DealerOrderAllocateLog::create([ - 'order_id'=>$order->id, - 'last_consignor_id'=>$oldConsignor->id, - 'new_consignor_id' =>$order->consignor_id, - ]); - } - return $order; - } - - /** - * 获取收货地址 - * - * @param \App\Models\User $user - * @param int|null $shippingAddressId - * @return \App\Models\ShippingAddress|null - * - * @throws \Illuminate\Database\Eloquent\ModelNotFoundException - */ - protected function getShippingAddress(User $user, ?int $shippingAddressId = null): ?ShippingAddress - { - if ($shippingAddressId) { - return $user->shippingAddresses()->findOrFail($shippingAddressId); - } - - return $user->shippingAddresses()->where('is_default', true)->first(); - } - - /** - * 用户通过下单新增库存 - * - * @return void - */ - protected function orderInQty(DealerOrder $order) - { - foreach ($order->products as $product) { - //增加本地库存 - $userProduct = $order->user->dealerProducts()->firstOrCreate([ - 'product_id'=> $product->product_id, - ]); - //如果云仓已收货 - if ($order->local_status < 2 && $order->deposit_status !== 1) { - $userProduct->increment('stock', $product->qty); - - DealerUserProductLog::create([ - 'user_id'=> $order->user_id, - 'product_id'=> $product->product_id, - 'type' => DealerUserProductLog::TYPE_ORDER_IN, - 'qty'=>$product->qty, - 'remark'=>'订单:'.$order->sn, - ]); - } else { - $userProduct->increment('stock', $product->qty + $product->deposit_qty); - - DealerUserProductLog::create([ - 'user_id'=> $order->user_id, - 'product_id'=> $product->product_id, - 'type' => DealerUserProductLog::TYPE_ORDER_IN, - 'qty'=>$product->qty + $product->deposit_qty, - 'remark'=>'订单:'.$order->sn, - ]); - } - } - $order->update([ - 'local_status' => 2, - 'deposit_status'=> 2, - ]); - } - - /** - * 用户通过订单云仓库增加本地库存 - * - * @return void - */ - protected function orderInAllQty(DealerOrder $order) - { - foreach ($order->products as $product) { - $userProduct = $order->user->dealerProducts()->firstOrCreate([ - 'product_id'=> $product->product_id, - ]); - $userProduct->increment('stock', $product->qty + $product->deposit_qty); - - DealerUserProductLog::create([ - 'user_id'=> $order->user_id, - 'product_id'=> $product->product_id, - 'type' => DealerUserProductLog::TYPE_ORDER_IN, - 'qty'=>$product->qty + $product->deposit_qty, - 'remark'=>'订单:'.$order->sn, - ]); - } - } - - /** - * 用户通过订单扣减本地库存发货 - * - * @return void - */ - public function orderOutQty(DealerOrder $order) - { - foreach ($order->products as $product) { - if ($product->qty > 0 && $order->local_status == 0) { - $userProduct = $order->consignor->dealerProducts()->firstOrCreate([ - 'product_id'=> $product->product_id, - ]); - $userProduct->decrement('stock', $product->qty); - DealerUserProductLog::create([ - 'user_id'=> $order->consignor_id, - 'product_id'=> $product->product_id, - 'type' => DealerUserProductLog::TYPE_ORDER_OUT, - 'qty'=>$product->qty, - 'remark' =>'订单:'.$order->sn, - ]); - } - } - $order->update([ - 'local_status'=>1, - ]); - } - - /** - * 用户通过订单扣减云库存发货 - * - * @return void - */ - public function orderOutDepositQty(DealerOrder $order) - { - foreach ($order->products as $product) { - if ($product->deposit_qty > 0 && $order->deposit_status == 0) { - $userProduct = $order->consignor->dealerProducts()->firstOrCreate([ - 'product_id'=> $product->product_id, - ]); - $userProduct->decrement('stock', $product->deposit_qty); - - DealerUserProductLog::create([ - 'user_id'=> $order->consignor_id, - 'product_id'=> $product->product_id, - 'type' => DealerUserProductLog::TYPE_ORDER_OUT, - 'qty'=>$product->deposit_qty, - 'remark' =>'订单:'.$order->sn, - ]); - } - } - $order->update([ - 'deposit_status'=>1, - ]); - } - - /** - * 用户通过订单获取云库存 - * - * @param DealerOrder $order - * @return void - */ - public function orderInDepositstock(DealerOrder $order) - { - foreach ($order->products as $product) { - if ($product->deposit_qty > 0 && $order->deposit_status == 0) { - $userProduct = $order->user->dealerProducts()->firstOrCreate([ - 'product_id'=> $product->product_id, - ]); - $userProduct->increment('deposit_stock', $product->deposit_qty); - - DealerUserProductLog::create([ - 'is_deposit'=>true, - 'user_id'=> $order->user_id, - 'product_id'=> $product->product_id, - 'type' => DealerUserProductLog::TYPE_ORDER_IN, - 'qty'=>$product->deposit_qty, - 'remark' =>'订单:'.$order->sn, - ]); - } - } - $order->update([ - 'deposit_status'=>2, - ]); - } - - private function getConsignor(User $user, $totalAmount, ?User $lastConsignor = null) - { - // $rules = [ - // [ - // 'amount' => app_settings('dealer.upgrade_amount_'.DealerLvl::Contracted->value), - // 'lvl' => DealerLvl::Contracted, - // ], - // [ - // 'amount' => app_settings('dealer.upgrade_amount_'.DealerLvl::Special->value), - // 'lvl' => DealerLvl::Special, - // ], - // [ - // 'amount' => app_settings('dealer.upgrade_amount_'.DealerLvl::Gold->value), - // 'lvl' => DealerLvl::Gold, - // ], - // ]; - // $lvl = $user->dealer->lvl; - // //计算通过这个订单可能升级成为的身份 - // foreach ($rules as $rule) { - // if ($totalAmount >= $rule['amount'] && $lvl->value < $rule['lvl']->value) { - // $lvl = $rule['lvl']; - // } - // } - $lvl = $this->willBecome($user, $totalAmount); - //如果是签约单,直接抛到公司后台发货 - if ($lvl->value >= DealerLvl::Contracted->value) { - return null; - } - //新逻辑 - $consignor = null; - $_lastConsignor = $lastConsignor; - do { - $query = User::with(['userInfo', 'dealer']); - if ($_lastConsignor) { - $query->where('id', $_lastConsignor->userInfo->real_inviter_id); - } else { - $query->where('id', $user->userInfo->real_inviter_id); - } - $consignor = $query->first(); - if ($consignor) {//找到老上级 - if ($consignor->dealer->is_sale == true && $consignor->dealer->lvl->value > $lvl->value) { - break; - } else { - $_lastConsignor = $consignor; - $consignor = null; - } - } else {//如果找不到人了 - $consignor = $lastConsignor; - break; - } - } while (empty($consignor)); - - return $consignor?->userInfo; - } -} diff --git a/app/Services/Dealer/WalletService.php b/app/Services/Dealer/WalletService.php deleted file mode 100644 index 88aa7ef7..00000000 --- a/app/Services/Dealer/WalletService.php +++ /dev/null @@ -1,81 +0,0 @@ -wallet($user); - - // 变更前余额 - $beforeBalance = $wallet->balance; - - if (bccomp($changeBalance, '0', 2) < 0) { - // 支出 - - $absChangeBalance = abs($changeBalance); - - if (bccomp($wallet->balance, $absChangeBalance, 2) === -1) { - throw new BizException('余额不足'); - } - - $wallet->update([ - 'balance' => bcsub($wallet->balance, $absChangeBalance, 2), - 'total_expenses' => bcadd($wallet->total_expenses, $absChangeBalance, 2), - ]); - } else { - // 收入 - - $wallet->update([ - 'balance' => bcadd($wallet->balance, $changeBalance, 2), - 'total_revenue' => bcadd($wallet->total_revenue, $changeBalance, 2), - ]); - } - - return $user->dealerWalletLogs()->create([ - 'loggable_id' => $loggable?->id, - 'loggable_type' => $loggable?->getMorphClass(), - 'before_balance' => $beforeBalance, - 'change_balance' => $changeBalance, - 'action' => $action, - 'remarks' => $remarks, - ]); - } - - /** - * @param \App\Models\User $user - * @return \App\Models\DealerWallet - */ - protected function wallet(User $user): DealerWallet - { - if ($wallet = $user->dealerWallet()->lockForUpdate()->first()) { - return $wallet; - } - - $user->dealerWallet()->create(); - - return $this->wallet($user); - } -} diff --git a/app/Services/PayService.php b/app/Services/PayService.php index 9de2c686..6a67fa3e 100644 --- a/app/Services/PayService.php +++ b/app/Services/PayService.php @@ -2,19 +2,11 @@ namespace App\Services; -use App\Enums\DealerDeliveryBillStatus; -use App\Enums\DealerOrderStatus; use App\Exceptions\BizException; use App\Exceptions\InvalidPaySerialNumberException; -use App\Models\DealerDeliveryBill; -use App\Models\DealerOrder; -use App\Models\DealerUserProduct; -use App\Models\DealerUserProductLog; use App\Models\DistributionPreIncomeJob; use App\Models\Order; use App\Models\PayLog; -use App\Services\Dealer\OrderService; -use Illuminate\Support\Facades\DB; class PayService { @@ -88,72 +80,6 @@ class PayService 'jobable_type' => $payable->getMorphClass(), 'remarks' => '支付订单', ]); - } elseif ($payable instanceof DealerOrder) { - if (! $payable->isPendinged()) { - throw new BizException('订单不是待打款'); - } - - $payable->pay_sn = $payLog->pay_sn; - $payable->pay_time = $payLog->pay_at; - $payable->out_trade_no = $payLog->out_trade_no; - $payable->pay_way = $payLog->pay_way; - - if ($payLog->isOffline()) { - $payable->pay_image = $params['pay_image'] ?? null; - $payable->pay_info = $params['pay_info'] ?? null; - $payable->status = DealerOrderStatus::Confirming; - } else { - $payable->paied_time = $payLog->pay_at; - $payable->status = DealerOrderStatus::Paid; - //签约单,云库存直接发货 - if ($payable->consignor === null) { - (new OrderService())->orderInDepositstock($payable); - } - } - - $payable->save(); - } elseif ($payable instanceof DealerDeliveryBill) { - if (! $payable->isPending()) { - throw new BizException('提货单状态不是待打款'); - } - - $payable->pay_sn = $payLog->pay_sn; - $payable->pay_at = $payLog->pay_at; - $payable->out_trade_no = $payLog->out_trade_no; - $payable->pay_way = $payLog->pay_way; - $payable->status = DealerDeliveryBillStatus::Paid; - $payable->save(); - - // 将云仓库存变更为本地库存 - $dealerProductLogs = []; - - foreach ($payable->deliveryProducts as $deliveryProduct) { - DealerUserProduct::where([ - 'user_id' => $payable->user_id, - 'product_id' => $deliveryProduct->product_id, - ])->update([ - 'stock' => DB::raw("stock + {$deliveryProduct->qty}"), - ]); - - $dealerProductLogs[] = [ - 'user_id' => $payable->user_id, - 'product_id' => $deliveryProduct->product_id, - 'type' => DealerUserProductLog::TYPE_TRANSFER_IN, - 'qty' => $deliveryProduct->qty, - 'remark' => "云库存转本地库存,提货单【{$payable->sn}】", - 'is_deposit' => false, - 'created_at' => $payable->updated_at, - 'updated_at' => $payable->updated_at, - ]; - } - - DealerUserProductLog::insert($dealerProductLogs); - - //如果云仓库提货单存在关联订单,则该订单直接处理云仓部分的发货 - if ($payable->order_id) { - $dealerOrder = DealerOrder::find($payable->order_id); - (new OrderService())->shippingOrder($dealerOrder, 'deposit_qty'); - } } return $payLog; diff --git a/database/migrations/2022_01_12_151731_create_dealers_table.php b/database/migrations/2022_01_12_151731_create_dealers_table.php deleted file mode 100644 index a4c66959..00000000 --- a/database/migrations/2022_01_12_151731_create_dealers_table.php +++ /dev/null @@ -1,35 +0,0 @@ -id(); - $table->unsignedBigInteger('user_id')->unique()->comment('用户ID'); - $table->tinyInteger('lvl')->default(0)->comment('经销商等级'); - $table->boolean('is_sale')->default(false)->comment('是否可销售'); - $table->boolean('is_manager')->default(false)->comment('是否是管理者'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealers'); - } -} diff --git a/database/migrations/2022_01_12_165443_create_dealer_products_table.php b/database/migrations/2022_01_12_165443_create_dealer_products_table.php deleted file mode 100644 index 644abe0b..00000000 --- a/database/migrations/2022_01_12_165443_create_dealer_products_table.php +++ /dev/null @@ -1,40 +0,0 @@ -id(); - $table->string('name')->comment('商品名称'); - $table->string('subtitle')->nullable()->comment('商品副标题'); - $table->string('cover')->nullable()->comment('封面图'); - $table->json('images')->nullable()->comment('商品图片'); - $table->text('description')->nullable()->comment('商品详情'); - $table->unsignedDecimal('price', 10, 2)->default(0.00)->comment('销售价格:元'); - $table->integer('stock')->unsigned()->default(0)->comment('库存'); - $table->integer('sales_count')->unsigned()->default(0)->comment('销量'); - $table->unsignedTinyInteger('is_sale')->default(0)->comment('是否在售'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_products'); - } -} diff --git a/database/migrations/2022_01_12_165458_create_dealer_orders_table.php b/database/migrations/2022_01_12_165458_create_dealer_orders_table.php deleted file mode 100644 index d756ba95..00000000 --- a/database/migrations/2022_01_12_165458_create_dealer_orders_table.php +++ /dev/null @@ -1,51 +0,0 @@ -id(); - $table->string('sn')->comment('订单编号'); - $table->unsignedBigInteger('user_id')->comment('下单用户'); - $table->unsignedBigInteger('consignor_id')->nullable()->comment('发货用户'); - $table->unsignedDecimal('total_amount', 10, 2)->default(0.00)->comment('订单价格'); - $table->unsignedTinyInteger('status')->default(0)->comment('状态:0待接单,1待打款,2待收款,3待发货,4待收货,9已完成,10已取消'); - $table->unsignedTinyInteger('settle_state')->default(0)->comment('结算状态:0待处理,1已生成,2已结算'); - $table->string('consignee_name')->nullable()->comment('收货人姓名'); - $table->string('consignee_telephone')->nullable()->comment('收货人联系方式'); - $table->string('consignee_zone')->nullable()->comment('收货人所在地区'); - $table->string('consignee_address')->nullable()->comment('收货人详细地址'); - $table->text('pay_info')->nullable()->comment('收款信息;用户确认打款时存入'); - $table->string('pay_image')->nullable()->comment('打款凭证'); - $table->timestamp('pay_time')->nullable()->comment('支付时间'); - $table->timestamp('paied_time')->nullable()->comment('确认收款时间'); - $table->timestamp('shipping_time')->nullable()->comment('发货时间'); - $table->timestamp('shippinged_time')->nullable()->comment('确认收货时间'); - $table->timestamps(); - - $table->unique('sn'); - $table->index(['user_id', 'status']); - $table->index('status'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_orders'); - } -} diff --git a/database/migrations/2022_01_12_165509_create_dealer_order_products_table.php b/database/migrations/2022_01_12_165509_create_dealer_order_products_table.php deleted file mode 100644 index d88824ab..00000000 --- a/database/migrations/2022_01_12_165509_create_dealer_order_products_table.php +++ /dev/null @@ -1,39 +0,0 @@ -id(); - $table->unsignedBigInteger('order_id')->comment('订单ID'); - $table->unsignedBigInteger('product_id')->comment('商品ID'); - $table->string('name')->comment('商品名称'); - $table->string('subtitle')->nullable()->comment('商品副标题'); - $table->string('cover')->nullable()->comment('封面图'); - $table->unsignedDecimal('price', 10, 2)->default(0.00)->comment('销售价格:元'); - $table->unsignedDecimal('sale_price', 10, 2)->default(0.00)->comment('成交价格:元'); - $table->integer('qty')->unsigned()->default(0)->comment('数量'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_order_products'); - } -} diff --git a/database/migrations/2022_01_12_165719_create_dealer_product_lvl_rules_table.php b/database/migrations/2022_01_12_165719_create_dealer_product_lvl_rules_table.php deleted file mode 100644 index 5691a9d5..00000000 --- a/database/migrations/2022_01_12_165719_create_dealer_product_lvl_rules_table.php +++ /dev/null @@ -1,35 +0,0 @@ -id(); - $table->unsignedBigInteger('product_id')->default(0)->comment('商品ID'); - $table->unsignedDecimal('sale_price', 10, 2)->default(0.00)->comment('销售价格:元'); - $table->unsignedDecimal('min_order_amount', 10, 2)->default(0.00)->comment('最低进货价'); - $table->unsignedTinyInteger('lvl')->default(0)->comment('等级'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_product_lvl_rules'); - } -} diff --git a/database/migrations/2022_01_12_165733_create_dealer_product_sale_rules_table.php b/database/migrations/2022_01_12_165733_create_dealer_product_sale_rules_table.php deleted file mode 100644 index 78b10ac2..00000000 --- a/database/migrations/2022_01_12_165733_create_dealer_product_sale_rules_table.php +++ /dev/null @@ -1,34 +0,0 @@ -id(); - $table->unsignedBigInteger('product_id')->default(0)->comment('商品ID'); - $table->unsignedDecimal('price', 10, 2)->default(0.00)->comment('销售价格:元'); - $table->unsignedInteger('qty')->default(0)->comment('达到指定数量'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_product_sale_rules'); - } -} diff --git a/database/migrations/2022_01_12_173559_create_dealer_manager_sales_logs_table.php b/database/migrations/2022_01_12_173559_create_dealer_manager_sales_logs_table.php deleted file mode 100644 index 6797e58d..00000000 --- a/database/migrations/2022_01_12_173559_create_dealer_manager_sales_logs_table.php +++ /dev/null @@ -1,42 +0,0 @@ -id(); - $table->unsignedBigInteger('user_id')->comment('经销商的用户ID'); - $table->unsignedBigInteger('order_id')->comment('订单ID'); - $table->unsignedBigInteger('product_id')->comment('商品ID'); - $table->tinyInteger('lvl')->comment('经销商等级'); - $table->unsignedBigInteger('sales_volume')->default(0)->comment('商品销量'); - $table->timestamp('order_completed_at')->nullable()->comment('订单完成时间'); - $table->timestamps(); - - $table->unique(['user_id', 'order_id', 'product_id']); - $table->index('order_id'); - $table->index('product_id'); - $table->index('order_completed_at'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_manager_sales_logs'); - } -} diff --git a/database/migrations/2022_01_12_175842_create_dealer_user_products_table.php b/database/migrations/2022_01_12_175842_create_dealer_user_products_table.php deleted file mode 100644 index 645a397f..00000000 --- a/database/migrations/2022_01_12_175842_create_dealer_user_products_table.php +++ /dev/null @@ -1,36 +0,0 @@ -id(); - $table->unsignedBigInteger('user_id')->comment('用户ID'); - $table->unsignedBigInteger('product_id')->comment('商品ID'); - $table->unsignedInteger('stock')->default(0)->comment('库存'); - $table->timestamps(); - - $table->unique(['user_id', 'product_id']); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_user_products'); - } -} diff --git a/database/migrations/2022_01_12_190218_create_dealer_user_product_logs_table.php b/database/migrations/2022_01_12_190218_create_dealer_user_product_logs_table.php deleted file mode 100644 index cf5805ed..00000000 --- a/database/migrations/2022_01_12_190218_create_dealer_user_product_logs_table.php +++ /dev/null @@ -1,35 +0,0 @@ -id(); - $table->unsignedBigInteger('user_id')->comment('用户ID'); - $table->unsignedBigInteger('product_id')->comment('商品ID'); - $table->unsignedTinyInteger('type')->default(0)->comment('变动类型'); - $table->unsignedInteger('qty')->default(0)->comment('变动数量'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_user_product_logs'); - } -} diff --git a/database/migrations/2022_01_13_105530_add_unit_to_dealer_products_table.php b/database/migrations/2022_01_13_105530_add_unit_to_dealer_products_table.php deleted file mode 100644 index f41b58fc..00000000 --- a/database/migrations/2022_01_13_105530_add_unit_to_dealer_products_table.php +++ /dev/null @@ -1,34 +0,0 @@ -string('unit')->nullable()->comment('单位'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealer_products', function (Blueprint $table) { - // - $table->dropColumn('unit'); - }); - } -} diff --git a/database/migrations/2022_01_13_110453_create_dealer_product_manage_rules_table.php b/database/migrations/2022_01_13_110453_create_dealer_product_manage_rules_table.php deleted file mode 100644 index 3e99708a..00000000 --- a/database/migrations/2022_01_13_110453_create_dealer_product_manage_rules_table.php +++ /dev/null @@ -1,36 +0,0 @@ -id(); - $table->unsignedBigInteger('product_id')->comment('商品ID'); - $table->unsignedTinyInteger('lvl')->default(0)->comment('等级'); - $table->unsignedDecimal('price_1st', 10, 2)->default(0.00)->comment('第一个价格'); - $table->unsignedDecimal('price_2st', 10, 2)->default(0.00)->comment('第二个价格'); - $table->unsignedDecimal('price_3st', 10, 2)->default(0.00)->comment('第三个价格'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_product_manage_rules'); - } -} diff --git a/database/migrations/2022_01_13_111606_create_dealer_manage_subsidy_logs_table.php b/database/migrations/2022_01_13_111606_create_dealer_manage_subsidy_logs_table.php deleted file mode 100644 index bd8d0671..00000000 --- a/database/migrations/2022_01_13_111606_create_dealer_manage_subsidy_logs_table.php +++ /dev/null @@ -1,43 +0,0 @@ -id(); - $table->unsignedBigInteger('user_id')->comment('经销商的用户ID'); - $table->tinyInteger('lvl')->comment('经销商等级'); - $table->unsignedBigInteger('order_id')->comment('订单ID'); - $table->unsignedBigInteger('product_id')->comment('商品ID'); - $table->unsignedBigInteger('sales_volume')->default(0)->comment('商品销量'); - $table->unsignedDecimal('total_amount', 10, 2)->default(0)->comment('补贴总金额'); - $table->timestamp('order_completed_at')->nullable()->comment('订单完成时间'); - $table->timestamps(); - - $table->unique(['user_id', 'order_id', 'product_id']); - $table->index('order_id'); - $table->index('product_id'); - $table->index('order_completed_at'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_manage_subsidy_logs'); - } -} diff --git a/database/migrations/2022_01_13_202326_add_pay_info_to_dealers_table.php b/database/migrations/2022_01_13_202326_add_pay_info_to_dealers_table.php deleted file mode 100644 index cb05f3fd..00000000 --- a/database/migrations/2022_01_13_202326_add_pay_info_to_dealers_table.php +++ /dev/null @@ -1,34 +0,0 @@ -text('pay_info')->nullable()->comment('用户保留的收款信息'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealers', function (Blueprint $table) { - // - $table->dropColumn('pay_info'); - }); - } -} diff --git a/database/migrations/2022_01_14_150058_create_dealer_purchase_logs_table.php b/database/migrations/2022_01_14_150058_create_dealer_purchase_logs_table.php deleted file mode 100644 index 6c86bec9..00000000 --- a/database/migrations/2022_01_14_150058_create_dealer_purchase_logs_table.php +++ /dev/null @@ -1,42 +0,0 @@ -id(); - $table->unsignedBigInteger('user_id')->comment('经销商的用户ID'); - $table->unsignedBigInteger('order_id')->comment('订单ID'); - $table->tinyInteger('lvl')->comment('经销商等级'); - $table->unsignedDecimal('total_amount', 10, 2)->default(0)->comment('采购金额(订单金额)'); - $table->text('path')->nullable()->comment('邀请路径'); - $table->string('remark')->nullable()->comment('备注'); - $table->timestamp('order_completed_at')->nullable()->comment('订单完成时间'); - $table->timestamps(); - - $table->unique(['user_id', 'order_id']); - $table->index('order_id'); - $table->index('order_completed_at'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_purchase_logs'); - } -} diff --git a/database/migrations/2022_01_14_175143_add_manager_subsidy_to_dealer_products_table.php b/database/migrations/2022_01_14_175143_add_manager_subsidy_to_dealer_products_table.php deleted file mode 100644 index dcebf7c0..00000000 --- a/database/migrations/2022_01_14_175143_add_manager_subsidy_to_dealer_products_table.php +++ /dev/null @@ -1,34 +0,0 @@ -unsignedDecimal('manager_subsidy')->default(0.00)->comment('管理者津贴'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealer_products', function (Blueprint $table) { - // - $table->dropColumn(['manager_subsidy']); - }); - } -} diff --git a/database/migrations/2022_01_15_141159_add_remark_to_dealer_user_product_logs_table.php b/database/migrations/2022_01_15_141159_add_remark_to_dealer_user_product_logs_table.php deleted file mode 100644 index 682d3972..00000000 --- a/database/migrations/2022_01_15_141159_add_remark_to_dealer_user_product_logs_table.php +++ /dev/null @@ -1,34 +0,0 @@ -string('remark')->nullable()->comment('备注'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealer_user_product_logs', function (Blueprint $table) { - // - $table->dropColumn('remark'); - }); - } -} diff --git a/database/migrations/2022_01_16_200133_create_dealer_manager_subsidies_table.php b/database/migrations/2022_01_16_200133_create_dealer_manager_subsidies_table.php deleted file mode 100644 index 8ae9a949..00000000 --- a/database/migrations/2022_01_16_200133_create_dealer_manager_subsidies_table.php +++ /dev/null @@ -1,46 +0,0 @@ -id(); - $table->unsignedBigInteger('user_id')->comment('经销商的用户ID'); - $table->tinyInteger('lvl')->comment('经销商等级'); - $table->boolean('is_manager')->default(false)->comment('是否是管理者'); - $table->unsignedDecimal('total_amount', 10, 2)->default(0)->comment('总金额'); - $table->unsignedDecimal('real_amount', 10, 2)->default(0)->comment('实际金额=总金额-手续费'); - $table->unsignedDecimal('fee', 10, 2)->default(0)->comment('手续费'); - $table->unsignedDecimal('fee_rate', 4, 2)->default(0)->comment('手续费率(百分比)'); - $table->timestamp('start_at')->comment('结算开始时间'); - $table->timestamp('end_at')->comment('结算结束时间'); - $table->tinyInteger('status')->default(0)->comment('状态: 0 待处理'); - $table->text('remark')->nullable()->comment('备注'); - $table->timestamps(); - - $table->unique(['user_id', 'start_at', 'end_at']); - $table->index(['start_at', 'end_at']); - $table->index('status'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_manager_subsidies'); - } -} diff --git a/database/migrations/2022_01_16_200142_create_dealer_manage_subsidies_table.php b/database/migrations/2022_01_16_200142_create_dealer_manage_subsidies_table.php deleted file mode 100644 index 80df5134..00000000 --- a/database/migrations/2022_01_16_200142_create_dealer_manage_subsidies_table.php +++ /dev/null @@ -1,46 +0,0 @@ -id(); - $table->unsignedBigInteger('user_id')->comment('经销商的用户ID'); - $table->tinyInteger('lvl')->comment('经销商等级'); - $table->boolean('is_manager')->default(false)->comment('是否是管理者'); - $table->unsignedDecimal('total_amount', 10, 2)->default(0)->comment('总金额'); - $table->unsignedDecimal('real_amount', 10, 2)->default(0)->comment('实际金额=总金额-手续费'); - $table->unsignedDecimal('fee', 10, 2)->default(0)->comment('手续费'); - $table->unsignedDecimal('fee_rate', 4, 2)->default(0)->comment('手续费率(百分比)'); - $table->timestamp('start_at')->comment('结算开始时间'); - $table->timestamp('end_at')->comment('结算结束时间'); - $table->tinyInteger('status')->default(0)->comment('状态: 0 待处理'); - $table->text('remark')->nullable()->comment('备注'); - $table->timestamps(); - - $table->unique(['user_id', 'start_at', 'end_at']); - $table->index(['start_at', 'end_at']); - $table->index('status'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_manage_subsidies'); - } -} diff --git a/database/migrations/2022_01_16_200521_create_dealer_earnings_table.php b/database/migrations/2022_01_16_200521_create_dealer_earnings_table.php deleted file mode 100644 index ec25328e..00000000 --- a/database/migrations/2022_01_16_200521_create_dealer_earnings_table.php +++ /dev/null @@ -1,48 +0,0 @@ -id(); - $table->unsignedBigInteger('user_id')->comment('用户ID'); - $table->string('earningable_type')->nullable(); - $table->unsignedBigInteger('earningable_id')->nullable(); - $table->tinyInteger('lvl')->comment('经销商等级'); - $table->unsignedDecimal('total_amount', 10, 2)->default(0)->comment('总金额'); - $table->unsignedDecimal('total_earnings', 10, 2)->default(0)->comment('总收入=总金额-手续费'); - $table->unsignedDecimal('fee', 10, 2)->default(0)->comment('手续费'); - $table->unsignedDecimal('fee_rate', 4, 2)->default(0)->comment('手续费率'); - $table->unsignedBigInteger('payer_id')->nullable()->comment('付款人的用户ID'); - $table->text('pay_info')->nullable()->comment('收款信息'); - $table->timestamp('pay_at')->nullable()->comment('付款时间'); - $table->timestamp('settle_at')->nullable()->comment('结算时间'); - $table->tinyInteger('status')->default(0)->comment('状态'); - $table->text('remark')->nullable()->comment('备注'); - $table->timestamps(); - - $table->unique(['user_id', 'earningable_type', 'earningable_id']); - $table->index(['earningable_type', 'earningable_id']); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_earnings'); - } -} diff --git a/database/migrations/2022_01_17_095411_create_dealer_purchase_subsidies_table.php b/database/migrations/2022_01_17_095411_create_dealer_purchase_subsidies_table.php deleted file mode 100644 index 407e7ef6..00000000 --- a/database/migrations/2022_01_17_095411_create_dealer_purchase_subsidies_table.php +++ /dev/null @@ -1,50 +0,0 @@ -id(); - $table->unsignedBigInteger('user_id')->comment('用户ID'); - $table->unsignedBigInteger('payer_id')->nullable()->comment('付款人ID'); - $table->tinyInteger('lvl')->comment('经销商等级'); - $table->unsignedDecimal('total_purchase_amount', 10, 2)->default(0)->comment('采购总额'); - $table->unsignedDecimal('subsidy_rate', 4, 2)->default(0)->comment('补贴比例(百分比)'); - $table->unsignedDecimal('total_subsidy', 10, 2)->default(0)->comment('补贴总额=采购总额*补贴比例/100'); - $table->unsignedDecimal('total_amount', 10, 2)->default(0)->comment('应得补贴(扣除下级的补贴后的最终金额)'); - $table->unsignedDecimal('real_amount', 10, 2)->default(0)->comment('实得补贴=应得补贴-手续费'); - $table->unsignedDecimal('fee', 10, 2)->default(0)->comment('手续费=应得补贴*手续费率/100'); - $table->unsignedDecimal('fee_rate', 4, 2)->default(0)->comment('手续费率(百分比)'); - $table->timestamp('start_at')->comment('结算开始时间'); - $table->timestamp('end_at')->comment('结算结束时间'); - $table->tinyInteger('settle_state')->default(0)->comment('0=>待处理, 1=>已处理, 2=>已完成'); - $table->tinyInteger('status')->default(0)->comment('状态: 0 待处理'); - $table->string('remark')->nullable()->comment('备注'); - $table->timestamps(); - - $table->unique(['user_id', 'start_at', 'end_at']); - $table->index(['start_at', 'end_at']); - $table->index('status'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_purchase_subsidies'); - } -} diff --git a/database/migrations/2022_01_17_100317_create_dealer_purchase_subsidy_logs_table.php b/database/migrations/2022_01_17_100317_create_dealer_purchase_subsidy_logs_table.php deleted file mode 100644 index 80869592..00000000 --- a/database/migrations/2022_01_17_100317_create_dealer_purchase_subsidy_logs_table.php +++ /dev/null @@ -1,37 +0,0 @@ -id(); - $table->unsignedBigInteger('purchase_subsidy_id')->comment('采购补贴ID'); - $table->unsignedBigInteger('change_from_purchase_subsidy_id')->nullable()->comment('变更来源的'); - $table->decimal('change_amount', 10, 2)->comment('变更金额'); - $table->string('remark')->nullable()->comment('备注'); - $table->timestamps(); - - $table->index('purchase_subsidy_id'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_purchase_subsidy_logs'); - } -} diff --git a/database/migrations/2022_01_17_135120_add_is_settle_to_dealer_manage_subsidies_table.php b/database/migrations/2022_01_17_135120_add_is_settle_to_dealer_manage_subsidies_table.php deleted file mode 100644 index f6b92b41..00000000 --- a/database/migrations/2022_01_17_135120_add_is_settle_to_dealer_manage_subsidies_table.php +++ /dev/null @@ -1,32 +0,0 @@ -boolean('is_settle')->default(0)->comment('是否结算'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealer_manage_subsidies', function (Blueprint $table) { - $table->dropColumn('is_settle'); - }); - } -} diff --git a/database/migrations/2022_01_17_142233_add_is_settle_to_dealer_manager_subsidies_table.php b/database/migrations/2022_01_17_142233_add_is_settle_to_dealer_manager_subsidies_table.php deleted file mode 100644 index 386252da..00000000 --- a/database/migrations/2022_01_17_142233_add_is_settle_to_dealer_manager_subsidies_table.php +++ /dev/null @@ -1,32 +0,0 @@ -boolean('is_settle')->default(0)->comment('是否结算'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealer_manager_subsidies', function (Blueprint $table) { - $table->dropColumn('is_settle'); - }); - } -} diff --git a/database/migrations/2022_01_17_145248_add_allocated_at_to_dealer_orders_table.php b/database/migrations/2022_01_17_145248_add_allocated_at_to_dealer_orders_table.php deleted file mode 100644 index 97b31d72..00000000 --- a/database/migrations/2022_01_17_145248_add_allocated_at_to_dealer_orders_table.php +++ /dev/null @@ -1,34 +0,0 @@ -timestamp('allocated_at')->nullable()->comment('分配时间'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealer_orders', function (Blueprint $table) { - // - $table->dropColumn('allocated_at'); - }); - } -} diff --git a/database/migrations/2022_01_17_145556_create_dealer_order_allocate_logs_table.php b/database/migrations/2022_01_17_145556_create_dealer_order_allocate_logs_table.php deleted file mode 100644 index 8dd6fcb7..00000000 --- a/database/migrations/2022_01_17_145556_create_dealer_order_allocate_logs_table.php +++ /dev/null @@ -1,34 +0,0 @@ -id(); - $table->unsignedBigInteger('order_id')->comment('订单ID'); - $table->unsignedBigInteger('last_consignor_id')->comment('上个接单人'); - $table->unsignedBigInteger('new_consignor_id')->nullable()->comment('新接单人'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_order_allocate_logs'); - } -} diff --git a/database/migrations/2022_01_17_160300_add_contracted_lvl_at_to_dealers_table.php b/database/migrations/2022_01_17_160300_add_contracted_lvl_at_to_dealers_table.php deleted file mode 100644 index 7e98eee9..00000000 --- a/database/migrations/2022_01_17_160300_add_contracted_lvl_at_to_dealers_table.php +++ /dev/null @@ -1,32 +0,0 @@ -timestamp('contracted_lvl_at')->nullable()->comment('成为签约的时间'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealers', function (Blueprint $table) { - $table->dropColumn(['contracted_lvl_at']); - }); - } -} diff --git a/database/migrations/2022_01_18_100740_create_dealer_channel_subsidy_logs_table.php b/database/migrations/2022_01_18_100740_create_dealer_channel_subsidy_logs_table.php deleted file mode 100644 index a977b69a..00000000 --- a/database/migrations/2022_01_18_100740_create_dealer_channel_subsidy_logs_table.php +++ /dev/null @@ -1,41 +0,0 @@ -id(); - $table->unsignedBigInteger('user_id')->comment('经销商的用户ID'); - $table->tinyInteger('lvl')->comment('经销商等级'); - $table->unsignedBigInteger('order_id')->comment('订单ID'); - $table->unsignedDecimal('total_amount', 10, 2)->default(0)->comment('补贴总额'); - $table->timestamp('order_completed_at')->nullable()->comment('订单完成时间'); - $table->string('remark')->nullable()->comment('备注'); - $table->timestamps(); - - $table->unique(['user_id', 'order_id']); - $table->index('order_id'); - $table->index('order_completed_at'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_channel_subsidy_logs'); - } -} diff --git a/database/migrations/2022_01_18_113101_create_dealer_upgrade_logs_table.php b/database/migrations/2022_01_18_113101_create_dealer_upgrade_logs_table.php deleted file mode 100644 index 6e7a86ae..00000000 --- a/database/migrations/2022_01_18_113101_create_dealer_upgrade_logs_table.php +++ /dev/null @@ -1,35 +0,0 @@ -id(); - $table->unsignedBigInteger('user_id'); - $table->tinyInteger('before_lvl'); - $table->tinyInteger('change_lvl'); - $table->string('remark'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_upgrade_logs'); - } -} diff --git a/database/migrations/2022_01_18_142430_add_pay_image_to_dealer_earnings_table.php b/database/migrations/2022_01_18_142430_add_pay_image_to_dealer_earnings_table.php deleted file mode 100644 index 8a371851..00000000 --- a/database/migrations/2022_01_18_142430_add_pay_image_to_dealer_earnings_table.php +++ /dev/null @@ -1,34 +0,0 @@ -string('pay_image')->nullable()->comment('打款凭证'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealer_earnings', function (Blueprint $table) { - // - $table->dropColumn('pay_image'); - }); - } -} diff --git a/database/migrations/2022_01_18_143452_add_bonds_to_dealers_table.php b/database/migrations/2022_01_18_143452_add_bonds_to_dealers_table.php deleted file mode 100644 index 65b521d1..00000000 --- a/database/migrations/2022_01_18_143452_add_bonds_to_dealers_table.php +++ /dev/null @@ -1,34 +0,0 @@ -unsignedDecimal('bonds')->default(0.00)->comment('已缴纳保证金'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealers', function (Blueprint $table) { - // - $table->dropColumn('bonds'); - }); - } -} diff --git a/database/migrations/2022_01_19_192508_create_dealer_sales_value_logs_table.php b/database/migrations/2022_01_19_192508_create_dealer_sales_value_logs_table.php deleted file mode 100644 index 888aacb9..00000000 --- a/database/migrations/2022_01_19_192508_create_dealer_sales_value_logs_table.php +++ /dev/null @@ -1,40 +0,0 @@ -id(); - $table->unsignedBigInteger('user_id')->comment('用户ID'); - $table->string('loggable_type')->nullable()->comment('日志关联对象的类型'); - $table->unsignedBigInteger('loggable_id')->nullable()->comment('日志关联对象的ID'); - $table->tinyInteger('type')->default(1)->comment('类型: 1 个人, 2 团队'); - $table->decimal('change_sales_value', 18, 2)->default(0.00)->comment('变更销售值'); - $table->string('remark')->nullable()->comment('备注'); - $table->timestamps(); - - $table->index(['user_id', 'type']); - $table->index(['loggable_type', 'loggable_id']); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_sales_value_logs'); - } -} diff --git a/database/migrations/2022_01_19_194357_add_self_sales_value_to_dealers_table.php b/database/migrations/2022_01_19_194357_add_self_sales_value_to_dealers_table.php deleted file mode 100644 index 61075892..00000000 --- a/database/migrations/2022_01_19_194357_add_self_sales_value_to_dealers_table.php +++ /dev/null @@ -1,32 +0,0 @@ -unsignedDecimal('self_sales_value', 18, 2)->default(0)->comment('个人销售值'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealers', function (Blueprint $table) { - $table->dropColumn('self_sales_value'); - }); - } -} diff --git a/database/migrations/2022_01_19_194401_add_team_sales_value_to_dealers_table.php b/database/migrations/2022_01_19_194401_add_team_sales_value_to_dealers_table.php deleted file mode 100644 index bd070f02..00000000 --- a/database/migrations/2022_01_19_194401_add_team_sales_value_to_dealers_table.php +++ /dev/null @@ -1,32 +0,0 @@ -unsignedDecimal('team_sales_value', 18, 2)->default(0)->comment('个人销售值'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealers', function (Blueprint $table) { - $table->dropColumn('team_sales_value'); - }); - } -} diff --git a/database/migrations/2022_01_24_170832_add_remark_to_dealer_orders_table.php b/database/migrations/2022_01_24_170832_add_remark_to_dealer_orders_table.php deleted file mode 100644 index d0d3f454..00000000 --- a/database/migrations/2022_01_24_170832_add_remark_to_dealer_orders_table.php +++ /dev/null @@ -1,34 +0,0 @@ -string('remark')->nullable()->comment('订单备注'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealer_orders', function (Blueprint $table) { - // - $table->dropColumn('remark'); - }); - } -} diff --git a/database/migrations/2022_01_25_131329_create_dealer_wallets_table.php b/database/migrations/2022_01_25_131329_create_dealer_wallets_table.php deleted file mode 100644 index 5599195a..00000000 --- a/database/migrations/2022_01_25_131329_create_dealer_wallets_table.php +++ /dev/null @@ -1,36 +0,0 @@ -id(); - $table->unsignedBigInteger('user_id')->unique()->comment('用户ID'); - $table->unsignedDecimal('balance', 12, 2)->default(0)->comment('余额'); - $table->unsignedDecimal('total_expenses', 12, 2)->default(0)->comment('总支出'); - $table->unsignedDecimal('total_revenue', 12, 2)->default(0)->comment('总收入'); - $table->boolean('withdrawable')->default(true)->comment('是否可提现'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_wallets'); - } -} diff --git a/database/migrations/2022_01_25_131739_create_dealer_wallet_logs_table.php b/database/migrations/2022_01_25_131739_create_dealer_wallet_logs_table.php deleted file mode 100644 index e7550655..00000000 --- a/database/migrations/2022_01_25_131739_create_dealer_wallet_logs_table.php +++ /dev/null @@ -1,37 +0,0 @@ -id(); - $table->unsignedBigInteger('user_id')->comment('用户ID'); - $table->nullableMorphs('loggable'); - $table->tinyInteger('action')->comment('操作类型'); - $table->decimal('before_balance', 12, 2)->default(0)->comment('变更前的余额'); - $table->decimal('change_balance', 12, 2)->default(0)->comment('变动余额'); - $table->string('remarks')->nullable()->comment('备注'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_wallet_logs'); - } -} diff --git a/database/migrations/2022_01_25_135106_create_dealer_wallet_to_bank_logs_table.php b/database/migrations/2022_01_25_135106_create_dealer_wallet_to_bank_logs_table.php deleted file mode 100644 index 41913975..00000000 --- a/database/migrations/2022_01_25_135106_create_dealer_wallet_to_bank_logs_table.php +++ /dev/null @@ -1,40 +0,0 @@ -id(); - $table->unsignedBigInteger('user_id')->comment('用户ID'); - $table->unsignedDecimal('amount')->comment('提现金额'); - $table->unsignedDecimal('rate', 18, 2)->default(0)->comment('费率'); - $table->unsignedDecimal('service_amount')->default(0)->comment('手续费'); - $table->unsignedDecimal('account_amount')->comment('到账金额'); - $table->unsignedTinyInteger('status')->default(0)->comment('状态:0未处理,1成功,2失败'); - $table->text('pay_info')->nullable()->comment('收款信息'); - $table->string('pay_image')->nullable()->comment('打款凭证'); - $table->string('remarks')->nullable()->comment('备注'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_wallet_to_bank_logs'); - } -} diff --git a/database/migrations/2022_01_26_114703_add_paid_time_index_to_dealer_orders_table.php b/database/migrations/2022_01_26_114703_add_paid_time_index_to_dealer_orders_table.php deleted file mode 100644 index 82520cd7..00000000 --- a/database/migrations/2022_01_26_114703_add_paid_time_index_to_dealer_orders_table.php +++ /dev/null @@ -1,32 +0,0 @@ -index('paied_time'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealer_orders', function (Blueprint $table) { - $table->dropIndex(['paied_time']); - }); - } -} diff --git a/database/migrations/2022_02_11_163430_add_pay_way_to_dealer_orders_table.php b/database/migrations/2022_02_11_163430_add_pay_way_to_dealer_orders_table.php deleted file mode 100644 index f4684385..00000000 --- a/database/migrations/2022_02_11_163430_add_pay_way_to_dealer_orders_table.php +++ /dev/null @@ -1,34 +0,0 @@ -string('pay_way')->nullable()->comment('1线下打款,2余额'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealer_orders', function (Blueprint $table) { - // - $table->dropColumn('pay_way'); - }); - } -} diff --git a/database/migrations/2022_02_14_103211_create_dealer_shopping_cart_items_table.php b/database/migrations/2022_02_14_103211_create_dealer_shopping_cart_items_table.php deleted file mode 100644 index fb0c00be..00000000 --- a/database/migrations/2022_02_14_103211_create_dealer_shopping_cart_items_table.php +++ /dev/null @@ -1,38 +0,0 @@ -id(); - $table->unsignedBigInteger('user_id')->comment('用户ID'); - $table->unsignedBigInteger('product_id')->comment('商品ID'); - $table->string('name')->comment('商品名称'); - $table->string('cover')->nullable()->comment('封面图'); - $table->unsignedDecimal('sell_price', 10, 2)->default(0.00)->comment('销售价格:元'); - $table->unsignedDecimal('dealer_price', 10, 2)->default(0.00)->comment('经销商价格:元'); - $table->unsignedInteger('quantity')->default(0)->comment('购买数量'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_shopping_cart_items'); - } -} diff --git a/database/migrations/2022_02_14_114040_add_has_revoke_to_dealer_user_product_logs_table.php b/database/migrations/2022_02_14_114040_add_has_revoke_to_dealer_user_product_logs_table.php deleted file mode 100644 index 8863418e..00000000 --- a/database/migrations/2022_02_14_114040_add_has_revoke_to_dealer_user_product_logs_table.php +++ /dev/null @@ -1,34 +0,0 @@ -unsignedBigInteger('revoke_id')->default(0)->comment('撤销关联ID'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealer_user_product_logs', function (Blueprint $table) { - // - $table->dropColumn('revoke_id'); - }); - } -} diff --git a/database/migrations/2022_02_15_113720_del_user_id_order_id_product_id_unique_index_to_dealer_manage_subsidy_logs_table.php b/database/migrations/2022_02_15_113720_del_user_id_order_id_product_id_unique_index_to_dealer_manage_subsidy_logs_table.php deleted file mode 100644 index fc25f010..00000000 --- a/database/migrations/2022_02_15_113720_del_user_id_order_id_product_id_unique_index_to_dealer_manage_subsidy_logs_table.php +++ /dev/null @@ -1,32 +0,0 @@ -dropUnique(['user_id', 'order_id', 'product_id']); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealer_manage_subsidy_logs', function (Blueprint $table) { - $table->unique(['user_id', 'order_id', 'product_id']); - }); - } -} diff --git a/database/migrations/2022_02_21_153159_create_dealer_order_refuse_logs_table.php b/database/migrations/2022_02_21_153159_create_dealer_order_refuse_logs_table.php deleted file mode 100644 index f1b0ccc1..00000000 --- a/database/migrations/2022_02_21_153159_create_dealer_order_refuse_logs_table.php +++ /dev/null @@ -1,35 +0,0 @@ -id(); - $table->unsignedBigInteger('order_id'); - $table->string('reason')->nullable()->comment('原因'); - $table->timestamps(); - - $table->index('order_id'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_order_refuse_logs'); - } -} diff --git a/database/migrations/2022_02_22_112419_add_pay_sn_to_dealer_orders_table.php b/database/migrations/2022_02_22_112419_add_pay_sn_to_dealer_orders_table.php deleted file mode 100644 index 84631036..00000000 --- a/database/migrations/2022_02_22_112419_add_pay_sn_to_dealer_orders_table.php +++ /dev/null @@ -1,32 +0,0 @@ -string('pay_sn')->nullable()->comment('支付流水号'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealer_orders', function (Blueprint $table) { - $table->dropColumn(['pay_sn']); - }); - } -} diff --git a/database/migrations/2022_02_22_112425_add_out_trade_no_to_dealer_orders_table.php b/database/migrations/2022_02_22_112425_add_out_trade_no_to_dealer_orders_table.php deleted file mode 100644 index 624ba5b7..00000000 --- a/database/migrations/2022_02_22_112425_add_out_trade_no_to_dealer_orders_table.php +++ /dev/null @@ -1,32 +0,0 @@ -string('out_trade_no')->nullable()->comment('外部交易单号'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealer_orders', function (Blueprint $table) { - $table->dropColumn(['out_trade_no']); - }); - } -} diff --git a/database/migrations/2022_02_23_104107_add_pay_way_to_dealer_earnings_table.php b/database/migrations/2022_02_23_104107_add_pay_way_to_dealer_earnings_table.php deleted file mode 100644 index e8b642f7..00000000 --- a/database/migrations/2022_02_23_104107_add_pay_way_to_dealer_earnings_table.php +++ /dev/null @@ -1,34 +0,0 @@ -string('pay_way')->nullable()->comment('1线下打款,2余额'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealer_earnings', function (Blueprint $table) { - // - $table->dropColumn('pay_way'); - }); - } -} diff --git a/database/migrations/2022_03_08_100618_add_deposit_stock_to_dealer_user_products_table.php b/database/migrations/2022_03_08_100618_add_deposit_stock_to_dealer_user_products_table.php deleted file mode 100644 index ad487abc..00000000 --- a/database/migrations/2022_03_08_100618_add_deposit_stock_to_dealer_user_products_table.php +++ /dev/null @@ -1,32 +0,0 @@ -unsignedBigInteger('deposit_stock')->default(0)->comment('托管库存'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealer_user_products', function (Blueprint $table) { - $table->dropColumn(['deposit_stock']); - }); - } -} diff --git a/database/migrations/2022_03_08_103158_add_deposit_qty_to_dealer_order_products_table.php b/database/migrations/2022_03_08_103158_add_deposit_qty_to_dealer_order_products_table.php deleted file mode 100644 index 5c669c25..00000000 --- a/database/migrations/2022_03_08_103158_add_deposit_qty_to_dealer_order_products_table.php +++ /dev/null @@ -1,32 +0,0 @@ -unsignedBigInteger('deposit_qty')->default(0)->comment('托管数量'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealer_order_products', function (Blueprint $table) { - $table->dropColumn(['deposit_qty']); - }); - } -} diff --git a/database/migrations/2022_03_08_105741_create_dealer_delivery_bills_table.php b/database/migrations/2022_03_08_105741_create_dealer_delivery_bills_table.php deleted file mode 100644 index bfea05d8..00000000 --- a/database/migrations/2022_03_08_105741_create_dealer_delivery_bills_table.php +++ /dev/null @@ -1,50 +0,0 @@ -id(); - $table->string('sn')->unique(); - $table->unsignedBigInteger('user_id'); - $table->unsignedBigInteger('order_id')->nullable(); - $table->unsignedDecimal('shipping_fee', 18, 2)->default(0)->comment('运费'); - $table->string('remark')->nullable()->comment('备注'); - - // 收货人信息 - $table->string('consignee_name')->nullable()->comment('收货人-姓名'); - $table->string('consignee_telephone')->nullable()->comment('收货人-联系方式'); - $table->string('consignee_zone')->nullable()->comment('收货人-所在地区'); - $table->string('consignee_address')->nullable()->comment('收货人-详细地址'); - - // 支付信息 - $table->string('pay_sn')->nullable()->comment('支付单号'); - $table->string('pay_way')->nullable()->comment('支付方式'); - $table->string('out_trade_no')->nullable()->comment('外部交易号'); - $table->timestamp('pay_at')->nullable()->comment('付款时间'); - - $table->tinyInteger('status')->default(0)->comment('状态'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_delivery_bills'); - } -} diff --git a/database/migrations/2022_03_08_105753_create_dealer_delivery_products_table.php b/database/migrations/2022_03_08_105753_create_dealer_delivery_products_table.php deleted file mode 100644 index 13f901a6..00000000 --- a/database/migrations/2022_03_08_105753_create_dealer_delivery_products_table.php +++ /dev/null @@ -1,36 +0,0 @@ -id(); - $table->unsignedBigInteger('delivery_bill_id'); - $table->unsignedBigInteger('product_id'); - $table->unsignedBigInteger('qty'); - $table->timestamps(); - - $table->unique(['delivery_bill_id', 'product_id']); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('dealer_delivery_products'); - } -} diff --git a/database/migrations/2022_03_08_145732_add_is_deposit_to_dealer_user_product_logs_table.php b/database/migrations/2022_03_08_145732_add_is_deposit_to_dealer_user_product_logs_table.php deleted file mode 100644 index 387a7162..00000000 --- a/database/migrations/2022_03_08_145732_add_is_deposit_to_dealer_user_product_logs_table.php +++ /dev/null @@ -1,34 +0,0 @@ -boolean('is_deposit')->default(false)->comment('是否云库存'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealer_user_product_logs', function (Blueprint $table) { - // - $table->dropColumn(['is_deposit']); - }); - } -} diff --git a/database/migrations/2022_03_14_113838_add_deposit_status_to_dealer_orders_table.php b/database/migrations/2022_03_14_113838_add_deposit_status_to_dealer_orders_table.php deleted file mode 100644 index 6dce48aa..00000000 --- a/database/migrations/2022_03_14_113838_add_deposit_status_to_dealer_orders_table.php +++ /dev/null @@ -1,35 +0,0 @@ -unsignedTinyInteger('local_status')->nullable()->default(0)->comment('本地仓发货状态'); - $table->unsignedTinyInteger('deposit_status')->nullable()->default(0)->comment('云仓发货状态'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealer_orders', function (Blueprint $table) { - // - $table->dropColumn(['local_status', 'deposit_status']); - }); - } -} diff --git a/database/migrations/2022_04_13_104039_add_pay_columns_to_dealer_wallet_to_bank_logs_table.php b/database/migrations/2022_04_13_104039_add_pay_columns_to_dealer_wallet_to_bank_logs_table.php deleted file mode 100644 index 8bc680ae..00000000 --- a/database/migrations/2022_04_13_104039_add_pay_columns_to_dealer_wallet_to_bank_logs_table.php +++ /dev/null @@ -1,37 +0,0 @@ -string('pay_sn')->nullable()->comment('支付单号'); - $table->tinyInteger('pay_way')->default(1)->comment('支付方式: 1 线下, 2 代付'); - $table->timestamp('pay_at')->nullable()->comment('支付时间'); - $table->text('failed_reason')->nullable()->comment('失败原因'); - - $table->unique('pay_sn'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealer_wallet_to_bank_logs', function (Blueprint $table) { - $table->dropColumn(['pay_sn', 'pay_way', 'failed_reason', 'pay_at']); - }); - } -} diff --git a/database/migrations/2022_04_22_172136_add_manager_id_to_dealer_wallet_to_bank_logs_table.php b/database/migrations/2022_04_22_172136_add_manager_id_to_dealer_wallet_to_bank_logs_table.php deleted file mode 100644 index eb58c117..00000000 --- a/database/migrations/2022_04_22_172136_add_manager_id_to_dealer_wallet_to_bank_logs_table.php +++ /dev/null @@ -1,32 +0,0 @@ -unsignedBigInteger('manager_id')->nullable()->comment('管理者UID'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('dealer_wallet_to_bank_logs', function (Blueprint $table) { - $table->dropColumn(['manager_id']); - }); - } -} diff --git a/database/seeders/AdminMenuSeeder.php b/database/seeders/AdminMenuSeeder.php index 60dc9814..c35797cc 100644 --- a/database/seeders/AdminMenuSeeder.php +++ b/database/seeders/AdminMenuSeeder.php @@ -289,83 +289,6 @@ class AdminMenuSeeder extends Seeder ], ], ], - [ - 'title' =>'批零管理', - 'icon' => 'fa fa-skyatlas', - 'uri' =>'', - 'children' => [ - [ - 'title' =>'经销商管理', - 'icon' => '', - 'uri' => 'dealer-users', - ], - [ - 'title' =>'经销商资金明细', - 'icon'=>'', - 'uri' => 'dealer-earnings', - ], - [ - 'title' =>'商品管理', - 'icon' => '', - 'uri' => 'dealer-products', - ], - [ - 'title' => '订单管理', - 'icon' => '', - 'uri' => 'dealer-orders', - ], - [ - 'title' =>'系统订单', - 'icon' => '', - 'uri' => 'dealer-manager-orders?type=manager&filter-status[]=2&filter-status[]=3', - ], - [ - 'title' => '云仓提货单', - 'icon' => '', - 'uri' => 'dealer-delivery-bills', - ], - [ - 'title' =>'签约渠道补贴', - 'icon'=>'', - 'uri' => 'dealer-channel-subsidies', - ], - [ - 'title' =>'进货补贴', - 'icon' => '', - 'uri' => 'dealer-purchase-subsidies', - ], - [ - 'title' =>'进货补贴明细', - 'icon' => '', - 'uri' => 'dealer-purchase-logs', - ], - [ - 'title'=>'管理津贴', - 'icon' => '', - 'uri' => 'dealer-manage-subsidies', - ], - [ - 'title' =>'管理津贴明细', - 'icon' => '', - 'uri' => 'dealer-manage-subsidy-logs', - ], - [ - 'title'=>'管理者津贴', - 'icon' => '', - 'uri' => 'dealer-manager-subsidies', - ], - [ - 'title'=>'管理者津贴明细', - 'icon' => '', - 'uri'=>'dealer-manager-sales-logs', - ], - [ - 'title' =>'余额提现', - 'icon' =>'', - 'uri'=>'dealer-wallet-to-bank-logs', - ], - ], - ], [ 'title' => '系统管理', 'icon' => 'feather icon-settings', diff --git a/database/seeders/AdminPermissionSeeder.php b/database/seeders/AdminPermissionSeeder.php index 4fe1a3e6..fb2988ef 100644 --- a/database/seeders/AdminPermissionSeeder.php +++ b/database/seeders/AdminPermissionSeeder.php @@ -312,106 +312,6 @@ class AdminPermissionSeeder extends Seeder 'logs_index'=>['name' =>'变动日志'], ], ], - 'dealers' =>[ - 'name' =>'经销商管理', - 'curd'=>['index', 'show', 'update'], - 'children'=>[ - 'edit_lvl'=>['name' =>'修改经销商等级'], - 'bonds'=>['name' =>'填写保证金'], - 'edit_product'=>['name' =>'调整库存'], - 'wallet_change' => ['name' => '变更余额'], - ], - ], - 'dealer_products'=>[ - 'name'=>'批零商品', - 'curd'=> true, - 'children' => [ - 'lvl_rules'=>['name' =>'等级规则'], - 'sale_rules'=>['name' =>'销售规则'], - 'manage_rules' =>['name' =>'管理规则'], - ], - ], - 'dealer_orders'=>[ - 'name' =>'批零订单', - 'curd' => ['index', 'show'], - 'children' =>[ - 'paid'=>['name' =>'确认收款'], - 'refuse'=>['name' =>'拒绝收款'], - 'shipping'=>['name' =>'确认发货'], - 'allocate'=>['name' =>'自动分配'], - 'manager'=>['name' =>'系统订单'], - 'remark'=>['name' =>'备注'], - 'cancel'=>['name' =>'取消订单'], - ], - ], - 'dealer_delivery_bills' => [ - 'name' =>'云仓提货单', - 'curd' => ['index', 'show'], - 'children' =>[], - ], - 'dealer_earnings'=>[ - 'name' =>'资金管理', - 'curd' => ['index', 'show'], - 'children' => [ - 'channel'=>['name' =>'渠道补贴'], - 'purchase'=>['name' =>'进货补贴'], - 'manage' =>['name' =>'管理补贴'], - 'manager'=>['name' =>'管理者补贴'], - 'pay'=>['name' =>'确认打款'], - ], - ], - 'dealer_channel_subsidies' => [ - 'name' =>'签约渠道补贴', - 'curd' => ['index'], - 'children' => [ - 'pay' => ['name' => '付款'], - 'batch_pay' => ['name' => '批量付款'], - ], - ], - 'dealer_purchase_subsidies' => [ - 'name' =>'进货补贴', - 'curd' => ['index', 'show'], - 'children' => [ - 'pay' => ['name' => '付款'], - 'batch_pay' => ['name' => '批量付款'], - ], - ], - 'dealer_manager_subsidies' => [ - 'name' =>'管理者津贴', - 'curd' => ['index'], - 'children' => [ - 'pay' => ['name' => '付款'], - 'batch_pay' => ['name' => '批量付款'], - ], - ], - 'dealer_manager_sales_logs'=>[ - 'name' =>'管理者津贴明细', - 'curd' => ['index'], - ], - 'dealer_manage_subsidies' => [ - 'name' =>'管理津贴', - 'curd' => ['index'], - 'children' => [ - 'pay' => ['name' => '付款'], - 'batch_pay' => ['name' => '批量付款'], - ], - ], - 'dealer_manage_subsidy_logs'=>[ - 'name' =>'管理津贴明细', - 'curd' => ['index'], - ], - 'dealer_purchase_logs'=>[ - 'name' =>'进货补贴明细', - 'curd' => ['index'], - ], - 'dealer_wallet_to_bank_logs'=>[ - 'name' =>'余额提现', - 'curd' => ['index', 'show'], - 'children' =>[ - 'export'=>['name' =>'导出打款单'], - 'verify'=>['name' =>'提现审核'], - ], - ], 'activities'=>[ 'name' =>'活动管理', 'curd' => true, diff --git a/database/seeders/AppSettingSeeder.php b/database/seeders/AppSettingSeeder.php index 23c85db7..b4b82963 100644 --- a/database/seeders/AppSettingSeeder.php +++ b/database/seeders/AppSettingSeeder.php @@ -2,7 +2,6 @@ namespace Database\Seeders; -use App\Enums\DealerLvl; use App\Models\Order; use App\Models\Setting; use Illuminate\Database\Seeder; @@ -177,110 +176,6 @@ class AppSettingSeeder extends Seeder ], 'remarks' => '会员奖励配置', ], - 'dealer' => [ - 'value' => [ - 'fee_rate' => '6', // 手续费比例(百分比) - 'withdraw_threshold_amount'=>'0', //提现门槛金额 - 'withdraw_fee_rate'=>'0.00', //提现手续费率 - - // 金牌经销商升级金额 - 'upgrade_amount_'.DealerLvl::Gold->value => '2520', - // 特邀经销商升级金额 - 'upgrade_amount_'.DealerLvl::Special->value => '8600', - // 合约经销商升级金额 - 'upgrade_amount_'.DealerLvl::Contracted->value => '26400', - - //单次下单最低金额 - // 金牌经销商 - 'min_order_amount_'.DealerLvl::Gold->value => '1260', - // 特邀经销商 - 'min_order_amount_'.DealerLvl::Special->value => '1720', - // 签约约经销商 - 'min_order_amount_'.DealerLvl::Contracted->value => '2640', - // 二级签约约经销商 - 'min_order_amount_'.DealerLvl::Secondary->value => '2640', - // 一级签约约经销商 - 'min_order_amount_'.DealerLvl::Top->value => '2640', - - // 渠道补贴规则 - 'channel_rules' => [ - // 签约 -> 签约 ->签约 - DealerLvl::Contracted->value.'_'.DealerLvl::Contracted->value => [ - DealerLvl::Contracted->value.'_0' => '3960', - DealerLvl::Contracted->value.'_1' => '790', - ], - - // 签约 -> 特邀 -> 签约 -> 签约 - DealerLvl::Contracted->value.'_'.DealerLvl::Special->value => [ - DealerLvl::Special->value.'_0' => '2640', - DealerLvl::Contracted->value.'_1' => '1320', - DealerLvl::Contracted->value.'_2' => '790', - ], - - // 特邀 -> 特邀 ->特邀 - DealerLvl::Special->value.'_'.DealerLvl::Special->value => [ - DealerLvl::Special->value.'_0' => '800', - DealerLvl::Special->value.'_1' => '200', - ], - - // 特邀 -> 金牌 -> 特邀 -> 特邀 - DealerLvl::Special->value.'_'.DealerLvl::Gold->value => [ - DealerLvl::Gold->value.'_0' => '500', - DealerLvl::Special->value.'_1' => '300', - DealerLvl::Special->value.'_2' => '200', - ], - - // 金牌 -> 金牌 - DealerLvl::Gold->value.'_'.DealerLvl::Gold->value => [ - DealerLvl::Gold->value.'_0' => '300', - ], - ], - - //超过N小时未接单自动分配 - 'order_auto_allocate_times'=>'1', - - 'purchase_rules'=>[ - ['price' => '1', 'rate' => '2.00'], - ['price' => '2', 'rate' => '3.00'], - ['price' => '3', 'rate' => '4.00'], - ['price' => '5', 'rate' => '5.00'], - ['price' => '8', 'rate' => '6.00'], - ['price' => '11', 'rate' => '7.00'], - ['price' => '15', 'rate' => '8.00'], - ['price' => '20', 'rate' => '9.00'], - ['price' => '30', 'rate' => '10.00'], - ['price' => '40', 'rate' => '11.00'], - ['price' => '55', 'rate' => '12.00'], - ['price' => '70', 'rate' => '13.00'], - ['price' => '90', 'rate' => '14.00'], - ['price' => '115', 'rate' => '15.00'], - ['price' => '145', 'rate' => '16.00'], - ['price' => '185', 'rate' => '17.00'], - ['price' => '230', 'rate' => '18.00'], - ['price' => '280', 'rate' => '19.00'], - ['price' => '340', 'rate' => '20.00'], - ['price' => '400', 'rate' => '21.00'], - ['price' => '500', 'rate' => '22.00'], - ], - 'bank'=>[ //银行卡收款 - 'user_name' => '收款人名称', //收款人 - 'bank_name' => '银行名称', - 'bank_number' => '银行卡号', - 'bank_description'=>'开户行', - ], - 'alipay' => [ //支付宝收款 - 'user_name' => '收款人姓名', - 'ali_name'=> '收款账号', - 'image' => '', - ], - 'wechat' => [ //微信收款 - 'user_name' => '收款人姓名', - 'wechat_name'=>'微信id', - 'image' => '', - ], - ], - 'remarks' => '经销商配置', - ], ] as $key => $values) { Setting::firstOrCreate(['key' => $key], $values); } diff --git a/resources/lang/zh_CN/dealer-earning.php b/resources/lang/zh_CN/dealer-earning.php deleted file mode 100644 index d48b704f..00000000 --- a/resources/lang/zh_CN/dealer-earning.php +++ /dev/null @@ -1,34 +0,0 @@ - [ - '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' => '打款凭证', - 'pay_way'=>'支付方式', - ], - 'options' => [ - ], -]; diff --git a/resources/lang/zh_CN/dealer-manage-subsidy-log.php b/resources/lang/zh_CN/dealer-manage-subsidy-log.php deleted file mode 100644 index bdaa2100..00000000 --- a/resources/lang/zh_CN/dealer-manage-subsidy-log.php +++ /dev/null @@ -1,19 +0,0 @@ - [ - 'DealerManageSubsidyLog' => '管理津贴明细', - 'dealer-manage-subsidy-logs' => '管理津贴明细', - ], - 'fields' => [ - 'user_id' => '用户', - 'lvl' => '等级', - 'order_id' => '订单', - 'product_id' => '商品', - 'sales_volume' => '商品销量', - 'total_amount' => '补贴总金额', - 'order_completed_at' => '订单完成时间', - ], - 'options' => [ - ], -]; diff --git a/resources/lang/zh_CN/dealer-manager-sales-log.php b/resources/lang/zh_CN/dealer-manager-sales-log.php deleted file mode 100644 index 4bd0c8c6..00000000 --- a/resources/lang/zh_CN/dealer-manager-sales-log.php +++ /dev/null @@ -1,18 +0,0 @@ - [ - 'DealerManagerSalesLog' => '管理者津贴明细', - 'dealer-manager-sales-logs' => '管理者津贴明细', - ], - 'fields' => [ - 'user_id' => '用户手机号', - 'order_id' => '订单', - 'product_id' => '商品', - 'lvl' => '等级', - 'sales_volume' => '商品销量', - 'order_completed_at' => '订单完成时间', - ], - 'options' => [ - ], -]; diff --git a/resources/lang/zh_CN/dealer-order.php b/resources/lang/zh_CN/dealer-order.php deleted file mode 100644 index c42837db..00000000 --- a/resources/lang/zh_CN/dealer-order.php +++ /dev/null @@ -1,45 +0,0 @@ - [ - 'DealerOrder' => '订单管理', - 'dealer-orders' => '订单管理', - 'dealer-manager-orders' => '系统订单', - ], - 'fields' => [ - 'sn' => '订单编号', - 'user_id' => '下单用户', - 'user'=>[ - 'phone' => '下单用户', - ], - 'userInfo' => [ - 'nickname' => '昵称', - ], - 'user_info'=>[ - 'nickname' => '昵称', - ], - 'consignor_id' => '发货用户', - 'consignor' => [ - 'phone' => '发货用户', - ], - 'remark' => '备注', - 'total_amount' => '订单价格', - 'status' => '状态', - 'order_status'=>'状态', - 'settle_state' => '结算状态', - 'consignee_name' => '收货人姓名', - 'consignee_telephone' => '收货人联系方式', - 'consignee_zone' => '收货人所在地区', - 'consignee_address' => '收货人详细地址', - 'pay_info' => '收款信息', - 'pay_image' => '打款凭证', - 'pay_way'=>'支付方式', - 'pay_time' => '支付时间', - 'paied_time' => '确认收款时间', - 'shipping_time' => '发货时间', - 'shippinged_time' => '确认收货时间', - 'created_at'=>'下单时间', - ], - 'options' => [ - ], -]; diff --git a/resources/lang/zh_CN/dealer-product.php b/resources/lang/zh_CN/dealer-product.php deleted file mode 100644 index afd33f8d..00000000 --- a/resources/lang/zh_CN/dealer-product.php +++ /dev/null @@ -1,23 +0,0 @@ - [ - 'DealerProduct' => '商品管理', - 'dealer-products' => '商品管理', - ], - 'fields' => [ - 'name' => '商品名称', - 'subtitle' => '商品副标题', - 'cover' => '封面图', - 'images' => '商品图片', - 'description' => '商品详情', - 'price' => '销售价格', - 'manager_subsidy'=>'管理者津贴', - 'stock' => '库存', - 'sales_count' => '销量', - 'is_sale' => '是否在售', - 'unit'=>'单位', - ], - 'options' => [ - ], -]; diff --git a/resources/lang/zh_CN/dealer-purchase-log.php b/resources/lang/zh_CN/dealer-purchase-log.php deleted file mode 100644 index e12ca0b2..00000000 --- a/resources/lang/zh_CN/dealer-purchase-log.php +++ /dev/null @@ -1,18 +0,0 @@ - [ - 'DealerPurchaseLog' => '进货补贴明细', - 'dealer-purchase-logs' => '进货补贴明细', - ], - 'fields' => [ - 'user_id' => '用户', - 'order_id' => '订单', - 'lvl' => '经销商等级', - 'total_amount' => '订单金额', - 'remark' => '备注', - 'order_completed_at' => '订单完成时间', - ], - 'options' => [ - ], -]; diff --git a/resources/lang/zh_CN/dealer-wallet-to-bank-log.php b/resources/lang/zh_CN/dealer-wallet-to-bank-log.php deleted file mode 100644 index 5eb8caac..00000000 --- a/resources/lang/zh_CN/dealer-wallet-to-bank-log.php +++ /dev/null @@ -1,26 +0,0 @@ - [ - 'DealerWalletToBankLog' => '余额提现', - 'dealer-wallet-to-bank-logs' => '余额提现', - ], - 'fields' => [ - 'user_id' => '用户', - 'user'=>[ - 'phone' => '手机号', - ], - 'pay_image' => '打款凭证', - 'amount' => '提现金额', - 'rate' => '费率', - 'service_amount' => '手续费', - 'account_amount' => '到账金额', - 'status' => '状态', - 'remarks' => '备注', - 'failed_reason' => '失败原因', - 'pay_way' => '支付方式', - 'manager_id' => '管理者', - ], - 'options' => [ - ], -]; diff --git a/resources/lang/zh_CN/dealer.php b/resources/lang/zh_CN/dealer.php deleted file mode 100644 index 74f4c61d..00000000 --- a/resources/lang/zh_CN/dealer.php +++ /dev/null @@ -1,42 +0,0 @@ - [ - 'Dealer' => '经销商管理', - 'dealers' => '经销商管理', - 'dealer-users' => '经销商', - ], - 'fields' => [ - 'user_id' => '用户ID', - 'user'=>[ - 'phone'=>'手机号', - ], - 'userInfo'=>[ - 'avatar' => '头像', - 'nickname' => '昵称', - 'agent_level'=>'身份', - 'growth_value'=>'消费值', - 'group_sales_value'=>'业绩', - 'inviterInfo'=>[ - 'user'=>[ - 'phone' =>'推荐人手机', - ], - ], - 'realInviterInfo'=>[ - 'user'=>[ - 'phone' =>'老直推手机', - ], - ], - ], - 'wallet' => [ - 'balance' => '余额', - ], - 'lvl' => '经销商等级', - 'is_sale' => '是否可销售', - 'is_manager' => '是否是管理者', - 'pay_info' => '用户保留的收款信息', - 'bonds' => '保证金', - ], - 'options' => [ - ], -]; diff --git a/resources/lang/zh_CN/models.php b/resources/lang/zh_CN/models.php index 17e6248b..f95ae728 100644 --- a/resources/lang/zh_CN/models.php +++ b/resources/lang/zh_CN/models.php @@ -2,7 +2,6 @@ use App\Models\AfterSale; use App\Models\Article; -use App\Models\DealerUserProductLog; use App\Models\Order; use App\Models\OrderProduct; use App\Models\ProductSku; @@ -24,5 +23,4 @@ return [ AfterSale::class => '售后订单', Article::class => '文章', OrderPackage::class => '包裹', - DealerUserProductLog::class => '日志', ]; diff --git a/worker.conf b/worker.conf index 4a56bdb1..565abbc3 100644 --- a/worker.conf +++ b/worker.conf @@ -1,51 +1,3 @@ -# 【批零】自动分配订单 -[program:zcs-dealer-order-allocate] -process_name=%(program_name)s_%(process_num)02d -command=php /www/wwwroot/admin.zichunsheng.cn/current/artisan dealer:order-auto-allocate -autostart=true -autorestart=true -stopasgroup=true -killasgroup=true -user=deployer -numprocs=1 -redirect_stderr=true -stdout_logfile_maxbytes=10MB -stdout_logfile_backups=1 -stdout_logfile=/www/wwwroot/admin.zichunsheng.cn/current/storage/logs/worker-dealer-order-allocate.log -stopwaitsecs=600 - -# 【批零】处理待结算的已付款订单 -[program:zcs-dealer-order-process] -process_name=%(program_name)s_%(process_num)02d -command=php /www/wwwroot/admin.zichunsheng.cn/current/artisan dealer:order-process -autostart=true -autorestart=true -stopasgroup=true -killasgroup=true -user=deployer -numprocs=1 -redirect_stderr=true -stdout_logfile_maxbytes=10MB -stdout_logfile_backups=10 -stdout_logfile=/www/wwwroot/admin.zichunsheng.cn/current/storage/logs/worker-dealer-order-process.log -stopwaitsecs=900 - -# 【批零】结算已完成的订单 -[program:zcs-dealer-order-settle] -process_name=%(program_name)s_%(process_num)02d -command=php /www/wwwroot/admin.zichunsheng.cn/current/artisan dealer:order-settle -autostart=true -autorestart=true -stopasgroup=true -killasgroup=true -user=deployer -numprocs=1 -redirect_stderr=true -stdout_logfile_maxbytes=10MB -stdout_logfile_backups=5 -stdout_logfile=/www/wwwroot/admin.zichunsheng.cn/current/storage/logs/worker-dealer-order-settle.log -stopwaitsecs=300 - # 【商城】关闭过期订单 [program:zcs-order-close-expired] process_name=%(program_name)s_%(process_num)02d