Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
5
51business
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
方斌
51business
Commits
8c14f14b
Commit
8c14f14b
authored
Apr 30, 2020
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix wechat classModel bug
parent
43701235
Pipeline
#22690
passed with stage
in 3 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
9 deletions
+22
-9
wechat.js
app/controller/course/v5/wechat.js
+8
-6
wechat.js
app/service/course/v5/wechat.js
+14
-3
No files found.
app/controller/course/v5/wechat.js
View file @
8c14f14b
...
@@ -16,12 +16,14 @@ class WechatController extends Controller {
...
@@ -16,12 +16,14 @@ class WechatController extends Controller {
async
callbackAction
()
{
async
callbackAction
()
{
const
{
ctx
,
service
}
=
this
;
const
{
ctx
,
service
}
=
this
;
const
ret
=
await
service
.
course
.
v5
.
wechat
.
callbackAction
();
const
ret
=
await
service
.
course
.
v5
.
wechat
.
callbackAction
();
if
(
ctx
.
isEmpty
(
ret
))
{
// if (ctx.isEmpty(ret)) {
ctx
.
success
(
'success'
);
// ctx.success('success');
}
else
{
// } else {
ctx
.
set
(
'content-type'
,
'text/xml'
);
// ctx.set('content-type', 'text/xml');
ctx
.
body
=
ret
;
// ctx.body = ret;
}
// }
ctx
.
success
(
'success'
);
}
}
async
check
()
{
async
check
()
{
...
...
app/service/course/v5/wechat.js
View file @
8c14f14b
...
@@ -50,13 +50,24 @@ class WechatService extends Service {
...
@@ -50,13 +50,24 @@ class WechatService extends Service {
}
}
if
(
!
flag
)
{
if
(
!
flag
)
{
const
xml
=
`<xml><ToUserName><![CDATA[
${
data
.
FromUserName
}
]]></ToUserName><FromUserName><![CDATA[
${
data
.
ToUserName
}
]]></FromUserName><CreateTime>
${
parseInt
(
new
Date
()
/
1000
)}
</CreateTime><MsgType><![CDATA[transfer_customer_service]]></MsgType></xml>`
;
await
this
.
transferCustomerService
(
data
);
ctx
.
logger
.
info
(
'course_ctx: '
+
xml
);
return
xml
;
}
}
return
''
;
return
''
;
}
}
async
transferCustomerService
(
data
)
{
const
{
ctx
}
=
this
;
const
xml
=
`<xml><ToUserName><![CDATA[
${
data
.
FromUserName
}
]]></ToUserName><FromUserName><![CDATA[
${
data
.
ToUserName
}
]]></FromUserName><CreateTime>
${
parseInt
(
new
Date
()
/
1000
)}
</CreateTime><MsgType><![CDATA[transfer_customer_service]]></MsgType></xml>`
;
const
token
=
await
this
.
getAccessToken
();
const
url
=
'https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token='
+
token
;
ctx
.
logger
.
info
(
'course_wechat_v5_param: '
+
JSON
.
stringify
(
xml
));
const
resp
=
await
ctx
.
helper
.
send_request
(
url
,
xml
,
{
method
:
'POST'
,
contentType
:
'text/xml'
});
ctx
.
logger
.
info
(
'course_wechat_v5_resp: '
+
JSON
.
stringify
(
resp
));
return
;
}
async
sendText
(
data
)
{
async
sendText
(
data
)
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment