Commit 8c14f14b authored by 任国军's avatar 任国军

fix wechat classModel bug

parent 43701235
Pipeline #22690 passed with stage
in 3 seconds
...@@ -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() {
......
...@@ -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;
......
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