Commit 661df675 authored by 任国军's avatar 任国军

fix xml

parent b3bc30b3
Pipeline #22648 passed with stage
in 3 seconds
......@@ -15,8 +15,13 @@ class WechatController extends Controller {
async callbackAction() {
const { ctx, service } = this;
await service.course.v5.wechat.callbackAction();
ctx.success('success');
const ret = await service.course.v5.wechat.callbackAction();
if (ctx.isEmpty(ret)) {
ctx.success('success');
} else {
ctx.set('content-type', 'text/xml');
ctx.body = ret;
}
}
async check() {
......
......@@ -26,9 +26,10 @@ class WechatService extends Service {
}
async callbackAction() {
const { ctx, app } = this;
const { ctx } = this;
ctx.logger.info('course_wechat_v5_receive: ' + JSON.stringify(ctx.request.body));
await this.sendMsg(ctx.request.body);
const ret = await this.sendMsg(ctx.request.body);
return ret;
}
async sendMsg(data) {
......@@ -49,12 +50,11 @@ class WechatService extends Service {
}
if (!flag) {
this.ctx.set('content-type', 'text/xml');
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>`;
this.ctx.body = xml;
ctx.logger.info('course_ctx: ' + xml);
return xml;
}
// return;
return '';
}
async sendText(data) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment