mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-26 12:23:06 +08:00
Merge branch 'koogua/v1.4.5' into demo
This commit is contained in:
commit
3202378f85
@ -1,8 +1,10 @@
|
|||||||
### [v1.4.5](https://gitee.com/koogua/course-tencent-cloud/releases/v1.4.5)(2021-09-27)
|
### [v1.4.5](https://gitee.com/koogua/course-tencent-cloud/releases/v1.4.5)(2021-09-27)
|
||||||
|
|
||||||
- 修正点击内容分享到微信会额外出现公众号二维码的问题
|
- 修正点击内容分享到微信会额外出现公众号二维码的问题
|
||||||
|
- 修正后台首页提问和回答的数量统计
|
||||||
- 调整登录限制(邮箱|手机)为注册限制
|
- 调整登录限制(邮箱|手机)为注册限制
|
||||||
- 调整订单发货为每一分钟执行一次
|
- 调整订单发货为每一分钟执行一次
|
||||||
|
- 增加首页推荐教师接口
|
||||||
- 增加微信公众号支付处理
|
- 增加微信公众号支付处理
|
||||||
- 增加取消订单功能
|
- 增加取消订单功能
|
||||||
- 优化计划任务
|
- 优化计划任务
|
||||||
|
@ -14,7 +14,7 @@ use App\Services\Logic\Article\ArticleList as ArticleListService;
|
|||||||
class IndexArticleList extends Cache
|
class IndexArticleList extends Cache
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $lifetime = 1 * 86400;
|
protected $lifetime = 15 * 60;
|
||||||
|
|
||||||
public function getLifetime()
|
public function getLifetime()
|
||||||
{
|
{
|
||||||
|
36
app/Caches/IndexFlashSaleList.php
Normal file
36
app/Caches/IndexFlashSaleList.php
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||||
|
* @license https://opensource.org/licenses/GPL-2.0
|
||||||
|
* @link https://www.koogua.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Caches;
|
||||||
|
|
||||||
|
use App\Services\Logic\FlashSale\SaleList;
|
||||||
|
|
||||||
|
class IndexFlashSaleList extends Cache
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $lifetime = 1 * 86400;
|
||||||
|
|
||||||
|
public function getLifetime()
|
||||||
|
{
|
||||||
|
return strtotime('tomorrow') - time();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getKey($id = null)
|
||||||
|
{
|
||||||
|
return 'index_flash_sale_list';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getContent($id = null)
|
||||||
|
{
|
||||||
|
$service = new SaleList();
|
||||||
|
|
||||||
|
$sales = $service->handle();
|
||||||
|
|
||||||
|
return $sales[0]['items'] ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -14,7 +14,7 @@ use App\Services\Logic\Question\QuestionList as QuestionListService;
|
|||||||
class IndexQuestionList extends Cache
|
class IndexQuestionList extends Cache
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $lifetime = 1 * 86400;
|
protected $lifetime = 15 * 60;
|
||||||
|
|
||||||
public function getLifetime()
|
public function getLifetime()
|
||||||
{
|
{
|
||||||
|
68
app/Caches/IndexTeacherList.php
Normal file
68
app/Caches/IndexTeacherList.php
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||||
|
* @license https://opensource.org/licenses/GPL-2.0
|
||||||
|
* @link https://www.koogua.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Caches;
|
||||||
|
|
||||||
|
use App\Models\User as UserModel;
|
||||||
|
use Phalcon\Mvc\Model\Resultset;
|
||||||
|
use Phalcon\Mvc\Model\ResultsetInterface;
|
||||||
|
|
||||||
|
class IndexTeacherList extends Cache
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $lifetime = 1 * 3600;
|
||||||
|
|
||||||
|
public function getLifetime()
|
||||||
|
{
|
||||||
|
return $this->lifetime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getKey($id = null)
|
||||||
|
{
|
||||||
|
return 'index_teacher_list';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getContent($id = null)
|
||||||
|
{
|
||||||
|
$teachers = $this->findTeachers();
|
||||||
|
|
||||||
|
if ($teachers->count() == 0) return [];
|
||||||
|
|
||||||
|
$result = [];
|
||||||
|
|
||||||
|
$baseUrl = kg_cos_url();
|
||||||
|
|
||||||
|
foreach ($teachers->toArray() as $teacher) {
|
||||||
|
|
||||||
|
$teacher['avatar'] = $baseUrl . $teacher['avatar'];
|
||||||
|
|
||||||
|
$result[] = [
|
||||||
|
'id' => $teacher['id'],
|
||||||
|
'name' => $teacher['name'],
|
||||||
|
'title' => $teacher['title'],
|
||||||
|
'avatar' => $teacher['avatar'],
|
||||||
|
'about' => $teacher['about'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $limit
|
||||||
|
* @return ResultsetInterface|Resultset|UserModel[]
|
||||||
|
*/
|
||||||
|
protected function findTeachers($limit = 8)
|
||||||
|
{
|
||||||
|
return UserModel::query()
|
||||||
|
->where('edu_role = :edu_role:', ['edu_role' => UserModel::EDU_ROLE_TEACHER])
|
||||||
|
->orderBy('RAND()')
|
||||||
|
->limit($limit)
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,70 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
|
||||||
* @license https://opensource.org/licenses/GPL-2.0
|
|
||||||
* @link https://www.koogua.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Caches;
|
|
||||||
|
|
||||||
use App\Models\Order as OrderModel;
|
|
||||||
use Phalcon\Mvc\Model\Resultset;
|
|
||||||
use Phalcon\Mvc\Model\ResultsetInterface;
|
|
||||||
|
|
||||||
class SaleTrend extends Cache
|
|
||||||
{
|
|
||||||
|
|
||||||
protected $lifetime = 2 * 3600;
|
|
||||||
|
|
||||||
public function getLifetime()
|
|
||||||
{
|
|
||||||
return $this->lifetime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getKey($id = null)
|
|
||||||
{
|
|
||||||
return 'sale_trend';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getContent($id = null)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param OrderModel[] $sales
|
|
||||||
* @param int $days
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function handleSales($sales, $days = 7)
|
|
||||||
{
|
|
||||||
$result = [];
|
|
||||||
|
|
||||||
foreach (array_reverse(range(1, $days)) as $num) {
|
|
||||||
$date = date('Y-m-d', strtotime("-{$num} days"));
|
|
||||||
$result[$date] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($sales as $sale) {
|
|
||||||
$date = date('Y-m-d', $sale->create_time);
|
|
||||||
$result[$date] += $sale->amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $days
|
|
||||||
* @return ResultsetInterface|Resultset|OrderModel[]
|
|
||||||
*/
|
|
||||||
protected function findSales($days = 7)
|
|
||||||
{
|
|
||||||
$time = strtotime("-{$days} days");
|
|
||||||
|
|
||||||
return OrderModel::query()
|
|
||||||
->where('status = :status:', ['status' => OrderModel::STATUS_FINISHED])
|
|
||||||
->andWhere('create_time > :time:', ['time' => $time])
|
|
||||||
->execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -7,12 +7,14 @@
|
|||||||
|
|
||||||
namespace App\Caches;
|
namespace App\Caches;
|
||||||
|
|
||||||
|
use App\Repos\Answer as AnswerRepo;
|
||||||
use App\Repos\Article as ArticleRepo;
|
use App\Repos\Article as ArticleRepo;
|
||||||
use App\Repos\Comment as CommentRepo;
|
use App\Repos\Comment as CommentRepo;
|
||||||
use App\Repos\Consult as ConsultRepo;
|
use App\Repos\Consult as ConsultRepo;
|
||||||
use App\Repos\Course as CourseRepo;
|
use App\Repos\Course as CourseRepo;
|
||||||
use App\Repos\ImGroup as GroupRepo;
|
use App\Repos\ImGroup as GroupRepo;
|
||||||
use App\Repos\Package as PackageRepo;
|
use App\Repos\Package as PackageRepo;
|
||||||
|
use App\Repos\Question as QuestionRepo;
|
||||||
use App\Repos\Review as ReviewRepo;
|
use App\Repos\Review as ReviewRepo;
|
||||||
use App\Repos\Topic as TopicRepo;
|
use App\Repos\Topic as TopicRepo;
|
||||||
use App\Repos\User as UserRepo;
|
use App\Repos\User as UserRepo;
|
||||||
@ -36,6 +38,8 @@ class SiteGlobalStat extends Cache
|
|||||||
{
|
{
|
||||||
$courseRepo = new CourseRepo();
|
$courseRepo = new CourseRepo();
|
||||||
$articleRepo = new ArticleRepo();
|
$articleRepo = new ArticleRepo();
|
||||||
|
$questionRepo = new QuestionRepo();
|
||||||
|
$answerRepo = new AnswerRepo();
|
||||||
$commentRepo = new CommentRepo();
|
$commentRepo = new CommentRepo();
|
||||||
$consultRepo = new ConsultRepo();
|
$consultRepo = new ConsultRepo();
|
||||||
$groupRepo = new GroupRepo();
|
$groupRepo = new GroupRepo();
|
||||||
@ -47,6 +51,8 @@ class SiteGlobalStat extends Cache
|
|||||||
return [
|
return [
|
||||||
'course_count' => $courseRepo->countCourses(),
|
'course_count' => $courseRepo->countCourses(),
|
||||||
'article_count' => $articleRepo->countArticles(),
|
'article_count' => $articleRepo->countArticles(),
|
||||||
|
'question_count' => $questionRepo->countQuestions(),
|
||||||
|
'answer_count' => $answerRepo->countAnswers(),
|
||||||
'comment_count' => $commentRepo->countComments(),
|
'comment_count' => $commentRepo->countComments(),
|
||||||
'consult_count' => $consultRepo->countConsults(),
|
'consult_count' => $consultRepo->countConsults(),
|
||||||
'group_count' => $groupRepo->countGroups(),
|
'group_count' => $groupRepo->countGroups(),
|
||||||
|
@ -59,13 +59,13 @@
|
|||||||
<div class="layui-col-md2">
|
<div class="layui-col-md2">
|
||||||
<div class="kg-stat-card">
|
<div class="kg-stat-card">
|
||||||
<div class="name">提问数</div>
|
<div class="name">提问数</div>
|
||||||
<div class="count">0</div>
|
<div class="count">{{ global_stat.question_count }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-col-md2">
|
<div class="layui-col-md2">
|
||||||
<div class="kg-stat-card">
|
<div class="kg-stat-card">
|
||||||
<div class="name">回答数</div>
|
<div class="name">回答数</div>
|
||||||
<div class="count">0</div>
|
<div class="count">{{ global_stat.answer_count }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-col-md2">
|
<div class="layui-col-md2">
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
namespace App\Http\Api\Controllers;
|
namespace App\Http\Api\Controllers;
|
||||||
|
|
||||||
use App\Caches\IndexArticleList;
|
use App\Caches\IndexArticleList;
|
||||||
|
use App\Caches\IndexFlashSaleList;
|
||||||
use App\Caches\IndexLiveList;
|
use App\Caches\IndexLiveList;
|
||||||
use App\Caches\IndexQuestionList;
|
use App\Caches\IndexQuestionList;
|
||||||
use App\Caches\IndexSimpleFeaturedCourseList;
|
use App\Caches\IndexSimpleFeaturedCourseList;
|
||||||
@ -15,6 +16,7 @@ use App\Caches\IndexSimpleFreeCourseList;
|
|||||||
use App\Caches\IndexSimpleNewCourseList;
|
use App\Caches\IndexSimpleNewCourseList;
|
||||||
use App\Caches\IndexSimpleVipCourseList;
|
use App\Caches\IndexSimpleVipCourseList;
|
||||||
use App\Caches\IndexSlideList;
|
use App\Caches\IndexSlideList;
|
||||||
|
use App\Caches\IndexTeacherList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @RoutePrefix("/api/index")
|
* @RoutePrefix("/api/index")
|
||||||
@ -70,6 +72,30 @@ class IndexController extends Controller
|
|||||||
return $this->jsonSuccess(['lives' => $lives]);
|
return $this->jsonSuccess(['lives' => $lives]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Get("/teachers", name="api.index.teachers")
|
||||||
|
*/
|
||||||
|
public function teachersAction()
|
||||||
|
{
|
||||||
|
$cache = new IndexTeacherList();
|
||||||
|
|
||||||
|
$teachers = $cache->get();
|
||||||
|
|
||||||
|
return $this->jsonSuccess(['teachers' => $teachers]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Get("/flash/sales", name="api.index.flash_sales")
|
||||||
|
*/
|
||||||
|
public function flashSalesAction()
|
||||||
|
{
|
||||||
|
$cache = new IndexFlashSaleList();
|
||||||
|
|
||||||
|
$sales = $cache->get();
|
||||||
|
|
||||||
|
return $this->jsonSuccess(['sales' => $sales]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Get("/courses/featured", name="api.index.featured_courses")
|
* @Get("/courses/featured", name="api.index.featured_courses")
|
||||||
*/
|
*/
|
||||||
|
@ -111,7 +111,7 @@ class UserLimit extends Validator
|
|||||||
{
|
{
|
||||||
$count = $this->counter->hGet($user->id, 'order_count');
|
$count = $this->counter->hGet($user->id, 'order_count');
|
||||||
|
|
||||||
if ($count > 10) {
|
if ($count > 50) {
|
||||||
throw new BadRequestException('user_limit.reach_daily_order_limit');
|
throw new BadRequestException('user_limit.reach_daily_order_limit');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user