mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-25 12:09:09 +08:00
1.调整微信公众号模板消息
This commit is contained in:
parent
e03dcad201
commit
1e679cb24c
@ -121,17 +121,6 @@ class ConnectController extends Controller
|
|||||||
|
|
||||||
$openUser = $service->getOpenUserInfo($code, $state, $provider);
|
$openUser = $service->getOpenUserInfo($code, $state, $provider);
|
||||||
|
|
||||||
/**
|
|
||||||
* 微信扫码登录检查是否关注过公众号,关注过直接登录
|
|
||||||
*/
|
|
||||||
if ($provider == ConnectModel::PROVIDER_WEIXIN && !empty($openUser['unionid'])) {
|
|
||||||
$subscribe = $service->getWeChatSubscribe($openUser['unionid']);
|
|
||||||
if ($subscribe && $subscribe->deleted == 0) {
|
|
||||||
$service->authSubscribeLogin($subscribe);
|
|
||||||
return $this->response->redirect(['for' => 'home.index']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$connect = $service->getConnectRelation($openUser['id'], $openUser['provider']);
|
$connect = $service->getConnectRelation($openUser['id'], $openUser['provider']);
|
||||||
|
|
||||||
if ($this->authUser->id > 0) {
|
if ($this->authUser->id > 0) {
|
||||||
@ -148,6 +137,8 @@ class ConnectController extends Controller
|
|||||||
|
|
||||||
$captcha = $service->getSettings('captcha');
|
$captcha = $service->getSettings('captcha');
|
||||||
|
|
||||||
|
$this->seo->prependTitle('绑定帐号');
|
||||||
|
|
||||||
$this->view->pick('connect/bind');
|
$this->view->pick('connect/bind');
|
||||||
$this->view->setVar('captcha', $captcha);
|
$this->view->setVar('captcha', $captcha);
|
||||||
$this->view->setVar('provider', $provider);
|
$this->view->setVar('provider', $provider);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Home\Controllers;
|
namespace App\Http\Home\Controllers;
|
||||||
|
|
||||||
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
|
use App\Http\Home\Services\UserConsole as HomeUserConsoleService;
|
||||||
use App\Services\Logic\Account\OAuthProvider as OAuthProviderService;
|
use App\Services\Logic\Account\OAuthProvider as OAuthProviderService;
|
||||||
use App\Services\Logic\User\Console\AccountInfo as AccountInfoService;
|
use App\Services\Logic\User\Console\AccountInfo as AccountInfoService;
|
||||||
use App\Services\Logic\User\Console\AnswerList as AnswerListService;
|
use App\Services\Logic\User\Console\AnswerList as AnswerListService;
|
||||||
@ -117,6 +117,10 @@ class UserConsoleController extends Controller
|
|||||||
|
|
||||||
$connects = $service->handle();
|
$connects = $service->handle();
|
||||||
|
|
||||||
|
$service = new HomeUserConsoleService();
|
||||||
|
|
||||||
|
$wechatOAConnect = $service->getWeChatOAConnect();
|
||||||
|
|
||||||
if ($type == 'info') {
|
if ($type == 'info') {
|
||||||
$this->view->pick('user/console/account_info');
|
$this->view->pick('user/console/account_info');
|
||||||
} elseif ($type == 'phone') {
|
} elseif ($type == 'phone') {
|
||||||
@ -127,6 +131,7 @@ class UserConsoleController extends Controller
|
|||||||
$this->view->pick('user/console/account_password');
|
$this->view->pick('user/console/account_password');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->view->setVar('wechat_oa_connected', $wechatOAConnect ? 1 : 0);
|
||||||
$this->view->setVar('oauth_provider', $oauthProvider);
|
$this->view->setVar('oauth_provider', $oauthProvider);
|
||||||
$this->view->setVar('connects', $connects);
|
$this->view->setVar('connects', $connects);
|
||||||
$this->view->setVar('captcha', $captcha);
|
$this->view->setVar('captcha', $captcha);
|
||||||
@ -293,21 +298,6 @@ class UserConsoleController extends Controller
|
|||||||
$this->view->setVar('pager', $pager);
|
$this->view->setVar('pager', $pager);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @Get("/subscribe", name="home.uc.subscribe")
|
|
||||||
*/
|
|
||||||
public function subscribeAction()
|
|
||||||
{
|
|
||||||
$subscribeRepo = new WeChatSubscribeRepo();
|
|
||||||
|
|
||||||
$subscribe = $subscribeRepo->findByUserId($this->authUser->id);
|
|
||||||
|
|
||||||
$subscribed = $subscribe ? 1 : 0;
|
|
||||||
|
|
||||||
$this->view->pick('user/console/subscribe');
|
|
||||||
$this->view->setVar('subscribed', $subscribed);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Get("/notify/stats", name="home.uc.notify_stats")
|
* @Get("/notify/stats", name="home.uc.notify_stats")
|
||||||
*/
|
*/
|
||||||
|
@ -9,12 +9,9 @@ namespace App\Http\Home\Services;
|
|||||||
|
|
||||||
use App\Models\Connect as ConnectModel;
|
use App\Models\Connect as ConnectModel;
|
||||||
use App\Models\User as UserModel;
|
use App\Models\User as UserModel;
|
||||||
use App\Models\WeChatSubscribe as WeChatSubscribeModel;
|
|
||||||
use App\Repos\Connect as ConnectRepo;
|
use App\Repos\Connect as ConnectRepo;
|
||||||
use App\Repos\User as UserRepo;
|
use App\Repos\User as UserRepo;
|
||||||
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
|
|
||||||
use App\Services\Auth\Home as AuthService;
|
use App\Services\Auth\Home as AuthService;
|
||||||
use App\Services\Auth\Home as HomeAuthService;
|
|
||||||
use App\Services\Logic\Account\Register as RegisterService;
|
use App\Services\Logic\Account\Register as RegisterService;
|
||||||
use App\Services\Logic\Notice\External\AccountLogin as AccountLoginNotice;
|
use App\Services\Logic\Notice\External\AccountLogin as AccountLoginNotice;
|
||||||
use App\Services\OAuth\QQ as QQAuth;
|
use App\Services\OAuth\QQ as QQAuth;
|
||||||
@ -82,19 +79,6 @@ class Connect extends Service
|
|||||||
$this->handleConnectRelation($user, $openUser);
|
$this->handleConnectRelation($user, $openUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function authSubscribeLogin(WeChatSubscribeModel $subscribe)
|
|
||||||
{
|
|
||||||
$userRepo = new UserRepo();
|
|
||||||
|
|
||||||
$user = $userRepo->findById($subscribe->user_id);
|
|
||||||
|
|
||||||
$this->handleLoginNotice($user);
|
|
||||||
|
|
||||||
$auth = new HomeAuthService();
|
|
||||||
|
|
||||||
$auth->saveAuthInfo($user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function authConnectLogin(ConnectModel $connect)
|
public function authConnectLogin(ConnectModel $connect)
|
||||||
{
|
{
|
||||||
$userRepo = new UserRepo();
|
$userRepo = new UserRepo();
|
||||||
@ -132,13 +116,6 @@ class Connect extends Service
|
|||||||
return $auth->getUserInfo($token, $openId);
|
return $auth->getUserInfo($token, $openId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getWeChatSubscribe($unionId)
|
|
||||||
{
|
|
||||||
$subscribeRepo = new WeChatSubscribeRepo();
|
|
||||||
|
|
||||||
return $subscribeRepo->findByUnionId($unionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getConnectRelation($openId, $provider)
|
public function getConnectRelation($openId, $provider)
|
||||||
{
|
{
|
||||||
$connectRepo = new ConnectRepo();
|
$connectRepo = new ConnectRepo();
|
||||||
|
25
app/Http/Home/Services/UserConsole.php
Normal file
25
app/Http/Home/Services/UserConsole.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||||
|
* @license https://opensource.org/licenses/GPL-2.0
|
||||||
|
* @link https://www.koogua.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Http\Home\Services;
|
||||||
|
|
||||||
|
use App\Models\Connect as ConnectModel;
|
||||||
|
use App\Repos\Connect as ConnectRepo;
|
||||||
|
|
||||||
|
class UserConsole extends Service
|
||||||
|
{
|
||||||
|
|
||||||
|
public function getWeChatOAConnect()
|
||||||
|
{
|
||||||
|
$user = $this->getLoginUser();
|
||||||
|
|
||||||
|
$connectRepo = new ConnectRepo();
|
||||||
|
|
||||||
|
return $connectRepo->findByUserId($user->id, ConnectModel::PROVIDER_WECHAT_OA);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
{%- macro connect_user(item) %}
|
{%- macro connect_user(item) %}
|
||||||
{% if item.open_avatar %}
|
{% if item.open_avatar %}
|
||||||
<span class="open-avatar"><img src="{{ item.open_avatar }}"></span>
|
<span class="open-avatar"><img src="{{ item.open_avatar }}" alt="{{ item.open_name }}"></span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<span class="open-name">{{ item.open_name }}</span>
|
<span class="open-name">{{ item.open_name }}</span>
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
@ -27,89 +27,116 @@
|
|||||||
<div class="my-sidebar">{{ partial('user/console/menu') }}</div>
|
<div class="my-sidebar">{{ partial('user/console/menu') }}</div>
|
||||||
<div class="my-content">
|
<div class="my-content">
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<div class="my-nav">
|
{% if oauth_provider.wechat.enabled == 1 %}
|
||||||
<span class="title">账号安全</span>
|
<div class="section">
|
||||||
</div>
|
<div class="my-nav">
|
||||||
<div class="security-item-list">
|
<span class="title">关注订阅</span>
|
||||||
<div class="security-item">
|
|
||||||
<div class="info">
|
|
||||||
<span class="icon"><i class="layui-icon layui-icon-password"></i></span>
|
|
||||||
<span class="title">登录密码</span>
|
|
||||||
<span class="summary">经常更改密码有助于保护您的帐号安全</span>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="action">
|
<div class="wechat-scan-box">
|
||||||
<a class="layui-btn layui-btn-sm btn-edit-pwd" href="{{ edit_pwd_url }}">修改</a>
|
{% if wechat_oa_connected == 0 %}
|
||||||
</div>
|
<div class="qrcode"></div>
|
||||||
</div>
|
<div class="tips">关注官方公众号,订阅系统重要通知</div>
|
||||||
<div class="security-item">
|
|
||||||
<div class="info">
|
|
||||||
<span class="icon"><i class="layui-icon layui-icon-cellphone"></i></span>
|
|
||||||
<span class="title">手机绑定</span>
|
|
||||||
{% if account.phone %}
|
|
||||||
<span class="summary">已绑定手机:{{ account.phone|anonymous }}</span>
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="summary">可用于登录和重置密码</span>
|
<div class="tips">你已经关注官方公众号</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="action">
|
|
||||||
<a class="layui-btn layui-btn-sm btn-edit-phone" href="{{ edit_phone_url }}">绑定</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="security-item">
|
|
||||||
<div class="info">
|
|
||||||
<span class="icon"><i class="layui-icon layui-icon-email"></i></span>
|
|
||||||
<span class="title">邮箱绑定</span>
|
|
||||||
{% if account.email %}
|
|
||||||
<span class="summary">已绑定邮箱:{{ account.email|anonymous }}</span>
|
|
||||||
{% else %}
|
|
||||||
<span class="summary">可用于登录和重置密码</span>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
<div class="action">
|
|
||||||
<a class="layui-btn layui-btn-sm btn-edit-email" href="{{ edit_email_url }}">绑定</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="my-nav">
|
|
||||||
<span class="title">开放登录</span>
|
|
||||||
</div>
|
|
||||||
{% if connects %}
|
|
||||||
<div class="connect-tips">已经绑定的第三方帐号</div>
|
|
||||||
<div class="connect-list">
|
|
||||||
<table class="layui-table" lay-skin="line">
|
|
||||||
<tr>
|
|
||||||
<td>提供方</td>
|
|
||||||
<td>用户信息</td>
|
|
||||||
<td>更新日期</td>
|
|
||||||
<td width="15%">操作</td>
|
|
||||||
</tr>
|
|
||||||
{% for connect in connects %}
|
|
||||||
{% set url = url({'for':'home.uc.unconnect','id':connect.id}) %}
|
|
||||||
{% set time = connect.update_time > 0 ? connect.update_time : connect.create_time %}
|
|
||||||
<tr>
|
|
||||||
<td>{{ connect_provider(connect) }}</td>
|
|
||||||
<td>{{ connect_user(connect) }}</td>
|
|
||||||
<td>{{ date('Y-m-d H:i',time) }}</td>
|
|
||||||
<td><a class="layui-btn layui-btn-danger layui-btn-sm kg-delete" href="javascript:" data-url="{{ url }}" data-tips="确定要解除绑定吗?">解绑</a></td>
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="connect-tips">支持绑定的第三方帐号</div>
|
<div class="section">
|
||||||
<div class="oauth-list">
|
<div class="my-nav">
|
||||||
{% if oauth_provider.qq.enabled == 1 %}
|
<span class="title">账号安全</span>
|
||||||
<a class="layui-icon layui-icon-login-qq login-qq" href="{{ url({'for':'home.oauth.qq'}) }}"></a>
|
</div>
|
||||||
{% endif %}
|
<div class="security-item-list">
|
||||||
{% if oauth_provider.weixin.enabled == 1 %}
|
<div class="security-item">
|
||||||
<a class="layui-icon layui-icon-login-wechat login-wechat" href="{{ url({'for':'home.oauth.weixin'}) }}"></a>
|
<div class="info">
|
||||||
{% endif %}
|
<span class="icon"><i class="layui-icon layui-icon-password"></i></span>
|
||||||
{% if oauth_provider.weibo.enabled == 1 %}
|
<span class="title">登录密码</span>
|
||||||
<a class="layui-icon layui-icon-login-weibo login-weibo" href="{{ url({'for':'home.oauth.weibo'}) }}"></a>
|
<span class="summary">经常更改密码有助于保护您的帐号安全</span>
|
||||||
|
</div>
|
||||||
|
<div class="action">
|
||||||
|
<a class="layui-btn layui-btn-sm btn-edit-pwd" href="{{ edit_pwd_url }}">修改</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="security-item">
|
||||||
|
<div class="info">
|
||||||
|
<span class="icon"><i class="layui-icon layui-icon-cellphone"></i></span>
|
||||||
|
<span class="title">手机绑定</span>
|
||||||
|
{% if account.phone %}
|
||||||
|
<span class="summary">已绑定手机:{{ account.phone|anonymous }}</span>
|
||||||
|
{% else %}
|
||||||
|
<span class="summary">可用于登录和重置密码</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="action">
|
||||||
|
<a class="layui-btn layui-btn-sm btn-edit-phone" href="{{ edit_phone_url }}">绑定</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="security-item">
|
||||||
|
<div class="info">
|
||||||
|
<span class="icon"><i class="layui-icon layui-icon-email"></i></span>
|
||||||
|
<span class="title">邮箱绑定</span>
|
||||||
|
{% if account.email %}
|
||||||
|
<span class="summary">已绑定邮箱:{{ account.email|anonymous }}</span>
|
||||||
|
{% else %}
|
||||||
|
<span class="summary">可用于登录和重置密码</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="action">
|
||||||
|
<a class="layui-btn layui-btn-sm btn-edit-email" href="{{ edit_email_url }}">绑定</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="section">
|
||||||
|
<div class="my-nav">
|
||||||
|
<span class="title">开放登录</span>
|
||||||
|
</div>
|
||||||
|
{% if connects|length > 0 %}
|
||||||
|
<div class="connect-tips">已经绑定的第三方帐号</div>
|
||||||
|
<div class="connect-list">
|
||||||
|
<table class="layui-table" lay-skin="line">
|
||||||
|
<tr>
|
||||||
|
<td>提供方</td>
|
||||||
|
<td>用户信息</td>
|
||||||
|
<td>更新日期</td>
|
||||||
|
<td width="15%">操作</td>
|
||||||
|
</tr>
|
||||||
|
{% for connect in connects %}
|
||||||
|
{% set url = url({'for':'home.uc.unconnect','id':connect.id}) %}
|
||||||
|
{% set time = connect.update_time > 0 ? connect.update_time : connect.create_time %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ connect_provider(connect) }}</td>
|
||||||
|
<td>{{ connect_user(connect) }}</td>
|
||||||
|
<td>{{ date('Y-m-d H:i',time) }}</td>
|
||||||
|
<td><a class="layui-btn layui-btn-danger layui-btn-sm kg-delete" href="javascript:" data-url="{{ url }}" data-tips="确定要解除绑定吗?">解绑</a></td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<div class="connect-tips">支持绑定的第三方帐号</div>
|
||||||
|
<div class="oauth-list">
|
||||||
|
{% if oauth_provider.qq.enabled == 1 %}
|
||||||
|
<a class="layui-icon layui-icon-login-qq login-qq" href="{{ url({'for':'home.oauth.qq'}) }}"></a>
|
||||||
|
{% endif %}
|
||||||
|
{% if oauth_provider.weixin.enabled == 1 %}
|
||||||
|
<a class="layui-icon layui-icon-login-wechat login-wechat" href="{{ url({'for':'home.oauth.weixin'}) }}"></a>
|
||||||
|
{% endif %}
|
||||||
|
{% if oauth_provider.weibo.enabled == 1 %}
|
||||||
|
<a class="layui-icon layui-icon-login-weibo login-weibo" href="{{ url({'for':'home.oauth.weibo'}) }}"></a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block include_js %}
|
||||||
|
|
||||||
|
{% if oauth_provider.wechat.enabled == 1 and wechat_oa_connected == 0 %}
|
||||||
|
{{ js_include('home/js/wechat.oa.subscribe.js') }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -7,7 +7,6 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
{% set wechat_oa_enabled = setting('wechat.oa','enabled') %}
|
|
||||||
{% set point_enabled = setting('point','enabled') %}
|
{% set point_enabled = setting('point','enabled') %}
|
||||||
|
|
||||||
<div class="my-profile-card wrap">
|
<div class="my-profile-card wrap">
|
||||||
@ -70,9 +69,6 @@
|
|||||||
<li><a href="{{ url({'for':'home.uc.profile'}) }}">个人信息</a></li>
|
<li><a href="{{ url({'for':'home.uc.profile'}) }}">个人信息</a></li>
|
||||||
<li><a href="{{ url({'for':'home.uc.contact'}) }}">收货地址</a></li>
|
<li><a href="{{ url({'for':'home.uc.contact'}) }}">收货地址</a></li>
|
||||||
<li><a href="{{ url({'for':'home.uc.account'}) }}">帐号安全</a></li>
|
<li><a href="{{ url({'for':'home.uc.account'}) }}">帐号安全</a></li>
|
||||||
{% if wechat_oa_enabled == 1 %}
|
|
||||||
<li><a href="{{ url({'for':'home.uc.subscribe'}) }}">关注订阅</a></li>
|
|
||||||
{% endif %}
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
@ -28,6 +28,6 @@
|
|||||||
|
|
||||||
{% block include_js %}
|
{% block include_js %}
|
||||||
|
|
||||||
{{ js_include('home/js/user.console.subscribe.js') }}
|
{{ js_include('home/js/wechat.oa.subscribe.js') }}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -1,70 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
|
||||||
* @license https://opensource.org/licenses/GPL-2.0
|
|
||||||
* @link https://www.koogua.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
class WeChatSubscribe extends Model
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键编号
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $id = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户编号
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $user_id = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 开放ID
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $open_id = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除标识
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $deleted = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $create_time = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $update_time = 0;
|
|
||||||
|
|
||||||
public function getSource(): string
|
|
||||||
{
|
|
||||||
return 'kg_wechat_subscribe';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function beforeCreate()
|
|
||||||
{
|
|
||||||
$this->create_time = time();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function beforeUpdate()
|
|
||||||
{
|
|
||||||
$this->update_time = time();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,77 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
|
||||||
* @license https://opensource.org/licenses/GPL-2.0
|
|
||||||
* @link https://www.koogua.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace App\Repos;
|
|
||||||
|
|
||||||
use App\Models\WeChatSubscribe as WeChatSubscribeModel;
|
|
||||||
use Phalcon\Mvc\Model;
|
|
||||||
|
|
||||||
class WeChatSubscribe extends Repository
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $userId
|
|
||||||
* @param string $openId
|
|
||||||
* @return WeChatSubscribeModel|Model|bool
|
|
||||||
*/
|
|
||||||
public function findSubscribe($userId, $openId)
|
|
||||||
{
|
|
||||||
return WeChatSubscribeModel::findFirst([
|
|
||||||
'conditions' => 'user_id= ?1 AND open_id = ?2',
|
|
||||||
'bind' => [1 => $userId, 2 => $openId],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $id
|
|
||||||
* @return WeChatSubscribeModel|Model|bool
|
|
||||||
*/
|
|
||||||
public function findById($id)
|
|
||||||
{
|
|
||||||
return WeChatSubscribeModel::findFirst([
|
|
||||||
'conditions' => 'id = :id:',
|
|
||||||
'bind' => ['id' => $id],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $userId
|
|
||||||
* @return WeChatSubscribeModel|Model|bool
|
|
||||||
*/
|
|
||||||
public function findByUserId($userId)
|
|
||||||
{
|
|
||||||
return WechatSubscribeModel::findFirst([
|
|
||||||
'conditions' => 'user_id = :user_id:',
|
|
||||||
'bind' => ['user_id' => $userId],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $openId
|
|
||||||
* @return WeChatSubscribeModel|Model|bool
|
|
||||||
*/
|
|
||||||
public function findByOpenId($openId)
|
|
||||||
{
|
|
||||||
return WeChatSubscribeModel::findFirst([
|
|
||||||
'conditions' => 'open_id = :open_id:',
|
|
||||||
'bind' => ['open_id' => $openId],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $unionId
|
|
||||||
* @return WeChatSubscribeModel|Model|bool
|
|
||||||
*/
|
|
||||||
public function findByUnionId($unionId)
|
|
||||||
{
|
|
||||||
return WeChatSubscribeModel::findFirst([
|
|
||||||
'conditions' => 'union_id = :union_id:',
|
|
||||||
'bind' => ['union_id' => $unionId],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -15,18 +15,20 @@ class OAuthProvider extends LogicService
|
|||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$local = $this->getSettings('oauth.local');
|
$local = $this->getSettings('oauth.local');
|
||||||
|
$qq = $this->getSettings('oauth.qq');
|
||||||
$weixin = $this->getSettings('oauth.weixin');
|
$weixin = $this->getSettings('oauth.weixin');
|
||||||
$weibo = $this->getSettings('oauth.weibo');
|
$weibo = $this->getSettings('oauth.weibo');
|
||||||
$qq = $this->getSettings('oauth.qq');
|
$wechatOA = $this->getSettings('wechat.oa');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'local' => [
|
'local' => [
|
||||||
'register_with_phone' => $local['register_with_phone'],
|
'register_with_phone' => $local['register_with_phone'],
|
||||||
'register_with_email' => $local['register_with_email'],
|
'register_with_email' => $local['register_with_email'],
|
||||||
],
|
],
|
||||||
|
'qq' => ['enabled' => $qq['enabled']],
|
||||||
'weixin' => ['enabled' => $weixin['enabled']],
|
'weixin' => ['enabled' => $weixin['enabled']],
|
||||||
'weibo' => ['enabled' => $weibo['enabled']],
|
'weibo' => ['enabled' => $weibo['enabled']],
|
||||||
'qq' => ['enabled' => $qq['enabled']],
|
'wechat' => ['enabled' => $wechatOA['enabled']],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
namespace App\Services\Logic\Notice\External\WeChat;
|
namespace App\Services\Logic\Notice\External\WeChat;
|
||||||
|
|
||||||
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
|
|
||||||
use App\Services\WeChatNotice;
|
use App\Services\WeChatNotice;
|
||||||
|
|
||||||
class AccountLogin extends WeChatNotice
|
class AccountLogin extends WeChatNotice
|
||||||
@ -21,9 +20,7 @@ class AccountLogin extends WeChatNotice
|
|||||||
*/
|
*/
|
||||||
public function handle(array $params)
|
public function handle(array $params)
|
||||||
{
|
{
|
||||||
$subscribeRepo = new WeChatSubscribeRepo();
|
$subscribe = $this->getConnect($params['user']['id']);
|
||||||
|
|
||||||
$subscribe = $subscribeRepo->findByUserId($params['user']['id']);
|
|
||||||
|
|
||||||
if (!$subscribe) return null;
|
if (!$subscribe) return null;
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
namespace App\Services\Logic\Notice\External\WeChat;
|
namespace App\Services\Logic\Notice\External\WeChat;
|
||||||
|
|
||||||
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
|
|
||||||
use App\Services\WeChatNotice;
|
use App\Services\WeChatNotice;
|
||||||
|
|
||||||
class ConsultReply extends WeChatNotice
|
class ConsultReply extends WeChatNotice
|
||||||
@ -21,9 +20,7 @@ class ConsultReply extends WeChatNotice
|
|||||||
*/
|
*/
|
||||||
public function handle(array $params)
|
public function handle(array $params)
|
||||||
{
|
{
|
||||||
$subscribeRepo = new WeChatSubscribeRepo();
|
$subscribe = $this->getConnect($params['user']['id']);
|
||||||
|
|
||||||
$subscribe = $subscribeRepo->findByUserId($params['user']['id']);
|
|
||||||
|
|
||||||
if (!$subscribe) return null;
|
if (!$subscribe) return null;
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
namespace App\Services\Logic\Notice\External\WeChat;
|
namespace App\Services\Logic\Notice\External\WeChat;
|
||||||
|
|
||||||
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
|
|
||||||
use App\Services\WeChatNotice;
|
use App\Services\WeChatNotice;
|
||||||
|
|
||||||
class GoodsDeliver extends WeChatNotice
|
class GoodsDeliver extends WeChatNotice
|
||||||
@ -21,9 +20,7 @@ class GoodsDeliver extends WeChatNotice
|
|||||||
*/
|
*/
|
||||||
public function handle($params)
|
public function handle($params)
|
||||||
{
|
{
|
||||||
$subscribeRepo = new WeChatSubscribeRepo();
|
$subscribe = $this->getConnect($params['user']['id']);
|
||||||
|
|
||||||
$subscribe = $subscribeRepo->findByUserId($params['user']['id']);
|
|
||||||
|
|
||||||
if (!$subscribe) return null;
|
if (!$subscribe) return null;
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
namespace App\Services\Logic\Notice\External\WeChat;
|
namespace App\Services\Logic\Notice\External\WeChat;
|
||||||
|
|
||||||
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
|
|
||||||
use App\Services\WeChatNotice;
|
use App\Services\WeChatNotice;
|
||||||
|
|
||||||
class LiveBegin extends WeChatNotice
|
class LiveBegin extends WeChatNotice
|
||||||
@ -21,9 +20,7 @@ class LiveBegin extends WeChatNotice
|
|||||||
*/
|
*/
|
||||||
public function handle(array $params)
|
public function handle(array $params)
|
||||||
{
|
{
|
||||||
$subscribeRepo = new WeChatSubscribeRepo();
|
$subscribe = $this->getConnect($params['user']['id']);
|
||||||
|
|
||||||
$subscribe = $subscribeRepo->findByUserId($params['user']['id']);
|
|
||||||
|
|
||||||
if (!$subscribe) return null;
|
if (!$subscribe) return null;
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
namespace App\Services\Logic\Notice\External\WeChat;
|
namespace App\Services\Logic\Notice\External\WeChat;
|
||||||
|
|
||||||
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
|
|
||||||
use App\Services\WeChatNotice;
|
use App\Services\WeChatNotice;
|
||||||
|
|
||||||
class OrderFinish extends WeChatNotice
|
class OrderFinish extends WeChatNotice
|
||||||
@ -21,9 +20,7 @@ class OrderFinish extends WeChatNotice
|
|||||||
*/
|
*/
|
||||||
public function handle($params)
|
public function handle($params)
|
||||||
{
|
{
|
||||||
$subscribeRepo = new WeChatSubscribeRepo();
|
$subscribe = $this->getConnect($params['user']['id']);
|
||||||
|
|
||||||
$subscribe = $subscribeRepo->findByUserId($params['user']['id']);
|
|
||||||
|
|
||||||
if (!$subscribe) return null;
|
if (!$subscribe) return null;
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
namespace App\Services\Logic\Notice\External\WeChat;
|
namespace App\Services\Logic\Notice\External\WeChat;
|
||||||
|
|
||||||
use App\Repos\WeChatSubscribe as WeChatSubscribeRepo;
|
|
||||||
use App\Services\WeChatNotice;
|
use App\Services\WeChatNotice;
|
||||||
|
|
||||||
class RefundFinish extends WeChatNotice
|
class RefundFinish extends WeChatNotice
|
||||||
@ -21,9 +20,7 @@ class RefundFinish extends WeChatNotice
|
|||||||
*/
|
*/
|
||||||
public function handle(array $params)
|
public function handle(array $params)
|
||||||
{
|
{
|
||||||
$subscribeRepo = new WeChatSubscribeRepo();
|
$subscribe = $this->getConnect($params['user']['id']);
|
||||||
|
|
||||||
$subscribe = $subscribeRepo->findByUserId($params['user']['id']);
|
|
||||||
|
|
||||||
if (!$subscribe) return null;
|
if (!$subscribe) return null;
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Models\Connect as ConnectModel;
|
||||||
|
use App\Repos\Connect as ConnectRepo;
|
||||||
use App\Services\WeChat as WeChatService;
|
use App\Services\WeChat as WeChatService;
|
||||||
use Phalcon\Logger\Adapter\File as FileLogger;
|
use Phalcon\Logger\Adapter\File as FileLogger;
|
||||||
|
|
||||||
@ -105,4 +107,11 @@ abstract class WeChatNotice extends Service
|
|||||||
return $template[$code]['id'] ?? null;
|
return $template[$code]['id'] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getConnect($userId)
|
||||||
|
{
|
||||||
|
$connectRepo = new ConnectRepo();
|
||||||
|
|
||||||
|
return $connectRepo->findByUserId($userId, ConnectModel::PROVIDER_WECHAT_OA);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,6 @@ final class V20210324064239 extends AbstractMigration
|
|||||||
$this->createUserSessionTable();
|
$this->createUserSessionTable();
|
||||||
$this->createUserTokenTable();
|
$this->createUserTokenTable();
|
||||||
$this->createVipTable();
|
$this->createVipTable();
|
||||||
$this->createWechatSubscribeTable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createAccountTable()
|
protected function createAccountTable()
|
||||||
@ -7206,72 +7205,4 @@ final class V20210324064239 extends AbstractMigration
|
|||||||
->create();
|
->create();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createWechatSubscribeTable()
|
|
||||||
{
|
|
||||||
$tableName = 'kg_wechat_subscribe';
|
|
||||||
|
|
||||||
if ($this->table($tableName)->exists()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->table($tableName, [
|
|
||||||
'id' => false,
|
|
||||||
'primary_key' => ['id'],
|
|
||||||
'engine' => 'InnoDB',
|
|
||||||
'encoding' => 'utf8mb4',
|
|
||||||
'collation' => 'utf8mb4_general_ci',
|
|
||||||
'comment' => '',
|
|
||||||
'row_format' => 'DYNAMIC',
|
|
||||||
])
|
|
||||||
->addColumn('id', 'integer', [
|
|
||||||
'null' => false,
|
|
||||||
'limit' => MysqlAdapter::INT_REGULAR,
|
|
||||||
'signed' => false,
|
|
||||||
'identity' => 'enable',
|
|
||||||
'comment' => '主键编号',
|
|
||||||
])
|
|
||||||
->addColumn('user_id', 'integer', [
|
|
||||||
'null' => false,
|
|
||||||
'default' => '0',
|
|
||||||
'limit' => MysqlAdapter::INT_REGULAR,
|
|
||||||
'signed' => false,
|
|
||||||
'comment' => '用户编号',
|
|
||||||
'after' => 'id',
|
|
||||||
])
|
|
||||||
->addColumn('open_id', 'string', [
|
|
||||||
'null' => false,
|
|
||||||
'default' => '',
|
|
||||||
'limit' => 64,
|
|
||||||
'collation' => 'utf8mb4_general_ci',
|
|
||||||
'encoding' => 'utf8mb4',
|
|
||||||
'comment' => '开放ID',
|
|
||||||
'after' => 'user_id',
|
|
||||||
])
|
|
||||||
->addColumn('create_time', 'integer', [
|
|
||||||
'null' => false,
|
|
||||||
'default' => '0',
|
|
||||||
'limit' => MysqlAdapter::INT_REGULAR,
|
|
||||||
'signed' => false,
|
|
||||||
'comment' => '创建时间',
|
|
||||||
'after' => 'open_id',
|
|
||||||
])
|
|
||||||
->addColumn('update_time', 'integer', [
|
|
||||||
'null' => false,
|
|
||||||
'default' => '0',
|
|
||||||
'limit' => MysqlAdapter::INT_REGULAR,
|
|
||||||
'signed' => false,
|
|
||||||
'comment' => '更新时间',
|
|
||||||
'after' => 'create_time',
|
|
||||||
])
|
|
||||||
->addIndex(['open_id'], [
|
|
||||||
'name' => 'open_id',
|
|
||||||
'unique' => false,
|
|
||||||
])
|
|
||||||
->addIndex(['user_id'], [
|
|
||||||
'name' => 'user_id',
|
|
||||||
'unique' => false,
|
|
||||||
])
|
|
||||||
->create();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ class V20210917093354 extends Phinx\Migration\AbstractMigration
|
|||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->alterConnectTable();
|
$this->alterConnectTable();
|
||||||
$this->alterWechatSubscribeTable();
|
|
||||||
$this->handleLocalAuthSettings();
|
$this->handleLocalAuthSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,52 +49,6 @@ class V20210917093354 extends Phinx\Migration\AbstractMigration
|
|||||||
$table->save();
|
$table->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function alterWechatSubscribeTable()
|
|
||||||
{
|
|
||||||
$table = $this->table('kg_wechat_subscribe');
|
|
||||||
|
|
||||||
if (!$table->hasColumn('union_id')) {
|
|
||||||
$table->addColumn('union_id', 'string', [
|
|
||||||
'null' => false,
|
|
||||||
'default' => '',
|
|
||||||
'limit' => 64,
|
|
||||||
'collation' => 'utf8mb4_general_ci',
|
|
||||||
'encoding' => 'utf8mb4',
|
|
||||||
'comment' => '联合ID',
|
|
||||||
'after' => 'open_id',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
if (!$table->hasColumn('deleted')) {
|
|
||||||
$table->addColumn('deleted', 'integer', [
|
|
||||||
'null' => false,
|
|
||||||
'default' => '0',
|
|
||||||
'limit' => MysqlAdapter::INT_REGULAR,
|
|
||||||
'signed' => false,
|
|
||||||
'comment' => '删除标识',
|
|
||||||
'after' => 'union_id',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
if (!$table->hasIndexByName('user_id')) {
|
|
||||||
$table->addIndex(['user_id'], [
|
|
||||||
'name' => 'user_id',
|
|
||||||
'unique' => false,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
if (!$table->hasIndexByName('open_id')) {
|
|
||||||
$table->addIndex(['open_id'], [
|
|
||||||
'name' => 'open_id',
|
|
||||||
'unique' => false,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
if (!$table->hasIndexByName('union_id')) {
|
|
||||||
$table->addIndex(['union_id'], [
|
|
||||||
'name' => 'union_id',
|
|
||||||
'unique' => false,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
$table->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function handleLocalAuthSettings()
|
protected function handleLocalAuthSettings()
|
||||||
{
|
{
|
||||||
$rows = [
|
$rows = [
|
||||||
|
@ -1700,6 +1700,30 @@
|
|||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.register-close-tips {
|
||||||
|
padding: 50px;
|
||||||
|
text-align: center;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wechat-scan-box {
|
||||||
|
padding: 20px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wechat-scan-box .qrcode {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wechat-scan-box .qrcode img {
|
||||||
|
border: 3px solid #999;
|
||||||
|
padding: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wechat-scan-box .tips {
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
.user-profile {
|
.user-profile {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -1934,6 +1958,10 @@
|
|||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.my-content .section {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.profile-form {
|
.profile-form {
|
||||||
width: 95%;
|
width: 95%;
|
||||||
}
|
}
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
layui.use(['jquery'], function () {
|
|
||||||
|
|
||||||
var $ = layui.jquery;
|
|
||||||
var subscribed = $('input[name=subscribed]').val();
|
|
||||||
var interval = null;
|
|
||||||
|
|
||||||
if (subscribed === '0') {
|
|
||||||
showQrCode();
|
|
||||||
interval = setInterval(function () {
|
|
||||||
queryStatus();
|
|
||||||
}, 5000);
|
|
||||||
}
|
|
||||||
|
|
||||||
function showQrCode() {
|
|
||||||
$.get('/wechat/oa/subscribe/qrcode', function (res) {
|
|
||||||
$('#sub-qrcode').html('<img alt="扫码关注" src="' + res.qrcode + '">');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function queryStatus() {
|
|
||||||
$.get('/wechat/oa/subscribe/status', function (res) {
|
|
||||||
if (res.status === 1) {
|
|
||||||
clearInterval(interval);
|
|
||||||
$('#sub-tips').addClass('success').html('关注公众号成功');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
34
public/static/home/js/wechat.oa.subscribe.js
Normal file
34
public/static/home/js/wechat.oa.subscribe.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
layui.use(['jquery', 'layer'], function () {
|
||||||
|
|
||||||
|
var $ = layui.jquery;
|
||||||
|
var layer = layui.layer;
|
||||||
|
var interval = null;
|
||||||
|
|
||||||
|
var $qrcode = $('.wechat-scan-box > .qrcode');
|
||||||
|
|
||||||
|
if ($qrcode.length > 0) {
|
||||||
|
showQrCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
function showQrCode() {
|
||||||
|
$.get('/wechat/oa/subscribe/qrcode', function (res) {
|
||||||
|
$qrcode.html('<img alt="关注微信公众号" src="' + res.qrcode.url + '">');
|
||||||
|
interval = setInterval(function () {
|
||||||
|
queryStatus();
|
||||||
|
}, 1500);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function queryStatus() {
|
||||||
|
$.get('/wechat/oa/subscribe/status', function (res) {
|
||||||
|
if (res.status === 1) {
|
||||||
|
clearInterval(interval);
|
||||||
|
layer.msg('关注微信公众号成功', {icon: 1});
|
||||||
|
setTimeout(function () {
|
||||||
|
window.location.reload();
|
||||||
|
}, 1500);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user