调整配置管理
parent
2598a8d187
commit
05f01969fd
|
|
@ -2,13 +2,20 @@
|
||||||
|
|
||||||
namespace App\Admin\Controllers;
|
namespace App\Admin\Controllers;
|
||||||
|
|
||||||
|
use App\Admin\Forms\Settings\App;
|
||||||
|
use App\Admin\Forms\Settings\Kuaidi100;
|
||||||
|
use App\Admin\Forms\Settings\Unipush;
|
||||||
use App\Admin\Repositories\Setting;
|
use App\Admin\Repositories\Setting;
|
||||||
use Dcat\Admin\Admin;
|
use Dcat\Admin\Admin;
|
||||||
use Dcat\Admin\Form;
|
use Dcat\Admin\Form;
|
||||||
use Dcat\Admin\Grid;
|
use Dcat\Admin\Grid;
|
||||||
use Dcat\Admin\Grid\Column;
|
use Dcat\Admin\Grid\Column;
|
||||||
use Dcat\Admin\Http\Controllers\AdminController;
|
use Dcat\Admin\Http\Controllers\AdminController;
|
||||||
|
use Dcat\Admin\Layout\Content;
|
||||||
|
use Dcat\Admin\Layout\Row;
|
||||||
use Dcat\Admin\Show;
|
use Dcat\Admin\Show;
|
||||||
|
use Dcat\Admin\Widgets\Tab;
|
||||||
|
use Illuminate\Support\Facades\Request;
|
||||||
|
|
||||||
class SettingController extends AdminController
|
class SettingController extends AdminController
|
||||||
{
|
{
|
||||||
|
|
@ -88,4 +95,34 @@ class SettingController extends AdminController
|
||||||
$form->display('updated_at');
|
$form->display('updated_at');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function index(Content $content): Content
|
||||||
|
{
|
||||||
|
return $content->header('配置管理')
|
||||||
|
->description('配置管理')
|
||||||
|
->body(function (Row $row) {
|
||||||
|
$type = Request::query('type', 'app');
|
||||||
|
$tab = new Tab();
|
||||||
|
switch ($type) {
|
||||||
|
case 'app':
|
||||||
|
$tab->add('系统配置', new App(), 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->add('快递100配置', new Kuaidi100(), true);
|
||||||
|
$tab->addLink('Uni-push配置', admin_route('settings.index', ['type'=>'unipush']));
|
||||||
|
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);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$row->column(12, $tab->withCard());
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Forms\Settings;
|
||||||
|
|
||||||
|
use App\Models\ArticleCategory;
|
||||||
|
use App\Models\Setting;
|
||||||
|
use Dcat\Admin\Widgets\Form;
|
||||||
|
|
||||||
|
class App extends Form
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle the form request.
|
||||||
|
*
|
||||||
|
* @param array $input
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle(array $input)
|
||||||
|
{
|
||||||
|
Setting::where('key', 'app')->updateOrCreate([
|
||||||
|
'key' => 'app',
|
||||||
|
], ['value' => $input]);
|
||||||
|
|
||||||
|
return $this
|
||||||
|
->response()
|
||||||
|
->success('配置更新成功!')
|
||||||
|
->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a form here.
|
||||||
|
*/
|
||||||
|
public function form()
|
||||||
|
{
|
||||||
|
$appSettings = Setting::where('key', 'app')->first();
|
||||||
|
|
||||||
|
$this->text('app_name', 'APP名称')->value($appSettings?->value['app_name']);
|
||||||
|
$this->divider();
|
||||||
|
$this->text('search_hot_keys', '搜索热词(英文半角逗号隔开)')->value($appSettings?->value['search_hot_keys']);
|
||||||
|
$this->divider();
|
||||||
|
$this->number('order_payment_expires_at', '订单支付过期时间(秒)')->value($appSettings?->value['order_payment_expires_at']);
|
||||||
|
$this->number('sale_after_expire_days', '售后过期时间(天)')->value($appSettings?->value['sale_after_expire_days']);
|
||||||
|
$this->divider();
|
||||||
|
|
||||||
|
$this->number('sign_click_points', '签到送积分(分)')->value($appSettings?->value['sign_click_points']);
|
||||||
|
$this->number('sign_click_continue', '每连续签到额外奖励(天)')->value($appSettings?->value['sign_click_continue']);
|
||||||
|
$this->number('sign_click_continue_points', '每连续签到额外奖励(分)')->value($appSettings?->value['sign_click_continue_points']);
|
||||||
|
$this->divider();
|
||||||
|
|
||||||
|
$this->select('article_help', '帮助文章指定分类')->options(ArticleCategory::whereNull('parent_id')->pluck('name', 'id'))->value($appSettings?->value['article_help']);
|
||||||
|
$this->select('article_agreement', '协议文章指定分类')->options(ArticleCategory::whereNull('parent_id')->pluck('name', 'id'))->value($appSettings?->value['article_agreement']);
|
||||||
|
$this->select('article_health', '健康文章指定分类')->options(ArticleCategory::whereNull('parent_id')->pluck('name', 'id'))->value($appSettings?->value['article_health']);
|
||||||
|
|
||||||
|
$this->text('article_about_us', '关于我们文章指定(链接)')->value($appSettings?->value['article_about_us']);
|
||||||
|
$this->text('article_user_promotion_agreement', '服务协议文章指定(链接)')->value($appSettings?->value['article_user_promotion_agreement']);
|
||||||
|
$this->text('article_user_hide_agreement', '隐私协议文章指定(链接)')->value($appSettings?->value['article_user_hide_agreement']);
|
||||||
|
$this->divider();
|
||||||
|
|
||||||
|
$this->text('invite_uri', '分享邀请地址(链接)')->value($appSettings?->value['article_about_us']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Forms\Settings;
|
||||||
|
|
||||||
|
use App\Models\Setting;
|
||||||
|
use Dcat\Admin\Widgets\Form;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
|
class Kuaidi100 extends Form
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle the form request.
|
||||||
|
*
|
||||||
|
* @param array $input
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle(array $input)
|
||||||
|
{
|
||||||
|
Setting::where('key', 'kuaidi100')->updateOrCreate([
|
||||||
|
'key' => 'kuaidi100',
|
||||||
|
], ['value' => $input]);
|
||||||
|
|
||||||
|
return $this
|
||||||
|
->response()
|
||||||
|
->success('配置更新成功!')
|
||||||
|
->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a form here.
|
||||||
|
*/
|
||||||
|
public function form()
|
||||||
|
{
|
||||||
|
$appSettings = Setting::where('key', 'kuaidi100')->first();
|
||||||
|
|
||||||
|
$this->switch('is_use', '是否启用')->value(Arr::get($appSettings?->value, 'is_use', 0));
|
||||||
|
$this->divider();
|
||||||
|
$this->text('app_key', 'APP_KEY')->value(Arr::get($appSettings?->value, 'app_key', ''));
|
||||||
|
$this->text('customer', 'CUSTOMER')->value(Arr::get($appSettings?->value, 'customer', ''));
|
||||||
|
$this->text('secret', 'SECRET')->value(Arr::get($appSettings?->value, 'secret', ''));
|
||||||
|
$this->text('userid', 'USER_ID')->value(Arr::get($appSettings?->value, 'userid', ''));
|
||||||
|
$this->text('callback_uri', '回调地址(链接)')->value(Arr::get($appSettings?->value, 'callback_uri', ''));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Forms\Settings;
|
||||||
|
|
||||||
|
use App\Models\Setting;
|
||||||
|
use Dcat\Admin\Widgets\Form;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
|
class Unipush extends Form
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle the form request.
|
||||||
|
*
|
||||||
|
* @param array $input
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle(array $input)
|
||||||
|
{
|
||||||
|
Setting::where('key', 'unipush')->updateOrCreate([
|
||||||
|
'key' => 'unipush',
|
||||||
|
], ['value' => $input]);
|
||||||
|
|
||||||
|
return $this
|
||||||
|
->response()
|
||||||
|
->success('配置更新成功!')
|
||||||
|
->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a form here.
|
||||||
|
*/
|
||||||
|
public function form()
|
||||||
|
{
|
||||||
|
$appSettings = Setting::where('key', 'unipush')->first();
|
||||||
|
|
||||||
|
$this->switch('is_use', '是否启用')->value(Arr::get($appSettings?->value, 'is_use', 0));
|
||||||
|
$this->text('mall_app_id', '商城APP_ID')->value(Arr::get($appSettings?->value, 'mall_app_id', ''));
|
||||||
|
$this->text('mall_app_key', '商城APP_KEY')->value(Arr::get($appSettings?->value, 'mall_app_key', ''));
|
||||||
|
$this->text('mall_app_secret', '商城APP_SECRET')->value(Arr::get($appSettings?->value, 'mall_app_secret', ''));
|
||||||
|
$this->text('mall_master_secret', '商城APP_MASTER_SECRET')->value(Arr::get($appSettings?->value, 'mall_master_secret', ''));
|
||||||
|
|
||||||
|
$this->divider();
|
||||||
|
$this->switch('merchant_is_use', '是否启用')->value(Arr::get($appSettings?->value, 'merchant_is_use', 0));
|
||||||
|
$this->text('merchant_app_id', '商户APP_ID')->value(Arr::get($appSettings?->value, 'merchant_app_id', ''));
|
||||||
|
$this->text('merchant_app_key', '商户APP_KEY')->value(Arr::get($appSettings?->value, 'merchant_app_key', ''));
|
||||||
|
$this->text('merchant_app_secret', '商户APP_SECRET')->value(Arr::get($appSettings?->value, 'merchant_app_secret', ''));
|
||||||
|
$this->text('merchant_master_secret', '商户APP_MASTER_SECRET')->value(Arr::get($appSettings?->value, 'merchant_master_secret', ''));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -74,7 +74,7 @@ class OrderPackageService
|
||||||
'updated_at' => $package->created_at,
|
'updated_at' => $package->created_at,
|
||||||
]);
|
]);
|
||||||
}, $packageProducts));
|
}, $packageProducts));
|
||||||
if (app_settings('kuaidi100_is_use')) {
|
if (app_settings('kuaidi100.is_use')) {
|
||||||
$kuaidi100Service = new Kuaidi100Service();
|
$kuaidi100Service = new Kuaidi100Service();
|
||||||
$kuaidi100Service->poll($package->shipping_number, $package->shipping_code, $package->consignee_telephone);
|
$kuaidi100Service->poll($package->shipping_number, $package->shipping_code, $package->consignee_telephone);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,9 @@ class PushMessageCommand extends Command
|
||||||
$status = 2; //默认失败
|
$status = 2; //默认失败
|
||||||
//如果是系统消息
|
//如果是系统消息
|
||||||
if ($task->message instanceof Message) {
|
if ($task->message instanceof Message) {
|
||||||
$status = $mallPushService->push($task->sn, $task->message) ? 1 : 2;
|
if ((bool) app_settings('nuipush.is_use')) {//如果开启了推送
|
||||||
|
$status = $mallPushService->push($task->sn, $task->message) ? 1 : 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$task->update([
|
$task->update([
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,9 @@ class ArticleController extends Controller
|
||||||
public function config(Request $request)
|
public function config(Request $request)
|
||||||
{
|
{
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'about_us'=>app_settings('article_about_us', ''),
|
'about_us'=>app_settings('app.article_about_us', ''),
|
||||||
'user_promotion_agreement'=> app_settings('article_user_promotion_agreement', ''),
|
'user_promotion_agreement'=> app_settings('app.article_user_promotion_agreement', ''),
|
||||||
'user_hide_agreement' => app_settings('article_user_hide_agreement', ),
|
'user_hide_agreement' => app_settings('app.article_user_hide_agreement', ),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,9 +43,9 @@ class ArticleController extends Controller
|
||||||
$cate = (string) $request->query('cate');
|
$cate = (string) $request->query('cate');
|
||||||
$key = (string) $request->query('key');
|
$key = (string) $request->query('key');
|
||||||
$categoryId = Arr::get([
|
$categoryId = Arr::get([
|
||||||
'help'=> app_settings('article_help'),
|
'help'=> app_settings('app.article_help'),
|
||||||
'agreement'=> app_settings('article_agreement'),
|
'agreement'=> app_settings('app.article_agreement'),
|
||||||
'health'=> app_settings('article_health'),
|
'health'=> app_settings('app.article_health'),
|
||||||
], $cate);
|
], $cate);
|
||||||
$query = Article::query()->with(['likesInfo'=>function ($q) use ($request) {
|
$query = Article::query()->with(['likesInfo'=>function ($q) use ($request) {
|
||||||
$user_id = $request->user()?->id;
|
$user_id = $request->user()?->id;
|
||||||
|
|
|
||||||
|
|
@ -63,12 +63,12 @@ class ClickController extends Controller
|
||||||
]);
|
]);
|
||||||
|
|
||||||
//发放当天签到积分
|
//发放当天签到积分
|
||||||
$points = app_settings('sign_click_points');
|
$points = app_settings('app.sign_click_points');
|
||||||
$pointsService->sendPoints(1, $user, $points, '签到奖励');
|
$pointsService->sendPoints(1, $user, $points, '签到奖励');
|
||||||
|
|
||||||
//发放额外的奖励积分
|
//发放额外的奖励积分
|
||||||
$continueClickDays = app_settings('sign_click_continue', 0);
|
$continueClickDays = app_settings('app.sign_click_continue', 0);
|
||||||
$continueClickPoints = app_settings('sign_click_continue_points');
|
$continueClickPoints = app_settings('app.sign_click_continue_points');
|
||||||
if (($continueClickDays > 0 && $click->continue_click_times % $continueClickDays) == 0) {
|
if (($continueClickDays > 0 && $click->continue_click_times % $continueClickDays) == 0) {
|
||||||
$pointsService->sendPoints(1, $user, $continueClickPoints, '连续签到奖励');
|
$pointsService->sendPoints(1, $user, $continueClickPoints, '连续签到奖励');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ class ProductSkuController extends Controller
|
||||||
public function searchHotKeys(Request $request)
|
public function searchHotKeys(Request $request)
|
||||||
{
|
{
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'keys' => explode(',', app_settings('search_hot_keys')),
|
'keys' => explode(',', app_settings('app.search_hot_keys')),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ class ShareBgController extends Controller
|
||||||
|
|
||||||
public function userQrCode(Request $request)
|
public function userQrCode(Request $request)
|
||||||
{
|
{
|
||||||
$inviteUri = app_settings('invite_uri').'/register?code=';
|
$inviteUri = app_settings('app.invite_uri').'/register?code=';
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'qr_code' => base64_encode(QrCode::format('png')->size(100)->margin(0)->generate($inviteUri.$request->user()->userInfo?->code)),
|
'qr_code' => base64_encode(QrCode::format('png')->size(100)->margin(0)->generate($inviteUri.$request->user()->userInfo?->code)),
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -20,13 +20,13 @@ class ArticleController extends Controller
|
||||||
$view = '';
|
$view = '';
|
||||||
//区分文章分类ID
|
//区分文章分类ID
|
||||||
switch ($article->category_id) {
|
switch ($article->category_id) {
|
||||||
case app_settings('article_agreement'): //如果是协议分类
|
case app_settings('app.article_agreement'): //如果是协议分类
|
||||||
$view = 'endpoint.article.agreement';
|
$view = 'endpoint.article.agreement';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//区分文章的分类祖先ID
|
//区分文章的分类祖先ID
|
||||||
switch ($article->category->ancestors->first()?->id) {
|
switch ($article->category->ancestors->first()?->id) {
|
||||||
case app_settings('article_agreement'): //如果是协议
|
case app_settings('app.article_agreement'): //如果是协议
|
||||||
$view = 'endpoint.article.agreement';
|
$view = 'endpoint.article.agreement';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ class Order extends Model
|
||||||
public function scopeExpired()
|
public function scopeExpired()
|
||||||
{
|
{
|
||||||
return $this->where('status', static::STATUS_PENDING)
|
return $this->where('status', static::STATUS_PENDING)
|
||||||
->where('created_at', '<=', now()->subSeconds(app_settings('order_payment_expires_at')));
|
->where('created_at', '<=', now()->subSeconds(app_settings('app.order_payment_expires_at')));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -320,7 +320,7 @@ class Order extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
$seconds = now()->diffInSeconds(
|
$seconds = now()->diffInSeconds(
|
||||||
$this->created_at->addSeconds(app_settings('order_payment_expires_at')), false
|
$this->created_at->addSeconds(app_settings('app.order_payment_expires_at')), false
|
||||||
);
|
);
|
||||||
|
|
||||||
return $seconds > 0 ? $seconds : 0;
|
return $seconds > 0 ? $seconds : 0;
|
||||||
|
|
|
||||||
|
|
@ -1328,12 +1328,12 @@ class Kuaidi100Service
|
||||||
|
|
||||||
public function setAppKey($appKey = null)
|
public function setAppKey($appKey = null)
|
||||||
{
|
{
|
||||||
$this->appKey = $appKey ??app_settings('kuaidi100_app_key');
|
$this->appKey = $appKey ??app_settings('kuaidi100.app_key');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setCustomer($customer = null)
|
public function setCustomer($customer = null)
|
||||||
{
|
{
|
||||||
$this->customer = $customer ??app_settings('kuaidi100_customer');
|
$this->customer = $customer ??app_settings('kuaidi100.customer');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1344,7 +1344,7 @@ class Kuaidi100Service
|
||||||
public function poll(string $number, string $code, string $phone)
|
public function poll(string $number, string $code, string $phone)
|
||||||
{
|
{
|
||||||
$uri = '/poll';
|
$uri = '/poll';
|
||||||
$callbackUrl = app_settings('kuaidi100_callback');
|
$callbackUrl = app_settings('kuaidi100.callback');
|
||||||
|
|
||||||
if (empty($callbackUrl)) {
|
if (empty($callbackUrl)) {
|
||||||
throw new BizException('未配置推送回调地址');
|
throw new BizException('未配置推送回调地址');
|
||||||
|
|
@ -1357,7 +1357,7 @@ class Kuaidi100Service
|
||||||
'key' => $this->appKey,
|
'key' => $this->appKey,
|
||||||
'parameters'=> [
|
'parameters'=> [
|
||||||
'callbackurl'=> $callbackUrl,
|
'callbackurl'=> $callbackUrl,
|
||||||
'salt' => app_settings('kuaidi100_secret'),
|
'salt' => app_settings('kuaidi100.secret'),
|
||||||
'phone' => $phone,
|
'phone' => $phone,
|
||||||
'resultv2' => '1',
|
'resultv2' => '1',
|
||||||
'autoCom' => empty($code) ? 1 : 0,
|
'autoCom' => empty($code) ? 1 : 0,
|
||||||
|
|
@ -1488,7 +1488,7 @@ class Kuaidi100Service
|
||||||
*/
|
*/
|
||||||
public function unPollSign(string $sign, array $params)
|
public function unPollSign(string $sign, array $params)
|
||||||
{
|
{
|
||||||
return $sign === strtoupper(md5(json_encode($params, JSON_UNESCAPED_UNICODE).app_settings('kuaidi100_secret')));
|
return $sign === strtoupper(md5(json_encode($params, JSON_UNESCAPED_UNICODE).app_settings('kuaidi100.secret')));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStatusName($state = 0)
|
public function getStatusName($state = 0)
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ class OrderPackageService
|
||||||
|
|
||||||
// 更新商品的售后过期时间
|
// 更新商品的售后过期时间
|
||||||
$package->orderProducts()->update([
|
$package->orderProducts()->update([
|
||||||
'after_expire_at'=> $package->checked_at->addDays(app_settings('sale_after_expire_days', 7)),
|
'after_expire_at'=> $package->checked_at->addDays(app_settings('app.sale_after_expire_days', 7)),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -713,7 +713,7 @@ class OrderService
|
||||||
'attach' => json_encode([
|
'attach' => json_encode([
|
||||||
'pay_way' => $payWay,
|
'pay_way' => $payWay,
|
||||||
]),
|
]),
|
||||||
'body' => app_settings('app_name').'-商城订单',
|
'body' => app_settings('app.app_name').'-商城订单',
|
||||||
'out_trade_no' => $order->sn,
|
'out_trade_no' => $order->sn,
|
||||||
'total_fee' => $order->total_amount,
|
'total_fee' => $order->total_amount,
|
||||||
'notify_url' => url(route('wxpay.order_paid_notify', [], false), [], true),
|
'notify_url' => url(route('wxpay.order_paid_notify', [], false), [], true),
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,10 @@ class MallUnipushService extends UniPushService
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->appId = app_settings('mall_push_app_id', '');
|
$this->appId = app_settings('unipush.mall_app_id', '');
|
||||||
$this->appKey = app_settings('mall_push_app_key', '');
|
$this->appKey = app_settings('unipush.mall_app_key', '');
|
||||||
$this->appSecret = app_settings('mall_push_app_secret', '');
|
$this->appSecret = app_settings('unipush.mall_app_secret', '');
|
||||||
$this->masterSecret = app_settings('mall_push_master_secret', '');
|
$this->masterSecret = app_settings('unipush.mall_master_secret', '');
|
||||||
parent::__construct($this->appId, $this->appKey, $this->appSecret, $this->masterSecret);
|
parent::__construct($this->appId, $this->appKey, $this->appSecret, $this->masterSecret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ namespace App\Services;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use Illuminate\Contracts\Cache\Repository as Cache;
|
use Illuminate\Contracts\Cache\Repository as Cache;
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
class SettingService
|
class SettingService
|
||||||
{
|
{
|
||||||
|
|
@ -40,12 +42,15 @@ class SettingService
|
||||||
if (! array_key_exists($key, $this->items)) {
|
if (! array_key_exists($key, $this->items)) {
|
||||||
try {
|
try {
|
||||||
$this->items[$key] = $this->cache->remember($this->cacheKey($key), $this->ttl, function () use ($key) {
|
$this->items[$key] = $this->cache->remember($this->cacheKey($key), $this->ttl, function () use ($key) {
|
||||||
$settings = Setting::where('key', $key)->firstOrFail();
|
$_key = $this->keyHandle($key);
|
||||||
|
$settings = Setting::where('key', $_key[0])->firstOrFail();
|
||||||
|
|
||||||
return $settings->value;
|
return Arr::get($settings->value, $_key[1]);
|
||||||
});
|
});
|
||||||
} catch (ModelNotFoundException $e) {
|
} catch (ModelNotFoundException $e) {
|
||||||
return $default;
|
return $default;
|
||||||
|
} catch (Throwable $th) {
|
||||||
|
return $default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,11 +86,8 @@ class SettingService
|
||||||
$keys = is_array($key) ? $key : [$key => $value];
|
$keys = is_array($key) ? $key : [$key => $value];
|
||||||
|
|
||||||
foreach ($keys as $key => $value) {
|
foreach ($keys as $key => $value) {
|
||||||
Setting::updateOrCreate([
|
$_key = $this->keyHandle($key);
|
||||||
'key' => $key,
|
Setting::where('key', $_key[0])->update(['value->'.$_key[1] => $value]);
|
||||||
], [
|
|
||||||
'value' => $value,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->cleanCache($key);
|
$this->cleanCache($key);
|
||||||
}
|
}
|
||||||
|
|
@ -95,7 +97,7 @@ class SettingService
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function cleanCache(string $key): void
|
public function cleanCache(string $key): void
|
||||||
{
|
{
|
||||||
unset($this->items[$key]);
|
unset($this->items[$key]);
|
||||||
|
|
||||||
|
|
@ -110,4 +112,9 @@ class SettingService
|
||||||
{
|
{
|
||||||
return "settings.{$key}";
|
return "settings.{$key}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function keyHandle(string $key)
|
||||||
|
{
|
||||||
|
return explode('.', $key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,110 +15,51 @@ class AppSettingSeeder extends Seeder
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
foreach ([
|
foreach ([
|
||||||
'app_name' => [
|
'app'=> [
|
||||||
'value' => '子春生',
|
'value'=> [
|
||||||
'remarks'=>'应用名称',
|
'app_name' => '子春生',
|
||||||
|
'order_payment_expires_at' => 1800,
|
||||||
|
'sale_after_expire_days' => 7,
|
||||||
|
'sign_click_points' => 5,
|
||||||
|
'sign_click_continue' => 7,
|
||||||
|
'sign_click_continue_points' => 10,
|
||||||
|
'article_help' => 1,
|
||||||
|
'article_agreement' => 2,
|
||||||
|
'article_health' => 3,
|
||||||
|
'article_about_us' => env('APP_URL', '').'/h5/articles/1',
|
||||||
|
'article_user_promotion_agreement' => env('APP_URL', '').'/h5/articles/2',
|
||||||
|
'article_user_hide_agreement' => env('APP_URL', '').'/h5/articles/3',
|
||||||
|
'invite_uri' => '',
|
||||||
|
'search_hot_keys' => '搜索热词,分词1,分词2,分词3',
|
||||||
|
],
|
||||||
|
'remarks' => '系统配置',
|
||||||
],
|
],
|
||||||
'order_payment_expires_at' => [
|
'kuaidi100' => [
|
||||||
'value' => 1800,
|
'value' => [
|
||||||
'remarks' => '订单支付过期时间(秒)',
|
'is_use' => true,
|
||||||
|
'callback_uri' => env('APP_URL', '').'/callback/kuaidi100',
|
||||||
|
'app_key' => 'BTvgbjti4727',
|
||||||
|
'customer' => '064109188EC4D85DA655DFC342144C6A',
|
||||||
|
'secret' => '1bd287d1981749f2a30ea74cac0ab99c',
|
||||||
|
'userid' => 'ec0b6ec7729d4f22824cfd3c519dd45b',
|
||||||
|
],
|
||||||
|
'remarks' => '快递100配置',
|
||||||
],
|
],
|
||||||
'sale_after_expire_days' => [
|
'unipush' => [
|
||||||
'value' => 7,
|
'value' =>[
|
||||||
'remarks' => '售后过期时间(天)',
|
'is_use' => true,
|
||||||
|
'mall_app_id' => 'iikmCoESID8bC1LhOPG1r8',
|
||||||
|
'mall_app_key' => 'JX33P0wP8bAQprI953hpN6',
|
||||||
|
'mall_app_secret' => 'a3u3B6lXjq6fPTBlOGiOc9',
|
||||||
|
'mall_master_secret' => 'MAxmqomwo597xJeDuMCvx1',
|
||||||
|
'merchant_is_use' => false,
|
||||||
|
'merchant_app_id' => '',
|
||||||
|
'merchant_app_key' => '',
|
||||||
|
'merchant_app_secret' => '',
|
||||||
|
'merchant_master_secret' => '',
|
||||||
|
],
|
||||||
|
'remarks' => '个推配置',
|
||||||
],
|
],
|
||||||
|
|
||||||
'sign_click_points' => [
|
|
||||||
'value' => 5,
|
|
||||||
'remarks' => '签到送积分(分)',
|
|
||||||
],
|
|
||||||
'sign_click_continue' => [
|
|
||||||
'value' => 7,
|
|
||||||
'remarks' => '每连续N天签到额外奖励',
|
|
||||||
],
|
|
||||||
'sign_click_continue_points' => [
|
|
||||||
'value' => 10,
|
|
||||||
'remarks' => '每连续签到额外奖励(分)',
|
|
||||||
],
|
|
||||||
|
|
||||||
'article_help' => [
|
|
||||||
'value' => 1,
|
|
||||||
'remarks' => '帮助文章指定分类(ID)',
|
|
||||||
],
|
|
||||||
'article_agreement' => [
|
|
||||||
'value' => 2,
|
|
||||||
'remarks' => '协议文章指定分类(ID)',
|
|
||||||
],
|
|
||||||
'article_agreement' => [
|
|
||||||
'value' => 3,
|
|
||||||
'remarks' => '健康文章指定分类(ID)',
|
|
||||||
],
|
|
||||||
|
|
||||||
'article_about_us' => [
|
|
||||||
'value' => env('APP_URL', '').'/h5/articles/1',
|
|
||||||
'remarks' => '关于我们文章指定(链接)',
|
|
||||||
],
|
|
||||||
'article_user_promotion_agreement' => [
|
|
||||||
'value' => env('APP_URL', '').'/h5/articles/2',
|
|
||||||
'remarks' => '服务协议文章指定(链接)',
|
|
||||||
],
|
|
||||||
'article_user_hide_agreement' => [
|
|
||||||
'value' => env('APP_URL', '').'/h5/articles/3',
|
|
||||||
'remarks' => '隐私协议文章指定(链接)',
|
|
||||||
],
|
|
||||||
|
|
||||||
'kuaidi100_is_use' => [
|
|
||||||
'value' => true,
|
|
||||||
'remarks' => '快递100:是否开启',
|
|
||||||
],
|
|
||||||
'kuaidi100_callback' => [
|
|
||||||
'value' => env('APP_URL', '').'/callback/kuaidi100',
|
|
||||||
'remarks' => '快递100:回调地址(链接)',
|
|
||||||
],
|
|
||||||
'kuaidi100_app_key' => [
|
|
||||||
'value' => 'BTvgbjti4727',
|
|
||||||
'remarks' => '快递100:APP_KEY',
|
|
||||||
],
|
|
||||||
'kuaidi100_customer' => [
|
|
||||||
'value' => '064109188EC4D85DA655DFC342144C6A',
|
|
||||||
'remarks' => '快递100:CUSTOMER',
|
|
||||||
],
|
|
||||||
'kuaidi100_secret' => [
|
|
||||||
'value' => '1bd287d1981749f2a30ea74cac0ab99c',
|
|
||||||
'remarks' => '快递100:SECRET',
|
|
||||||
],
|
|
||||||
'kuaidi100_userid' => [
|
|
||||||
'value' => 'ec0b6ec7729d4f22824cfd3c519dd45b',
|
|
||||||
'remarks' => '快递100:USER_ID',
|
|
||||||
],
|
|
||||||
|
|
||||||
'mall_push_app_id' => [
|
|
||||||
'value' => 'iikmCoESID8bC1LhOPG1r8',
|
|
||||||
'remarks' => '个推:APP_ID',
|
|
||||||
],
|
|
||||||
'mall_push_app_key' => [
|
|
||||||
'value' => 'JX33P0wP8bAQprI953hpN6',
|
|
||||||
'remarks' => '个推:APP_KEY',
|
|
||||||
],
|
|
||||||
'mall_push_app_secret' => [
|
|
||||||
'value' => 'a3u3B6lXjq6fPTBlOGiOc9',
|
|
||||||
'remarks' => '个推:APP_SECRET',
|
|
||||||
],
|
|
||||||
'mall_push_master_secret' => [
|
|
||||||
'value' => 'MAxmqomwo597xJeDuMCvx1',
|
|
||||||
'remarks' => '个推:APP_MASTER_SECRET',
|
|
||||||
],
|
|
||||||
|
|
||||||
'invite_uri' => [
|
|
||||||
'value' => '',
|
|
||||||
'remarks' => '分享邀请地址(链接)',
|
|
||||||
],
|
|
||||||
|
|
||||||
'search_hot_keys' => [
|
|
||||||
'value' => '搜索热词,分词1,分词2,分词3',
|
|
||||||
'remarks'=>'搜索热词(半角逗号,隔开)',
|
|
||||||
],
|
|
||||||
|
|
||||||
] as $key => $values) {
|
] as $key => $values) {
|
||||||
Setting::firstOrCreate(['key' => $key], $values);
|
Setting::firstOrCreate(['key' => $key], $values);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue