mirror of https://gitee.com/karson/fastadmin.git
parent
ec0eefd16a
commit
92a219710d
|
|
@ -213,7 +213,7 @@ CREATE TABLE `fa_configvalue` (
|
|||
-- Records of `fa_configvalue`
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
INSERT INTO `fa_configvalue` VALUES ('wechat', '微信菜单', '{\"menu\":[{\"name\":\"极速后台\",\"sub_button\":[{\"name\":\"官网\",\"type\":\"view\",\"url\":\"http:\\/\\/www.fastadmin.net\"},{\"name\":\"演示站\",\"type\":\"view\",\"url\":\"http:\\/\\/demo.fastadmin.net\"}]},{\"name\":\"联系客户\",\"type\":\"click\",\"key\":\"58cb852984970\"},{\"name\":\"关于我们\",\"type\":\"click\",\"key\":\"58bf944aa0777\"}],\"config\":[{\"id\":\"default.subscribe.message\",\"name\":\"关注后自动推送内容\",\"value\":\"欢迎关注我们!\"},{\"id\":\"cccdddd\",\"name\":\"dfsdffdsfdsdfsdfs\",\"value\":\"fsfsfsdfsdfdsfdsgggg\"}]}', '0', '1492186828', '5', 'normal');
|
||||
INSERT INTO `fa_configvalue` VALUES ('wechat', '微信菜单', '{\"menu\":[{\"name\":\"极速后台\",\"sub_button\":[{\"name\":\"官网\",\"type\":\"view\",\"url\":\"http:\\/\\/www.fastadmin.net\"},{\"name\":\"演示站\",\"type\":\"view\",\"url\":\"http:\\/\\/demo.fastadmin.net\"}]},{\"name\":\"联系客服\",\"type\":\"click\",\"key\":\"58cb852984970\"},{\"name\":\"关于我们\",\"type\":\"click\",\"key\":\"58bf944aa0777\"}],\"config\":[{\"id\":\"default.subscribe.message\",\"name\":\"关注后自动推送内容\",\"value\":\"欢迎关注我们!\"},{\"id\":\"cccdddd\",\"name\":\"dfsdffdsfdsdfsdfs\",\"value\":\"fsfsfsdfsdfdsfdsgggg\"}]}', '0', '1493986907', '5', 'normal');
|
||||
COMMIT;
|
||||
|
||||
-- ----------------------------
|
||||
|
|
@ -373,7 +373,14 @@ CREATE TABLE `fa_wechat_autoreply` (
|
|||
`updatetime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
|
||||
`status` varchar(30) NOT NULL DEFAULT '' COMMENT '状态',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='微信自动回复表';
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='微信自动回复表';
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of `fa_wechat_autoreply`
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
INSERT INTO `fa_wechat_autoreply` VALUES ('1', '输入hello', 'hello', '58c7d908c4570', '123', '1493366855', '1493366855', 'normal'), ('2', '输入你好', '你好', '58fdfaa9e1965', 'sad', '1493704976', '1493704976', 'normal');
|
||||
COMMIT;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for `fa_wechat_context`
|
||||
|
|
@ -415,7 +422,7 @@ CREATE TABLE `fa_wechat_response` (
|
|||
-- Records of `fa_wechat_response`
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
INSERT INTO `fa_wechat_response` VALUES ('1', '签到送积分', '58adaf7876aab', 'app', '{\"app\":\"signin\"}', '', '1487777656', '0', 'normal'), ('2', '关于我们', '58bf944aa0777', 'app', '{\"app\":\"article\",\"id\":\"1\"}', '', '1488950346', '0', 'normal'), ('3', '测试我们', '58c7d908c4570', 'text', '{\"content\":\"\\u8fd4\\u56de\\u6210\\u529f\\u5566\\uff01\"}', '测试我们', '1489492232', '0', 'normal'), ('4', '联系客服', '58cb852984970', 'app', '{\"app\":\"service\"}', '', '1489732905', '0', 'normal');
|
||||
INSERT INTO `fa_wechat_response` VALUES ('1', '签到送积分', '58adaf7876aab', 'app', '{\"app\":\"signin\"}', '', '1487777656', '1487777656', 'normal'), ('2', '关于我们', '58bf944aa0777', 'app', '{\"app\":\"page\",\"id\":\"1\"}', '', '1488950346', '1488950346', 'normal'), ('3', '自动回复1', '58c7d908c4570', 'text', '{\"content\":\"world\"}', '', '1489492232', '1489492232', 'normal'), ('4', '联系客服', '58cb852984970', 'app', '{\"app\":\"service\"}', '', '1489732905', '1489732905', 'normal'), ('5', '自动回复2', '58fdfaa9e1965', 'text', '{\"content\":\"我是FastAdmin!\"}', '', '1493039785', '1493039785', 'normal');
|
||||
COMMIT;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class Menu extends Backend
|
|||
public function sync($ids = NULL)
|
||||
{
|
||||
$this->code = -1;
|
||||
$app = new Application(Config::get('wechat')->toArray());
|
||||
$app = new Application(Config::get('wechat'));
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ if (!function_exists('configvalue'))
|
|||
*/
|
||||
function configvalue($id)
|
||||
{
|
||||
$data = Configvalue::get('wechat');
|
||||
$data = Configvalue::get($id);
|
||||
return $data ? $data->content : null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,11 +3,12 @@
|
|||
namespace app\index\controller;
|
||||
|
||||
use app\common\controller\Frontend;
|
||||
use app\common\model\WechatAutoreply;
|
||||
use app\common\model\WechatContext;
|
||||
use app\common\model\WechatResponse;
|
||||
use EasyWeChat\Foundation\Application;
|
||||
use EasyWeChat\Payment\Order;
|
||||
use fast\service\Wechat as WechatService;
|
||||
use fast\third\Application;
|
||||
use think\Config;
|
||||
use think\Log;
|
||||
|
||||
|
|
@ -22,7 +23,7 @@ class Wechat extends Frontend
|
|||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->app = new Application(Config::getSecret('wechat')->toArray());
|
||||
$this->app = new Application(Config::get('wechat'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -68,11 +69,11 @@ class Wechat extends Frontend
|
|||
break;
|
||||
}
|
||||
|
||||
$response = $WechatResponse->where(["eventkey" => $eventkey, 'status' => FA_STATUS_NORMAL])->get();
|
||||
$response = $WechatResponse->where(["eventkey" => $eventkey, 'status' => 'normal'])->find();
|
||||
if ($response)
|
||||
{
|
||||
$content = (array) json_decode($response['content'], TRUE);
|
||||
$context = $WechatContext->where(['openid' => $openid])->get();
|
||||
$context = $WechatContext->where(['openid' => $openid])->find();
|
||||
$data = ['eventkey' => $eventkey, 'command' => '', 'refreshtime' => time(), 'openid' => $openid];
|
||||
if ($context)
|
||||
{
|
||||
|
|
@ -81,7 +82,7 @@ class Wechat extends Frontend
|
|||
}
|
||||
else
|
||||
{
|
||||
$id = $WechatContext->data($data)->insert();
|
||||
$id = $WechatContext->data($data)->save();
|
||||
$data['id'] = $id;
|
||||
}
|
||||
$result = $WechatService->response($this, $openid, $content, $data);
|
||||
|
|
@ -99,10 +100,10 @@ class Wechat extends Frontend
|
|||
case 'link': //链接消息
|
||||
default: //其它消息
|
||||
//上下文事件处理
|
||||
$context = $WechatContext->where([['openid', $openid], ['refreshtime', '>=', time() - 1800]])->get();
|
||||
$context = $WechatContext->where(['openid' => ['=', $openid], 'refreshtime' => ['>=', time() - 1800]])->find();
|
||||
if ($context && $context['eventkey'])
|
||||
{
|
||||
$response = $WechatResponse->where(['eventkey' => $context['eventkey'], 'status' => FA_STATUS_NORMAL])->get();
|
||||
$response = $WechatResponse->where(['eventkey' => $context['eventkey'], 'status' => 'normal'])->find();
|
||||
if ($response)
|
||||
{
|
||||
$WechatContext->data(array('refreshtime' => time()))->where('id', $context['id'])->update();
|
||||
|
|
@ -117,15 +118,15 @@ class Wechat extends Frontend
|
|||
//自动回复处理
|
||||
if ($message->MsgType == 'text')
|
||||
{
|
||||
$wechat_autoreply = new Orm('wechat_autoreply');
|
||||
$autoreply = $wechat_autoreply->where(['text' => $message->Content, 'status' => FA_STATUS_NORMAL])->get();
|
||||
$wechat_autoreply = new WechatAutoreply();
|
||||
$autoreply = $wechat_autoreply->where(['text' => $message->Content, 'status' => 'normal'])->find();
|
||||
if ($autoreply)
|
||||
{
|
||||
$response = $WechatResponse->where(["eventkey" => $autoreply['eventkey'], 'status' => FA_STATUS_NORMAL])->get();
|
||||
$response = $WechatResponse->where(["eventkey" => $autoreply['eventkey'], 'status' => 'normal'])->find();
|
||||
if ($response)
|
||||
{
|
||||
$content = (array) json_decode($response['content'], TRUE);
|
||||
$context = $WechatContext->where(['openid' => $openid])->get();
|
||||
$context = $WechatContext->where(['openid' => $openid])->find();
|
||||
$result = $WechatService->response($this, $openid, $content, $context);
|
||||
if ($result)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use app\common\model\UserThird;
|
|||
use EasyWeChat\Message\News;
|
||||
use EasyWeChat\Message\Transfer;
|
||||
use fast\Date;
|
||||
use think\Config;
|
||||
|
||||
/**
|
||||
* Wechat服务类
|
||||
|
|
@ -62,7 +63,6 @@ class Wechat
|
|||
// 微信输入交互内容指令
|
||||
public function command($obj, $openid, $content, $context)
|
||||
{
|
||||
$content = [];
|
||||
$response = FALSE;
|
||||
if (isset($content['app']))
|
||||
{
|
||||
|
|
@ -131,7 +131,7 @@ class Wechat
|
|||
// 微信点击菜单event指令
|
||||
public function response($obj, $openid, $content, $context)
|
||||
{
|
||||
$content = [];
|
||||
$upload = Config::get('upload');
|
||||
$response = FALSE;
|
||||
if (isset($content['app']))
|
||||
{
|
||||
|
|
@ -176,8 +176,8 @@ class Wechat
|
|||
{
|
||||
$news = new News();
|
||||
$news->title = $pageinfo['title'];
|
||||
$news->url = $pageinfo['outlink'] ? $pageinfo['outlink'] : url('page/show/' . $pageinfo['id'], 1);
|
||||
$news->image = cdn($pageinfo['image']);
|
||||
$news->url = $pageinfo['url'] ? $pageinfo['url'] : url('index/page/show', ['id' => $pageinfo['id']], true, true);
|
||||
$news->image = $upload['cdnurl'] . $pageinfo['image'];
|
||||
$news->description = $pageinfo['description'];
|
||||
$response[] = $news;
|
||||
}
|
||||
|
|
@ -190,8 +190,8 @@ class Wechat
|
|||
{
|
||||
$news = new News();
|
||||
$news->title = $pageinfo['title'];
|
||||
$news->url = $pageinfo['outlink'] ? $pageinfo['outlink'] : url('page/show/' . $pageinfo['id'], 1);
|
||||
$news->image = cdn($pageinfo['image']);
|
||||
$news->url = $pageinfo['url'] ? $pageinfo['url'] : url('index/page/show', ['id' => $pageinfo['id']], true, true);
|
||||
$news->image = $upload['cdnurl'] . $pageinfo['image'];
|
||||
$news->description = $pageinfo['description'];
|
||||
return $news;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,17 +48,24 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'adminlte', 'validator'], f
|
|||
});
|
||||
|
||||
//清除缓存
|
||||
$(document).on('click', "[data-toggle='wipeCache']", function () {
|
||||
$(document).on('click', "[data-toggle='wipecache']", function () {
|
||||
$.ajax({
|
||||
url: 'ajax/wipeCache',
|
||||
url: 'ajax/wipecache',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function (ret) {
|
||||
if (ret.hasOwnProperty("code")) {
|
||||
var msg = ret.hasOwnProperty("msg") && ret.msg != "" ? ret.msg : "";
|
||||
if (ret.code === 1) {
|
||||
Backend.api.toastr.success(ret.msg);
|
||||
Toastr.success(msg ? msg : __('Wipe cache completed'));
|
||||
} else {
|
||||
Backend.api.toastr.error('清除系统缓存失败!');
|
||||
Toastr.error(msg ? msg : __('Wipe cache failed'));
|
||||
}
|
||||
} else {
|
||||
Toastr.error(__('Unknown data format'));
|
||||
}
|
||||
}, error: function () {
|
||||
Toastr.error(__('Network error'));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue