Commit 3d11ca21 by 王昆

gsb

parent 3d238cf1
var System = require("../../../system")
const crypto = require('crypto');
var fs = require("fs");
var accesskey = 'DHmRtFlw2Zr3KaRwUFeiu7FWATnmla';
var accessKeyId = 'LTAIyAUK8AD04P5S';
var url = "https://gsb-zc.oss-cn-beijing.aliyuncs.com";
class UploadCtl {
constructor() {
this.cmdPdf2HtmlPattern = "docker run -i --rm -v /tmp/:/pdf 0c pdf2htmlEX --zoom 1.3 '{fileName}'";
this.restS = System.getObject("util.execClient");
this.cmdInsertToFilePattern = "sed -i 's/id=\"page-container\"/id=\"page-container\" contenteditable=\"true\"/'";
//sed -i 's/1111/&BBB/' /tmp/input.txt
//sed 's/{position}/{content}/g' {path}
}
async getOssConfig() {
var policyText = {
"expiration": "2119-12-31T16:00:00.000Z",
"conditions": [
["content-length-range", 0, 1048576000],
["starts-with", "$key", "zc"]
]
};
var b = new Buffer(JSON.stringify(policyText));
var policyBase64 = b.toString('base64');
var signature = crypto.createHmac('sha1', accesskey).update(policyBase64).digest().toString('base64'); //base64
var data = {
OSSAccessKeyId: accessKeyId,
policy: policyBase64,
Signature: signature,
Bucket: 'gsb-zc',
success_action_status: 201,
url: url
};
return data;
};
async upfile(srckey, dest) {
var oss = System.getObject("util.ossClient");
var result = await oss.upfile(srckey, "/tmp/" + dest);
return result;
};
async downfile(srckey) {
var oss = System.getObject("util.ossClient");
var downfile = await oss.downfile(srckey).then(function () {
downfile = "/tmp/" + srckey;
return downfile;
});
return downfile;
};
async pdf2html(obj) {
var srckey = obj.key;
var downfile = await this.downfile(srckey);
var cmd = this.cmdPdf2HtmlPattern.replace(/\{fileName\}/g, srckey);
var rtn = await this.restS.exec(cmd);
var path = "/tmp/" + srckey.split(".pdf")[0] + ".html";
var a = await this.insertToFile(path);
fs.unlink("/tmp/" + srckey);
var result = await this.upfile(srckey.split(".pdf")[0] + ".html", srckey.split(".pdf")[0] + ".html");
return result.url;
};
async insertToFile(path) {
var cmd = this.cmdInsertToFilePattern + " " + path;
return await this.restS.exec(cmd);
};
}
module.exports = UploadCtl;
\ No newline at end of file
...@@ -4,8 +4,11 @@ const settings = require("../../../../config/settings") ...@@ -4,8 +4,11 @@ const settings = require("../../../../config/settings")
class MerchantService extends ServiceBase { class MerchantService extends ServiceBase {
constructor() { constructor() {
super(); super();
this.SETTINGS_KEY = "merchant_settings_";
this.INFO_KEY = "merchant_info_";
this.channelSve = system.getObject("service.saas.channelSve"); this.channelSve = system.getObject("service.saas.channelSve");
this.mainSve = system.getObject("service.saas.mainSve"); this.mainSve = system.getObject("service.saas.mainSve");
this.redisClient = system.getObject("util.redisClient");
} }
async mapByIds(params) { async mapByIds(params) {
...@@ -55,6 +58,37 @@ class MerchantService extends ServiceBase { ...@@ -55,6 +58,37 @@ class MerchantService extends ServiceBase {
return rs; return rs;
} }
async getMerchantWithCache(params) {
let key = this.INFO_KEY + params.id;
let merchant = await this.redisClient.get(key);
if(!merchant || params.forceUpdate) {
let info = await this.info(params) || {};
merchant = info.data || {};
await this.redisClient.setWithEx(key, JSON.stringify(merchant), 60 * 31);
} else {
merchant = JSON.parse(merchant);
}
return merchant;
}
async getSettings(merchant_id) {
if(!merchant_id) {
return;
}
let key = this.SETTINGS_KEY + merchant_id;
let settings = await this.redisClient.get(key);
if(!settings) {
let rs = await this.callms("merchant", "mchtSettings", {id: merchant_id}) || {};
settings = rs.data;
if(settings && settings.appid && settings.secret) {
await this.redisClient.setWithEx(key, JSON.stringify(settings), 60 * 30);
}
} else {
settings = JSON.parse(settings);
}
return settings;
}
async setChannel(rows) { async setChannel(rows) {
if(!rows) { if(!rows) {
return; return;
......
const system = require("../../../system");
const ServiceBase = require("../../svems.base")
class MerchantAppletuserService extends ServiceBase {
constructor() {
super();
this.redisClient = system.getObject("util.redisClient");
}
async login(params) {
try {
return await this.callms("uc", "appletLogin", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async getLoginUser(params) {
let key = "applet_login_" + params.merchant_id +"_" + params.openid;
try {
let user = await this.redisClient.get(key);
if(!user) {
let appletUserInfo = await this.callms("uc", "appletUserInfo", params) || {};
user = appletUserInfo.data;
if(user) {
await this.redisClient.setWithEx(key, JSON.stringify(user), 60 * 33);
}
} else {
user = JSON.parse(user);
}
return user;
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = MerchantAppletuserService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../svems.base")
class MerchantuserService extends ServiceBase {
constructor() {
super();
}
async save(params) {
try {
return await this.callms("uc", "merchantSave", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async info(params) {
try {
return await this.callms("uc", "merchantInfo", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async enabled(params) {
try {
return await this.callms("uc", "merchantEnabled", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async page(params) {
try {
return await this.callms("uc", "merchantPage", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async mapByIds(params) {
try {
return await this.callms("uc", "merchantMapByIds", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = MerchantuserService;
\ No newline at end of file
...@@ -178,7 +178,7 @@ class System { ...@@ -178,7 +178,7 @@ class System {
// common: "http://127.0.0.1:3102" + path, // common: "http://127.0.0.1:3102" + path,
// 商户服务 // 商户服务
merchant: domain2 + ":3101" + path, merchant: domain + ":3101" + path,
// merchant: "http://127.0.0.1:3101" + path, // merchant: "http://127.0.0.1:3101" + path,
// 订单服务 // 订单服务
...@@ -190,7 +190,7 @@ class System { ...@@ -190,7 +190,7 @@ class System {
// invoice: "http://127.0.0.1:3105" + path, // invoice: "http://127.0.0.1:3105" + path,
// 用户服务 // 用户服务
uc: domain2 + ":3106" + path, uc: domain + ":3106" + path,
// uc: "http://127.0.0.1:3106" + path, // uc: "http://127.0.0.1:3106" + path,
} }
} else { } else {
......
const system=require("../system");
const uuidv4 = require('uuid/v4');
class IdcardClient {
constructor() {
// 加权因子
this.weight_factor = [7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2];
// 校验码
this.check_code = ['1', '0', 'X' , '9', '8', '7', '6', '5', '4', '3', '2'];
}
async checkIDCard(idcard) {
if(!idcard) {
return false;
}
var code = idcard.toString().toUpperCase();
var last = idcard[17];//最后一个
var seventeen = code.substring(0,17);
// ISO 7064:1983.MOD 11-2
// 判断最后一位校验码是否正确
var arr = seventeen.split("");
var len = arr.length;
var num = 0;
for(var i = 0; i < len; i++){
num = num + arr[i] * this.weight_factor[i];
}
// 获取余数
var resisue = num%11;
var last_no = this.check_code[resisue];
// 格式的正则
// 正则思路
/*
第一位不可能是0
第二位到第六位可以是0-9
第七位到第十位是年份,所以七八位为19或者20
十一位和十二位是月份,这两位是01-12之间的数值
十三位和十四位是日期,是从01-31之间的数值
十五,十六,十七都是数字0-9
十八位可能是数字0-9,也可能是X
*/
var idcard_patter = /^[1-9][0-9]{5}([1][9][0-9]{2}|[2][0][0|1][0-9])([0][1-9]|[1][0|1|2])([0][1-9]|[1|2][0-9]|[3][0|1])[0-9]{3}([0-9]|[X])$/;
// 判断格式是否正确
var format = idcard_patter.test(idcard);
// 返回验证结果,校验码和格式同时正确才算是合法的身份证号码
return last === last_no && format ? true : false;
}
}
module.exports = IdcardClient;
// 函数参数必须是字符串,因为二代身份证号码是十八位,而在javascript中,十八位的数值会超出计算范围,造成不精确的结果,导致最后两位和计算的值不一致,从而该函数出现错误。
// 详情查看javascript的数值范围
function checkIDCard(idcode){
}
\ No newline at end of file
const system = require("../system");
var crypto = require('crypto');
var fs = require('fs');
var path = require('path');
var http = require("http");
var request = require('request');
const axios = require("axios");
class AppletBase {
constructor() {
this.redisClient = system.getObject("util.redisClient");
this.merchantSve = system.getObject("service.saas.merchantSve");
this.merchantappletuserSve = system.getObject("service.uc.merchantappletuserSve");
}
async getConfig(merchant_id) {
return await this.merchantSve.getSettings(merchant_id);
}
async getMerchant(merchant_id) {
return await this.merchantSve.getMerchantWithCache({id: merchant_id, forceUpdate: true});
}
async getLoginUser(merchant_id, openid, forceUpdate) {
return await this.merchantappletuserSve.getLoginUser({merchant_id: merchant_id, openid: openid, forceUpdate: forceUpdate});
}
async code2Session(obj, req) {
let wxConfig = await this.getConfig(obj.merchant_id);
let code = obj.code;
let url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxConfig.appid + "&secret=" + wxConfig.secret + "&grant_type=authorization_code&js_code=" + code;
try {
let rs = await axios({
method: 'post',
url: url,
});
// rtn = await this.rc.execGet({}, url);
console.log(rs.data);
console.log("code2Sessioncode2Sessioncode2Session");
// var result = JSON.parse(rtn.stdout);
return rs.data;
} catch (e) {
console.log(e);
return null;
}
}
async decryptData(obj) {
// base64 decode
var sessionKey = new Buffer(obj.sessionKey, 'base64')
var encryptedData = new Buffer(obj.encryptedData, 'base64')
var iv = new Buffer(obj.iv, 'base64')
try {
var decipher = crypto.createDecipheriv('aes-128-cbc', sessionKey, iv);
decipher.setAutoPadding(true);
var decoded = decipher.update(encryptedData, 'binary', 'utf8');
decoded += decipher.final('utf8');
decoded = JSON.parse(decoded);
} catch (err) {
console.log(err);
throw new Error('Illegal Buffer ' + JSON.stringify(obj) + " aaaaaaaaaa " + err.stack);
}
return decoded;
}
async getAccessToken() {
var rtn = null;
var url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + this.wxConfig.appid + "&secret=" + this.wxConfig.secret;
try {
rtn = await this.rc.execGet({}, url);
console.log(rtn);
console.log("code2Sessioncode2Sessioncode2Session");
var result = JSON.parse(rtn.stdout);
if (result && result.access_token) {
}
return result;
} catch (e) {
return null;
}
}
async getAK(type) {
type = type || 1;
var key = "access_token_" + this.wxConfig.appid;
var ak = await this.redisClient.get(key);
if (ak) {
return ak;
} else {
var rs = await this.getAccessToken(type);
if (rs && rs.access_token) {
ak = rs.access_token;
await this.redisClient.setWithEx(key, ak, 7000);
}
}
return ak || "";
}
async getIdCardInfo(imageUrl, type) {
type = type || 1;
var ak = await this.getAK(type);
if (!ak) {
return;
}
var url = "http://api.weixin.qq.com/cv/ocr/idcard?type=photo&img_url=" + encodeURI(imageUrl) + "&access_token=" + ak;
try {
var rtn = await this.rc.execGet({}, url);
console.log(rtn);
var result = JSON.parse(rtn.stdout);
return result;
} catch (e) {
console.log(e.stack)
return null;
}
}
async getBankInfo(imageUrl, type) {
type = type || 1;
var ak = await this.getAK(type);
if (!ak) {
return;
}
var url = "http://api.weixin.qq.com/cv/ocr/bankcard?img_url=" + encodeURI(imageUrl) + "&access_token=" + ak;
try {
var rtn = await this.rc.execGet({}, url);
console.log(rtn);
var result = JSON.parse(rtn.stdout);
return result;
} catch (e) {
console.log(e.stack)
return null;
}
}
async getWXACodeUnlimit(access_token, obj) {
var rtn = null;
var url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + access_token;
try {
rtn = await this.rc.execPost2(obj, url);
// var buf = Buffer.from(rtn.stdout, 'binary');
// console.log(rtn.stdout.from());
// var base64Data = rtn.stdout.replace(/^data:image\/\w+;base64,/, "");
// var dataBuffer = new Buffer(base64Data, 'base64');
// var result=JSON.parse(rtn);
// console.log(rtn.stdout);
return rtn.stdout;
} catch (e) {
return null;
}
}
async sendCustomerMessage(obj, type) {
var ctype = 1;
if (type) {
ctype = type;
}
var result = await this.getAccessToken(ctype);
console.log(result);
var url = ""
if (result && result.access_token) {
url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + result.access_token;
try {
return this.rc.execPost2(obj, url).stdout;
} catch (e) {
console.log(e);
return null;
}
}
}
async uploadTempMaterial(filepath, type) {
var ctype = 1;
if (type) {
ctype = type;
}
var that = this;
var form = { //构造表单
media: fs.createReadStream(filepath)
}
var result = await this.getAccessToken(ctype);
console.log(result);
var url = ""
if (result && result.access_token) {
return new Promise(function (resolve, reject) {
var url = 'https://api.weixin.qq.com/cgi-bin/media/upload?access_token=' + result.access_token + '&type=image';
request.post(url, {
formData: form,
json: true
}, function (err, res, body) {
if (err) {
reject(err);
} else {
console.log("111111qqqqqqqqqqqqqqq");
console.log(body);
resolve(body);
}
})
})
}
}
returnResult(code, msg, data) {
return {
code: code || 0,
msg: msg || "",
data: data
}
}
returnSuccess(data) {
return this.returnResult(1, "success", data)
}
returnFail(msg, data) {
return this.returnResult(0, msg, data);
}
trim(o) {
if (!o) {
return "";
}
return o.toString().trim();
}
getUidStr(len, radix) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
var uuid = [],
i;
radix = radix || chars.length;
if (len) {
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else {
var r;
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
uuid[14] = '4';
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
r = 0 | Math.random() * 16;
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
}
}
}
return uuid.join('');
}
}
module.exports = AppletBase;
// var task=new AppletBase();
// var imgpath = path.dirname(__filename) + '/impl/gzh.jpg';
// var c={media_id:"x-u4c1uLiHhV8h6ZiJ88M6FRx-HTYrlxH2x2eT00knFiuS1947klzUbwrWp5ePt6"};
// var text="4006-798-9999";
// var obj={'touser':'owD7y5JaO2DWzNqNk7cOz_nXBZAs','msgtype':'text','text':{content:"text"}};
// task.sendCustomerMessage(obj,3).then(function(result){
// console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
\ No newline at end of file
var system = require("../../system")
const http = require("http")
const querystring = require('querystring');
var settings = require("../../../config/settings");
const AppletBase = require("../applet.base");
const fs = require("fs");
const moment = require("moment");
class MerchantApplet extends AppletBase {
constructor() {
super();
this.uploadCtl=system.getObject("web.common.uploadCtl");
this.idcardClient = system.getObject("util.idcardClient");
this.merchantappletuserSve = system.getObject("service.uc.merchantappletuserSve");
this.merchantId = 1;
}
async test(o, obj, req) {
return {code: 0, data: 1};
}
async uploadConfig(gobj, pobj, req, loginUser){
try {
// if(!loginUser){
// return {code: 0};
// }
// var openid = loginUser.openId;
var data = await this.uploadCtl.getOssConfig();
return this.returnSuccess(data);
} catch (error) {
console.log(error);
return {code: 500};
}
}
// 登录接口 post
async login(o, obj, req) {
try {
let merchant_id = req.merchant_id;
let nickName = obj.nickName;
let avatarUrl = obj.avatarUrl;
let merchant = await this.getMerchant(merchant_id);
let user;
let wxSession = await this.code2Session(obj, req);
if (!wxSession.openid) {
return this.returnFail("登录信息解析错误,请重试");
}
let params = {
saas_merchant_id: merchant_id,
saas_id: merchant.saas_id,
openid: wxSession.openid,
nickName: nickName,
avatarUrl: avatarUrl,
};
let res = await this.merchantappletuserSve.login(params);
if(res.status === 0) {
return this.returnSuccess(res.data);
} else {
return this.returnFail(res.msg, res.data);
}
} catch (e) {
console.log(e.stack);
}
}
async loginUser(gobj, pobj, req, loginUser) {
let user = await this.getLoginUser(pobj.merchant_id, pobj.openid);
return this.returnSuccess(user);
}
//
// async commonInfo(gobj, pobj, req, loginUser) {
// var user = await this.bmuserSve.findById(loginUser.id);
// return {
// code : 1,
// data: {
// telphone: "15235755003",
// telphones: ["15235755003","15210210265"],
// }
// };
// }
//
//
// // 保存订单信息
// async saveOrder(gobj, pobj, req, loginUser) {
// try {
// var rs = await this.buildOrder(pobj, loginUser);
// if(rs.code === 0) {
// return rs;
// }
//
// var info = await this.bmorderSve.saveOrderBiz(rs.data);
// var result = {code : 1};
// return result;
// } catch (e) {
// console.log(e.stack);
// //日志记录
// logCtl.error({
// optitle: "查询商户信息错误, params [id = " + pobj.id + " ]",
// op: "wxapplet/impl/xggApplet/merchantInfo",
// content: e.stack,
// clientIp: req.clientIp
// });
// if(e.name == 'SequelizeUniqueConstraintError') {
// return {code: 2, msg:"您的信息已经提交成功,请到我的订单中查看"};
// }
// return {
// code: -200,
// msg: "error",
// data: {},
// stack : e.stack
// };
// }
// }
//
// async buildOrder(obj, loginUser) {
// var rs = {code: 0};
// if(!loginUser) {
// rs.msg = "登录超时,请重新登录";
// return rs;
// }
//
// if(!obj.idcard_front) {
// rs.msg = "请上传身份证正面图";
// return rs;
// }
// if(!obj.idcard_back) {
// rs.msg = "请上传身份证反面图";
// return rs;
// }
// if(!obj.idcard) {
// rs.msg = "请填写身份证号码";
// return rs;
// }
// if(!await this.idcardClient.checkIDCard(obj.idcard)) {
//
// }
// if(!obj.legal_name) {
// rs.msg = "请填写法人姓名";
// return rs;
// }
// if(!obj.legal_mobile) {
// rs.msg = "请填写手机号码";
// return rs;
// }
//
// if(!obj.companyNames) {
// rs.msg = "请填写公司名称";
// return rs;
// }
//
// if(!obj.bank_front) {
// rs.msg = "请上传银行卡正面图";
// return rs;
// }
// if(!obj.bank_back) {
// rs.msg = "请上传银行卡反面图";
// return rs;
// }
//
// if(!obj.bankMobile) {
// rs.msg = "请填写银行预留手机号";
// return rs;
// }
//
// var orderNo = loginUser.id + "" + moment().format("YYYYMMDDHHmmss");
// var order = {
// merchantId : obj.merchantId || this.merchantId,
// companyId : obj.companyId,
// orderNo : orderNo,
// userId : loginUser.id,
// ownerId: 0,
// status: 0,
// auditStatus:0
// };
//
// var userbiz = {
// merchantId : obj.merchantId || this.merchantId,
// companyId : obj.companyId,
// orderNo: orderNo,
// user_id: loginUser.id,
// idcard_front: obj.idcard_front,
// idcard_back: obj.idcard_back,
// idcard: obj.idcard,
// legal_name: obj.legal_name,
// legal_mobile: obj.legal_mobile,
// person_img: obj.person_img || "",
// companyNames: obj.companyNames,
// bank_front: obj.bank_front,
// bank_back: obj.bank_back,
// bank: obj.bank,
// bankno: obj.bankno,
// bankMobile: obj.bankMobile || "",
// };
//
// rs.code = 1;
// rs.data = {
// order : order,
// userbiz: userbiz,
// };
// return rs;
// }
//
//
// async myOrders(gobj, pobj, req, loginUser) {
// if(!loginUser) {
// return {code: 1, data:{count:0, rows:[]}};
// }
// try {
// var params = {
// pageSize: pobj.pageSize || 10,
// currentPage: pobj.currentPage || 1,
// userId: loginUser.id,
// }
//
// var page = await this.bmorderSve.pageByCondition(params);
// var result = {code : 1, data: page};
// return result;
// } catch (e) {
// console.log(e.stack);
// //日志记录
// logCtl.error({
// optitle: "绑定手机, params [" + JSON.stringify(params) + " ]",
// op: "wxapplet/impl/xggApplet/myReqList",
// content: e.stack,
// clientIp: req.clientIp
// });
// return {
// code: -200,
// msg: "error",
// data: {},
// stack : e.stack
// };
// }
//
// console.log(decryptData);
// }
//
//
// /**
// * 查询订单明细
// * @param {*} gobj
// * @param {*} pobj
// * @param {*} req
// * @param {*} loginUser
// */
// async queryOrderInfo(gobj, pobj, req, loginUser){
// if(!loginUser){
// return system.getResult(null, `请先登陆`);
// }
// try {
// return await this.bmorderSve.queryOrderInfo(pobj);
// } catch (error) {
// console.log(error);
// return system.getResult(null,error);
// }
// }
//
// async idcardValid(gobj, pobj, req, loginUser){
// try {
// var idcard = (pobj.idcard || "").trim();
// if(!idcard) {
// return {code: 0, msg: "请填写身份证号码"};
// }
//
// var isIdcard = await this.idcardClient.checkIDCard(idcard);
// if(isIdcard) {
// return {code: 1};
// }
// return {code: 0, msg: "身份证号码错误"};
// } catch (error) {
// console.log(error);
// return {code: 500, msg: "服务忙,请稍后重试"};
// }
// }
//
}
module.exports = MerchantApplet;
\ No newline at end of file
var url = require("url");
var System = require("../../base/system");
const settings = require("../settings");
module.exports = function (app) {
app.all("/applet/*", function (req, res, next) {
return next();
});
app.get('/applet/:qname/:method', async function (req, res) {
console.log("get");
try {
req.codepath = req.headers["codepath"];
var classPath = req.params["qname"];
var methodName = req.params["method"];
var tClientIp = System.get_client_ip(req);
var params = [];
req.openid = req.query.openid;
req.merchant_id = req.query.merchant_id;
req.query.saas_merchant_id = req.query.merchant_id;
params.push(req.query);
params.push(req);
var p = null;
var invokeObj = System.getObject("applet." + classPath);
if (invokeObj[methodName]) {
p = invokeObj[methodName].apply(invokeObj, params);
}
p.then(r => {
res.end(JSON.stringify(r));
});
} catch (e) {
console.log(e);
}
});
app.post('/applet/:qname/:method', async function (req, res) {
console.log("post");
req.codepath = req.headers["codepath"];
var classPath = req.params["qname"];
var methodName = req.params["method"];
var params = [];
req.openid = req.body.openid;
req.merchant_id = req.body.merchant_id;
req.body.saas_merchant_id = req.body.merchant_id; // 为历史买单,为要的急买单
params.push(req.query);
params.push(req.body);
var tClientIp = System.get_client_ip(req);
req.body.clientIp = tClientIp;
params.push(req);
var p = null;
var invokeObj = System.getObject("applet." + classPath);
if (invokeObj[methodName]) {
p = invokeObj[methodName].apply(invokeObj, params);
}
p.then(r => {
res.end(JSON.stringify(r));
}).then(() => {
params.pop();
if (params && params[1] && params[1].file) {
} else {
}
}).catch(e => {
console.log(e);
});
});
};
\ No newline at end of file
...@@ -16,14 +16,14 @@ ...@@ -16,14 +16,14 @@
## 登录相关 ## 登录相关
  1 [登录接口](/doc/user/login.md)   1 [登录接口](/doc/user/login.md)
## 渠道管理 ## 订单管理
  1 [渠道接口](/doc/saas/channel.md)   1 [订单接口](/doc/saas/order.md)
## 签约主体 ## 小程序接口
  1 [主体接口](/doc/saas/main.md)   1 [登录](/doc/applet/login.md)
  1 [订单](/doc/applet/order.md)
## 商户管理
  1 [商户接口](/doc/saas/merchant.md)
## 其他 ## 其他
......
<a name="menu">目录</a>
1. [登录](#login)
1. [当前用户信息查询](#currentUser)
## **<a name="login"> 登录</a>**
[返回到目录](#menu)
##### URL
[/web/uc/userCtl/login]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
```javascript
{
"code": "071KXwug1X4U2v0Idywg1MtDug1KXwuA", // 小程序wx.login返回code
"merchant_id": "11247613260000707", // 商户id,小程序写死
"nickName": "123", // 用户昵称
"avatarUrl": "https://" // 用户头像
}
```
#### 返回结果
```javascript
{
"code": 1,
"msg": "success",
"data": {
"openid": "od1Y85FIQbVye0WzZnAKnTh5YC6k", // openId
"nickName": "123", // 昵称
"avatarUrl": "https:/", // 头像
}
}
```
## **<a name="currentUser"> 当前用户信息查询</a>**
[返回到目录](#menu)
##### URL
[/web/uc/userCtl/currentUser]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"openid": "od1Y85FIQbVye0WzZnAKnTh5YC6k",
"merchant_id": "11247613260000707"
}
```
#### 返回结果
```javascript
{
"code": 1,
"msg": "success",
"data": {
"openid": "od1Y85FIQbVye0WzZnAKnTh5YC6k", // openId
"nickName": "123", // 昵称
"avatarUrl": "https:/", // 头像
}
}
```
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