91 lines
3.8 KiB
JavaScript
91 lines
3.8 KiB
JavaScript
'use strict';
|
|
module.exports = {
|
|
/**
|
|
* XXXnameXXX
|
|
* @url client/timedTask/pub/task 前端调用的url参数地址
|
|
* data 请求参数
|
|
* @param {String} params1 参数1
|
|
*/
|
|
main: async (event) => {
|
|
let {data = {}, userInfo, util, filterResponse, originalParam} = event;
|
|
let {customUtil, uniID, config, pubFun, vk, db, _} = util;
|
|
let {uid} = data;
|
|
let res = {code: 0, msg: ""};
|
|
// 业务逻辑开始-----------------------------------------------------------
|
|
|
|
if (data.key !== 'lsgjoksdjf') return {code: 1, msg: '非法请求'}
|
|
|
|
const certificateList = await vk.baseDao.select({
|
|
dbName: "jjx-certificate",
|
|
whereJson: {
|
|
hasReport: false,
|
|
paidConfirm: true
|
|
}
|
|
});
|
|
// console.log('certificateList', certificateList)
|
|
const url = 'https://tczapi.fadada.com/czapi/api/compliance-contract-report'
|
|
// const url = 'https://czapi-test.fadada.com/evidence-api/api/compliance-contract-report'
|
|
for (let i = 0; i < certificateList.rows.length; i++) {
|
|
const certificate = certificateList.rows[i];
|
|
const contract = await vk.baseDao.findById({
|
|
dbName: "jjx-contract",
|
|
id: certificate.contractId
|
|
});
|
|
// console.log('contract', contract)
|
|
// console.log('deliveryMethods', certificate.deliveryMethods)
|
|
if (certificate.deliveryMethods.paper) {
|
|
const result = await pubFun.fadada(url, {
|
|
contractNum: contract.transactionId,
|
|
// contractNum: 'C2510141800348945357 ',
|
|
evidenceType: 0,
|
|
'reportExpressInfo.name': certificate.paperDelivery.receiver,
|
|
'reportExpressInfo.mobile': certificate.paperDelivery.phone,
|
|
'reportExpressInfo.address': certificate.paperDelivery.address,
|
|
}, true)
|
|
console.log('certificate', {
|
|
contractNum: contract.transactionId,
|
|
evidenceType: 0,
|
|
'reportExpressInfo.name': certificate.paperDelivery.receiver,
|
|
'reportExpressInfo.mobile': certificate.paperDelivery.phone,
|
|
'reportExpressInfo.address': certificate.paperDelivery.address,
|
|
})
|
|
if (parseInt(result.code) === 1000) {
|
|
await vk.baseDao.update({
|
|
dbName: "jjx-certificate",
|
|
whereJson: {
|
|
contractId: certificate.contractId
|
|
},
|
|
dataJson: {
|
|
hasReport: true,
|
|
reportData: result.data
|
|
}
|
|
});
|
|
}
|
|
} else {
|
|
const result = await pubFun.fadada(url, {
|
|
contractNum: contract.transactionId,
|
|
evidenceType: 2
|
|
}, true)
|
|
// console.log('compliance-contract-report', result)
|
|
|
|
if (parseInt(result.code) === 1000) {
|
|
await vk.baseDao.update({
|
|
dbName: "jjx-certificate",
|
|
whereJson: {
|
|
contractId: certificate.contractId
|
|
},
|
|
dataJson: {
|
|
hasReport: true,
|
|
downloadUrl: result.data.downloadUrl,
|
|
reportData: result.data
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
// 业务逻辑结束-----------------------------------------------------------
|
|
return res;
|
|
}
|
|
}
|