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 {
async callbackAction() {
const { ctx, service } = this;
const ret = await service.course.v5.wechat.callbackAction();
if (ctx.isEmpty(ret)) {
// if (ctx.isEmpty(ret)) {
// ctx.success('success');
// } else {
// ctx.set('content-type', 'text/xml');
// ctx.body = ret;
// }
ctx.success('success');
} else {
ctx.set('content-type', 'text/xml');
ctx.body = ret;
}
}
async check() {
......
......@@ -50,13 +50,24 @@ class WechatService extends Service {
}
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>`;
ctx.logger.info('course_ctx: ' + xml);
return xml;
await this.transferCustomerService(data);
}
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) {
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