Commit 72b96f35 by zhaoxiqing

gsb

parent 61ebcf44
...@@ -26,13 +26,15 @@ class EntcontractService extends ServiceBase { ...@@ -26,13 +26,15 @@ class EntcontractService extends ServiceBase {
this.URL = "http://39.106.185.66:8000/merchant/busi/reg"; this.URL = "http://39.106.185.66:8000/merchant/busi/reg";
this.YZKEY = "4a112ce87c38464d8d454caf23b7b31f" this.YZKEY = "4a112ce87c38464d8d454caf23b7b31f";
this.YZHDURL = "http://bifrost-youzan-gateway.qa.s.qima-inc.com/api/auth_exempt/youzan.pay.finance.tax.sign.merchant.gsb.notify/1.0.0";
} }
async getAppConfig() { async getAppConfig() {
return { return {
appId : "1201869719607517185", appId: "1201869719607517185",
key : "bee7870e008ab144bf518b70ef91f8ac", key: "bee7870e008ab144bf518b70ef91f8ac",
} }
} }
...@@ -204,7 +206,6 @@ class EntcontractService extends ServiceBase { ...@@ -204,7 +206,6 @@ class EntcontractService extends ServiceBase {
} }
async createYzMerchant(params) { async createYzMerchant(params) {
var data = { var data = {
appId: "1202849621743763458", appId: "1202849621743763458",
...@@ -279,17 +280,17 @@ class EntcontractService extends ServiceBase { ...@@ -279,17 +280,17 @@ class EntcontractService extends ServiceBase {
} }
let ecompany = await this.ecompanyDao.findOne({ let ecompany = await this.ecompanyDao.findOne({
"name" : params.merchantName, "name": params.merchantName,
}) })
if(!ecompany) { if (!ecompany) {
// 创建ecompany // 创建ecompany
ecompany = await this.ecompanyDao.create({ ecompany = await this.ecompanyDao.create({
"name" : params.merchantName, "name": params.merchantName,
"nameA" : '', "nameA": '',
"isEnabled" : true, "isEnabled": true,
"isQuiet" : true, "isQuiet": true,
"sealurl" : "", "sealurl": "",
"encryptkey" : "", "encryptkey": "",
"posturl": "" "posturl": ""
}); });
} }
...@@ -299,22 +300,22 @@ class EntcontractService extends ServiceBase { ...@@ -299,22 +300,22 @@ class EntcontractService extends ServiceBase {
let template = await this.etemplateDao.findOne({ let template = await this.etemplateDao.findOne({
ecompany_id: ecompany.id, ecompany_id: ecompany.id,
}); });
if(!template) { if (!template) {
template = await this.etemplateDao.create({ template = await this.etemplateDao.create({
ecompany_id:ecompany.id, ecompany_id: ecompany.id,
name:ecompany.name, name: ecompany.name,
templateid:temp.templateid, templateid: temp.templateid,
ecompanyMainId: temp.ecompanyMainId, ecompanyMainId: temp.ecompanyMainId,
nameA: temp.nameA, nameA: temp.nameA,
filekey:temp.filekey,//e签宝返回文件key filekey: temp.filekey,//e签宝返回文件key
filepath:temp.filepath,//需要在后台补充 filepath: temp.filepath,//需要在后台补充
placeholderkey:temp.placeholderkey,//模板占位信息 placeholderkey: temp.placeholderkey,//模板占位信息
isEnabled:true, isEnabled: true,
}); });
} }
reso.data.ecid = template.id; reso.data.ecid = template.id;
if(!erchants.ecid) { if (!erchants.ecid) {
erchants.ecid = template.id; erchants.ecid = template.id;
await erchants.save(); await erchants.save();
} }
...@@ -323,7 +324,7 @@ class EntcontractService extends ServiceBase { ...@@ -323,7 +324,7 @@ class EntcontractService extends ServiceBase {
ecompany_id: ecompany.id, ecompany_id: ecompany.id,
etemplate_id: template.id, etemplate_id: template.id,
}); });
if(!busi) { if (!busi) {
await this.ecompanybusiDao.create({ await this.ecompanybusiDao.create({
ecompany_id: ecompany.id, ecompany_id: ecompany.id,
etemplate_id: template.id, etemplate_id: template.id,
...@@ -540,13 +541,13 @@ class EntcontractService extends ServiceBase { ...@@ -540,13 +541,13 @@ class EntcontractService extends ServiceBase {
let merchantSign = await this.yzmerchantsignedDao.findOne({ let merchantSign = await this.yzmerchantsignedDao.findOne({
entcontract_id: entcontract.id, entcontract_id: entcontract.id,
}); });
if(!merchantSign) { if (!merchantSign) {
return this.returnjson(500, "数据错误"); return this.returnjson(500, "数据错误");
} }
let res = { let res = {
code: 0, code: 0,
msg:"执行成功", msg: "执行成功",
data: { data: {
ecid: merchantSign.ecid, ecid: merchantSign.ecid,
appId: merchantSign.appId, appId: merchantSign.appId,
...@@ -706,7 +707,7 @@ class EntcontractService extends ServiceBase { ...@@ -706,7 +707,7 @@ class EntcontractService extends ServiceBase {
} }
if (!contract.fileurl) { if (!contract.fileurl) {
await this.syncYzSign(2134); //await this.syncYzSign(2134);
// 请求文件地址 // 请求文件地址
let fileRs = await this.utilesignbaoSve.downloadUserContractFile(contract.eflowid, "econtractSve"); let fileRs = await this.utilesignbaoSve.downloadUserContractFile(contract.eflowid, "econtractSve");
if (fileRs.code == 1 && fileRs.data.selfossUrl) { if (fileRs.code == 1 && fileRs.data.selfossUrl) {
...@@ -755,7 +756,7 @@ class EntcontractService extends ServiceBase { ...@@ -755,7 +756,7 @@ class EntcontractService extends ServiceBase {
// 查用户 // 查用户
var user = await this.userDao.findById(account.user_id); var user = await this.userDao.findById(account.user_id);
// 查商户签约返回值 // 查商户签约返回值
let signInfo =await this.yzmerchantsignedDao.findOne({entcontract_id: contractId}); let signInfo = await this.yzmerchantsignedDao.findOne({entcontract_id: contractId});
if (!signInfo) { if (!signInfo) {
return null; return null;
} }
...@@ -769,7 +770,7 @@ class EntcontractService extends ServiceBase { ...@@ -769,7 +770,7 @@ class EntcontractService extends ServiceBase {
"fileUrl": contract.fileurl, // 签约合同pdf文件 "fileUrl": contract.fileurl, // 签约合同pdf文件
"idName": account.userName, // 代理人姓名 "idName": account.userName, // 代理人姓名
"idNo": account.personsSign, // 代理人身份证 "idNo": account.personsSign, // 代理人身份证
"mobile" : account.mobile, //代理人手机号 "mobile": account.mobile, //代理人手机号
"nonceStr": await this.getUidStr(16), // 随机码 "nonceStr": await this.getUidStr(16), // 随机码
"beginDate": await this.formateTime(contract.begin_at), // 合同开始时间 "beginDate": await this.formateTime(contract.begin_at), // 合同开始时间
"endDate": await this.formateTime(contract.end_at), // 合同结束时间 "endDate": await this.formateTime(contract.end_at), // 合同结束时间
...@@ -785,20 +786,33 @@ class EntcontractService extends ServiceBase { ...@@ -785,20 +786,33 @@ class EntcontractService extends ServiceBase {
console.log(JSON.stringify(param)); console.log(JSON.stringify(param));
var rs = ""; var rs = "";
try { try {
var rs = await this.restClient.execPost(param, "有赞给出的回调地址"); rs = await axios({
if (rs.stdout) { method: 'post',
let rsData = JSON.parse(rs.stdout); url: this.YZHDURL,
if (rsData.code == "0" || rsData.code == "0000") { data: param,
account.isPush = true; headers: {'X-Service-Chain': {"name":"prj0015875"}},
account.save(); });
}
}
return rs.stdout;
} catch (error) { } catch (error) {
console.log(rs, "push sign url " + busi.postsignurl, "rs = " + rs); console.log(rs, "push sign url 有赞回调接口", "rs = " + rs);
console.log(error); console.log(error);
return "error"; return "error";
} }
// try {
// var rs = await this.restClient.execPost(param, "http://bifrost-youzan-gateway.qa.uth_exence.tax.sign.merchant.gsb.notify/1.0.");
// if (rs.stdout) {
// let rsData = JSON.parse(rs.stdout);
// if (rsData.code == "0" || rsData.code == "0000") {
// account.isPush = true;
// account.save();
// }
// }
// return rs.stdout;
// } catch (error) {
// console.log(rs, "push sign url 有赞回调接口", "rs = " + rs);
// console.log(error);
// return "error";
// }
} }
async formateTime(inputTime) { async formateTime(inputTime) {
......
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