From 8c05c7a165aca5ddb8a0d769e81a3c23232961ab Mon Sep 17 00:00:00 2001 From: xuanchen <122383162@qq.com> Date: Thu, 12 Jan 2023 14:48:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/Withdraw/.gitignore | 2 - modules/Withdraw/Config/config.php | 13 - .../0000_00_00_000000_create_banks_table.php | 36 -- ...21_09_26_115830_create_withdraws_table.php | 44 --- ...021_09_26_120338_create_accounts_table.php | 39 --- ...2021_09_26_130107_create_configs_table.php | 36 -- .../2021_09_27_085100_create_logs_table.php | 36 -- ...03_142359_create_alipay_accounts_table.php | 37 -- modules/Withdraw/Events/WithdrawAuditPass.php | 8 - .../Withdraw/Events/WithdrawAuditReject.php | 8 - modules/Withdraw/Events/WithdrawEvent.php | 25 -- .../Controllers/Admin/AccountController.php | 46 --- .../Admin/Actions/WithdrawAudit.php | 48 --- .../Http/Controllers/Admin/BankController.php | 50 --- .../Controllers/Admin/ConfigController.php | 40 --- .../Controllers/Admin/WithdrawController.php | 74 ---- .../Controllers/Api/AccountController.php | 144 -------- .../Http/Controllers/Api/IndexController.php | 155 --------- .../Http/Requests/UserBankAccountRequest.php | 35 -- .../Requests/UserEditBankAccountRequest.php | 35 -- .../Http/Requests/WithdrawRequest.php | 35 -- .../Account/UserAlipayAccountCollection.php | 21 -- .../Account/UserAlipayAccountResource.php | 21 -- .../Account/UserBankAccountCollection.php | 21 -- .../Account/UserBankAccountResource.php | 27 -- .../Http/Resources/Bank/BankResource.php | 18 - .../Resources/Withdraw/WithdrawCollection.php | 21 -- .../Resources/Withdraw/WithdrawResource.php | 30 -- modules/Withdraw/Models/Account.php | 15 - modules/Withdraw/Models/AlipayAccount.php | 23 -- modules/Withdraw/Models/Bank.php | 23 -- modules/Withdraw/Models/Config.php | 23 -- modules/Withdraw/Models/Log.php | 12 - .../Withdraw/Models/Traits/BelongsToBank.php | 22 -- .../Models/Traits/WithdrawActions.php | 326 ------------------ modules/Withdraw/Models/Withdraw.php | 126 ------- .../Providers/RouteServiceProvider.php | 78 ----- .../Providers/WithdrawServiceProvider.php | 77 ----- modules/Withdraw/README.md | 9 - modules/Withdraw/Resources/assets/js/app.js | 0 .../Withdraw/Resources/assets/sass/app.scss | 0 .../Withdraw/Resources/views/index.blade.php | 9 - .../Resources/views/layouts/master.blade.php | 19 - modules/Withdraw/Routes/admin.php | 13 - modules/Withdraw/Routes/api.php | 15 - modules/Withdraw/Selectable/AccountAble.php | 49 --- modules/Withdraw/Traits/HasWithdraws.php | 50 --- modules/Withdraw/Withdraw.php | 164 --------- modules/Withdraw/composer.json | 21 -- modules/Withdraw/module.json | 15 - modules/Withdraw/提现模块 v3.apifox.json | 1 - 51 files changed, 2195 deletions(-) delete mode 100644 modules/Withdraw/.gitignore delete mode 100644 modules/Withdraw/Config/config.php delete mode 100644 modules/Withdraw/Database/Migrations/0000_00_00_000000_create_banks_table.php delete mode 100644 modules/Withdraw/Database/Migrations/2021_09_26_115830_create_withdraws_table.php delete mode 100644 modules/Withdraw/Database/Migrations/2021_09_26_120338_create_accounts_table.php delete mode 100644 modules/Withdraw/Database/Migrations/2021_09_26_130107_create_configs_table.php delete mode 100644 modules/Withdraw/Database/Migrations/2021_09_27_085100_create_logs_table.php delete mode 100644 modules/Withdraw/Database/Migrations/2021_11_03_142359_create_alipay_accounts_table.php delete mode 100644 modules/Withdraw/Events/WithdrawAuditPass.php delete mode 100644 modules/Withdraw/Events/WithdrawAuditReject.php delete mode 100644 modules/Withdraw/Events/WithdrawEvent.php delete mode 100644 modules/Withdraw/Http/Controllers/Admin/AccountController.php delete mode 100644 modules/Withdraw/Http/Controllers/Admin/Actions/WithdrawAudit.php delete mode 100644 modules/Withdraw/Http/Controllers/Admin/BankController.php delete mode 100644 modules/Withdraw/Http/Controllers/Admin/ConfigController.php delete mode 100644 modules/Withdraw/Http/Controllers/Admin/WithdrawController.php delete mode 100644 modules/Withdraw/Http/Controllers/Api/AccountController.php delete mode 100644 modules/Withdraw/Http/Controllers/Api/IndexController.php delete mode 100644 modules/Withdraw/Http/Requests/UserBankAccountRequest.php delete mode 100644 modules/Withdraw/Http/Requests/UserEditBankAccountRequest.php delete mode 100644 modules/Withdraw/Http/Requests/WithdrawRequest.php delete mode 100644 modules/Withdraw/Http/Resources/Account/UserAlipayAccountCollection.php delete mode 100644 modules/Withdraw/Http/Resources/Account/UserAlipayAccountResource.php delete mode 100644 modules/Withdraw/Http/Resources/Account/UserBankAccountCollection.php delete mode 100644 modules/Withdraw/Http/Resources/Account/UserBankAccountResource.php delete mode 100644 modules/Withdraw/Http/Resources/Bank/BankResource.php delete mode 100644 modules/Withdraw/Http/Resources/Withdraw/WithdrawCollection.php delete mode 100644 modules/Withdraw/Http/Resources/Withdraw/WithdrawResource.php delete mode 100644 modules/Withdraw/Models/Account.php delete mode 100644 modules/Withdraw/Models/AlipayAccount.php delete mode 100644 modules/Withdraw/Models/Bank.php delete mode 100644 modules/Withdraw/Models/Config.php delete mode 100644 modules/Withdraw/Models/Log.php delete mode 100644 modules/Withdraw/Models/Traits/BelongsToBank.php delete mode 100644 modules/Withdraw/Models/Traits/WithdrawActions.php delete mode 100644 modules/Withdraw/Models/Withdraw.php delete mode 100644 modules/Withdraw/Providers/RouteServiceProvider.php delete mode 100644 modules/Withdraw/Providers/WithdrawServiceProvider.php delete mode 100644 modules/Withdraw/README.md delete mode 100644 modules/Withdraw/Resources/assets/js/app.js delete mode 100644 modules/Withdraw/Resources/assets/sass/app.scss delete mode 100644 modules/Withdraw/Resources/views/index.blade.php delete mode 100644 modules/Withdraw/Resources/views/layouts/master.blade.php delete mode 100644 modules/Withdraw/Routes/admin.php delete mode 100644 modules/Withdraw/Routes/api.php delete mode 100644 modules/Withdraw/Selectable/AccountAble.php delete mode 100644 modules/Withdraw/Traits/HasWithdraws.php delete mode 100644 modules/Withdraw/Withdraw.php delete mode 100644 modules/Withdraw/composer.json delete mode 100644 modules/Withdraw/module.json delete mode 100644 modules/Withdraw/提现模块 v3.apifox.json diff --git a/modules/Withdraw/.gitignore b/modules/Withdraw/.gitignore deleted file mode 100644 index 3ce5adb..0000000 --- a/modules/Withdraw/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.idea -vendor diff --git a/modules/Withdraw/Config/config.php b/modules/Withdraw/Config/config.php deleted file mode 100644 index 7e2d19c..0000000 --- a/modules/Withdraw/Config/config.php +++ /dev/null @@ -1,13 +0,0 @@ - '提现模块', - 'is_chain' => false,//提现账户是否是区块链,true 是 false 否 - 'account' => 'coins',//提现账户 - 'withdraw_no_counter_length' => 8, - 'model' => [ - 'account_rules' => Modules\User\Models\AccountRule::class,//规则表 - 'chain_money' => App\Models\DayDataChain::class,//记录金额表 - ], - -]; diff --git a/modules/Withdraw/Database/Migrations/0000_00_00_000000_create_banks_table.php b/modules/Withdraw/Database/Migrations/0000_00_00_000000_create_banks_table.php deleted file mode 100644 index 2980e82..0000000 --- a/modules/Withdraw/Database/Migrations/0000_00_00_000000_create_banks_table.php +++ /dev/null @@ -1,36 +0,0 @@ -id(); - $table->string('name'); - $table->string('cover')->nullable(); - $table->boolean('status'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('withdraw_banks'); - } - -} diff --git a/modules/Withdraw/Database/Migrations/2021_09_26_115830_create_withdraws_table.php b/modules/Withdraw/Database/Migrations/2021_09_26_115830_create_withdraws_table.php deleted file mode 100644 index ef622f2..0000000 --- a/modules/Withdraw/Database/Migrations/2021_09_26_115830_create_withdraws_table.php +++ /dev/null @@ -1,44 +0,0 @@ -id(); - $table->unsignedBigInteger('user_id')->index(); - $table->unsignedBigInteger('bank_account_id')->nullable()->index(); - $table->unsignedBigInteger('alipay_account_id')->nullable()->index(); - $table->string('withdraw_no', 32)->comment('提现单号'); - $table->decimal('amount')->unsigned(0)->comment('提现金额'); - $table->decimal('tax')->unsigned()->comment('手续费'); - $table->decimal('take')->unsigned()->comment('实际到账金额'); - $table->boolean('status'); - $table->boolean('type'); - $table->json('source')->nullable(); - $table->timestamp('paid_at')->nullable()->comment('付款成功时间'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('withdraws'); - } - -} diff --git a/modules/Withdraw/Database/Migrations/2021_09_26_120338_create_accounts_table.php b/modules/Withdraw/Database/Migrations/2021_09_26_120338_create_accounts_table.php deleted file mode 100644 index f4af787..0000000 --- a/modules/Withdraw/Database/Migrations/2021_09_26_120338_create_accounts_table.php +++ /dev/null @@ -1,39 +0,0 @@ -id(); - $table->unsignedBigInteger('user_id'); - $table->unsignedBigInteger('bank_id'); - $table->string('name')->comment('收款人姓名'); - $table->string('no')->comment('银行卡号'); - $table->string('branch_name')->nullable()->comment('支行名称'); - $table->string('mobile')->comment('收款人手机号'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('withdraw_bank_accounts'); - } - -} diff --git a/modules/Withdraw/Database/Migrations/2021_09_26_130107_create_configs_table.php b/modules/Withdraw/Database/Migrations/2021_09_26_130107_create_configs_table.php deleted file mode 100644 index 1e220f3..0000000 --- a/modules/Withdraw/Database/Migrations/2021_09_26_130107_create_configs_table.php +++ /dev/null @@ -1,36 +0,0 @@ -id(); - $table->string('name', 100); - $table->string('slug', 100); - $table->string('value', 100); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('withdraw_configs'); - } - -} diff --git a/modules/Withdraw/Database/Migrations/2021_09_27_085100_create_logs_table.php b/modules/Withdraw/Database/Migrations/2021_09_27_085100_create_logs_table.php deleted file mode 100644 index 1d30043..0000000 --- a/modules/Withdraw/Database/Migrations/2021_09_27_085100_create_logs_table.php +++ /dev/null @@ -1,36 +0,0 @@ -id(); - $table->unsignedBigInteger('withdraw_id')->index(); - $table->boolean('status'); - $table->string('remark')->nullable(); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('withdraw_logs'); - } - -} diff --git a/modules/Withdraw/Database/Migrations/2021_11_03_142359_create_alipay_accounts_table.php b/modules/Withdraw/Database/Migrations/2021_11_03_142359_create_alipay_accounts_table.php deleted file mode 100644 index dcac629..0000000 --- a/modules/Withdraw/Database/Migrations/2021_11_03_142359_create_alipay_accounts_table.php +++ /dev/null @@ -1,37 +0,0 @@ -id(); - $table->unsignedBigInteger('user_id')->index(); - $table->text('name')->comment('支付宝姓名'); - $table->text('identity_type')->comment('标识类型:ALIPAY_USER_ID 支付宝的会员ID,ALIPAY_LOGON_ID:支付宝登录号,支持邮箱和手机号格式'); - $table->text('identity')->comment('支付宝账号'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('withdraw_alipay_accounts'); - } - -} diff --git a/modules/Withdraw/Events/WithdrawAuditPass.php b/modules/Withdraw/Events/WithdrawAuditPass.php deleted file mode 100644 index 46bfc17..0000000 --- a/modules/Withdraw/Events/WithdrawAuditPass.php +++ /dev/null @@ -1,8 +0,0 @@ -withdraw = $withdraw; - } - -} \ No newline at end of file diff --git a/modules/Withdraw/Http/Controllers/Admin/AccountController.php b/modules/Withdraw/Http/Controllers/Admin/AccountController.php deleted file mode 100644 index bc61581..0000000 --- a/modules/Withdraw/Http/Controllers/Admin/AccountController.php +++ /dev/null @@ -1,46 +0,0 @@ -model()->with(['user.info']); - $grid->disableCreateButton(); - $grid->actions(function ($actions) { - $actions->disableDelete(); - $actions->disableView(); - }); - $grid->filter(function (Grid\Filter $filter) { - $filter->column(1 / 2, function (Grid\Filter $filter) { - $filter->like('user.username', '用户账号'); - $filter->like('no', '卡号'); - }); - $filter->column(1 / 2, function (Grid\Filter $filter) { - $filter->like('user.info.nickname', '用户昵称'); - }); - }); - - $grid->column('id', '#ID#'); - $grid->column('用户')->display(function () { - return $this->user->username."({$this->user->info->nickname})"; - }); - - $grid->column('name', '提款人'); - $grid->column('bank.name', '开户行'); - $grid->column('no', '卡号'); - $grid->column('created_at', '创建时间'); - - return $grid; - } - -} \ No newline at end of file diff --git a/modules/Withdraw/Http/Controllers/Admin/Actions/WithdrawAudit.php b/modules/Withdraw/Http/Controllers/Admin/Actions/WithdrawAudit.php deleted file mode 100644 index 5c886c9..0000000 --- a/modules/Withdraw/Http/Controllers/Admin/Actions/WithdrawAudit.php +++ /dev/null @@ -1,48 +0,0 @@ -status; - $remark = $request->remark; - - try { - if ($status == Withdraw::STATUS_PASS) { - $withdraw->pass($remark); - } - if ($status == Withdraw::STATUS_REJECT) { - $withdraw->reject($remark); - } - - return $this->response()->success('操作成功')->refresh(); - } catch (\Exception $e) { - return $this->response()->error($e->getMessage())->refresh(); - } - - } - - public function form(Model $model) - { - $this->select('status', '状态') - ->options([ - Withdraw::STATUS_PASS => '通过', - Withdraw::STATUS_REJECT => '驳回', - ]) - ->required(); - - $this->text('remark', '说明'); - } - -} diff --git a/modules/Withdraw/Http/Controllers/Admin/BankController.php b/modules/Withdraw/Http/Controllers/Admin/BankController.php deleted file mode 100644 index d43f5b4..0000000 --- a/modules/Withdraw/Http/Controllers/Admin/BankController.php +++ /dev/null @@ -1,50 +0,0 @@ -filter(function (Grid\Filter $filter) { - $filter->column(1 / 2, function (Grid\Filter $filter) { - $filter->like('name', '银行名称'); - }); - }); - $grid->column('id', '#ID#'); - $grid->column('cover', '图标')->image('', 60, 60); - $grid->column('name', '银行名称'); - $grid->column('status', '状态')->switch([ - 'on' => ['value' => 1, 'text' => '打开', 'color' => 'success'], - 'off' => ['value' => 0, 'text' => '关闭', 'color' => 'danger'], - ]); - $grid->column('created_at', '创建时间'); - - return $grid; - } - - public function form() - { - $form = new Form(new Bank()); - $this->cover($form); - $form->text('name', '银行名称')->required(); - - $form->switch('status', '是否开启')->default(1); - - return $form; - } - -} \ No newline at end of file diff --git a/modules/Withdraw/Http/Controllers/Admin/ConfigController.php b/modules/Withdraw/Http/Controllers/Admin/ConfigController.php deleted file mode 100644 index 33f77bc..0000000 --- a/modules/Withdraw/Http/Controllers/Admin/ConfigController.php +++ /dev/null @@ -1,40 +0,0 @@ -disableFilter(); - - $grid->column('id', '#ID#'); - $grid->column('name', '名称'); - $grid->column('slug', '别名'); - $grid->column('value', '值'); - $grid->column('created_at', '创建时间'); - - return $grid; - } - - public function form(): Form - { - $form = new Form(new Config()); - $form->text('name', '名称')->required(); - $form->text('slug', '别名')->required(); - $form->text('value', '值')->required(); - - return $form; - } - -} \ No newline at end of file diff --git a/modules/Withdraw/Http/Controllers/Admin/WithdrawController.php b/modules/Withdraw/Http/Controllers/Admin/WithdrawController.php deleted file mode 100644 index eb155b4..0000000 --- a/modules/Withdraw/Http/Controllers/Admin/WithdrawController.php +++ /dev/null @@ -1,74 +0,0 @@ -model()->with(['user.info'])->latest(); - - $grid->disableCreateButton(); - $grid->actions(function ($actions) { - $actions->disableDelete(); - $actions->disableView(); - $actions->disableEdit(); - if ($actions->row->canAudit()) { - $actions->add(new WithdrawAudit()); - } - }); - - $grid->filter(function (Grid\Filter $filter) { - $filter->column(1 / 2, function (Grid\Filter $filter) { - $filter->like('user.username', '账户'); - $filter->equal('status', '状态')->select(Withdraw::STATUS); - $filter->like('bankAccount.branch_name', '开户行'); - }); - $filter->column(1 / 2, function (Grid\Filter $filter) { - $filter->like('user.info.nickname', '昵称'); - $filter->like('bankAccount.no', '卡号'); - }); - - }); - - $grid->column('id', 'ID'); - $grid->column('用户')->display(function () { - return $this->user->username."({$this->user->info->nickname})"; - }); - $grid->column('提现账号') - ->display(function () { - return '查看'; - }) - ->modal('提现账号', AccountAble::class); - $grid->column('amount', '提现金额'); - $grid->column('tax', '手续费'); - $grid->column('take', '实到金额'); - $grid->column('type', '提现类型') - ->using(Withdraw::TYPES) - ->label(Withdraw::TYPES_LABEL); - - $grid->column('status', '状态') - ->using(Withdraw::STATUS) - ->label([ - Withdraw::STATUS_INIT => 'info', - Withdraw::STATUS_PASS => 'success', - Withdraw::STATUS_REJECT => 'danger', - ]); - $grid->column('paid_at', '审核时间'); - $grid->column('source', '备份数据')->hide(); - $grid->column('created_at', '申请时间'); - - return $grid; - } - -} \ No newline at end of file diff --git a/modules/Withdraw/Http/Controllers/Api/AccountController.php b/modules/Withdraw/Http/Controllers/Api/AccountController.php deleted file mode 100644 index 6f4c576..0000000 --- a/modules/Withdraw/Http/Controllers/Api/AccountController.php +++ /dev/null @@ -1,144 +0,0 @@ -where('user_id', $user->id)->paginate(); - - return $this->success(new UserBankAccountCollection($lists)); - } - - /** - * Notes: description - * - * @Author: 玄尘 - * @Date : 2021/9/26 14:09 - * @return JsonResponse - */ - public function create(): JsonResponse - { - $banks = Bank::where('status', Bank::STATUS_OPEN)->get(); - - $data = [ - 'banks' => BankResource::collection($banks), - ]; - - return $this->success($data); - } - - /*** - * Notes: 提交 - * - * @Author: 玄尘 - * @Date : 2021/9/26 14:11 - * @param UserBankAccountRequest $request - * @return JsonResponse|mixed - */ - public function store(UserBankAccountRequest $request) - { - $user = Api::user(); - - try { - $user->bankAccounts()->create([ - 'name' => $request->name, - 'mobile' => $request->mobile, - 'no' => $request->no, - 'branch_name' => $request->branch_name ?? '', - 'bank_id' => $request->bank_id, - ]); - - return $this->success('添加成功'); - } catch (\Exception $exception) { - return $this->failed($exception->getMessage()); - } - } - - /** - * Notes: description - * - * @Author: 玄尘 - * @Date : 2021/9/26 14:23 - * @param Account $account - */ - public function edit(Account $account): JsonResponse - { - $banks = Bank::where('status', Bank::STATUS_OPEN)->get(); - - $data = [ - 'banks' => BankResource::collection($banks), - 'info' => new UserBankAccountResource($account), - ]; - - return $this->success($data); - } - - /** - * Notes: description - * - * @Author: 玄尘 - * @Date : 2021/9/26 14:26 - * @param UserEditBankAccountRequest $request - * @param Account $account - * @return JsonResponse|mixed - */ - public function update(UserEditBankAccountRequest $request, Account $account) - { - try { - $account->update([ - 'name' => $request->name, - 'mobile' => $request->mobile, - 'no' => $request->no, - 'branch_name' => $request->branch_name, - 'bank_id' => $request->bank_id, - ]); - - return $this->success('编辑成功'); - } catch (\Exception $exception) { - return $this->failed($exception->getMessage()); - } - } - - /** - * Notes: 删除 - * - * @Author: 玄尘 - * @Date : 2021/9/26 15:02 - * @param Account $account - * @return JsonResponse - */ - public function destroy(Account $account): JsonResponse - { - $user = Api::user(); - if ($account->user->isNot($user)) { - return $this->failed('您没有权限删除'); - } - $account->delete(); - - return $this->success('删除成功'); - } - -} \ No newline at end of file diff --git a/modules/Withdraw/Http/Controllers/Api/IndexController.php b/modules/Withdraw/Http/Controllers/Api/IndexController.php deleted file mode 100644 index 145f489..0000000 --- a/modules/Withdraw/Http/Controllers/Api/IndexController.php +++ /dev/null @@ -1,155 +0,0 @@ -type ?? 'day'; - $date = $request->date ?? Carbon::now()->format('Y-m-d'); - - $time = Carbon::parse($date); - - switch ($type) { - case 'month': - $timeBetween = [ - $time->startOfMonth()->toDateTimeString(), - $time->endOfMonth()->toDateTimeString(), - ]; - break; - case 'year': - $timeBetween = [ - $time->startOfYear()->toDateTimeString(), - $time->endOfYear()->toDateTimeString(), - ]; - break; - case 'day': - default: - $timeBetween = [ - $time->startOfDay()->toDateTimeString(), - $time->endOfDay()->toDateTimeString(), - ]; - break; - } - - $lists = $user->withdraws() - ->whereBetween('created_at', $timeBetween) - ->latest() - ->paginate(); - - $is_chain = config('withdraw.is_chain', false); - - if ($is_chain) { - $all = floatval($user->getStoneFormatBalance()); - } else { - $account = config('withdraw.account', 'coins'); - $all = $user->account->{$account}; - } - $data = [ - 'all' => $all, - 'lists' => new WithdrawCollection($lists), - ]; - - return $this->success($data); - } - - /** - * Notes: 提现前置 - * - * @Author: 玄尘 - * @Date : 2021/1/21 14:21 - */ - public function create(Request $request): JsonResponse - { - $user = Api::user(); - $is_chain = config('withdraw.is_chain', false); - $bank_account_id = $request->bank_account_id; - $alipay_account_id = $request->alipay_account_id; - if ($bank_account_id) { - $bank_account = $user->bankAccounts()->where('id', $bank_account_id)->first(); - } else { - $bank_account = $user->bankAccounts()->first(); - } - if ($alipay_account_id) { - $alipay_account = $user->alipayAccounts()->where('id', $alipay_account_id)->first(); - } else { - $alipay_account = $user->alipayAccounts()->first(); - } - - $data = [ - 'tax' => Config::getValue('tax', 0), - 'bank_account' => $bank_account ? new UserBankAccountResource($bank_account) : '', - 'alipay_account' => $alipay_account ? new UserAlipayAccountResource($alipay_account) : '', - 'bank_accounts' => UserBankAccountResource::collection($user->bankAccounts), - 'alipay_accounts' => UserAlipayAccountResource::collection($user->alipayAccounts), - 'is_chain' => config('withdraw.is_chain'), - 'certification' => (bool) $user->certification, - 'types' => Withdraw::TYPES, - ]; - - if ($is_chain) { - $data = array_merge($data, [ - 'balance' => floatval($user->getStoneFormatBalance()),//账户余额 - 'cost' => (new DayDataChain())->getStoneValue(),//现金价值 - ]); - } else { - $account = config('withdraw.account'); - $data = array_merge($data, [ - 'balance' => $user->account->{$account},//账户余额 - 'cost' => 1, - ]); - } - - return $this->success($data); - } - - /** - * Notes: 提现 - * - * @Author: 玄尘 - * @Date : 2021/1/21 14:27 - * @param WithdrawRequest $request - * @return JsonResponse|mixed - */ - public function store(WithdrawRequest $request) - { - $user = Api::user(); - - try { -// if (! $user->certification) { -// throw new \Exception('未进行个人认证不可提现'); -// } - - Withdraw::createInfo($user, $request); - - return $this->success('申请提现成功,等待管理员审核'); - } catch (\Exception $e) { - return $this->failed($e->getmessage()); - } - - } - -} \ No newline at end of file diff --git a/modules/Withdraw/Http/Requests/UserBankAccountRequest.php b/modules/Withdraw/Http/Requests/UserBankAccountRequest.php deleted file mode 100644 index 1dbca34..0000000 --- a/modules/Withdraw/Http/Requests/UserBankAccountRequest.php +++ /dev/null @@ -1,35 +0,0 @@ - 'required', - 'no' => ['required', 'unique:withdraw_bank_accounts,no', 'digits_between:16,19'], -// 'branch_name' => 'required', - 'mobile' => 'required', - 'bank_id' => 'required', - ]; - } - - public function messages(): array - { - return [ - 'name.required' => '收款人姓名必须填写', - 'no.required' => '银行卡号必须填写', - 'no.unique' => '此银行卡号已提交过', - 'no.integer' => '银行卡号必须是数字', - 'no.digits_between' => '银行卡号长度必须在:min ~ :max之间', - 'branch_name.required' => '支行名称必须填写', - 'mobile.required' => '收款人手机号必须填写', - 'bank_id.required' => '银行必须选择', - ]; - } - -} \ No newline at end of file diff --git a/modules/Withdraw/Http/Requests/UserEditBankAccountRequest.php b/modules/Withdraw/Http/Requests/UserEditBankAccountRequest.php deleted file mode 100644 index cb63781..0000000 --- a/modules/Withdraw/Http/Requests/UserEditBankAccountRequest.php +++ /dev/null @@ -1,35 +0,0 @@ - 'required', - 'no' => ['required', 'digits_between:16,19'], -// 'branch_name' => 'required', - 'mobile' => 'required', - 'bank_id' => 'required', - ]; - } - - public function messages(): array - { - return [ - 'name.required' => '收款人姓名必须填写', - 'no.required' => '银行卡号必须填写', - 'no.unique' => '此银行卡号已提交过', - 'no.integer' => '银行卡号必须是数字', - 'no.digits_between' => '银行卡号长度必须在:min ~ :max之间', - 'branch_name.required' => '支行名称必须填写', - 'mobile.required' => '收款人手机号必须填写', - 'bank_id.required' => '银行必须选择', - ]; - } - -} \ No newline at end of file diff --git a/modules/Withdraw/Http/Requests/WithdrawRequest.php b/modules/Withdraw/Http/Requests/WithdrawRequest.php deleted file mode 100644 index 8a4ca4a..0000000 --- a/modules/Withdraw/Http/Requests/WithdrawRequest.php +++ /dev/null @@ -1,35 +0,0 @@ - ['required_if:type,1'], - 'name' => ['required_if:type,2'], - 'identity' => ['required_if:type,2'], - 'amount' => 'required|numeric', - 'type' => 'required|numeric', - ]; - } - - public function messages(): array - { - return [ - 'bank_account_id.required_if' => '提现账户必须选择', - 'amount.required' => '提现金额必须选择', - 'amount.numeric' => '提现金额必须填写', - 'type.required' => '提现类型必须选择', - 'type.numeric' => '提现类型必须填写', - 'name.required_if' => '提现人必须填写', - 'identity.required_if' => '支付宝账号必须填写', - - ]; - } - -} \ No newline at end of file diff --git a/modules/Withdraw/Http/Resources/Account/UserAlipayAccountCollection.php b/modules/Withdraw/Http/Resources/Account/UserAlipayAccountCollection.php deleted file mode 100644 index 36d8399..0000000 --- a/modules/Withdraw/Http/Resources/Account/UserAlipayAccountCollection.php +++ /dev/null @@ -1,21 +0,0 @@ - $this->collection->map(function ($info) { - return new UserAlipayAccountResource($info); - }), - 'page' => $this->page(), - ]; - } - -} \ No newline at end of file diff --git a/modules/Withdraw/Http/Resources/Account/UserAlipayAccountResource.php b/modules/Withdraw/Http/Resources/Account/UserAlipayAccountResource.php deleted file mode 100644 index e9576c1..0000000 --- a/modules/Withdraw/Http/Resources/Account/UserAlipayAccountResource.php +++ /dev/null @@ -1,21 +0,0 @@ - $this->id, - 'name' => $this->name, - 'identity_type' => $this->identity_type, - 'identity' => $this->identity, - 'created_at' => (string) $this->created_at, - ]; - } - -} \ No newline at end of file diff --git a/modules/Withdraw/Http/Resources/Account/UserBankAccountCollection.php b/modules/Withdraw/Http/Resources/Account/UserBankAccountCollection.php deleted file mode 100644 index e0f304c..0000000 --- a/modules/Withdraw/Http/Resources/Account/UserBankAccountCollection.php +++ /dev/null @@ -1,21 +0,0 @@ - $this->collection->map(function ($info) { - return new UserBankAccountResource($info); - }), - 'page' => $this->page(), - ]; - } - -} \ No newline at end of file diff --git a/modules/Withdraw/Http/Resources/Account/UserBankAccountResource.php b/modules/Withdraw/Http/Resources/Account/UserBankAccountResource.php deleted file mode 100644 index 1babf44..0000000 --- a/modules/Withdraw/Http/Resources/Account/UserBankAccountResource.php +++ /dev/null @@ -1,27 +0,0 @@ - $this->id, - 'bank' => [ - 'id' => $this->bank_id, - 'name' => $this->bank->name, - 'cover' => $this->bank->cover_url, - ], - 'name' => $this->name, - 'no' => $this->no, - 'branch_name' => $this->branch_name, - 'mobile' => $this->mobile, - 'created_at' => (string) $this->created_at, - ]; - } - -} \ No newline at end of file diff --git a/modules/Withdraw/Http/Resources/Bank/BankResource.php b/modules/Withdraw/Http/Resources/Bank/BankResource.php deleted file mode 100644 index 1199b0e..0000000 --- a/modules/Withdraw/Http/Resources/Bank/BankResource.php +++ /dev/null @@ -1,18 +0,0 @@ - $this->id, - 'name' => $this->name, - ]; - } - -} \ No newline at end of file diff --git a/modules/Withdraw/Http/Resources/Withdraw/WithdrawCollection.php b/modules/Withdraw/Http/Resources/Withdraw/WithdrawCollection.php deleted file mode 100644 index f097654..0000000 --- a/modules/Withdraw/Http/Resources/Withdraw/WithdrawCollection.php +++ /dev/null @@ -1,21 +0,0 @@ - $this->collection->map(function ($info) { - return new WithdrawResource($info); - }), - 'page' => $this->page(), - ]; - } - -} diff --git a/modules/Withdraw/Http/Resources/Withdraw/WithdrawResource.php b/modules/Withdraw/Http/Resources/Withdraw/WithdrawResource.php deleted file mode 100644 index 81752bf..0000000 --- a/modules/Withdraw/Http/Resources/Withdraw/WithdrawResource.php +++ /dev/null @@ -1,30 +0,0 @@ - $this->id, - 'status' => [ - 'status' => $this->status, - 'status_text' => $this->status_text, - ], - 'amount' => $this->amount, - 'tax' => $this->tax, - 'take' => $this->take, - 'payment_at' => (string) $this->payment_at, - 'way' => '红包提现', - 'quantity' => $this->source[config('withdraw.account')] ?? '', - 'source' => $this->source, - - 'create_at' => (string) $this->created_at, - ]; - } - -} diff --git a/modules/Withdraw/Models/Account.php b/modules/Withdraw/Models/Account.php deleted file mode 100644 index 54a76a5..0000000 --- a/modules/Withdraw/Models/Account.php +++ /dev/null @@ -1,15 +0,0 @@ - '支付宝的会员ID', - self::TYPE_LOGONID => '支付宝登录号,支持邮箱和手机号格式', - ]; - -} diff --git a/modules/Withdraw/Models/Bank.php b/modules/Withdraw/Models/Bank.php deleted file mode 100644 index c5ad603..0000000 --- a/modules/Withdraw/Models/Bank.php +++ /dev/null @@ -1,23 +0,0 @@ - '开启', - self::STATUS_CLOSE => '关闭', - ]; - -} diff --git a/modules/Withdraw/Models/Config.php b/modules/Withdraw/Models/Config.php deleted file mode 100644 index 2e65a5d..0000000 --- a/modules/Withdraw/Models/Config.php +++ /dev/null @@ -1,23 +0,0 @@ -where('slug', $slug)->first(); - - if ($info) { - return $info->value; - } else { - return $default; - } - } - -} diff --git a/modules/Withdraw/Models/Log.php b/modules/Withdraw/Models/Log.php deleted file mode 100644 index 0293d7b..0000000 --- a/modules/Withdraw/Models/Log.php +++ /dev/null @@ -1,12 +0,0 @@ -belongsTo(Bank::class); - } - -} \ No newline at end of file diff --git a/modules/Withdraw/Models/Traits/WithdrawActions.php b/modules/Withdraw/Models/Traits/WithdrawActions.php deleted file mode 100644 index d2b81ac..0000000 --- a/modules/Withdraw/Models/Traits/WithdrawActions.php +++ /dev/null @@ -1,326 +0,0 @@ -canAudit()) { - throw new \Exception('该提现记录已经被审核'); - } - - try { - if ($this->type == self::TYPE_ALIPAY) { - - if (! $this->alipayAccount) { - throw new \Exception('未找到支付宝账户'); - } - - $allPlugins = Pay::alipay() - ->mergeCommonPlugins([TransUniTransferPlugin::class]); - - $params = [ - 'out_biz_no' => $this->withdraw_no, - 'trans_amount' => $this->take, - 'payee_info' => [ - 'identity' => $this->alipayAccount->identity, - 'identity_type' => $this->alipayAccount->identity_type, - 'name' => $this->alipayAccount->name, - ], - ]; - - $res = Pay::alipay($this->getPayConfig('alipay'))->pay($allPlugins, $params); - if ($res->code != 10000) { - throw new \Exception($res->sub_msg); - } - - } - - DB::transaction(function () use ($remark) { - $this->status = Withdraw::STATUS_PASS; - $this->paid_at = now(); - $this->save(); - }); - - $this->addLog(Withdraw::STATUS_INIT, $remark); - - event(new WithdrawAuditPass($this)); - - return true; - } catch (\Exception $e) { - throw new \Exception($e->getMessage()); - } - } - - /** - * Notes: 驳回 - * - * @Author: 玄尘 - * @Date : 2021/9/26 15:21 - * @param string $remark - * @return bool - * @throws \Exception - */ - public function reject(string $remark = ''): bool - { - if (! $this->canAudit()) { - throw new \Exception('该提现记录已经被审核'); - } - - try { - DB::transaction(function () use ($remark) { - $this->status = Withdraw::STATUS_REJECT; - $this->paid_at = now(); - $this->save(); - - $is_chain = config('withdraw.is_chain', false); - - if (! $is_chain) { - $this->user->account->rule('withdraw_in', $this->amount, false, [ - 'withdraw_id' => $this->id, - ]); - } else { - $hash = $this->rejectPick(); - $source = [ - 'reject_hash' => $hash, - ]; - - $this->update(['source' => $source]); - } - - $this->addLog(Withdraw::STATUS_REJECT, $remark); - - event(new WithdrawAuditReject($this)); - - }); - - return true; - } catch (\Exception $e) { - throw new \Exception($e->getMessage()); - } - } - - /** - * Notes: 添加记录 - * - * @Author: 玄尘 - * @Date : 2021/9/27 8:56 - * @param $status - * @param string $remark - * @return bool - */ - public function addLog($status, string $remark = ''): bool - { - $this->logs()->create([ - 'status' => $status, - 'remark' => $remark, - ]); - - return true; - } - - /** - * Notes: 创建提现信息 - * - * @Author: 玄尘 - * @Date : 2021/9/27 10:14 - */ - public static function createInfo($user, $params): bool - { - try { - DB::transaction(function () use ($user, $params) { - - $type = $params->type ?? 0; - $bank_account_id = $params->bank_account_id ?? 0; - $amount = $params->amount; - - $account_name = config('withdraw.account'); - $source = [ - $account_name => $amount, - ]; - - $cash = $amount; - - $is_chain = config('withdraw.is_chain', false); - - $balance = $is_chain ? $user->getStoneBalance() : $user->account->{$account_name}; - - if ($amount > $balance) { - throw new \Exception('提现失败,余额不足'); - } - - if ($is_chain) { - $cost = (new DayDataChain())->getStoneValue(); - $cash = bcmul($cost, $amount, 2); - $source = array_merge($source, ['cost' => $cost,]); - } - - $withdraw_min = Config::getValue('min', 1); - - if ($withdraw_min > 0 && $cash < $withdraw_min) { - throw new \Exception("提现失败,提现金额必须大于等于{$withdraw_min}"); - } - - $tax_value = Config::getValue('tax', 0); - - $tax = $tax_value ? round($cash * $tax_value / 100, 2) : 0; - $take = $cash - $tax; - - if ($type == Withdraw::TYPE_BANK) { - $bank_account = Account::find($bank_account_id); - if (! $bank_account) { - throw new \Exception('提现失败,未找到提现账户信息'); - } - - if ($bank_account->user->isNot($user)) { - throw new \Exception('提现失败,您不可使用此提现账户'); - } - - $info = $user->withdraws()->create([ - 'bank_account_id' => $bank_account_id, - 'amount' => $cash, - 'tax' => $tax, //手续费 - 'take' => $take, //实到金额 - 'source' => $source, - 'type' => Withdraw::TYPE_BANK, - ]); - } else { - $alipay_account = $user->alipayAccounts()->create([ - 'name' => $params->name, - 'identity' => $params->identity, - 'identity_type' => 'ALIPAY_LOGON_ID', - ]); - - $info = $user->withdraws()->create([ - 'alipay_account_id' => $alipay_account->id, - 'amount' => $cash, - 'tax' => $tax, //手续费 - 'take' => $take, //实到金额 - 'source' => $source, - 'type' => Withdraw::TYPE_ALIPAY, - ]); - } - - if (! $is_chain) { - $user->account->rule('withdraw_out', -$cash, false, [ - 'withdraw_id' => $info->id, - ]); - } else { - $hash = $info->pick();//转到代持账户 - $source = array_merge($source, ['hash' => $hash,]); - - $info->update(['source' => $source]); - } - }); - - return true; - } catch (\Exception $e) { - throw new \Exception($e->getMessage()); - } - } - - /** - * Notes: 申请提现时将提现金额转入代持账户 - * - * @Author: 玄尘 - * @Date : 2021/9/27 10:34 - * @return string - * @throws \Exception - */ - public function pick(): string - { - $to_address = Config::getValue('withdraw_addr', ''); - - if (! $to_address) { - throw new \Exception('提现失败,缺少代持账户信息,请管理人员配置代持账户。'); - } - - $number = $this->source['coins'] ?? 0; - if (! $number) { - throw new \Exception('提现数据错误'); - } - - $from_address = $this->user->blockChain->address; - $balance = coinsFormat(Chain33::Balance()->get($from_address)['balance']); - - if ($number > $balance) { - throw new \Exception('提现失败,数量不足'); - } - - try { - $fromAddr = Address::where('address', $from_address)->first(); - - return Chain33::Transaction() - ->coins($to_address, $number * 1e8, $fromAddr->private_key, 0, '用户提现'); - - } catch (\Exception $e) { - throw new \Exception($e->getMessage()); - } - } - - /** - * Notes: description - * - * @Author: 玄尘 - * @Date : 2021/9/27 14:45 - * @return string - * @throws \Exception - */ - public function rejectPick(): string - { - $from_address = Config::getValue('withdraw_addr', ''); - - if (! $from_address) { - throw new \Exception('提现失败,缺少代持账户信息,请管理人员配置代持账户。'); - } - - $number = $this->source['coins'] ?? 0; - if (! $number) { - throw new \Exception('提现数据错误'); - } - - $to_address = $this->user->blockChain->address; - $balance = coinsFormat(Chain33::Balance()->get($from_address)['balance']); - - if ($number > $balance) { - throw new \Exception('驳回失败,代持账户数量不足'); - } - - try { - $fromAddr = Address::where('address', $from_address)->first(); - - return Chain33::Transaction() - ->coins($to_address, $number * 1e8, $fromAddr->private_key, 0, '驳回提现'); - - } catch (\Exception $e) { - throw new \Exception($e->getMessage()); - } - } - -} \ No newline at end of file diff --git a/modules/Withdraw/Models/Withdraw.php b/modules/Withdraw/Models/Withdraw.php deleted file mode 100644 index c8ee7e9..0000000 --- a/modules/Withdraw/Models/Withdraw.php +++ /dev/null @@ -1,126 +0,0 @@ - '待审核', - self::STATUS_PASS => '通过', - self::STATUS_REJECT => '驳回', - ]; - - const TYPE_BANK = 1; - const TYPE_ALIPAY = 2; - - const TYPES = [ - self::TYPE_BANK => '银行卡', - self::TYPE_ALIPAY => '支付宝', - ]; - - const TYPES_LABEL = [ - self::TYPE_BANK => 'primary', - self::TYPE_ALIPAY => 'success', - ]; - - protected $casts = [ - 'source' => 'json', - ]; - - public static function boot() - { - parent::boot(); - - self::creating(function ($model) { - $time = explode(' ', microtime()); - - $counter = $model->whereDate('created_at', Carbon::today())->count() + 1; - - $len = config('withdraw.withdraw_no_counter_length'); - - $len = $len < 6 ? 6 : $len; - $len = $len > 16 ? 16 : $len; - - $model->withdraw_no = date('YmdHis'). - sprintf('%06d', $time[0] * 1e6). - sprintf('%0'.$len.'d', $counter); - - $model->status = self::STATUS_INIT; - }); - } - - /** - * Notes: 关联银行账号 - * - * @Author: 玄尘 - * @Date : 2021/9/27 8:39 - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo - */ - public function bankAccount(): BelongsTo - { - return $this->belongsTo(Account::class); - } - - /** - * Notes: 支付宝账号 - * - * @Author: 玄尘 - * @Date : 2021/11/3 15:58 - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo - */ - public function alipayAccount(): BelongsTo - { - return $this->belongsTo(AlipayAccount::class); - } - - /** - * Notes: 提现状态 - * - * @Author: 玄尘 - * @Date : 2021/9/26 15:06 - * @return string - */ - public function getStatusTextAttribute(): string - { - return self::STATUS[$this->status] ?? '未知'; - } - - /** - * Notes: 是否可以审核 - * - * @Author: 玄尘 - * @Date : 2021/9/26 15:06 - * @return bool - */ - public function canAudit(): bool - { - return $this->status == self::STATUS_INIT; - } - - /** - * Notes: 操作记录 - * - * @Author: 玄尘 - * @Date : 2021/9/27 8:53 - * @return \Illuminate\Database\Eloquent\Relations\HasMany - */ - public function logs(): HasMany - { - return $this->hasMany(Log::class); - } - -} diff --git a/modules/Withdraw/Providers/RouteServiceProvider.php b/modules/Withdraw/Providers/RouteServiceProvider.php deleted file mode 100644 index 7ae1c02..0000000 --- a/modules/Withdraw/Providers/RouteServiceProvider.php +++ /dev/null @@ -1,78 +0,0 @@ -mapApiRoutes(); - - $this->mapAdminRoutes(); - } - - /** - * Define the "web" routes for the application. - * These routes all receive session state, CSRF protection, etc. - * - * @return void - */ - protected function mapAdminRoutes() - { - Route::as(config('admin.route.as')) - ->domain(config('admin.route.domain')) - ->middleware(config('admin.route.middleware')) - ->namespace($this->moduleNamespace.'\\Admin') - ->prefix(config('admin.route.prefix')) - ->group(module_path($this->moduleName, 'Routes/admin.php')); - } - - /** - * Define the "api" routes for the application. - * These routes are typically stateless. - * - * @return void - */ - protected function mapApiRoutes() - { - Route::as(config('api.route.as')) - ->domain(config('api.route.domain')) - ->middleware(config('api.route.middleware')) - ->namespace($this->moduleNamespace.'\\Api') - ->prefix(config('api.route.prefix').'/withdraws') - ->group(module_path($this->moduleName, 'Routes/api.php')); - } - -} diff --git a/modules/Withdraw/Providers/WithdrawServiceProvider.php b/modules/Withdraw/Providers/WithdrawServiceProvider.php deleted file mode 100644 index 6106710..0000000 --- a/modules/Withdraw/Providers/WithdrawServiceProvider.php +++ /dev/null @@ -1,77 +0,0 @@ -registerConfig(); - $this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations')); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - $this->app->register(RouteServiceProvider::class); - - $models = config('withdraw.model'); - if ($models) { - foreach ($models as $key => $model) { - $this->app->bind('withdraw.model.'.$key, function ($app) use ($model) { - return (new $model); - }); - } - } - } - - /** - * Register config. - * - * @return void - */ - protected function registerConfig() - { - $this->publishes([ - module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower.'.php'), - ], 'withdraw-config'); - - $this->mergeConfigFrom( - module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower - ); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return []; - } - -} diff --git a/modules/Withdraw/README.md b/modules/Withdraw/README.md deleted file mode 100644 index 34be6ee..0000000 --- a/modules/Withdraw/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# 提现模块 - -> 1、先发布资源 - -> 2、启用模块 - -> 3、修改配置里的 account 提现账户 - -> 4、修改提现账变规则对应的账户 diff --git a/modules/Withdraw/Resources/assets/js/app.js b/modules/Withdraw/Resources/assets/js/app.js deleted file mode 100644 index e69de29..0000000 diff --git a/modules/Withdraw/Resources/assets/sass/app.scss b/modules/Withdraw/Resources/assets/sass/app.scss deleted file mode 100644 index e69de29..0000000 diff --git a/modules/Withdraw/Resources/views/index.blade.php b/modules/Withdraw/Resources/views/index.blade.php deleted file mode 100644 index cf8ed5d..0000000 --- a/modules/Withdraw/Resources/views/index.blade.php +++ /dev/null @@ -1,9 +0,0 @@ -@extends('withdraw::layouts.master') - -@section('content') -
- This view is loaded from module: {!! config('withdraw.name') !!} -
-@endsection diff --git a/modules/Withdraw/Resources/views/layouts/master.blade.php b/modules/Withdraw/Resources/views/layouts/master.blade.php deleted file mode 100644 index 2db20c8..0000000 --- a/modules/Withdraw/Resources/views/layouts/master.blade.php +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - -