1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-08-06 06:21:41 +08:00

测试退款,增加若干命令行快捷方法

This commit is contained in:
xiaochong0302 2020-09-24 20:06:36 +08:00
parent c886434ccc
commit 5e5fbedea9
12 changed files with 176 additions and 60 deletions

View File

@ -5,10 +5,19 @@ namespace App\Console\Tasks;
use App\Caches\IndexFreeCourseList as IndexFreeCourseListCache;
use App\Caches\IndexNewCourseList as IndexNewCourseListCache;
use App\Caches\IndexVipCourseList as IndexVipCourseListCache;
use App\Http\Admin\Services\Setting as SettingService;
use App\Library\Utils\Password as PasswordUtil;
use App\Validators\Account as AccountValidator;
class MaintainTask extends Task
{
/**
* 重建首页课程缓存
*
* @param array $params
* @command: php console.php maintain reset_index_course_cache
*/
public function rebuildIndexCourseCacheAction($params)
{
$section = $params[0] ?? null;
@ -29,4 +38,63 @@ class MaintainTask extends Task
}
}
/**
* 修改密码
*
* @param array $params
* @command: php console.php maintain reset_password 13507083515 123456
*/
public function resetPasswordAction($params)
{
if (empty($params[0])) {
echo 'account is required' . PHP_EOL;
}
if (empty($params[1])) {
echo 'password is required' . PHP_EOL;
}
$validator = new AccountValidator();
$account = $validator->checkAccount($params[0]);
$salt = PasswordUtil::salt();
$hash = PasswordUtil::hash($params[1], $salt);
$account->salt = $salt;
$account->password = $hash;
$account->update();
echo 'reset password success' . PHP_EOL;
}
/**
* 关闭验证码
*
* @command: php console.php maintain disable_captcha
*/
public function disableCaptchaAction()
{
$service = new SettingService();
$service->updateSettings('captcha', ['enabled' => 0]);
echo 'disable captcha success' . PHP_EOL;
}
/**
* 启用验证码
*
* @command: php console.php maintain enable_captcha
*/
public function enableCaptchaAction()
{
$service = new SettingService();
$service->updateSettings('captcha', ['enabled' => 1]);
echo 'enable captcha success' . PHP_EOL;
}
}

View File

@ -28,6 +28,8 @@ class VodEventTask extends Task
$this->handleNewFileUploadEvent($event);
} elseif ($event['EventType'] == 'ProcedureStateChanged') {
$this->handleProcedureStateChangedEvent($event);
} elseif ($event['EventType'] == 'FileDeleted') {
$this->handleFileDeletedEvent($event);
}
$count++;
@ -123,6 +125,11 @@ class VodEventTask extends Task
$chapter->update(['attrs' => $attrs]);
}
protected function handleFileDeletedEvent($event)
{
}
protected function pullEvents()
{
$vodService = new VodService();

View File

@ -10,6 +10,7 @@ use App\Repos\Chapter as ChapterRepo;
use App\Repos\Course as CourseRepo;
use App\Services\ChapterVod as ChapterVodService;
use App\Services\CourseStat as CourseStatService;
use App\Services\Vod as VodService;
use App\Validators\ChapterLive as ChapterLiveValidator;
use App\Validators\ChapterRead as ChapterReadValidator;
use App\Validators\ChapterVod as ChapterVodValidator;
@ -100,9 +101,11 @@ class ChapterContent extends Service
$chapter->update(['attrs' => $attrs]);
$courseStats = new CourseStatService();
$this->updateCourseVodAttrs($vod->course_id);
$courseStats->updateVodAttrs($chapter->course_id);
if (!empty($vod->file_id)) {
$this->deleteVodFile($vod->file_id);
}
}
protected function updateChapterLive(ChapterModel $chapter)
@ -135,9 +138,7 @@ class ChapterContent extends Service
$chapter->update(['attrs' => $attrs]);
$courseStats = new CourseStatService();
$courseStats->updateLiveAttrs($chapter->course_id);
$this->updateCourseLiveAttrs($live->course_id);
}
protected function updateChapterRead(ChapterModel $chapter)
@ -164,9 +165,35 @@ class ChapterContent extends Service
$chapter->update(['attrs' => $attrs]);
$courseStats = new CourseStatService();
$this->updateCourseReadAttrs($read->course_id);
}
$courseStats->updateReadAttrs($chapter->course_id);
protected function updateCourseVodAttrs($courseId)
{
$statService = new CourseStatService();
$statService->updateVodAttrs($courseId);
}
protected function updateCourseLiveAttrs($courseId)
{
$statService = new CourseStatService();
$statService->updateLiveAttrs($courseId);
}
protected function updateCourseReadAttrs($courseId)
{
$statService = new CourseStatService();
$statService->updateReadAttrs($courseId);
}
protected function deleteVodFile($fileId)
{
$vodService = new VodService();
$vodService->deleteMedia($fileId);
}
protected function rebuildCatalogCache(ChapterModel $chapter)

View File

@ -2,6 +2,9 @@
{% block content %}
{% set disabled_submit = captcha.enabled == 1 ? 'disabled="disabled"' : '' %}
{% set disabled_class = captcha.enabled == 1 ? 'layui-btn-disabled' : '' %}
<div class="kg-login-wrap">
<div class="layui-card">
<div class="layui-card-header">管理登录</div>
@ -26,8 +29,8 @@
{% endif %}
<div class="layui-form-item">
<div class="layui-input-block">
{% set disabled = captcha.enabled ? 'disabled="disabled"' : '' %}
<button id="submit-btn" class="layui-btn layui-btn-fluid layui-btn-disabled" {{ disabled }} lay-submit="true" lay-filter="go">立即登录</button>
<button id="submit-btn" class="layui-btn layui-btn-fluid {{ disabled_class }}" {{ disabled_submit }} lay-submit="true" lay-filter="go">立即登录</button>
<input type="hidden" name="ticket">
<input type="hidden" name="rand">
</div>

View File

@ -113,7 +113,7 @@
<div class="layui-form-item">
<label class="layui-form-label">请求方法</label>
<div class="layui-input-block">
<input class="layui-input" type="text" name="file" value="DescribeAudioTrackTemplates" readonly="readonly">
<input class="layui-input" type="text" name="file" value="DescribeTranscodeTemplates" readonly="readonly">
</div>
</div>
<div class="layui-form-item">

View File

@ -271,7 +271,7 @@ class Live extends Service
return http_build_query([
'txSecret' => $txSecret,
'txTime' => $txTime
'txTime' => $txTime,
]);
}

View File

@ -37,6 +37,8 @@ Abstract class Smser extends Service
{
$sender = $this->createSingleSender();
$params = $this->formatParams($params);
$signature = $this->getSignature();
try {
@ -71,6 +73,17 @@ Abstract class Smser extends Service
return new SmsSingleSender($this->settings['app_id'], $this->settings['app_key']);
}
protected function formatParams($params)
{
if (!empty($params)) {
$params = array_map(function ($value) {
return strval($value);
}, $params);
}
return $params;
}
protected function getTemplateId($code)
{
$template = json_decode($this->settings['template'], true);

View File

@ -173,7 +173,7 @@ class Storage extends Service
*/
protected function generateFileName($extension = '', $prefix = '')
{
$randName = date('YmdHis') . rand(1000, 9999);
$randName = date('YmdHis') . rand(100, 999) . rand(100, 999);
return $prefix . $randName . '.' . $extension;
}

View File

@ -8,9 +8,10 @@ use TencentCloud\Common\Exception\TencentCloudSDKException;
use TencentCloud\Common\Profile\ClientProfile;
use TencentCloud\Common\Profile\HttpProfile;
use TencentCloud\Vod\V20180717\Models\ConfirmEventsRequest;
use TencentCloud\Vod\V20180717\Models\DescribeAudioTrackTemplatesRequest;
use TencentCloud\Vod\V20180717\Models\DeleteMediaRequest;
use TencentCloud\Vod\V20180717\Models\DescribeMediaInfosRequest;
use TencentCloud\Vod\V20180717\Models\DescribeTaskDetailRequest;
use TencentCloud\Vod\V20180717\Models\DescribeTranscodeTemplatesRequest;
use TencentCloud\Vod\V20180717\Models\ProcessMediaRequest;
use TencentCloud\Vod\V20180717\Models\PullEventsRequest;
use TencentCloud\Vod\V20180717\VodClient;
@ -53,21 +54,21 @@ class Vod extends Service
{
try {
$request = new DescribeAudioTrackTemplatesRequest();
$request = new DescribeTranscodeTemplatesRequest();
$params = '{}';
$request->fromJsonString($params);
$response = $this->client->DescribeAudioTrackTemplates($request);
$response = $this->client->DescribeTranscodeTemplates($request);
$this->logger->debug('Describe Audio Track Templates Response ' . $response->toJsonString());
$this->logger->debug('Describe Transcode Templates Response ' . $response->toJsonString());
$result = $response->TotalCount > 0;
} catch (TencentCloudSDKException $e) {
$this->logger->error('Describe Audio Track Templates Exception ' . kg_json_encode([
$this->logger->error('Describe Transcode Templates Exception ' . kg_json_encode([
'code' => $e->getErrorCode(),
'message' => $e->getMessage(),
'requestId' => $e->getRequestId(),
@ -274,6 +275,44 @@ class Vod extends Service
return $result;
}
/**
* 删除媒体
*
* @param string $fileId
* @return bool
*/
public function deleteMedia($fileId)
{
try {
$request = new DeleteMediaRequest();
$params = json_encode(['FileId' => $fileId]);
$request->fromJsonString($params);
$this->logger->debug('Delete Media Request ' . $params);
$response = $this->client->DeleteMedia($request);
$this->logger->debug('Delete Media Response ' . $response->toJsonString());
$result = !empty($response->RequestId);
} catch (TencentCloudSDKException $e) {
$this->logger->error('Delete Media Exception ' . kg_json_encode([
'code' => $e->getErrorCode(),
'message' => $e->getMessage(),
'requestId' => $e->getRequestId(),
]));
$result = false;
}
return $result;
}
/**
* 获取媒体信息
*
@ -574,7 +613,7 @@ class Vod extends Service
{
$result = null;
if ($this->settings['wmk_enabled'] && $this->settings['wmk_tpl_id'] > 0) {
if ($this->settings['wmk_enabled'] == 1 && $this->settings['wmk_tpl_id'] > 0) {
$result = (int)$this->settings['wmk_tpl_id'];
}

View File

@ -27,17 +27,13 @@ class ConsoleErrorHandler extends Component
*/
public function handleException($e)
{
$config = $this->getConfig();
$logger = $this->getLogger();
$content = sprintf('%s(%d): %s', $e->getFile(), $e->getLine(), $e->getMessage());
$logger->error($content);
if ($config->get('env') == ENV_DEV) {
echo $content;
}
echo $content . PHP_EOL;
}
/**

View File

@ -3668,10 +3668,6 @@ class InitTable extends Phinx\Migration\AbstractMigration
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'create_time',
])
->addIndex(['item_type', 'status'], [
'name' => 'type_status',
'unique' => false,
])
->create();
$this->table('kg_topic', [
'id' => false,

View File

@ -12983,39 +12983,6 @@ return array(
'Index_comment' => '',
),
),
'type_status' =>
array(
1 =>
array(
'Table' => 'kg_task',
'Non_unique' => '1',
'Key_name' => 'type_status',
'Seq_in_index' => '1',
'Column_name' => 'item_type',
'Collation' => 'A',
'Sub_part' => NULL,
'Packed' => NULL,
'Null' => '',
'Index_type' => 'BTREE',
'Comment' => '',
'Index_comment' => '',
),
2 =>
array(
'Table' => 'kg_task',
'Non_unique' => '1',
'Key_name' => 'type_status',
'Seq_in_index' => '2',
'Column_name' => 'status',
'Collation' => 'A',
'Sub_part' => NULL,
'Packed' => NULL,
'Null' => '',
'Index_type' => 'BTREE',
'Comment' => '',
'Index_comment' => '',
),
),
),
'foreign_keys' => NULL,
),