mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-21 11:18:10 +08:00
* Merge remote-tracking branch 'gitee/xiaochong0302/I280IZ' into xiaocho… * 初步完成开放登录,待线上测试7 * Merge branch 'demo' of gitee.com:koogua/course-tencent-cloud into xiao… * 初步完成开放登录,待线上测试6 * !30 开放登录线上测试5 * !29 开放登录线上测试5 * 初步完成开放登录,待线上测试5 * !28 开放登录线上测试4 * 初步完成开放登录,待线上测试4 * !27 开放登录线上测试3 * 初步完成开放登录,待线上测试3 * !26 开放登录线上测试2 * 初步完成开放登录,待线上测试2 * !25 开放登录线上测试 * 初步完成开放登录,待线上测试 * !22 验证更新h5支付 * Merge remote-tracking branch 'remotes/gitee/develop' into demo * !20 验证更新h5支付 * Merge branch 'develop' of https://gitee.com/koogua/course-tencent-clou… * !16 v1.2.0阶段性合并 * 删除调试断点代码 * 删除重复的signature方法 * Merge branch 'develop' of https://gitee.com/koogua/course-tencent-clou… * demo后台增加统计 * !5 更新版本号1.1.0 * !4 v1.1.0版本develop->demo * Merge branch 'develop' into demo * 1.增加changelog.md * Merge branch 'develop' into demo * Merge branch 'develop' into demo * Merge branch 'develop' into demo * !1 精简优化代码 * Merge branch 'develop' into demo * 合并修改
171 lines
4.9 KiB
PHP
171 lines
4.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Admin\Services;
|
|
|
|
use App\Caches\Setting as SettingCache;
|
|
use App\Repos\Setting as SettingRepo;
|
|
use App\Repos\Vip as VipRepo;
|
|
|
|
class Setting extends Service
|
|
{
|
|
|
|
public function getQQAuthSettings()
|
|
{
|
|
$oauth = $this->getSettings('oauth.qq');
|
|
|
|
$oauth['redirect_uri'] = $oauth['redirect_uri'] ?: kg_full_url(['for' => 'home.oauth.qq_callback']);
|
|
|
|
return $oauth;
|
|
}
|
|
|
|
public function getWeixinAuthSettings()
|
|
{
|
|
$oauth = $this->getSettings('oauth.weixin');
|
|
|
|
$oauth['redirect_uri'] = $oauth['redirect_uri'] ?: kg_full_url(['for' => 'home.oauth.weixin_callback']);
|
|
|
|
return $oauth;
|
|
}
|
|
|
|
public function getWeiboAuthSettings()
|
|
{
|
|
$oauth = $this->getSettings('oauth.weibo');
|
|
|
|
$oauth['redirect_uri'] = $oauth['redirect_uri'] ?: kg_full_url(['for' => 'home.oauth.weibo_callback']);
|
|
|
|
return $oauth;
|
|
}
|
|
|
|
public function getAlipaySettings()
|
|
{
|
|
$alipay = $this->getSettings('pay.alipay');
|
|
|
|
$alipay['return_url'] = $alipay['return_url'] ?: kg_full_url(['for' => 'home.alipay_callback']);
|
|
$alipay['notify_url'] = $alipay['notify_url'] ?: kg_full_url(['for' => 'home.alipay_notify']);
|
|
|
|
return $alipay;
|
|
}
|
|
|
|
public function getWxpaySettings()
|
|
{
|
|
$wxpay = $this->getSettings('pay.wxpay');
|
|
|
|
$wxpay['return_url'] = $wxpay['return_url'] ?: kg_full_url(['for' => 'home.wxpay_callback']);
|
|
$wxpay['notify_url'] = $wxpay['notify_url'] ?: kg_full_url(['for' => 'home.wxpay_notify']);
|
|
|
|
return $wxpay;
|
|
}
|
|
|
|
public function getVipSettings()
|
|
{
|
|
$vipRepo = new VipRepo();
|
|
|
|
return $vipRepo->findAll(['deleted' => 0]);
|
|
}
|
|
|
|
public function getLiveSettings($section)
|
|
{
|
|
$result = $this->getSettings($section);
|
|
|
|
if ($section == 'live.notify') {
|
|
$result['stream_begin_url'] = $result['stream_begin_url'] ?: kg_full_url(['for' => 'home.live_notify'], ['action' => 'streamBegin']);
|
|
$result['stream_end_url'] = $result['stream_end_url'] ?: kg_full_url(['for' => 'home.live_notify'], ['action' => 'streamEnd']);
|
|
$result['record_url'] = $result['record_url'] ?: kg_full_url(['for' => 'home.live_notify'], ['action' => 'record']);
|
|
$result['snapshot_url'] = $result['snapshot_url'] ?: kg_full_url(['for' => 'home.live_notify'], ['action' => 'snapshot']);
|
|
$result['porn_url'] = $result['porn_url'] ?: kg_full_url(['for' => 'home.live_notify'], ['action' => 'porn']);
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
public function getSettings($section)
|
|
{
|
|
$settingsRepo = new SettingRepo();
|
|
|
|
$items = $settingsRepo->findBySection($section);
|
|
|
|
$result = [];
|
|
|
|
/**
|
|
* demo分支过滤敏感数据
|
|
*/
|
|
if ($items->count() > 0) {
|
|
foreach ($items as $item) {
|
|
$case1 = preg_match('/(id|auth|key|secret|password|pwd)$/', $item->item_key);
|
|
$case2 = $this->dispatcher->getControllerName() == 'setting';
|
|
if ($case1 && $case2) {
|
|
$item->item_value = '***';
|
|
}
|
|
$result[$item->item_key] = $item->item_value;
|
|
}
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
public function updateSettings($section, $settings)
|
|
{
|
|
$settingsRepo = new SettingRepo();
|
|
|
|
foreach ($settings as $key => $value) {
|
|
$item = $settingsRepo->findItem($section, $key);
|
|
if ($item) {
|
|
$item->item_value = trim($value);
|
|
$item->update();
|
|
}
|
|
}
|
|
|
|
$cache = new SettingCache();
|
|
|
|
$cache->rebuild($section);
|
|
}
|
|
|
|
public function updateStorageSettings($section, $settings)
|
|
{
|
|
$protocol = ['http://', 'https://'];
|
|
|
|
if (isset($settings['domain'])) {
|
|
$settings['domain'] = str_replace($protocol, '', $settings['domain']);
|
|
}
|
|
|
|
$this->updateSettings($section, $settings);
|
|
}
|
|
|
|
public function updateVodSettings($section, $settings)
|
|
{
|
|
$this->updateSettings($section, $settings);
|
|
}
|
|
|
|
public function updateLiveSettings($section, $settings)
|
|
{
|
|
$protocol = ['http://', 'https://'];
|
|
|
|
if (in_array($section, ['live.push', 'live.pull'])) {
|
|
if (isset($settings['domain'])) {
|
|
$settings['domain'] = str_replace($protocol, '', $settings['domain']);
|
|
}
|
|
}
|
|
|
|
$this->updateSettings($section, $settings);
|
|
}
|
|
|
|
public function updateSmsSettings($section, $settings)
|
|
{
|
|
$settings['template'] = kg_json_encode($settings['template']);
|
|
|
|
$this->updateSettings($section, $settings);
|
|
}
|
|
|
|
public function updateVipSettings($items)
|
|
{
|
|
$vipRepo = new VipRepo();
|
|
|
|
foreach ($items as $id => $price) {
|
|
$vip = $vipRepo->findById($id);
|
|
$vip->price = $price;
|
|
$vip->update();
|
|
}
|
|
}
|
|
|
|
}
|