Commit c18cfc80 by 陈思聪

feat:百度工商注册新流程

parent 7eaf66ae
...@@ -5,6 +5,19 @@ class CompanycaseCtl extends CtlBase { ...@@ -5,6 +5,19 @@ class CompanycaseCtl extends CtlBase {
super("delivery", CtlBase.getServiceName(CompanycaseCtl)); super("delivery", CtlBase.getServiceName(CompanycaseCtl));
} }
/* 接受到百度推送过来的工商注册申请材料 */
async receiveSubmitMaterialsFormBaidu(pobj) {
let data = pobj.d;
console.log("接受到百度推送过来的工商注册申请材料:"+JSON.stringify(data))
try {
await this.service.receiveSubmitMaterialsFormBaidu(data);
} catch (err) {
console.log(err)
return system.getResult(null, err.message)
}
}
// 提交材料 // 提交材料
async submitMaterials(pobj, qobj, req) { async submitMaterials(pobj, qobj, req) {
try { try {
...@@ -55,5 +68,18 @@ class CompanycaseCtl extends CtlBase { ...@@ -55,5 +68,18 @@ class CompanycaseCtl extends CtlBase {
return system.getResult(null, err.message) return system.getResult(null, err.message)
} }
} }
// 改变工商状态。工商信息初审未通过、工商信息提交中、工商局审核未通过、工商局审核通过、补正复审中、补正复审未通过、刻章中、刻章完成、证件已上传、证件已邮寄
async updateGongshangStatus(pobj, qobj, req) {
try {
if (!pobj.id) {
throw new Error("参数错误")
}
const rs = await this.service.updateGongshangStatus(pobj);
return system.getResult(rs);
} catch (err) {
return system.getResult(null, err.message)
}
}
} }
module.exports = CompanycaseCtl; module.exports = CompanycaseCtl;
...@@ -16,6 +16,88 @@ class CompanycaseService extends ServiceBase { ...@@ -16,6 +16,88 @@ class CompanycaseService extends ServiceBase {
this.qualificationDao = system.getObject("db.delivery.qualificationDao"); this.qualificationDao = system.getObject("db.delivery.qualificationDao");
} }
async receiveSubmitMaterialsFormBaidu(data){
console.log(`mmmmmmmmmmmm接受到百度推送过来的工商材料信息`+JSON.stringify(data))
const actionBody = data.d
const deliverData = await this.deliveryDao.findOne({
demand_code: actionBody.who.serviceId,
product_code: 'companyCase'
});
if (!deliverData) {
throw new Error("查不到此交付单");
}
// 将百度推送过来的数据入库
const deliverInfo = deliverData.delivery_info
deliverInfo.channelMaterials = {
who: actionBody.who,
com: actionBody.com,
receiver: actionBody.receiver,
shareholders: actionBody.shareholders,
members: actionBody.members
}
return this.db.transaction(async (t) => {
const cacheInf = await this.cacheinfoDao.findOne({
deliver_id: deliverData.id
});
let pobj = null
if(cacheInf){
let cacheInfo = cacheInf.cache_info;
cacheInfo.companyInfo.channelMaterials = {
who: actionBody.who,
com: actionBody.com,
receiver: actionBody.receiver,
shareholders: actionBody.shareholders,
members: actionBody.members
}
pobj = {
deliver_id: deliverData.id,
cache_info: cacheInfo
}
}else{
pobj = {
deliver_id: deliverData.id,
cache_info:{
companyInfo: {
companyName:actionBody.com.names[0],
spareName: [""],
serviceArea: "",
channelMaterials: {
who: actionBody.who,
com: actionBody.com,
receiver: actionBody.receiver,
shareholders: actionBody.shareholders,
members: actionBody.members
}
},
materialFile:{
applicationFormUrl:{},
registDocumentsUrl:{}
}
}
}
}
await this.cacheinfoDao.createOrUpdate(pobj, t);
await this.newmaterialDao.createOrUpdate(pobj, t);
// 更新公司名称
await this.deliveryDao.updateByWhere({
company_name: actionBody.com.names[0],
delivery_info: {
...deliverInfo,
companyName: actionBody.com.names[0]
}
}, {
delivery_code: deliverData.delivery_code
}, t);
return "SUCCESS"
});
}
async submitMaterials(pobj, qobj, req) { async submitMaterials(pobj, qobj, req) {
const deliverData = await this.deliveryDao.findOne({ const deliverData = await this.deliveryDao.findOne({
id: pobj.deliver_id id: pobj.deliver_id
...@@ -23,7 +105,18 @@ class CompanycaseService extends ServiceBase { ...@@ -23,7 +105,18 @@ class CompanycaseService extends ServiceBase {
if (!deliverData) { if (!deliverData) {
throw new Error("查不到此交付单"); throw new Error("查不到此交付单");
} }
await TOQFT.getClientByType(deliverData.product_code).submitMaterials(pobj.username, deliverData, pobj.cache_info); if(deliverData.delivery_info && deliverData.delivery_info.channelMaterials){
console.log(`【提交材料】+++++new走百度新接口提交材料${pobj.deliver_id}`)
await TOQFT.getClientByType(deliverData.product_code).submitMaterialsNew(pobj.username, deliverData, pobj.cache_info);
if([system.SERVERSESTATUS.COLLECTING].includes(deliverData.delivery_status)){
console.log(`【提交材料】+++++new走百度新接口更新工商注册状态${pobj.deliver_id}`)
await TOQFT.getClientByType(deliverData.product_code).updateGongshangRegStatus(pobj.username, deliverData, system.SERVERSESTATUS.AUDITING);
}
}else{
console.log(`+++++old走百度老接口提交材料${pobj.deliver_id}`)
await TOQFT.getClientByType(deliverData.product_code).submitMaterials(pobj.username, deliverData, pobj.cache_info);
}
return this.db.transaction(async (t) => { return this.db.transaction(async (t) => {
await this.cacheinfoDao.createOrUpdate(pobj, t); await this.cacheinfoDao.createOrUpdate(pobj, t);
await this.newmaterialDao.createOrUpdate(pobj, t); await this.newmaterialDao.createOrUpdate(pobj, t);
...@@ -69,6 +162,83 @@ class CompanycaseService extends ServiceBase { ...@@ -69,6 +162,83 @@ class CompanycaseService extends ServiceBase {
return "SUCCESS" return "SUCCESS"
} }
/**
* 工商信息初审未通过、工商信息提交中、工商局审核未通过、工商局审核通过、补正复审中、补正复审未通过、刻章中、刻章完成、证件已上传、证件已邮寄
*
* @param {*} pobj
* @param {*} qobj
* @param {*} req
*/
async updateGongshangStatus(pobj, qobj, req) {
console.log(`更新百度工商注册新流程状态开始:`+JSON.stringify(pobj));
const deliverData = await this.deliveryDao.findOne({
id: pobj.id
});
if (!deliverData) {
throw new Error("查不到此交付单");
}
if(!deliverData.delivery_info){
throw new Error("交付单详情为空");
}
if(!deliverData.delivery_info.channelMaterials){
throw new Error("百度未同步公司注册申请材料");
}
if(!deliverData.delivery_info.channelMaterials.who){
throw new Error("who参数为空");
}
let statusArr = [
"EXPERT_AUDIT_FAILED", // 工商信息初审未通过
"ICB_SUBMITTING",// 工商信息提交中
"ICB_AUDIT_FAILED",// 工商局审核未通过
"ICB_AUDIT_PASS",// 工商局审核通过
"ICB_RE-AUDITING",// 补正复审中
"ICB_RE-AUDIT_FAILED",// 补正复审未通过
"ENGRAVING",// 刻章中
"ENGRAVED",// 刻章完成
"LICENSE_UPLOADED",// 证件已上传
"LICENSE_POSTED"// 证件已邮寄
]
let isExist = statusArr.includes(pobj.status)
if(!isExist){
throw new Error("状态非法");
}
let licenseUrl = null;
let expressNum = null;
if("LICENSE_UPLOADED" == pobj.status){
if(!pobj.licenseUrl || pobj.licenseUrl== ''){
throw new Error("营业执照地址不能为空");
}
licenseUrl = pobj.licenseUrl;
}else if("LICENSE_POSTED" == pobj.status){
if(!pobj.expressNum || pobj.expressNum== ''){
throw new Error("快递号不能为空");
}
expressNum = pobj.expressNum;
}
// 更新百度工商注册流程状态
let client = TOQFT.getClientByType(deliverData.product_code);
console.log(">>>>开始调用百度接口更新工商状态接口:"+pobj.id)
const res = await client.updateGongshangRegStatus(pobj.username, deliverData, pobj.status);
if("LICENSE_UPLOADED" == pobj.status){
console.log(">>>>开始调用百度接口更新回传营业执照:"+pobj.id)
await client.submitLicense(pobj.username,deliverData,licenseUrl)
}else if("LICENSE_POSTED" == pobj.status){
console.log(">>>>开始调用百度接口更新回传刻章信息:"+pobj.id)
await client.submitEngraving(pobj.username,deliverData,licenseUrl)
}
return "SUCCESS"
}
async changeDeliveryStatus(pobj, qobj, req) { async changeDeliveryStatus(pobj, qobj, req) {
const deliverData = await this.deliveryDao.findOne({ const deliverData = await this.deliveryDao.findOne({
id: pobj.id id: pobj.id
...@@ -151,7 +321,14 @@ class CompanycaseService extends ServiceBase { ...@@ -151,7 +321,14 @@ class CompanycaseService extends ServiceBase {
delivery_status: status delivery_status: status
} }
} }
await TOQFT.getClientByType(deliverData.product_code).changeStatus(pobj.username, deliverData, materials);
if(system.SERVICECODE.COMPANYCASE == deliverData.product_code && deliverData.delivery_info.channelMaterials){
console.log(`【更新交付单状态】new 调用百度新接口更新工商注册状态.(id=${pobj.id})`)
await TOQFT.getClientByType(deliverData.product_code).updateGongshangRegStatus(pobj.username, deliverData, status);
}else{
console.log(`【更新交付单状态】old 调用百度老接口更新工商注册状态.(id=${pobj.id})`)
await TOQFT.getClientByType(deliverData.product_code).changeStatus(pobj.username, deliverData, materials);
}
await this.deliveryDao.updateByWhere(updateData, { await this.deliveryDao.updateByWhere(updateData, {
id: pobj.id id: pobj.id
......
...@@ -44,6 +44,109 @@ class GongshangClient extends BaseClient { ...@@ -44,6 +44,109 @@ class GongshangClient extends BaseClient {
return this.instance; return this.instance;
} }
// ===================== 20220425 百度工商注册新流程 接口 start =====================
/**
* 百度工商注册新流程公司注册完成后,供应商将营业执照回传百度
*/
async submitLicense(username, deliverData, licenseUrl){
let pushData = {
deliveryId: deliverData.id,
who: deliverData.delivery_info.channelMaterials.who,
licenseUrl: licenseUrl
}
console.log(`开始调用百度回传营业执照接口(deliveryId=${deliverData.id}),请求参数:`+JSON.stringify(pushData))
const res = await this.pushQiFuTong(username, {
actionType: "submitGongshangLicense",
actionBody: pushData
});
console.log(`结束调用百度回传营业执照接口(deliveryId=${deliverData.id}),返回结果:`+JSON.stringify(res))
return res;
}
/**
* 百度工商注册新流程:刻章环节,供应商使用此接口同步刻章信息(需多次调用)
*/
async submitEngraving(username, deliverData, status, expressNum){
let pushData = {
deliveryId: deliverData.id,
who: deliverData.delivery_info.channelMaterials.who,
content: "公章、财务章、合同章",
status: status,
expressNum: expressNum
}
console.log(`开始调用百度回传刻章信息接口(deliveryId=${deliverData.id}),请求参数:`+JSON.stringify(pushData))
const res = await this.pushQiFuTong(username, {
actionType: "submitGongshangEngraving",
actionBody: pushData
});
console.log(`结束调用百度回传刻章信息接口(deliveryId=${deliverData.id}),返回结果:`+JSON.stringify(res))
return res;
}
/**
* 百度工商注册新流程: 状态需要及时更新,方便用户了解当前进度。
*/
async updateGongshangRegStatus(username, deliverData, updateStatus){
let updateBaiduGongshangStatus = null;
if(system.SERVERSESTATUS.AUDITING == updateStatus){ // 收集材料环节
updateBaiduGongshangStatus = 'ICB_AUDITING' // 工商局审核中
}else if(system.SERVERSESTATUS.ENGRAVING == updateStatus){ // 刻章环节
updateBaiduGongshangStatus = 'COLLECTING_ENGRAVE_MATERIAL' // 刻章资料收集中
}else {
console.log(`【百度工商注册新流程】deliveryId: ${deliverData.id} 交付单状态为:${updateStatus} 不需要通知百度`)
return ;
}
console.log(`【百度工商注册新流程】deliveryId: ${deliverData.id} 交付单状态为:${updateStatus} 告知百度状态为:${updateBaiduGongshangStatus}`)
let pushData = {
deliveryId: deliverData.id,
who: deliverData.delivery_info.channelMaterials.who,
status: updateStatus
}
console.log(`开始调用百度更新工商状态接口(deliveryId=${deliverData.id}),请求参数:`+JSON.stringify(pushData))
const res = await this.pushQiFuTong(username, {
actionType: "updateGongshangRegStatus",
actionBody: pushData
});
console.log(`结束调用百度更新工商状态接口(deliveryId=${deliverData.id}),返回结果:`+JSON.stringify(res))
return res;
}
/**
* 百度工商注册新流程,供应商变更用户申请材料
* @param {*} username
* @param {*} deliverData
* @param {*} cacheInfo
* @returns
*/
async submitMaterialsNew(username, deliverData, cacheInfo){
let pushData = {
deliveryId: deliverData.id,
deliverContent: {
who: cacheInfo.companyInfo.channelMaterials.who, // 目标
com: cacheInfo.companyInfo.channelMaterials.com, // 公司基本信息
receiver: cacheInfo.companyInfo.channelMaterials.receiver, // 邮寄地址
shareholders: cacheInfo.companyInfo.channelMaterials.shareholders, // 股东信息
members: cacheInfo.companyInfo.channelMaterials.members // 主要人员信息
}
}
console.log(`开始调用百度供应商变更用户申请材料(deliveryId=${deliverData.id}),请求参数:`+JSON.stringify(pushData))
const res = await this.pushQiFuTong(username, {
actionType: "submitGongshangMaterial",
actionBody: pushData
});
console.log(`结束调用百度供应商变更用户申请材料(deliveryId=${deliverData.id}),返回结果:`+JSON.stringify(res))
return res;
}
// ===================== 20220425 百度工商注册新流程 接口 end =====================
async submitMaterials(username, deliverData, materials) { async submitMaterials(username, deliverData, materials) {
const { companyInfo, materialFile, } = materials; const { companyInfo, materialFile, } = materials;
let { applicationFormUrl, registDocumentsUrl } = materialFile; let { applicationFormUrl, registDocumentsUrl } = materialFile;
......
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