Commit 44d82ccf by Sxy

feat: 接入百度360

parent a31625a1
...@@ -4,9 +4,9 @@ const querystring = require('querystring'); ...@@ -4,9 +4,9 @@ const querystring = require('querystring');
var settings = require("../../../../config/settings"); var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base"); const CtlBase = require("../../ctl.base");
const moment = require("moment"); const moment = require("moment");
class WangwenCtl extends CtlBase { class NewdeliverCtl extends CtlBase {
constructor() { constructor() {
super("delivery", CtlBase.getServiceName(WangwenCtl)); super("delivery", CtlBase.getServiceName(NewdeliverCtl));
} }
// 查询 详情 // 查询 详情
...@@ -39,7 +39,7 @@ class WangwenCtl extends CtlBase { ...@@ -39,7 +39,7 @@ class WangwenCtl extends CtlBase {
// 更改状态 // 更改状态
async changeDeliveryStatus(pobj, qobj, req) { async changeDeliveryStatus(pobj, qobj, req) {
try { try {
if (!pobj.deliver_id) { if (!pobj.id) {
throw new Error("参数错误") throw new Error("参数错误")
} }
const rs = await this.service.changeDeliveryStatus(pobj); const rs = await this.service.changeDeliveryStatus(pobj);
...@@ -49,4 +49,4 @@ class WangwenCtl extends CtlBase { ...@@ -49,4 +49,4 @@ class WangwenCtl extends CtlBase {
} }
} }
} }
module.exports = WangwenCtl; module.exports = NewdeliverCtl;
...@@ -212,7 +212,7 @@ class DeliverDao extends Dao { ...@@ -212,7 +212,7 @@ class DeliverDao extends Dao {
return result; return result;
} }
async findInfoByWangwen(pobj) { async newFindInfo(pobj) {
const result = await this.model.findOne({ const result = await this.model.findOne({
where: { where: {
id: pobj.id id: pobj.id
......
...@@ -49,9 +49,6 @@ class DeliverService extends ServiceBase { ...@@ -49,9 +49,6 @@ class DeliverService extends ServiceBase {
throw new Error("查不到此交付单"); throw new Error("查不到此交付单");
} }
// 推送到商城
// await pushTx.submitMaterials(deliverData, JSON.parse(JSON.stringify(pobj.cache_info)))
if ([system.SERVERSESTATUS.COLLECTING, system.SERVERSESTATUS.USERCONFIRMATIONREJECT].includes(deliverData.delivery_status)) { if ([system.SERVERSESTATUS.COLLECTING, system.SERVERSESTATUS.USERCONFIRMATIONREJECT].includes(deliverData.delivery_status)) {
await pushQft.submitMaterials(deliverData, JSON.parse(JSON.stringify(pobj.cache_info))) await pushQft.submitMaterials(deliverData, JSON.parse(JSON.stringify(pobj.cache_info)))
} }
...@@ -59,24 +56,6 @@ class DeliverService extends ServiceBase { ...@@ -59,24 +56,6 @@ class DeliverService extends ServiceBase {
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.materialDao.createOrUpdate(pobj, t); await this.materialDao.createOrUpdate(pobj, t);
if (deliverData.source_number === "tencentCloud") {
if (deliverData.delivery_status === system.SERVERSESTATUS.COLLECTING) {
await this.dao.updateByWhere({
delivery_status: system.SERVERSESTATUS.SUBMITING
}, {
id: pobj.deliver_id
}, t);
this.statuslogDao.create({
flow_type: system.FLOWCODE.DELIVERY,
flow_id: pobj.deliver_id,
status_code: system.SERVERSESTATUS.SUBMITING,
salesman_id: pobj.userid,
salesman_name: pobj.username
});
}
}
if (deliverData.source_number === "aliCloud") { if (deliverData.source_number === "aliCloud") {
if ([system.SERVERSESTATUS.COLLECTING, system.SERVERSESTATUS.USERCONFIRMATIONREJECT].includes(deliverData.delivery_status)) { if ([system.SERVERSESTATUS.COLLECTING, system.SERVERSESTATUS.USERCONFIRMATIONREJECT].includes(deliverData.delivery_status)) {
await this.dao.updateByWhere({ await this.dao.updateByWhere({
...@@ -93,8 +72,6 @@ class DeliverService extends ServiceBase { ...@@ -93,8 +72,6 @@ class DeliverService extends ServiceBase {
}); });
} }
} }
return "SUCCESS" return "SUCCESS"
}); });
} }
...@@ -177,6 +154,8 @@ class DeliverService extends ServiceBase { ...@@ -177,6 +154,8 @@ class DeliverService extends ServiceBase {
status = system.SERVERSESTATUS.SUCCESS; status = system.SERVERSESTATUS.SUCCESS;
// txstatus = pushTx.TXSTATUS.SUCCESS; // txstatus = pushTx.TXSTATUS.SUCCESS;
break break
default:
throw new Error("此状态手动不能更改");
} }
// await pushTx.pushChangeOrder(txstatus, deliverData.delivery_code); // await pushTx.pushChangeOrder(txstatus, deliverData.delivery_code);
...@@ -196,7 +175,16 @@ class DeliverService extends ServiceBase { ...@@ -196,7 +175,16 @@ class DeliverService extends ServiceBase {
return "success" return "success"
} }
// 点击详情 将 订单状态 从 已接单更新为收集材料中 /**
* 阿里渠道
* 1. 交付单起始状态 为 已接单
* 2. 点击详情 更新为 用户待上传材料
* 3. 当用户上传完材料 自动更新为 收集材料中
*
* 其他渠道
* 1. 交付单起始状态 为 已接单
* 2. 点击详情 更新为 收集材料中
*/
async toCollecting(pobj) { async toCollecting(pobj) {
const deliverData = await this.dao.findOne({ const deliverData = await this.dao.findOne({
id: pobj.id id: pobj.id
...@@ -204,35 +192,36 @@ class DeliverService extends ServiceBase { ...@@ -204,35 +192,36 @@ class DeliverService extends ServiceBase {
if (!deliverData) { if (!deliverData) {
throw new Error("没有此交付单"); throw new Error("没有此交付单");
} }
/**
*
* 1. 交付单起始状态 为 已接单
* 2. 点击详情 更新为 用户待上传材料
* 3. 当用户上传完材料 自动更新为 收集材料中
*/
if (system.SERVERSESTATUS.RECEIVED === deliverData.delivery_status) { if (system.SERVERSESTATUS.RECEIVED === deliverData.delivery_status) {
let status;
if (deliverData.source_number === "aliCloud") {
status = system.SERVERSESTATUS.USERUPLOADWAIT
} else {
status = system.SERVERSESTATUS.COLLECTING
}
await this.dao.updateByWhere({ await this.dao.updateByWhere({
delivery_status: system.SERVERSESTATUS.USERUPLOADWAIT delivery_status: status
}, { }, {
id: pobj.id id: pobj.id
}); });
this.statuslogDao.create({ this.statuslogDao.create({
flow_type: system.FLOWCODE.DELIVERY, flow_type: system.FLOWCODE.DELIVERY,
flow_id: pobj.id, flow_id: pobj.id,
status_code: system.SERVERSESTATUS.USERUPLOADWAIT, status_code: status,
salesman_id: pobj.userid, salesman_id: pobj.userid,
salesman_name: pobj.username salesman_name: pobj.username
}); });
} }
return "success" return "SUCCESS"
} }
/**
* 1. 保存资质信息
*/
async addQualification(pobj) { async addQualification(pobj) {
/**
* 1. 保存资质信息
* 2. 判断是否有年报服务,有的话改变年报状态
*/
const deliverData = await this.dao.findOne({ const deliverData = await this.dao.findOne({
id: pobj.deliver_id id: pobj.deliver_id
}); });
...@@ -242,58 +231,9 @@ class DeliverService extends ServiceBase { ...@@ -242,58 +231,9 @@ class DeliverService extends ServiceBase {
if (deliverData.delivery_status !== system.SERVERSESTATUS.DISPOSEING) { if (deliverData.delivery_status !== system.SERVERSESTATUS.DISPOSEING) {
throw new Error("该交付单状态下不可提交"); throw new Error("该交付单状态下不可提交");
} }
let annualReportData;
let annualReportArry = [];
// 年报逻辑 await this.qualificationDao.createOrUpdate(pobj);
if (deliverData.master_source_number) { return "SUCCESS"
annualReportData = await this.dao.findOne({
master_source_number: deliverData.master_source_number,
id: {
$ne: deliverData.id
}
});
if (annualReportData && annualReportData.delivery_status === System.ANNUALREPORT.RECEIVED) {
// TODO: let year = annualReportData.delivery_info && annualReportData.delivery_info.numYear || 5
let year = 5;
for (let i = new Date().getFullYear(); i < new Date().getFullYear() + year; i++) {
annualReportArry.push({
year: i,
status: System.ANNUALREPORT.WAITDECLARE,
deliver_id: annualReportData.id
});
}
// 推送年报信息
// await pushTx.pushChangeOrder(pushTx.TXSTATUS.WAITDECLARE, annualReportData.delivery_code, {
// annualReport: annualReportArry
// })
}
}
return this.db.transaction(async (t) => {
await this.qualificationDao.createOrUpdate(pobj, t);
if (annualReportData && annualReportData.delivery_status === System.ANNUALREPORT.RECEIVED) {
await this.dao.updateByWhere({
delivery_status: System.ANNUALREPORT.TAKEEFFECT
}, {
id: annualReportData.id
}, t);
this.statuslogDao.create({
flow_type: system.FLOWCODE.DELIVERY,
flow_id: annualReportData.id,
status_code: System.ANNUALREPORT.TAKEEFFECT,
salesman_id: pobj.userid,
salesman_name: pobj.username
});
await this.annualreportDao.bulkCreate(annualReportArry, t);
}
return "success"
});
} }
async closeDeliver(pobj) { async closeDeliver(pobj) {
......
...@@ -4,11 +4,12 @@ const settings = require("../../../../config/settings"); ...@@ -4,11 +4,12 @@ const settings = require("../../../../config/settings");
const moment = require("moment"); const moment = require("moment");
const System = require("../../../system"); const System = require("../../../system");
const pushQft = require("../../../utils/toqifutongClient") const pushQft = require("../../../utils/toqifutongClient")
const TOQFT = require("../../../utils/toQft");
class WangwenService extends ServiceBase { class NewdeliverService extends ServiceBase {
constructor() { constructor() {
super("delivery", ServiceBase.getDaoName(WangwenService)); super("delivery", ServiceBase.getDaoName(NewdeliverService));
this.cacheinfoDao = system.getObject("db.delivery.cacheinfoDao"); this.cacheinfoDao = system.getObject("db.delivery.cacheinfoDao");
this.deliveryDao = system.getObject("db.delivery.deliverDao"); this.deliveryDao = system.getObject("db.delivery.deliverDao");
this.newmaterialDao = system.getObject("db.delivery.newmaterialDao"); this.newmaterialDao = system.getObject("db.delivery.newmaterialDao");
...@@ -16,7 +17,7 @@ class WangwenService extends ServiceBase { ...@@ -16,7 +17,7 @@ class WangwenService extends ServiceBase {
} }
async findInfo(pobj, qobj, req) { async findInfo(pobj, qobj, req) {
let result = await this.deliveryDao.findInfoByWangwen({ let result = await this.deliveryDao.newFindInfo({
id: pobj.id id: pobj.id
}); });
if (!result) { if (!result) {
...@@ -34,22 +35,28 @@ class WangwenService extends ServiceBase { ...@@ -34,22 +35,28 @@ class WangwenService extends ServiceBase {
throw new Error("查不到此交付单"); throw new Error("查不到此交付单");
} }
if ([system.SERVERSESTATUS.COLLECTING, system.SERVERSESTATUS.USERCONFIRMATIONREJECT].includes(deliverData.delivery_status)) { if ([system.SERVERSESTATUS.COLLECTING, system.SERVERSESTATUS.USERCONFIRMATIONREJECT].includes(deliverData.delivery_status)) {
await pushQft.wangwenSubmitOption(deliverData, pobj.cache_info); 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);
if ([system.SERVERSESTATUS.COLLECTING, system.SERVERSESTATUS.USERCONFIRMATIONREJECT].includes(deliverData.delivery_status)) { if ([system.SERVERSESTATUS.COLLECTING, system.SERVERSESTATUS.USERCONFIRMATIONREJECT].includes(deliverData.delivery_status)) {
let status;
if (deliverData.source_number === "aliCloud") {
status = system.SERVERSESTATUS.USERCONFIRMATIONWAIT
} else {
status = system.SERVERSESTATUS.COLLECTSUCCESS;
}
await this.deliveryDao.updateByWhere({ await this.deliveryDao.updateByWhere({
delivery_status: system.SERVERSESTATUS.USERCONFIRMATIONWAIT delivery_status: status
}, { }, {
id: pobj.deliver_id id: pobj.deliver_id
}, t); }, t);
this.statuslogDao.create({ this.statuslogDao.create({
flow_type: system.FLOWCODE.DELIVERY, flow_type: system.FLOWCODE.DELIVERY,
flow_id: pobj.deliver_id, flow_id: pobj.deliver_id,
status_code: system.SERVERSESTATUS.USERCONFIRMATIONWAIT, status_code: status,
salesman_id: pobj.userid, salesman_id: pobj.userid,
salesman_name: pobj.username salesman_name: pobj.username
}); });
...@@ -60,7 +67,7 @@ class WangwenService extends ServiceBase { ...@@ -60,7 +67,7 @@ class WangwenService extends ServiceBase {
async changeDeliveryStatus(pobj, qobj, req) { async changeDeliveryStatus(pobj, qobj, req) {
const deliverData = await this.deliveryDao.findOne({ const deliverData = await this.deliveryDao.findOne({
id: pobj.deliver_id id: pobj.id
}); });
if (!deliverData) { if (!deliverData) {
throw new Error("没有此交付单"); throw new Error("没有此交付单");
...@@ -68,41 +75,40 @@ class WangwenService extends ServiceBase { ...@@ -68,41 +75,40 @@ class WangwenService extends ServiceBase {
let status; let status;
switch (deliverData.delivery_status) { switch (deliverData.delivery_status) {
case system.SERVERSESTATUS.USERCONFIRMATIONRESOLVE: case system.SERVERSESTATUS.USERCONFIRMATIONRESOLVE:
case system.SERVERSESTATUS.COLLECTSUCCESS:
status = system.SERVERSESTATUS.ACCOUNTREGISTRATION; status = system.SERVERSESTATUS.ACCOUNTREGISTRATION;
await pushQft.wangwenSubmitOption(deliverData);
break break
case system.SERVERSESTATUS.ACCOUNTREGISTRATION: case system.SERVERSESTATUS.ACCOUNTREGISTRATION:
status = system.SERVERSESTATUS.SUBMITING; status = system.SERVERSESTATUS.SUBMITING;
await pushQft.wangwenSubmitOption(deliverData);
break break
case system.SERVERSESTATUS.SUBMITING: case system.SERVERSESTATUS.SUBMITING:
status = system.SERVERSESTATUS.DISPOSEING; status = system.SERVERSESTATUS.DISPOSEING;
await pushQft.wangwenSubmitOption(deliverData);
break break
case system.SERVERSESTATUS.DISPOSEING: case system.SERVERSESTATUS.DISPOSEING:
status = system.SERVERSESTATUS.THROUGH; status = system.SERVERSESTATUS.THROUGH;
await pushQft.wangwenSubmitOption(deliverData);
break break
case system.SERVERSESTATUS.THROUGH: case system.SERVERSESTATUS.THROUGH:
status = system.SERVERSESTATUS.SUCCESS; status = system.SERVERSESTATUS.SUCCESS;
break break
default: default:
throw new Error("此状态手动不能更改"); throw new Error("此状态手动不能更改");
break
} }
await TOQFT.getClientByType(deliverData.product_code).changeStatus(pobj.username, deliverData);
await this.deliveryDao.updateByWhere({ await this.deliveryDao.updateByWhere({
delivery_status: status delivery_status: status
}, { }, {
id: pobj.deliver_id id: pobj.id
}) })
this.statuslogDao.create({ this.statuslogDao.create({
flow_type: system.FLOWCODE.DELIVERY, flow_type: system.FLOWCODE.DELIVERY,
flow_id: pobj.deliver_id, flow_id: pobj.id,
status_code: status, status_code: status,
salesman_id: pobj.userid, salesman_id: pobj.userid,
salesman_name: pobj.username salesman_name: pobj.username
}); });
return "success" return "SUCCESS"
} }
} }
module.exports = WangwenService; module.exports = NewdeliverService;
...@@ -356,7 +356,8 @@ System.SCHEMESTATUS = { ...@@ -356,7 +356,8 @@ System.SCHEMESTATUS = {
System.SERVERSESTATUS = { System.SERVERSESTATUS = {
RECEIVED: "received",//已接单 RECEIVED: "received",//已接单
COLLECTING: "collecting",//收集材料中 COLLECTING: "collecting",//收集材料中
SUBMITING: "submiting",//递交材料中 COLLECTSUCCESS: "collectsuccess",//收集材料完成
SUBMITING: "submiting",//递交材料中 || 向工信部递交材料
DISPOSEING: "disposeing",//工信部处理中 || 工信部已受理 DISPOSEING: "disposeing",//工信部处理中 || 工信部已受理
POSTING: "posting",//证书已邮寄 POSTING: "posting",//证书已邮寄
SUCCESS: "success",//服务已完成 SUCCESS: "success",//服务已完成
......
...@@ -14,7 +14,12 @@ class LogClient { ...@@ -14,7 +14,12 @@ class LogClient {
rtninfo.requestId = this.getUUID() rtninfo.requestId = this.getUUID()
req.params.param = pobj req.params.param = pobj
//第三个字段应该存公司id //第三个字段应该存公司id
system.execLogs(settings.appname + "_" + req.xctx.codetitle, req.params, "_" + "icp-deliver" + (pobj.company_id || '') + "_", rtninfo, errinfo).then(res => { system.execLogs(
settings.appname + "_" + req.xctx.codetitle,
req.params, "_" + "icp-deliver" + (pobj.company_id || '') + "_",
rtninfo,
errinfo
).then(res => {
if (res && res.status == 1) { if (res && res.status == 1) {
console.log("log.....success") console.log("log.....success")
} else { } else {
......
const axios = require("axios");
const settings = require("../../../config/settings");
const system = require("../../system");
const centerChannelUrl = settings.centerChannelUrl();
const qifutongUrl = settings.qifutongUrl();
/**
* 请求启服通的基类
* 封装 获取 userpin token
* 统一请求方法
* 统一日志记录
*/
class BaseClient {
constructor(appKey, secret) {
this.appKey = appKey;
this.secret = secret;
}
/**
* 推送到 启服通
* @param {*} user
* @param {*} data
*/
async pushQiFuTong(user, data) {
const header = await this.getLoginByUserName(user);
await this.postRequest(`${qifutongUrl}/web/action/qcapi/springBoard`, data, header);
}
async getLoginByUserName(user) {
const token = await this.getAppTokenByAppKey(this.appKey, this.secret);
const data = await this.postRequest(`${centerChannelUrl}/api/opreceive/accessAuth/springBoard`,
{
"actionType": "getLoginByUserName",
"actionBody": {
"channelUserId": user,
" user": user,
"userName": user
}
}, {
token
});
return {
token,
userpin: data.userpin
}
}
async getAppTokenByAppKey(appKey, secret) {
const data = await this.postRequest(`${centerChannelUrl}/api/opreceive/accessAuth/getAppTokenByAppKey`,
{
"actionType": "getAppTokenByAppKey",
"actionBody": {
"appkey": appKey,
"secret": secret
}
});
return data.token
}
async postRequest(url, data, headers = {}) {
try {
console.log(` ${url} : 请求信息 ------- `);
console.log(JSON.stringify(data))
console.log(JSON.stringify(headers))
let result = await axios.post(`${url}`, data, {
headers: {
'Content-Type': 'application/json',
...headers
}
});
result = result.data;
console.log(` ${url} : 返回信息 ------- `);
console.log(result);
system.execLogs(
`请求:${url}`,
{
data,
headers
},
'交付请求',
result,
null
).catch(err => {
console.log(`日志写入错误 ${url}`)
});
if (result.status === 0) {
return result.data
} else {
throw new Error(result.msg)
}
} catch (err) {
console.log(` ${url} : 返回错误信息 ------- `);
console.log(err)
throw (err)
}
}
}
module.exports = BaseClient;
const vatClient = require("./vatClient")
const wangwenClient = require("./wangwenClient")
const system = require("../../system");
/**
* 根据产品类型选择不同的方法
* @param {*} type
*/
function getClientByType(type) {
switch (type) {
case system.SERVICECODE.ICP:
case system.SERVICECODE.EDI:
return new vatClient()
case system.SERVICECODE.WANGWEN:
return new wangwenClient()
default:
throw new Error("此状态手动不能更改");
}
}
module.exports = {
vatClient: new vatClient(),
wangwenClient: new wangwenClient(),
getClientByType
}
\ No newline at end of file
const BaseClient = require("./baseClient")
const system = require("../../system");
const settings = require("../../../config/settings");
const { appKey, secret } = settings;
const qualificationDao = system.getObject("db.delivery.qualificationDao");
/**
* 增值电信 产品
*/
class VatClient extends BaseClient {
constructor() {
super(appKey, secret);
this.CIRCUITSTATUS = {
ACCOUNTREGISTRATION: 507, // 完成账户注册
SUBMITING: 508, // 提交材料到工信部
DISPOSEING: 509, // 工信部已受理
DISPOSEINGFAIL: 510, // 工信不予受理
THROUGH: 511, // 工信部通过
THROUGHFAIL: 512 // 工信部未通过
}
}
/**
* 递交材料
* @param {*} deliverData
* @param {*} materials
*/
async submitMaterials(username, deliverData, materials) {
const { businessLicense, materialFile, otherInformation } = materials;
const {
address, businessTerm, createdAt,
enterpriseCode, legalRepresentative, name,
registeredCapital, scopeBusiness, type
} = businessLicense;
const { domain, corporateName, includeForeignInvestment } = otherInformation;
const {
companyBasicForm, companyServiceQualityForm,
icpCertificate, networkSecurityInformationForm,
partnerBusinessLicense, partnerDomainCertificate,
partnerForeignInvestment, partnerIdCardList,
partnerLaw, partnerPlan, partnerPreviewOtherList,
partnerSignAndStampOtherList, partnerSignOtherList,
businessDevelopmentForm, partnerStampOtherList
} = materialFile;
await this.pushQiFuTong(username, {
actionType: "serviceProviderSubmitMaterial",
actionBody: {
orderNo: deliverData.delivery_code,
material: {
BusinessLicense: {
Address: address,
BusinessTerm: businessTerm,
CreatedAt: createdAt,
EnterpriseCode: enterpriseCode,
LegalRepresentative: legalRepresentative,
Name: name,
RegisteredCapital: registeredCapital,
ScopeBusiness: scopeBusiness,
Type: type
},
Domain: domain,
CorporateName: corporateName,
IncludeForeignInvestment: includeForeignInvestment === "是",
PartnerBusinessLicense: partnerBusinessLicense.url,
PartnerIdCardList: partnerIdCardList.map(item => item.url),
PartnerDomainCertificate: partnerDomainCertificate.url,
PartnerPreviewOtherList: (partnerPreviewOtherList && partnerPreviewOtherList.length > 0) ? partnerPreviewOtherList.map(item => item.url) : undefined,
PartnerPlan: partnerPlan.url,
PartnerForeignInvestment: partnerForeignInvestment.url,
PartnerLaw: partnerLaw.url,
IcpCertificate: icpCertificate.url,
BusinessDevelopmentForm: businessDevelopmentForm.url,
CompanyBasicForm: companyBasicForm.url,
CompanyServiceQualityForm: companyServiceQualityForm.url,
NetworkSecurityInformationForm: networkSecurityInformationForm.url,
PartnerSignAndStampOtherList: partnerSignAndStampOtherList.url && [partnerSignAndStampOtherList.url],
PartnerSignOtherList: partnerSignOtherList.url && [partnerSignOtherList.url],
PartnerStampOtherList: partnerStampOtherList.url && [partnerStampOtherList.url]
}
}
});
}
/**
* 改变 状态
* @param {*} status
* @param {*} sendMessage 办理的资质文件等
*/
async changeStatus(username, deliverData, materials = {}) {
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:
const qualificationData = await qualificationDao.findOne({
deliver_id: deliverData.id
});
if (qualificationData) {
materials.officialFileURL = qualificationData.file && qualificationData.file.url
}
status = this.CIRCUITSTATUS.THROUGH
break
case system.SERVERSESTATUS.THROUGH:
return "SUCCESS"
default:
throw new Error("此状态不能手动更改");
}
await this.pushQiFuTong(username, {
actionType: "serviceProviderNotification",
actionBody: {
orderNo: deliverData.delivery_code,
status,
...materials
}
});
}
}
module.exports = VatClient
\ No newline at end of file
const BaseClient = require("./baseClient")
const settings = require("../../../config/settings");
const system = require("../../system");
const { appKey, secret } = settings;
/**
* 食品 网文 产品
*/
class WangwenClient extends BaseClient {
constructor() {
super(appKey, secret);
}
/**
* 文网文 递交材料,状态变更
601: "完成账户注册",
602: "服务商提交资料",
603: "服务商完成提交资料到⼯信部",
604: "⼯商部已受理",
605: "⼯商部不予受理",
606: "⼯商部通过",
607: "⼯商部未通过"
*/
async submitMaterials(username, deliverData, materials) {
const channelType = {
"wangwen": "esp.wangwen",
"food": "esp.food"
};
let req = {};
switch (deliverData.delivery_status) {
case system.SERVERSESTATUS.COLLECTING:
case system.SERVERSESTATUS.USERCONFIRMATIONREJECT:
let { basicInfo, materialList } = materials;
let extInfo = {};
for (let val in basicInfo) {
if (basicInfo[val]) {
extInfo[val] = basicInfo[val];
}
}
for (let val of materialList) {
if (val.files || val.files.length > 0) {
let urls = [];
for (let file of val.files) {
if (file && file.url) {
urls.push(file.url);
}
}
if (urls.length > 0) {
extInfo[val.key] = urls
}
}
}
req = {
"ApplicationStatus": 601,
"extInfo": JSON.stringify(extInfo)
}
break
case system.SERVERSESTATUS.USERCONFIRMATIONRESOLVE:
req.ApplicationStatus = 602;
break
case system.SERVERSESTATUS.ACCOUNTREGISTRATION:
req.ApplicationStatus = 603;
break
case system.SERVERSESTATUS.SUBMITING:
req.ApplicationStatus = 604;
break
case system.SERVERSESTATUS.DISPOSEING:
req.ApplicationStatus = 606;
break
default:
throw new Error("此状态手动不能更改");
}
await this.pushQiFuTong(username, {
actionType: "serviceSubmitOption",
actionBody: {
"channelType": channelType[deliverData.product_code],
"orderNo": deliverData.delivery_code,
"extInfo": "{}",
...req,
}
});
}
async changeStatus(username, deliverData, materials) {
await this.submitMaterials(username, deliverData, materials);
}
}
module.exports = WangwenClient
\ 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