diff --git a/app/Builders/ImFriendUserList.php b/app/Builders/ImFriendUserList.php index 0c51d029..f8a39826 100644 --- a/app/Builders/ImFriendUserList.php +++ b/app/Builders/ImFriendUserList.php @@ -26,7 +26,7 @@ class ImFriendUserList extends Builder $columns = [ 'id', 'name', 'avatar', 'title', 'about', 'vip', - 'gender', 'location', 'active_time', + 'gender', 'area', 'active_time', ]; $users = $userRepo->findByIds($ids, $columns); diff --git a/app/Http/Desktop/Controllers/Controller.php b/app/Http/Desktop/Controllers/Controller.php index 57b6e40a..6cba9828 100644 --- a/app/Http/Desktop/Controllers/Controller.php +++ b/app/Http/Desktop/Controllers/Controller.php @@ -127,9 +127,6 @@ class Controller extends \Phalcon\Mvc\Controller 'cs' => [ 'enabled' => $im['cs_enabled'], ], - 'robot' => [ - 'enabled' => $im['robot_enabled'], - ], 'websocket' => [ 'url' => $this->config->websocket->url, ], @@ -141,7 +138,7 @@ class Controller extends \Phalcon\Mvc\Controller if ($this->siteInfo['enabled'] == 0) { $this->dispatcher->forward([ 'controller' => 'error', - 'action' => 'shutdown', + 'action' => 'maintain', 'params' => ['message' => $this->siteInfo['closed_tips']], ]); } diff --git a/app/Http/Desktop/Controllers/ErrorController.php b/app/Http/Desktop/Controllers/ErrorController.php index 25b6a91d..930c413a 100644 --- a/app/Http/Desktop/Controllers/ErrorController.php +++ b/app/Http/Desktop/Controllers/ErrorController.php @@ -68,9 +68,9 @@ class ErrorController extends \Phalcon\Mvc\Controller } /** - * @Get("/shutdown", name="desktop.error.shutdown") + * @Get("/maintain", name="desktop.error.maintain") */ - public function shutdownAction() + public function maintainAction() { $message = $this->dispatcher->getParam('message'); diff --git a/app/Http/Desktop/Views/error/shutdown.volt b/app/Http/Desktop/Views/error/maintain.volt similarity index 100% rename from app/Http/Desktop/Views/error/shutdown.volt rename to app/Http/Desktop/Views/error/maintain.volt diff --git a/app/Http/Desktop/Views/user/show.volt b/app/Http/Desktop/Views/user/show.volt index 9a6b107f..9772f16b 100644 --- a/app/Http/Desktop/Views/user/show.volt +++ b/app/Http/Desktop/Views/user/show.volt @@ -29,7 +29,7 @@

{{ user.name }}{{ gender_info(user.gender) }}

-

{{ user.location }}

+

{{ user.area }}

{{ date('Y-m-d H:i',user.active_time) }}

{% if user.about %} diff --git a/app/Library/Helper.php b/app/Library/Helper.php index 05f550b4..0ee934f5 100644 --- a/app/Library/Helper.php +++ b/app/Library/Helper.php @@ -125,9 +125,8 @@ function kg_site_base_url() { $scheme = filter_input(INPUT_SERVER, 'REQUEST_SCHEME'); $host = filter_input(INPUT_SERVER, 'HTTP_HOST'); - $path = filter_input(INPUT_SERVER, 'SCRIPT_NAME'); - return "{$scheme}://{$host}" . rtrim(dirname($path), '/'); + return sprintf('%s://%s', $scheme, $host); } /** @@ -184,9 +183,10 @@ function kg_ci_base_url() * 获取数据万象URL * * @param string $path + * @param string $style * @return string */ -function kg_ci_img_url($path) +function kg_ci_img_url($path, $style = null) { if (!$path) return ''; @@ -196,33 +196,35 @@ function kg_ci_img_url($path) $storage = new StorageService(); - return $storage->getCiImageUrl($path); + return $storage->getCiImageUrl($path, $style); } /** * 获取头像数据万象URL * * @param string $path + * @param string $style * @return string */ -function kg_ci_avatar_img_url($path) +function kg_ci_avatar_img_url($path, $style = null) { $path = $path ?: kg_default_avatar_path(); - return kg_ci_img_url($path); + return kg_ci_img_url($path, $style); } /** * 获取封面数据万象URL * * @param string $path + * @param string $style * @return string */ -function kg_ci_cover_img_url($path) +function kg_ci_cover_img_url($path, $style = null) { $path = $path ?: kg_default_cover_path(); - return kg_ci_img_url($path); + return kg_ci_img_url($path, $style); } /** @@ -347,17 +349,6 @@ function kg_duration($time, $mode = 'simple') return $result; } -/** - * 判断是否有路由权限 - * - * @param string $route - * @return bool - */ -function kg_can($route = null) -{ - return true; -} - /** * 构造icon路径 * @@ -370,7 +361,7 @@ function kg_icon_link($path, $local = true, $version = null) { $href = kg_static_url($path, $local, $version); - return '' . PHP_EOL; + return sprintf('', $href); } /** @@ -385,7 +376,7 @@ function kg_css_link($path, $local = true, $version = null) { $href = kg_static_url($path, $local, $version); - return '' . PHP_EOL; + return sprintf('', $href); } /** @@ -400,7 +391,7 @@ function kg_js_include($path, $local = true, $version = null) { $src = kg_static_url($path, $local, $version); - return '' . PHP_EOL; + return sprintf('', $src); } /** diff --git a/app/Library/Logger.php b/app/Library/Logger.php index a4e61293..38824ecf 100644 --- a/app/Library/Logger.php +++ b/app/Library/Logger.php @@ -17,9 +17,11 @@ class Logger { $config = Di::getDefault()->get('config'); - $channel = $channel ? $channel . '-' : ''; + $channel = $channel ? $channel : 'common'; - $path = log_path() . '/' . $channel . date('Y-m-d') . '.log'; + $filename = sprintf('%s-%s.log', $channel, date('Y-m-d')); + + $path = log_path($filename); $level = $config->env != ENV_DEV ? $config->log->level : PhalconLogger::DEBUG; diff --git a/app/Models/Chapter.php b/app/Models/Chapter.php index 8f84140d..b6153288 100644 --- a/app/Models/Chapter.php +++ b/app/Models/Chapter.php @@ -100,7 +100,7 @@ class Chapter extends Model /** * 模式类型 * - * @var string + * @var int */ public $model; diff --git a/app/Models/Course.php b/app/Models/Course.php index a8b1978f..0a82e12b 100644 --- a/app/Models/Course.php +++ b/app/Models/Course.php @@ -147,14 +147,14 @@ class Course extends Model /** * 模式类型 * - * @var string + * @var int */ public $model; /** * 难度级别 * - * @var string + * @var int */ public $level; diff --git a/app/Models/ImGroup.php b/app/Models/ImGroup.php index 488e3329..eba27c47 100644 --- a/app/Models/ImGroup.php +++ b/app/Models/ImGroup.php @@ -40,7 +40,7 @@ class ImGroup extends Model /** * 群组类型 * - * @var string + * @var int */ public $type; diff --git a/app/Models/ImMessage.php b/app/Models/ImMessage.php index 055abd86..b369d4ff 100644 --- a/app/Models/ImMessage.php +++ b/app/Models/ImMessage.php @@ -44,7 +44,7 @@ class ImMessage extends Model /** * 接收方类型 * - * @var string + * @var int */ public $receiver_type; diff --git a/app/Models/ImNotice.php b/app/Models/ImNotice.php index a4b294c1..0db34ae9 100644 --- a/app/Models/ImNotice.php +++ b/app/Models/ImNotice.php @@ -7,13 +7,6 @@ use Phalcon\Mvc\Model\Behavior\SoftDelete; class ImNotice extends Model { - /** - * 请求状态 - */ - const REQUEST_PENDING = 'pending'; // 待处理 - const REQUEST_ACCEPTED = 'accepted'; // 已接受 - const REQUEST_REFUSED = 'refused'; // 已拒绝 - /** * 通知类型 */ @@ -117,8 +110,6 @@ class ImNotice extends Model if (!empty($this->item_info)) { $this->item_info = kg_json_encode($this->item_info); - } else { - $this->item_info = ''; } } @@ -126,14 +117,14 @@ class ImNotice extends Model { $this->update_time = time(); - if (is_array($this->item_info) && !empty($this->item_info)) { + if (is_array($this->item_info)) { $this->item_info = kg_json_encode($this->item_info); } } public function afterFetch() { - if (!empty($this->item_info)) { + if (!empty($this->item_info) && is_string($this->item_info)) { $this->item_info = json_decode($this->item_info, true); } } diff --git a/app/Models/Task.php b/app/Models/Task.php index b7039d9c..e9b11c45 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -36,14 +36,14 @@ class Task extends Model /** * 条目编号 * - * @var string + * @var int */ public $item_id; /** * 条目类型 * - * @var string + * @var int */ public $item_type; diff --git a/app/Models/User.php b/app/Models/User.php index 5662ed02..5f5edb5a 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -59,11 +59,11 @@ class User extends Model public $about; /** - * 所在地 + * 地区 * * @var string */ - public $location; + public $area; /** * 性别 @@ -72,20 +72,6 @@ class User extends Model */ public $gender; - /** - * 教学角色 - * - * @var int - */ - public $edu_role; - - /** - * 后台角色 - * - * @var int - */ - public $admin_role; - /** * 会员标识 * @@ -107,6 +93,20 @@ class User extends Model */ public $deleted; + /** + * 教学角色 + * + * @var int + */ + public $edu_role; + + /** + * 后台角色 + * + * @var int + */ + public $admin_role; + /** * 课程数 * diff --git a/app/Providers/Volt.php b/app/Providers/Volt.php index 22f891c1..bb786e46 100644 --- a/app/Providers/Volt.php +++ b/app/Providers/Volt.php @@ -54,10 +54,6 @@ class Volt extends Provider return 'kg_substr(' . $resolvedArgs . ')'; }); - $compiler->addFunction('can', function ($resolvedArgs) { - return 'kg_can(' . $resolvedArgs . ')'; - }); - $compiler->addFilter('duration', function ($resolvedArgs) { return 'kg_duration(' . $resolvedArgs . ')'; }); diff --git a/app/Services/Frontend/My/ProfileInfo.php b/app/Services/Frontend/My/ProfileInfo.php index a2872601..1486f3bd 100644 --- a/app/Services/Frontend/My/ProfileInfo.php +++ b/app/Services/Frontend/My/ProfileInfo.php @@ -19,7 +19,7 @@ class ProfileInfo extends FrontendService { $user->avatar = kg_ci_img_url($user->avatar); - $area = $this->handleArea($user->location); + $user->area = $this->handleArea($user->area); return [ 'id' => $user->id, @@ -27,9 +27,8 @@ class ProfileInfo extends FrontendService 'avatar' => $user->avatar, 'title' => $user->title, 'about' => $user->about, + 'area' => $user->area, 'gender' => $user->gender, - 'location' => $user->location, - 'area' => $area, 'vip' => $user->vip, 'locked' => $user->locked, 'vip_expiry_time' => $user->vip_expiry_time, @@ -39,9 +38,9 @@ class ProfileInfo extends FrontendService ]; } - protected function handleArea($location) + protected function handleArea($area) { - $area = explode('/', $location); + $area = explode('/', $area); return [ 'province' => $area[0] ?? '', diff --git a/app/Services/Frontend/My/ProfileUpdate.php b/app/Services/Frontend/My/ProfileUpdate.php index 9d519ede..722589fe 100644 --- a/app/Services/Frontend/My/ProfileUpdate.php +++ b/app/Services/Frontend/My/ProfileUpdate.php @@ -31,7 +31,7 @@ class ProfileUpdate extends FrontendService } if (!empty($post['area'])) { - $data['location'] = $validator->checkArea($post['area']); + $data['area'] = $validator->checkArea($post['area']); } if (!empty($post['about'])) { diff --git a/app/Services/Frontend/Order/OrderCreate.php b/app/Services/Frontend/Order/OrderCreate.php index d7762b79..90ee6067 100644 --- a/app/Services/Frontend/Order/OrderCreate.php +++ b/app/Services/Frontend/Order/OrderCreate.php @@ -59,12 +59,6 @@ class OrderCreate extends FrontendService $order = $this->createPackageOrder($package, $user); - } elseif ($post['item_type'] == OrderModel::ITEM_VIP) { - - $vip = $validator->checkVip($post['item_id']); - - $order = $this->createVipOrder($vip, $user); - } elseif ($post['item_type'] == OrderModel::ITEM_REWARD) { list($courseId, $rewardId) = explode('-', $post['item_id']); @@ -73,6 +67,12 @@ class OrderCreate extends FrontendService $reward = $validator->checkReward($rewardId); $order = $this->createRewardOrder($course, $reward, $user); + + } elseif ($post['item_type'] == OrderModel::ITEM_VIP) { + + $vip = $validator->checkVip($post['item_id']); + + $order = $this->createVipOrder($vip, $user); } $this->incrUserDailyOrderCount($user); @@ -186,7 +186,7 @@ class OrderCreate extends FrontendService $order = new OrderModel(); $order->owner_id = $user->id; - $order->item_id = "{$course->id}-{$reward->id}"; + $order->item_id = $course->id; $order->item_type = OrderModel::ITEM_REWARD; $order->item_info = $itemInfo; $order->client_type = $this->getClientType(); diff --git a/app/Services/Frontend/Search/User.php b/app/Services/Frontend/Search/User.php index 17475cfc..1bc4b312 100644 --- a/app/Services/Frontend/Search/User.php +++ b/app/Services/Frontend/Search/User.php @@ -64,7 +64,7 @@ class User extends FrontendService 'about' => $item['about'], 'vip' => (int)$item['vip'], 'gender' => (int)$item['gender'], - 'location' => $item['location'], + 'area' => $item['area'], ]; } diff --git a/app/Services/Frontend/Teacher/TeacherInfo.php b/app/Services/Frontend/Teacher/TeacherInfo.php index 516636a7..f2e8eb10 100644 --- a/app/Services/Frontend/Teacher/TeacherInfo.php +++ b/app/Services/Frontend/Teacher/TeacherInfo.php @@ -2,37 +2,17 @@ namespace App\Services\Frontend\Teacher; -use App\Models\User as UserModel; use App\Services\Frontend\Service as FrontendService; -use App\Services\Frontend\UserTrait; +use App\Services\Frontend\User\UserInfo as UserInfoService; class TeacherInfo extends FrontendService { - use UserTrait; - public function getUser($id) { - $user = $this->checkUser($id); + $service = new UserInfoService(); - return $this->handleUser($user); - } - - protected function handleUser(UserModel $user) - { - $user->avatar = kg_ci_img_url($user->avatar); - - return [ - 'id' => $user->id, - 'name' => $user->name, - 'avatar' => $user->avatar, - 'title' => $user->title, - 'about' => $user->about, - 'location' => $user->location, - 'gender' => $user->gender, - 'vip' => $user->vip, - 'locked' => $user->locked, - ]; + return $service->handle($id); } } diff --git a/app/Services/Frontend/User/UserInfo.php b/app/Services/Frontend/User/UserInfo.php index 48b0ccda..a6528198 100644 --- a/app/Services/Frontend/User/UserInfo.php +++ b/app/Services/Frontend/User/UserInfo.php @@ -31,7 +31,7 @@ class UserInfo extends FrontendService 'avatar' => $user->avatar, 'title' => $user->title, 'about' => $user->about, - 'location' => $user->location, + 'area' => $user->area, 'gender' => $user->gender, 'vip' => $user->vip, 'locked' => $user->locked, diff --git a/app/Services/Search/UserDocument.php b/app/Services/Search/UserDocument.php index 5c9a8a4f..795b7fca 100644 --- a/app/Services/Search/UserDocument.php +++ b/app/Services/Search/UserDocument.php @@ -40,7 +40,7 @@ class UserDocument extends Component 'avatar' => $user->avatar, 'about' => $user->about, 'gender' => $user->gender, - 'location' => $user->location, + 'area' => $user->area, 'vip' => $user->vip, ]; } diff --git a/app/Services/Storage.php b/app/Services/Storage.php index b5a3c162..10261364 100644 --- a/app/Services/Storage.php +++ b/app/Services/Storage.php @@ -144,11 +144,14 @@ class Storage extends Service * 获取数据万象图片URL * * @param string $key + * @param string $style * @return string */ - public function getCiImageUrl($key) + public function getCiImageUrl($key, $style = null) { - return $this->getCiBaseUrl() . $key; + $style = $style ?: ''; + + return $this->getCiBaseUrl() . $key . $style; } /** @@ -161,7 +164,7 @@ class Storage extends Service $protocol = $this->settings['bucket_protocol']; $domain = $this->settings['bucket_domain']; - return $protocol . '://' . $domain; + return sprintf('%s://%s', $protocol, trim($domain, '/')); } /** @@ -174,7 +177,7 @@ class Storage extends Service $protocol = $this->settings['ci_protocol']; $domain = $this->settings['ci_domain']; - return $protocol . '://' . $domain; + return sprintf('%s://%s', $protocol, trim($domain, '/')); } /** diff --git a/public/static/desktop/js/im.js b/public/static/desktop/js/im.js index e2fe3113..dcf0d919 100644 --- a/public/static/desktop/js/im.js +++ b/public/static/desktop/js/im.js @@ -50,9 +50,9 @@ layui.use(['jquery', 'layim'], function () { members: { url: '/im/group/users' }, - maxLength: 1000, msgbox: '/im/msgbox', - chatLog: '/im/chatlog' + chatLog: '/im/chatlog', + maxLength: 1000 }); layim.on('ready', function (options) {