Commit 72b96f35 by zhaoxiqing

gsb

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