Commit dec1aeff authored by 任国军's avatar 任国军

add transferCustomerService

parent 1d732172
Pipeline #22613 passed with stage
in 3 seconds
'use strict';
const xml2js = require('xml2js');
const Controller = require('egg').Controller;
class TestController extends Controller {
async test() {
const { service, ctx } = this;
const from = { lng: 120.069206, lat: 30.291121 };
const to = { lng: 120.212997, lat: 30.29133 };
const ret = await service.course.lbs.getLBSDistance('walking', from, [ to, to ]);
ctx.success(ret);
this.ctx.set('content-type', 'text/xml');
const data = {
MsgType: 'transfer_customer_service',
ToUserName: 'to',
FromUserName: 'from',
CreateTime: parseInt(new Date() / 1000),
};
const builder = new xml2js.Builder();
const xml = builder.buildObject(data);
this.ctx.body = xml;
console.log(this.ctx);
}
}
module.exports = TestController;
......@@ -124,6 +124,7 @@ class UserService extends Service {
if (ctx.isEmpty(userInfo)) {
const uuid = uuidV4();
userInfo = await ctx.classModel.V5.CourseUser.findOrCreate({ where: { openid, is_deleted: 0 }, defaults: { uuid, openid } });
userInfo = await ctx.classModel.V5.CourseUser.findOne({ where: { openid, is_deleted: 0 } });
}
// 存储缓存标识
......@@ -138,7 +139,6 @@ class UserService extends Service {
await app.memcache.set(key, value, 7 * 24 * 3600);
const authToken = await this.service.jwt.apply({ user_uuid: userInfo.uuid, openid: userInfo.openid });
await app.memcache.set('course_auth_token_' + userInfo.uuid, authToken, 7 * 24 * 3600);
JSON.s;
const ret = {
user_uuid: userInfo.uuid,
openid: userInfo.openid,
......
......@@ -5,6 +5,7 @@ const SECRET = 'a1b2d32b018988176181497bd74a0b7d';
const fs = require('fs');
const request = require('request');
const crypto = require('crypto');
const xml2js = require('xml2js');
class WechatService extends Service {
async getAccessToken() {
......@@ -49,12 +50,16 @@ class WechatService extends Service {
}
if (!flag) {
return {
this.ctx.set('content-type', 'text/xml');
let xml = {
MsgType: 'transfer_customer_service',
ToUserName: data.FromUserName,
FromUserName: data.ToUserName,
CreateTime: parseInt(new Date() / 1000),
};
const builder = new xml2js.Builder();
xml = builder.buildObject(xml);
this.ctx.body = xml;
}
return;
}
......
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