1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-07-15 21:02:20 +08:00

Merge branch 'koogua/v1.6.4' into demo

# Conflicts:
#	CHANGELOG.md
#	app/Http/Home/Views/help/index.volt
#	app/Services/Logic/Chapter/ChapterInfo.php
#	app/Services/Logic/Course/CourseInfo.php
This commit is contained in:
xiaochong0302 2023-06-15 19:42:34 +08:00
commit 4cb998c6e3
82 changed files with 725 additions and 384 deletions

View File

@ -1,4 +1,19 @@
### [v1.6.4](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.3)(2023-06-15)
- 增加推荐课程等Widget
- 更新Composer包
- 修正验证空口令问题
- 优化订单确认页样式
- 优化课程等Me相关信息
- 优化分享URL
- 优化用户课程查找
- 优化通知相关
- 优化Providers
- 优化课程章节权限
- 优化钉钉机器人
### [v1.6.3](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.3)(2023-05-08) ### [v1.6.3](https://gitee.com/koogua/course-tencent-cloud/releases/v1.6.3)(2023-05-08)
- 强化文章|提问|课程列表参数检查 - 强化文章|提问|课程列表参数检查
- 优化HtmlPurifier内容过滤 - 优化HtmlPurifier内容过滤
- 优化排序条件和分页重复问题 - 优化排序条件和分页重复问题

View File

@ -55,7 +55,7 @@ Tips: 请用手机注册一个新账号,用户中心 -> 关注订阅,扫码
### 项目组件 ### 项目组件
- 后台框架:[phalcon 3.4.5](https://phalcon.io) - 后台框架:[phalcon 3.4.5](https://phalcon.io)
- 前端框架:[layui 2.7.6](https://layui.com) - 前端框架:[layui 2.8.2](https://layui.com)
- 全文检索:[xunsearch 1.4.9](http://www.xunsearch.com) - 全文检索:[xunsearch 1.4.9](http://www.xunsearch.com)
- 即时通讯:[workerman 3.5.22](https://workerman.net) - 即时通讯:[workerman 3.5.22](https://workerman.net)
- 基础依赖:[php7.3](https://php.net) [mysql5.7](https://mysql.com) [redis5.0](https://redis.io) - 基础依赖:[php7.3](https://php.net) [mysql5.7](https://mysql.com) [redis5.0](https://redis.io)

View File

@ -12,7 +12,7 @@ use App\Repos\Article as ArticleRepo;
class Article extends Cache class Article extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -12,7 +12,7 @@ use App\Repos\Chapter as ChapterRepo;
class Chapter extends Cache class Chapter extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -12,7 +12,7 @@ use App\Repos\Course as CourseRepo;
class Course extends Cache class Course extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -13,7 +13,7 @@ use App\Repos\Course as CourseRepo;
class CourseCategoryList extends Cache class CourseCategoryList extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -13,7 +13,7 @@ use App\Repos\Course as CourseRepo;
class CoursePackageList extends Cache class CoursePackageList extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -14,7 +14,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
class CourseRecommendedList extends Cache class CourseRecommendedList extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -13,7 +13,7 @@ use App\Repos\Course as CourseRepo;
class CourseRelatedList extends Cache class CourseRelatedList extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -13,7 +13,7 @@ use App\Repos\Course as CourseRepo;
class CourseTeacherList extends Cache class CourseTeacherList extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -14,7 +14,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
class CourseTopicList extends Cache class CourseTopicList extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -0,0 +1,83 @@
<?php
/**
* @copyright Copyright (c) 2023 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
namespace App\Caches;
use App\Models\Article as ArticleModel;
use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface;
class FeaturedArticleList extends Cache
{
protected $lifetime = 86400;
public function getLifetime()
{
$tomorrow = strtotime('tomorrow');
return $tomorrow - time();
}
public function getKey($id = null)
{
return 'featured_article_list';
}
public function getContent($id = null)
{
$limit = 8;
$articles = $this->findArticles($limit);
if ($articles->count() == 0) {
return [];
}
$result = [];
foreach ($articles as $article) {
$userCount = $article->user_count;
if ($article->fake_user_count > $article->user_count) {
$userCount = $article->fake_user_count;
}
$result[] = [
'id' => $article->id,
'title' => $article->title,
'cover' => $article->cover,
'market_price' => (float)$article->market_price,
'vip_price' => (float)$article->vip_price,
'user_count' => $userCount,
'favorite_count' => $article->favorite_count,
'comment_count' => $article->comment_count,
'view_count' => $article->view_count,
'like_count' => $article->like_count,
];
}
return $result;
}
/**
* @param int $limit
* @return ResultsetInterface|Resultset|ArticleModel[]
*/
protected function findArticles($limit = 8)
{
return ArticleModel::query()
->where('featured = 1')
->andWhere('published = 1')
->andWhere('deleted = 0')
->orderBy('id DESC')
->limit($limit)
->execute();
}
}

View File

@ -0,0 +1,85 @@
<?php
/**
* @copyright Copyright (c) 2023 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
namespace App\Caches;
use App\Models\Course as CourseModel;
use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface;
class FeaturedCourseList extends Cache
{
protected $lifetime = 86400;
public function getLifetime()
{
$tomorrow = strtotime('tomorrow');
return $tomorrow - time();
}
public function getKey($id = null)
{
return 'featured_course_list';
}
public function getContent($id = null)
{
$limit = 8;
$courses = $this->findCourses($limit);
if ($courses->count() == 0) {
return [];
}
$result = [];
foreach ($courses as $course) {
$userCount = $course->user_count;
if ($course->fake_user_count > $course->user_count) {
$userCount = $course->fake_user_count;
}
$result[] = [
'id' => $course->id,
'title' => $course->title,
'cover' => $course->cover,
'model' => $course->model,
'level' => $course->level,
'rating' => round($course->rating, 1),
'market_price' => (float)$course->market_price,
'vip_price' => (float)$course->vip_price,
'user_count' => $userCount,
'lesson_count' => $course->lesson_count,
'review_count' => $course->review_count,
'favorite_count' => $course->favorite_count,
];
}
return $result;
}
/**
* @param int $limit
* @return ResultsetInterface|Resultset|CourseModel[]
*/
protected function findCourses($limit = 8)
{
return CourseModel::query()
->where('featured = 1')
->andWhere('published = 1')
->andWhere('deleted = 0')
->orderBy('id DESC')
->limit($limit)
->execute();
}
}

View File

@ -12,7 +12,7 @@ use App\Repos\FlashSale as FlashSaleRepo;
class FlashSale extends Cache class FlashSale extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -14,7 +14,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
class HotQuestionList extends Cache class HotQuestionList extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -19,7 +19,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
class IndexFeaturedCourseList extends Cache class IndexFeaturedCourseList extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -12,7 +12,7 @@ use App\Services\Logic\FlashSale\SaleList;
class IndexFlashSaleList extends Cache class IndexFlashSaleList extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -19,7 +19,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
class IndexFreeCourseList extends Cache class IndexFreeCourseList extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -18,7 +18,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
class IndexLiveList extends Cache class IndexLiveList extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -19,7 +19,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
class IndexNewCourseList extends Cache class IndexNewCourseList extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -17,7 +17,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
class IndexSimpleFeaturedCourseList extends Cache class IndexSimpleFeaturedCourseList extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -17,7 +17,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
class IndexSimpleFreeCourseList extends Cache class IndexSimpleFreeCourseList extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -17,7 +17,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
class IndexSimpleNewCourseList extends Cache class IndexSimpleNewCourseList extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -17,7 +17,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
class IndexSimpleVipCourseList extends Cache class IndexSimpleVipCourseList extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -14,7 +14,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
class IndexTeacherList extends Cache class IndexTeacherList extends Cache
{ {
protected $lifetime = 1 * 3600; protected $lifetime = 3600;
public function getLifetime() public function getLifetime()
{ {

View File

@ -19,7 +19,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
class IndexVipCourseList extends Cache class IndexVipCourseList extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -13,7 +13,7 @@ use App\Repos\Package as PackageRepo;
class PackageCourseList extends Cache class PackageCourseList extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -12,7 +12,7 @@ use App\Repos\PointGift as PointGiftRepo;
class PointGift extends Cache class PointGift extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -19,7 +19,7 @@ class PointHotGiftList extends Cache
* *
* @var int * @var int
*/ */
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
/** /**
* 显示个数 * 显示个数

View File

@ -12,7 +12,7 @@ use App\Repos\Question as QuestionRepo;
class Question extends Cache class Question extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -15,7 +15,7 @@ class TaggedArticleList extends Cache
protected $limit = 5; protected $limit = 5;
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -15,7 +15,7 @@ class TaggedQuestionList extends Cache
protected $limit = 5; protected $limit = 5;
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -16,7 +16,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
class TopAnswererList extends Cache class TopAnswererList extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -16,7 +16,7 @@ use Phalcon\Mvc\Model\ResultsetInterface;
class TopAuthorList extends Cache class TopAuthorList extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -12,7 +12,7 @@ use App\Repos\User as UserRepo;
class User extends Cache class User extends Cache
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -10,7 +10,7 @@ namespace App\Caches;
class UserDailyCounter extends Counter class UserDailyCounter extends Counter
{ {
protected $lifetime = 1 * 86400; protected $lifetime = 86400;
public function getLifetime() public function getLifetime()
{ {

View File

@ -20,11 +20,13 @@ class StudentController extends Controller
*/ */
public function searchAction() public function searchAction()
{ {
$courseId = $this->request->getQuery('course_id', 'int', 0);
$studentService = new StudentService(); $studentService = new StudentService();
$sourceTypes = $studentService->getSourceTypes(); $sourceTypes = $studentService->getSourceTypes();
$xmCourses = $studentService->getXmCourses('all'); $xmCourses = $studentService->getXmCourses('all', $courseId);
$this->view->setVar('source_types', $sourceTypes); $this->view->setVar('source_types', $sourceTypes);
$this->view->setVar('xm_courses', $xmCourses); $this->view->setVar('xm_courses', $xmCourses);
@ -56,9 +58,11 @@ class StudentController extends Controller
*/ */
public function addAction() public function addAction()
{ {
$courseId = $this->request->getQuery('course_id', 'int', 0);
$studentService = new StudentService(); $studentService = new StudentService();
$xmCourses = $studentService->getXmCourses('charge'); $xmCourses = $studentService->getXmCourses('all', $courseId);
$this->view->setVar('xm_courses', $xmCourses); $this->view->setVar('xm_courses', $xmCourses);
} }

View File

@ -20,7 +20,7 @@ use App\Validators\CourseUser as CourseUserValidator;
class Student extends Service class Student extends Service
{ {
public function getXmCourses($scope = 'all') public function getXmCourses($scope = 'all', $courseId = 0)
{ {
$courseRepo = new CourseRepo(); $courseRepo = new CourseRepo();
@ -46,6 +46,7 @@ class Student extends Service
$result[] = [ $result[] = [
'name' => sprintf('%s - %s¥%0.2f', $item->id, $item->title, $item->market_price), 'name' => sprintf('%s - %s¥%0.2f', $item->id, $item->title, $item->market_price),
'value' => $item->id, 'value' => $item->id,
'selected' => $item->id == $courseId,
]; ];
} }

View File

@ -14,15 +14,15 @@
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">App Secret</label> <label class="layui-form-label">Webhook</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" type="text" name="app_secret" value="{{ robot.app_secret }}" lay-verify="required"> <input class="layui-input" type="text" name="app_token" value="{{ robot.webhook_url }}" lay-verify="required">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">Access Token</label> <label class="layui-form-label">加签密钥</label>
<div class="layui-input-block"> <div class="layui-input-block">
<input class="layui-input" type="text" name="app_token" value="{{ robot.app_token }}" lay-verify="required"> <input class="layui-input" type="text" name="app_secret" value="{{ robot.app_secret }}" lay-verify="required">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">

View File

@ -18,8 +18,13 @@
{% endif %} {% endif %}
{%- endmacro %} {%- endmacro %}
{% if course %}
{% set add_url = url({'for':'admin.student.add'},{'course_id':course.id}) %}
{% set search_url = url({'for':'admin.student.search'},{'course_id':course.id}) %}
{% else %}
{% set add_url = url({'for':'admin.student.add'}) %} {% set add_url = url({'for':'admin.student.add'}) %}
{% set search_url = url({'for':'admin.student.search'}) %} {% set search_url = url({'for':'admin.student.search'}) %}
{% endif %}
<div class="kg-nav"> <div class="kg-nav">
<div class="kg-nav-left"> <div class="kg-nav-left">

View File

@ -8,7 +8,6 @@
namespace App\Http\Home\Controllers; namespace App\Http\Home\Controllers;
use App\Http\Home\Services\FullH5Url as FullH5UrlService; use App\Http\Home\Services\FullH5Url as FullH5UrlService;
use App\Http\Home\Services\Index as IndexService;
use App\Services\Logic\Help\HelpInfo as HelpInfoService; use App\Services\Logic\Help\HelpInfo as HelpInfoService;
use App\Services\Logic\Help\HelpList as HelpListService; use App\Services\Logic\Help\HelpList as HelpListService;
@ -66,19 +65,9 @@ class HelpController extends Controller
$this->notFound(); $this->notFound();
} }
$featuredCourses = $this->getFeaturedCourses();
$this->seo->prependTitle(['帮助', $help['title']]); $this->seo->prependTitle(['帮助', $help['title']]);
$this->view->setVar('help', $help); $this->view->setVar('help', $help);
$this->view->setVar('featured_courses', $featuredCourses);
}
protected function getFeaturedCourses()
{
$service = new IndexService();
return $service->getSimpleFeaturedCourses();
} }
} }

View File

@ -7,6 +7,8 @@
namespace App\Http\Home\Controllers; namespace App\Http\Home\Controllers;
use App\Caches\FeaturedArticleList as FeaturedArticleListCache;
use App\Caches\FeaturedCourseList as FeaturedCourseListCache;
use App\Services\Logic\Article\TopAuthorList as TopAuthorListService; use App\Services\Logic\Article\TopAuthorList as TopAuthorListService;
use App\Services\Logic\Question\HotQuestionList as HotQuestionListService; use App\Services\Logic\Question\HotQuestionList as HotQuestionListService;
use App\Services\Logic\Question\TopAnswererList as TopAnswererListService; use App\Services\Logic\Question\TopAnswererList as TopAnswererListService;
@ -33,6 +35,34 @@ class WidgetController extends Controller
$this->view->setVar('tags', $pager->items); $this->view->setVar('tags', $pager->items);
} }
/**
* @Get("/featured/courses", name="home.widget.featured_courses")
*/
public function featuredCoursesAction()
{
$cache = new FeaturedCourseListCache();
$courses = $cache->get();
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
$this->view->pick('widget/featured_courses');
$this->view->setVar('courses', $courses);
}
/**
* @Get("/featured/articles", name="home.widget.featured_articles")
*/
public function featuredArticlesAction()
{
$cache = new FeaturedArticleListCache();
$articles = $cache->get();
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
$this->view->pick('widget/featured_articles');
$this->view->setVar('articles', $articles);
}
/** /**
* @Get("/hot/questions", name="home.widget.hot_questions") * @Get("/hot/questions", name="home.widget.hot_questions")
*/ */

View File

@ -2,7 +2,7 @@
{% block content %} {% block content %}
{{ partial('macros/course') }} {% set courses_url = url({'for':'home.widget.featured_courses'}) %}
<div class="breadcrumb"> <div class="breadcrumb">
<span class="layui-breadcrumb"> <span class="layui-breadcrumb">
@ -32,25 +32,23 @@
</div> </div>
</div> </div>
<div class="layout-sidebar"> <div class="layout-sidebar">
{% if featured_courses %} <div class="sidebar" id="course-list" data-url="{{ courses_url }}"></div>
<div class="sidebar">
<div class="layui-card">
<div class="layui-card-header">推荐课程</div>
<div class="layui-card-body">
{% for course in featured_courses %}
{{ sidebar_course_card(course) }}
{% endfor %}
</div>
</div>
</div>
{% endif %}
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
{% block include_js %} {% block inline_js %}
{{ js_include('home/js/help.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>
{% endblock %} {% endblock %}

View File

@ -2,7 +2,7 @@
{% block content %} {% block content %}
{{ partial('macros/course') }} {% set courses_url = url({'for':'home.widget.featured_courses'}) %}
{% set share_url = share_url('help',help.id,auth_user.id) %} {% set share_url = share_url('help',help.id,auth_user.id) %}
{% set qrcode_url = url({'for':'home.qrcode'},{'text':share_url}) %} {% set qrcode_url = url({'for':'home.qrcode'},{'text':share_url}) %}
@ -27,18 +27,7 @@
</div> </div>
</div> </div>
<div class="layout-sidebar"> <div class="layout-sidebar">
{% if featured_courses %} <div class="sidebar" id="course-list" data-url="{{ courses_url }}"></div>
<div class="sidebar">
<div class="layui-card">
<div class="layui-card-header">推荐课程</div>
<div class="layui-card-body">
{% for course in featured_courses %}
{{ sidebar_course_card(course) }}
{% endfor %}
</div>
</div>
</div>
{% endif %}
</div> </div>
</div> </div>
@ -55,3 +44,18 @@
{{ css_link('home/css/content.css') }} {{ css_link('home/css/content.css') }}
{% endblock %} {% endblock %}
{% block inline_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>
{% endblock %}

View File

@ -2,7 +2,7 @@
{% block content %} {% block content %}
{{ partial('macros/course') }} {% set courses_url = url({'for':'home.widget.featured_courses'}) %}
{% set share_url = share_url('page',page.id,auth_user.id) %} {% set share_url = share_url('page',page.id,auth_user.id) %}
{% set qrcode_url = url({'for':'home.qrcode'},{'text':share_url}) %} {% set qrcode_url = url({'for':'home.qrcode'},{'text':share_url}) %}
@ -26,18 +26,7 @@
</div> </div>
</div> </div>
<div class="layout-sidebar"> <div class="layout-sidebar">
{% if featured_courses %} <div class="sidebar" id="course-list" data-url="{{ courses_url }}"></div>
<div class="sidebar">
<div class="layui-card">
<div class="layui-card-header">推荐课程</div>
<div class="layui-card-body">
{% for course in featured_courses %}
{{ sidebar_course_card(course) }}
{% endfor %}
</div>
</div>
</div>
{% endif %}
</div> </div>
</div> </div>
@ -54,3 +43,18 @@
{{ css_link('home/css/content.css') }} {{ css_link('home/css/content.css') }}
{% endblock %} {% endblock %}
{% block inline_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>
{% endblock %}

View File

@ -0,0 +1,20 @@
{% if articles|length > 0 %}
<div class="layui-card">
<div class="layui-card-header">推荐文章</div>
<div class="layui-card-body">
<div class="sidebar-article-list">
{% for article in articles %}
{% set article_url = url({'for':'home.article.show','id':article.id}) %}
<div class="title">
<a href="{{ article_url }}" target="_blank">{{ article.title }}</a>
</div>
<div class="meta">
<span class="view">{{ article.view_count }} 浏览</span>
<span class="like">{{ article.like_count }} 点赞</span>
<span class="comment">{{ article.comment_count }} 评论</span>
</div>
{% endfor %}
</div>
</div>
</div>
{% endif %}

View File

@ -0,0 +1,12 @@
{{ partial('macros/course') }}
{% if courses|length > 0 %}
<div class="layui-card">
<div class="layui-card-header">推荐课程</div>
<div class="layui-card-body">
{% for course in courses %}
{{ sidebar_course_card(course) }}
{% endfor %}
</div>
</div>
{% endif %}

View File

@ -46,7 +46,7 @@ class Sitemap
public function build($filename = null) public function build($filename = null)
{ {
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; $xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n"; $xml .= '<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
foreach ($this->items as $item) { foreach ($this->items as $item) {
$item['loc'] = htmlentities($item['loc'], ENT_QUOTES); $item['loc'] = htmlentities($item['loc'], ENT_QUOTES);

View File

@ -26,15 +26,19 @@ class Annotation extends Provider
$this->di->setShared($this->serviceName, function () use ($config) { $this->di->setShared($this->serviceName, function () use ($config) {
if ($config->get('env') == ENV_DEV) { if ($config->get('env') == ENV_DEV) {
$annotations = new MemoryAnnotations(); $annotations = new MemoryAnnotations();
} else { } else {
$statsKey = '_ANNOTATION_'; $statsKey = '_ANNOTATION_';
$annotations = new RedisAnnotations([ $annotations = new RedisAnnotations([
'host' => $config->path('redis.host'), 'host' => $config->path('redis.host'),
'port' => $config->path('redis.port'), 'port' => $config->path('redis.port'),
'auth' => $config->path('redis.auth'), 'auth' => $config->path('redis.auth'),
'index' => $config->path('redis.index') ?: 0, 'index' => $config->path('redis.index'),
'lifetime' => $config->path('annotation.lifetime') ?: 30 * 86400, 'lifetime' => $config->path('annotation.lifetime'),
'prefix' => $statsKey . ':', 'prefix' => $statsKey . ':',
'statsKey' => $statsKey, 'statsKey' => $statsKey,
]); ]);

View File

@ -33,7 +33,7 @@ class Cache extends Provider
'host' => $config->path('redis.host'), 'host' => $config->path('redis.host'),
'port' => $config->path('redis.port'), 'port' => $config->path('redis.port'),
'auth' => $config->path('redis.auth'), 'auth' => $config->path('redis.auth'),
'index' => $config->path('redis.index') ?: 0, 'index' => $config->path('redis.index'),
]); ]);
}); });
} }

View File

@ -42,8 +42,11 @@ class Database extends Provider
$connection = new MySqlAdapter($options); $connection = new MySqlAdapter($options);
if ($config->get('env') == ENV_DEV) { if ($config->get('env') == ENV_DEV) {
$eventsManager = new EventsManager(); $eventsManager = new EventsManager();
$eventsManager->attach('db', new DbListener()); $eventsManager->attach('db', new DbListener());
$connection->setEventsManager($eventsManager); $connection->setEventsManager($eventsManager);
} }

View File

@ -26,15 +26,19 @@ class MetaData extends Provider
$this->di->setShared($this->serviceName, function () use ($config) { $this->di->setShared($this->serviceName, function () use ($config) {
if ($config->get('env') == ENV_DEV) { if ($config->get('env') == ENV_DEV) {
$metaData = new MemoryMetaData(); $metaData = new MemoryMetaData();
} else { } else {
$statsKey = '_METADATA_'; $statsKey = '_METADATA_';
$metaData = new RedisMetaData([ $metaData = new RedisMetaData([
'host' => $config->path('redis.host'), 'host' => $config->path('redis.host'),
'port' => $config->path('redis.port'), 'port' => $config->path('redis.port'),
'auth' => $config->path('redis.auth'), 'auth' => $config->path('redis.auth'),
'index' => $config->path('redis.index') ?: 0, 'index' => $config->path('redis.index'),
'lifetime' => $config->path('metadata.lifetime') ?: 30 * 86400, 'lifetime' => $config->path('metadata.lifetime'),
'prefix' => $statsKey . ':', 'prefix' => $statsKey . ':',
'statsKey' => $statsKey, 'statsKey' => $statsKey,
]); ]);

View File

@ -28,8 +28,8 @@ class Session extends Provider
'host' => $config->path('redis.host'), 'host' => $config->path('redis.host'),
'port' => $config->path('redis.port'), 'port' => $config->path('redis.port'),
'auth' => $config->path('redis.auth'), 'auth' => $config->path('redis.auth'),
'index' => $config->path('redis.index') ?: 0, 'index' => $config->path('redis.index'),
'lifetime' => $config->path('session.lifetime') ?: 24 * 3600, 'lifetime' => $config->path('session.lifetime'),
'prefix' => '_SESSION_:', 'prefix' => '_SESSION_:',
]); ]);

View File

@ -99,6 +99,16 @@ class Volt extends Provider
return 'kg_anonymous(' . $resolvedArgs . ')'; return 'kg_anonymous(' . $resolvedArgs . ')';
}); });
$compiler->addFilter('split', function ($resolvedArgs, $exprArgs) use ($compiler) {
$firstArgument = $compiler->expression($exprArgs[0]['expr']);
if (isset($exprArgs[1])) {
$secondArgument = $compiler->expression($exprArgs[1]['expr']);
} else {
$secondArgument = '';
}
return sprintf('explode(%s,%s)', $secondArgument, $firstArgument);
});
return $volt; return $volt;
}); });
} }

View File

@ -135,24 +135,21 @@ class DingTalkNotice extends Service
*/ */
public function send($params) public function send($params)
{ {
if (!isset($params['msgtype'])) { $webhookUrl = $this->settings['webhook_url'];
$params['msgtype'] = 'text';
}
$appSecret = $this->settings['app_secret']; $appSecret = $this->settings['app_secret'];
$appToken = $this->settings['app_token'];
$timestamp = time() * 1000; $timestamp = time() * 1000;
$data = sprintf("%s\n%s", $timestamp, $appSecret); $data = sprintf("%s\n%s", $timestamp, $appSecret);
$sign = urlencode(base64_encode(hash_hmac('sha256', $data, $appSecret, true))); $sign = urlencode(base64_encode(hash_hmac('sha256', $data, $appSecret, true)));
$baseUrl = 'https://oapi.dingtalk.com/robot/send'; $postUrl = $webhookUrl;
$postUrl = $baseUrl . '?' . http_build_query([ if (!empty($appSecret)) {
'access_token' => $appToken, $postUrl = $webhookUrl . '&' . http_build_query([
'timestamp' => $timestamp, 'timestamp' => $timestamp,
'sign' => $sign, 'sign' => $sign,
]); ]);
}
try { try {

View File

@ -120,7 +120,6 @@ trait ArticleDataTrait
$tagRepo = new TagRepo(); $tagRepo = new TagRepo();
$tags = $tagRepo->findByIds($newTagIds); $tags = $tagRepo->findByIds($newTagIds);
if ($tags->count() > 0) { if ($tags->count() > 0) {
$articleTags = [];
foreach ($tags as $tag) { foreach ($tags as $tag) {
$articleTags[] = ['id' => $tag->id, 'name' => $tag->name]; $articleTags[] = ['id' => $tag->id, 'name' => $tag->name];
$this->recountTagArticles($tag->id); $this->recountTagArticles($tag->id);

View File

@ -75,47 +75,7 @@ class ChapterInfo extends LogicService
$result['course'] = $service->handleCourseInfo($this->course); $result['course'] = $service->handleCourseInfo($this->course);
$me = [ $result['me'] = $this->handleMeInfo($chapter, $user);
'role_type' => 0,
'plan_id' => 0,
'position' => 0,
'logged' => 0,
'joined' => 0,
'owned' => 0,
'liked' => 0,
];
if ($this->joinedChapter) {
$me['joined'] = 1;
}
if ($this->ownedChapter) {
$me['owned'] = 1;
}
if ($user->id > 0) {
$me['logged'] = 1;
$likeRepo = new ChapterLikeRepo();
$like = $likeRepo->findChapterLike($chapter->id, $user->id);
if ($like && $like->deleted == 0) {
$me['liked'] = 1;
}
if ($this->courseUser) {
$me['role_type'] = $this->courseUser->role_type;
$me['plan_id'] = $this->courseUser->plan_id;
}
if ($this->chapterUser) {
$me['position'] = $this->chapterUser->position;
}
}
$result['me'] = $me;
return $result; return $result;
} }
@ -179,6 +139,51 @@ class ChapterInfo extends LogicService
$this->incrChapterUserCount($chapter); $this->incrChapterUserCount($chapter);
} }
protected function handleMeInfo(ChapterModel $chapter, UserModel $user)
{
$me = [
'role_type' => 0,
'plan_id' => 0,
'position' => 0,
'logged' => 0,
'joined' => 0,
'owned' => 0,
'liked' => 0,
];
if ($user->id > 0) {
if ($this->joinedChapter) {
$me['joined'] = 1;
}
if ($this->ownedChapter) {
$me['owned'] = 1;
}
$me['logged'] = 1;
$likeRepo = new ChapterLikeRepo();
$like = $likeRepo->findChapterLike($chapter->id, $user->id);
if ($like && $like->deleted == 0) {
$me['liked'] = 1;
}
if ($this->courseUser) {
$me['role_type'] = $this->courseUser->role_type;
$me['plan_id'] = $this->courseUser->plan_id;
}
if ($this->chapterUser) {
$me['position'] = $this->chapterUser->position;
}
}
return $me;
}
protected function incrUserCourseCount(UserModel $user) protected function incrUserCourseCount(UserModel $user)
{ {
$user->course_count += 1; $user->course_count += 1;

View File

@ -69,6 +69,8 @@ trait ChapterTrait
public function setChapterUser(ChapterModel $chapter, UserModel $user) public function setChapterUser(ChapterModel $chapter, UserModel $user)
{ {
if ($user->id == 0) return;
$chapterUser = null; $chapterUser = null;
/** /**
@ -76,7 +78,7 @@ trait ChapterTrait
*/ */
$courseUser = $this->courseUser; $courseUser = $this->courseUser;
if ($user->id > 0 && $courseUser) { if ($courseUser) {
$chapterUserRepo = new ChapterUserRepo(); $chapterUserRepo = new ChapterUserRepo();
$chapterUser = $chapterUserRepo->findPlanChapterUser($chapter->id, $user->id, $courseUser->plan_id); $chapterUser = $chapterUserRepo->findPlanChapterUser($chapter->id, $user->id, $courseUser->plan_id);
} }

View File

@ -35,6 +35,13 @@ class CourseInfo extends LogicService
$result = $service->handleBasicInfo($course); $result = $service->handleBasicInfo($course);
$result['me'] = $this->handleMeInfo($course, $user);
return $result;
}
protected function handleMeInfo(CourseModel $course, UserModel $user)
{
$me = [ $me = [
'plan_id' => 0, 'plan_id' => 0,
'allow_order' => 0, 'allow_order' => 0,
@ -47,14 +54,6 @@ class CourseInfo extends LogicService
'favorited' => 0, 'favorited' => 0,
]; ];
if ($this->joinedCourse) {
$me['joined'] = 1;
}
if ($this->ownedCourse) {
$me['owned'] = 1;
}
$caseOwned = $this->ownedCourse == false; $caseOwned = $this->ownedCourse == false;
$casePrice = $course->market_price > 0; $casePrice = $course->market_price > 0;
$caseModel = true; $caseModel = true;
@ -66,6 +65,14 @@ class CourseInfo extends LogicService
$caseModel = $course->attrs['end_date'] < date('Y-m-d'); $caseModel = $course->attrs['end_date'] < date('Y-m-d');
} }
if ($caseOwned && $casePrice && $caseModel) {
$me['allow_order'] = 1;
}
if ($course->market_price == 0) {
$me['allow_reward'] = 1;
}
if ($user->id > 0) { if ($user->id > 0) {
if ($caseOwned && $casePrice && $caseModel) { if ($caseOwned && $casePrice && $caseModel) {
@ -76,6 +83,14 @@ class CourseInfo extends LogicService
$me['allow_reward'] = 1; $me['allow_reward'] = 1;
} }
if ($this->joinedCourse) {
$me['joined'] = 1;
}
if ($this->ownedCourse) {
$me['owned'] = 1;
}
$me['logged'] = 1; $me['logged'] = 1;
$favoriteRepo = new CourseFavoriteRepo(); $favoriteRepo = new CourseFavoriteRepo();
@ -93,9 +108,7 @@ class CourseInfo extends LogicService
} }
} }
$result['me'] = $me; return $me;
return $result;
} }
} }

View File

@ -9,7 +9,6 @@ namespace App\Services\Logic\Notice\External;
use App\Models\Task as TaskModel; use App\Models\Task as TaskModel;
use App\Models\User as UserModel; use App\Models\User as UserModel;
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\Logic\Notice\External\WeChat\AccountLogin as WeChatAccountLoginNotice; use App\Services\Logic\Notice\External\WeChat\AccountLogin as WeChatAccountLoginNotice;
use App\Services\Logic\Service as LogicService; use App\Services\Logic\Service as LogicService;
use App\Traits\Client as ClientTrait; use App\Traits\Client as ClientTrait;
@ -23,19 +22,11 @@ class AccountLogin extends LogicService
{ {
$wechatNoticeEnabled = $this->wechatNoticeEnabled(); $wechatNoticeEnabled = $this->wechatNoticeEnabled();
if (!$wechatNoticeEnabled) return;
$params = $task->item_info; $params = $task->item_info;
$userId = $task->item_info['user']['id']; if ($wechatNoticeEnabled) {
$subscribeRepo = new WeChatSubscribeRepo();
$subscribe = $subscribeRepo->findByUserId($userId);
if ($subscribe) {
$notice = new WeChatAccountLoginNotice(); $notice = new WeChatAccountLoginNotice();
$notice->handle($subscribe, $params); $notice->handle($params);
} }
} }

View File

@ -12,7 +12,6 @@ use App\Models\Task as TaskModel;
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\User as UserRepo; use App\Repos\User as UserRepo;
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\Logic\Notice\External\Sms\ConsultReply as SmsConsultReplyNotice; use App\Services\Logic\Notice\External\Sms\ConsultReply as SmsConsultReplyNotice;
use App\Services\Logic\Notice\External\WeChat\ConsultReply as WeChatConsultReplyNotice; use App\Services\Logic\Notice\External\WeChat\ConsultReply as WeChatConsultReplyNotice;
use App\Services\Logic\Service as LogicService; use App\Services\Logic\Service as LogicService;
@ -25,8 +24,6 @@ class ConsultReply extends LogicService
$wechatNoticeEnabled = $this->wechatNoticeEnabled(); $wechatNoticeEnabled = $this->wechatNoticeEnabled();
$smsNoticeEnabled = $this->smsNoticeEnabled(); $smsNoticeEnabled = $this->smsNoticeEnabled();
if (!$wechatNoticeEnabled && !$smsNoticeEnabled) return;
$consultId = $task->item_info['consult']['id']; $consultId = $task->item_info['consult']['id'];
$consultRepo = new ConsultRepo(); $consultRepo = new ConsultRepo();
@ -65,18 +62,14 @@ class ConsultReply extends LogicService
], ],
]; ];
$subscribeRepo = new WeChatSubscribeRepo(); if ($wechatNoticeEnabled) {
$subscribe = $subscribeRepo->findByUserId($consult->owner_id);
if ($wechatNoticeEnabled && $subscribe) {
$notice = new WeChatConsultReplyNotice(); $notice = new WeChatConsultReplyNotice();
$notice->handle($subscribe, $params); $notice->handle($params);
} }
if ($smsNoticeEnabled) { if ($smsNoticeEnabled) {
$notice = new SmsConsultReplyNotice(); $notice = new SmsConsultReplyNotice();
$notice->handle($user, $params); $notice->handle($params);
} }
} }

View File

@ -13,7 +13,6 @@ use App\Models\Task as TaskModel;
use App\Repos\Chapter as ChapterRepo; use App\Repos\Chapter as ChapterRepo;
use App\Repos\Course as CourseRepo; use App\Repos\Course as CourseRepo;
use App\Repos\User as UserRepo; use App\Repos\User as UserRepo;
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\Logic\Notice\External\Sms\LiveBegin as SmsLiveBeginNotice; use App\Services\Logic\Notice\External\Sms\LiveBegin as SmsLiveBeginNotice;
use App\Services\Logic\Notice\External\WeChat\LiveBegin as WeChatLiveBeginNotice; use App\Services\Logic\Notice\External\WeChat\LiveBegin as WeChatLiveBeginNotice;
use App\Services\Logic\Service as LogicService; use App\Services\Logic\Service as LogicService;
@ -26,8 +25,6 @@ class LiveBegin extends LogicService
$wechatNoticeEnabled = $this->wechatNoticeEnabled(); $wechatNoticeEnabled = $this->wechatNoticeEnabled();
$smsNoticeEnabled = $this->smsNoticeEnabled(); $smsNoticeEnabled = $this->smsNoticeEnabled();
if (!$wechatNoticeEnabled && !$smsNoticeEnabled) return;
$courseUser = $task->item_info['course_user']; $courseUser = $task->item_info['course_user'];
$chapterId = $task->item_info['chapter']['id']; $chapterId = $task->item_info['chapter']['id'];
@ -60,21 +57,16 @@ class LiveBegin extends LogicService
'start_time' => $chapter->attrs['start_time'], 'start_time' => $chapter->attrs['start_time'],
'end_time' => $chapter->attrs['end_time'], 'end_time' => $chapter->attrs['end_time'],
], ],
'course_user' => $courseUser,
]; ];
$subscribeRepo = new WeChatSubscribeRepo(); if ($wechatNoticeEnabled) {
$subscribe = $subscribeRepo->findByUserId($user->id);
if ($wechatNoticeEnabled && $subscribe) {
$notice = new WeChatLiveBeginNotice(); $notice = new WeChatLiveBeginNotice();
$notice->handle($subscribe, $params); $notice->handle($params);
} }
if ($smsNoticeEnabled) { if ($smsNoticeEnabled) {
$notice = new SmsLiveBeginNotice(); $notice = new SmsLiveBeginNotice();
$notice->handle($user, $params); $notice->handle($params);
} }
} }
@ -91,8 +83,6 @@ class LiveBegin extends LogicService
'course_user' => [ 'course_user' => [
'course_id' => $courseUser->course_id, 'course_id' => $courseUser->course_id,
'user_id' => $courseUser->user_id, 'user_id' => $courseUser->user_id,
'role_type' => $courseUser->role_type,
'source_type' => $courseUser->role_type,
], ],
'chapter' => [ 'chapter' => [
'id' => $chapter->id, 'id' => $chapter->id,

View File

@ -11,7 +11,6 @@ use App\Models\Order as OrderModel;
use App\Models\Task as TaskModel; use App\Models\Task as TaskModel;
use App\Repos\Order as OrderRepo; use App\Repos\Order as OrderRepo;
use App\Repos\User as UserRepo; use App\Repos\User as UserRepo;
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\Logic\Notice\External\Sms\OrderFinish as SmsOrderFinishNotice; use App\Services\Logic\Notice\External\Sms\OrderFinish as SmsOrderFinishNotice;
use App\Services\Logic\Notice\External\WeChat\OrderFinish as WeChatOrderFinishNotice; use App\Services\Logic\Notice\External\WeChat\OrderFinish as WeChatOrderFinishNotice;
use App\Services\Logic\Service as LogicService; use App\Services\Logic\Service as LogicService;
@ -24,8 +23,6 @@ class OrderFinish extends LogicService
$wechatNoticeEnabled = $this->wechatNoticeEnabled(); $wechatNoticeEnabled = $this->wechatNoticeEnabled();
$smsNoticeEnabled = $this->smsNoticeEnabled(); $smsNoticeEnabled = $this->smsNoticeEnabled();
if (!$wechatNoticeEnabled && !$smsNoticeEnabled) return;
$orderId = $task->item_info['order']['id']; $orderId = $task->item_info['order']['id'];
$orderRepo = new OrderRepo(); $orderRepo = new OrderRepo();
@ -50,18 +47,14 @@ class OrderFinish extends LogicService
], ],
]; ];
$subscribeRepo = new WeChatSubscribeRepo(); if ($wechatNoticeEnabled) {
$subscribe = $subscribeRepo->findByUserId($order->owner_id);
if ($wechatNoticeEnabled && $subscribe) {
$notice = new WeChatOrderFinishNotice(); $notice = new WeChatOrderFinishNotice();
$notice->handle($subscribe, $params); $notice->handle($params);
} }
if ($smsNoticeEnabled) { if ($smsNoticeEnabled) {
$notice = new SmsOrderFinishNotice(); $notice = new SmsOrderFinishNotice();
$notice->handle($user, $params); $notice->handle($params);
} }
} }

View File

@ -11,7 +11,6 @@ use App\Models\PointGiftRedeem as PointGiftRedeemModel;
use App\Models\Task as TaskModel; use App\Models\Task as TaskModel;
use App\Repos\PointGiftRedeem as PointGiftRedeemRepo; use App\Repos\PointGiftRedeem as PointGiftRedeemRepo;
use App\Repos\User as UserRepo; use App\Repos\User as UserRepo;
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\Logic\Notice\External\Sms\GoodsDeliver as SmsGoodsDeliverNotice; use App\Services\Logic\Notice\External\Sms\GoodsDeliver as SmsGoodsDeliverNotice;
use App\Services\Logic\Notice\External\WeChat\GoodsDeliver as WeChatGoodsDeliverNotice; use App\Services\Logic\Notice\External\WeChat\GoodsDeliver as WeChatGoodsDeliverNotice;
use App\Services\Logic\Service as LogicService; use App\Services\Logic\Service as LogicService;
@ -24,9 +23,7 @@ class PointGoodsDeliver extends LogicService
$wechatNoticeEnabled = $this->wechatNoticeEnabled(); $wechatNoticeEnabled = $this->wechatNoticeEnabled();
$smsNoticeEnabled = $this->smsNoticeEnabled(); $smsNoticeEnabled = $this->smsNoticeEnabled();
if (!$wechatNoticeEnabled && !$smsNoticeEnabled) return; $redeemId = $task->item_info['redeem']['id'];
$redeemId = $task->item_info['point_redeem']['id'];
$redeemRepo = new PointGiftRedeemRepo(); $redeemRepo = new PointGiftRedeemRepo();
@ -46,18 +43,14 @@ class PointGoodsDeliver extends LogicService
'deliver_time' => time(), 'deliver_time' => time(),
]; ];
$subscribeRepo = new WeChatSubscribeRepo(); if ($wechatNoticeEnabled) {
$subscribe = $subscribeRepo->findByUserId($user->id);
if ($wechatNoticeEnabled && $subscribe) {
$notice = new WeChatGoodsDeliverNotice(); $notice = new WeChatGoodsDeliverNotice();
$notice->handle($subscribe, $params); $notice->handle($params);
} }
if ($smsNoticeEnabled) { if ($smsNoticeEnabled) {
$notice = new SmsGoodsDeliverNotice(); $notice = new SmsGoodsDeliverNotice();
$notice->handle($user, $params); $notice->handle($params);
} }
} }
@ -71,7 +64,7 @@ class PointGoodsDeliver extends LogicService
$task = new TaskModel(); $task = new TaskModel();
$itemInfo = [ $itemInfo = [
'point_gift_redeem' => ['id' => $redeem->id], 'redeem' => ['id' => $redeem->id],
]; ];
$task->item_id = $redeem->id; $task->item_id = $redeem->id;

View File

@ -11,7 +11,6 @@ use App\Models\Refund as RefundModel;
use App\Models\Task as TaskModel; use App\Models\Task as TaskModel;
use App\Repos\Refund as RefundRepo; use App\Repos\Refund as RefundRepo;
use App\Repos\User as UserRepo; use App\Repos\User as UserRepo;
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\Logic\Notice\External\Sms\RefundFinish as SmsRefundFinishNotice; use App\Services\Logic\Notice\External\Sms\RefundFinish as SmsRefundFinishNotice;
use App\Services\Logic\Notice\External\WeChat\RefundFinish as WeChatRefundFinishNotice; use App\Services\Logic\Notice\External\WeChat\RefundFinish as WeChatRefundFinishNotice;
use App\Services\Logic\Service as LogicService; use App\Services\Logic\Service as LogicService;
@ -24,8 +23,6 @@ class RefundFinish extends LogicService
$wechatNoticeEnabled = $this->wechatNoticeEnabled(); $wechatNoticeEnabled = $this->wechatNoticeEnabled();
$smsNoticeEnabled = $this->smsNoticeEnabled(); $smsNoticeEnabled = $this->smsNoticeEnabled();
if (!$wechatNoticeEnabled && !$smsNoticeEnabled) return;
$refundId = $task->item_info['refund']['id']; $refundId = $task->item_info['refund']['id'];
$refundRepo = new RefundRepo(); $refundRepo = new RefundRepo();
@ -50,18 +47,14 @@ class RefundFinish extends LogicService
], ],
]; ];
$subscribeRepo = new WeChatSubscribeRepo(); if ($wechatNoticeEnabled) {
$subscribe = $subscribeRepo->findByUserId($refund->owner_id);
if ($wechatNoticeEnabled && $subscribe) {
$notice = new WeChatRefundFinishNotice(); $notice = new WeChatRefundFinishNotice();
$notice->handle($subscribe, $params); $notice->handle($params);
} }
if ($smsNoticeEnabled) { if ($smsNoticeEnabled) {
$notice = new SmsRefundFinishNotice(); $notice = new SmsRefundFinishNotice();
$notice->handle($user, $params); $notice->handle($params);
} }
} }

View File

@ -7,7 +7,6 @@
namespace App\Services\Logic\Notice\External\Sms; namespace App\Services\Logic\Notice\External\Sms;
use App\Models\User as UserModel;
use App\Repos\Account as AccountRepo; use App\Repos\Account as AccountRepo;
use App\Services\Smser; use App\Services\Smser;
@ -17,15 +16,14 @@ class ConsultReply extends Smser
protected $templateCode = 'consult_reply'; protected $templateCode = 'consult_reply';
/** /**
* @param UserModel $user
* @param array $params * @param array $params
* @return bool|null * @return bool|null
*/ */
public function handle(UserModel $user, array $params) public function handle(array $params)
{ {
$accountRepo = new AccountRepo(); $accountRepo = new AccountRepo();
$account = $accountRepo->findById($user->id); $account = $accountRepo->findById($params['user']['id']);
if (!$account->phone) return null; if (!$account->phone) return null;

View File

@ -7,7 +7,6 @@
namespace App\Services\Logic\Notice\External\Sms; namespace App\Services\Logic\Notice\External\Sms;
use App\Models\User as UserModel;
use App\Repos\Account as AccountRepo; use App\Repos\Account as AccountRepo;
use App\Services\Smser; use App\Services\Smser;
@ -17,22 +16,21 @@ class GoodsDeliver extends Smser
protected $templateCode = 'goods_deliver'; protected $templateCode = 'goods_deliver';
/** /**
* @param UserModel $user
* @param array $params * @param array $params
* @return bool|null * @return bool|null
*/ */
public function handle(UserModel $user, array $params) public function handle(array $params)
{ {
$params['deliver_time'] = date('Y-m-d H:i', $params['deliver_time']);
$accountRepo = new AccountRepo(); $accountRepo = new AccountRepo();
$account = $accountRepo->findById($user->id); $account = $accountRepo->findById($params['user']['id']);
if (!$account->phone) return null; if (!$account->phone) return null;
$templateId = $this->getTemplateId($this->templateCode); $templateId = $this->getTemplateId($this->templateCode);
$params['deliver_time'] = date('Y-m-d H:i', $params['deliver_time']);
$params = [ $params = [
$params['goods_name'], $params['goods_name'],
$params['order_sn'], $params['order_sn'],

View File

@ -7,7 +7,6 @@
namespace App\Services\Logic\Notice\External\Sms; namespace App\Services\Logic\Notice\External\Sms;
use App\Models\User as UserModel;
use App\Repos\Account as AccountRepo; use App\Repos\Account as AccountRepo;
use App\Services\Smser; use App\Services\Smser;
@ -17,20 +16,19 @@ class LiveBegin extends Smser
protected $templateCode = 'live_begin'; protected $templateCode = 'live_begin';
/** /**
* @param UserModel $user
* @param array $params * @param array $params
* @return bool|null * @return bool|null
*/ */
public function handle(UserModel $user, array $params) public function handle(array $params)
{ {
$params['live']['start_time'] = date('H:i', $params['live']['start_time']);
$accountRepo = new AccountRepo(); $accountRepo = new AccountRepo();
$account = $accountRepo->findById($user->id); $account = $accountRepo->findById($params['user']['id']);
if (!$account->phone) return null; if (!$account->phone) return null;
$params['live']['start_time'] = date('H:i', $params['live']['start_time']);
$params = [ $params = [
$params['course']['title'], $params['course']['title'],
$params['chapter']['title'], $params['chapter']['title'],

View File

@ -7,7 +7,6 @@
namespace App\Services\Logic\Notice\External\Sms; namespace App\Services\Logic\Notice\External\Sms;
use App\Models\User as UserModel;
use App\Repos\Account as AccountRepo; use App\Repos\Account as AccountRepo;
use App\Services\Smser; use App\Services\Smser;
@ -17,15 +16,14 @@ class OrderFinish extends Smser
protected $templateCode = 'order_finish'; protected $templateCode = 'order_finish';
/** /**
* @param UserModel $user
* @param array $params * @param array $params
* @return bool|null * @return bool|null
*/ */
public function handle(UserModel $user, array $params) public function handle(array $params)
{ {
$accountRepo = new AccountRepo(); $accountRepo = new AccountRepo();
$account = $accountRepo->findById($user->id); $account = $accountRepo->findById($params['user']['id']);
if (!$account->phone) return null; if (!$account->phone) return null;

View File

@ -7,7 +7,6 @@
namespace App\Services\Logic\Notice\External\Sms; namespace App\Services\Logic\Notice\External\Sms;
use App\Models\User as UserModel;
use App\Repos\Account as AccountRepo; use App\Repos\Account as AccountRepo;
use App\Services\Smser; use App\Services\Smser;
@ -17,15 +16,14 @@ class RefundFinish extends Smser
protected $templateCode = 'refund_finish'; protected $templateCode = 'refund_finish';
/** /**
* @param UserModel $user
* @param array $params * @param array $params
* @return bool|null * @return bool|null
*/ */
public function handle(UserModel $user, array $params) public function handle(array $params)
{ {
$accountRepo = new AccountRepo(); $accountRepo = new AccountRepo();
$account = $accountRepo->findById($user->id); $account = $accountRepo->findById($params['user']['id']);
if (!$account->phone) return null; if (!$account->phone) return null;

View File

@ -7,7 +7,7 @@
namespace App\Services\Logic\Notice\External\WeChat; namespace App\Services\Logic\Notice\External\WeChat;
use App\Models\WeChatSubscribe as WeChatSubscribeModel; use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\WeChatNotice; use App\Services\WeChatNotice;
class AccountLogin extends WeChatNotice class AccountLogin extends WeChatNotice
@ -16,12 +16,17 @@ class AccountLogin extends WeChatNotice
protected $templateCode = 'account_login'; protected $templateCode = 'account_login';
/** /**
* @param WeChatSubscribeModel $subscribe
* @param array $params * @param array $params
* @return bool * @return bool|null
*/ */
public function handle(WeChatSubscribeModel $subscribe, array $params) public function handle(array $params)
{ {
$subscribeRepo = new WeChatSubscribeRepo();
$subscribe = $subscribeRepo->findByUserId($params['user']['id']);
if (!$subscribe) return null;
$first = '你好,登录系统成功!'; $first = '你好,登录系统成功!';
$remark = '如果非本人操作,请立即修改密码哦!'; $remark = '如果非本人操作,请立即修改密码哦!';

View File

@ -7,7 +7,7 @@
namespace App\Services\Logic\Notice\External\WeChat; namespace App\Services\Logic\Notice\External\WeChat;
use App\Models\WeChatSubscribe as WeChatSubscribeModel; use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\WeChatNotice; use App\Services\WeChatNotice;
class ConsultReply extends WeChatNotice class ConsultReply extends WeChatNotice
@ -16,12 +16,17 @@ class ConsultReply extends WeChatNotice
protected $templateCode = 'consult_reply'; protected $templateCode = 'consult_reply';
/** /**
* @param WeChatSubscribeModel $subscribe
* @param array $params * @param array $params
* @return bool * @return bool|null
*/ */
public function handle(WeChatSubscribeModel $subscribe, array $params) public function handle(array $params)
{ {
$subscribeRepo = new WeChatSubscribeRepo();
$subscribe = $subscribeRepo->findByUserId($params['user']['id']);
if (!$subscribe) return null;
$first = sprintf('%s 回复了你的咨询!', $params['replier']['name']); $first = sprintf('%s 回复了你的咨询!', $params['replier']['name']);
$remark = '如果还有其它疑问,请和我们保持联系哦!'; $remark = '如果还有其它疑问,请和我们保持联系哦!';

View File

@ -7,7 +7,7 @@
namespace App\Services\Logic\Notice\External\WeChat; namespace App\Services\Logic\Notice\External\WeChat;
use App\Models\WeChatSubscribe as WeChatSubscribeModel; use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\WeChatNotice; use App\Services\WeChatNotice;
class GoodsDeliver extends WeChatNotice class GoodsDeliver extends WeChatNotice
@ -16,12 +16,16 @@ class GoodsDeliver extends WeChatNotice
protected $templateCode = 'goods_deliver'; protected $templateCode = 'goods_deliver';
/** /**
* @param WeChatSubscribeModel $subscribe
* @param array $params * @param array $params
* @return bool * @return bool|null
*/ */
public function handle(WeChatSubscribeModel $subscribe, $params) public function handle($params)
{ {
$subscribeRepo = new WeChatSubscribeRepo();
$subscribe = $subscribeRepo->findByUserId($params['user']['id']);
if (!$subscribe) return null;
$first = '发货已处理完成!'; $first = '发货已处理完成!';
$remark = '感谢您的支持,有疑问请联系客服哦!'; $remark = '感谢您的支持,有疑问请联系客服哦!';

View File

@ -7,7 +7,7 @@
namespace App\Services\Logic\Notice\External\WeChat; namespace App\Services\Logic\Notice\External\WeChat;
use App\Models\WeChatSubscribe as WeChatSubscribeModel; use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\WeChatNotice; use App\Services\WeChatNotice;
class LiveBegin extends WeChatNotice class LiveBegin extends WeChatNotice
@ -16,12 +16,17 @@ class LiveBegin extends WeChatNotice
protected $templateCode = 'live_begin'; protected $templateCode = 'live_begin';
/** /**
* @param WeChatSubscribeModel $subscribe
* @param array $params * @param array $params
* @return bool * @return bool|null
*/ */
public function handle(WeChatSubscribeModel $subscribe, array $params) public function handle(array $params)
{ {
$subscribeRepo = new WeChatSubscribeRepo();
$subscribe = $subscribeRepo->findByUserId($params['user']['id']);
if (!$subscribe) return null;
$first = '你参与的课程直播就要开始了!'; $first = '你参与的课程直播就要开始了!';
$startTime = date('H:i', $params['live']['start_time']); $startTime = date('H:i', $params['live']['start_time']);

View File

@ -7,7 +7,7 @@
namespace App\Services\Logic\Notice\External\WeChat; namespace App\Services\Logic\Notice\External\WeChat;
use App\Models\WeChatSubscribe as WeChatSubscribeModel; use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\WeChatNotice; use App\Services\WeChatNotice;
class OrderFinish extends WeChatNotice class OrderFinish extends WeChatNotice
@ -16,12 +16,16 @@ class OrderFinish extends WeChatNotice
protected $templateCode = 'order_finish'; protected $templateCode = 'order_finish';
/** /**
* @param WeChatSubscribeModel $subscribe
* @param array $params * @param array $params
* @return bool * @return bool|null
*/ */
public function handle(WeChatSubscribeModel $subscribe, $params) public function handle($params)
{ {
$subscribeRepo = new WeChatSubscribeRepo();
$subscribe = $subscribeRepo->findByUserId($params['user']['id']);
if (!$subscribe) return null;
$first = '订单已处理完成!'; $first = '订单已处理完成!';
$remark = '感谢您的支持,有疑问请联系客服哦!'; $remark = '感谢您的支持,有疑问请联系客服哦!';

View File

@ -7,7 +7,7 @@
namespace App\Services\Logic\Notice\External\WeChat; namespace App\Services\Logic\Notice\External\WeChat;
use App\Models\WeChatSubscribe as WeChatSubscribeModel; use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
use App\Services\WeChatNotice; use App\Services\WeChatNotice;
class RefundFinish extends WeChatNotice class RefundFinish extends WeChatNotice
@ -16,12 +16,17 @@ class RefundFinish extends WeChatNotice
protected $templateCode = 'refund_finish'; protected $templateCode = 'refund_finish';
/** /**
* @param WeChatSubscribeModel $subscribe
* @param array $params * @param array $params
* @return bool * @return bool
*/ */
public function handle(WeChatSubscribeModel $subscribe, array $params) public function handle(array $params)
{ {
$subscribeRepo = new WeChatSubscribeRepo();
$subscribe = $subscribeRepo->findByUserId($params['user']['id']);
if (!$subscribe) return null;
$first = '退款已处理完成!'; $first = '退款已处理完成!';
$remark = '感谢您的支持,有疑问请联系客服哦!'; $remark = '感谢您的支持,有疑问请联系客服哦!';

45
composer.lock generated
View File

@ -2366,16 +2366,16 @@
}, },
{ {
"name": "qcloud/cos-sdk-v5", "name": "qcloud/cos-sdk-v5",
"version": "v2.6.1", "version": "v2.6.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/tencentyun/cos-php-sdk-v5.git", "url": "https://github.com/tencentyun/cos-php-sdk-v5.git",
"reference": "d367ba8d0305b83364b64055594a0ac22b1cefd8" "reference": "92a1ee62b85ed4e7bf6836a684df5d7e3158d0ed"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/tencentyun/cos-php-sdk-v5/zipball/d367ba8d0305b83364b64055594a0ac22b1cefd8", "url": "https://api.github.com/repos/tencentyun/cos-php-sdk-v5/zipball/92a1ee62b85ed4e7bf6836a684df5d7e3158d0ed",
"reference": "d367ba8d0305b83364b64055594a0ac22b1cefd8", "reference": "92a1ee62b85ed4e7bf6836a684df5d7e3158d0ed",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -2387,6 +2387,7 @@
"require": { "require": {
"ext-curl": "*", "ext-curl": "*",
"ext-json": "*", "ext-json": "*",
"ext-mbstring": "*",
"ext-simplexml": "*", "ext-simplexml": "*",
"guzzlehttp/guzzle": "^6.2.1 || ^7.0", "guzzlehttp/guzzle": "^6.2.1 || ^7.0",
"guzzlehttp/guzzle-services": "^1.1", "guzzlehttp/guzzle-services": "^1.1",
@ -2433,9 +2434,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/tencentyun/cos-php-sdk-v5/issues", "issues": "https://github.com/tencentyun/cos-php-sdk-v5/issues",
"source": "https://github.com/tencentyun/cos-php-sdk-v5/tree/v2.6.1" "source": "https://github.com/tencentyun/cos-php-sdk-v5/tree/v2.6.2"
}, },
"time": "2023-02-07T09:49:12+00:00" "time": "2023-04-07T07:38:24+00:00"
}, },
{ {
"name": "ralouphie/getallheaders", "name": "ralouphie/getallheaders",
@ -4910,16 +4911,16 @@
}, },
{ {
"name": "tencentcloud/tencentcloud-sdk-php", "name": "tencentcloud/tencentcloud-sdk-php",
"version": "3.0.824", "version": "3.0.889",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/TencentCloud/tencentcloud-sdk-php.git", "url": "https://github.com/TencentCloud/tencentcloud-sdk-php.git",
"reference": "1d85da7e51ba02defe33fbae0b6dbae0f1d7caf5" "reference": "a08031e5111f17131fceb429eebb8223c105d8b3"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/TencentCloud/tencentcloud-sdk-php/zipball/1d85da7e51ba02defe33fbae0b6dbae0f1d7caf5", "url": "https://api.github.com/repos/TencentCloud/tencentcloud-sdk-php/zipball/a08031e5111f17131fceb429eebb8223c105d8b3",
"reference": "1d85da7e51ba02defe33fbae0b6dbae0f1d7caf5", "reference": "a08031e5111f17131fceb429eebb8223c105d8b3",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -4932,6 +4933,9 @@
"guzzlehttp/guzzle": "^6.3 || ^7.0", "guzzlehttp/guzzle": "^6.3 || ^7.0",
"php": ">=5.6.0" "php": ">=5.6.0"
}, },
"require-dev": {
"phpunit/phpunit": "^9.5"
},
"type": "library", "type": "library",
"autoload": { "autoload": {
"psr-4": { "psr-4": {
@ -4957,9 +4961,9 @@
"homepage": "https://github.com/TencentCloud/tencentcloud-sdk-php", "homepage": "https://github.com/TencentCloud/tencentcloud-sdk-php",
"support": { "support": {
"issues": "https://github.com/TencentCloud/tencentcloud-sdk-php/issues", "issues": "https://github.com/TencentCloud/tencentcloud-sdk-php/issues",
"source": "https://github.com/TencentCloud/tencentcloud-sdk-php/tree/3.0.824" "source": "https://github.com/TencentCloud/tencentcloud-sdk-php/tree/3.0.889"
}, },
"time": "2023-02-15T00:03:58+00:00" "time": "2023-05-22T00:02:52+00:00"
}, },
{ {
"name": "webmozart/assert", "name": "webmozart/assert",
@ -5097,16 +5101,16 @@
}, },
{ {
"name": "workerman/gateway-worker", "name": "workerman/gateway-worker",
"version": "v3.0.27", "version": "v3.0.28",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/walkor/GatewayWorker.git", "url": "https://github.com/walkor/GatewayWorker.git",
"reference": "c0cae6c0e69288ab7dcc8b25599d3b9e4f4441d2" "reference": "a7dffc53403133131a51b9fd3c6c6d70869cb6d3"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/walkor/GatewayWorker/zipball/c0cae6c0e69288ab7dcc8b25599d3b9e4f4441d2", "url": "https://api.github.com/repos/walkor/GatewayWorker/zipball/a7dffc53403133131a51b9fd3c6c6d70869cb6d3",
"reference": "c0cae6c0e69288ab7dcc8b25599d3b9e4f4441d2", "reference": "a7dffc53403133131a51b9fd3c6c6d70869cb6d3",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -5116,7 +5120,8 @@
] ]
}, },
"require": { "require": {
"workerman/workerman": "^4.0.0 || ^5.0.0" "php": ">=7.0",
"workerman/workerman": "^4.0.30"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -5135,7 +5140,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/walkor/GatewayWorker/issues", "issues": "https://github.com/walkor/GatewayWorker/issues",
"source": "https://github.com/walkor/GatewayWorker/tree/v3.0.27" "source": "https://github.com/walkor/GatewayWorker/tree/v3.0.28"
}, },
"funding": [ "funding": [
{ {
@ -5147,7 +5152,7 @@
"type": "patreon" "type": "patreon"
} }
], ],
"time": "2023-02-09T09:16:04+00:00" "time": "2023-03-24T03:56:27+00:00"
}, },
{ {
"name": "workerman/gatewayclient", "name": "workerman/gatewayclient",
@ -5641,5 +5646,5 @@
"ext-fileinfo": "*" "ext-fileinfo": "*"
}, },
"platform-dev": [], "platform-dev": [],
"plugin-api-version": "2.3.0" "plugin-api-version": "2.0.0"
} }

View File

@ -0,0 +1,37 @@
<?php
/**
* @copyright Copyright (c) 2023 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
use Phinx\Db\Adapter\MysqlAdapter;
use Phinx\Migration\AbstractMigration;
final class V20230522141831 extends AbstractMigration
{
public function up()
{
$this->alterReviewLikeTable();
}
protected function alterReviewLikeTable()
{
$table = $this->table('kg_review_like');
if (!$table->hasColumn('update_time')) {
$table->addColumn('update_time', 'integer', [
'null' => false,
'default' => '0',
'limit' => MysqlAdapter::INT_REGULAR,
'signed' => false,
'comment' => '更新时间',
'after' => 'create_time',
]);
}
$table->save();
}
}

View File

@ -0,0 +1,51 @@
<?php
/**
* @copyright Copyright (c) 2023 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
require_once 'SettingTrait.php';
use Phinx\Migration\AbstractMigration;
final class V20230611193031 extends AbstractMigration
{
use SettingTrait;
public function up()
{
$this->handleDingTalkRobotSettings();
}
protected function handleDingTalkRobotSettings()
{
$row = $this->getQueryBuilder()
->select('*')
->from('kg_setting')
->where(['section' => 'dingtalk.robot'])
->andWhere(['item_key' => 'app_token'])
->execute()->fetch(PDO::FETCH_ASSOC);
$webhookUrl = '';
/**
* 直接使用webhook地址不用单独分离出access_token简化用户操作
*/
if (!empty($row['item_value'])) {
$webhookUrl = "https://oapi.dingtalk.com/robot/send?access_token={$row['item_value']}";
}
$rows = [
[
'section' => 'dingtalk.robot',
'item_key' => 'webhook_url',
'item_value' => $webhookUrl,
],
];
$this->insertSettings($rows);
}
}

View File

@ -11,7 +11,7 @@ trait PageTrait
protected function insertPages(array $rows) protected function insertPages(array $rows)
{ {
foreach ($rows as $key => $row) { foreach ($rows as $key => $row) {
$exists = $this->pageExits($row['alias']); $exists = $this->pageExists($row['alias']);
if ($exists) unset($rows[$key]); if ($exists) unset($rows[$key]);
} }
@ -20,7 +20,7 @@ trait PageTrait
$this->table('kg_page')->insert($rows)->save(); $this->table('kg_page')->insert($rows)->save();
} }
protected function pageExits($alias) protected function pageExists($alias)
{ {
$row = $this->getQueryBuilder() $row = $this->getQueryBuilder()
->select('*') ->select('*')
@ -28,7 +28,7 @@ trait PageTrait
->where(['alias' => $alias]) ->where(['alias' => $alias])
->execute()->fetch(); ->execute()->fetch();
return $row ? true : false; return (bool)$row;
} }
} }

View File

@ -11,7 +11,7 @@ trait SettingTrait
protected function insertSettings(array $rows) protected function insertSettings(array $rows)
{ {
foreach ($rows as $key => $row) { foreach ($rows as $key => $row) {
$exists = $this->settingExits($row['section'], $row['item_key']); $exists = $this->settingExists($row['section'], $row['item_key']);
if ($exists) unset($rows[$key]); if ($exists) unset($rows[$key]);
} }
@ -20,7 +20,7 @@ trait SettingTrait
$this->table('kg_setting')->insert($rows)->save(); $this->table('kg_setting')->insert($rows)->save();
} }
protected function settingExits($section, $itemKey) protected function settingExists($section, $itemKey)
{ {
$row = $this->getQueryBuilder() $row = $this->getQueryBuilder()
->select('*') ->select('*')
@ -28,7 +28,7 @@ trait SettingTrait
->where(['section' => $section, 'item_key' => $itemKey]) ->where(['section' => $section, 'item_key' => $itemKey])
->execute()->fetch(); ->execute()->fetch();
return $row ? true : false; return (bool)$row;
} }
} }

View File

@ -1,10 +0,0 @@
layui.use(['jquery', 'helper'], function () {
var $ = layui.jquery;
var helper = layui.helper;
$('.btn-cs').on('click', function () {
helper.cs();
});
});