diff --git a/app/Http/Admin/Views/setting/pay_wxpay_test.volt b/app/Http/Admin/Views/setting/pay_wxpay_test.volt
index 3c57f314..518d4517 100644
--- a/app/Http/Admin/Views/setting/pay_wxpay_test.volt
+++ b/app/Http/Admin/Views/setting/pay_wxpay_test.volt
@@ -1,6 +1,6 @@
{% extends 'templates/main.volt' %}
-{% block contnet %}
+{% block content %}
{% if qrcode %}
diff --git a/app/Http/Admin/Views/setting/vod.volt b/app/Http/Admin/Views/setting/vod.volt
index fc8b7d55..9017d7a2 100644
--- a/app/Http/Admin/Views/setting/vod.volt
+++ b/app/Http/Admin/Views/setting/vod.volt
@@ -113,7 +113,7 @@
diff --git a/app/Http/Home/Services/ImCsTrait.php b/app/Http/Home/Services/ImCsTrait.php
index a86a3dc5..c3a816c1 100644
--- a/app/Http/Home/Services/ImCsTrait.php
+++ b/app/Http/Home/Services/ImCsTrait.php
@@ -2,7 +2,7 @@
namespace App\Http\Home\Services;
-use App\Caches\Setting as SettingCache;
+use App\Services\Service as AppService;
use GatewayClient\Gateway;
trait ImCsTrait
@@ -11,32 +11,33 @@ trait ImCsTrait
public function getCsUser()
{
$csUserIds = [];
+
$onlineUserIds = [];
- $cache = new SettingCache();
+ $appService = new AppService();
- $imInfo = $cache->get('im');
+ $csInfo = $appService->getSettings('im.cs');
Gateway::$registerAddress = $this->getRegisterAddress();
- if (!empty($imInfo['cs_user1_id'])) {
- $csUserIds[] = $imInfo['cs_user1_id'];
- if (Gateway::isUidOnline($imInfo['cs_user1_id'])) {
- $onlineUserIds[] = $imInfo['cs_user1_id'];
+ if (!empty($csInfo['user1_id'])) {
+ $csUserIds[] = $csInfo['user1_id'];
+ if (Gateway::isUidOnline($csInfo['user1_id'])) {
+ $onlineUserIds[] = $csInfo['user1_id'];
}
}
- if (!empty($imInfo['cs_user2_id'])) {
- $csUserIds[] = $imInfo['cs_user2_id'];
- if (Gateway::isUidOnline($imInfo['cs_user2_id'])) {
- $onlineUserIds[] = $imInfo['cs_user2_id'];
+ if (!empty($csInfo['user2_id'])) {
+ $csUserIds[] = $csInfo['user2_id'];
+ if (Gateway::isUidOnline($csInfo['user2_id'])) {
+ $onlineUserIds[] = $csInfo['user2_id'];
}
}
- if (!empty($imInfo['cs_user3_id'])) {
- $csUserIds[] = $imInfo['cs_user3_id'];
- if (Gateway::isUidOnline($imInfo['cs_user3_id'])) {
- $onlineUserIds[] = $imInfo['cs_user3_id'];
+ if (!empty($csInfo['user3_id'])) {
+ $csUserIds[] = $csInfo['user3_id'];
+ if (Gateway::isUidOnline($csInfo['user3_id'])) {
+ $onlineUserIds[] = $csInfo['user3_id'];
}
}
diff --git a/app/Http/Home/Services/ImFriendTrait.php b/app/Http/Home/Services/ImFriendTrait.php
index 1e807383..5731397b 100644
--- a/app/Http/Home/Services/ImFriendTrait.php
+++ b/app/Http/Home/Services/ImFriendTrait.php
@@ -11,17 +11,24 @@ use App\Repos\ImUser as ImUserRepo;
use App\Validators\ImFriendUser as ImFriendUserValidator;
use App\Validators\ImNotice as ImNoticeValidator;
use GatewayClient\Gateway;
+use Phalcon\Di;
+use Phalcon\Http\Request;
Trait ImFriendTrait
{
public function applyFriend()
{
+ /**
+ * @var Request $request
+ */
+ $request = Di::getDefault()->get('request');
+
$loginUser = $this->getLoginUser();
$user = $this->getImUser($loginUser->id);
- $post = $this->request->getPost();
+ $post = $request->getPost();
$validator = new ImFriendUserValidator();
@@ -37,12 +44,17 @@ Trait ImFriendTrait
public function acceptFriend()
{
+ /**
+ * @var Request $request
+ */
+ $request = Di::getDefault()->get('request');
+
$loginUser = $this->getLoginUser();
$user = $this->getImUser($loginUser->id);
- $noticeId = $this->request->getPost('notice_id');
- $groupId = $this->request->getPost('group_id');
+ $noticeId = $request->getPost('notice_id');
+ $groupId = $request->getPost('group_id');
$validator = new ImFriendUserValidator();
@@ -103,11 +115,16 @@ Trait ImFriendTrait
public function refuseFriend()
{
+ /**
+ * @var Request $request
+ */
+ $request = Di::getDefault()->get('request');
+
$loginUser = $this->getLoginUser();
$user = $this->getImUser($loginUser->id);
- $noticeId = $this->request->getPost('notice_id');
+ $noticeId = $request->getPost('notice_id');
$validator = new ImNoticeValidator();
diff --git a/app/Http/Home/Services/ImGroupTrait.php b/app/Http/Home/Services/ImGroupTrait.php
index 7cdf1a93..d411e4d6 100644
--- a/app/Http/Home/Services/ImGroupTrait.php
+++ b/app/Http/Home/Services/ImGroupTrait.php
@@ -13,35 +13,48 @@ use App\Validators\ImGroup as ImGroupValidator;
use App\Validators\ImGroupUser as ImGroupUserValidator;
use App\Validators\ImNotice as ImNoticeValidator;
use GatewayClient\Gateway;
+use Phalcon\Di;
+use Phalcon\Http\Request;
Trait ImGroupTrait
{
public function applyGroup()
{
+ /**
+ * @var Request $request
+ */
+ $request = Di::getDefault()->get('request');
+
$loginUser = $this->getLoginUser();
$user = $this->getImUser($loginUser->id);
- $post = $this->request->getPost();
-
$validator = new ImGroupUserValidator();
+ $post = $request->getPost();
+
$group = $validator->checkGroup($post['group_id']);
$remark = $validator->checkRemark($post['remark']);
$validator->checkIfJoined($group->id, $user->id);
+ $validator->checkIfAllowJoin($group->id, $user->id);
$this->handleApplyGroupNotice($user, $group, $remark);
}
public function acceptGroup()
{
+ /**
+ * @var Request $request
+ */
+ $request = Di::getDefault()->get('request');
+
$loginUser = $this->getLoginUser();
$user = $this->getImUser($loginUser->id);
- $noticeId = $this->request->getPost('notice_id', 'int');
+ $noticeId = $request->getPost('notice_id', 'int');
$validator = new ImNoticeValidator();
@@ -92,11 +105,16 @@ Trait ImGroupTrait
public function refuseGroup()
{
+ /**
+ * @var Request $request
+ */
+ $request = Di::getDefault()->get('request');
+
$loginUser = $this->getLoginUser();
$user = $this->getImUser($loginUser->id);
- $noticeId = $this->request->getPost('notice_id', 'int');
+ $noticeId = $request->getPost('notice_id', 'int');
$validator = new ImNoticeValidator();
diff --git a/app/Http/Home/Views/im/group/show.volt b/app/Http/Home/Views/im/group/show.volt
index 9b87b338..885f6451 100644
--- a/app/Http/Home/Views/im/group/show.volt
+++ b/app/Http/Home/Views/im/group/show.volt
@@ -3,7 +3,6 @@
{% block content %}
{% set group.about = group.about ? group.about : '这个家伙真懒,什么都没有留下~' %}
- {% set apply_group_url = '' %}
{% set users_url = url({'for':'home.group.users','id':group.id}) %}
{% set active_users_url = url({'for':'home.group.active_users','id':group.id}) %}
diff --git a/app/Library/Sitemap.php b/app/Library/Sitemap.php
index 26dd7728..02e7fdd9 100644
--- a/app/Library/Sitemap.php
+++ b/app/Library/Sitemap.php
@@ -24,7 +24,7 @@ class Sitemap
* @param string $changefreq 更新频率的单位
* @param string $lastmod 日期格式 YYYY-MM-DD
*/
- function addItem($loc, $priority = null, $changefreq = null, $lastmod = null)
+ public function addItem($loc, $priority = null, $changefreq = null, $lastmod = null)
{
$this->items[] = array(
'loc' => $loc,
@@ -38,7 +38,7 @@ class Sitemap
* @param string $filename
* @return mixed
*/
- function build($filename = null)
+ public function build($filename = null)
{
$xml = '' . "\n";
$xml .= '' . "\n";
diff --git a/app/Repos/ImGroup.php b/app/Repos/ImGroup.php
index 1f8b05b0..7265b426 100644
--- a/app/Repos/ImGroup.php
+++ b/app/Repos/ImGroup.php
@@ -79,6 +79,18 @@ class ImGroup extends Repository
return ImGroupModel::findFirst($id);
}
+ /**
+ * @param int $courseId
+ * @return ImGroupModel|Model|bool
+ */
+ public function findByCourseId($courseId)
+ {
+ return ImGroupModel::findFirst([
+ 'conditions' => 'course_id = :course_id:',
+ 'bind' => ['course_id' => $courseId],
+ ]);
+ }
+
/**
* @param array $ids
* @param string|array $columns
diff --git a/app/Services/Live.php b/app/Services/Live.php
index 539a24be..fc0f08ad 100644
--- a/app/Services/Live.php
+++ b/app/Services/Live.php
@@ -271,7 +271,7 @@ class Live extends Service
return http_build_query([
'txSecret' => $txSecret,
- 'txTime' => $txTime
+ 'txTime' => $txTime,
]);
}
diff --git a/app/Services/LiveNotify.php b/app/Services/LiveNotify.php
index c2c8daee..051172d4 100644
--- a/app/Services/LiveNotify.php
+++ b/app/Services/LiveNotify.php
@@ -162,9 +162,13 @@ class LiveNotify extends Service
*/
protected function checkSign($sign, $time)
{
- if (!$sign || !$time) return false;
+ if (!$sign || !$time) {
+ return false;
+ }
- if ($time < time()) return false;
+ if ($time < time()) {
+ return false;
+ }
$notify = $this->getSettings('live.notify');
diff --git a/app/Services/Logic/Chapter/ChapterInfo.php b/app/Services/Logic/Chapter/ChapterInfo.php
index 31245ba5..fe8cd5d8 100644
--- a/app/Services/Logic/Chapter/ChapterInfo.php
+++ b/app/Services/Logic/Chapter/ChapterInfo.php
@@ -6,8 +6,10 @@ use App\Models\Chapter as ChapterModel;
use App\Models\ChapterUser as ChapterUserModel;
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\ChapterLike as ChapterLikeRepo;
+use App\Repos\ImGroup as ImGroupRepo;
use App\Services\Logic\ChapterTrait;
use App\Services\Logic\CourseTrait;
use App\Services\Logic\Service;
@@ -114,6 +116,17 @@ class ChapterInfo extends Service
$this->joinedCourse = true;
+ $groupRepo = new ImGroupRepo();
+
+ $group = $groupRepo->findByCourseId($course->id);
+
+ $groupUser = new ImGroupUserModel();
+
+ $groupUser->group_id = $group->id;
+ $groupUser->user_id = $user->id;
+
+ $groupUser->create();
+
$this->incrCourseUserCount($course);
$this->incrUserCourseCount($user);
diff --git a/app/Services/Mail/Verify.php b/app/Services/Mail/Verify.php
index 199183bb..6709a1ca 100644
--- a/app/Services/Mail/Verify.php
+++ b/app/Services/Mail/Verify.php
@@ -22,7 +22,7 @@ class Verify extends MailerService
$minutes = 5;
- $code = $verify->getEmailCode($email, 60 * $minutes);
+ $code = $verify->getMailCode($email, 60 * $minutes);
$subject = '邮件验证码';
diff --git a/app/Services/MyStorage.php b/app/Services/MyStorage.php
index 7ac2c478..e6d6ca74 100644
--- a/app/Services/MyStorage.php
+++ b/app/Services/MyStorage.php
@@ -106,7 +106,7 @@ class MyStorage extends Storage
*
* @param string $prefix
* @param string $mimeType
- * @param string $uploadType
+ * @param int $uploadType
* @return UploadModel|bool
*/
protected function upload($prefix, $mimeType, $uploadType)
diff --git a/app/Services/Pay/AlipayGateway.php b/app/Services/Pay/AlipayGateway.php
index 40fa26e1..e686be2f 100644
--- a/app/Services/Pay/AlipayGateway.php
+++ b/app/Services/Pay/AlipayGateway.php
@@ -42,9 +42,10 @@ class AlipayGateway extends Service
$options = [
'app_id' => $this->settings['app_id'],
- 'ali_public_key' => $this->settings['public_key'],
'private_key' => $this->settings['private_key'],
- 'return_url' => $this->settings['return_url'],
+ 'ali_public_key' => config_path('alipay/alipayCertPublicKey.crt'), // 支付宝公钥证书
+ 'alipay_root_cert' => config_path('alipay/alipayRootCert.crt'), // 支付宝根证书
+ 'app_cert_public_key' => config_path('alipay/appCertPublicKey.crt'), // 应用公钥证书
'notify_url' => $this->settings['notify_url'],
'log' => [
'file' => log_path('alipay.log'),
diff --git a/app/Services/Smser.php b/app/Services/Smser.php
index 6a4d2efd..d0b26985 100644
--- a/app/Services/Smser.php
+++ b/app/Services/Smser.php
@@ -37,6 +37,8 @@ Abstract class Smser extends Service
{
$sender = $this->createSingleSender();
+ $params = $this->formatParams($params);
+
$signature = $this->getSignature();
try {
@@ -71,6 +73,17 @@ Abstract class Smser extends Service
return new SmsSingleSender($this->settings['app_id'], $this->settings['app_key']);
}
+ protected function formatParams($params)
+ {
+ if (!empty($params)) {
+ $params = array_map(function ($value) {
+ return strval($value);
+ }, $params);
+ }
+
+ return $params;
+ }
+
protected function getTemplateId($code)
{
$template = json_decode($this->settings['template'], true);
diff --git a/app/Services/Storage.php b/app/Services/Storage.php
index 1f723851..cb7e4d31 100644
--- a/app/Services/Storage.php
+++ b/app/Services/Storage.php
@@ -173,7 +173,7 @@ class Storage extends Service
*/
protected function generateFileName($extension = '', $prefix = '')
{
- $randName = date('YmdHis') . rand(1000, 9999);
+ $randName = date('YmdHis') . rand(100, 999) . rand(100, 999);
return $prefix . $randName . '.' . $extension;
}
diff --git a/app/Services/Throttle.php b/app/Services/Throttle.php
index 1d0d0e33..7a5f4140 100644
--- a/app/Services/Throttle.php
+++ b/app/Services/Throttle.php
@@ -49,7 +49,7 @@ class Throttle extends Service
return md5($httpHost . '|' . $clientAddress);
}
- throw new \RuntimeException('Unable to generate the request signature.');
+ throw new \RuntimeException('Unable to generate request signature');
}
protected function getCacheKey($sign)
diff --git a/app/Services/Verify.php b/app/Services/Verify.php
index 171e636b..da1afe8e 100644
--- a/app/Services/Verify.php
+++ b/app/Services/Verify.php
@@ -29,9 +29,9 @@ class Verify extends Service
return $code;
}
- public function getEmailCode($email, $lifetime = 300)
+ public function getMailCode($email, $lifetime = 300)
{
- $key = $this->getEmailCacheKey($email);
+ $key = $this->getMailCacheKey($email);
$code = Text::random(Text::RANDOM_NUMERIC, 6);
@@ -49,18 +49,18 @@ class Verify extends Service
return $code == $value;
}
- public function checkEmailCode($email, $code)
+ public function checkMailCode($email, $code)
{
- $key = $this->getEmailCacheKey($email);
+ $key = $this->getMailCacheKey($email);
$value = $this->cache->get($key);
return $code == $value;
}
- protected function getEmailCacheKey($email)
+ protected function getMailCacheKey($email)
{
- return "verify:email:{$email}";
+ return "verify:mail:{$email}";
}
protected function getSmsCacheKey($phone)
diff --git a/app/Services/Vod.php b/app/Services/Vod.php
index 82f50680..d30351bd 100644
--- a/app/Services/Vod.php
+++ b/app/Services/Vod.php
@@ -8,9 +8,10 @@ use TencentCloud\Common\Exception\TencentCloudSDKException;
use TencentCloud\Common\Profile\ClientProfile;
use TencentCloud\Common\Profile\HttpProfile;
use TencentCloud\Vod\V20180717\Models\ConfirmEventsRequest;
-use TencentCloud\Vod\V20180717\Models\DescribeAudioTrackTemplatesRequest;
+use TencentCloud\Vod\V20180717\Models\DeleteMediaRequest;
use TencentCloud\Vod\V20180717\Models\DescribeMediaInfosRequest;
use TencentCloud\Vod\V20180717\Models\DescribeTaskDetailRequest;
+use TencentCloud\Vod\V20180717\Models\DescribeTranscodeTemplatesRequest;
use TencentCloud\Vod\V20180717\Models\ProcessMediaRequest;
use TencentCloud\Vod\V20180717\Models\PullEventsRequest;
use TencentCloud\Vod\V20180717\VodClient;
@@ -53,21 +54,21 @@ class Vod extends Service
{
try {
- $request = new DescribeAudioTrackTemplatesRequest();
+ $request = new DescribeTranscodeTemplatesRequest();
$params = '{}';
$request->fromJsonString($params);
- $response = $this->client->DescribeAudioTrackTemplates($request);
+ $response = $this->client->DescribeTranscodeTemplates($request);
- $this->logger->debug('Describe Audio Track Templates Response ' . $response->toJsonString());
+ $this->logger->debug('Describe Transcode Templates Response ' . $response->toJsonString());
$result = $response->TotalCount > 0;
} catch (TencentCloudSDKException $e) {
- $this->logger->error('Describe Audio Track Templates Exception ' . kg_json_encode([
+ $this->logger->error('Describe Transcode Templates Exception ' . kg_json_encode([
'code' => $e->getErrorCode(),
'message' => $e->getMessage(),
'requestId' => $e->getRequestId(),
@@ -274,6 +275,44 @@ class Vod extends Service
return $result;
}
+ /**
+ * 删除媒体
+ *
+ * @param string $fileId
+ * @return bool
+ */
+ public function deleteMedia($fileId)
+ {
+ try {
+
+ $request = new DeleteMediaRequest();
+
+ $params = json_encode(['FileId' => $fileId]);
+
+ $request->fromJsonString($params);
+
+ $this->logger->debug('Delete Media Request ' . $params);
+
+ $response = $this->client->DeleteMedia($request);
+
+ $this->logger->debug('Delete Media Response ' . $response->toJsonString());
+
+ $result = !empty($response->RequestId);
+
+ } catch (TencentCloudSDKException $e) {
+
+ $this->logger->error('Delete Media Exception ' . kg_json_encode([
+ 'code' => $e->getErrorCode(),
+ 'message' => $e->getMessage(),
+ 'requestId' => $e->getRequestId(),
+ ]));
+
+ $result = false;
+ }
+
+ return $result;
+ }
+
/**
* 获取媒体信息
*
@@ -574,7 +613,7 @@ class Vod extends Service
{
$result = null;
- if ($this->settings['wmk_enabled'] && $this->settings['wmk_tpl_id'] > 0) {
+ if ($this->settings['wmk_enabled'] == 1 && $this->settings['wmk_tpl_id'] > 0) {
$result = (int)$this->settings['wmk_tpl_id'];
}
diff --git a/app/Validators/Account.php b/app/Validators/Account.php
index 08afc337..0bc8e8e7 100644
--- a/app/Validators/Account.php
+++ b/app/Validators/Account.php
@@ -67,7 +67,7 @@ class Account extends Validator
public function checkPassword($password)
{
if (!CommonValidator::password($password)) {
- throw new BadRequestException('account.invalid_password');
+ throw new BadRequestException('account.invalid_pwd');
}
return $password;
@@ -76,7 +76,7 @@ class Account extends Validator
public function checkConfirmPassword($newPassword, $confirmPassword)
{
if ($newPassword != $confirmPassword) {
- throw new BadRequestException('account.password_not_match');
+ throw new BadRequestException('account.pwd_not_match');
}
}
@@ -85,7 +85,7 @@ class Account extends Validator
$hash = PasswordUtil::hash($password, $account->salt);
if ($hash != $account->password) {
- throw new BadRequestException('account.origin_password_incorrect');
+ throw new BadRequestException('account.origin_pwd_incorrect');
}
}
@@ -94,7 +94,7 @@ class Account extends Validator
$hash = PasswordUtil::hash($password, $account->salt);
if ($hash != $account->password) {
- throw new BadRequestException('account.login_password_incorrect');
+ throw new BadRequestException('account.login_pwd_incorrect');
}
}
@@ -140,7 +140,7 @@ class Account extends Validator
$hash = PasswordUtil::hash($password, $account->salt);
if ($hash != $account->password) {
- throw new BadRequestException('account.login_password_incorrect');
+ throw new BadRequestException('account.login_pwd_incorrect');
}
$userRepo = new UserRepo();
diff --git a/app/Validators/ImGroupUser.php b/app/Validators/ImGroupUser.php
index e262aa3e..676e0633 100644
--- a/app/Validators/ImGroupUser.php
+++ b/app/Validators/ImGroupUser.php
@@ -3,7 +3,13 @@
namespace App\Validators;
use App\Exceptions\BadRequest as BadRequestException;
+use App\Models\ImGroup as ImGroupModel;
+use App\Models\User as UserModel;
+use App\Repos\Course as CourseRepo;
+use App\Repos\CourseUser as CourseUserRepo;
+use App\Repos\ImGroup as ImGroupRepo;
use App\Repos\ImGroupUser as ImGroupUserRepo;
+use App\Repos\User as UserRepo;
class ImGroupUser extends Validator
{
@@ -59,4 +65,39 @@ class ImGroupUser extends Validator
}
}
+ public function checkIfAllowJoin($groupId, $userId)
+ {
+ $message = 'im_group_user.join_not_allowed';
+
+ $groupRepo = new ImGroupRepo();
+ $group = $groupRepo->findById($groupId);
+
+ $userRepo = new UserRepo();
+ $user = $userRepo->findById($userId);
+
+ $staff = $user->admin_role > 0 || $user->edu_role == UserModel::EDU_ROLE_TEACHER;
+
+ if ($group->type == ImGroupModel::TYPE_STAFF && !$staff) {
+ throw new BadRequestException($message);
+ }
+
+ if ($group->course_id > 0) {
+
+ $courseRepo = new CourseRepo();
+ $course = $courseRepo->findById($group->course_id);
+
+ $courseUserRepo = new CourseUserRepo();
+ $courseUser = $courseUserRepo->findCourseUser($course->id, $user->id);
+
+ if ($course->market_price > 0) {
+ if ($course->vip_price > 0 && !$courseUser) {
+ throw new BadRequestException($message);
+ }
+ if ($course->vip_price == 0 && $user->vip == 0) {
+ throw new BadRequestException($message);
+ }
+ }
+ }
+ }
+
}
diff --git a/app/Validators/Validator.php b/app/Validators/Validator.php
index 99f95dba..2f3a8091 100644
--- a/app/Validators/Validator.php
+++ b/app/Validators/Validator.php
@@ -9,9 +9,9 @@ use Phalcon\Mvc\User\Component;
class Validator extends Component
{
- public function checkAuthUser($authUser)
+ public function checkAuthUser($authInfo)
{
- if (empty($authUser['id'])) {
+ if (empty($authInfo['id'])) {
throw new UnauthorizedException('sys.unauthorized');
}
}
diff --git a/app/Validators/Verify.php b/app/Validators/Verify.php
index 9c8e4e78..360616f8 100644
--- a/app/Validators/Verify.php
+++ b/app/Validators/Verify.php
@@ -30,11 +30,11 @@ class Verify extends Validator
public function checkCode($identity, $code)
{
if (CommonValidator::email($identity)) {
- $this->checkEmailCode($identity, $code);
+ $this->checkMailCode($identity, $code);
} elseif (CommonValidator::phone($identity)) {
$this->checkSmsCode($identity, $code);
} else {
- throw new BadRequestException('verify.unsupported_identity');
+ throw new BadRequestException('verify.invalid_code');
}
}
@@ -49,14 +49,14 @@ class Verify extends Validator
}
}
- public function checkEmailCode($email, $code)
+ public function checkMailCode($email, $code)
{
$service = new VerifyService();
- $result = $service->checkEmailCode($email, $code);
+ $result = $service->checkMailCode($email, $code);
if (!$result) {
- throw new BadRequestException('verify.invalid_email_code');
+ throw new BadRequestException('verify.invalid_mail_code');
}
}
diff --git a/bootstrap/ConsoleErrorHandler.php b/bootstrap/ConsoleErrorHandler.php
index c6a25826..45060b2c 100644
--- a/bootstrap/ConsoleErrorHandler.php
+++ b/bootstrap/ConsoleErrorHandler.php
@@ -27,17 +27,13 @@ class ConsoleErrorHandler extends Component
*/
public function handleException($e)
{
- $config = $this->getConfig();
-
$logger = $this->getLogger();
$content = sprintf('%s(%d): %s', $e->getFile(), $e->getLine(), $e->getMessage());
$logger->error($content);
- if ($config->get('env') == ENV_DEV) {
- echo $content;
- }
+ echo $content . PHP_EOL;
}
/**
@@ -45,7 +41,7 @@ class ConsoleErrorHandler extends Component
*/
protected function getConfig()
{
- return $this->getDI()->get('config');
+ return $this->getDI()->getShared('config');
}
/**
diff --git a/bootstrap/ConsoleKernel.php b/bootstrap/ConsoleKernel.php
index b531a253..9bb01233 100644
--- a/bootstrap/ConsoleKernel.php
+++ b/bootstrap/ConsoleKernel.php
@@ -26,8 +26,8 @@ class ConsoleKernel extends Kernel
$this->loader = new Loader();
$this->initAppEnv();
- $this->initAppConfigs();
- $this->initAppSettings();
+ $this->initAppConfig();
+ $this->initAppSetting();
$this->registerLoaders();
$this->registerServices();
$this->registerErrorHandler();
diff --git a/bootstrap/Helper.php b/bootstrap/Helper.php
index 42b8fdde..240acb1c 100644
--- a/bootstrap/Helper.php
+++ b/bootstrap/Helper.php
@@ -115,7 +115,7 @@ function tmp_path($path = '')
}
/**
- * Rtrim slash
+ * Trim path slash
*
* @param string $path
* @return string
diff --git a/bootstrap/HttpKernel.php b/bootstrap/HttpKernel.php
index 5598eb84..648c905b 100644
--- a/bootstrap/HttpKernel.php
+++ b/bootstrap/HttpKernel.php
@@ -35,8 +35,8 @@ class HttpKernel extends Kernel
$this->loader = new Loader();
$this->initAppEnv();
- $this->initAppConfigs();
- $this->initAppSettings();
+ $this->initAppConfig();
+ $this->initAppSetting();
$this->registerLoaders();
$this->registerServices();
$this->registerModules();
diff --git a/bootstrap/Kernel.php b/bootstrap/Kernel.php
index 5e1bea07..5cb8c9db 100644
--- a/bootstrap/Kernel.php
+++ b/bootstrap/Kernel.php
@@ -27,7 +27,7 @@ abstract class Kernel
/**
* @var array
*/
- protected $configs = [];
+ protected $config = [];
public function getApp()
{
@@ -44,16 +44,16 @@ abstract class Kernel
require __DIR__ . '/Helper.php';
}
- protected function initAppConfigs()
+ protected function initAppConfig()
{
- $this->configs = require config_path('config.php');
+ $this->config = require config_path('config.php');
}
- protected function initAppSettings()
+ protected function initAppSetting()
{
- ini_set('date.timezone', $this->configs['timezone']);
+ ini_set('date.timezone', $this->config['timezone']);
- if ($this->configs['env'] == ENV_DEV) {
+ if ($this->config['env'] == ENV_DEV) {
ini_set('display_errors', 1);
error_reporting(E_ALL);
} else {
diff --git a/config/errors.php b/config/errors.php
index 3a80b3f5..94e90723 100644
--- a/config/errors.php
+++ b/config/errors.php
@@ -26,10 +26,11 @@ $error['security.invalid_http_referer'] = '无效请求来源';
*/
$error['verify.invalid_phone'] = '无效手机号';
$error['verify.invalid_email'] = '无效的邮箱';
+$error['verify.invalid_code'] = '无效的验证码';
$error['verify.invalid_sms_code'] = '无效的短信验证码';
-$error['verify.invalid_email_code'] = '无效的邮件验证码';
-$error['verify.send_sms_failed'] = '发送短信验证码失败';
-$error['verify.send_email_failed'] = '发送邮件验证码失败';
+$error['verify.invalid_mail_code'] = '无效的邮件验证码';
+$error['verify.send_sms_failed'] = '发送短信失败';
+$error['verify.send_mail_failed'] = '发送邮件失败';
/**
* captcha相关
@@ -41,16 +42,16 @@ $error['captcha.invalid_code'] = '无效的验证码';
*/
$error['account.not_found'] = '账号不存在';
$error['account.login_block'] = '账号被锁定,无法登录';
-$error['account.login_password_incorrect'] = '登录密码不正确';
+$error['account.login_pwd_incorrect'] = '登录密码不正确';
$error['account.invalid_login_name'] = '无效的登录名';
$error['account.invalid_email'] = '无效的电子邮箱';
$error['account.invalid_phone'] = '无效的手机号';
-$error['account.invalid_password'] = '无效的密码(字母或数字6-16位)';
+$error['account.invalid_pwd'] = '无效的密码(字母或数字6-16位)';
$error['account.email_taken'] = '邮箱被占用';
$error['account.phone_taken'] = '手机号被占用';
-$error['account.password_not_match'] = '密码不匹配';
-$error['account.origin_password_incorrect'] = '原有密码不正确';
-$error['account.login_password_incorrect'] = '登录密码不正确';
+$error['account.pwd_not_match'] = '密码不匹配';
+$error['account.origin_pwd_incorrect'] = '原有密码不正确';
+$error['account.login_pwd_incorrect'] = '登录密码不正确';
/**
* 用户相关
@@ -341,6 +342,7 @@ $error['im_group.invalid_publish_status'] = '无效的发布状态';
$error['im_group_user.not_found'] = '群组关系不存在';
$error['im_group_user.remark_too_long'] = '验证信息太长(超过30字符)';
$error['im_group_user.has_joined'] = '已经加入过群组';
+$error['im_group_user.join_not_allowed'] = '当前不允许加入群组';
$error['im_friend_user.not_found'] = '好友关系不存在';
$error['im_friend_user.remark_too_long'] = '验证信息太长(超过30字符)';
diff --git a/db/migrations/20200827063842_init_table.php b/db/migrations/20200827063842_init_table.php
index e202ca88..f11f2b42 100644
--- a/db/migrations/20200827063842_init_table.php
+++ b/db/migrations/20200827063842_init_table.php
@@ -3668,10 +3668,6 @@ class InitTable extends Phinx\Migration\AbstractMigration
'limit' => MysqlAdapter::INT_REGULAR,
'after' => 'create_time',
])
- ->addIndex(['item_type', 'status'], [
- 'name' => 'type_status',
- 'unique' => false,
- ])
->create();
$this->table('kg_topic', [
'id' => false,
@@ -3816,7 +3812,7 @@ class InitTable extends Phinx\Migration\AbstractMigration
->addColumn('channel_sn', 'string', [
'null' => false,
'default' => '',
- 'limit' => 32,
+ 'limit' => 64,
'collation' => 'utf8mb4_general_ci',
'encoding' => 'utf8mb4',
'comment' => '平台序号',
diff --git a/db/migrations/schema.php b/db/migrations/schema.php
index adbdfff9..b43fdd28 100644
--- a/db/migrations/schema.php
+++ b/db/migrations/schema.php
@@ -12983,39 +12983,6 @@ return array(
'Index_comment' => '',
),
),
- 'type_status' =>
- array(
- 1 =>
- array(
- 'Table' => 'kg_task',
- 'Non_unique' => '1',
- 'Key_name' => 'type_status',
- 'Seq_in_index' => '1',
- 'Column_name' => 'item_type',
- 'Collation' => 'A',
- 'Sub_part' => NULL,
- 'Packed' => NULL,
- 'Null' => '',
- 'Index_type' => 'BTREE',
- 'Comment' => '',
- 'Index_comment' => '',
- ),
- 2 =>
- array(
- 'Table' => 'kg_task',
- 'Non_unique' => '1',
- 'Key_name' => 'type_status',
- 'Seq_in_index' => '2',
- 'Column_name' => 'status',
- 'Collation' => 'A',
- 'Sub_part' => NULL,
- 'Packed' => NULL,
- 'Null' => '',
- 'Index_type' => 'BTREE',
- 'Comment' => '',
- 'Index_comment' => '',
- ),
- ),
),
'foreign_keys' => NULL,
),