添加会员奖励配置
parent
52c4beb374
commit
89252298ad
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Forms\Settings\App;
|
||||
use App\Admin\Forms\Settings\Distribution;
|
||||
use App\Admin\Forms\Settings\Kuaidi100;
|
||||
use App\Admin\Forms\Settings\Unipush;
|
||||
use App\Admin\Repositories\Setting;
|
||||
|
|
@ -108,16 +109,25 @@ class SettingController extends AdminController
|
|||
$tab->add('系统配置', new App(), true);
|
||||
$tab->addLink('快递100配置', admin_route('settings.index', ['type'=>'kuaidi100']));
|
||||
$tab->addLink('Uni-push配置', admin_route('settings.index', ['type'=>'unipush']));
|
||||
$tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution']));
|
||||
break;
|
||||
case 'kuaidi100':
|
||||
$tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app']));
|
||||
$tab->add('快递100配置', new Kuaidi100(), true);
|
||||
$tab->addLink('Uni-push配置', admin_route('settings.index', ['type'=>'unipush']));
|
||||
$tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution']));
|
||||
break;
|
||||
case 'unipush':
|
||||
$tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app']));
|
||||
$tab->addLink('快递100配置', admin_route('settings.index', ['type'=>'kuaidi100']));
|
||||
$tab->add('Uni-push配置', new Unipush(), true);
|
||||
$tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution']));
|
||||
break;
|
||||
case 'distribution':
|
||||
$tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app']));
|
||||
$tab->addLink('快递100配置', admin_route('settings.index', ['type'=>'kuaidi100']));
|
||||
$tab->addLink('Uni-push配置', admin_route('settings.index', ['type'=>'unipush']));
|
||||
$tab->add('会员奖励配置', new Distribution(), true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace App\Admin\Forms\Settings;
|
|||
|
||||
use App\Models\ArticleCategory;
|
||||
use App\Models\Setting;
|
||||
use App\Services\SettingService;
|
||||
use Dcat\Admin\Widgets\Form;
|
||||
|
||||
class App extends Form
|
||||
|
|
@ -21,6 +22,9 @@ class App extends Form
|
|||
'key' => 'app',
|
||||
], ['value' => $input]);
|
||||
|
||||
//清配置缓存
|
||||
app(SettingService::class)->cleanCache('app');
|
||||
|
||||
return $this
|
||||
->response()
|
||||
->success('配置更新成功!')
|
||||
|
|
|
|||
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Forms\Settings;
|
||||
|
||||
use App\Models\Setting;
|
||||
use App\Services\SettingService;
|
||||
use Dcat\Admin\Widgets\Form;
|
||||
|
||||
class Distribution extends Form
|
||||
{
|
||||
/**
|
||||
* Handle the form request.
|
||||
*
|
||||
* @param array $input
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(array $input)
|
||||
{
|
||||
Setting::where('key', 'distribution')->updateOrCreate([
|
||||
'key' => 'distribution',
|
||||
], ['value' => $input]);
|
||||
|
||||
//清配置缓存
|
||||
app(SettingService::class)->cleanCache('distribution');
|
||||
|
||||
return $this
|
||||
->response()
|
||||
->success('配置更新成功!')
|
||||
->refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a form here.
|
||||
*/
|
||||
public function form()
|
||||
{
|
||||
$appSettings = (array) Setting::where('key', 'distribution')->value('value');
|
||||
|
||||
// dd(config('distribution'), app_settings('distribution'));
|
||||
|
||||
$this->currency('price_diff_fee_rate', '会员差价手续费')->value($appSettings['price_diff_fee_rate'] ?? 0)->symbol('%');
|
||||
$this->currency('lvl_same_bonus_fee_rate', '平级奖励手续费')->value($appSettings['lvl_same_bonus_fee_rate'] ?? 0)->symbol('%');
|
||||
$this->currency('lvl_diff_bonus_fee_rate', '级差奖励手续费')->value($appSettings['lvl_diff_bonus_fee_rate'] ?? 0)->symbol('%');
|
||||
// $this->divider();
|
||||
$this->table('rules', '规则', function ($table) {
|
||||
$table->hidden('lv_key');
|
||||
$table->text('lv_name_show', '等级名称')->disable();
|
||||
$table->hidden('lv_name');
|
||||
$table->currency('lvl_same_bonus_rate', '平级奖励比例')->symbol('%');
|
||||
$table->currency('lvl_diff_bonus_rate', '级差奖励比例')->symbol('%');
|
||||
})->customFormat(function ($v) use ($appSettings) {
|
||||
$_rules = $appSettings['rules'] ?? [];
|
||||
if ($_rules) {
|
||||
foreach ($_rules as $key => &$rule) {
|
||||
$rule['lv_key'] = $key;
|
||||
$rule['lv_name_show'] = $rule['lv_name'];
|
||||
}
|
||||
}
|
||||
return $_rules;
|
||||
})->saving(function ($v) {
|
||||
return collect($v)->keyBy('lv_key')->toArray();
|
||||
})->disableCreate()->disableDelete();
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Admin\Forms\Settings;
|
||||
|
||||
use App\Models\Setting;
|
||||
use App\Services\SettingService;
|
||||
use Dcat\Admin\Widgets\Form;
|
||||
|
||||
class Kuaidi100 extends Form
|
||||
|
|
@ -20,6 +21,9 @@ class Kuaidi100 extends Form
|
|||
'key' => 'kuaidi100',
|
||||
], ['value' => $input]);
|
||||
|
||||
//清配置缓存
|
||||
app(SettingService::class)->cleanCache('kuaidi100');
|
||||
|
||||
return $this
|
||||
->response()
|
||||
->success('配置更新成功!')
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Admin\Forms\Settings;
|
||||
|
||||
use App\Models\Setting;
|
||||
use App\Services\SettingService;
|
||||
use Dcat\Admin\Widgets\Form;
|
||||
|
||||
class Unipush extends Form
|
||||
|
|
@ -20,6 +21,9 @@ class Unipush extends Form
|
|||
'key' => 'unipush',
|
||||
], ['value' => $input]);
|
||||
|
||||
//清配置缓存
|
||||
app(SettingService::class)->cleanCache('unipush');
|
||||
|
||||
return $this
|
||||
->response()
|
||||
->success('配置更新成功!')
|
||||
|
|
|
|||
|
|
@ -497,6 +497,6 @@ class DistributionPreIncomeJobService
|
|||
*/
|
||||
protected function getConfig(): array
|
||||
{
|
||||
return config('distribution');
|
||||
return app_settings('distribution');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,8 +44,11 @@ class SettingService
|
|||
$this->items[$key] = $this->cache->remember($this->cacheKey($key), $this->ttl, function () use ($key) {
|
||||
$_key = $this->keyHandle($key);
|
||||
$settings = Setting::where('key', $_key[0])->firstOrFail();
|
||||
|
||||
return Arr::get($settings->value, $_key[1]);
|
||||
if (isset($_key[1])) {
|
||||
return Arr::get($settings->value, $_key[1]);
|
||||
} else {
|
||||
return $settings->value;
|
||||
}
|
||||
});
|
||||
} catch (ModelNotFoundException $e) {
|
||||
return $default;
|
||||
|
|
|
|||
|
|
@ -61,6 +61,76 @@ class AppSettingSeeder extends Seeder
|
|||
],
|
||||
'remarks' => '个推配置',
|
||||
],
|
||||
'distribution' => [
|
||||
'value' => [
|
||||
// 会员差价手续费
|
||||
'price_diff_fee_rate' => '0.23',
|
||||
// 平级奖励手续费
|
||||
'lvl_same_bonus_fee_rate' => '0',
|
||||
// 级差奖励手续费
|
||||
'lvl_diff_bonus_fee_rate' => '0.10',
|
||||
|
||||
// 代理等级分润规则
|
||||
'rules' => [
|
||||
// 平民(粉丝)
|
||||
'civilian' => [
|
||||
'lvl_same_bonus_rate' => '0', // 平级奖励比例
|
||||
'lvl_diff_bonus_rate' => '0', // 级差奖励比例
|
||||
'lv_name' => '粉丝',
|
||||
],
|
||||
|
||||
// 店铺
|
||||
'vip' => [
|
||||
'lvl_same_bonus_rate' => '0', // 平级奖励比例
|
||||
'lvl_diff_bonus_rate' => '0.02', // 级差奖励比例
|
||||
'lv_name' => '店铺',
|
||||
],
|
||||
|
||||
// 社区
|
||||
'community' => [
|
||||
'lvl_same_bonus_rate' => '0.01', // 平级奖励比例
|
||||
'lvl_diff_bonus_rate' => '0.10', // 级差奖励比例
|
||||
'lv_name' => '社区',
|
||||
],
|
||||
|
||||
// 区级
|
||||
'district' => [
|
||||
'lvl_same_bonus_rate' => '0.02', // 平级奖励比例
|
||||
'lvl_diff_bonus_rate' => '0.19', // 级差奖励比例
|
||||
'lv_name' => '区级',
|
||||
],
|
||||
|
||||
// 市级
|
||||
'city' => [
|
||||
'lvl_same_bonus_rate' => '0.01', // 平级奖励比例
|
||||
'lvl_diff_bonus_rate' => '0.32', // 级差奖励比例
|
||||
'lv_name' => '市级',
|
||||
],
|
||||
|
||||
// 省级
|
||||
'province' => [
|
||||
'lvl_same_bonus_rate' => '0.01', // 平级奖励比例
|
||||
'lvl_diff_bonus_rate' => '0.42', // 级差奖励比例
|
||||
'lv_name' => '省级',
|
||||
],
|
||||
|
||||
// 分公司
|
||||
'branch' => [
|
||||
'lvl_same_bonus_rate' => '0.01', // 平级奖励比例
|
||||
'lvl_diff_bonus_rate' => '0.48', // 级差奖励比例
|
||||
'lv_name' => '分公司',
|
||||
],
|
||||
|
||||
// 董事
|
||||
'director' => [
|
||||
'lvl_same_bonus_rate' => '0.01', // 平级奖励比例
|
||||
'lvl_diff_bonus_rate' => '0.50', // 级差奖励
|
||||
'lv_name' => '董事',
|
||||
],
|
||||
],
|
||||
],
|
||||
'remarks' => '会员奖励配置',
|
||||
],
|
||||
] as $key => $values) {
|
||||
Setting::firstOrCreate(['key' => $key], $values);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue