1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-08-01 12:28:09 +08:00

Compare commits

...

40 Commits

Author SHA1 Message Date
xiaochong0302
2c9f3b7577 补充course_user中教师来源类型 2025-06-19 10:02:10 +08:00
xiaochong0302
13b3327b2f 教师可访问其教授课程 2025-06-18 15:45:44 +08:00
xiaochong0302
247050f4ef Merge branch 'koogua/v1.7.8'
# Conflicts:
#	public/static/admin/js/avatar.upload.js
2025-06-15 16:51:20 +08:00
xiaochong0302
57409cb630 v1.7.8 2025-06-15 15:08:42 +08:00
xiaochong0302
4e1e8340b9 1.添加closeLiveTask
2.优化kg-back返回
3.优化统计分析代码位置
2025-06-11 15:01:23 +08:00
xiaochong0302
2ab6ae71cd 1.优化直播状态显示
2.优化关闭注册提示
2025-06-09 22:46:28 +08:00
xiaochong0302
303442f446 搜索结果中图片alt属性增加striptags过滤 2025-06-09 19:08:33 +08:00
xiaochong0302
7281029dd0 sitemap.xml直接写入public目录 2025-06-05 17:53:06 +08:00
xiaochong0302
f5ed2ce239 优化fixbar电话图标 2025-05-26 19:19:12 +08:00
xiaochong0302
2a1b4b69fd fixbar增加电话图标 2025-05-26 10:41:17 +08:00
xiaochong0302
123e1ec97f 后台重置头像->上传头像 2025-05-23 17:03:58 +08:00
xiaochong0302
b2f795eb3b 还原几个不能为空的腾讯云配置 2025-05-22 23:31:26 +08:00
xiaochong0302
12db90d9c1 还原几个不能为空的腾讯云配置 2025-05-22 23:31:12 +08:00
xiaochong0302
59bfe4a765 gitee webhook测试 2025-05-21 11:05:18 +08:00
xiaochong0302
fb0b760e2e 1.优化后台配置默认值
2.后台增加返回顶部功能
3.精简优化逻辑
2025-05-20 18:09:19 +08:00
xiaochong0302
e31b86580d 优化课时列表直播提示 2025-05-20 18:09:15 +08:00
xiaochong0302
f2a446a876 移除Throttle 2025-05-20 18:09:12 +08:00
xiaochong0302
27440fe679 1.优化后台配置默认值
2.后台增加返回顶部功能
3.精简优化逻辑
2025-05-20 18:06:11 +08:00
xiaochong0302
7a9fee5545 优化课时列表直播提示 2025-05-08 17:18:20 +08:00
xiaochong0302
d927e619e8 移除Throttle 2025-05-02 07:55:38 +08:00
xiaochong0302
77cdc594ff 优化layer窗口中表单的跳转 2025-04-20 17:05:30 +08:00
xiaochong0302
0d8b07033a 优化layer窗口中表单的跳转 2025-04-20 17:03:36 +08:00
xiaochong0302
9ad15b72cf 优化倒计时 2025-04-20 17:03:32 +08:00
xiaochong0302
12f0f6dc87 重命令若干路由 2025-04-20 17:03:28 +08:00
xiaochong0302
3efa081e81 LiveChapter -> LiveChat 2025-04-20 17:03:24 +08:00
xiaochong0302
47a6c5cce1 修正workerman中onMessage无法调用问题 2025-04-20 17:03:20 +08:00
xiaochong0302
328aea1e2d 1.优化章节列表UI
2.优化评价UI
2025-04-20 17:03:17 +08:00
xiaochong0302
e5869e1e8f 1.优化课程目录UI
2.优化收藏UI
3.修正收费课程试听问题
2025-04-20 17:03:14 +08:00
xiaochong0302
9fcea65989 1.优化vip页面
2.优化索引管理工具
2025-04-20 17:03:11 +08:00
xiaochong0302
08d3859e38 1.抽离refund.info.js
2.优化获取临时令牌日志
2025-04-03 19:02:48 +08:00
xiaochong0302
02983a27c9 优化微信公众号相关 2025-04-03 19:02:45 +08:00
xiaochong0302
72deb17daa 增强注册验证 2025-04-03 19:02:42 +08:00
xiaochong0302
76edeef591 v1.7.6 2025-03-19 22:09:45 +08:00
xiaochong0302
9c737c7241 更新layui-v2.9.25 2025-03-19 22:09:41 +08:00
xiaochong0302
21f9bdd4b1 去除不必要的deliver阻断 2025-03-19 22:09:36 +08:00
xiaochong0302
9b0700e5c1 统一支付和登录二维码样式 2025-03-19 22:09:23 +08:00
xiaochong0302
054ab77f08 去除多余的引入 2025-03-11 18:51:50 +08:00
xiaochong0302
90ab9bc018 修正文章和问题缓存 2025-03-11 18:48:58 +08:00
xiaochong0302
77b7224901 限制全文搜索长度为50 2025-03-11 18:48:55 +08:00
xiaochong0302
f5665bc94a 修正SiteVisit积分问题 2025-02-25 16:41:48 +08:00
132 changed files with 1182 additions and 1223 deletions

View File

@ -1,4 +1,39 @@
### [v1.7.5](https://gitee.com/koogua/course-tencent-cloud/releases/v1.7.5)(2024-02-22)
### [v1.7.8](https://gitee.com/koogua/course-tencent-cloud/releases/v1.7.8)(2025-06-20)
- 移除ThrottleLimit
- 增加CloseLiveTask
- 增加搜索页图片alt属性striptags过滤
- 后台增加返回顶部快捷方式
- 前台fixbar增加联系电话
- 优化安装脚本
- 优化课时列表直播提示
- 优化后台返回链接
- 优化统计分析代码位置
- 直播回调后更新课时缓存
- 后台清空头像->上传头像
- sitemap.xml直接写入网站根目录
### [v1.7.7](https://gitee.com/koogua/course-tencent-cloud/releases/v1.7.7)(2025-04-20)
- 优化索引管理工具
- 优化章节等页面UI
- 修正workerman中onMessage问题
- 修正非免费课程试听问题
- 优化layer窗口中的表单跳转
- 文件清理以及命名优化
- 优化倒计时
### [v1.7.6](https://gitee.com/koogua/course-tencent-cloud/releases/v1.7.6)(2025-03-22)
- 升级layui-v2.9.25
- 去除发货中不必要的异常抛出
- 去除文章和问题缓存重建
- 去除多余的文件引用
- 修正每日访问站点积分问题
- 限制全文搜索关键字长度
- 统一规划二维码样式
### [v1.7.5](https://gitee.com/koogua/course-tencent-cloud/releases/v1.7.5)(2025-02-22)
- 优化后台统计图表
- 优化图片放大查看

View File

@ -1,6 +1,6 @@
## 酷瓜云课堂
![酷瓜云课堂](https://portal-1255691183.file.myqcloud.com/img/content/61dd395c053e5.png)
[![酷瓜云课堂-开源知识付费解决方案](https://portal-1255691183.file.myqcloud.com/img/content/63ec392618bd5.png)](https://www.koogua.com)
### 系统介绍
@ -63,4 +63,4 @@ Tips: 请用手机注册一个新账号,用户中心 -> 关注订阅,扫码
- [码云平台](https://gitee.com/koogua/course-tencent-cloud/issues)
- [官方社区](https://www.koogua.com/community)
- QQ交流群: 788459713
- QQ交流群: 787363898

View File

@ -18,6 +18,13 @@ abstract class Migration
abstract public function run();
protected function saveSettings(array $settings)
{
foreach ($settings as $setting) {
$this->saveSetting($setting);
}
}
protected function saveSetting(array $setting)
{
$settingRepo = new SettingRepo();
@ -32,4 +39,4 @@ abstract class Migration
}
}
}
}

View File

@ -20,8 +20,6 @@ class ArticleIndexTask extends Task
* 搜索测试
*
* @command: php console.php article_index search {query}
* @param array $params
* @throws \XSException
*/
public function searchAction($params)
{
@ -31,7 +29,9 @@ class ArticleIndexTask extends Task
exit('please special a query word' . PHP_EOL);
}
$result = $this->searchArticles($query);
$handler = new ArticleSearcher();
$result = $handler->search($query);
var_export($result);
}
@ -42,24 +42,6 @@ class ArticleIndexTask extends Task
* @command: php console.php article_index clean
*/
public function cleanAction()
{
$this->cleanArticleIndex();
}
/**
* 重建索引
*
* @command: php console.php article_index rebuild
*/
public function rebuildAction()
{
$this->rebuildArticleIndex();
}
/**
* 清空索引
*/
protected function cleanArticleIndex()
{
$handler = new ArticleSearcher();
@ -74,8 +56,10 @@ class ArticleIndexTask extends Task
/**
* 重建索引
*
* @command: php console.php article_index rebuild
*/
protected function rebuildArticleIndex()
public function rebuildAction()
{
$articles = $this->findArticles();
@ -83,7 +67,7 @@ class ArticleIndexTask extends Task
$handler = new ArticleSearcher();
$documenter = new ArticleDocument();
$doc = new ArticleDocument();
$index = $handler->getXS()->getIndex();
@ -92,7 +76,7 @@ class ArticleIndexTask extends Task
$index->beginRebuild();
foreach ($articles as $article) {
$document = $documenter->setDocument($article);
$document = $doc->setDocument($article);
$index->add($document);
}
@ -102,17 +86,39 @@ class ArticleIndexTask extends Task
}
/**
* 搜索文章
* 刷新索引缓存
*
* @param string $query
* @return array
* @throws \XSException
* @command: php console.php article_index flush_index
*/
protected function searchArticles($query)
public function flushIndexAction()
{
$handler = new ArticleSearcher();
return $handler->search($query);
$index = $handler->getXS()->getIndex();
echo '------ start flush article index ------' . PHP_EOL;
$index->flushIndex();
echo '------ end flush article index ------' . PHP_EOL;
}
/**
* 刷新搜索日志
*
* @command: php console.php article_index flush_logging
*/
public function flushLoggingAction()
{
$handler = new ArticleSearcher();
$index = $handler->getXS()->getIndex();
echo '------ start flush article logging ------' . PHP_EOL;
$index->flushLogging();
echo '------ end flush article logging ------' . PHP_EOL;
}
/**

View File

@ -0,0 +1,72 @@
<?php
/**
* @copyright Copyright (c) 2024 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
namespace App\Console\Tasks;
use App\Caches\CourseChapterList as CourseChapterListCache;
use App\Models\Chapter as ChapterModel;
use App\Models\ChapterLive as ChapterLiveModel;
use App\Repos\Chapter as ChapterRepo;
use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface;
class CloseLiveTask extends Task
{
public function mainAction()
{
$chapterLives = $this->findChapterLives();
echo sprintf('pending lives: %s', $chapterLives->count()) . PHP_EOL;
if ($chapterLives->count() == 0) return;
echo '------ start close live task ------' . PHP_EOL;
foreach ($chapterLives as $chapterLive) {
$chapterLive->status = ChapterLiveModel::STATUS_INACTIVE;
$chapterLive->update();
$chapterRepo = new ChapterRepo();
$chapter = $chapterRepo->findById($chapterLive->chapter_id);
$attrs = $chapter->attrs;
$attrs['stream']['status'] = ChapterModel::SS_INACTIVE;
$chapter->attrs = $attrs;
$chapter->update();
$cache = new CourseChapterListCache();
$cache->rebuild($chapterLive->course_id);
}
echo '------ end close live task ------' . PHP_EOL;
}
/**
* 查找待关闭直播
*
* @param int $limit
* @return ResultsetInterface|Resultset|ChapterLiveModel[]
*/
protected function findChapterLives(int $limit = 100)
{
$status = ChapterLiveModel::STATUS_ACTIVE;
$endTime = time() - 3600;
return ChapterLiveModel::query()
->where('status = :status:', ['status' => $status])
->andWhere('end_time < :end_time:', ['end_time' => $endTime])
->limit($limit)
->execute();
}
}

View File

@ -20,8 +20,6 @@ class CourseIndexTask extends Task
* 搜索测试
*
* @command: php console.php course_index search {query}
* @param array $params
* @throws \XSException
*/
public function searchAction($params)
{
@ -31,7 +29,9 @@ class CourseIndexTask extends Task
exit('please special a query word' . PHP_EOL);
}
$result = $this->searchCourses($query);
$handler = new CourseSearcher();
$result = $handler->search($query);
var_export($result);
}
@ -42,24 +42,6 @@ class CourseIndexTask extends Task
* @command: php console.php course_index clean
*/
public function cleanAction()
{
$this->cleanCourseIndex();
}
/**
* 重建索引
*
* @command: php console.php course_index rebuild
*/
public function rebuildAction()
{
$this->rebuildCourseIndex();
}
/**
* 清空索引
*/
protected function cleanCourseIndex()
{
$handler = new CourseSearcher();
@ -74,8 +56,10 @@ class CourseIndexTask extends Task
/**
* 重建索引
*
* @command: php console.php course_index rebuild
*/
protected function rebuildCourseIndex()
public function rebuildAction()
{
$courses = $this->findCourses();
@ -83,7 +67,7 @@ class CourseIndexTask extends Task
$handler = new CourseSearcher();
$documenter = new CourseDocument();
$doc = new CourseDocument();
$index = $handler->getXS()->getIndex();
@ -92,7 +76,7 @@ class CourseIndexTask extends Task
$index->beginRebuild();
foreach ($courses as $course) {
$document = $documenter->setDocument($course);
$document = $doc->setDocument($course);
$index->add($document);
}
@ -102,17 +86,39 @@ class CourseIndexTask extends Task
}
/**
* 搜索课程
* 刷新索引缓存
*
* @param string $query
* @return array
* @throws \XSException
* @command: php console.php course_index flush_index
*/
protected function searchCourses($query)
public function flushIndexAction()
{
$handler = new CourseSearcher();
return $handler->search($query);
$index = $handler->getXS()->getIndex();
echo '------ start flush course index ------' . PHP_EOL;
$index->flushIndex();
echo '------ end flush course index ------' . PHP_EOL;
}
/**
* 刷新搜索日志
*
* @command: php console.php course_index flush_logging
*/
public function flushLoggingAction()
{
$handler = new CourseSearcher();
$index = $handler->getXS()->getIndex();
echo '------ start flush course logging ------' . PHP_EOL;
$index->flushLogging();
echo '------ end flush course logging ------' . PHP_EOL;
}
/**
@ -124,7 +130,7 @@ class CourseIndexTask extends Task
{
return CourseModel::query()
->where('published = 1')
->where('deleted = 0')
->andWhere('deleted = 0')
->execute();
}

View File

@ -58,8 +58,6 @@ class DeliverTask extends Task
case OrderModel::ITEM_VIP:
$this->handleVipOrder($order);
break;
default:
$this->noMatchedHandler($order);
}
$order->status = OrderModel::STATUS_FINISHED;
@ -155,11 +153,6 @@ class DeliverTask extends Task
$this->closePendingOrders($user->id);
}
protected function noMatchedHandler(OrderModel $order)
{
throw new \RuntimeException("No Matched Handler For Order: {$order->id}");
}
protected function closePendingOrders($userId)
{
$orders = $this->findUserPendingOrders($userId);

View File

@ -20,8 +20,6 @@ class QuestionIndexTask extends Task
* 搜索测试
*
* @command: php console.php question_index search {query}
* @param array $params
* @throws \XSException
*/
public function searchAction($params)
{
@ -31,7 +29,9 @@ class QuestionIndexTask extends Task
exit('please special a query word' . PHP_EOL);
}
$result = $this->searchQuestions($query);
$handler = new QuestionSearcher();
$result = $handler->search($query);
var_export($result);
}
@ -42,24 +42,6 @@ class QuestionIndexTask extends Task
* @command: php console.php question_index clean
*/
public function cleanAction()
{
$this->cleanQuestionIndex();
}
/**
* 重建索引
*
* @command: php console.php question_index rebuild
*/
public function rebuildAction()
{
$this->rebuildQuestionIndex();
}
/**
* 清空索引
*/
protected function cleanQuestionIndex()
{
$handler = new QuestionSearcher();
@ -74,8 +56,10 @@ class QuestionIndexTask extends Task
/**
* 重建索引
*
* @command: php console.php question_index rebuild
*/
protected function rebuildQuestionIndex()
public function rebuildAction()
{
$questions = $this->findQuestions();
@ -83,7 +67,7 @@ class QuestionIndexTask extends Task
$handler = new QuestionSearcher();
$documenter = new QuestionDocument();
$doc = new QuestionDocument();
$index = $handler->getXS()->getIndex();
@ -92,7 +76,7 @@ class QuestionIndexTask extends Task
$index->beginRebuild();
foreach ($questions as $question) {
$document = $documenter->setDocument($question);
$document = $doc->setDocument($question);
$index->add($document);
}
@ -102,17 +86,39 @@ class QuestionIndexTask extends Task
}
/**
* 搜索文章
* 刷新索引缓存
*
* @param string $query
* @return array
* @throws \XSException
* @command: php console.php question_index flush_index
*/
protected function searchQuestions($query)
public function flushIndexAction()
{
$handler = new QuestionSearcher();
return $handler->search($query);
$index = $handler->getXS()->getIndex();
echo '------ start flush question index ------' . PHP_EOL;
$index->flushIndex();
echo '------ end flush question index ------' . PHP_EOL;
}
/**
* 刷新搜索日志
*
* @command: php console.php question_index flush_logging
*/
public function flushLoggingAction()
{
$handler = new QuestionSearcher();
$index = $handler->getXS()->getIndex();
echo '------ start flush question logging ------' . PHP_EOL;
$index->flushLogging();
echo '------ end flush question logging ------' . PHP_EOL;
}
/**

View File

@ -37,7 +37,7 @@ class SitemapTask extends Task
$this->sitemap = new Sitemap();
$filename = tmp_path('sitemap.xml');
$filename = public_path('sitemap.xml');
echo '------ start sitemap task ------' . PHP_EOL;

View File

@ -13,12 +13,12 @@ use GuzzleHttp\Client;
class SyncAppInfoTask extends Task
{
const API_BASE_URL = 'https://www.koogua.com/api';
public function mainAction()
{
echo '------ start sync app info ------' . PHP_EOL;
$url = 'https://www.koogua.com/api/instance/collect';
$site = $this->getSettings('site');
$serverHost = parse_url($site['url'], PHP_URL_HOST);
@ -38,6 +38,8 @@ class SyncAppInfoTask extends Task
$client = new Client();
$url = sprintf('%s/instance/collect', self::API_BASE_URL);
$client->request('POST', $url, ['form_params' => $params]);
echo '------ end sync app info ------' . PHP_EOL;

View File

@ -71,28 +71,6 @@ class UploadController extends Controller
return $this->jsonSuccess(['data' => $data]);
}
/**
* @Post("/avatar/img", name="admin.upload.avatar_img")
*/
public function uploadAvatarImageAction()
{
$service = new StorageService();
$file = $service->uploadAvatarImage();
if (!$file) {
return $this->jsonError(['msg' => '上传文件失败']);
}
$data = [
'id' => $file->id,
'name' => $file->name,
'url' => $service->getImageUrl($file->path),
];
return $this->jsonSuccess(['data' => $data]);
}
/**
* @Post("/content/img", name="admin.upload.content_img")
*/

View File

@ -9,10 +9,8 @@ namespace App\Http\Admin\Services;
use App\Builders\ArticleList as ArticleListBuilder;
use App\Builders\ReportList as ReportListBuilder;
use App\Caches\Article as ArticleCache;
use App\Http\Admin\Services\Traits\AccountSearchTrait;
use App\Library\Paginator\Query as PagerQuery;
use App\Library\Utils\Word as WordUtil;
use App\Models\Article as ArticleModel;
use App\Models\Category as CategoryModel;
use App\Models\Reason as ReasonModel;
@ -137,7 +135,6 @@ class Article extends Service
$article->create();
$this->saveDynamicAttrs($article);
$this->rebuildArticleCache($article);
$this->rebuildArticleIndex($article);
$this->recountUserArticles($user);
@ -208,7 +205,6 @@ class Article extends Service
$owner = $this->findUser($article->owner_id);
$this->saveDynamicAttrs($article);
$this->rebuildArticleCache($article);
$this->rebuildArticleIndex($article);
$this->recountUserArticles($owner);
@ -228,7 +224,6 @@ class Article extends Service
$owner = $this->findUser($article->owner_id);
$this->saveDynamicAttrs($article);
$this->rebuildArticleCache($article);
$this->rebuildArticleIndex($article);
$this->recountUserArticles($owner);
@ -248,7 +243,6 @@ class Article extends Service
$owner = $this->findUser($article->owner_id);
$this->saveDynamicAttrs($article);
$this->rebuildArticleCache($article);
$this->rebuildArticleIndex($article);
$this->recountUserArticles($owner);
@ -287,7 +281,6 @@ class Article extends Service
$owner = $this->findUser($article->owner_id);
$this->rebuildArticleCache($article);
$this->rebuildArticleIndex($article);
$this->recountUserArticles($owner);
@ -323,7 +316,6 @@ class Article extends Service
$owner = $this->findUser($article->owner_id);
$this->rebuildArticleCache($article);
$this->rebuildArticleIndex($article);
$this->recountUserArticles($owner);
}
@ -362,7 +354,6 @@ class Article extends Service
$owner = $this->findUser($article->owner_id);
$this->recountUserArticles($owner);
$this->rebuildArticleCache($article);
$this->rebuildArticleIndex($article);
}
}
@ -389,7 +380,6 @@ class Article extends Service
$owner = $this->findUser($article->owner_id);
$this->recountUserArticles($owner);
$this->rebuildArticleCache($article);
$this->rebuildArticleIndex($article);
}
}
@ -408,13 +398,6 @@ class Article extends Service
return $userRepo->findById($id);
}
protected function rebuildArticleCache(ArticleModel $article)
{
$cache = new ArticleCache();
$cache->rebuild($article->id);
}
protected function rebuildArticleIndex(ArticleModel $article)
{
$sync = new ArticleIndexSync();

View File

@ -251,14 +251,16 @@ class ChapterContent extends Service
$content = $validator->checkContent($post['content']);
$read->update(['content' => $content]);
$read->content = $content;
$read->update();
$attrs = $chapter->attrs;
$attrs['word_count'] = WordUtil::getWordCount($content);
$attrs['duration'] = WordUtil::getWordDuration($content);
$chapter->attrs = $attrs;
$chapter->update(['attrs' => $attrs]);
$chapter->update();
$this->updateCourseReadAttrs($read->course_id);
}

View File

@ -9,7 +9,6 @@ namespace App\Http\Admin\Services;
use App\Builders\QuestionList as QuestionListBuilder;
use App\Builders\ReportList as ReportListBuilder;
use App\Caches\Question as QuestionCache;
use App\Http\Admin\Services\Traits\AccountSearchTrait;
use App\Library\Paginator\Query as PagerQuery;
use App\Models\Category as CategoryModel;
@ -131,7 +130,6 @@ class Question extends Service
$question->create();
$this->saveDynamicAttrs($question);
$this->rebuildQuestionCache($question);
$this->rebuildQuestionIndex($question);
$this->recountUserQuestions($user);
@ -195,7 +193,6 @@ class Question extends Service
$owner = $this->findUser($question->owner_id);
$this->saveDynamicAttrs($question);
$this->rebuildQuestionCache($question);
$this->rebuildQuestionIndex($question);
$this->recountUserQuestions($owner);
@ -219,7 +216,6 @@ class Question extends Service
$owner = $this->findUser($question->owner_id);
$this->saveDynamicAttrs($question);
$this->rebuildQuestionCache($question);
$this->rebuildQuestionIndex($question);
$this->recountUserQuestions($owner);
@ -238,7 +234,6 @@ class Question extends Service
$owner = $this->findUser($question->owner_id);
$this->rebuildQuestionCache($question);
$this->rebuildQuestionIndex($question);
$this->recountUserQuestions($owner);
@ -278,7 +273,6 @@ class Question extends Service
$owner = $this->findUser($question->owner_id);
$this->recountUserQuestions($owner);
$this->rebuildQuestionCache($question);
$this->rebuildQuestionIndex($question);
return $question;
@ -313,7 +307,6 @@ class Question extends Service
$owner = $this->findUser($question->owner_id);
$this->rebuildQuestionCache($question);
$this->rebuildQuestionIndex($question);
$this->recountUserQuestions($owner);
}
@ -352,7 +345,6 @@ class Question extends Service
$owner = $this->findUser($question->owner_id);
$this->recountUserQuestions($owner);
$this->rebuildQuestionCache($question);
$this->rebuildQuestionIndex($question);
}
}
@ -379,7 +371,6 @@ class Question extends Service
$owner = $this->findUser($question->owner_id);
$this->recountUserQuestions($owner);
$this->rebuildQuestionCache($question);
$this->rebuildQuestionIndex($question);
}
}
@ -398,13 +389,6 @@ class Question extends Service
return $userRepo->findById($id);
}
protected function rebuildQuestionCache(QuestionModel $question)
{
$cache = new QuestionCache();
$cache->rebuild($question->id);
}
protected function rebuildQuestionIndex(QuestionModel $question)
{
$sync = new QuestionIndexSync();

View File

@ -52,8 +52,8 @@ class Setting extends Service
{
$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']);
$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;
}
@ -62,8 +62,8 @@ class Setting extends Service
{
$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']);
$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;
}
@ -109,11 +109,11 @@ class Setting extends Service
$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']);
$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;

View File

@ -9,7 +9,7 @@
<div class="kg-nav-left">
<span class="layui-breadcrumb">
{% if parent.id > 0 %}
<a class="kg-back" href="{{ back_url }}"><i class="layui-icon layui-icon-return"></i>返回</a>
<a href="{{ back_url }}"><i class="layui-icon layui-icon-return"></i>返回</a>
<a><cite>{{ parent.name }}</cite></a>
{% endif %}
<a><cite>分类管理</cite></a>
@ -87,4 +87,4 @@
</tbody>
</table>
{% endblock %}
{% endblock %}

View File

@ -88,7 +88,7 @@
layer.open({
type: 2,
title: '推流测试',
area: ['720px', '500px'],
area: ['720px', '540px'],
content: [url, 'no']
});
});
@ -97,4 +97,4 @@
</script>
{% endblock %}
{% endblock %}

View File

@ -43,7 +43,7 @@
<div class="kg-nav">
<div class="kg-nav-left">
<span class="layui-breadcrumb">
<a class="kg-back" href="{{ back_url }}"><i class="layui-icon layui-icon-return"></i>返回</a>
<a href="{{ back_url }}"><i class="layui-icon layui-icon-return"></i>返回</a>
<a><cite>{{ course.title }}</cite></a>
<a><cite>{{ chapter.title }}</cite></a>
<a><cite>课时管理</cite></a>
@ -126,4 +126,4 @@
</tbody>
</table>
{% endblock %}
{% endblock %}

View File

@ -9,7 +9,7 @@
<div class="kg-nav">
<div class="kg-nav-left">
<span class="layui-breadcrumb">
<a class="kg-back" href="{{ back_url }}"><i class="layui-icon layui-icon-return"></i>返回</a>
<a href="{{ back_url }}"><i class="layui-icon layui-icon-return"></i>返回</a>
<a><cite>{{ course.title }}</cite></a>
<a><cite>章节管理</cite></a>
</span>
@ -79,4 +79,4 @@
</tbody>
</table>
{% endblock %}
{% endblock %}

View File

@ -3,7 +3,6 @@
<table class="kg-table layui-table">
<tr>
<th>名称</th>
<th>类型</th>
<th>大小</th>
<th>日期</th>
<th width="15%">操作</th>
@ -13,7 +12,6 @@
{% set delete_url = url({'for':'admin.resource.delete','id':item.id}) %}
<tr>
<td><input class="layui-input res-name" type="text" value="{{ item.upload.name }}" data-url="{{ update_url }}"></td>
<td>{{ item.upload.mime }}</td>
<td>{{ item.upload.size|human_size }}</td>
<td>{{ date('Y-m-d H:i:s',item.create_time) }}</td>
<td>
@ -27,4 +25,4 @@
{% else %}
<div class="kg-center">没有相关资料</div>
<br>
{% endif %}
{% endif %}

View File

@ -6,7 +6,7 @@
<div class="layui-card-body">
<table class="layui-table">
<colgroup>
<col width="100">
<col width="25%">
<col>
</colgroup>
<tbody>
@ -24,4 +24,4 @@
</tbody>
</table>
</div>
</div>
</div>

View File

@ -1,9 +1,9 @@
<div class="layui-card layui-text" xmlns="http://www.w3.org/1999/html">
<div class="layui-card layui-text">
<div class="layui-card-header">服务器信息</div>
<div class="layui-card-body">
<table class="layui-table">
<colgroup>
<col width="100">
<col width="25%">
<col>
</colgroup>
<tbody>
@ -22,4 +22,4 @@
</tbody>
</table>
</div>
</div>
</div>

View File

@ -3,7 +3,7 @@
<div class="layui-card-body">
<table class="layui-table">
<colgroup>
<col width="100">
<col width="25%">
<col>
</colgroup>
<tbody>
@ -26,4 +26,4 @@
</tbody>
</table>
</div>
</div>
</div>

View File

@ -11,9 +11,11 @@
积分兑换
{% elseif value == 6 %}
抽奖兑换
{% elseif value == 7 %}
教师
{% elseif value == 10 %}
试听
{% else %}
N/A
{% endif %}
{%- endmacro %}
{%- endmacro %}

View File

@ -25,9 +25,7 @@
<div class="kg-nav-left">
<span class="layui-breadcrumb">
{% if parent.id > 0 %}
<a class="kg-back" href="{{ back_url }}">
<i class="layui-icon layui-icon-return"></i> 返回
</a>
<a href="{{ back_url }}"><i class="layui-icon layui-icon-return"></i>返回</a>
<a><cite>{{ parent.name }}</cite></a>
{% endif %}
<a><cite>导航管理</cite></a>

View File

@ -65,7 +65,7 @@
layer.open({
type: 2,
title: '推流测试',
area: ['720px', '500px'],
area: ['720px', '540px'],
content: [url, 'no']
});
});
@ -85,4 +85,4 @@
</script>
{% endblock %}
{% endblock %}

View File

@ -34,7 +34,7 @@
type: 2,
title: '支付宝 - 支付测试',
resize: false,
area: ['640px', '300px'],
area: ['640px', '320px'],
content: [url, 'no']
});
});
@ -45,7 +45,7 @@
type: 2,
title: '微信 - 支付测试',
resize: false,
area: ['640px', '300px'],
area: ['640px', '320px'],
content: [url, 'no']
});
});
@ -54,4 +54,4 @@
</script>
{% endblock %}
{% endblock %}

View File

@ -20,9 +20,10 @@
{{ js_include('lib/layui/layui.js') }}
{{ js_include('admin/js/common.js') }}
{{ js_include('admin/js/fixbar.js') }}
{% block include_js %}{% endblock %}
{% block inline_js %}{% endblock %}
</body>
</html>
</html>

View File

@ -21,12 +21,11 @@
<div class="layui-form-item">
<label class="layui-form-label" style="padding-top:30px;">头像</label>
<div class="layui-input-inline" style="width:80px;">
<img id="avatar" class="kg-avatar" src="{{ user.avatar }}">
<img id="img-avatar" class="kg-avatar" src="{{ user.avatar }}">
<input type="hidden" name="avatar" value="{{ user.avatar }}">
<input type="hidden" name="default_avatar" value="{{ default_avatar }}">
</div>
<div class="layui-input-inline" style="padding-top:25px;">
<button id="clear-avatar" class="layui-btn layui-btn-sm" type="button">清空</button>
<button id="change-avatar" class="layui-btn layui-btn-sm" type="button">更换</button>
</div>
</div>
<div class="layui-form-item">
@ -153,6 +152,12 @@
{% endblock %}
{% block include_js %}
{{ js_include('admin/js/avatar.upload.js') }}
{% endblock %}
{% block inline_js %}
<script>
@ -163,12 +168,6 @@
var form = layui.form;
var laydate = layui.laydate;
$('#clear-avatar').on('click', function () {
var defaultAvatar = $('input[name=default_avatar]').val();
$('input[name=avatar]').val(defaultAvatar);
$('#avatar').attr('src', defaultAvatar);
});
laydate.render({
elem: 'input[name=vip_expiry_time]',
type: 'datetime'
@ -201,4 +200,4 @@
</script>
{% endblock %}
{% endblock %}

View File

@ -30,8 +30,6 @@ class Controller extends \Phalcon\Mvc\Controller
$this->setCors();
}
$this->checkRateLimit();
return true;
}

View File

@ -7,7 +7,7 @@
namespace App\Http\Api\Controllers;
use App\Services\Logic\Live\LiveChapter as LiveChapterService;
use App\Services\Logic\Live\LiveChat as LiveChatService;
use App\Services\Logic\Live\LiveList as LiveListService;
/**
@ -33,7 +33,7 @@ class LiveController extends Controller
*/
public function chatsAction($id)
{
$service = new LiveChapterService();
$service = new LiveChatService();
$chats = $service->getRecentChats($id);
@ -45,7 +45,7 @@ class LiveController extends Controller
*/
public function statsAction($id)
{
$service = new LiveChapterService();
$service = new LiveChatService();
$stats = $service->getStats($id);
@ -57,7 +57,7 @@ class LiveController extends Controller
*/
public function statusAction($id)
{
$service = new LiveChapterService();
$service = new LiveChatService();
$status = $service->getStatus($id);
@ -69,7 +69,7 @@ class LiveController extends Controller
*/
public function bindUserAction($id)
{
$service = new LiveChapterService();
$service = new LiveChatService();
$service->bindUser($id);
@ -81,7 +81,7 @@ class LiveController extends Controller
*/
public function sendMessageAction($id)
{
$service = new LiveChapterService();
$service = new LiveChatService();
$message = $service->sendMessage($id);

View File

@ -34,7 +34,7 @@ class AccountController extends Controller
}
if ($this->authUser->id > 0) {
return $this->response->redirect('/');
return $this->response->redirect(['for' => 'home.index']);
}
$returnUrl = $this->request->getHTTPReferer();
@ -62,7 +62,7 @@ class AccountController extends Controller
}
if ($this->authUser->id > 0) {
return $this->response->redirect('/');
return $this->response->redirect(['for' => 'home.index']);
}
$service = new OAuthProviderService();
@ -105,7 +105,7 @@ class AccountController extends Controller
return $this->response->redirect(['for' => 'home.index']);
}
$this->seo->prependTitle('重置密码');
$this->seo->prependTitle('忘记密码');
}
/**
@ -119,9 +119,11 @@ class AccountController extends Controller
$returnUrl = $this->request->getPost('return_url', 'string');
$location = $returnUrl ?: $this->url->get(['for' => 'home.index']);
$content = [
'location' => $returnUrl ?: '/',
'msg' => '注册成功',
'location' => $location,
'msg' => '注册账号成功',
];
return $this->jsonSuccess($content);
@ -140,7 +142,12 @@ class AccountController extends Controller
$location = $returnUrl ?: $this->url->get(['for' => 'home.index']);
return $this->jsonSuccess(['location' => $location]);
$content = [
'location' => $location,
'msg' => '登录账号成功',
];
return $this->jsonSuccess($content);
}
/**
@ -156,7 +163,12 @@ class AccountController extends Controller
$location = $returnUrl ?: $this->url->get(['for' => 'home.index']);
return $this->jsonSuccess(['location' => $location]);
$content = [
'location' => $location,
'msg' => '登录账号成功',
];
return $this->jsonSuccess($content);
}
/**

View File

@ -120,27 +120,21 @@ class ConnectController extends Controller
$service = new ConnectService();
$openUser = $service->getOpenUserInfo($code, $state, $provider);
$connect = $service->getConnectRelation($openUser['id'], $openUser['provider']);
if ($this->authUser->id > 0) {
if ($openUser) {
$service->bindUser($openUser);
return $this->response->redirect(['for' => 'home.uc.account']);
}
} else {
if ($connect) {
$service->authConnectLogin($connect);
return $this->response->redirect(['for' => 'home.index']);
}
if ($this->authUser->id > 0 && $openUser) {
$service->bindUser($openUser);
return $this->response->redirect(['for' => 'home.uc.account']);
}
$captcha = $service->getSettings('captcha');
if ($this->authUser->id == 0 && $connect) {
$service->authConnectLogin($connect);
return $this->response->redirect(['for' => 'home.index']);
}
$this->seo->prependTitle('绑定帐号');
$this->view->pick('connect/bind');
$this->view->setVar('captcha', $captcha);
$this->view->setVar('provider', $provider);
$this->view->setVar('open_user', $openUser);
}

View File

@ -77,8 +77,14 @@ class ConsultController extends Controller
$consult = $service->handle($consult->id);
$location = $this->url->get([
'for' => 'home.course.show',
'id' => $consult['course']['id'],
]);
$content = [
'consult' => $consult,
'location' => $location,
'target' => 'parent',
'msg' => '提交咨询成功',
];
@ -92,14 +98,13 @@ class ConsultController extends Controller
{
$service = new ConsultUpdateService();
$consult = $service->handle($id);
$service->handle($id);
$service = new ConsultInfoService();
$consult = $service->handle($consult->id);
$location = $this->url->get(['for' => 'home.uc.consults']);
$content = [
'consult' => $consult,
'location' => $location,
'target' => 'parent',
'msg' => '更新咨询成功',
];
@ -127,14 +132,13 @@ class ConsultController extends Controller
$service = new ConsultReplyService();
$consult = $service->handle($id);
$service->handle($id);
$service = new ConsultInfoService();
$consult = $service->handle($consult->id);
$location = $this->url->get(['for' => 'home.tc.consults']);
$content = [
'consult' => $consult,
'location' => $location,
'target' => 'parent',
'msg' => '回复咨询成功',
];

View File

@ -77,8 +77,6 @@ class Controller extends \Phalcon\Mvc\Controller
$this->checkCsrfToken();
}
$this->checkRateLimit();
return true;
}

View File

@ -37,8 +37,6 @@ class LayerController extends \Phalcon\Mvc\Controller
$this->checkCsrfToken();
}
$this->checkRateLimit();
return true;
}

View File

@ -7,7 +7,7 @@
namespace App\Http\Home\Controllers;
use App\Services\Logic\Live\LiveChapter as LiveChapterService;
use App\Services\Logic\Live\LiveChat as LiveChatService;
use Phalcon\Mvc\View;
/**
@ -21,7 +21,7 @@ class LiveController extends Controller
*/
public function chatsAction($id)
{
$service = new LiveChapterService();
$service = new LiveChatService();
$chats = $service->getRecentChats($id);
@ -35,7 +35,7 @@ class LiveController extends Controller
*/
public function statsAction($id)
{
$service = new LiveChapterService();
$service = new LiveChatService();
$stats = $service->getStats($id);
@ -47,7 +47,7 @@ class LiveController extends Controller
*/
public function statusAction($id)
{
$service = new LiveChapterService();
$service = new LiveChatService();
$status = $service->getStatus($id);
@ -59,7 +59,7 @@ class LiveController extends Controller
*/
public function bindUserAction($id)
{
$service = new LiveChapterService();
$service = new LiveChatService();
$service->bindUser($id);
@ -71,7 +71,7 @@ class LiveController extends Controller
*/
public function sendMessageAction($id)
{
$service = new LiveChapterService();
$service = new LiveChatService();
$response = $service->sendMessage($id);

View File

@ -104,7 +104,7 @@ class PublicController extends \Phalcon\Mvc\Controller
}
/**
* @Get("/alipay/callback", name="home.alipay_callback")
* @Get("/alipay/callback", name="home.alipay.callback")
*/
public function alipayCallbackAction()
{
@ -112,7 +112,7 @@ class PublicController extends \Phalcon\Mvc\Controller
}
/**
* @Get("/wxpay/callback", name="home.wxpay_callback")
* @Get("/wxpay/callback", name="home.wxpay.callback")
*/
public function wxpayCallbackAction()
{
@ -120,7 +120,7 @@ class PublicController extends \Phalcon\Mvc\Controller
}
/**
* @Post("/alipay/notify", name="home.alipay_notify")
* @Post("/alipay/notify", name="home.alipay.notify")
*/
public function alipayNotifyAction()
{
@ -136,7 +136,7 @@ class PublicController extends \Phalcon\Mvc\Controller
}
/**
* @Post("/wxpay/notify", name="home.wxpay_notify")
* @Post("/wxpay/notify", name="home.wxpay.notify")
*/
public function wxpayNotifyAction()
{
@ -188,7 +188,7 @@ class PublicController extends \Phalcon\Mvc\Controller
}
/**
* @Post("/live/notify", name="home.live_notify")
* @Post("/live/notify", name="home.live.notify")
*/
public function liveNotifyAction()
{
@ -198,6 +198,7 @@ class PublicController extends \Phalcon\Mvc\Controller
return $this->jsonSuccess();
} else {
$this->response->setStatusCode(403);
return $this->jsonError();
}
}

View File

@ -49,7 +49,15 @@ class RefundController extends Controller
$service->handle();
return $this->jsonSuccess(['msg' => '申请退款成功']);
$location = $this->url->get(['for' => 'home.uc.refunds']);
$content = [
'location' => $location,
'target' => 'parent',
'msg' => '提交申请成功',
];
return $this->jsonSuccess($content);
}
/**

View File

@ -55,13 +55,6 @@ class ReviewController extends Controller
$this->notFound();
}
$approved = $review['published'] == ReviewModel::PUBLISH_APPROVED;
$owned = $review['me']['owned'] == 1;
if (!$approved && !$owned) {
$this->notFound();
}
return $this->jsonSuccess(['review' => $review]);
}
@ -72,14 +65,13 @@ class ReviewController extends Controller
{
$service = new ReviewCreateService();
$review = $service->handle();
$service->handle();
$service = new ReviewInfoService();
$review = $service->handle($review->id);
$location = $this->url->get(['for' => 'home.uc.reviews']);
$content = [
'review' => $review,
'location' => $location,
'target' => 'parent',
'msg' => '发布评价成功',
];
@ -95,12 +87,11 @@ class ReviewController extends Controller
$service->handle($id);
$service = new ReviewInfoService();
$review = $service->handle($id);
$location = $this->url->get(['for' => 'home.uc.reviews']);
$content = [
'review' => $review,
'location' => $location,
'target' => 'parent',
'msg' => '更新评价成功',
];

View File

@ -108,8 +108,6 @@ class UserConsoleController extends Controller
$service = new AccountInfoService();
$captcha = $service->getSettings('captcha');
$account = $service->handle();
$service = new OAuthProviderService();
@ -137,7 +135,6 @@ class UserConsoleController extends Controller
$this->view->setVar('wechat_oa_connected', $wechatOAConnect ? 1 : 0);
$this->view->setVar('oauth_provider', $oauthProvider);
$this->view->setVar('connects', $connects);
$this->view->setVar('captcha', $captcha);
$this->view->setVar('account', $account);
}

View File

@ -24,12 +24,9 @@ class WeChatOfficialAccountController extends Controller
*/
public function bindAction()
{
$captcha = $this->getSettings('captcha');
$this->seo->prependTitle('绑定帐号');
$this->view->pick('wechat/oa/bind');
$this->view->setVar('captcha', $captcha);
}
/**

View File

@ -14,6 +14,7 @@ use App\Repos\User as UserRepo;
use App\Services\Auth\Home as AuthService;
use App\Services\Logic\Account\Register as RegisterService;
use App\Services\Logic\Notice\External\AccountLogin as AccountLoginNotice;
use App\Services\Logic\WeChat\OfficialAccount as WeChatOAService;
use App\Validators\Account as AccountValidator;
use App\Validators\WeChatOfficialAccount as WeChatOAValidator;
@ -63,10 +64,13 @@ class WeChatOfficialAccount extends Service
$openId = $validator->checkLoginOpenId($post['ticket']);
$unionId = $this->getUnionId($openId);
$connect = new ConnectModel();
$connect->user_id = $user->id;
$connect->open_id = $openId;
$connect->union_id = $unionId;
$connect->provider = ConnectModel::PROVIDER_WECHAT_OA;
$connect->create();
@ -86,6 +90,8 @@ class WeChatOfficialAccount extends Service
$openId = $validator->checkLoginOpenId($post['ticket']);
$unionId = $this->getUnionId($openId);
$registerService = new RegisterService();
$account = $registerService->handle();
@ -98,6 +104,7 @@ class WeChatOfficialAccount extends Service
$connect->user_id = $user->id;
$connect->open_id = $openId;
$connect->union_id = $unionId;
$connect->provider = ConnectModel::PROVIDER_WECHAT_OA;
$connect->create();
@ -111,6 +118,17 @@ class WeChatOfficialAccount extends Service
$this->eventsManager->fire('Account:afterRegister', $this, $user);
}
protected function getUnionId($openId)
{
$service = new WeChatOAService();
$app = $service->getOfficialAccount();
$user = $app->user->get($openId);
return $user['unionid'] ?: '';
}
protected function getAppAuth()
{
/**

View File

@ -36,6 +36,6 @@
</form>
{% else %}
<div class="register-close-tips">
<i class="layui-icon layui-icon-tips"></i> 邮箱注册已关闭
<i class="layui-icon layui-icon-lock"></i> 邮箱注册已关闭
</div>
{% endif %}
{% endif %}

View File

@ -36,6 +36,6 @@
</form>
{% else %}
<div class="register-close-tips">
<i class="layui-icon layui-icon-tips"></i> 手机注册已关闭
<i class="layui-icon layui-icon-lock"></i> 手机注册已关闭
</div>
{% endif %}
{% endif %}

View File

@ -1,35 +1,44 @@
{%- macro model_icon(model) %}
{% if model == 1 %}
<i class="iconfont icon-video"></i>
{% elseif model == 2 %}
<i class="iconfont icon-live"></i>
{% elseif model == 3 %}
<i class="iconfont icon-article"></i>
{% elseif model == 4 %}
<i class="layui-icon layui-icon-user"></i>
{% endif %}
{%- endmacro %}
{%- macro show_lesson_list(parent,chapter) %}
<ul class="sidebar-lesson-list">
{% for lesson in parent.children %}
{% set url = url({'for':'home.chapter.show','id':lesson.id}) %}
{% set active = (chapter.id == lesson.id) ? 'active' : 'normal' %}
<li class="lesson-title layui-elip">
{% if lesson.me.owned == 1 %}
<a class="{{ active }}" href="{{ url }}" title="{{ lesson.title }}">{{ lesson.title }}</a>
{% else %}
<span class="deny" title="{{ lesson.title }}">{{ lesson.title }}</span>
{% set active = chapter.id == lesson.id ? 'active' : 'normal' %}
{% set priv = lesson.me.owned == 1 ? 'allow' : 'deny' %}
<li class="sidebar-lesson layui-elip {{ priv }} {{ active }}" data-url="{{ url }}">
<span class="model">{{ model_icon(lesson.model) }}</span>
<span class="title" title="{{ lesson.title }}">{{ lesson.title }}</span>
{% if lesson.me.owned == 0 %}
<span class="lock"><i class="iconfont icon-lock"></i></span>
{% endif %}
</li>
{% endfor %}
</ul>
{%- endmacro %}
<div class="layui-card sidebar-card sidebar-chapter">
<div class="layui-card sidebar-card sidebar-catalog">
<div class="layui-card-header">课程目录</div>
<div class="layui-card-body">
{% if catalog|length > 1 %}
<div class="sidebar-chapter-list">
{% for item in catalog %}
<div class="chapter-title layui-elip">{{ item.title }}</div>
<div class="sidebar-lesson-list">
{{ show_lesson_list(item,chapter) }}
</div>
<div class="sidebar-chapter layui-elip">{{ item.title }}</div>
{{ show_lesson_list(item,chapter) }}
{% endfor %}
</div>
{% else %}
<div class="sidebar-lesson-list">
{{ show_lesson_list(catalog[0],chapter) }}
</div>
{{ show_lesson_list(catalog[0],chapter) }}
{% endif %}
</div>
</div>
</div>

View File

@ -35,11 +35,7 @@
<div class="layui-card-body">
<div class="chat-msg-list" id="chat-msg-list" data-url="{{ live_chats_url }}"></div>
<form class="layui-form chat-msg-form" method="post" action="{{ send_msg_url }}">
{% if auth_user.id > 0 %}
<input class="layui-input" type="text" name="content" maxlength="50" placeholder="快来一起互动吧" lay-verType="tips" lay-verify="required">
{% else %}
<input class="layui-input" type="text" placeholder="登录后才可以发言哦" readonly="readonly">
{% endif %}
<input class="layui-input" type="text" name="content" maxlength="50" placeholder="快来一起互动吧" lay-vertype="tips" lay-verify="required">
<button class="layui-hide" type="submit" lay-submit="true" lay-filter="chat">发送</button>
</form>
</div>
@ -80,4 +76,4 @@
{{ js_include('home/js/course.share.js') }}
{{ js_include('home/js/copy.js') }}
{% endblock %}
{% endblock %}

View File

@ -1,9 +1,15 @@
{% for chat in chats %}
<div class="chat">
{% if chat.user.vip == 1 %}
<span class="layui-icon layui-icon-diamond icon-vip"></span>
{% endif %}
<span class="user">{{ chat.user.name }}</span>
<span class="content">{{ chat.content }}</span>
</div>
{% endfor %}
{% if chat.user.vip == 1 %}
<div class="chat chat-vip">
<span class="icon"><i class="layui-icon layui-icon-diamond"></i></span>
<span class="user layui-badge layui-bg-orange">{{ chat.user.name }}</span>
<span class="content">{{ chat.content }}</span>
</div>
{% else %}
<div class="chat chat-normal">
<span class="icon"><i class="layui-icon layui-icon-username"></i></span>
<span class="user layui-badge layui-bg-blue">{{ chat.user.name }}</span>
<span class="content">{{ chat.content }}</span>
</div>
{% endif %}
{% endfor %}

View File

@ -11,9 +11,9 @@
</span>
</div>
<div class="preview">
<div class="live-preview">
<div class="icon"><i class="layui-icon layui-icon-face-cry"></i></div>
<div class="tips">直播已禁止,谢谢关注!</div>
</div>
{% endblock %}
{% endblock %}

View File

@ -13,19 +13,19 @@
</div>
{% if time() < chapter.start_time %}
<div class="preview countdown">
<div class="live-preview countdown wrap">
<div class="icon"><i class="layui-icon layui-icon-time"></i></div>
<div class="timer"></div>
<div class="tips">直播倒计时开始啦,敬请关注!</div>
</div>
{% elseif chapter.start_time < time() and chapter.end_time > time() %}
<div class="preview countdown">
<div class="live-preview countdown wrap">
<div class="icon"><i class="layui-icon layui-icon-face-surprised"></i></div>
<div class="timer"></div>
<div class="tips">直播时间到了,老师去哪了?</div>
</div>
{% else %}
<div class="preview">
<div class="live-preview wrap">
<div class="icon"><i class="layui-icon layui-icon-tree"></i></div>
<div class="tips">直播已结束,谢谢关注!</div>
</div>
@ -43,4 +43,4 @@
{{ js_include('home/js/chapter.live.countdown.js') }}
{% endblock %}
{% endblock %}

View File

@ -7,7 +7,7 @@
<div class="icon" title="{{ like_title }}" data-url="{{ like_url }}">
<i class="layui-icon layui-icon-praise icon-praise {{ like_class }}"></i>
</div>
<div class="text">{{ chapter.like_count }}</div>
<div class="text" data-count="{{ chapter.like_count }}">{{ chapter.like_count }}</div>
</div>
<div class="item" id="toolbar-online">
<div class="icon" title="在线人数">
@ -15,4 +15,4 @@
</div>
<div class="text">0</div>
</div>
</div>
</div>

View File

@ -1,103 +1,118 @@
{%- macro show_lesson_list(chapter) %}
<ul class="lesson-list">
{% for lesson in chapter.children %}
{% set url = url({'for':'home.chapter.show','id':lesson.id}) %}
{% set priv = lesson.me.owned ? 'allow' : 'deny' %}
{% if lesson.model == 1 %}
<li class="lesson-item">{{ vod_lesson_info(lesson) }}</li>
<li class="lesson-item {{ priv }}" data-url="{{ url }}">{{ vod_lesson_info(lesson) }}</li>
{% elseif lesson.model == 2 %}
<li class="lesson-item">{{ live_lesson_info(lesson) }}</li>
<li class="lesson-item {{ priv }}" data-url="{{ url }}">{{ live_lesson_info(lesson) }}</li>
{% elseif lesson.model == 3 %}
<li class="lesson-item">{{ read_lesson_info(lesson) }}</li>
<li class="lesson-item {{ priv }}" data-url="{{ url }}">{{ read_lesson_info(lesson) }}</li>
{% elseif lesson.model == 4 %}
<li class="lesson-item">{{ offline_lesson_info(lesson) }}</li>
<li class="lesson-item deny" data-url="{{ url }}">{{ offline_lesson_info(lesson) }}</li>
{% endif %}
{% endfor %}
</ul>
{%- endmacro %}
{%- macro vod_lesson_info(lesson) %}
{% set url = lesson.me.owned ? url({'for':'home.chapter.show','id':lesson.id}) : '' %}
{% set priv = lesson.me.owned ? 'allow' : 'deny' %}
<a class="{{ priv }} view-lesson" href="javascript:" data-url="{{ url }}">
<i class="layui-icon layui-icon-play"></i>
<div class="left">
<span class="model"><i class="iconfont icon-video"></i></span>
<span class="title">{{ lesson.title }}</span>
{% if lesson.free == 1 %}
<span class="iconfont icon-trial"></span>
{% endif %}
{% if lesson.me.duration > 0 %}
<span class="study-time" title="学习时长:{{ lesson.me.duration|duration }}"><i class="layui-icon layui-icon-time"></i></span>
{% endif %}
{% if priv == 'deny' %}
<span class="iconfont icon-lock"></span>
{% if lesson.me.owned == 0 %}
<span class="lock"><i class="iconfont icon-lock"></i></span>
{% endif %}
{% if lesson.free == 1 %}
<span class="flag flag-free">试听</span>
{% endif %}
</div>
<div class="right">
<span class="duration">{{ lesson.attrs.duration|duration }}</span>
</a>
</div>
{%- endmacro %}
{%- macro live_lesson_info(lesson) %}
{% set url = lesson.me.owned ? url({'for':'home.chapter.show','id':lesson.id}) : '' %}
{% set priv = lesson.me.owned ? 'allow' : 'deny' %}
<a class="{{ priv }} view-lesson" href="javascript:" data-url="{{ url }}">
<i class="layui-icon layui-icon-video"></i>
<div class="left">
<span class="model"><i class="iconfont icon-live"></i></span>
<span class="title">{{ lesson.title }}</span>
{% if lesson.free == 1 %}
<span class="iconfont icon-trial"></span>
{% endif %}
{% if lesson.me.duration > 0 %}
<span class="study-time" title="学习时长:{{ lesson.me.duration|duration }}"><i class="layui-icon layui-icon-time"></i></span>
{% endif %}
{% if priv == 'deny' %}
<span class="iconfont icon-lock"></span>
{% if lesson.me.owned == 0 %}
<span class="lock"><i class="iconfont icon-lock"></i></span>
{% endif %}
<span class="live" title="{{ date('Y-m-d H:i',lesson.attrs.start_time) }}">{{ live_status_info(lesson) }}</span>
</a>
{% if lesson.attrs.playback.ready == 1 %}
<span class="flag flag-playback">回放</span>
{% endif %}
{% if lesson.free == 1 %}
<span class="flag flag-free">试听</span>
{% endif %}
</div>
<div class="right">
<span class="live-status">{{ live_status_info(lesson) }}</span>
<span class="live-time">{{ date('Y-m-d H:i',lesson.attrs.start_time) }}</span>
</div>
{%- endmacro %}
{%- macro read_lesson_info(lesson) %}
{% set url = lesson.me.owned ? url({'for':'home.chapter.show','id':lesson.id}) : '' %}
{% set priv = lesson.me.owned ? 'allow' : 'deny' %}
<a class="{{ priv }} view-lesson" href="javascript:" data-url="{{ url }}">
<i class="layui-icon layui-icon-read"></i>
<div class="left">
<span class="model"><i class="iconfont icon-article"></i></span>
<span class="title">{{ lesson.title }}</span>
{% if lesson.free == 1 %}
<span class="iconfont icon-trial"></span>
{% endif %}
{% if lesson.me.duration > 0 %}
<span class="study-time" title="学习时长:{{ lesson.me.duration|duration }}"><i class="layui-icon layui-icon-time"></i></span>
{% endif %}
{% if priv == 'deny' %}
<span class="iconfont icon-lock"></span>
{% if lesson.me.owned == 0 %}
<span class="lock"><i class="iconfont icon-lock"></i></span>
{% endif %}
</a>
{% if lesson.free == 1 %}
<span class="flag flag-free">试读</span>
{% endif %}
</div>
<div class="right">
<span class="size"></span>
</div>
{%- endmacro %}
{%- macro offline_lesson_info(lesson) %}
<a class="deny view-lesson" href="javascript:">
<i class="layui-icon layui-icon-user"></i>
<div class="left">
<span class="model"><i class="layui-icon layui-icon-user"></i></span>
<span class="title">{{ lesson.title }}</span>
{% if lesson.free == 1 %}
<span class="layui-badge free-badge">试听</span>
{% if lesson.me.owned == 0 %}
<span class="lock"><i class="iconfont icon-lock"></i></span>
{% endif %}
<span class="live" title="{{ date('Y-m-d H:i',lesson.attrs.start_time) }}">{{ offline_status_info(lesson) }}</span>
</a>
{% if lesson.free == 1 %}
<span class="flag flag-free">试听</span>
{% endif %}
</div>
<div class="right">
<span class="live-status">{{ offline_status_info(lesson) }}</span>
<span class="live-time">{{ date('Y-m-d H:i',lesson.attrs.start_time) }}</span>
</div>
{%- endmacro %}
{%- macro live_status_info(lesson) %}
{% if lesson.attrs.stream.status == 'active' %}
<span class="active">{{ date('m月d日 H:i',lesson.attrs.start_time) }} 直播中</span>
<span class="flag flag-active">直播中</span>
{% elseif lesson.attrs.start_time > time() %}
<span class="pending">{{ date('m月d日 H:i',lesson.attrs.start_time) }} 倒计时</span>
<span class="flag flag-scheduled">倒计时</span>
{% elseif lesson.attrs.end_time < time() %}
<span class="finished">{{ date('m月d日 H:i',lesson.attrs.start_time) }} 已结束</span>
<span class="flag flag-ended">已结束</span>
{% elseif lesson.attrs.stream.status == 'inactive' %}
<span class="flag flag-inactive">未推流</span>
{% endif %}
{%- endmacro %}
{%- macro offline_status_info(lesson) %}
{% if lesson.attrs.start_time < time() and lesson.attrs.end_time > time() %}
<span class="active">{{ date('m月d日 H:i',lesson.attrs.start_time) }} 授课中</span>
<span class="flag flag-active">授课中</span>
{% elseif lesson.attrs.start_time > time() %}
<span class="pending">{{ date('m月d日 H:i',lesson.attrs.start_time) }} 未开始</span>
<span class="flag flag-scheduled">未开始</span>
{% elseif lesson.attrs.end_time < time() %}
<span class="finished">{{ date('m月d日 H:i',lesson.attrs.start_time) }} 已结束</span>
<span class="flag flag-ended">已结束</span>
{% endif %}
{%- endmacro %}
@ -119,4 +134,4 @@
{% else %}
{{ show_lesson_list(chapters[0]) }}
{% endif %}
{% endif %}
{% endif %}

View File

@ -105,21 +105,21 @@
{{ offline_meta_info(course) }}
{% endif %}
</div>
<div class="rating">
<div class="ratings">
<p class="item">
<span class="name">内容实用</span>
<span class="star">{{ star_info(course.ratings.rating1) }}</span>
<span class="star" id="rating1" data-value="{{ course.ratings.rating1 }}"></span>
<span class="score">{{ "%0.1f"|format(course.ratings.rating1) }} 分</span>
</p>
<p class="item">
<span class="name">简洁易懂</span>
<span class="star">{{ star_info(course.ratings.rating2) }}</span>
<span class="star" id="rating2" data-value="{{ course.ratings.rating2 }}"></span>
<span class="score">{{ "%0.1f"|format(course.ratings.rating2) }} 分</span>
</p>
<p class="item">
<span class="name">逻辑清晰</span>
<span class="star">{{ star_info(course.ratings.rating3) }}</span>
<span class="star" id="rating3" data-value="{{ course.ratings.rating3 }}"></span>
<span class="score">{{ "%0.1f"|format(course.ratings.rating3) }} 分</span>
</p>
</div>
</div>
</div>

View File

@ -26,8 +26,8 @@
{% endif %}
<div class="item" id="toolbar-favorite">
<div class="icon" title="{{ favorite_title }}" data-url="{{ favorite_url }}">
<i class="layui-icon layui-icon-star icon-star {{ favorite_class }}"></i>
<i class="layui-icon icon-star {{ favorite_class }}"></i>
</div>
<div class="text" data-count="{{ course.favorite_count }}">{{ course.favorite_count }}</div>
</div>
</div>
</div>

View File

@ -31,17 +31,10 @@
{% endblock %}
{% block inline_js %}
{% block include_js %}
<script>
layui.use(['jquery', 'helper'], function () {
var $ = layui.jquery;
var helper = layui.helper;
var $courseList = $('#course-list');
if ($courseList.length > 0) {
helper.ajaxLoadHtml($courseList.data('url'), $courseList.attr('id'));
}
});
</script>
{{ js_include('lib/clipboard.min.js') }}
{{ js_include('home/js/help.show.js') }}
{{ js_include('home/js/copy.js') }}
{% endblock %}
{% endblock %}

View File

@ -11,5 +11,11 @@
积分
{% elseif value == 6 %}
抽奖
{% elseif value == 7 %}
教师
{% elseif value == 10 %}
试听
{% else %}
N/A
{% endif %}
{%- endmacro %}
{%- endmacro %}

View File

@ -10,7 +10,7 @@
{% if course.model in [1,2,3] %}
<p>
<span>学习期限:{{ date('Y-m-d',course.study_expiry_time) }}</span>
<span>退款期限:{{ date('Y-m-d',course.refund_expiry_time) }}</span>
<span>退款期限:{{ course.refund_expiry > 0 ? date('Y-m-d',course.refund_expiry_time) : '不支持' }}</span>
</p>
{% elseif course.model == 4 %}
<p>上课时间:{{ course.attrs.start_date }} ~ {{ course.attrs.end_date }}</p>
@ -23,13 +23,13 @@
<div class="order-item">
<p>课程名称:{{ course.title }}</p>
<p>
<span>市场价格:{{ '¥%0.2f'|format(course.market_price) }}</span>
<span>市场价格:<em class="price">{{ '¥%0.2f'|format(course.market_price) }}</em></span>
<span>会员价格:<em class="price">{{ '¥%0.2f'|format(course.vip_price) }}</em></span>
</p>
{% if course.model in [1,2,3] %}
<p>
<span>学习期限:{{ date('Y-m-d',course.study_expiry_time) }}</span>
<span>退款期限:{{ date('Y-m-d',course.refund_expiry_time) }}</span>
<span>退款期限:{{ course.refund_expiry > 0 ? date('Y-m-d',course.refund_expiry_time) : '不支持' }}</span>
</p>
{% endif %}
</div>

View File

@ -26,7 +26,7 @@
<a class="layui-btn layui-bg-blue" href="{{ order_pay_url }}" target="_top">立即支付</a>
{% endif %}
{% if order.me.allow_cancel == 1 %}
<a class="layui-btn layui-bg-red order-cancel" href="javascript:" data-sn="{{ order.sn }}" data-url="{{ order_cancel_url }}">立即取消</a>
<button class="layui-btn layui-bg-red btn-order-cancel" data-sn="{{ order.sn }}" data-url="{{ order_cancel_url }}">立即取消</button>
{% endif %}
{% if order.me.allow_refund == 1 %}
<a class="layui-btn layui-bg-blue" href="{{ refund_confirm_url }}">申请退款</a>
@ -39,4 +39,4 @@
{{ js_include('home/js/order.info.js') }}
{% endblock %}
{% endblock %}

View File

@ -30,17 +30,10 @@
{% endblock %}
{% block inline_js %}
{% block include_js %}
<script>
layui.use(['jquery', 'helper'], function () {
var $ = layui.jquery;
var helper = layui.helper;
var $courseList = $('#course-list');
if ($courseList.length > 0) {
helper.ajaxLoadHtml($courseList.data('url'), $courseList.attr('id'));
}
});
</script>
{{ js_include('lib/clipboard.min.js') }}
{{ js_include('home/js/page.show.js') }}
{{ js_include('home/js/copy.js') }}
{% endblock %}
{% endblock %}

View File

@ -9,7 +9,7 @@
<div class="order-item">
<p>课程名称:<span>{{ course.title }}</span></p>
<p>退款期限:<span>{{ date('Y-m-d H:i:s',course.refund_expiry_time) }} {{ expiry_flag }}</span></p>
<p>退款金额:<span class="price">{{ '¥%0.2f'|format(course.refund_amount) }}</span>退款比例:<span class="price">{{ 100 * course.refund_percent }}%</span></p>
<p>退款金额:<span class="price">{{ '¥%0.2f'|format(course.refund_amount) }}</span>退款比例:<span class="rate">{{ 100 * course.refund_rate }}%</span></p>
</div>
{% elseif confirm.item_type == 2 %}
{% set courses = confirm.item_info.courses %}
@ -18,7 +18,7 @@
<div class="order-item">
<p>课程名称:<span>{{ course.title }}</span></p>
<p>退款期限:<span>{{ date('Y-m-d H:i:s',course.refund_expiry_time) }} {{ expiry_flag }}</span></p>
<p>退款金额:<span class="price">{{ '¥%0.2f'|format(course.refund_amount) }}</span>退款比例:<span class="price">{{ 100 * course.refund_percent }}%</span></p>
<p>退款金额:<span class="price">{{ '¥%0.2f'|format(course.refund_amount) }}</span>退款比例:<span class="rate">{{ 100 * course.refund_rate }}%</span></p>
</div>
{% endfor %}
{% endif %}
@ -40,12 +40,9 @@
</table>
<br>
{% if confirm.refund_amount > 0 %}
<form class="layui-form layui-form-pane" method="post" action="{{ url({'for':'home.refund.create'}) }}">
<form class="layui-form" method="post" action="{{ url({'for':'home.refund.create'}) }}">
<div class="layui-form-item">
<label class="layui-form-label">退款原因</label>
<div class="layui-input-block">
<input class="layui-input" name="apply_note" lay-verify="required">
</div>
<input class="layui-input" name="apply_note" placeholder="请告知我们退款原因,让我们做的更好..." lay-verify="required">
</div>
<div class="layui-form-item center">
<button class="layui-btn" lay-submit="true" lay-filter="go">提交申请</button>
@ -68,4 +65,4 @@
});
</script>
{% endblock %}
{% endblock %}

View File

@ -9,9 +9,9 @@
<table class="layui-table order-table" lay-size="lg">
<tr>
<td colspan="2">
订单金额:<span class="price">{{ '¥%0.2f'|format(refund.order.amount) }}</span>
退款金额:<span class="price">{{ '¥%0.2f'|format(refund.amount) }}</span>
退款状态:<span class="status">{{ refund_status(refund.status) }}</span>
<span>订单金额:<em class="price">{{ '¥%0.2f'|format(refund.order.amount) }}</em></span>
<span>退款金额:<em class="price">{{ '¥%0.2f'|format(refund.amount) }}</em></span>
<span>退款状态:{{ refund_status(refund.status) }}</span>
</td>
</tr>
<tr>
@ -22,41 +22,8 @@
<br>
<div class="center">
{% if refund.me.allow_cancel == 1 %}
<button class="kg-refund layui-btn" data-sn="{{ refund.sn }}" data-url="{{ cancel_url }}">取消退款</button>
<button class="layui-btn btn-refund-cancel" data-sn="{{ refund.sn }}" data-url="{{ cancel_url }}">取消退款</button>
{% endif %}
</div>
{% endblock %}
{% block inline_js %}
<script>
layui.use(['jquery', 'layer'], function () {
var $ = layui.jquery;
var layer = layui.layer;
var index = parent.layer.getFrameIndex(window.name);
parent.layer.iframeAuto(index);
$('.kg-refund').on('click', function () {
var url = $(this).data('url');
var data = {sn: $(this).data('sn')};
layer.confirm('确定要取消退款吗?', function () {
$.ajax({
type: 'POST',
url: url,
data: data,
success: function (res) {
layer.msg(res.msg, {icon: 1});
setTimeout(function () {
parent.window.location.href = '/uc/refunds';
}, 1500);
}
});
});
});
});
</script>
{% endblock %}

View File

@ -24,9 +24,9 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label" for="content">评价内容</label>
<label class="layui-form-label">评价内容</label>
<div class="layui-input-block">
<textarea name="content" id="content" class="layui-textarea" placeholder="请描述你的学习经历,例如学习成果、课程内容、讲师风格、教学服务等。"></textarea>
<textarea name="content" class="layui-textarea" placeholder="请描述你的学习经历,例如学习成果、课程内容、讲师风格、教学服务等。" lay-verify="required"></textarea>
</div>
</div>
<div class="layui-form-item">
@ -54,4 +54,4 @@
{{ js_include('home/js/user.console.review.js') }}
{% endblock %}
{% endblock %}

View File

@ -26,7 +26,7 @@
<div class="layui-form-item">
<label class="layui-form-label">评价内容</label>
<div class="layui-input-block">
<textarea name="content" class="layui-textarea">{{ review.content }}</textarea>
<textarea name="content" class="layui-textarea" lay-verify="required">{{ review.content }}</textarea>
</div>
</div>
<div class="layui-form-item">
@ -53,4 +53,4 @@
{{ js_include('home/js/user.console.review.js') }}
{% endblock %}
{% endblock %}

View File

@ -19,7 +19,7 @@
{% if item.cover %}
<div class="cover">
<a href="{{ article_url }}" target="_blank">
<img src="{{ item.cover }}!cover_270" alt="{{ item.title }}">
<img src="{{ item.cover }}!cover_270" alt="{{ item.title|striptags }}">
</a>
</div>
{% endif %}

View File

@ -6,7 +6,7 @@
<div class="search-course-card">
<div class="cover">
<a href="{{ course_url }}" target="_blank">
<img src="{{ item.cover }}!cover_270" alt="{{ item.title }}">
<img src="{{ item.cover }}!cover_270" alt="{{ item.title|striptags }}">
</a>
</div>
<div class="info">

View File

@ -19,7 +19,7 @@
{% if item.cover %}
<div class="cover">
<a href="{{ question_url }}" target="_blank">
<img src="{{ item.cover }}!cover_270" alt="{{ item.title }}">
<img src="{{ item.cover }}!cover_270" alt="{{ item.title|striptags }}">
</a>
</div>
{% endif %}

View File

@ -1,6 +1,9 @@
<!DOCTYPE html>
<html lang="zh-CN-Hans">
<head>
{% if site_info.analytics_enabled == 1 %}
{{ site_info.analytics_script }}
{% endif %}
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
@ -38,12 +41,5 @@
{% block include_js %}{% endblock %}
{% block inline_js %}{% endblock %}
{% if site_info.analytics_enabled == 1 %}
<div class="layui-hide">
{{ site_info.analytics_script }}
</div>
{% endif %}
</body>
</html>
</html>

View File

@ -10,10 +10,11 @@
{% set point_enabled = setting('point','enabled') %}
<div class="my-profile-card wrap">
<div class="vip">{{ vip_info(auth_user) }}</div>
<div class="avatar">
<img class="my-avatar" src="{{ auth_user.avatar }}" alt="{{ auth_user.name }}">
</div>
<div class="name">{{ auth_user.name }} {{ vip_info(auth_user) }}</div>
<div class="name">{{ auth_user.name }}</div>
</div>
<div class="layui-card">
@ -71,4 +72,4 @@
<li><a href="{{ url({'for':'home.uc.account'}) }}">帐号安全</a></li>
</ul>
</div>
</div>
</div>

View File

@ -79,7 +79,6 @@
{% block include_js %}
{{ js_include('home/js/user.avatar.upload.js') }}
{{ js_include('home/js/user.console.profile.js') }}
{% endblock %}
{% endblock %}

View File

@ -1,33 +0,0 @@
{% extends 'templates/main.volt' %}
{% block content %}
<div class="layout-main">
<div class="my-sidebar">{{ partial('user/console/menu') }}</div>
<div class="my-content">
<div class="wrap">
<div class="my-nav">
<span class="title">关注订阅</span>
</div>
<div class="my-subscribe">
{% if subscribed == 0 %}
<div id="sub-qrcode" class="qrcode"></div>
<div id="sub-tips" class="tips">订阅官方公众号,接收重要通知!</div>
{% else %}
<div class="tips">你已经订阅官方公众号</div>
{% endif %}
</div>
<div class="layui-hide">
<input type="hidden" name="subscribed" value="{{ subscribed }}">
</div>
</div>
</div>
</div>
{% endblock %}
{% block include_js %}
{{ js_include('home/js/wechat.oa.subscribe.js') }}
{% endblock %}

View File

@ -4,13 +4,13 @@
<div class="vip-header">会员权益</div>
<div class="vip-reason-list wrap">
<span class="layui-badge reason-badge">好课畅学</span>
<span class="layui-badge reason-badge">会员折扣</span>
<span class="layui-badge reason-badge">高清视频</span>
<span class="layui-badge reason-badge">广告免疫</span>
<span class="layui-badge reason-badge">会员标识</span>
<span class="layui-badge reason-badge">贴心服务</span>
<div class="vip-priv-list wrap">
<button class="layui-btn layui-bg-blue">好课畅学</button>
<button class="layui-btn layui-bg-blue">会员折扣</button>
<button class="layui-btn layui-bg-blue">高清视频</button>
<button class="layui-btn layui-bg-blue">广告免疫</button>
<button class="layui-btn layui-bg-blue">会员标识</button>
<button class="layui-btn layui-bg-blue">优先服务</button>
</div>
<div class="vip-header">开通会员</div>
@ -57,4 +57,4 @@
{{ js_include('home/js/vip.index.js') }}
{% endblock %}
{% endblock %}

View File

@ -3,7 +3,7 @@
<div class="layui-row layui-col-space20">
{% for item in pager.items %}
{% set user_url = url({'for':'home.user.show','id':item.id}) %}
<div class="layui-col-md2">
<div class="layui-col-md3">
<div class="user-card">
<div class="avatar">
<a href="{{ user_url }}" title="{{ item.about }}" target="_blank">

View File

@ -16,7 +16,7 @@ class AppInfo
protected $link = 'https://www.koogua.com';
protected $version = '1.7.5';
protected $version = '1.7.8';
public function __get($name)
{

View File

@ -0,0 +1,51 @@
<?php
/**
* @copyright Copyright (c) 2024 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
namespace App\Library\Paginator\Adapter;
use App\Library\Paginator\Query as PaginatorQuery;
use Phalcon\Paginator\Adapter\NativeArray as PhNativeArray;
use stdClass;
class NativeArray extends PhNativeArray
{
/**
* @var string
*/
protected $baseUrl;
/**
* @var array
*/
protected $params = [];
public function paginate(): stdClass
{
$pager = parent::paginate();
$query = new PaginatorQuery();
$this->baseUrl = $query->getBaseUrl();
$this->params = $query->getParams();
$pager->first = $this->buildPageUrl($pager->first);
$pager->previous = $this->buildPageUrl($pager->previous);
$pager->next = $this->buildPageUrl($pager->next);
$pager->last = $this->buildPageUrl($pager->last);
return $pager;
}
protected function buildPageUrl($page)
{
$this->params['page'] = $page;
return $this->baseUrl . '?' . http_build_query($this->params);
}
}

View File

@ -19,6 +19,7 @@ class CourseUser extends Model
const SOURCE_MANUAL = 4; // 分配
const SOURCE_POINT_REDEEM = 5; // 积分兑换
const SOURCE_LUCKY_REDEEM = 6; // 抽奖兑换
const SOURCE_TEACHER = 7; // 教师
const SOURCE_TRIAL = 10; // 试听
/**
@ -137,6 +138,7 @@ class CourseUser extends Model
self::SOURCE_TRIAL => '试听',
self::SOURCE_VIP => '畅学',
self::SOURCE_MANUAL => '分配',
self::SOURCE_TEACHER => '教师',
self::SOURCE_POINT_REDEEM => '积分兑换',
self::SOURCE_LUCKY_REDEEM => '抽奖兑换',
];

View File

@ -19,7 +19,7 @@ class Order extends Model
const ITEM_PACKAGE = 2; // 套餐
const ITEM_REWARD = 3; // 赞赏(已弃用)
const ITEM_VIP = 4; // 会员
const ITEM_TEST = 99; // 测试
const ITEM_TEST = 99; // 支付测试
/**
* 状态类型
@ -191,7 +191,7 @@ class Order extends Model
self::ITEM_COURSE => '课程',
self::ITEM_PACKAGE => '套餐',
self::ITEM_VIP => '会员',
self::ITEM_TEST => '测试',
self::ITEM_TEST => '支付测试',
];
}

View File

@ -20,7 +20,7 @@ class PointHistory extends Model
const EVENT_SITE_VISIT = 5; // 站点访问
const EVENT_CHAPTER_STUDY = 6; // 课时学习
const EVENT_COURSE_REVIEW = 7; // 课程评价
const EVENT_IM_DISCUSS = 8; // 微聊讨论
const EVENT_IM_DISCUSS = 8; // 微聊讨论(已弃用)
const EVENT_COMMENT_POST = 9; // 发布评论
const EVENT_ARTICLE_POST = 10; // 发布文章
const EVENT_QUESTION_POST = 11; // 发布问题
@ -132,7 +132,6 @@ class PointHistory extends Model
self::EVENT_SITE_VISIT => '用户登录',
self::EVENT_CHAPTER_STUDY => '课时学习',
self::EVENT_COURSE_REVIEW => '课程评价',
self::EVENT_IM_DISCUSS => '微聊讨论',
];
}

View File

@ -29,8 +29,16 @@ class Connect extends Repository
$query->andWhere('user_id = :user_id:', ['user_id' => $where['user_id']]);
}
if (!empty($where['open_id'])) {
$query->andWhere('open_id = :open_id:', ['open_id' => $where['open_id']]);
}
if (!empty($where['provider'])) {
$query->andWhere('provider = :provider:', ['provider' => $where['provider']]);
if (is_array($where['provider'])) {
$query->inWhere('provider', $where['provider']);
} else {
$query->andWhere('provider = :provider:', ['provider' => $where['provider']]);
}
}
if (isset($where['deleted'])) {
@ -67,19 +75,6 @@ class Connect extends Repository
]);
}
/**
* @param string $openId
* @param int $provider
* @return ConnectModel|Model|bool
*/
public function findByOpenIdShallow($openId, $provider)
{
return ConnectModel::findFirst([
'conditions' => 'open_id = ?1 AND provider = ?2',
'bind' => [1 => $openId, 2 => $provider],
]);
}
/**
* @param int $userId
* @param int $provider

View File

@ -7,7 +7,7 @@
namespace App\Services;
use App\Caches\CourseChapterList as CatalogCache;
use App\Caches\CourseChapterList as CourseChapterListCache;
use App\Models\Chapter as ChapterModel;
use App\Models\ChapterLive as ChapterLiveModel;
use App\Repos\Chapter as ChapterRepo;
@ -175,7 +175,7 @@ class LiveNotify extends Service
protected function rebuildCatalogCache(ChapterModel $chapter)
{
$cache = new CatalogCache();
$cache = new CourseChapterListCache();
$cache->rebuild($chapter->course_id);
}
@ -216,4 +216,4 @@ class LiveNotify extends Service
return $sign == $mySign;
}
}
}

View File

@ -36,6 +36,8 @@ class Register extends LogicService
$accountValidator = new AccountValidator();
$accountValidator->checkRegisterStatus($post['account']);
$accountValidator->checkLoginName($post['account']);
$data = [];

View File

@ -39,10 +39,10 @@ class ChapterList extends LogicService
if (count($chapters) == 0) return [];
if ($user->id > 0 && $this->courseUser) {
if ($user->id > 0) {
$chapters = $this->handleLoginUserChapters($chapters, $course, $user);
} else {
$chapters = $this->handleGuestUserChapters($chapters);
$chapters = $this->handleGuestUserChapters($chapters, $course);
}
return $chapters;
@ -50,7 +50,11 @@ class ChapterList extends LogicService
protected function handleLoginUserChapters(array $chapters, CourseModel $course, UserModel $user)
{
$mappings = $this->getLearningMappings($course->id, $user->id, $this->courseUser->plan_id);
$mappings = [];
if ($this->courseUser) {
$mappings = $this->getLearningMappings($course->id, $user->id, $this->courseUser->plan_id);
}
foreach ($chapters as &$chapter) {
foreach ($chapter['children'] as &$lesson) {
@ -61,23 +65,30 @@ class ChapterList extends LogicService
'owned' => $owned ? 1 : 0,
'logged' => 1,
];
// 如果课程是免费的,但又设置了课时试听,清除试听标识
if ($course->market_price == 0 && $lesson['free'] == 1) {
$lesson['free'] = 0;
}
}
}
return $chapters;
}
protected function handleGuestUserChapters(array $chapters)
protected function handleGuestUserChapters(array $chapters, CourseModel $course)
{
foreach ($chapters as &$chapter) {
foreach ($chapter['children'] as &$lesson) {
$owned = ($this->ownedCourse || $lesson['free'] == 1) && $lesson['published'] == 1;
$lesson['me'] = [
'progress' => 0,
'duration' => 0,
'logged' => 0,
'owned' => $owned ? 1 : 0,
'owned' => 0,
];
// 如果课程是免费的,但又设置了课时试听,清除试听标识
if ($course->market_price == 0 && $lesson['free'] == 1) {
$lesson['free'] = 0;
}
}
}

View File

@ -100,7 +100,7 @@ class CourseInfo extends LogicService
if ($this->courseUser) {
$me['reviewed'] = $this->courseUser->reviewed ? 1 : 0;
$me['progress'] = $this->courseUser->progress ? 1 : 0;
$me['progress'] = $this->courseUser->progress;
$me['plan_id'] = $this->courseUser->plan_id;
}
}

View File

@ -46,7 +46,11 @@ trait CourseUserTrait
$this->joinedCourse = true;
}
if ($course->market_price == 0) {
if ($course->teacher_id == $user->id) {
$this->ownedCourse = true;
} elseif ($course->market_price == 0) {
$this->ownedCourse = true;
@ -96,6 +100,7 @@ trait CourseUserTrait
case CourseUserModel::SOURCE_FREE:
case CourseUserModel::SOURCE_TRIAL:
case CourseUserModel::SOURCE_VIP:
case CourseUserModel::SOURCE_TEACHER:
$this->createCourseUser($course, $user, $expiryTime, $sourceType);
$this->deleteCourseUser($relation);
break;
@ -169,6 +174,8 @@ trait CourseUserTrait
$result = true;
} elseif ($course->vip_price == 0 && $user->vip == 1) {
$result = true;
} elseif($course->teacher_id == $user->id) {
$result = true;
}
return $result;
@ -176,6 +183,10 @@ trait CourseUserTrait
protected function getFreeSourceType(CourseModel $course, UserModel $user)
{
if ($course->teacher_id == $user->id) {
return CourseUserModel::SOURCE_TEACHER;
}
$sourceType = CourseUserModel::SOURCE_FREE;
if ($course->market_price > 0) {

View File

@ -12,7 +12,7 @@ use App\Services\Logic\Service as LogicService;
use App\Validators\Live as LiveValidator;
use GatewayClient\Gateway;
class LiveChapter extends LogicService
class LiveChat extends LogicService
{
use ChapterTrait;

View File

@ -121,7 +121,6 @@ class OrderConfirm extends LogicService
'lesson_count' => $course->lesson_count,
'study_expiry' => $course->study_expiry,
'refund_expiry' => $course->refund_expiry,
'origin_price' => $course->origin_price,
'market_price' => $course->market_price,
'vip_price' => $course->vip_price,
];

View File

@ -1,63 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
namespace App\Services\Logic\Point\History;
use App\Models\ImMessage as ImMessageModel;
use App\Models\PointHistory as PointHistoryModel;
use App\Repos\PointHistory as PointHistoryRepo;
use App\Repos\User as UserRepo;
use App\Services\Logic\Point\PointHistory;
class ImDiscuss extends PointHistory
{
public function handle(ImMessageModel $message)
{
$setting = $this->getSettings('point');
$pointEnabled = $setting['enabled'] ?? 0;
if ($pointEnabled == 0) return;
$eventRule = json_decode($setting['event_rule'], true);
$eventEnabled = $eventRule['im_discuss']['enabled'] ?? 0;
if ($eventEnabled == 0) return;
$eventPoint = $eventRule['im_discuss']['point'] ?? 0;
if ($eventPoint <= 0) return;
$eventId = $message->sender_id;
$eventType = PointHistoryModel::EVENT_IM_DISCUSS;
$eventInfo = new \stdClass();
$historyRepo = new PointHistoryRepo();
$history = $historyRepo->findDailyEventHistory($eventId, $eventType, date('Ymd'));
if ($history) return;
$userRepo = new UserRepo();
$user = $userRepo->findById($message->sender_id);
$history = new PointHistoryModel();
$history->user_id = $user->id;
$history->user_name = $user->name;
$history->event_id = $eventId;
$history->event_type = $eventType;
$history->event_info = $eventInfo;
$history->event_point = $eventPoint;
$this->handlePointHistory($history);
}
}

View File

@ -35,7 +35,7 @@ class SiteVisit extends PointHistory
$eventId = $user->id;
$eventType = PointHistoryModel::EVENT_SITE_VISIT;
$eventInfo = new \stdClass();
$eventInfo = [];
$historyRepo = new PointHistoryRepo();

View File

@ -28,12 +28,12 @@ class Article extends Handler
$paginator = new XunSearchPaginator([
'xs' => $searcher->getXS(),
'highlight' => $searcher->getHighlightFields(),
'query' => $params['query'],
'query' => $this->handleKeywords($params['query']),
'page' => $page,
'limit' => $limit,
]);
$pager = $paginator->getPaginate();
$pager = $paginator->paginate();
return $this->handleArticles($pager);
}

View File

@ -28,12 +28,12 @@ class Course extends Handler
$paginator = new XunSearchPaginator([
'xs' => $searcher->getXS(),
'highlight' => $searcher->getHighlightFields(),
'query' => $params['query'],
'query' => $this->handleKeywords($params['query']),
'page' => $page,
'limit' => $limit,
]);
$pager = $paginator->getPaginate();
$pager = $paginator->paginate();
return $this->handleCourses($pager);
}

View File

@ -18,4 +18,9 @@ abstract class Handler extends LogicService
abstract function getRelatedQuery($query, $limit);
}
protected function handleKeywords($str)
{
return kg_substr($str, 0, 50, '');
}
}

View File

@ -28,12 +28,12 @@ class Question extends Handler
$paginator = new XunSearchPaginator([
'xs' => $searcher->getXS(),
'highlight' => $searcher->getHighlightFields(),
'query' => $params['query'],
'query' => $this->handleKeywords($params['query']),
'page' => $page,
'limit' => $limit,
]);
$pager = $paginator->getPaginate();
$pager = $paginator->paginate();
return $this->handleQuestions($pager);
}

View File

@ -111,6 +111,9 @@ class OfficialAccount extends AppService
$logger->debug('Received Message: ' . json_encode($message));
/**
* 事件类型文档https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Receiving_event_pushes.html
*/
switch ($message['MsgType']) {
case 'event':
switch ($message['Event']) {
@ -161,44 +164,24 @@ class OfficialAccount extends AppService
if ($connect) return null;
/**
* 尼玛不知道为什么又多了个"qrscene_"前缀SCAN事件里面又不带这个前缀
*/
$loginScene = sprintf('qrscene_%s', self::QR_SCENE_LOGIN);
$subscribeScene = sprintf('qrscene_%s', self::QR_SCENE_SUBSCRIBE);
$userId = 0;
if (Text::startsWith($eventKey, $subscribeScene)) {
$userId = str_replace($subscribeScene, '', $eventKey);
} else {
$connect = $connectRepo->findByOpenIdShallow($openId, ConnectModel::PROVIDER_WECHAT_OA);
if ($connect) $userId = $connect->user_id;
/**
* 未关注过服务号,在登录页扫登录场景码,关注服务号
*/
if (Text::startsWith($eventKey, $loginScene)) {
$ticket = str_replace($loginScene, '', $eventKey);
$this->handleLoginPageSubscribe($ticket, $openId);
}
if ($userId > 0) {
$userRepo = new UserRepo();
$user = $userRepo->findById($userId);
if (!$user) return null;
$userInfo = $this->getUserInfo($openId);
$unionId = $userInfo['unionid'] ?: '';
$connect = new ConnectModel();
$connect->user_id = $userId;
$connect->open_id = $openId;
$connect->union_id = $unionId;
$connect->provider = ConnectModel::PROVIDER_WECHAT_OA;
$connect->create();
/**
* 未关注过服务号,在用户中心扫关注场景码,关注服务号
*/
if (Text::startsWith($eventKey, $subscribeScene)) {
$userId = str_replace($subscribeScene, '', $eventKey);
$this->handleAccountPageSubscribe($userId, $openId);
}
return new TextMessage('开心呀,我们又多了一个小伙伴!');
@ -228,19 +211,19 @@ class OfficialAccount extends AppService
$eventKey = $message['EventKey'] ?? '';
if (Text::startsWith($eventKey, self::QR_SCENE_LOGIN)) {
return $this->handleLoginScanEvent($eventKey, $openId);
$ticket = str_replace(self::QR_SCENE_LOGIN, '', $eventKey);
$this->handleLoginPageSubscribe($ticket, $openId);
} elseif (Text::startsWith($eventKey, self::QR_SCENE_SUBSCRIBE)) {
return $this->handleSubscribeScanEvent($eventKey, $openId);
$userId = str_replace(self::QR_SCENE_SUBSCRIBE, '', $eventKey);
$this->handleAccountPageSubscribe($userId, $openId);
}
return $this->emptyReply();
}
protected function handleLoginScanEvent($eventKey, $openId)
protected function handleLoginPageSubscribe($ticket, $openId)
{
$ticket = str_replace(self::QR_SCENE_LOGIN, '', $eventKey);
if (empty($ticket) || empty($openId)) return null;
if (empty($ticket) || empty($openId)) return;
$connectRepo = new ConnectRepo();
@ -256,31 +239,27 @@ class OfficialAccount extends AppService
];
$cache->save($keyName, $content, 30 * 60);
return $this->emptyReply();
}
protected function handleSubscribeScanEvent($eventKey, $openId)
protected function handleAccountPageSubscribe($userId, $openId)
{
$userId = str_replace(self::QR_SCENE_SUBSCRIBE, '', $eventKey);
if (empty($userId) || empty($openId)) return null;
if (empty($userId) || empty($openId)) return;
$userRepo = new UserRepo();
$user = $userRepo->findById($userId);
if (!$user) return null;
$userInfo = $this->getUserInfo($openId);
$unionId = $userInfo['unionid'] ?: '';
if (!$user) return;
$connectRepo = new ConnectRepo();
$connect = $connectRepo->findByOpenId($openId, ConnectModel::PROVIDER_WECHAT_OA);
if ($connect) return null;
if ($connect) return;
$userInfo = $this->getUserInfo($openId);
$unionId = $userInfo['unionid'] ?: '';
$connect = new ConnectModel();
@ -290,8 +269,6 @@ class OfficialAccount extends AppService
$connect->provider = ConnectModel::PROVIDER_WECHAT_OA;
$connect->create();
return $this->emptyReply();
}
protected function handleClickEvent($message)

View File

@ -53,15 +53,15 @@ class Refund extends Service
$serviceFee = $this->getServiceFee($order);
$serviceRate = $this->getServiceRate($order);
$refundPercent = 0.00;
$refundRate = 0.00;
$refundAmount = 0.00;
if ($itemInfo['course']['refund_expiry_time'] > time()) {
$refundPercent = $this->getCourseRefundPercent($order->item_id, $order->owner_id);
$refundAmount = round(($order->amount - $serviceFee) * $refundPercent, 2);
$refundRate = $this->getCourseRefundRate($order->item_id, $order->owner_id);
$refundAmount = round(($order->amount - $serviceFee) * $refundRate, 2);
}
$itemInfo['course']['refund_percent'] = $refundPercent;
$itemInfo['course']['refund_rate'] = $refundRate;
$itemInfo['course']['refund_amount'] = $refundAmount;
return [
@ -95,17 +95,17 @@ class Refund extends Service
$course['cover'] = kg_cos_course_cover_url($course['cover']);
$refundPercent = 0.00;
$refundRate = 0.00;
$refundAmount = 0.00;
if ($course['refund_expiry_time'] > time()) {
$pricePercent = round($course['market_price'] / $totalMarketPrice, 4);
$refundPercent = $this->getCourseRefundPercent($course['id'], $order->owner_id);
$refundAmount = round(($order->amount - $serviceFee) * $pricePercent * $refundPercent, 2);
$priceRate = round($course['market_price'] / $totalMarketPrice, 4);
$refundRate = $this->getCourseRefundRate($course['id'], $order->owner_id);
$refundAmount = round(($order->amount - $serviceFee) * $priceRate * $refundRate, 2);
$totalRefundAmount += $refundAmount;
}
$course['refund_percent'] = $refundPercent;
$course['refund_rate'] = $refundRate;
$course['refund_amount'] = $refundAmount;
}
@ -176,7 +176,7 @@ class Refund extends Service
return $serviceRate;
}
protected function getCourseRefundPercent($courseId, $userId)
protected function getCourseRefundRate($courseId, $userId)
{
$courseRepo = new CourseRepo();

View File

@ -10,6 +10,7 @@ namespace App\Services;
use Phalcon\Logger\Adapter\File as FileLogger;
use Qcloud\Cos\Client as CosClient;
use TencentCloud\Common\Credential;
use TencentCloud\Common\Exception\TencentCloudSDKException;
use TencentCloud\Common\Profile\ClientProfile;
use TencentCloud\Common\Profile\HttpProfile;
use TencentCloud\Sts\V20180813\Models\GetFederationTokenRequest;
@ -100,11 +101,12 @@ class Storage extends Service
$result = $client->GetFederationToken($request);
} catch (\Exception $e) {
} catch (TencentCloudSDKException $e) {
$this->logger->error('Get Tmp Token Exception' . kg_json_encode([
$this->logger->error('Get Tmp Token Exception ' . kg_json_encode([
'code' => $e->getCode(),
'message' => $e->getMessage(),
'requestId' => $e->getRequestId(),
]));
$result = false;
@ -130,11 +132,12 @@ class Storage extends Service
$result = $response['Location'] ? $key : false;
} catch (\Exception $e) {
} catch (TencentCloudSDKException $e) {
$this->logger->error('Put String Exception ' . kg_json_encode([
'code' => $e->getCode(),
'message' => $e->getMessage(),
'requestId' => $e->getRequestId(),
]));
$result = false;
@ -162,11 +165,12 @@ class Storage extends Service
$result = $response['Location'] ? $key : false;
} catch (\Exception $e) {
} catch (TencentCloudSDKException $e) {
$this->logger->error('Put File Exception ' . kg_json_encode([
'code' => $e->getCode(),
'message' => $e->getMessage(),
'requestId' => $e->getRequestId(),
]));
$result = false;
@ -194,11 +198,12 @@ class Storage extends Service
$result = $response['Location'] ? $key : false;
} catch (\Exception $e) {
} catch (TencentCloudSDKException $e) {
$this->logger->error('Delete Object Exception ' . kg_json_encode([
'code' => $e->getCode(),
'message' => $e->getMessage(),
'requestId' => $e->getRequestId(),
]));
$result = false;

View File

@ -1,65 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
namespace App\Services;
class Throttle extends Service
{
public function checkRateLimit()
{
$config = $this->getConfig();
if (!$config->path('throttle.enabled')) {
return true;
}
$cache = $this->getCache();
$sign = $this->getRequestSignature();
$cacheKey = $this->getCacheKey($sign);
if ($cache->ttl($cacheKey) < 1) {
$cache->save($cacheKey, 0, $config->path('throttle.lifetime'));
}
$rateLimit = $cache->get($cacheKey);
if ($rateLimit >= $config->path('throttle.rate_limit')) {
return false;
}
$cache->increment($cacheKey, 1);
return true;
}
protected function getRequestSignature()
{
$authUser = $this->getAuthUser();
if (!empty($authUser['id'])) {
return md5($authUser['id']);
}
$httpHost = $this->request->getHttpHost();
$clientAddress = $this->request->getClientAddress();
if ($httpHost && $clientAddress) {
return md5($httpHost . '|' . $clientAddress);
}
throw new \RuntimeException('Unable to generate request signature');
}
protected function getCacheKey($sign)
{
return "throttle:{$sign}";
}
}

View File

@ -28,13 +28,6 @@ trait Security
$validator->checkHttpReferer();
}
public function checkRateLimit()
{
$validator = new SecurityValidator();
$validator->checkRateLimit();
}
public function isNotSafeRequest()
{
/**

View File

@ -129,6 +129,29 @@ class Account extends Validator
}
}
public function checkRegisterStatus($account)
{
$local = $this->getSettings('oauth.local');
$allowPhone = $local['register_with_phone'] ?? false;
$allowEmail = $local['register_with_email'] ?? false;
$isEmail = CommonValidator::email($account);
$isPhone = CommonValidator::Phone($account);
if (!$allowPhone && !$allowEmail) {
throw new BadRequestException('account.register_disabled');
}
if ($isPhone && !$allowPhone) {
throw new BadRequestException('account.register_with_phone_disabled');
}
if ($isEmail && !$allowEmail) {
throw new BadRequestException('account.register_with_email_disabled');
}
}
public function checkVerifyLogin($name, $code)
{
$this->checkLoginName($name);

View File

@ -11,10 +11,7 @@ use App\Exceptions\BadRequest as BadRequestException;
use App\Models\Order as OrderModel;
use App\Models\Refund as RefundModel;
use App\Models\Trade as TradeModel;
use App\Repos\Course as CourseRepo;
use App\Repos\Order as OrderRepo;
use App\Repos\Package as PackageRepo;
use App\Repos\Vip as VipRepo;
class Order extends Validator
{
@ -50,54 +47,36 @@ class Order extends Validator
return $order;
}
public function checkItemType($itemType)
public function checkItemType($type)
{
$list = OrderModel::itemTypes();
$types = OrderModel::itemTypes();
if (!array_key_exists($itemType, $list)) {
if (!array_key_exists($type, $types)) {
throw new BadRequestException('order.invalid_item_type');
}
return $itemType;
return $type;
}
public function checkCourse($itemId)
public function checkCourse($id)
{
$courseRepo = new CourseRepo();
$validator = new Course();
$course = $courseRepo->findById($itemId);
if (!$course || $course->published == 0) {
throw new BadRequestException('order.item_not_found');
}
return $course;
return $validator->checkCourse($id);
}
public function checkPackage($itemId)
public function checkPackage($id)
{
$packageRepo = new PackageRepo();
$validator = new Package();
$package = $packageRepo->findById($itemId);
if (!$package || $package->published == 0) {
throw new BadRequestException('order.item_not_found');
}
return $package;
return $validator->checkPackage($id);
}
public function checkVip($itemId)
public function checkVip($id)
{
$vipRepo = new VipRepo();
$validator = new Vip();
$vip = $vipRepo->findById($itemId);
if (!$vip || $vip->deleted == 1) {
throw new BadRequestException('order.item_not_found');
}
return $vip;
return $validator->checkVip($id);
}
public function checkAmount($amount)
@ -105,7 +84,7 @@ class Order extends Validator
$value = $this->filter->sanitize($amount, ['trim', 'float']);
if ($value < 0.01 || $value > 100000) {
throw new BadRequestException('order.invalid_pay_amount');
throw new BadRequestException('order.invalid_amount');
}
return $value;
@ -148,7 +127,7 @@ class Order extends Validator
];
if (!in_array($order->item_type, $types)) {
throw new BadRequestException('order.refund_item_unsupported');
throw new BadRequestException('order.refund_not_supported');
}
$orderRepo = new OrderRepo();
@ -167,7 +146,7 @@ class Order extends Validator
];
if ($refund && in_array($refund->status, $scopes)) {
throw new BadRequestException('order.refund_apply_existed');
throw new BadRequestException('order.refund_request_existed');
}
}

View File

@ -8,9 +8,7 @@
namespace App\Validators;
use App\Exceptions\BadRequest as BadRequestException;
use App\Exceptions\ServiceUnavailable as ServiceUnavailableException;
use App\Library\CsrfToken as CsrfTokenService;
use App\Services\Throttle as ThrottleService;
class Security extends Validator
{
@ -53,17 +51,6 @@ class Security extends Validator
}
}
public function checkRateLimit()
{
$service = new ThrottleService();
$result = $service->checkRateLimit();
if (!$result) {
throw new ServiceUnavailableException('security.too_many_requests');
}
}
protected function getCsrfWhitelist()
{
return [];

View File

@ -91,7 +91,7 @@ class Trade extends Validator
];
if ($refund && in_array($refund->status, $scopes)) {
throw new BadRequestException('trade.refund_apply_existed');
throw new BadRequestException('trade.refund_request_existed');
}
}

Some files were not shown because too many files have changed in this diff Show More