切换导航条
此项目
正在载入...
登录
何书鹏
/
recruit
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
差异文件
浏览文件
作者
PPPSCN
8 years ago
提交
77ce4eedaf169f034fc588e47678cf9c3145baef
2 个父辈
388b5b61
92a21971
Merge remote-tracking branch 'upstream/master'
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
40 行增加
和
25 行删除
application/admin/command/Install/fastadmin.sql
application/admin/controller/wechat/Menu.php
application/common.php
application/index/controller/Wechat.php
extend/fast/service/Wechat.php
public/assets/js/backend/index.js
application/admin/command/Install/fastadmin.sql
查看文件 @
77ce4ee
...
...
@@ -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
;
...
...
application/admin/controller/wechat/Menu.php
查看文件 @
77ce4ee
...
...
@@ -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
{
...
...
application/common.php
查看文件 @
77ce4ee
...
...
@@ -74,7 +74,7 @@ if (!function_exists('configvalue'))
*/
function
configvalue
(
$id
)
{
$data
=
Configvalue
::
get
(
'wechat'
);
$data
=
Configvalue
::
get
(
$id
);
return
$data
?
$data
->
content
:
null
;
}
...
...
application/index/controller/Wechat.php
查看文件 @
77ce4ee
...
...
@@ -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
::
get
Secret
(
'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
)
{
...
...
extend/fast/service/Wechat.php
查看文件 @
77ce4ee
...
...
@@ -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
;
}
...
...
public/assets/js/backend/index.js
查看文件 @
77ce4ee
...
...
@@ -54,11 +54,18 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'adminlte', 'validator'], f
dataType
:
'json'
,
cache
:
false
,
success
:
function
(
ret
)
{
if
(
ret
.
code
===
1
)
{
Backend
.
api
.
toastr
.
success
(
__
(
'Wipe cache completed'
));
if
(
ret
.
hasOwnProperty
(
"code"
))
{
var
msg
=
ret
.
hasOwnProperty
(
"msg"
)
&&
ret
.
msg
!=
""
?
ret
.
msg
:
""
;
if
(
ret
.
code
===
1
)
{
Toastr
.
success
(
msg
?
msg
:
__
(
'Wipe cache completed'
));
}
else
{
Toastr
.
error
(
msg
?
msg
:
__
(
'Wipe cache failed'
));
}
}
else
{
Backend
.
api
.
toastr
.
error
(
__
(
'Wipe cache failed
'
));
Toastr
.
error
(
__
(
'Unknown data format
'
));
}
},
error
:
function
()
{
Toastr
.
error
(
__
(
'Network error'
));
}
});
});
...
...
请
注册
或
登录
后发表评论