mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-07-24 00:41:43 +08:00
支付宝支付调整成公钥证书模式
This commit is contained in:
parent
b199368c73
commit
c886434ccc
@ -3,10 +3,13 @@
|
||||
namespace App\Console\Tasks;
|
||||
|
||||
use App\Models\CourseUser as CourseUserModel;
|
||||
use App\Models\ImGroupUser as ImGroupUserModel;
|
||||
use App\Models\Order as OrderModel;
|
||||
use App\Models\Refund as RefundModel;
|
||||
use App\Models\Task as TaskModel;
|
||||
use App\Models\Trade as TradeModel;
|
||||
use App\Repos\ImGroup as ImGroupRepo;
|
||||
use App\Repos\ImGroupUser as ImGroupUserRepo;
|
||||
use App\Repos\Order as OrderRepo;
|
||||
use App\Repos\User as UserRepo;
|
||||
use App\Services\Sms\Order as OrderSms;
|
||||
@ -104,19 +107,36 @@ class DeliverTask extends Task
|
||||
*/
|
||||
$itemInfo = $order->item_info;
|
||||
|
||||
$data = [
|
||||
'user_id' => $order->owner_id,
|
||||
'course_id' => $order->item_id,
|
||||
'expiry_time' => $itemInfo['course']['study_expiry_time'],
|
||||
'role_type' => CourseUserModel::ROLE_STUDENT,
|
||||
'source_type' => CourseUserModel::SOURCE_CHARGE,
|
||||
];
|
||||
|
||||
$courseUser = new CourseUserModel();
|
||||
|
||||
if ($courseUser->create($data) === false) {
|
||||
$courseUser->user_id = $order->owner_id;
|
||||
$courseUser->course_id = $order->item_id;
|
||||
$courseUser->expiry_time = $itemInfo['course']['study_expiry_time'];
|
||||
$courseUser->role_type = CourseUserModel::ROLE_STUDENT;
|
||||
$courseUser->source_type = CourseUserModel::SOURCE_CHARGE;
|
||||
|
||||
if ($courseUser->create() === false) {
|
||||
throw new \RuntimeException('Create Course User Failed');
|
||||
}
|
||||
|
||||
$groupRepo = new ImGroupRepo();
|
||||
|
||||
$group = $groupRepo->findByCourseId($order->item_id);
|
||||
|
||||
$groupUserRepo = new ImGroupUserRepo();
|
||||
|
||||
$groupUser = $groupUserRepo->findGroupUser($group->id, $order->owner_id);
|
||||
|
||||
if ($groupUser) return;
|
||||
|
||||
$groupUser = new ImGroupUserModel();
|
||||
|
||||
$groupUser->group_id = $group->id;
|
||||
$groupUser->user_id = $order->owner_id;
|
||||
|
||||
if ($groupUser->create() === false) {
|
||||
throw new \RuntimeException('Create Group User Failed');
|
||||
}
|
||||
}
|
||||
|
||||
protected function handlePackageOrder(OrderModel $order)
|
||||
@ -128,33 +148,50 @@ class DeliverTask extends Task
|
||||
|
||||
foreach ($itemInfo['courses'] as $course) {
|
||||
|
||||
$data = [
|
||||
'user_id' => $order->owner_id,
|
||||
'course_id' => $course['id'],
|
||||
'expiry_time' => $course['study_expiry_time'],
|
||||
'role_type' => CourseUserModel::ROLE_STUDENT,
|
||||
'source_type' => CourseUserModel::SOURCE_CHARGE,
|
||||
];
|
||||
|
||||
$courseUser = new CourseUserModel();
|
||||
|
||||
if ($courseUser->create($data) === false) {
|
||||
$courseUser->user_id = $order->owner_id;
|
||||
$courseUser->course_id = $course['id'];
|
||||
$courseUser->expiry_time = $course['study_expiry_time'];
|
||||
$courseUser->role_type = CourseUserModel::ROLE_STUDENT;
|
||||
$courseUser->source_type = CourseUserModel::SOURCE_CHARGE;
|
||||
|
||||
if ($courseUser->create() === false) {
|
||||
throw new \RuntimeException('Create Course User Failed');
|
||||
}
|
||||
|
||||
$groupRepo = new ImGroupRepo();
|
||||
|
||||
$group = $groupRepo->findByCourseId($course['id']);
|
||||
|
||||
$groupUserRepo = new ImGroupUserRepo();
|
||||
|
||||
$groupUser = $groupUserRepo->findGroupUser($group->id, $order->owner_id);
|
||||
|
||||
if ($groupUser) continue;
|
||||
|
||||
$groupUser = new ImGroupUserModel();
|
||||
|
||||
$groupUser->group_id = $group->id;
|
||||
$groupUser->user_id = $order->owner_id;
|
||||
|
||||
if ($groupUser->create() === false) {
|
||||
throw new \RuntimeException('Create Group User Failed');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function handleVipOrder(OrderModel $order)
|
||||
{
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$user = $userRepo->findById($order->owner_id);
|
||||
|
||||
/**
|
||||
* @var array $itemInfo
|
||||
*/
|
||||
$itemInfo = $order->item_info;
|
||||
|
||||
$userRepo = new UserRepo();
|
||||
|
||||
$user = $userRepo->findById($order->owner_id);
|
||||
|
||||
$user->vip_expiry_time = $itemInfo['vip']['expiry_time'];
|
||||
|
||||
if ($user->update() === false) {
|
||||
|
@ -30,8 +30,8 @@ abstract class PayTest extends Service
|
||||
|
||||
$order = new OrderModel();
|
||||
|
||||
$order->subject = '测试 - 支付测试3.01元';
|
||||
$order->amount = 3.01;
|
||||
$order->subject = '测试 - 支付测试0.01元';
|
||||
$order->amount = 0.01;
|
||||
$order->owner_id = $authUser['id'];
|
||||
$order->item_type = OrderModel::ITEM_TEST;
|
||||
|
||||
@ -59,7 +59,7 @@ abstract class PayTest extends Service
|
||||
$order = new OrderModel();
|
||||
|
||||
/**
|
||||
* 微信沙箱环境金额不能自定义,只能是测试用例值(沙吊的不行)
|
||||
* 微信沙箱环境金额不能自定义,只能是固定测试用例值(SB的不行)
|
||||
*/
|
||||
if ($config->get('env') == ENV_DEV) {
|
||||
$order->subject = '测试 - 支付测试3.01元';
|
||||
|
@ -12,13 +12,6 @@
|
||||
<input class="layui-input" type="text" name="app_id" value="{{ alipay.app_id }}" lay-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">Public Key</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea class="layui-textarea" name="public_key" lay-verify="required">{{ alipay.public_key }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">Private Key</label>
|
||||
<div class="layui-input-block">
|
||||
|
@ -1,6 +1,6 @@
|
||||
{% extends 'templates/main.volt' %}
|
||||
|
||||
{% block contnet %}
|
||||
{% block content %}
|
||||
|
||||
<div class="kg-qrcode-block">
|
||||
{% if qrcode %}
|
||||
|
@ -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'];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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}) %}
|
||||
|
||||
|
@ -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 = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
||||
$xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
|
||||
|
@ -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
|
||||
|
@ -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');
|
||||
|
||||
|
@ -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);
|
||||
|
@ -22,7 +22,7 @@ class Verify extends MailerService
|
||||
|
||||
$minutes = 5;
|
||||
|
||||
$code = $verify->getEmailCode($email, 60 * $minutes);
|
||||
$code = $verify->getMailCode($email, 60 * $minutes);
|
||||
|
||||
$subject = '邮件验证码';
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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'),
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ class ConsoleErrorHandler extends Component
|
||||
*/
|
||||
protected function getConfig()
|
||||
{
|
||||
return $this->getDI()->get('config');
|
||||
return $this->getDI()->getShared('config');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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();
|
||||
|
@ -115,7 +115,7 @@ function tmp_path($path = '')
|
||||
}
|
||||
|
||||
/**
|
||||
* Rtrim slash
|
||||
* Trim path slash
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
|
@ -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();
|
||||
|
@ -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 {
|
||||
|
@ -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字符)';
|
||||
|
@ -3816,7 +3816,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' => '平台序号',
|
||||
|
Loading…
x
Reference in New Issue
Block a user