diff --git a/app/Admin/Forms/Settings/Dealer.php b/app/Admin/Forms/Settings/Dealer.php index 9fdb755a..29767556 100644 --- a/app/Admin/Forms/Settings/Dealer.php +++ b/app/Admin/Forms/Settings/Dealer.php @@ -41,6 +41,7 @@ class Dealer extends Form $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::Contracted->value, '签约门槛')->symbol('¥'); $this->currency('upgrade_amount_'.DealerLvl::Special->value, '特邀门槛')->symbol('¥'); @@ -133,6 +134,7 @@ class Dealer extends Form '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] ?? '', diff --git a/app/Endpoint/Api/Http/Controllers/Dealer/WalletController.php b/app/Endpoint/Api/Http/Controllers/Dealer/WalletController.php index 12932100..1c87dfcb 100644 --- a/app/Endpoint/Api/Http/Controllers/Dealer/WalletController.php +++ b/app/Endpoint/Api/Http/Controllers/Dealer/WalletController.php @@ -54,6 +54,11 @@ class WalletController extends Controller 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).'元'); diff --git a/app/Endpoint/Api/Http/Resources/Dealer/DealerResource.php b/app/Endpoint/Api/Http/Resources/Dealer/DealerResource.php index 8c0fbcfe..ba8e14fa 100644 --- a/app/Endpoint/Api/Http/Resources/Dealer/DealerResource.php +++ b/app/Endpoint/Api/Http/Resources/Dealer/DealerResource.php @@ -2,7 +2,6 @@ namespace App\Endpoint\Api\Http\Resources\Dealer; -use App\Models\DealerWalletToBankLog; use Illuminate\Http\Resources\Json\JsonResource; class DealerResource extends JsonResource @@ -22,7 +21,7 @@ class DealerResource extends JsonResource 'guanli_values'=> $this->calculate_total_amount, //预计管理津贴 'team_sales_value' => $this->team_sales_value, 'pay_info'=>$this->pay_info ?: null, - 'can_withdraw'=> DealerWalletToBankLog::where('user_id', $this->user_id)->where('created_at', '>', now()->subDays(7))->doesntExist(), + 'can_withdraw'=> $this->canWithdraw(), ]; } } diff --git a/app/Models/Dealer.php b/app/Models/Dealer.php index ff773e66..0128c0c6 100644 --- a/app/Models/Dealer.php +++ b/app/Models/Dealer.php @@ -391,4 +391,10 @@ class Dealer extends Model $this->userInfo->save(); } } + + public function canWithdraw() + { + $days = app_settings('dealer.withdraw_days', 7); + return DealerWalletToBankLog::where('user_id', $this->user_id)->where('created_at', '>', now()->subDays($days))->doesntExist(); + } }