Commit bfbe91ad by 陈思聪

fix: 新资质产品接入

parent df8fcb55
......@@ -22,6 +22,19 @@ class NewdeliverCtl extends CtlBase {
}
}
// 查询新材料详情
async findNewMaterial(pobj, qobj, req) {
try {
if (!pobj.id) {
throw new Error("参数错误")
}
const rs = await this.service.findNewMaterial(pobj);
return system.getResult(rs);
} catch (err) {
return system.getResult(null, err.message)
}
}
// 提交材料
async submitMaterials(pobj, qobj, req) {
......@@ -49,6 +62,19 @@ class NewdeliverCtl extends CtlBase {
}
}
// 编辑收件人信息
async updateRecipient(pobj, qobj, req) {
try {
if (!pobj.id) {
throw new Error("参数错误")
}
const rs = await this.service.updateRecipient(pobj);
return system.getResult(rs);
} catch (err) {
return system.getResult(null, err.message)
}
}
async addQualification(pobj, qobj, req) {
if (!pobj.id) {
return system.getResult(null, "deliver_id can not be empty,100290");
......
......@@ -29,8 +29,15 @@ class DeliverDao extends Dao {
let type = qobj.bizpath.split('/')[1];
if (type === 'deliveryManagement') {
qc.where.product_code = qc.where.product_code && [system.SERVICECODE.EDI, system.SERVICECODE.ICP].includes(qc.where.product_code) ? qc.where.product_code : {
$in: [system.SERVICECODE.EDI, system.SERVICECODE.ICP]
const serviceCodes = [system.SERVICECODE.EDI, system.SERVICECODE.ICP,system.SERVICECODE.IDC,system.SERVICECODE.ISP,
system.SERVICECODE.SP ,system.SERVICECODE.CCL,system.SERVICECODE.CDN,system.SERVICECODE.NCBI_AM,system.SERVICECODE.NCBI_lB,system.SERVICECODE.BC,
system.SERVICECODE.IEP,system.SERVICECODE.HRSL,system.SERVICECODE.LDP,system.SERVICECODE.RTPPOL, system.SERVICECODE.PBL_R, system.SERVICECODE.PBL_W,
system.SERVICECODE.CPL, system.SERVICECODE.ISO9001, system.SERVICECODE.ISO14001, system.SERVICECODE.ISO27001, system.SERVICECODE.ISO20000,
system.SERVICECODE.ISO45001,system.SERVICECODE.IONHTE, system.SERVICECODE.SISSM, system.SERVICECODE.SSGEI, system.SERVICECODE.DSCC, system.SERVICECODE.HTACS,
system.SERVICECODE.BL_TMD, system.SERVICECODE.BF_TMD, system.SERVICECODE.IDISL_B, system.SERVICECODE.IDISL_NB, system.SERVICECODE.LPE_2, system.SERVICECODE.LPE_3,
]
qc.where.product_code = qc.where.product_code && serviceCodes.includes(qc.where.product_code) ? qc.where.product_code : {
$in: serviceCodes
}
switch (qobj.bizpath) {
......
......@@ -16,6 +16,7 @@ class QualificationDao extends Dao {
certificateNumber: pobj.certificateNumber,
endAt: pobj.endAt,
file: pobj.file,
acceptNotifyFile: pobj.acceptNotifyFile,
serviceProject: pobj.serviceProject,
startAt: pobj.startAt,
deliver_id: pobj.deliver_id
......
......@@ -33,6 +33,10 @@ module.exports = (db, DataTypes) => {
file: {
allowNull: false,
type: DataTypes.JSON
},
acceptNotifyFile: {
allowNull: true,
type: DataTypes.JSON
}
}, {
paranoid: false,//假的删除
......
......@@ -25,6 +25,48 @@ class NewdeliverService extends ServiceBase {
return result;
}
async findNewMaterial(pobj, qobj, req) {
const result = await this.newmaterialDao.findOne({
deliver_id: pobj.id
});
return result;
}
// 编辑收件人信息
async updateRecipient(pobj){
const materialInfo = await this.newmaterialDao.findOne({
deliver_id: pobj.id
});
let cacheInfo = {};
if(!materialInfo){
// 如果缓存信息为空
cacheInfo = {
recipientInfo:{
addr: pobj.recipientInfo.addr,
name: pobj.recipientInfo.name,
phone: pobj.recipientInfo.phone,
expressNum: pobj.recipientInfo.expressNum
}
}
}else{
cacheInfo = materialInfo.materialInfo;
cacheInfo.recipientInfo = {
addr: pobj.recipientInfo.addr,
name: pobj.recipientInfo.name,
phone: pobj.recipientInfo.phone,
expressNum: pobj.recipientInfo.expressNum
}
}
const params = {
deliver_id: pobj.id,
cache_info: cacheInfo
}
return await this.submitMaterials(params);
}
async submitMaterials(pobj, qobj, req) {
const deliverData = await this.deliveryDao.findOne({
id: pobj.deliver_id
......@@ -34,7 +76,7 @@ class NewdeliverService extends ServiceBase {
throw new Error("查不到此交付单");
}
if ([system.SERVERSESTATUS.COLLECTING, system.SERVERSESTATUS.USERCONFIRMATIONREJECT, system.SERVERSESTATUS.FILLING].includes(deliverData.delivery_status)) {
await TOQFT.getClientByType(deliverData.product_code).submitMaterials(pobj.username, deliverData, pobj.cache_info);
await TOQFT.getClientByTypeAndChannel(deliverData.product_code, deliverData.source_number).submitMaterials(pobj.username, deliverData, pobj.cache_info);
}
return this.db.transaction(async (t) => {
......@@ -107,7 +149,7 @@ class NewdeliverService extends ServiceBase {
throw new Error("此状态手动不能更改");
}
await TOQFT.getClientByType(deliverData.product_code).changeStatus(pobj.username, deliverData);
await TOQFT.getClientByTypeAndChannel(deliverData.product_code, deliverData.source_number).changeStatus(pobj.username, deliverData);
await this.deliveryDao.updateByWhere({
delivery_status: status
......
const BaseClient = require("./baseClient")
const settings = require("../../../config/settings");
const system = require("../../system");
const moment = require("moment");
const qualificationDao = system.getObject("db.delivery.qualificationDao");
const { appKey, secret } = settings;
/**
* 通用资质类 产品
*/
class CommonVatClient extends BaseClient {
constructor() {
super(appKey, secret, "/web/action/qcapi/springBoard");
this.instance = null;
this.CIRCUITSTATUS = {
ACCOUNTREGISTRATION: 507, // 完成账户注册
SUBMITING: 508, // 提交材料到工信部
DISPOSEING: 509, // 工信部已受理
DISPOSEINGFAIL: 510, // 工信不予受理
THROUGH: 511, // 工信部通过
THROUGHFAIL: 512 // 工信部未通过
}
this.newmaterialDao = system.getObject("db.delivery.newmaterialDao");
this.qualificationDao = system.getObject("db.delivery.qualificationDao");
}
static getInstance() {
if (!this.instance) {
this.instance = new CommonVatClient();
}
return this.instance;
}
/**
* 递交材料
* @param {*} deliverData
* @param {*} materials
*/
async submitMaterials(username, deliverData, materials) {
const params={
username,
deliverData,
materials,
}
console.log(`【commonVatClient-submitMaterials】递交材料 方法入参,(deliveryId=${deliverData.id}),请求参数:`+JSON.stringify(params))
// 如果办理材料为空,则查询数据库
let businessLicense = {};
let recipientInfo = {};
let applyMaterial = {}; //办理材料
let acceptNotifyFileUrl = ''; // 受理通知书url
let certificateFileUrl = ''; // 证书文件url
if(!materials || Object.keys(materials).length == 0){
const materialData = await this.newmaterialDao.findOne({
deliver_id: deliverData.id,
});
if(materialData && materialData.materialInfo && materialData.materialInfo.businessLicense){
businessLicense = materialData.materialInfo.businessLicense;
}
if(materialData && materialData.materialInfo && materialData.materialInfo.recipientInfo){
recipientInfo = materialData.materialInfo.recipientInfo;
}
if(materialData && materialData.materialInfo && materialData.materialInfo.materialFile && materialData.materialInfo.materialFile.applyMaterial){
applyMaterial = materialData.materialInfo.materialFile.applyMaterial;
}
}
const qualificationData = await this.qualificationDao.findOne({
deliver_id: deliverData.id
});
if(qualificationData){
acceptNotifyFileUrl = qualificationData.acceptNotifyFile;
certificateFileUrl = qualificationData.file
}
const pushParams = {
orderNo: deliverData.delivery_code,
companyName: businessLicense.name != undefined ? businessLicense.name: null,
applyMaterial: applyMaterial.url != undefined ? applyMaterial.url: null,
user: {
name: recipientInfo.name != undefined ? recipientInfo.name: null,
phone: recipientInfo.phone != undefined ? recipientInfo.phone: null,
addr: recipientInfo.addr != undefined ? recipientInfo.addr: null,
},
acceptNotifyFile: acceptNotifyFileUrl != undefined?acceptNotifyFileUrl:null, // 受理通知书
certificateFile: certificateFileUrl!=undefined?certificateFileUrl:null,// 证书文件
expressNum: recipientInfo.expressNum!=undefined?recipientInfo.expressNum:null,
status: null,
};
console.log(`【commonVatClient-submitMaterials】开始调用启服通 递交材料 接口(deliveryId=${deliverData.id}),请求参数:`+JSON.stringify(pushParams))
const res = await this.pushQiFuTong(username, {
actionType: "serviceProviderNotification",
actionBody: pushParams
});
console.log(`【commonVatClient-submitMaterials】结束调用启服通 递交材料 接口(deliveryId=${deliverData.id}),请求参数:${JSON.stringify(pushParams)} `)
// system.execLogs(`请求启服通`, {url, data, headers }, '交付请求', result, null)
}
/**
* 改变 状态
* @param {*} status
* @param {*} sendMessage 办理的资质文件等
*/
async changeStatus(username, deliverData, materials = {}) {
const params ={
username,
deliverData,
materials
}
console.log(`【commonVatClient-changeStatus】改变状态 方法入参,(deliveryId=${deliverData.id}),请求参数:`+JSON.stringify(params))
let status;
switch (deliverData.delivery_status) {
case system.SERVERSESTATUS.USERCONFIRMATIONRESOLVE:
case system.SERVERSESTATUS.COLLECTSUCCESS:
status = this.CIRCUITSTATUS.ACCOUNTREGISTRATION
break
case system.SERVERSESTATUS.ACCOUNTREGISTRATION:
status = this.CIRCUITSTATUS.SUBMITING
break
case system.SERVERSESTATUS.SUBMITING:
status = this.CIRCUITSTATUS.DISPOSEING
break
case system.SERVERSESTATUS.DISPOSEING:
status = this.CIRCUITSTATUS.THROUGH
break
case system.SERVERSESTATUS.THROUGH:
return "SUCCESS"
default:
throw new Error("此状态不能手动更改");
}
// 如果办理材料为空,则查询数据库
let businessLicense = {};
let recipientInfo = {};
let applyMaterial = {}; //办理材料
let acceptNotifyFileUrl = ''; // 受理通知书url
let certificateFileUrl = ''; // 证书文件url
if(!materials || Object.keys(materials).length == 0){
const materialData = await this.newmaterialDao.findOne({
deliver_id: deliverData.id,
});
if(materialData && materialData.materialInfo && materialData.materialInfo.businessLicense){
businessLicense = materialData.materialInfo.businessLicense;
}
if(materialData && materialData.materialInfo && materialData.materialInfo.recipientInfo){
recipientInfo = materialData.materialInfo.recipientInfo;
}
if(materialData && materialData.materialInfo && materialData.materialInfo.materialFile && materialData.materialInfo.materialFile.applyMaterial){
applyMaterial = materialData.materialInfo.materialFile.applyMaterial;
}
}
const qualificationData = await this.qualificationDao.findOne({
deliver_id: deliverData.id
});
if(qualificationData){
acceptNotifyFileUrl = qualificationData.acceptNotifyFile;
certificateFileUrl = qualificationData.file
}
const pushParams = {
orderNo: deliverData.delivery_code,
companyName: businessLicense.name != undefined ? businessLicense.name: null,
applyMaterial: applyMaterial.url != undefined ? applyMaterial.url: null,
user: {
name: recipientInfo.name != undefined ? recipientInfo.name: null,
phone: recipientInfo.phone != undefined ? recipientInfo.phone: null,
addr: recipientInfo.addr != undefined ? recipientInfo.addr: null,
},
acceptNotifyFile: acceptNotifyFileUrl != undefined?acceptNotifyFileUrl:null, // 受理通知书
certificateFile: certificateFileUrl!=undefined?certificateFileUrl:null,// 证书文件
expressNum: recipientInfo.expressNum!=undefined?recipientInfo.expressNum:null,
status: status
};
console.log(`【commonVatClient-changeStatus】开始调用启服通提交材料接口 ,(deliveryId=${deliverData.id}),请求参数:`+JSON.stringify(pushParams))
await this.pushQiFuTong(username, {
actionType: "serviceProviderNotification",
actionBody: pushParams
});
console.log(`【commonVatClient-changeStatus】结束调用启服通提交材料接口 ,(deliveryId=${deliverData.id}),请求参数:${JSON.stringify(pushParams)} `)
}
}
module.exports = CommonVatClient
\ No newline at end of file
......@@ -3,6 +3,7 @@ const wangwenClient = require("./wangwenClient")
const pannongClient = require("./pannongClient")
const guangboClient = require("./guangboClient")
const gongshangClient = require("./gongshangClient")
const commonVatClient = require("./commonVatClient")
const system = require("../../system");
......@@ -34,6 +35,69 @@ function getClientByType(type) {
}
}
/**
* 根据产品类型、渠道选择不同的方法
* @param {*} type
* @param {*} channel
*/
function getClientByTypeAndChannel(type,channel) {
switch (type) {
case system.SERVICECODE.ICP:
case system.SERVICECODE.EDI:
case system.SERVICECODE.IDC:
case system.SERVICECODE.ISP:
case system.SERVICECODE.SP:
case system.SERVICECODE.CCL:
case system.SERVICECODE.CDN:
case system.SERVICECODE.NCBI_AM:
case system.SERVICECODE.NCBI_lB:
case system.SERVICECODE.BC:
case system.SERVICECODE.IEP:
case system.SERVICECODE.HRSL:
case system.SERVICECODE.LDP:
case system.SERVICECODE.RTPPOL:
case system.SERVICECODE.PBL_R:
case system.SERVICECODE.PBL_W:
case system.SERVICECODE.CPL:
case system.SERVICECODE.ISO9001:
case system.SERVICECODE.ISO14001:
case system.SERVICECODE.ISO27001:
case system.SERVICECODE.ISO20000:
case system.SERVICECODE.ISO45001:
case system.SERVICECODE.IONHTE:
case system.SERVICECODE.SISSM:
case system.SERVICECODE.SSGEI:
case system.SERVICECODE.DSCC:
case system.SERVICECODE.HTACS:
case system.SERVICECODE.BL_TMD:
case system.SERVICECODE.BF_TMD:
case system.SERVICECODE.IDISL_B:
case system.SERVICECODE.IDISL_NB:
case system.SERVICECODE.LPE_2:
case system.SERVICECODE.LPE_3: //, system.SERVICECODE.EDI
if([system.SERVICECODE.ICP,system.SERVICECODE.EDI].includes(type) && ['aliCloud','zc360','baidu','ename'].includes(channel)){ // 这4个渠道的icp、edi走老接口
return vatClient.getInstance();
}else{
return commonVatClient.getInstance();
}
case system.SERVICECODE.WANGWEN:
return wangwenClient.getInstance();
case system.SERVICECODE.PANNONG:
return pannongClient.getInstance();
case system.SERVICECODE.GUANGBO:
return guangboClient.getInstance();
case system.SERVICECODE.COMPANYCASE:
case system.SERVICECODE.OPENBANKACCOUNTCASE:
case system.SERVICECODE.TAXCASE:
case system.SERVICECODE.REGADDRCASE1:
case system.SERVICECODE.AGENTCASE1:
return gongshangClient.getInstance();
default:
throw new Error("无此产品类型");
}
}
module.exports = {
getClientByType
getClientByType,
getClientByTypeAndChannel
}
\ No newline at end of file
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