Commit 023fd55b by 赵庆

gsb

parent a5e4def7
......@@ -4,6 +4,7 @@ class EntcontractApi {
constructor() {
this.entcontractSve = system.getObject("service.entcontractSve");
this.ecompanybusiSve = system.getObject("service.ecompanybusiSve");
this.idcardClient = system.getObject("util.idcardClient");
}
async autoSign(pobj) {
......@@ -68,7 +69,6 @@ class EntcontractApi {
if (param.sign != sign) {
return this.returnjson(1001001, "签名错误");
}
try {
var result = await this.entcontractSve.autoSign(param);
return result;
......@@ -77,76 +77,75 @@ class EntcontractApi {
}
}
async sinedUsers3rd(obj, req) {
// 验证合法性
var appId = obj.appId;
var nonceStr = obj.nonceStr;
var idNo = obj.idNo;
var startId = obj.startId || 0;
var userId = obj.userId || "";
var pageSize = 20;
async autoSignToPer(pobj) {
// 处理参数
var param = {
ecid: this.trim(pobj.ecid),
appId: this.trim(pobj.appId),
userId: this.trim(pobj.userId),
idName: this.trim(pobj.idName),
mobile: this.trim(pobj.mobile),
idNo: this.trim(pobj.idNo),
nonceStr: this.trim(pobj.nonceStr),
sign: this.trim(pobj.sign)
};
if (!param.ecid) {
return this.returnjson(-1, "请传入薪必果提供的ecid")
}
if (!param.appId) {
return this.returnjson(-1, "请传入薪必果提供的appId")
}
if (!param.userId) {
return this.returnjson(-1, "请提供该用户的userId")
}
if (!param.idName) {
return this.returnjson(-1, "请提供该用户姓名")
}
if (!param.idNo) {
return this.returnjson(-1, "请提供该用户身份证号")
}else {
if(!await this.idcardClient.checkIDCard(param.idNo)){
return this.returnjson(-1, "身份证格式不正确");
}
}
if (!param.nonceStr) {
return this.returnjson(-1, "请提供随机码")
}
// 查appId关联key
var busi = await this.ecompanybusiSve.findOne({
appId: appId
appId: param.appId
});
if (!busi) {
return {
code: 1001003,
msg: "配置信息错误,请联系薪必果人员进行配置"
};
if (!busi || !busi.key) {
return this.returnjson(1001003, "配置信息错误,请联系薪必果人员进行配置");
}
// 签名
var signArr = [];
signArr.push("appId=" + appId);
signArr.push("idNo=" + idNo);
signArr.push("nonceStr=" + nonceStr);
signArr.push("startId=" + startId);
signArr.push("userId=" + userId);
signArr.push("key=" + busi.key);
var sign = md5(signArr.join("&")).toUpperCase();
if (sign != obj.sign) {
return {
code: 1001001,
msg: "签名失败"
};
}
var params = {
ecompanyId: busi.ecompany_id,
startId: startId,
idNo: idNo,
pageSize: pageSize,
userId3rd: userId,
};
var keys = Object.keys(param).sort();
for (var i = 0; i < keys.length; i++) {
var k = keys[i];
var v = param[k];
if (!k || !v || k == 'sign') {
continue;
}
signArr.push(k + "=" + v);
}
var signStr = signArr.join("&") + "&key=" + busi.key;
var sign = md5(signStr).toUpperCase();
if (param.sign != sign) {
return this.returnjson(1001001, "签名错误");
}
try {
var userList = await this.entcontractSve.findSignedUses4Push(params);
var result = {
code: 0,
msg: "success",
};
result.data = userList;
return result;
} catch (e) {
var result = {
code: 500,
msg: "接口异常"
};
console.log(e.stack);
//日志记录
logCtl.error({
optitle: "校验是否签约error",
op: "api/econtractApi/validContract",
content: e.stack,
clientIp: req.clientIp
});
var result = await this.entcontractSve.autoSignToPer(param);
return result;
} catch (error) {
console.log(error);
}
}
trim(o) {
if (!o) {
return "";
......@@ -154,7 +153,6 @@ class EntcontractApi {
return o.toString().trim();
}
returnjson(code, msg, data) {
return {
code: code,
......
const system = require("../../system");
const Dao = require("../dao.base");
class YzmerchantsignedDao extends Dao {
constructor() {
super(Dao.getModelName(YzmerchantsignedDao));
}
async getById(id) {
return await this.model.findOne({where: {id: id}, raw: true});
}
}
module.exports = YzmerchantsignedDao;
const system = require("../../system");
const settings = require("../../../config/settings");
const uiconfig = system.getUiConfig2(settings.wxconfig.appId);
module.exports = (db, DataTypes) => {
return db.define("yzmerchantsigned", {
companyName: DataTypes.STRING,
appId: DataTypes.STRING,
mchtId: DataTypes.STRING,
mainId: DataTypes.STRING,
secret: DataTypes.STRING,
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'c_yzmerchant_signed',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
\ No newline at end of file
const system = require("../../system");
const ServiceBase = require("../sve.base")
class YzmerchantsignedService extends ServiceBase {
constructor() {
super(ServiceBase.getDaoName(YzmerchantsignedService));
}
}
module.exports = YzmerchantsignedService;
......@@ -859,11 +859,6 @@
"resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz",
"integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs="
},
"crypto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz",
"integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig=="
},
"crypto-js": {
"version": "3.1.9-1",
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-3.1.9-1.tgz",
......
......@@ -19,7 +19,6 @@
"connect-redis": "^3.3.3",
"continuation-local-storage": "^3.2.1",
"cookie-parser": "^1.4.3",
"crypto": "^1.0.1",
"crypto-js": "^3.1.9-1",
"debug": "2.6.9",
"easyimage": "^3.1.0",
......
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