167 lines
9.7 KiB
PHP
167 lines
9.7 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Forms\Settings;
|
|
|
|
use App\Enums\DealerLvl;
|
|
use App\Models\Setting;
|
|
use App\Services\SettingService;
|
|
use Carbon\Carbon;
|
|
use Dcat\Admin\Widgets\Form;
|
|
|
|
class Dealer extends Form
|
|
{
|
|
/**
|
|
* Handle the form request.
|
|
*
|
|
* @param array $input
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function handle(array $input)
|
|
{
|
|
// dd($input);
|
|
Setting::where('key', 'dealer')->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'] ?? [],
|
|
];
|
|
}
|
|
}
|