- 基础环境:Docker 部署配置,源码挂载实时同步 - 修复:super_admin 权限补全、登录重定向循环 - 开发:店铺营销账户账单 - 抖音账户(15字段汇总账单) - 开发:店铺营销账户账单 - 淘系支付宝账户(8字段流水账单) - 开发:店铺营销账户账单 - 拼多多账户(7字段流水账单) - 业务页面导航集成:config/business_navigation.php + Business\Pages 控制器 - 各平台独立表结构和视图,互不影响
86 lines
2.0 KiB
PHP
86 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace Modules\OfflinePayments\Jobs;
|
|
|
|
use App\Abstracts\Job;
|
|
use App\Utilities\Modules;
|
|
use App\Models\Banking\Transaction;
|
|
use App\Models\Banking\Transfer;
|
|
|
|
class DeletePaymentMethod extends Job
|
|
{
|
|
protected $request;
|
|
|
|
/**
|
|
* Create a new job instance.
|
|
*
|
|
* @param $request
|
|
*/
|
|
public function __construct($request)
|
|
{
|
|
$this->request = $this->getRequestInstance($request);
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function handle()
|
|
{
|
|
$this->authorize();
|
|
|
|
$methods = json_decode(setting('offline-payments.methods'), true);
|
|
|
|
$payment_method = [];
|
|
|
|
$code = $this->request->get('code');
|
|
|
|
foreach ($methods as $key => $method) {
|
|
if ($method['code'] != $code) {
|
|
continue;
|
|
}
|
|
|
|
$payment_method = $methods[$key];
|
|
|
|
unset($methods[$key]);
|
|
}
|
|
|
|
setting()->set('offline-payments.methods', json_encode($methods));
|
|
|
|
setting()->save();
|
|
|
|
Modules::clearPaymentMethodsCache();
|
|
|
|
return $payment_method;
|
|
}
|
|
|
|
/**
|
|
* Determine if this action is applicable.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function authorize()
|
|
{
|
|
if ($relationships = $this->getRelationships()) {
|
|
$methods = json_decode(setting('offline-payments.methods'), true);
|
|
$method = $methods[array_search($this->request->get('code'), array_column($methods, 'code'))];
|
|
|
|
$message = trans('messages.warning.deleted', ['name' => $method['name'], 'text' => implode(', ', $relationships)]);
|
|
|
|
throw new \Exception($message);
|
|
}
|
|
}
|
|
|
|
public function getRelationships()
|
|
{
|
|
$counter = [];
|
|
|
|
if ($transaction_count = Transaction::where('payment_method', $this->request->get('code'))->count()) {
|
|
$counter[] = $transaction_count . ' ' . strtolower(trans_choice('general.transactions', ($transaction_count > 1) ? 2 : 1));
|
|
}
|
|
|
|
return $counter;
|
|
}
|
|
}
|