6
0
Fork 0

添加APP开关配置

release
vine_liutk 2021-12-28 21:04:13 +08:00
parent 89252298ad
commit 93795a8c40
6 changed files with 199 additions and 3 deletions

View File

@ -2,8 +2,10 @@
namespace App\Admin\Controllers;
use App\Admin\Forms\Settings\Android;
use App\Admin\Forms\Settings\App;
use App\Admin\Forms\Settings\Distribution;
use App\Admin\Forms\Settings\Ios;
use App\Admin\Forms\Settings\Kuaidi100;
use App\Admin\Forms\Settings\Unipush;
use App\Admin\Repositories\Setting;
@ -107,27 +109,51 @@ class SettingController extends AdminController
switch ($type) {
case 'app':
$tab->add('系统配置', new App(), true);
$tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution']));
$tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios']));
$tab->addLink('Android配置', admin_route('settings.index', ['type'=>'ios']));
$tab->addLink('快递100配置', admin_route('settings.index', ['type'=>'kuaidi100']));
$tab->addLink('Uni-push配置', admin_route('settings.index', ['type'=>'unipush']));
break;
case 'ios':
$tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app']));
$tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution']));
$tab->add('Ios配置', new Ios(), true);
$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 'android':
$tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app']));
$tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution']));
$tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios']));
$tab->add('Android配置', new Android(), true);
$tab->addLink('快递100配置', admin_route('settings.index', ['type'=>'kuaidi100']));
$tab->addLink('Uni-push配置', admin_route('settings.index', ['type'=>'unipush']));
break;
case 'kuaidi100':
$tab->addLink('系统配置', admin_route('settings.index', ['type'=>'app']));
$tab->addLink('会员奖励配置', admin_route('settings.index', ['type'=>'distribution']));
$tab->addLink('Ios配置', admin_route('settings.index', ['type'=>'ios']));
$tab->addLink('Android配置', admin_route('settings.index', ['type'=>'android']));
$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('会员奖励配置', admin_route('settings.index', ['type'=>'distribution']));
$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->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->add('会员奖励配置', new Distribution(), true);
$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']));
$tab->add('会员奖励配置', new Distribution(), true);
break;
default:
break;

View File

@ -0,0 +1,57 @@
<?php
namespace App\Admin\Forms\Settings;
use App\Models\Order;
use App\Models\Setting;
use App\Services\SettingService;
use Dcat\Admin\Widgets\Form;
class Android extends Form
{
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
Setting::where('key', 'android')->updateOrCreate([
'key' => 'android',
], ['value' => $input]);
//清配置缓存
app(SettingService::class)->cleanCache('android');
return $this
->response()
->success('配置更新成功!')
->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$appSettings = Setting::where('key', 'android')->value('value');
$this->number('v', '版本号')->min(0)->value($appSettings['v']??0)->help('配置应用最小版本号');
$this->divider();
$this->switch('is_verify', '审核开关')->value($appSettings['is_verify'] ?? 0);
$this->switch('wallet_show', '账户开关')->value($appSettings['wallet_show'] ?? 0);
$this->checkbox('pay_way', '支付方式')->options([
Order::PAY_WAY_WXPAY => '微信支付',
Order::PAY_WAY_ALIPAY => '支付宝',
Order::PAY_WAY_WALLET => '可提',
Order::PAY_WAY_BALANCE => '余额',
// Order::PAY_WAY_OFFLINE = 'offline'; // 现金支付
])->canCheckAll()->customFormat(function () use ($appSettings) {
return $appSettings['pay_way']??[];
});
}
}

View File

@ -0,0 +1,58 @@
<?php
namespace App\Admin\Forms\Settings;
use App\Models\Order;
use App\Models\Setting;
use App\Services\SettingService;
use Dcat\Admin\Widgets\Form;
class Ios extends Form
{
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public function handle(array $input)
{
Setting::where('key', 'ios')->updateOrCreate([
'key' => 'ios',
], ['value' => $input]);
//清配置缓存
app(SettingService::class)->cleanCache('ios');
return $this
->response()
->success('配置更新成功!')
->refresh();
}
/**
* Build a form here.
*/
public function form()
{
$appSettings = Setting::where('key', 'ios')->value('value');
$this->number('v', '版本号')->min(0)->value($appSettings['v']??0)->help('配置应用最小版本号');
$this->divider();
$this->switch('is_verify', '审核开关')->value($appSettings['is_verify'] ?? 0);
$this->switch('wallet_show', '账户开关')->value($appSettings['wallet_show'] ?? 0);
$this->checkbox('pay_way', '支付方式')->options([
Order::PAY_WAY_WXPAY => '微信支付',
Order::PAY_WAY_ALIPAY => '支付宝',
Order::PAY_WAY_WALLET => '可提',
Order::PAY_WAY_BALANCE => '余额',
// Order::PAY_WAY_OFFLINE = 'offline'; // 现金支付
])->canCheckAll()->customFormat(function () use ($appSettings) {
// dd($appSettings['pay_way']);
return $appSettings['pay_way']??[];
});
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Endpoint\Api\Http\Controllers;
use Illuminate\Http\Request;
class SettingController extends Controller
{
/**
*
*
* @param \Illuminate\Http\Request $request
* @return void
*/
public function index(Request $request)
{
return response()->json([
'ios'=>app_settings('ios'),
'android'=>app_settings('android'),
]);
}
}

View File

@ -27,6 +27,7 @@ use App\Endpoint\Api\Http\Controllers\Product\ProductFavoriteController;
use App\Endpoint\Api\Http\Controllers\Product\ProductSkuController;
use App\Endpoint\Api\Http\Controllers\Product\ProductViewLogController;
use App\Endpoint\Api\Http\Controllers\PushController;
use App\Endpoint\Api\Http\Controllers\SettingController;
use App\Endpoint\Api\Http\Controllers\ShareBgController;
use App\Endpoint\Api\Http\Controllers\ShippingAddressController;
use App\Endpoint\Api\Http\Controllers\ShoppingCartItemController;
@ -79,6 +80,9 @@ Route::group([
//绑定用户端cid
Route::post('push-bind-uni', [PushController::class, 'bindUniCid']);
//获取配置
Route::get('configs', [SettingController::class, 'index']);
Route::middleware(['auth:api'])->group(function () {
// 我的信息
Route::get('me', [UserController::class, 'show']);

View File

@ -2,6 +2,7 @@
namespace Database\Seeders;
use App\Models\Order;
use App\Models\Setting;
use Illuminate\Database\Seeder;
@ -35,6 +36,34 @@ class AppSettingSeeder extends Seeder
],
'remarks' => '系统配置',
],
'ios' => [
'value'=> [
'v'=>0,
'is_verify'=> false,
'wallet_show'=> true,
'pay_way' => [
Order::PAY_WAY_WXPAY,
Order::PAY_WAY_ALIPAY,
Order::PAY_WAY_WALLET,
Order::PAY_WAY_BALANCE,
],
],
'remarks' => 'Ios配置',
],
'android' => [
'value'=> [
'v'=>0,
'is_verify'=> false,
'wallet_show'=> true,
'pay_way' => [
Order::PAY_WAY_WXPAY,
Order::PAY_WAY_ALIPAY,
Order::PAY_WAY_WALLET,
Order::PAY_WAY_BALANCE,
],
],
'remarks' => 'Android配置',
],
'kuaidi100' => [
'value' => [
'is_use' => true,