diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d08a790..6cb084df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,24 @@ +### [v1.2.7](https://gitee.com/koogua/course-tencent-cloud/releases/v1.2.7)(2021-02-26) + +### 新增 + +- 钉钉机器人群消息通知 +- demo分支重置演示帐号计划任务 +- 添加学员自动加入相关课程群组 +- 后台查看积分记录 + +### 更新 + +- 路由重命名 admin.group -> admin.im_group +- 路由重命名 home.group -> home.im_group +- 样式重命名 sidebar-teacher-card -> sidebar-user-card +- 去除顶部积分导航 +- 用户中心部分样式调整 +- 后台部分导航调整 +- 不能删除课程教师问题 +- 积分模块可通过后台控制是否启用 +- 解除好友关系后好友数量未递减 + ### [v1.2.6](https://gitee.com/koogua/course-tencent-cloud/releases/v1.2.6)(2021-02-20) ### 新增 diff --git a/app/Console/Tasks/CleanLogTask.php b/app/Console/Tasks/CleanLogTask.php index e198d702..581d6163 100644 --- a/app/Console/Tasks/CleanLogTask.php +++ b/app/Console/Tasks/CleanLogTask.php @@ -26,6 +26,7 @@ class CleanLogTask extends Task $this->cleanOrderLog(); $this->cleanRefundLog(); $this->cleanPointLog(); + $this->cleanDingTalkLog(); $this->cleanNoticeLog(); $this->cleanOtherLog(); } @@ -234,6 +235,18 @@ class CleanLogTask extends Task $this->whitelist[] = $type; } + /** + * 清理钉钉日志 + */ + protected function cleanDingTalkLog() + { + $type = 'dingtalk'; + + $this->cleanLog($type, 7); + + $this->whitelist[] = $type; + } + /** * 清理通知日志 */ diff --git a/app/Console/Tasks/DeliverTask.php b/app/Console/Tasks/DeliverTask.php index d41a22b7..e15007da 100644 --- a/app/Console/Tasks/DeliverTask.php +++ b/app/Console/Tasks/DeliverTask.php @@ -21,17 +21,13 @@ use Phalcon\Mvc\Model\ResultsetInterface; class DeliverTask extends Task { - const TRY_COUNT = 3; - public function mainAction() { $logger = $this->getLogger('order'); $tasks = $this->findTasks(30); - if ($tasks->count() == 0) { - return; - } + if ($tasks->count() == 0) return; $orderRepo = new OrderRepo(); @@ -84,7 +80,7 @@ class DeliverTask extends Task $task->try_count += 1; $task->priority += 1; - if ($task->try_count > self::TRY_COUNT) { + if ($task->try_count > $task->max_try_count) { $task->status = TaskModel::STATUS_FAILED; } diff --git a/app/Console/Tasks/NoticeTask.php b/app/Console/Tasks/NoticeTask.php index 7d17318d..8d3abe45 100644 --- a/app/Console/Tasks/NoticeTask.php +++ b/app/Console/Tasks/NoticeTask.php @@ -3,6 +3,10 @@ namespace App\Console\Tasks; use App\Models\Task as TaskModel; +use App\Services\DingTalk\Notice\ConsultCreate as ConsultCreateNotice; +use App\Services\DingTalk\Notice\CustomService as CustomServiceNotice; +use App\Services\DingTalk\Notice\ServerMonitor as ServerMonitorNotice; +use App\Services\DingTalk\Notice\TeacherLive as TeacherLiveNotice; use App\Services\Logic\Notice\AccountLogin as AccountLoginNotice; use App\Services\Logic\Notice\ConsultReply as ConsultReplyNotice; use App\Services\Logic\Notice\LiveBegin as LiveBeginNotice; @@ -14,8 +18,6 @@ use Phalcon\Mvc\Model\ResultsetInterface; class NoticeTask extends Task { - const TRY_COUNT = 3; - public function mainAction() { $logger = $this->getLogger('notice'); @@ -46,6 +48,18 @@ class NoticeTask extends Task case TaskModel::TYPE_NOTICE_CONSULT_REPLY: $this->handleConsultReplyNotice($task); break; + case TaskModel::TYPE_NOTICE_CONSULT_CREATE: + $this->handleConsultCreateNotice($task); + break; + case TaskModel::TYPE_NOTICE_TEACHER_LIVE: + $this->handleTeacherLiveNotice($task); + break; + case TaskModel::TYPE_NOTICE_SERVER_MONITOR: + $this->handleServerMonitorNotice($task); + break; + case TaskModel::TYPE_NOTICE_CUSTOM_SERVICE: + $this->handleCustomServiceNotice($task); + break; } $task->status = TaskModel::STATUS_FINISHED; @@ -57,7 +71,7 @@ class NoticeTask extends Task $task->try_count += 1; $task->priority += 1; - if ($task->try_count > self::TRY_COUNT) { + if ($task->try_count >= $task->max_try_count) { $task->status = TaskModel::STATUS_FAILED; } @@ -77,42 +91,70 @@ class NoticeTask extends Task { $notice = new AccountLoginNotice(); - return $notice->handleTask($task); + $notice->handleTask($task); } protected function handleLiveBeginNotice(TaskModel $task) { $notice = new LiveBeginNotice(); - return $notice->handleTask($task); + $notice->handleTask($task); } protected function handleOrderFinishNotice(TaskModel $task) { $notice = new OrderFinishNotice(); - return $notice->handleTask($task); + $notice->handleTask($task); } protected function handleRefundFinishNotice(TaskModel $task) { $notice = new RefundFinishNotice(); - return $notice->handleTask($task); + $notice->handleTask($task); } protected function handleConsultReplyNotice(TaskModel $task) { $notice = new ConsultReplyNotice(); - return $notice->handleTask($task); + $notice->handleTask($task); + } + + protected function handleConsultCreateNotice(TaskModel $task) + { + $notice = new ConsultCreateNotice(); + + $notice->handleTask($task); + } + + protected function handleTeacherLiveNotice(TaskModel $task) + { + $notice = new TeacherLiveNotice(); + + $notice->handleTask($task); + } + + protected function handleServerMonitorNotice(TaskModel $task) + { + $notice = new ServerMonitorNotice(); + + $notice->handleTask($task); + } + + protected function handleCustomServiceNotice(TaskModel $task) + { + $notice = new CustomServiceNotice(); + + $notice->handleTask($task); } /** * @param int $limit * @return ResultsetInterface|Resultset|TaskModel[] */ - protected function findTasks($limit = 100) + protected function findTasks($limit = 300) { $itemTypes = [ TaskModel::TYPE_NOTICE_ACCOUNT_LOGIN, @@ -120,6 +162,10 @@ class NoticeTask extends Task TaskModel::TYPE_NOTICE_ORDER_FINISH, TaskModel::TYPE_NOTICE_REFUND_FINISH, TaskModel::TYPE_NOTICE_CONSULT_REPLY, + TaskModel::TYPE_NOTICE_CONSULT_CREATE, + TaskModel::TYPE_NOTICE_TEACHER_LIVE, + TaskModel::TYPE_NOTICE_SERVER_MONITOR, + TaskModel::TYPE_NOTICE_CUSTOM_SERVICE, ]; $status = TaskModel::STATUS_PENDING; diff --git a/app/Console/Tasks/OptimizeTableTask.php b/app/Console/Tasks/OptimizeTableTask.php new file mode 100644 index 00000000..7143c0b7 --- /dev/null +++ b/app/Console/Tasks/OptimizeTableTask.php @@ -0,0 +1,71 @@ +optimizeImMessageTable(); + $this->optimizeLearningTable(); + $this->optimizeTaskTable(); + } + + protected function optimizeImMessageTable() + { + $count = ImMessageModel::count(); + + if ($count < 1000000) return; + + $messageModel = new ImMessageModel(); + + $tableName = $messageModel->getSource(); + + $this->db->delete($tableName, "create_time < :create_time", [ + 'create_time' => strtotime('-6 months'), + ]); + + $this->db->execute("OPTIMIZE TABLE {$tableName}"); + } + + protected function optimizeLearningTable() + { + $count = LearningModel::count(); + + if ($count < 1000000) return; + + $learningModel = new LearningModel(); + + $tableName = $learningModel->getSource(); + + $this->db->delete($tableName, "create_time < :create_time", [ + 'create_time' => strtotime('-6 months'), + ]); + + $this->db->execute("OPTIMIZE TABLE {$tableName}"); + } + + protected function optimizeTaskTable() + { + $count = TaskModel::count(); + + if ($count < 1000000) return; + + $taskModel = new TaskModel(); + + $tableName = $taskModel->getSource(); + + $this->db->delete($tableName, "create_time < :create_time AND status > :status", [ + 'create_time' => strtotime('-6 months'), + 'status' => TaskModel::STATUS_PENDING, + ]); + + $this->db->execute("OPTIMIZE TABLE {$tableName}"); + } + +} \ No newline at end of file diff --git a/app/Console/Tasks/PointGiftDeliverTask.php b/app/Console/Tasks/PointGiftDeliverTask.php index 0f8baac9..1af243e7 100644 --- a/app/Console/Tasks/PointGiftDeliverTask.php +++ b/app/Console/Tasks/PointGiftDeliverTask.php @@ -13,6 +13,7 @@ use App\Repos\ImGroup as ImGroupRepo; use App\Repos\ImGroupUser as ImGroupUserRepo; use App\Repos\PointGift as PointGiftRepo; use App\Repos\PointRedeem as PointRedeemRepo; +use App\Services\DingTalk\Notice\PointRedeem as PointRedeemNotice; use App\Services\Logic\Point\PointHistory as PointHistoryService; use Phalcon\Mvc\Model\Resultset; use Phalcon\Mvc\Model\ResultsetInterface; @@ -20,17 +21,13 @@ use Phalcon\Mvc\Model\ResultsetInterface; class PointGiftDeliverTask extends Task { - const TRY_COUNT = 3; - public function mainAction() { $logger = $this->getLogger('point'); $tasks = $this->findTasks(30); - if ($tasks->count() == 0) { - return; - } + if ($tasks->count() == 0) return; $redeemRepo = new PointRedeemRepo(); @@ -77,7 +74,7 @@ class PointGiftDeliverTask extends Task $task->try_count += 1; $task->priority += 1; - if ($task->try_count > self::TRY_COUNT) { + if ($task->try_count > $task->max_try_count) { $task->status = TaskModel::STATUS_FAILED; } @@ -167,7 +164,9 @@ class PointGiftDeliverTask extends Task protected function handleGoodsRedeem(PointRedeemModel $redeem) { + $notice = new PointRedeemNotice(); + $notice->createTask($redeem); } protected function handleCashRedeem(PointRedeemModel $redeem) diff --git a/app/Console/Tasks/RefundTask.php b/app/Console/Tasks/RefundTask.php index 41e04a51..9689542c 100644 --- a/app/Console/Tasks/RefundTask.php +++ b/app/Console/Tasks/RefundTask.php @@ -20,20 +20,13 @@ use Phalcon\Mvc\Model\ResultsetInterface; class RefundTask extends Task { - /** - * 重试次数 - */ - const TRY_COUNT = 3; - public function mainAction() { $logger = $this->getLogger('refund'); $tasks = $this->findTasks(30); - if ($tasks->count() == 0) { - return; - } + if ($tasks->count() == 0) return; $tradeRepo = new TradeRepo(); $orderRepo = new OrderRepo(); @@ -96,7 +89,7 @@ class RefundTask extends Task $task->try_count += 1; $task->priority += 1; - if ($task->try_count > self::TRY_COUNT) { + if ($task->try_count > $task->max_try_count) { $task->status = TaskModel::STATUS_FAILED; } diff --git a/app/Console/Tasks/ServerMonitorTask.php b/app/Console/Tasks/ServerMonitorTask.php new file mode 100644 index 00000000..7eff21ca --- /dev/null +++ b/app/Console/Tasks/ServerMonitorTask.php @@ -0,0 +1,220 @@ +getSettings('dingtalk.robot'); + + if ($robot['enabled'] == 0) return; + + $items = [ + 'cpu' => $this->checkCpu(), + 'memory' => $this->checkMemory(), + 'disk' => $this->checkDisk(), + 'mysql' => $this->checkMysql(), + 'redis' => $this->checkRedis(), + 'xunsearch' => $this->checkXunsearch(), + 'websocket' => $this->checkWebsocket(), + ]; + + foreach ($items as $key => $value) { + if (empty($value)) { + unset($items[$key]); + } + } + + if (empty($items)) return; + + $content = implode("\n", $items); + + $notice = new ServerMonitorNotice(); + + $notice->createTask($content); + } + + protected function checkCpu() + { + $cpuCount = $this->getCpuCount(); + + $load = sys_getloadavg(); + + if ($load[1] > $cpuCount * 0.8) { + return sprintf("cpu负载超过%s", $load[1]); + } + } + + protected function checkMemory() + { + $memInfo = file_get_contents('/proc/meminfo'); + + $total = null; + + if (preg_match('/MemTotal\:\s+(\d+) kB/', $memInfo, $totalMatches)) { + $total = $totalMatches[1]; + } + + if ($total === null) return; + + $available = null; + + if (preg_match('/MemAvailable\:\s+(\d+) kB/', $memInfo, $avaMatches)) { + $available = $avaMatches[1]; + } + + if ($available === null) return; + + $left = 100 * ($available / $total); + + if ($left < 20) { + return sprintf("memory剩余不足%s%%", round($left)); + } + } + + protected function checkDisk() + { + $free = disk_free_space('/'); + $total = disk_total_space('/'); + + $left = 100 * $free / $total; + + if ($left < 20) { + return sprintf("disk剩余不足%s%%", round($left)); + } + } + + protected function checkMysql() + { + try { + + $benchmark = new Benchmark(); + + $benchmark->start(); + + $user = UserModel::findFirst(); + + $benchmark->stop(); + + $elapsedTime = $benchmark->getElapsedTime(); + + if ($user === false) { + return sprintf("mysql查询失败"); + } + + if ($elapsedTime > 1) { + return sprintf("mysql查询响应超过%s秒", round($elapsedTime, 2)); + } + + } catch (\Exception $e) { + return sprintf("mysql可能存在异常"); + } + } + + protected function checkRedis() + { + try { + + $benchmark = new Benchmark(); + + $benchmark->start(); + + $site = $this->getSettings('site'); + + $benchmark->stop(); + + $elapsedTime = $benchmark->getElapsedTime(); + + if (empty($site)) { + return sprintf("redis查询失败"); + } + + if ($elapsedTime > 1) { + return sprintf("redis查询响应超过%s秒", round($elapsedTime, 2)); + } + + } catch (\Exception $e) { + return sprintf("redis可能存在异常"); + } + } + + protected function checkXunsearch() + { + try { + + $benchmark = new Benchmark(); + + $benchmark->start(); + + $searcher = new UserSearcher(); + + $user = $searcher->search('id:10000'); + + $benchmark->stop(); + + $elapsedTime = $benchmark->getElapsedTime(); + + if (empty($user)) { + return sprintf("xunsearch搜索失败"); + } + + if ($elapsedTime > 1) { + return sprintf("xunsearch搜索响应超过%s秒", round($elapsedTime, 2)); + } + + } catch (\Exception $e) { + return sprintf("xunsearch可能存在异常"); + } + } + + protected function checkWebsocket() + { + try { + + $benchmark = new Benchmark(); + + $config = $this->getConfig(); + + Gateway::$registerAddress = $config->path('websocket.register_address'); + + $benchmark->start(); + + Gateway::isUidOnline(10000); + + $benchmark->stop(); + + $elapsedTime = $benchmark->getElapsedTime(); + + if ($elapsedTime > 1) { + return sprintf("websocket响应超过%s秒", round($elapsedTime, 2)); + } + + } catch (\Exception $e) { + return sprintf("websocket可能存在异常"); + } + } + + protected function getCpuCount() + { + $cpuInfo = file_get_contents('/proc/cpuinfo'); + + preg_match("/^cpu cores\s:\s(\d+)/m", $cpuInfo, $matches); + + $coreCount = intval($matches[1]); + + preg_match_all("/^processor/m", $cpuInfo, $matches); + + $processorCount = count($matches[0]); + + return $coreCount * $processorCount; + } + +} \ No newline at end of file diff --git a/app/Console/Tasks/TeacherLiveNoticeTask.php b/app/Console/Tasks/TeacherLiveNoticeTask.php new file mode 100644 index 00000000..fac00d68 --- /dev/null +++ b/app/Console/Tasks/TeacherLiveNoticeTask.php @@ -0,0 +1,81 @@ +findLives(); + + if ($lives->count() == 0) return; + + $redis = $this->getRedis(); + + $keyName = $this->getCacheKeyName(); + + foreach ($lives as $live) { + $redis->sAdd($keyName, $live->chapter_id); + } + + $redis->expire($keyName, 86400); + } + + /** + * 消费讲师提醒 + */ + public function consumeAction() + { + $redis = $this->getRedis(); + + $keyName = $this->getCacheKeyName(); + + $liveIds = $redis->sMembers($keyName); + + if (count($liveIds) == 0) return; + + $liveRepo = new ChapterLiveRepo(); + + $notice = new TeacherLiveNotice(); + + foreach ($liveIds as $liveId) { + + $live = $liveRepo->findById($liveId); + + if ($live->start_time - time() < 30 * 60) { + + $notice->createTask($live); + + $redis->sRem($keyName, $liveId); + } + } + } + + /** + * @return ResultsetInterface|Resultset|ChapterLiveModel[] + */ + protected function findLives() + { + $today = strtotime(date('Ymd')); + + return ChapterLiveModel::query() + ->betweenWhere('start_time', $today, $today + 86400) + ->execute(); + } + + protected function getCacheKeyName() + { + return 'teacher_live_notice_task'; + } + +} \ No newline at end of file diff --git a/app/Http/Admin/Controllers/CourseController.php b/app/Http/Admin/Controllers/CourseController.php index 587e3e89..9b927b52 100644 --- a/app/Http/Admin/Controllers/CourseController.php +++ b/app/Http/Admin/Controllers/CourseController.php @@ -33,9 +33,13 @@ class CourseController extends Controller $xmCategories = $courseService->getXmCategories(0); $xmTeachers = $courseService->getXmTeachers(0); + $modelTypes = $courseService->getModelTypes(); + $levelTypes = $courseService->getLevelTypes(); $this->view->setVar('xm_categories', $xmCategories); $this->view->setVar('xm_teachers', $xmTeachers); + $this->view->setVar('model_types', $modelTypes); + $this->view->setVar('level_types', $levelTypes); } /** diff --git a/app/Http/Admin/Controllers/ImGroupController.php b/app/Http/Admin/Controllers/ImGroupController.php index 7be26303..e1f73991 100644 --- a/app/Http/Admin/Controllers/ImGroupController.php +++ b/app/Http/Admin/Controllers/ImGroupController.php @@ -11,7 +11,7 @@ class ImGroupController extends Controller { /** - * @Get("/list", name="admin.group.list") + * @Get("/list", name="admin.im_group.list") */ public function listAction() { @@ -25,15 +25,20 @@ class ImGroupController extends Controller } /** - * @Get("/search", name="admin.group.search") + * @Get("/search", name="admin.im_group.search") */ public function searchAction() { + $groupService = new ImGroupService(); + + $types = $groupService->getGroupTypes(); + $this->view->pick('im/group/search'); + $this->view->setVar('types', $types); } /** - * @Get("/add", name="admin.group.add") + * @Get("/add", name="admin.im_group.add") */ public function addAction() { @@ -41,7 +46,7 @@ class ImGroupController extends Controller } /** - * @Get("/{id:[0-9]+}/edit", name="admin.group.edit") + * @Get("/{id:[0-9]+}/edit", name="admin.im_group.edit") */ public function editAction($id) { @@ -55,7 +60,7 @@ class ImGroupController extends Controller } /** - * @Post("/create", name="admin.group.create") + * @Post("/create", name="admin.im_group.create") */ public function createAction() { @@ -64,7 +69,7 @@ class ImGroupController extends Controller $group = $groupService->createGroup(); $location = $this->url->get([ - 'for' => 'admin.group.edit', + 'for' => 'admin.im_group.edit', 'id' => $group->id, ]); @@ -77,7 +82,7 @@ class ImGroupController extends Controller } /** - * @Post("/{id:[0-9]+}/update", name="admin.group.update") + * @Post("/{id:[0-9]+}/update", name="admin.im_group.update") */ public function updateAction($id) { @@ -85,7 +90,7 @@ class ImGroupController extends Controller $groupService->updateGroup($id); - $location = $this->url->get(['for' => 'admin.group.list']); + $location = $this->url->get(['for' => 'admin.im_group.list']); $content = [ 'location' => $location, @@ -96,7 +101,7 @@ class ImGroupController extends Controller } /** - * @Post("/{id:[0-9]+}/delete", name="admin.group.delete") + * @Post("/{id:[0-9]+}/delete", name="admin.im_group.delete") */ public function deleteAction($id) { @@ -115,7 +120,7 @@ class ImGroupController extends Controller } /** - * @Post("/{id:[0-9]+}/restore", name="admin.group.restore") + * @Post("/{id:[0-9]+}/restore", name="admin.im_group.restore") */ public function restoreAction($id) { diff --git a/app/Http/Admin/Controllers/IndexController.php b/app/Http/Admin/Controllers/IndexController.php index 7b7b9da2..c5ff04b4 100644 --- a/app/Http/Admin/Controllers/IndexController.php +++ b/app/Http/Admin/Controllers/IndexController.php @@ -39,12 +39,23 @@ class IndexController extends Controller $todayStat = $indexService->getTodayStat(); $appInfo = $indexService->getAppInfo(); $serverInfo = $indexService->getServerInfo(); - $releases = $indexService->getReleases(); $this->view->setVar('global_stat', $globalStat); $this->view->setVar('today_stat', $todayStat); $this->view->setVar('app_info', $appInfo); $this->view->setVar('server_info', $serverInfo); + } + + /** + * @Get("/releases", name="admin.releases") + */ + public function releasesAction() + { + $indexService = new IndexService(); + + $releases = $indexService->getReleases(); + + $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW); $this->view->setVar('releases', $releases); } diff --git a/app/Http/Admin/Controllers/OrderController.php b/app/Http/Admin/Controllers/OrderController.php index 54597b42..c243e430 100644 --- a/app/Http/Admin/Controllers/OrderController.php +++ b/app/Http/Admin/Controllers/OrderController.php @@ -15,7 +15,13 @@ class OrderController extends Controller */ public function searchAction() { + $orderService = new OrderService(); + $itemTypes = $orderService->getItemTypes(); + $statusTypes = $orderService->getStatusTypes(); + + $this->view->setVar('item_types', $itemTypes); + $this->view->setVar('status_types', $statusTypes); } /** diff --git a/app/Http/Admin/Controllers/PointHistoryController.php b/app/Http/Admin/Controllers/PointHistoryController.php new file mode 100644 index 00000000..cce0f88c --- /dev/null +++ b/app/Http/Admin/Controllers/PointHistoryController.php @@ -0,0 +1,40 @@ +getEventTypes(); + + $this->view->pick('point/history/search'); + $this->view->setVar('event_types', $eventTypes); + } + + /** + * @Get("/list", name="admin.point_history.list") + */ + public function listAction() + { + $historyService = new PointHistoryService(); + + $pager = $historyService->getHistories(); + + $this->view->pick('point/history/list'); + + $this->view->setVar('pager', $pager); + } + +} \ No newline at end of file diff --git a/app/Http/Admin/Controllers/RefundController.php b/app/Http/Admin/Controllers/RefundController.php index 7271f416..3799e23e 100644 --- a/app/Http/Admin/Controllers/RefundController.php +++ b/app/Http/Admin/Controllers/RefundController.php @@ -15,7 +15,11 @@ class RefundController extends Controller */ public function searchAction() { + $refundService = new RefundService(); + $statusTypes = $refundService->getStatusTypes(); + + $this->view->setVar('status_types', $statusTypes); } /** diff --git a/app/Http/Admin/Controllers/SettingController.php b/app/Http/Admin/Controllers/SettingController.php index 76cff636..c7734972 100644 --- a/app/Http/Admin/Controllers/SettingController.php +++ b/app/Http/Admin/Controllers/SettingController.php @@ -378,4 +378,30 @@ class SettingController extends Controller } } + /** + * @Route("/dingtalk/robot", name="admin.setting.dingtalk_robot") + */ + public function dingtalkRobotAction() + { + $section = 'dingtalk.robot'; + + $settingService = new SettingService(); + + if ($this->request->isPost()) { + + $data = $this->request->getPost(); + + $settingService->updatePointSettings($section, $data); + + return $this->jsonSuccess(['msg' => '更新配置成功']); + + } else { + + $robot = $settingService->getSettings($section); + + $this->view->pick('setting/dingtalk_robot'); + $this->view->setVar('robot', $robot); + } + } + } diff --git a/app/Http/Admin/Controllers/StudentController.php b/app/Http/Admin/Controllers/StudentController.php index 9b2707fb..e72a01a3 100644 --- a/app/Http/Admin/Controllers/StudentController.php +++ b/app/Http/Admin/Controllers/StudentController.php @@ -15,7 +15,11 @@ class StudentController extends Controller */ public function searchAction() { + $studentService = new StudentService(); + $sourceTypes = $studentService->getSourceTypes(); + + $this->view->setVar('source_types', $sourceTypes); } /** diff --git a/app/Http/Admin/Controllers/TestController.php b/app/Http/Admin/Controllers/TestController.php index 4db114d2..d159935d 100644 --- a/app/Http/Admin/Controllers/TestController.php +++ b/app/Http/Admin/Controllers/TestController.php @@ -6,6 +6,7 @@ use App\Http\Admin\Services\AlipayTest as AlipayTestService; use App\Http\Admin\Services\Setting as SettingService; use App\Http\Admin\Services\WxpayTest as WxpayTestService; use App\Services\Captcha as CaptchaService; +use App\Services\DingTalkNotice as DingTalkNoticeService; use App\Services\Live as LiveService; use App\Services\Mail\Test as TestMailService; use App\Services\MyStorage as StorageService; @@ -250,4 +251,20 @@ class TestController extends Controller return $this->jsonSuccess(['status' => $status]); } + /** + * @Post("/dingtalk/robot", name="admin.test.dingtalk_robot") + */ + public function dingTalkRobotAction() + { + $noticeService = new DingTalkNoticeService(); + + $result = $noticeService->test(); + + if ($result) { + return $this->jsonSuccess(['msg' => '发送消息成功,请到钉钉确认']); + } else { + return $this->jsonError(['msg' => '发送消息失败,请检查配置']); + } + } + } \ No newline at end of file diff --git a/app/Http/Admin/Controllers/TopicController.php b/app/Http/Admin/Controllers/TopicController.php index 02d08f30..087580e7 100644 --- a/app/Http/Admin/Controllers/TopicController.php +++ b/app/Http/Admin/Controllers/TopicController.php @@ -22,6 +22,14 @@ class TopicController extends Controller $this->view->setVar('pager', $pager); } + /** + * @Get("/search", name="admin.topic.search") + */ + public function searchAction() + { + + } + /** * @Get("/add", name="admin.topic.add") */ diff --git a/app/Http/Admin/Controllers/TradeController.php b/app/Http/Admin/Controllers/TradeController.php index b4781320..2600351f 100644 --- a/app/Http/Admin/Controllers/TradeController.php +++ b/app/Http/Admin/Controllers/TradeController.php @@ -15,7 +15,13 @@ class TradeController extends Controller */ public function searchAction() { + $tradeService = new TradeService(); + $channelTypes = $tradeService->getChannelTypes(); + $statusTypes = $tradeService->getStatusTypes(); + + $this->view->setVar('channel_types', $channelTypes); + $this->view->setVar('status_types', $statusTypes); } /** diff --git a/app/Http/Admin/Controllers/UserController.php b/app/Http/Admin/Controllers/UserController.php index d1482164..5d106768 100644 --- a/app/Http/Admin/Controllers/UserController.php +++ b/app/Http/Admin/Controllers/UserController.php @@ -18,9 +18,11 @@ class UserController extends Controller { $userService = new UserService(); - $roles = $userService->getRoles(); + $eduRoleTypes = $userService->getEduRoleTypes(); + $adminRoles = $userService->getAdminRoles(); - $this->view->setVar('roles', $roles); + $this->view->setVar('edu_role_types', $eduRoleTypes); + $this->view->setVar('admin_roles', $adminRoles); } /** @@ -42,9 +44,9 @@ class UserController extends Controller { $userService = new UserService(); - $roles = $userService->getRoles(); + $adminRoles = $userService->getAdminRoles(); - $this->view->setVar('roles', $roles); + $this->view->setVar('admin_roles', $adminRoles); } /** @@ -81,7 +83,7 @@ class UserController extends Controller $user = $userService->getUser($id); $account = $userService->getAccount($id); - $roles = $userService->getRoles(); + $adminRoles = $userService->getAdminRoles(); if ($user->admin_role == RoleModel::ROLE_ROOT) { $this->response->redirect(['for' => 'admin.user.list']); @@ -89,7 +91,7 @@ class UserController extends Controller $this->view->setVar('user', $user); $this->view->setVar('account', $account); - $this->view->setVar('roles', $roles); + $this->view->setVar('admin_roles', $adminRoles); } /** diff --git a/app/Http/Admin/Services/AuthNode.php b/app/Http/Admin/Services/AuthNode.php index 20dedbb5..a0978c90 100644 --- a/app/Http/Admin/Services/AuthNode.php +++ b/app/Http/Admin/Services/AuthNode.php @@ -149,6 +149,12 @@ class AuthNode extends Service 'type' => 'menu', 'route' => 'admin.topic.list', ], + [ + 'id' => '1-4-5', + 'title' => '搜索话题', + 'type' => 'menu', + 'route' => 'admin.topic.search', + ], [ 'id' => '1-4-2', 'title' => '添加话题', @@ -349,31 +355,31 @@ class AuthNode extends Service 'id' => '2-4-1', 'title' => '群组列表', 'type' => 'menu', - 'route' => 'admin.group.list', + 'route' => 'admin.im_group.list', ], [ 'id' => '2-4-2', 'title' => '搜索群组', 'type' => 'menu', - 'route' => 'admin.group.search', + 'route' => 'admin.im_group.search', ], [ 'id' => '2-4-3', 'title' => '添加群组', 'type' => 'menu', - 'route' => 'admin.group.add', + 'route' => 'admin.im_group.add', ], [ 'id' => '2-4-4', 'title' => '编辑群组', 'type' => 'button', - 'route' => 'admin.group.edit', + 'route' => 'admin.im_group.edit', ], [ 'id' => '2-4-5', 'title' => '删除群组', 'type' => 'button', - 'route' => 'admin.group.delete', + 'route' => 'admin.im_group.delete', ], ], ], @@ -493,6 +499,12 @@ class AuthNode extends Service 'type' => 'menu', 'route' => 'admin.point_redeem.list', ], + [ + 'id' => '2-8-6', + 'title' => '积分记录', + 'type' => 'menu', + 'route' => 'admin.point_history.list', + ], [ 'id' => '2-8-3', 'title' => '添加礼品', @@ -800,6 +812,12 @@ class AuthNode extends Service 'type' => 'menu', 'route' => 'admin.setting.wechat_oa', ], + [ + 'id' => '5-1-15', + 'title' => '钉钉机器人', + 'type' => 'menu', + 'route' => 'admin.setting.dingtalk_robot', + ], [ 'id' => '5-1-14', 'title' => '积分设置', diff --git a/app/Http/Admin/Services/Course.php b/app/Http/Admin/Services/Course.php index 1767f553..1768f428 100644 --- a/app/Http/Admin/Services/Course.php +++ b/app/Http/Admin/Services/Course.php @@ -232,6 +232,16 @@ class Course extends Service return $course; } + public function getModelTypes() + { + return CourseModel::modelTypes(); + } + + public function getLevelTypes() + { + return CourseModel::levelTypes(); + } + public function getStudyExpiryOptions() { return CourseModel::studyExpiryOptions(); diff --git a/app/Http/Admin/Services/ImGroup.php b/app/Http/Admin/Services/ImGroup.php index a24cd560..9f4af997 100644 --- a/app/Http/Admin/Services/ImGroup.php +++ b/app/Http/Admin/Services/ImGroup.php @@ -14,6 +14,11 @@ use App\Validators\ImGroup as ImGroupValidator; class ImGroup extends Service { + public function getGroupTypes() + { + return ImGroupModel::types(); + } + public function getGroups() { $pagerQuery = new PagerQuery(); diff --git a/app/Http/Admin/Services/Index.php b/app/Http/Admin/Services/Index.php index 9febad0f..b67928c3 100644 --- a/app/Http/Admin/Services/Index.php +++ b/app/Http/Admin/Services/Index.php @@ -59,7 +59,7 @@ class Index extends Service $client = new Client(); - $response = $client->get($url, ['timeout' => 3]); + $response = $client->get($url); $content = json_decode($response->getBody(), true); diff --git a/app/Http/Admin/Services/Order.php b/app/Http/Admin/Services/Order.php index d43adf42..05ebb525 100644 --- a/app/Http/Admin/Services/Order.php +++ b/app/Http/Admin/Services/Order.php @@ -4,6 +4,7 @@ namespace App\Http\Admin\Services; use App\Builders\OrderList as OrderListBuilder; use App\Library\Paginator\Query as PaginateQuery; +use App\Models\Order as OrderModel; use App\Repos\Account as AccountRepo; use App\Repos\Order as OrderRepo; use App\Repos\User as UserRepo; @@ -12,6 +13,16 @@ use App\Validators\Order as OrderValidator; class Order extends Service { + public function getItemTypes() + { + return OrderModel::itemTypes(); + } + + public function getStatusTypes() + { + return OrderModel::statusTypes(); + } + public function getOrders() { $pageQuery = new PaginateQuery(); diff --git a/app/Http/Admin/Services/PointHistory.php b/app/Http/Admin/Services/PointHistory.php new file mode 100644 index 00000000..83b0bc99 --- /dev/null +++ b/app/Http/Admin/Services/PointHistory.php @@ -0,0 +1,32 @@ +getParams(); + + $sort = $pagerQuery->getSort(); + $page = $pagerQuery->getPage(); + $limit = $pagerQuery->getLimit(); + + $historyRepo = new PointHistoryRepo(); + + return $historyRepo->paginate($params, $sort, $page, $limit); + } + + public function getEventTypes() + { + return PointHistoryModel::eventTypes(); + } + +} \ No newline at end of file diff --git a/app/Http/Admin/Services/Refund.php b/app/Http/Admin/Services/Refund.php index 89efeb70..2617f4fa 100644 --- a/app/Http/Admin/Services/Refund.php +++ b/app/Http/Admin/Services/Refund.php @@ -16,6 +16,11 @@ use App\Validators\Refund as RefundValidator; class Refund extends Service { + public function getStatusTypes() + { + return RefundModel::statusTypes(); + } + public function getRefunds() { $pageQuery = new PaginateQuery(); diff --git a/app/Http/Admin/Services/Student.php b/app/Http/Admin/Services/Student.php index 9ecceade..2e8b9b4f 100644 --- a/app/Http/Admin/Services/Student.php +++ b/app/Http/Admin/Services/Student.php @@ -7,9 +7,11 @@ use App\Builders\LearningList as LearningListBuilder; use App\Library\Paginator\Query as PagerQuery; use App\Models\Course as CourseModel; use App\Models\CourseUser as CourseUserModel; +use App\Models\ImGroupUser as ImGroupUserModel; use App\Models\User as UserModel; use App\Repos\Course as CourseRepo; use App\Repos\CourseUser as CourseUserRepo; +use App\Repos\ImGroupUser as ImGroupUserRepo; use App\Repos\Learning as LearningRepo; use App\Repos\User as UserRepo; use App\Validators\CourseUser as CourseUserValidator; @@ -17,6 +19,11 @@ use App\Validators\CourseUser as CourseUserValidator; class Student extends Service { + public function getSourceTypes() + { + return CourseUserModel::sourceTypes(); + } + public function getCourse($id) { $repo = new CourseRepo(); @@ -100,9 +107,13 @@ class Student extends Service $courseUser->create($data); - $this->incrCourseUserCount($course); + $course->user_count += 1; + $course->update(); - $this->incrUserCourseCount($user); + $user->course_count += 1; + $user->update(); + + $this->handleImGroupUser($course, $user); return $courseUser; } @@ -126,18 +137,33 @@ class Student extends Service return $relation; } - protected function incrCourseUserCount(CourseModel $course) + protected function handleImGroupUser(CourseModel $course, UserModel $user) { - $course->user_count += 1; + $courseRepo = new CourseRepo(); - $course->update(); - } + $imGroup = $courseRepo->findImGroup($course->id); - protected function incrUserCourseCount(UserModel $user) - { - $user->course_count += 1; + $userRepo = new UserRepo(); - $user->update(); + $imUser = $userRepo->findImUser($user->id); + + $imGroupUserRepo = new ImGroupUserRepo(); + + $imGroupUser = $imGroupUserRepo->findGroupUser($imGroup->id, $user->id); + + if ($imGroupUser) return; + + $imGroupUser = new ImGroupUserModel(); + + $imGroupUser->group_id = $imGroup->id; + $imGroupUser->user_id = $imUser->id; + $imGroupUser->create(); + + $imUser->group_count += 1; + $imUser->update(); + + $imGroup->user_count += 1; + $imGroup->update(); } protected function findOrFail($id) diff --git a/app/Http/Admin/Services/Trade.php b/app/Http/Admin/Services/Trade.php index 7205ce6c..9b818a81 100644 --- a/app/Http/Admin/Services/Trade.php +++ b/app/Http/Admin/Services/Trade.php @@ -5,6 +5,7 @@ namespace App\Http\Admin\Services; use App\Builders\TradeList as TradeListBuilder; use App\Library\Paginator\Query as PaginateQuery; use App\Models\Refund as RefundModel; +use App\Models\Trade as TradeModel; use App\Repos\Account as AccountRepo; use App\Repos\Order as OrderRepo; use App\Repos\Trade as TradeRepo; @@ -14,6 +15,16 @@ use App\Validators\Trade as TradeValidator; class Trade extends Service { + public function getChannelTypes() + { + return TradeModel::channelTypes(); + } + + public function getStatusTypes() + { + return TradeModel::statusTypes(); + } + public function getTrades() { $pageQuery = new PaginateQuery(); diff --git a/app/Http/Admin/Services/User.php b/app/Http/Admin/Services/User.php index 91d2a06c..539fcb32 100644 --- a/app/Http/Admin/Services/User.php +++ b/app/Http/Admin/Services/User.php @@ -18,7 +18,12 @@ use App\Validators\User as UserValidator; class User extends Service { - public function getRoles() + public function getEduRoleTypes() + { + return UserModel::eduRoleTypes(); + } + + public function getAdminRoles() { $roleRepo = new RoleRepo(); diff --git a/app/Http/Admin/Views/audit/list.volt b/app/Http/Admin/Views/audit/list.volt index 6c43fbb5..b1b739d7 100644 --- a/app/Http/Admin/Views/audit/list.volt +++ b/app/Http/Admin/Views/audit/list.volt @@ -2,12 +2,19 @@ {% block content %} + {% set search_url = url({'for':'admin.audit.search'}) %} +
操作记录
+
+ + 搜索记录 + +
diff --git a/app/Http/Admin/Views/consult/list.volt b/app/Http/Admin/Views/consult/list.volt index 21a74f8d..65f0f5ee 100644 --- a/app/Http/Admin/Views/consult/list.volt +++ b/app/Http/Admin/Views/consult/list.volt @@ -4,10 +4,12 @@ {%- macro private_info(value) %} {% if value == 1 %} - + 私密 {% endif %} {%- endmacro %} + {% set search_url = url({'for':'admin.consult.search'}) %} +
@@ -18,6 +20,11 @@ 咨询管理
+
+ + 搜索咨询 + +
diff --git a/app/Http/Admin/Views/course/list.volt b/app/Http/Admin/Views/course/list.volt index ed9d18dc..9af90372 100644 --- a/app/Http/Admin/Views/course/list.volt +++ b/app/Http/Admin/Views/course/list.volt @@ -44,12 +44,23 @@ {% endif %} {%- endmacro %} + {% set add_url = url({'for':'admin.course.add'}) %} + {% set search_url = url({'for':'admin.course.search'}) %} +
课程管理
+
+ + 添加课程 + + + 搜索课程 + +
diff --git a/app/Http/Admin/Views/course/search.volt b/app/Http/Admin/Views/course/search.volt index 1076d9a4..23a444dc 100644 --- a/app/Http/Admin/Views/course/search.volt +++ b/app/Http/Admin/Views/course/search.volt @@ -33,18 +33,17 @@
- - - + {% for value,title in model_types %} + + {% endfor %}
- - - - + {% for value,title in level_types %} + + {% endfor %}
diff --git a/app/Http/Admin/Views/help/list.volt b/app/Http/Admin/Views/help/list.volt index f7926df5..6f942096 100644 --- a/app/Http/Admin/Views/help/list.volt +++ b/app/Http/Admin/Views/help/list.volt @@ -2,12 +2,19 @@ {% block content %} + {% set add_url = url({'for':'admin.help.add'}) %} +
+
diff --git a/app/Http/Admin/Views/im/group/add.volt b/app/Http/Admin/Views/im/group/add.volt index 28c8724b..1e55374f 100644 --- a/app/Http/Admin/Views/im/group/add.volt +++ b/app/Http/Admin/Views/im/group/add.volt @@ -2,7 +2,7 @@ {% block content %} - +
添加群组
diff --git a/app/Http/Admin/Views/im/group/edit.volt b/app/Http/Admin/Views/im/group/edit.volt index 1a3b7cb1..7cb6a8b3 100644 --- a/app/Http/Admin/Views/im/group/edit.volt +++ b/app/Http/Admin/Views/im/group/edit.volt @@ -2,7 +2,7 @@ {% block content %} - +
编辑群组
diff --git a/app/Http/Admin/Views/im/group/list.volt b/app/Http/Admin/Views/im/group/list.volt index 7934d5b4..89ecddfb 100644 --- a/app/Http/Admin/Views/im/group/list.volt +++ b/app/Http/Admin/Views/im/group/list.volt @@ -22,12 +22,23 @@ {% endif %} {%- endmacro %} + {% set add_url = url({'for':'admin.im_group.add'}) %} + {% set search_url = url({'for':'admin.im_group.search'}) %} +
群组管理
+
+ + 添加群组 + + + 搜索群组 + +
@@ -51,11 +62,11 @@ {% for item in pager.items %} - {% set preview_url = url({'for':'home.group.show','id':item.id}) %} - {% set edit_url = url({'for':'admin.group.edit','id':item.id}) %} - {% set update_url = url({'for':'admin.group.update','id':item.id}) %} - {% set delete_url = url({'for':'admin.group.delete','id':item.id}) %} - {% set restore_url = url({'for':'admin.group.restore','id':item.id}) %} + {% set preview_url = url({'for':'home.im_group.show','id':item.id}) %} + {% set edit_url = url({'for':'admin.im_group.edit','id':item.id}) %} + {% set update_url = url({'for':'admin.im_group.update','id':item.id}) %} + {% set delete_url = url({'for':'admin.im_group.delete','id':item.id}) %} + {% set restore_url = url({'for':'admin.im_group.restore','id':item.id}) %} diff --git a/app/Http/Admin/Views/im/group/search.volt b/app/Http/Admin/Views/im/group/search.volt index 9ce882e2..5fe743a6 100644 --- a/app/Http/Admin/Views/im/group/search.volt +++ b/app/Http/Admin/Views/im/group/search.volt @@ -2,7 +2,7 @@ {% block content %} - +
搜索群组
@@ -33,9 +33,9 @@
- - - + {% for value,title in types %} + + {% endfor %}
diff --git a/app/Http/Admin/Views/index/main.volt b/app/Http/Admin/Views/index/main.volt index fe01baff..147865b3 100644 --- a/app/Http/Admin/Views/index/main.volt +++ b/app/Http/Admin/Views/index/main.volt @@ -28,4 +28,22 @@ } +{% endblock %} + +{% block inline_js %} + + + {% endblock %} \ No newline at end of file diff --git a/app/Http/Admin/Views/index/main_app_trend.volt b/app/Http/Admin/Views/index/main_app_trend.volt index fd4d4684..ea660824 100644 --- a/app/Http/Admin/Views/index/main_app_trend.volt +++ b/app/Http/Admin/Views/index/main_app_trend.volt @@ -1,19 +1,6 @@
产品动态
-
{{ item.id }} {{ item.name }} {{ type_info(item.type) }}
- - - - - - {% for release in releases %} - - - - - {% endfor %} - -
{{ release.title }}{{ release.date }}
+
\ No newline at end of file diff --git a/app/Http/Admin/Views/index/releases.volt b/app/Http/Admin/Views/index/releases.volt new file mode 100644 index 00000000..f8e23b6f --- /dev/null +++ b/app/Http/Admin/Views/index/releases.volt @@ -0,0 +1,14 @@ + + + + + + + {% for release in releases %} + + + + + {% endfor %} + +
{{ release.title }}{{ release.date }}
\ No newline at end of file diff --git a/app/Http/Admin/Views/macros/point.volt b/app/Http/Admin/Views/macros/point.volt index 8b2d6093..06aced06 100644 --- a/app/Http/Admin/Views/macros/point.volt +++ b/app/Http/Admin/Views/macros/point.volt @@ -18,6 +18,14 @@ {% endif %} {%- endmacro %} +{%- macro event_point_info(value) %} + {% if value > 0 %} + +{{ value }} + {% else %} + {{ value }} + {% endif %} +{%- endmacro %} + {%- macro event_type_info(value) %} {% if value == 1 %} 订单消费 @@ -38,7 +46,7 @@ {% endif %} {%- endmacro %} -{%- macro event_detail_info(history) %} +{%- macro event_item_info(history) %} {% set event_info = history.event_info %} {% if history.event_type == 1 %}

{{ event_info.order.subject }}

diff --git a/app/Http/Admin/Views/order/list.volt b/app/Http/Admin/Views/order/list.volt index 8b6a39b3..4ec3802f 100644 --- a/app/Http/Admin/Views/order/list.volt +++ b/app/Http/Admin/Views/order/list.volt @@ -4,12 +4,19 @@ {{ partial('order/macro') }} + {% set search_url = url({'for':'admin.order.search'}) %} +
订单管理
+
+ + 搜索订单 + +
diff --git a/app/Http/Admin/Views/order/search.volt b/app/Http/Admin/Views/order/search.volt index 627fbc31..1f266a06 100644 --- a/app/Http/Admin/Views/order/search.volt +++ b/app/Http/Admin/Views/order/search.volt @@ -21,21 +21,17 @@
- - - - - + {% for value,title in item_types %} + + {% endfor %}
- - - - - + {% for value,title in status_types %} + + {% endfor %}
diff --git a/app/Http/Admin/Views/package/list.volt b/app/Http/Admin/Views/package/list.volt index e23a17d8..1c94d2f6 100644 --- a/app/Http/Admin/Views/package/list.volt +++ b/app/Http/Admin/Views/package/list.volt @@ -2,12 +2,23 @@ {% block content %} + {% set add_url = url({'for':'admin.package.add'}) %} + {% set search_url = url({'for':'admin.package.search'}) %} +
+
diff --git a/app/Http/Admin/Views/page/list.volt b/app/Http/Admin/Views/page/list.volt index 5e7a5062..607f17f2 100644 --- a/app/Http/Admin/Views/page/list.volt +++ b/app/Http/Admin/Views/page/list.volt @@ -2,12 +2,19 @@ {% block content %} + {% set add_url = url({'for':'admin.page.add'}) %} +
单页管理
+
+ + 添加单页 + +
diff --git a/app/Http/Admin/Views/point/history/list.volt b/app/Http/Admin/Views/point/history/list.volt new file mode 100644 index 00000000..145ecffa --- /dev/null +++ b/app/Http/Admin/Views/point/history/list.volt @@ -0,0 +1,55 @@ +{% extends 'templates/main.volt' %} + +{% block content %} + + {{ partial('macros/point') }} + + {% set search_url = url({'for':'admin.point_history.search'}) %} + +
+
+ + 积分记录 + +
+
+ + 搜索积分 + +
+
+ +
+ + + + + + + + + + + + + + + + + + {% for item in pager.items %} + {% set user_filter_url = url({'for':'admin.point_history.list'},{'user_id':item.user_id}) %} + + + + + + + + {% endfor %} + +
用户积分来源详情时间
{{ item.user_name }}({{ item.user_id }}){{ event_point_info(item.event_point) }}{{ event_type_info(item.event_type) }}{{ event_item_info(item) }}{{ date('Y-m-d H:i:s',item.create_time) }}
+ + {{ partial('partials/pager') }} + +{% endblock %} \ No newline at end of file diff --git a/app/Http/Admin/Views/point/history/search.volt b/app/Http/Admin/Views/point/history/search.volt new file mode 100644 index 00000000..4717481b --- /dev/null +++ b/app/Http/Admin/Views/point/history/search.volt @@ -0,0 +1,38 @@ +{% extends 'templates/main.volt' %} + +{% block content %} + + +
+ 搜索积分 +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ {% for value,title in event_types %} + + {% endfor %} +
+
+
+ +
+ + +
+
+ + +{% endblock %} \ No newline at end of file diff --git a/app/Http/Admin/Views/point/redeem/list.volt b/app/Http/Admin/Views/point/redeem/list.volt index c86b4b1b..30e7633b 100644 --- a/app/Http/Admin/Views/point/redeem/list.volt +++ b/app/Http/Admin/Views/point/redeem/list.volt @@ -43,9 +43,10 @@ {% set gift_url = url({'for':'home.point_gift.show','id':item.gift_id}) %} -

{{ item.gift_name }}({{ item.gift_id }}){{ gift_type_info(item.gift_type) }}

-

用户名称:{{ item.user_name }} ({{ item.user_id }}) 联系方式: - +

{{ item.gift_name }}({{ item.gift_id }}){{ gift_type_info(item.gift_type) }}

+

+ 用户名称:{{ item.user_name }}({{ item.user_id }}) + 联系方式:查看

{{ item.gift_point }} @@ -67,6 +68,12 @@ {% endblock %} +{% block include_js %} + + {{ js_include('admin/js/contact.js') }} + +{% endblock %} + {% block inline_js %} -{% endblock %} - -{% block include_js %} - - {{ js_include('admin/js/contact.js') }} - {% endblock %} \ No newline at end of file diff --git a/app/Http/Admin/Views/refund/list.volt b/app/Http/Admin/Views/refund/list.volt index 972409cd..ced2cf7e 100644 --- a/app/Http/Admin/Views/refund/list.volt +++ b/app/Http/Admin/Views/refund/list.volt @@ -4,12 +4,19 @@ {{ partial('refund/macro') }} + {% set search_url = url({'for':'admin.refund.search'}) %} +
退款管理
+
+ + 搜索退款 + +
diff --git a/app/Http/Admin/Views/refund/search.volt b/app/Http/Admin/Views/refund/search.volt index 0db3df64..eab5c260 100644 --- a/app/Http/Admin/Views/refund/search.volt +++ b/app/Http/Admin/Views/refund/search.volt @@ -21,12 +21,9 @@
- - - - - - + {% for value,title in status_types %} + + {% endfor %}
diff --git a/app/Http/Admin/Views/review/list.volt b/app/Http/Admin/Views/review/list.volt index 3e61817e..5ae6b73d 100644 --- a/app/Http/Admin/Views/review/list.volt +++ b/app/Http/Admin/Views/review/list.volt @@ -2,6 +2,8 @@ {% block content %} + {% set search_url = url({'for':'admin.consult.search'}) %} +
@@ -12,6 +14,11 @@ 评价管理
+
diff --git a/app/Http/Admin/Views/role/list.volt b/app/Http/Admin/Views/role/list.volt index ab2dceab..61a32597 100644 --- a/app/Http/Admin/Views/role/list.volt +++ b/app/Http/Admin/Views/role/list.volt @@ -10,12 +10,19 @@ {% endif %} {%- endmacro %} + {% set add_url = url({'for':'admin.role.add'}) %} +
角色管理
+
+ + 添加角色 + +
@@ -43,7 +50,11 @@ {% set restore_url = url({'for':'admin.role.restore','id':item.id}) %} - + {% if item.id == 1 %} + + {% else %} + + {% endif %}
{{ item.id }}{{ item.name }}{{ item.name }}{{ item.name }}{{ type_info(item.type) }} @@ -54,11 +65,16 @@
diff --git a/app/Http/Admin/Views/setting/captcha.volt b/app/Http/Admin/Views/setting/captcha.volt index 888c7937..1119fc25 100644 --- a/app/Http/Admin/Views/setting/captcha.volt +++ b/app/Http/Admin/Views/setting/captcha.volt @@ -9,13 +9,13 @@
- +
- +
diff --git a/app/Http/Admin/Views/setting/dingtalk_robot.volt b/app/Http/Admin/Views/setting/dingtalk_robot.volt new file mode 100644 index 00000000..76bb4ab9 --- /dev/null +++ b/app/Http/Admin/Views/setting/dingtalk_robot.volt @@ -0,0 +1,62 @@ +{% extends 'templates/main.volt' %} + +{% block content %} + +
+
+ 钉钉机器人 +
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+
+ 通知测试 +
+
+ +
+ + +
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/app/Http/Admin/Views/setting/im_cs.volt b/app/Http/Admin/Views/setting/im_cs.volt index 156633c5..cf4a7eaa 100644 --- a/app/Http/Admin/Views/setting/im_cs.volt +++ b/app/Http/Admin/Views/setting/im_cs.volt @@ -9,7 +9,7 @@
- +
diff --git a/app/Http/Admin/Views/setting/live_notify.volt b/app/Http/Admin/Views/setting/live_notify.volt index bb973c3f..69f66d76 100644 --- a/app/Http/Admin/Views/setting/live_notify.volt +++ b/app/Http/Admin/Views/setting/live_notify.volt @@ -8,31 +8,31 @@
- +
- +
- +
- +
- +
diff --git a/app/Http/Admin/Views/setting/live_pull.volt b/app/Http/Admin/Views/setting/live_pull.volt index d8cc833c..75637516 100644 --- a/app/Http/Admin/Views/setting/live_pull.volt +++ b/app/Http/Admin/Views/setting/live_pull.volt @@ -15,7 +15,7 @@
- +
diff --git a/app/Http/Admin/Views/setting/live_push.volt b/app/Http/Admin/Views/setting/live_push.volt index 6550b759..ed4cf1a3 100644 --- a/app/Http/Admin/Views/setting/live_push.volt +++ b/app/Http/Admin/Views/setting/live_push.volt @@ -7,7 +7,7 @@
- +
diff --git a/app/Http/Admin/Views/setting/secret.volt b/app/Http/Admin/Views/setting/secret.volt index 0e42d8da..8b09d864 100644 --- a/app/Http/Admin/Views/setting/secret.volt +++ b/app/Http/Admin/Views/setting/secret.volt @@ -9,19 +9,19 @@
- +
- +
- +
diff --git a/app/Http/Admin/Views/setting/sms.volt b/app/Http/Admin/Views/setting/sms.volt index 05a2acda..b0f337a8 100644 --- a/app/Http/Admin/Views/setting/sms.volt +++ b/app/Http/Admin/Views/setting/sms.volt @@ -11,19 +11,19 @@
- +
- +
- +
diff --git a/app/Http/Admin/Views/setting/storage.volt b/app/Http/Admin/Views/setting/storage.volt index 9b1d2d6e..f6874821 100644 --- a/app/Http/Admin/Views/setting/storage.volt +++ b/app/Http/Admin/Views/setting/storage.volt @@ -9,13 +9,13 @@
- +
- +
diff --git a/app/Http/Admin/Views/slide/list.volt b/app/Http/Admin/Views/slide/list.volt index 919d8c0c..d40d6a45 100644 --- a/app/Http/Admin/Views/slide/list.volt +++ b/app/Http/Admin/Views/slide/list.volt @@ -12,12 +12,19 @@ {% endif %} {%- endmacro %} + {% set add_url = url({'for':'admin.slide.add'}) %} + diff --git a/app/Http/Admin/Views/student/list.volt b/app/Http/Admin/Views/student/list.volt index 16d92f20..c8554604 100644 --- a/app/Http/Admin/Views/student/list.volt +++ b/app/Http/Admin/Views/student/list.volt @@ -8,9 +8,9 @@ {% elseif value == 2 %} 付费 {% elseif value == 3 %} - 导入 + 畅学 {% elseif value == 4 %} - 会员 + 导入 {% elseif value == 5 %} 积分 {% elseif value == 6 %} @@ -18,6 +18,9 @@ {% endif %} {%- endmacro %} + {% set add_url = url({'for':'admin.student.add'}) %} + {% set search_url = url({'for':'admin.student.search'}) %} +
@@ -42,7 +53,7 @@ - + @@ -55,8 +66,8 @@ {% set edit_url = url({'for':'admin.student.edit'},{'relation_id':item.id}) %}
基本信息 学习情况成员来源来源类型 有效期限 操作
-

课程:{{ item.course.title }}({{ item.course.id }})

-

学员:{{ item.user.name }}({{ item.user.id }})

+

课程:{{ item.course.title }}({{ item.course.id }})

+

学员:{{ item.user.name }}({{ item.user.id }})

进度:{{ item.progress }}%

diff --git a/app/Http/Admin/Views/student/search.volt b/app/Http/Admin/Views/student/search.volt index 673da0d3..55fdb461 100644 --- a/app/Http/Admin/Views/student/search.volt +++ b/app/Http/Admin/Views/student/search.volt @@ -23,10 +23,9 @@
- - - - + {% for value,title in source_types %} + + {% endfor %}
diff --git a/app/Http/Admin/Views/topic/list.volt b/app/Http/Admin/Views/topic/list.volt index 295d1484..10290a79 100644 --- a/app/Http/Admin/Views/topic/list.volt +++ b/app/Http/Admin/Views/topic/list.volt @@ -2,12 +2,23 @@ {% block content %} + {% set add_url = url({'for':'admin.topic.add'}) %} + {% set search_url = url({'for':'admin.topic.search'}) %} + diff --git a/app/Http/Admin/Views/topic/search.volt b/app/Http/Admin/Views/topic/search.volt new file mode 100644 index 00000000..7a4c97c5 --- /dev/null +++ b/app/Http/Admin/Views/topic/search.volt @@ -0,0 +1,44 @@ +{% extends 'templates/main.volt' %} + +{% block content %} + + +
+ 搜索话题 +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+ + +{% endblock %} \ No newline at end of file diff --git a/app/Http/Admin/Views/trade/list.volt b/app/Http/Admin/Views/trade/list.volt index 92832022..a8177d81 100644 --- a/app/Http/Admin/Views/trade/list.volt +++ b/app/Http/Admin/Views/trade/list.volt @@ -4,12 +4,19 @@ {{ partial('trade/macro') }} + {% set search_url = url({'for':'admin.trade.search'}) %} +
diff --git a/app/Http/Admin/Views/trade/search.volt b/app/Http/Admin/Views/trade/search.volt index 8f8c9a1b..d8bc32f2 100644 --- a/app/Http/Admin/Views/trade/search.volt +++ b/app/Http/Admin/Views/trade/search.volt @@ -21,17 +21,17 @@
- - + {% for value,title in channel_types %} + + {% endfor %}
- - - - + {% for value,title in status_types %} + + {% endfor %}
diff --git a/app/Http/Admin/Views/user/add.volt b/app/Http/Admin/Views/user/add.volt index ab83b88c..c88e85bf 100644 --- a/app/Http/Admin/Views/user/add.volt +++ b/app/Http/Admin/Views/user/add.volt @@ -30,7 +30,7 @@
- {% for role in roles %} + {% for role in admin_roles %} {% if role.id > 1 %} {% endif %} diff --git a/app/Http/Admin/Views/user/edit.volt b/app/Http/Admin/Views/user/edit.volt index 1cd4a31f..5cd94fe7 100644 --- a/app/Http/Admin/Views/user/edit.volt +++ b/app/Http/Admin/Views/user/edit.volt @@ -38,7 +38,7 @@
- {% for role in roles %} + {% for role in admin_roles %} {% if role.id > 1 %} {% endif %} diff --git a/app/Http/Admin/Views/user/list.volt b/app/Http/Admin/Views/user/list.volt index 19eac204..8d164110 100644 --- a/app/Http/Admin/Views/user/list.volt +++ b/app/Http/Admin/Views/user/list.volt @@ -35,12 +35,23 @@ {% endif %} {%- endmacro %} + {% set add_url = url({'for':'admin.user.add'}) %} + {% set search_url = url({'for':'admin.user.search'}) %} +
diff --git a/app/Http/Admin/Views/user/search.volt b/app/Http/Admin/Views/user/search.volt index 3327191a..323adbf6 100644 --- a/app/Http/Admin/Views/user/search.volt +++ b/app/Http/Admin/Views/user/search.volt @@ -21,14 +21,15 @@
- - + {% for value,title in edu_role_types %} + + {% endfor %}
- {% for item in roles %} + {% for item in admin_roles %} {% endfor %}
diff --git a/app/Http/Home/Controllers/ImController.php b/app/Http/Home/Controllers/ImController.php index 7461363e..133ba5fa 100644 --- a/app/Http/Home/Controllers/ImController.php +++ b/app/Http/Home/Controllers/ImController.php @@ -205,14 +205,14 @@ class ImController extends Controller /** * @Post("/msg/cs/send", name="home.im.send_cs_msg") */ - public function sendCsMessageAction() + public function sendCustomMessageAction() { $from = $this->request->getPost('from', 'string'); $to = $this->request->getPost('to', 'string'); $service = new ImService(); - $service->sendCsMessage($from, $to); + $service->sendCustomMessage($from, $to); return $this->jsonSuccess(); } diff --git a/app/Http/Home/Controllers/ImGroupController.php b/app/Http/Home/Controllers/ImGroupController.php index bde92ad8..cae102d2 100644 --- a/app/Http/Home/Controllers/ImGroupController.php +++ b/app/Http/Home/Controllers/ImGroupController.php @@ -12,7 +12,7 @@ class ImGroupController extends Controller { /** - * @Get("/list", name="home.group.list") + * @Get("/list", name="home.im_group.list") */ public function listAction() { @@ -22,7 +22,7 @@ class ImGroupController extends Controller } /** - * @Get("/pager", name="home.group.pager") + * @Get("/pager", name="home.im_group.pager") */ public function pagerAction() { @@ -38,7 +38,7 @@ class ImGroupController extends Controller } /** - * @Get("/{id:[0-9]+}", name="home.group.show") + * @Get("/{id:[0-9]+}", name="home.im_group.show") */ public function showAction($id) { @@ -53,7 +53,7 @@ class ImGroupController extends Controller } /** - * @Get("/{id:[0-9]+}/users", name="home.group.users") + * @Get("/{id:[0-9]+}/users", name="home.im_group.users") */ public function usersAction($id) { @@ -69,7 +69,7 @@ class ImGroupController extends Controller } /** - * @Get("/{id:[0-9]+}/users/active", name="home.group.active_users") + * @Get("/{id:[0-9]+}/users/active", name="home.im_group.active_users") */ public function activeUsersAction($id) { diff --git a/app/Http/Home/Controllers/PointRedeemController.php b/app/Http/Home/Controllers/PointRedeemController.php index 37b99430..1292a3b6 100644 --- a/app/Http/Home/Controllers/PointRedeemController.php +++ b/app/Http/Home/Controllers/PointRedeemController.php @@ -19,7 +19,7 @@ class PointRedeemController extends Controller $service->handle(); - return $this->jsonSuccess(['msg' => '兑换成功']); + return $this->jsonSuccess(['msg' => '兑换请求提交成功']); } } diff --git a/app/Http/Home/Controllers/UserConsoleController.php b/app/Http/Home/Controllers/UserConsoleController.php index 16f22f8f..de6a035f 100644 --- a/app/Http/Home/Controllers/UserConsoleController.php +++ b/app/Http/Home/Controllers/UserConsoleController.php @@ -44,10 +44,6 @@ class UserConsoleController extends Controller public function initialize() { parent::initialize(); - - $wechatOA = $this->getSettings('wechat.oa'); - - $this->view->setVar('wechat_oa', $wechatOA); } /** diff --git a/app/Http/Home/Services/ImFriendTrait.php b/app/Http/Home/Services/ImFriendTrait.php index 5731397b..4dd492fb 100644 --- a/app/Http/Home/Services/ImFriendTrait.php +++ b/app/Http/Home/Services/ImFriendTrait.php @@ -58,7 +58,7 @@ Trait ImFriendTrait $validator = new ImFriendUserValidator(); - $validator->checkGroup($groupId); + $group = $validator->checkGroup($groupId); $validator = new ImNoticeValidator(); @@ -81,7 +81,7 @@ Trait ImFriendTrait $friendUserModel->create([ 'user_id' => $user->id, 'friend_id' => $sender->id, - 'group_id' => $groupId, + 'group_id' => $group->id, ]); $this->incrUserFriendCount($user); @@ -147,7 +147,9 @@ Trait ImFriendTrait public function quitFriend($id) { - $user = $this->getLoginUser(); + $loginUser = $this->getLoginUser(); + + $user = $this->getImUser($loginUser->id); $validator = new ImFriendUserValidator(); @@ -156,6 +158,8 @@ Trait ImFriendTrait $friendUser = $validator->checkFriendUser($user->id, $friend->id); $friendUser->delete(); + + $this->decrUserFriendCount($user); } protected function handleApplyFriendNotice(ImUserModel $sender, ImUserModel $receiver, ImFriendGroupModel $group, $remark) diff --git a/app/Http/Home/Services/ImMessageTrait.php b/app/Http/Home/Services/ImMessageTrait.php index 5a4842bb..07b33bd7 100644 --- a/app/Http/Home/Services/ImMessageTrait.php +++ b/app/Http/Home/Services/ImMessageTrait.php @@ -11,6 +11,7 @@ use App\Models\ImMessage as ImMessageModel; use App\Repos\ImFriendUser as ImFriendUserRepo; use App\Repos\ImMessage as ImMessageRepo; use App\Repos\ImUser as ImUserRepo; +use App\Services\DingTalk\Notice\CustomService as CustomServiceNotice; use App\Validators\ImFriendUser as ImFriendUserValidator; use App\Validators\ImGroup as ImGroupValidator; use App\Validators\ImGroupUser as ImGroupUserValidator; @@ -22,7 +23,7 @@ use GatewayClient\Gateway; * layim中普通聊天和自定义聊天中接收方用户名使用的字段不一样,也够坑爹的 * 普通聊天username,自定义聊天name */ -Trait ImMessageTrait +trait ImMessageTrait { public function getChatMessages() @@ -166,9 +167,11 @@ Trait ImMessageTrait } $this->eventsManager->fire('ImMessage:afterCreate', $this, $imMessage); + + return $imMessage; } - public function sendCsMessage($from, $to) + public function sendCustomMessage($from, $to) { $validator = new ImMessageValidator(); @@ -214,7 +217,11 @@ Trait ImMessageTrait unset($to['name']); - $this->sendChatMessage($from, $to); + $message = $this->sendChatMessage($from, $to); + + $this->handleCustomServiceNotice($message); + + return $message; } public function pullUnreadFriendMessages($id) @@ -334,4 +341,11 @@ Trait ImMessageTrait $group->update(); } + protected function handleCustomServiceNotice(ImMessageModel $message) + { + $notice = new CustomServiceNotice(); + + $notice->createTask($message); + } + } \ No newline at end of file diff --git a/app/Http/Home/Views/course/show_catalog.volt b/app/Http/Home/Views/course/show_catalog.volt index 445f8feb..b53dc928 100644 --- a/app/Http/Home/Views/course/show_catalog.volt +++ b/app/Http/Home/Views/course/show_catalog.volt @@ -55,23 +55,25 @@ {% endif %} {%- endmacro %} -
- {% for chapter in chapters %} -
-

{{ chapter.title }}

-
-
    - {% for lesson in chapter.children %} - {% if lesson.model == 1 %} -
  • {{ vod_lesson_info(lesson) }}
  • - {% elseif lesson.model == 2 %} -
  • {{ live_lesson_info(lesson) }}
  • - {% elseif lesson.model == 3 %} -
  • {{ read_lesson_info(lesson) }}
  • - {% endif %} - {% endfor %} -
+{% if chapters %} +
+ {% for chapter in chapters %} +
+

{{ chapter.title }}

+
+
    + {% for lesson in chapter.children %} + {% if lesson.model == 1 %} +
  • {{ vod_lesson_info(lesson) }}
  • + {% elseif lesson.model == 2 %} +
  • {{ live_lesson_info(lesson) }}
  • + {% elseif lesson.model == 3 %} +
  • {{ read_lesson_info(lesson) }}
  • + {% endif %} + {% endfor %} +
+
-
- {% endfor %} -
\ No newline at end of file + {% endfor %} +
+{% endif %} \ No newline at end of file diff --git a/app/Http/Home/Views/course/show_meta.volt b/app/Http/Home/Views/course/show_meta.volt index 6355000c..c668df67 100644 --- a/app/Http/Home/Views/course/show_meta.volt +++ b/app/Http/Home/Views/course/show_meta.volt @@ -34,7 +34,9 @@ {%- macro meta_price_info(course) %}

- 原始价格{{ '¥%0.2f'|format(course.origin_price) }} + {% if course.origin_price > 0 %} + 原始价格{{ '¥%0.2f'|format(course.origin_price) }} + {% endif %} {% if course.market_price > 0 %} 优惠价格{{ '¥%0.2f'|format(course.market_price) }} {% else %} diff --git a/app/Http/Home/Views/im/group/active_users.volt b/app/Http/Home/Views/im/group/active_users.volt index 565d0eea..bb215a52 100644 --- a/app/Http/Home/Views/im/group/active_users.volt +++ b/app/Http/Home/Views/im/group/active_users.volt @@ -5,7 +5,7 @@ {% for user in users %} {% set user_url = url({'for':'home.user.show','id':user.id}) %} {% set user.title = user.title ? user.title : '暂露头角' %} -

标题:{{ item.course.title }} {{ model_info(item.course.model) }}

-

期限:{{ date('Y-m-d',item.expiry_time) }}

+

来源:{{ source_type_info(item.source_type) }}  期限:{{ date('Y-m-d',item.expiry_time) }}

用时:{{ item.duration|duration }}

diff --git a/app/Http/Home/Views/user/console/friends.volt b/app/Http/Home/Views/user/console/friends.volt index 8dcd4f61..b1cc764a 100644 --- a/app/Http/Home/Views/user/console/friends.volt +++ b/app/Http/Home/Views/user/console/friends.volt @@ -12,7 +12,7 @@ 我的好友 {% if pager.total_pages > 0 %} - +
diff --git a/app/Http/Home/Views/user/console/groups_joined.volt b/app/Http/Home/Views/user/console/groups_joined.volt index 677041c4..624da3e9 100644 --- a/app/Http/Home/Views/user/console/groups_joined.volt +++ b/app/Http/Home/Views/user/console/groups_joined.volt @@ -16,7 +16,7 @@ {% for item in pager.items %} - {% set show_url = url({'for':'home.group.show','id':item.id}) %} + {% set show_url = url({'for':'home.im_group.show','id':item.id}) %} {% set owner_url = url({'for':'home.user.show','id':item.owner.id}) %} {% set delete_url = url({'for':'home.im.quit_group','id':item.id}) %} diff --git a/app/Http/Home/Views/user/console/menu.volt b/app/Http/Home/Views/user/console/menu.volt index 619692fe..97b6aca5 100644 --- a/app/Http/Home/Views/user/console/menu.volt +++ b/app/Http/Home/Views/user/console/menu.volt @@ -7,6 +7,9 @@ {% endif %} {%- endmacro %} +{% set wechat_oa_enabled = setting('wechat.oa','enabled') %} +{% set point_enabled = setting('point','enabled') %} +
{{ auth_user.name }} @@ -36,16 +39,18 @@
-
-
积分中心
-
- +{% if point_enabled == 1 %} +
+
积分中心
+
-
+{% endif %}
聊天设置
@@ -64,7 +69,7 @@
  • 个人信息
  • 收货地址
  • 帐号安全
  • - {% if wechat_oa.enabled == 1 %} + {% if wechat_oa_enabled == 1 %}
  • 关注订阅
  • {% endif %} diff --git a/app/Http/Home/Views/user/console/point_history.volt b/app/Http/Home/Views/user/console/point_history.volt index b84a8649..b5a3a58e 100644 --- a/app/Http/Home/Views/user/console/point_history.volt +++ b/app/Http/Home/Views/user/console/point_history.volt @@ -33,7 +33,7 @@
    - + {% endfor %} diff --git a/app/Http/Home/Views/user/console/point_redeems.volt b/app/Http/Home/Views/user/console/point_redeems.volt index bb7c3a41..6ee218c0 100644 --- a/app/Http/Home/Views/user/console/point_redeems.volt +++ b/app/Http/Home/Views/user/console/point_redeems.volt @@ -34,7 +34,7 @@ - + {% endfor %} diff --git a/app/Http/Home/Views/user/groups.volt b/app/Http/Home/Views/user/groups.volt index ac88f2bd..cc918c4d 100644 --- a/app/Http/Home/Views/user/groups.volt +++ b/app/Http/Home/Views/user/groups.volt @@ -4,7 +4,7 @@
    {% for item in pager.items %} - {% set group_url = url({'for':'home.group.show','id':item.id}) %} + {% set group_url = url({'for':'home.im_group.show','id':item.id}) %} {% set item.about = item.about ? item.about : '这家伙真懒,什么都没留下!' %}
    diff --git a/app/Library/AppInfo.php b/app/Library/AppInfo.php index cfce4822..b5df7269 100644 --- a/app/Library/AppInfo.php +++ b/app/Library/AppInfo.php @@ -11,7 +11,7 @@ class AppInfo protected $link = 'https://koogua.com'; - protected $version = '1.2.6'; + protected $version = '1.2.7'; public function __get($name) { diff --git a/app/Library/Benchmark.php b/app/Library/Benchmark.php new file mode 100644 index 00000000..e6943787 --- /dev/null +++ b/app/Library/Benchmark.php @@ -0,0 +1,27 @@ +startTime = microtime(true); + } + + public function stop() + { + $this->endTime = microtime(true); + } + + public function getElapsedTime() + { + return $this->endTime - $this->startTime; + } + +} \ No newline at end of file diff --git a/app/Library/Helper.php b/app/Library/Helper.php index af1d528a..47363e5c 100644 --- a/app/Library/Helper.php +++ b/app/Library/Helper.php @@ -35,6 +35,24 @@ function kg_substr($str, $start, $length, $suffix = '...') return $str == $result ? $str : $result . $suffix; } +/** + * 占位替换 + * + * @param string $str + * @param array $data + * @return string + */ +function kg_ph_replace($str, $data = []) +{ + if (empty($data)) return $str; + + foreach ($data as $key => $value) { + $str = str_replace('{' . $key . '}', $value, $str); + } + + return $str; +} + /** * uniqid封装 * diff --git a/app/Library/Utils/ServerInfo.php b/app/Library/Utils/ServerInfo.php index 9d89fb94..7fb0b1ed 100644 --- a/app/Library/Utils/ServerInfo.php +++ b/app/Library/Utils/ServerInfo.php @@ -26,16 +26,14 @@ class ServerInfo $total = 0; - if (preg_match('/MemTotal\:\s+(\d+) kB/', $mem, $matches)) { - $total = $matches[1]; + if (preg_match('/MemTotal\:\s+(\d+) kB/', $mem, $totalMatches)) { + $total = $totalMatches[1]; } - unset($matches); - $free = 0; - if (preg_match('/MemFree\:\s+(\d+) kB/', $mem, $matches)) { - $free = $matches[1]; + if (preg_match('/MemFree\:\s+(\d+) kB/', $mem, $freeMatches)) { + $free = $freeMatches[1]; } $usage = $total - $free; diff --git a/app/Models/CourseRating.php b/app/Models/CourseRating.php index a124f798..7e9e9118 100644 --- a/app/Models/CourseRating.php +++ b/app/Models/CourseRating.php @@ -17,28 +17,28 @@ class CourseRating extends Model * * @var float */ - public $rating = 0.00; + public $rating = 5.00; /** * 维度1评分 * * @var float */ - public $rating1 = 0.00; + public $rating1 = 5.00; /** * 维度2评分 * * @var float */ - public $rating2 = 0.00; + public $rating2 = 5.00; /** * 维度3评分 * * @var float */ - public $rating3 = 0.00; + public $rating3 = 5.00; /** * 创建时间 diff --git a/app/Models/CourseUser.php b/app/Models/CourseUser.php index f31c2995..f652fa9d 100644 --- a/app/Models/CourseUser.php +++ b/app/Models/CourseUser.php @@ -18,7 +18,7 @@ class CourseUser extends Model */ const SOURCE_FREE = 1; // 免费 const SOURCE_CHARGE = 2; // 付费 - const SOURCE_VIP = 3; // 会员 + const SOURCE_VIP = 3; // 会员(畅学) const SOURCE_IMPORT = 4; // 导入 const SOURCE_POINT_REDEEM = 5; // 积分兑换 const SOURCE_LUCKY_REDEEM = 6; // 抽奖兑换 diff --git a/app/Models/Task.php b/app/Models/Task.php index 77839de6..eb63af53 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -13,12 +13,25 @@ class Task extends Model const TYPE_POINT_GIFT_DELIVER = 3; // 积分礼品派发 const TYPE_LUCKY_GIFT_DELIVER = 4; // 抽奖礼品派发 + /** + * 针对外部用户 + */ const TYPE_NOTICE_ACCOUNT_LOGIN = 11; // 帐号登录通知 - const TYPE_NOTICE_LIVE_BEGIN = 12; // 直播开始通知 + const TYPE_NOTICE_LIVE_BEGIN = 12; // 直播学员通知 const TYPE_NOTICE_ORDER_FINISH = 13; // 订单完成通知 const TYPE_NOTICE_REFUND_FINISH = 14; // 退款完成通知 const TYPE_NOTICE_CONSULT_REPLY = 15; // 咨询回复通知 + /** + * 针对内部人员 + */ + const TYPE_NOTICE_CONSULT_CREATE = 31; // 咨询创建通知 + const TYPE_NOTICE_TEACHER_LIVE = 32; // 直播讲师通知 + const TYPE_NOTICE_SERVER_MONITOR = 33; // 服务监控通知 + const TYPE_NOTICE_CUSTOM_SERVICE = 34; // 客服消息通知 + const TYPE_NOTICE_POINT_REDEEM = 35; // 积分兑换通知 + const TYPE_NOTICE_LUCKY_REDEEM = 36; // 抽奖兑换通知 + /** * 优先级 */ @@ -83,6 +96,13 @@ class Task extends Model */ public $try_count = 0; + /** + * 最大重试次数 + * + * @var int + */ + public $max_try_count = 3; + /** * 创建时间 * diff --git a/app/Repos/ChapterLive.php b/app/Repos/ChapterLive.php index 6319a384..74d83587 100644 --- a/app/Repos/ChapterLive.php +++ b/app/Repos/ChapterLive.php @@ -5,6 +5,7 @@ namespace App\Repos; use App\Library\Paginator\Adapter\QueryBuilder as PagerQueryBuilder; use App\Models\Chapter as ChapterModel; use App\Models\ChapterLive as ChapterLiveModel; +use Phalcon\Mvc\Model; class ChapterLive extends Repository { @@ -54,4 +55,28 @@ class ChapterLive extends Repository return $pager->paginate(); } + /** + * @param int $id + * @return ChapterLiveModel|Model|bool + */ + public function findById($id) + { + return ChapterLiveModel::findFirst([ + 'conditions' => 'id = :id:', + 'bind' => ['id' => $id], + ]); + } + + /** + * @param int $chapterId + * @return ChapterLiveModel|Model|bool + */ + public function findByChapterId($chapterId) + { + return ChapterLiveModel::findFirst([ + 'conditions' => 'chapter_id = :chapter_id:', + 'bind' => ['chapter_id' => $chapterId], + ]); + } + } diff --git a/app/Repos/Course.php b/app/Repos/Course.php index 43591050..d4b7cabe 100644 --- a/app/Repos/Course.php +++ b/app/Repos/Course.php @@ -180,6 +180,7 @@ class Course extends Repository ->join(CourseUserModel::class, 'u.id = cu.user_id', 'cu') ->where('cu.course_id = :course_id:', ['course_id' => $courseId]) ->andWhere('cu.role_type = :role_type:', ['role_type' => $roleType]) + ->andWhere('cu.deleted = :deleted:', ['deleted' => 0]) ->getQuery()->execute(); } diff --git a/app/Repos/ImFriendGroup.php b/app/Repos/ImFriendGroup.php index cb31a2c4..babbfa09 100644 --- a/app/Repos/ImFriendGroup.php +++ b/app/Repos/ImFriendGroup.php @@ -89,7 +89,7 @@ class ImFriendGroup extends Repository public function countUsers($groupId) { return (int)ImFriendUserModel::count([ - 'conditions' => 'group_id = :group_id: AND blocked = 0', + 'conditions' => 'group_id = :group_id:', 'bind' => ['group_id' => $groupId], ]); } diff --git a/app/Repos/Topic.php b/app/Repos/Topic.php index 14dc3372..dfeebe52 100644 --- a/app/Repos/Topic.php +++ b/app/Repos/Topic.php @@ -21,6 +21,10 @@ class Topic extends Repository $builder->where('1 = 1'); + if (!empty($where['id'])) { + $builder->andWhere('id = :id:', ['id' => $where['id']]); + } + if (!empty($where['title'])) { $builder->andWhere('title LIKE :title:', ['title' => "%{$where['title']}%"]); } diff --git a/app/Services/DingTalk/Notice/ConsultCreate.php b/app/Services/DingTalk/Notice/ConsultCreate.php new file mode 100644 index 00000000..87d7e4c8 --- /dev/null +++ b/app/Services/DingTalk/Notice/ConsultCreate.php @@ -0,0 +1,69 @@ +enabled) return; + + $consultRepo = new ConsultRepo(); + + $consult = $consultRepo->findById($task->item_id); + + $userRepo = new UserRepo(); + + $user = $userRepo->findById($consult->owner_id); + + $courseRepo = new CourseRepo(); + + $course = $courseRepo->findById($consult->course_id); + + $content = kg_ph_replace("{user.name} 对课程:{course.title} 发起了咨询:\n{consult.question}", [ + 'user.name' => $user->name, + 'course.title' => $course->title, + 'consult.question' => $consult->question, + ]); + + $this->atCourseTeacher($course->id, $content); + } + + public function createTask(ConsultModel $consult) + { + if (!$this->enabled) return; + + $keyName = "dingtalk_consult_create_notice:{$consult->owner_id}"; + + $cache = $this->getCache(); + + $content = $cache->get($keyName); + + if ($content) return; + + $cache->save($keyName, 1, 3600); + + $task = new TaskModel(); + + $itemInfo = [ + 'consult' => ['id' => $consult->id], + ]; + + $task->item_id = $consult->id; + $task->item_info = $itemInfo; + $task->item_type = TaskModel::TYPE_NOTICE_CONSULT_CREATE; + $task->priority = TaskModel::PRIORITY_LOW; + $task->status = TaskModel::STATUS_PENDING; + + $task->create(); + } + +} \ No newline at end of file diff --git a/app/Services/DingTalk/Notice/CustomService.php b/app/Services/DingTalk/Notice/CustomService.php new file mode 100644 index 00000000..08d0b289 --- /dev/null +++ b/app/Services/DingTalk/Notice/CustomService.php @@ -0,0 +1,63 @@ +enabled) return; + + $messageRepo = new ImMessageRepo(); + + $message = $messageRepo->findById($task->item_id); + + $userRepo = new UserRepo(); + + $sender = $userRepo->findById($message->sender_id); + + $content = kg_ph_replace("{user.name} 通过在线客服给你发送了消息:{message.content}", [ + 'user.name' => $sender->name, + 'message.content' => $message->content, + ]); + + $this->atCustomService($content); + } + + public function createTask(ImMessageModel $message) + { + if (!$this->enabled) return; + + $keyName = "dingtalk_custom_service_notice:{$message->sender_id}"; + + $cache = $this->getCache(); + + $content = $cache->get($keyName); + + if ($content) return; + + $cache->save($keyName, 1, 3600); + + $task = new TaskModel(); + + $itemInfo = [ + 'im_message' => ['id' => $message->id], + ]; + + $task->item_id = $message->id; + $task->item_info = $itemInfo; + $task->item_type = TaskModel::TYPE_NOTICE_CUSTOM_SERVICE; + $task->priority = TaskModel::PRIORITY_MIDDLE; + $task->status = TaskModel::STATUS_PENDING; + + $task->create(); + } + +} \ No newline at end of file diff --git a/app/Services/DingTalk/Notice/LiveTeacher.php b/app/Services/DingTalk/Notice/LiveTeacher.php new file mode 100644 index 00000000..e5125f76 --- /dev/null +++ b/app/Services/DingTalk/Notice/LiveTeacher.php @@ -0,0 +1,53 @@ +enabled) return; + + $liveRepo = new ChapterLiveRepo(); + + $live = $liveRepo->findById($task->item_id); + + $courseRepo = new CourseRepo(); + + $course = $courseRepo->findById($live->course_id); + + $content = kg_ph_replace("课程:{course.title} 计划于 {live.start_time} 开播,不要错过直播时间哦!", [ + 'course.title' => $course->title, + 'live.start_time' => date('Y-m-d H:i', $live->start_time), + ]); + + $this->atCourseTeacher($course->id, $content); + } + + public function createTask(ChapterLiveModel $live) + { + if (!$this->enabled) return; + + $task = new TaskModel(); + + $itemInfo = [ + 'live' => ['id' => $live->id], + ]; + + $task->item_id = $live->id; + $task->item_info = $itemInfo; + $task->item_type = TaskModel::TYPE_NOTICE_TEACHER_LIVE; + $task->priority = TaskModel::PRIORITY_LOW; + $task->status = TaskModel::STATUS_PENDING; + + $task->create(); + } + +} \ No newline at end of file diff --git a/app/Services/DingTalk/Notice/PointRedeem.php b/app/Services/DingTalk/Notice/PointRedeem.php new file mode 100644 index 00000000..ec2890d9 --- /dev/null +++ b/app/Services/DingTalk/Notice/PointRedeem.php @@ -0,0 +1,51 @@ +enabled) return; + + $redeemRepo = new PointRedeemRepo(); + + $redeem = $redeemRepo->findById($task->item_id); + + $content = kg_ph_replace("{user.name} 兑换了商品 {gift.name},不要忘记发货哦!", [ + 'user.name' => $redeem->user_name, + 'gift.name' => $redeem->gift_name, + ]); + + $this->atCustomService($content); + } + + public function createTask(PointRedeemModel $redeem) + { + if (!$this->enabled) return; + + if ($redeem->gift_type != PointGiftModel::TYPE_GOODS) return; + + $task = new TaskModel(); + + $itemInfo = [ + 'point_redeem' => ['id' => $redeem->id], + ]; + + $task->item_id = $redeem->id; + $task->item_info = $itemInfo; + $task->item_type = TaskModel::TYPE_NOTICE_POINT_REDEEM; + $task->priority = TaskModel::PRIORITY_MIDDLE; + $task->status = TaskModel::STATUS_PENDING; + + $task->create(); + } + +} \ No newline at end of file diff --git a/app/Services/DingTalk/Notice/ServerMonitor.php b/app/Services/DingTalk/Notice/ServerMonitor.php new file mode 100644 index 00000000..10202c95 --- /dev/null +++ b/app/Services/DingTalk/Notice/ServerMonitor.php @@ -0,0 +1,40 @@ +enabled) return; + + $notice = new DingTalkNotice(); + + $content = $task->item_info['content']; + + $notice->atTechSupport($content); + } + + public function createTask($content) + { + if (!$this->enabled) return; + + $task = new TaskModel(); + + $itemInfo = ['content' => $content]; + + $task->item_id = time(); + $task->item_info = $itemInfo; + $task->item_type = TaskModel::TYPE_NOTICE_SERVER_MONITOR; + $task->priority = TaskModel::PRIORITY_HIGH; + $task->status = TaskModel::STATUS_PENDING; + $task->max_try_count = 1; + + $task->create(); + } + +} \ No newline at end of file diff --git a/app/Services/DingTalkNotice.php b/app/Services/DingTalkNotice.php new file mode 100644 index 00000000..166cb52c --- /dev/null +++ b/app/Services/DingTalkNotice.php @@ -0,0 +1,229 @@ +settings = $this->getSettings('dingtalk.robot'); + + $this->logger = $this->getLogger('dingtalk'); + + $this->enabled = $this->settings['enabled'] == 1; + } + + /** + * 测试消息 + * + * @return bool + */ + public function test() + { + $params = [ + 'msgtype' => 'text', + 'text' => ['content' => '我是一条测试消息啦!'], + ]; + + return $this->send($params); + } + + /** + * 给技术人员发消息 + * + * @param string $content + * @return bool + */ + public function atTechSupport($content) + { + $atMobiles = $this->parseAtMobiles($this->settings['ts_mobiles']); + $atContent = $this->buildAtContent($content, $atMobiles); + + $params = [ + 'msgtype' => 'text', + 'text' => ['content' => $atContent], + 'at' => ['atMobiles' => $atMobiles], + ]; + + return $this->send($params); + } + + /** + * 给客服人员发消息 + * + * @param string $content + * @return bool + */ + public function atCustomService($content) + { + $atMobiles = $this->parseAtMobiles($this->settings['cs_mobiles']); + $atContent = $this->buildAtContent($content, $atMobiles); + + $params = [ + 'msgtype' => 'text', + 'text' => ['content' => $atContent], + 'at' => ['atMobiles' => $atMobiles], + ]; + + return $this->send($params); + } + + /** + * 给课程讲师发消息 + * + * @param int $courseId + * @param string $content + * @return bool + */ + public function atCourseTeacher($courseId, $content) + { + $courseRepo = new CourseRepo(); + + $course = $courseRepo->findById($courseId); + + $accountRepo = new AccountRepo(); + + $account = $accountRepo->findById($course->teacher_id); + + if (empty($account->phone)) return false; + + $atMobiles = [$account->phone]; + + $atContent = $this->buildAtContent($content, $atMobiles); + + $params = [ + 'msgtype' => 'text', + 'text' => ['content' => $atContent], + 'at' => ['atMobiles' => $atMobiles], + ]; + + return $this->send($params); + } + + /** + * 发送消息 + * + * @param array $params + * @return bool + */ + public function send($params) + { + if (!isset($params['msgtype'])) { + $params['msgtype'] = 'text'; + } + + $appSecret = $this->settings['app_secret']; + $appToken = $this->settings['app_token']; + + $timestamp = time() * 1000; + $data = sprintf("%s\n%s", $timestamp, $appSecret); + $sign = urlencode(base64_encode(hash_hmac('sha256', $data, $appSecret, true))); + + $baseUrl = 'https://oapi.dingtalk.com/robot/send'; + + $postUrl = $baseUrl . '?' . http_build_query([ + 'access_token' => $appToken, + 'timestamp' => $timestamp, + 'sign' => $sign, + ]); + + try { + + $client = new HttpClient(); + + $response = $client->post($postUrl, ['json' => $params]); + + $content = $response->getBody()->getContents(); + + $content = json_decode($content, true); + + $this->logger->debug('Send Message Request ' . kg_json_encode($params)); + + $this->logger->debug('Send Message Response ' . kg_json_encode($content)); + + $result = $content['errcode'] == 0; + + if ($result == false) { + $this->logger->error('Send Message Failed ' . kg_json_encode($content)); + } + + } catch (\Exception $e) { + + $this->logger->error('Send Message Exception ' . kg_json_encode([ + 'file' => $e->getFile(), + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + ])); + + $result = false; + } + + return $result; + } + + /** + * @param string $mobiles + * @return array + */ + protected function parseAtMobiles($mobiles) + { + if (empty($mobiles)) return []; + + $mobiles = str_replace([',', '|', '|'], ',', $mobiles); + + $mobiles = explode(',', $mobiles); + + $result = []; + + foreach ($mobiles as $mobile) { + if (CommonValidator::phone($mobile)) { + $result[] = $mobile; + } + } + + return $result; + } + + /** + * @param string $content + * @param array $mobiles + * @return string + */ + protected function buildAtContent($content, $mobiles = []) + { + if (empty($mobiles)) return $content; + + $result = ''; + + foreach ($mobiles as $mobile) { + $result .= sprintf('@%s ', $mobile); + } + + $result .= $content; + + return $result; + } + +} \ No newline at end of file diff --git a/app/Services/Logic/Consult/ConsultCreate.php b/app/Services/Logic/Consult/ConsultCreate.php index 369fd19a..2ec411dd 100644 --- a/app/Services/Logic/Consult/ConsultCreate.php +++ b/app/Services/Logic/Consult/ConsultCreate.php @@ -6,6 +6,7 @@ use App\Models\Chapter as ChapterModel; use App\Models\Consult as ConsultModel; use App\Models\Course as CourseModel; use App\Models\User as UserModel; +use App\Services\DingTalk\Notice\ConsultCreate as ConsultCreateNotice; use App\Services\Logic\ChapterTrait; use App\Services\Logic\CourseTrait; use App\Services\Logic\Service; @@ -75,6 +76,8 @@ class ConsultCreate extends Service $this->incrUserDailyConsultCount($user); + $this->handleConsultCreateNotice($consult); + return $consult; } @@ -111,6 +114,8 @@ class ConsultCreate extends Service $this->incrUserDailyConsultCount($user); + $this->handleConsultCreateNotice($consult); + return $consult; } @@ -150,4 +155,11 @@ class ConsultCreate extends Service $this->eventsManager->fire('UserDailyCounter:incrConsultCount', $this, $user); } + protected function handleConsultCreateNotice(ConsultModel $consult) + { + $notice = new ConsultCreateNotice(); + + $notice->createTask($consult); + } + } diff --git a/app/Services/Logic/Notice/AccountLogin.php b/app/Services/Logic/Notice/AccountLogin.php index 6ae4b18f..9f4fdd06 100644 --- a/app/Services/Logic/Notice/AccountLogin.php +++ b/app/Services/Logic/Notice/AccountLogin.php @@ -54,6 +54,7 @@ class AccountLogin extends LogicService $task->item_type = TaskModel::TYPE_NOTICE_ACCOUNT_LOGIN; $task->priority = TaskModel::PRIORITY_LOW; $task->status = TaskModel::STATUS_PENDING; + $task->max_try_count = 1; $task->create(); } diff --git a/app/Services/Logic/Notice/ConsultReply.php b/app/Services/Logic/Notice/ConsultReply.php index 3b77f7c1..34cfaebc 100644 --- a/app/Services/Logic/Notice/ConsultReply.php +++ b/app/Services/Logic/Notice/ConsultReply.php @@ -86,6 +86,7 @@ class ConsultReply extends LogicService $task->item_type = TaskModel::TYPE_NOTICE_CONSULT_REPLY; $task->priority = TaskModel::PRIORITY_LOW; $task->status = TaskModel::STATUS_PENDING; + $task->max_try_count = 1; $task->create(); } diff --git a/app/Services/Logic/Notice/LiveBegin.php b/app/Services/Logic/Notice/LiveBegin.php index f125c56c..a0818d54 100644 --- a/app/Services/Logic/Notice/LiveBegin.php +++ b/app/Services/Logic/Notice/LiveBegin.php @@ -92,6 +92,7 @@ class LiveBegin extends LogicService $task->item_type = TaskModel::TYPE_NOTICE_LIVE_BEGIN; $task->priority = TaskModel::PRIORITY_LOW; $task->status = TaskModel::STATUS_PENDING; + $task->max_try_count = 1; $task->create(); } diff --git a/app/Services/Logic/User/CourseList.php b/app/Services/Logic/User/CourseList.php index 431ad8ba..1ef41939 100644 --- a/app/Services/Logic/User/CourseList.php +++ b/app/Services/Logic/User/CourseList.php @@ -58,6 +58,7 @@ class CourseList extends Service 'progress' => $relation['progress'], 'duration' => $relation['duration'], 'reviewed' => $relation['reviewed'], + 'source_type' => $relation['source_type'], 'expiry_time' => $relation['expiry_time'], 'create_time' => $relation['create_time'], 'course' => $course, diff --git a/app/Validators/ImFriendGroup.php b/app/Validators/ImFriendGroup.php index 6d6d7450..5746d067 100644 --- a/app/Validators/ImFriendGroup.php +++ b/app/Validators/ImFriendGroup.php @@ -3,14 +3,14 @@ namespace App\Validators; use App\Exceptions\BadRequest as BadRequestException; -use App\Repos\ImGroup as ImGroupRepo; +use App\Repos\ImFriendGroup as ImFriendGroupRepo; class ImFriendGroup extends Validator { public function checkGroup($id) { - $groupRepo = new ImGroupRepo(); + $groupRepo = new ImFriendGroupRepo(); $group = $groupRepo->findById($id); diff --git a/db/migrations/20210215024511_data_202102151130.php b/db/migrations/20210215024511_data_202102151130.php new file mode 100644 index 00000000..60a959dd --- /dev/null +++ b/db/migrations/20210215024511_data_202102151130.php @@ -0,0 +1,70 @@ + 'dingtalk.robot', + 'item_key' => 'enabled', + 'item_value' => '0', + ], + [ + 'section' => 'dingtalk.robot', + 'item_key' => 'app_secret', + 'item_value' => '', + ], + [ + 'section' => 'dingtalk.robot', + 'item_key' => 'app_token', + 'item_value' => '', + ], + [ + 'section' => 'dingtalk.robot', + 'item_key' => 'ts_mobiles', + 'item_value' => '', + ], + [ + 'section' => 'dingtalk.robot', + 'item_key' => 'cs_mobiles', + 'item_value' => '', + ], + ]; + + $this->table('kg_setting')->insert($rows)->save(); + + $this->updateImGroupRouter(); + } + + public function down() + { + $this->getQueryBuilder() + ->delete('kg_setting') + ->where(['section' => 'dingtalk.robot']) + ->execute(); + } + + protected function updateImGroupRouter() + { + $roles = $this->getQueryBuilder() + ->select('*') + ->from('kg_role') + ->execute(); + + if ($roles->count() == 0) return; + + foreach ($roles as $role) { + if (strpos($role['routes'], 'admin.group') !== false) { + $routes = str_replace('admin.group', 'admin.im_group', $role['routes']); + $this->getQueryBuilder() + ->update('kg_role') + ->set(['routes' => $routes]) + ->where(['id' => $role['id']]) + ->execute(); + } + } + } + +} diff --git a/db/migrations/20210215034511_schema_202102151230.php b/db/migrations/20210215034511_schema_202102151230.php new file mode 100644 index 00000000..77b94e12 --- /dev/null +++ b/db/migrations/20210215034511_schema_202102151230.php @@ -0,0 +1,28 @@ +table('kg_task') + ->addColumn('max_try_count', 'integer', [ + 'null' => false, + 'default' => '0', + 'limit' => MysqlAdapter::INT_REGULAR, + 'signed' => false, + 'comment' => '最大尝试数', + 'after' => 'try_count', + ])->save(); + } + + public function down() + { + $this->table('kg_task') + ->removeColumn('max_try_count') + ->save(); + } + +} diff --git a/public/static/admin/css/common.css b/public/static/admin/css/common.css index c8977177..1bba752e 100644 --- a/public/static/admin/css/common.css +++ b/public/static/admin/css/common.css @@ -34,6 +34,11 @@ list-style: decimal; } +.loading { + padding: 30px; + text-align: center; +} + .kg-layer-content { padding: 15px; } diff --git a/public/static/home/js/im.cs.js b/public/static/home/js/im.cs.js index 06c7727d..f86c831f 100644 --- a/public/static/home/js/im.cs.js +++ b/public/static/home/js/im.cs.js @@ -64,7 +64,7 @@ layui.use(['jquery', 'layim'], function () { }); layim.on('sendMessage', function (res) { - sendCsMessage(res); + sendCustomMessage(res); }); showWelcomeMessage(csUser); @@ -77,7 +77,7 @@ layui.use(['jquery', 'layim'], function () { }); } - function sendCsMessage(res) { + function sendCustomMessage(res) { $.ajax({ type: 'POST', url: '/im/msg/cs/send', diff --git a/scheduler.php b/scheduler.php index 666bb7e4..253ad168 100644 --- a/scheduler.php +++ b/scheduler.php @@ -16,18 +16,24 @@ $scheduler->php($script, $bin, ['--task' => 'deliver', '--action' => 'main']) $scheduler->php($script, $bin, ['--task' => 'notice', '--action' => 'main']) ->at('*/3 * * * *'); -$scheduler->php($script, $bin, ['--task' => 'sync_learning', '--action' => 'main']) - ->at('*/7 * * * *'); - $scheduler->php($script, $bin, ['--task' => 'vod_event', '--action' => 'main']) ->at('*/5 * * * *'); -$scheduler->php($script, $bin, ['--task' => 'close_trade', '--action' => 'main']) - ->at('*/13 * * * *'); +$scheduler->php($script, $bin, ['--task' => 'sync_learning', '--action' => 'main']) + ->at('*/7 * * * *'); + +$scheduler->php($script, $bin, ['--task' => 'teacher_live_notice', '--action' => 'consume']) + ->at('*/10 * * * *'); $scheduler->php($script, $bin, ['--task' => 'point_gift_deliver', '--action' => 'main']) ->at('*/11 * * * *'); +$scheduler->php($script, $bin, ['--task' => 'server_monitor', '--action' => 'main']) + ->at('*/12 * * * *'); + +$scheduler->php($script, $bin, ['--task' => 'close_trade', '--action' => 'main']) + ->at('*/13 * * * *'); + $scheduler->php($script, $bin, ['--task' => 'close_order', '--action' => 'main']) ->hourly(3); @@ -58,4 +64,10 @@ $scheduler->php($script, $bin, ['--task' => 'revoke_vip', '--action' => 'main']) $scheduler->php($script, $bin, ['--task' => 'sitemap', '--action' => 'main']) ->daily(4, 3); +$scheduler->php($script, $bin, ['--task' => 'teacher_live_notice', '--action' => 'provide']) + ->daily(4, 7); + +$scheduler->php($script, $bin, ['--task' => 'optimize_table', '--action' => 'main']) + ->weekly(6, 5, 3); + $scheduler->run(); \ No newline at end of file
    {{ event_type_info(item.event_type) }} {{ event_point_info(item.event_point) }} {{ event_detail_info(item) }}{{ date('Y-m-d H:i',item.create_time) }}{{ date('Y-m-d',item.create_time) }}
    {{ item.gift.name }} {{ gift_type_info(item.gift.type) }} {{ item.gift.point }} {{ redeem_status_info(item.status) }}{{ date('Y-m-d H:i',item.create_time) }}{{ date('Y-m-d',item.create_time) }}