From 17e2aeb42e02f3db3c3e126bf9b50337d5760a0a Mon Sep 17 00:00:00 2001 From: vine_liutk <961510893@qq.com> Date: Sat, 15 Jan 2022 16:42:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=B7=BB=E5=8A=A0=E5=85=AC?= =?UTF-8?q?=E5=8F=B8=E6=94=B6=E6=AC=BE=E4=BF=A1=E6=81=AF=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/SettingController.php | 17 ++++ app/Admin/Forms/Settings/Dealer.php | 89 +++++++++++++++++++++ app/Models/DealerOrder.php | 3 + database/seeders/AppSettingSeeder.php | 39 +++++++++ 4 files changed, 148 insertions(+) create mode 100644 app/Admin/Forms/Settings/Dealer.php diff --git a/app/Admin/Controllers/SettingController.php b/app/Admin/Controllers/SettingController.php index 37e074da..2992a683 100644 --- a/app/Admin/Controllers/SettingController.php +++ b/app/Admin/Controllers/SettingController.php @@ -4,6 +4,7 @@ namespace App\Admin\Controllers; use App\Admin\Forms\Settings\Android; use App\Admin\Forms\Settings\App; +use App\Admin\Forms\Settings\Dealer; use App\Admin\Forms\Settings\Distribution; use App\Admin\Forms\Settings\Ios; use App\Admin\Forms\Settings\Kuaidi100; @@ -111,6 +112,7 @@ class SettingController extends AdminController 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'])); @@ -120,6 +122,17 @@ class SettingController extends AdminController 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'])); + 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'])); @@ -129,6 +142,7 @@ class SettingController extends AdminController 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'])); @@ -138,6 +152,7 @@ class SettingController extends AdminController 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'])); @@ -147,6 +162,7 @@ class SettingController extends AdminController 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); @@ -156,6 +172,7 @@ class SettingController extends AdminController 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'])); diff --git a/app/Admin/Forms/Settings/Dealer.php b/app/Admin/Forms/Settings/Dealer.php new file mode 100644 index 00000000..bb653bfe --- /dev/null +++ b/app/Admin/Forms/Settings/Dealer.php @@ -0,0 +1,89 @@ +updateOrCreate([ + 'key' => 'dealer', + ], ['value' => $input]); + + //清配置缓存 + app(SettingService::class)->cleanCache('dealer'); + + return $this + ->response() + ->success('配置更新成功!') + ->refresh(); + } + + /** + * Build a form here. + */ + public function form() + { + $this->currency('fee_rate', '手续费比例(百分比)')->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 [ + 'fee_rate'=>$dealerSettings['fee_rate'] ?? '', + 'bank'=>$dealerSettings['bank'] ?? [], + 'alipay'=>$dealerSettings['alipay'] ?? [], + 'wechat' =>$dealerSettings['wechat'] ?? [], + 'purchase_rules'=>$dealerSettings['purchase_rules'] ?? [], + ]; + } +} diff --git a/app/Models/DealerOrder.php b/app/Models/DealerOrder.php index 88157f65..fd7116d6 100644 --- a/app/Models/DealerOrder.php +++ b/app/Models/DealerOrder.php @@ -220,6 +220,9 @@ class DealerOrder extends Model } else { $payInfo = [ //todo-公司的收款信息 + 'bank'=>app_settings('dealer.bank'), + 'alipay'=>app_settings('dealer.alipay'), + 'wechat'=>app_settings('dealer.wechat'), ]; } } elseif ($this->isPending() || $this->isCancelled()) {//如果是已取消订单或者待确认订单不显示收款信息 diff --git a/database/seeders/AppSettingSeeder.php b/database/seeders/AppSettingSeeder.php index 2985e00d..2cd40406 100644 --- a/database/seeders/AppSettingSeeder.php +++ b/database/seeders/AppSettingSeeder.php @@ -176,6 +176,45 @@ class AppSettingSeeder extends Seeder 'dealer' => [ 'value' => [ 'fee_rate' => '6', // 手续费比例(百分比) + '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' => '经销商配置', ],