Commit 6e08c279 by Sxy

feat: 阿里流程

parent d562b7e8
......@@ -3,7 +3,7 @@ const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
const moment = require("moment");
const System = require("../../../system");
const pushTx = require("../../../utils/totxClient")
// const pushTx = require("../../../utils/totxClient")
class DeliverService extends ServiceBase {
constructor() {
......@@ -43,36 +43,53 @@ class DeliverService extends ServiceBase {
const deliverData = await this.dao.findOne({
id: pobj.deliver_id
});
if (!deliverData || ![
system.SERVERSESTATUS.COLLECTING,
system.SERVERSESTATUS.SUBMITING,
system.SERVERSESTATUS.DISPOSEING
].includes(deliverData.delivery_status)) {
throw new Error("此交付单不可提交材料");
if (!deliverData) {
throw new Error("查不到此交付单");
}
// 推送到商城
await pushTx.submitMaterials(deliverData, JSON.parse(JSON.stringify(pobj.cache_info)))
// await pushTx.submitMaterials(deliverData, JSON.parse(JSON.stringify(pobj.cache_info)))
// TODO:
return this.db.transaction(async (t) => {
await this.cacheinfoDao.createOrUpdate(pobj, t);
await this.materialDao.createOrUpdate(pobj, t);
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_name === "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_name === "aliCloud") {
if ([system.SERVERSESTATUS.COLLECTING, system.SERVERSESTATUS.USERCONFIRMATIONREJECT].includes(deliverData.delivery_status)) {
await this.dao.updateByWhere({
delivery_status: system.SERVERSESTATUS.USERCONFIRMATIONWAIT
}, {
id: pobj.deliver_id
}, t);
this.statuslogDao.create({
flow_type: system.FLOWCODE.DELIVERY,
flow_id: pobj.deliver_id,
status_code: system.SERVERSESTATUS.USERCONFIRMATIONWAIT,
salesman_id: pobj.userid,
salesman_name: pobj.username
});
}
}
return "SUCCESS"
});
}
......@@ -112,24 +129,45 @@ class DeliverService extends ServiceBase {
if (!deliverData) {
throw new Error("没有此交付单");
}
if (![system.SERVERSESTATUS.SUBMITING, system.SERVERSESTATUS.POSTING].includes(deliverData.delivery_status)) {
throw new Error("此状态下不可手动更新办理状态");
}
// if (![system.SERVERSESTATUS.SUBMITING, system.SERVERSESTATUS.POSTING].includes(deliverData.delivery_status)) {
// throw new Error("此状态下不可手动更新办理状态");
// }
let status;
let txstatus;
// let txstatus;
switch (deliverData.delivery_status) {
case system.SERVERSESTATUS.USERCONFIRMATIONRESOLVE:
status = system.SERVERSESTATUS.ACCOUNTREGISTRATION;
break
case system.SERVERSESTATUS.ACCOUNTREGISTRATION:
status = system.SERVERSESTATUS.SUBMITING;
break
case system.SERVERSESTATUS.DISPOSEING:
// 查询 资质信息
const ualificationData = await this.qualificationDao.findOne({
deliver_id: deliverData.id
});
if (!ualificationData) {
throw new Error("请上传办理的资质证照信息");
}
status = system.SERVERSESTATUS.THROUGH;
break
case system.SERVERSESTATUS.THROUGH:
status = system.SERVERSESTATUS.SUCCESS;
break
case system.SERVERSESTATUS.SUBMITING:
status = system.SERVERSESTATUS.DISPOSEING;
txstatus = pushTx.TXSTATUS.DISPOSEING;
// txstatus = pushTx.TXSTATUS.DISPOSEING;
break
case system.SERVERSESTATUS.POSTING:
status = system.SERVERSESTATUS.SUCCESS;
txstatus = pushTx.TXSTATUS.SUCCESS;
// txstatus = pushTx.TXSTATUS.SUCCESS;
break
}
await pushTx.pushChangeOrder(txstatus, deliverData.delivery_code);
// await pushTx.pushChangeOrder(txstatus, deliverData.delivery_code);
// TODO: 状态变更通知
await this.dao.updateByWhere({
delivery_status: status
}, {
......@@ -155,7 +193,7 @@ class DeliverService extends ServiceBase {
}
if (system.SERVERSESTATUS.RECEIVED === deliverData.delivery_status) {
await pushTx.pushChangeOrder(pushTx.TXSTATUS.COLLECTING, deliverData.delivery_code);
// await pushTx.pushChangeOrder(pushTx.TXSTATUS.COLLECTING, deliverData.delivery_code);
await this.dao.updateByWhere({
delivery_status: system.SERVERSESTATUS.COLLECTING
......@@ -210,12 +248,13 @@ class DeliverService extends ServiceBase {
});
}
// 推送年报信息
await pushTx.pushChangeOrder(pushTx.TXSTATUS.WAITDECLARE, annualReportData.delivery_code, {
annualReport: annualReportArry
})
// await pushTx.pushChangeOrder(pushTx.TXSTATUS.WAITDECLARE, annualReportData.delivery_code, {
// annualReport: annualReportArry
// })
}
}
return this.db.transaction(async (t) => {
await this.qualificationDao.createOrUpdate(pobj, t);
......@@ -255,11 +294,11 @@ class DeliverService extends ServiceBase {
throw new Error("该交付单状态下不可提交");
}
// 推送 关闭交付
await pushTx.pushChangeOrder(pushTx.TXSTATUS.CLOSED, deliverData.delivery_code, {
close_reason: pobj.close_reason
});
// await pushTx.pushChangeOrder(pushTx.TXSTATUS.CLOSED, deliverData.delivery_code, {
// close_reason: pobj.close_reason
// });
// 推送 退费
await pushTx.returnPremium(deliverData.delivery_code);
// await pushTx.returnPremium(deliverData.delivery_code);
// 年报逻辑
let annualReportData;
if (deliverData.master_source_number) {
......@@ -271,11 +310,11 @@ class DeliverService extends ServiceBase {
});
// 推送 关闭交付 资质
if (annualReportData) {
await pushTx.pushChangeOrder(pushTx.TXSTATUS.CLOSED, annualReportData.delivery_code, {
close_reason: "对应的资质交付关闭了"
});
// await pushTx.pushChangeOrder(pushTx.TXSTATUS.CLOSED, annualReportData.delivery_code, {
// close_reason: "对应的资质交付关闭了"
// });
// 推送 年报退费
await pushTx.returnPremium(annualReportData.delivery_code);
// await pushTx.returnPremium(annualReportData.delivery_code);
}
}
return this.db.transaction(async (t) => {
......@@ -322,21 +361,26 @@ class DeliverService extends ServiceBase {
if (!result) {
throw new Error("交付单不可查看");
}
if (!result.qualification) {
throw new Error("请先上传资质信息");
}
if (result.delivery_status !== system.SERVERSESTATUS.DISPOSEING) {
throw new Error("该状态下不可填写邮寄信息");
if (result.source_name === "tencentCloud") {
if (!result.qualification) {
throw new Error("请先上传资质信息");
}
if (result.delivery_status !== system.SERVERSESTATUS.DISPOSEING) {
throw new Error("该状态下不可填写邮寄信息");
}
}
const { material } = result;
let { proposerInfo } = material
proposerInfo.recipientInfo = pobj.recipientInfo;
await pushTx.pushChangeOrder(pushTx.TXSTATUS.POSTING, result.delivery_code, {
qualification: result.qualification,
recipientInfo: pobj.recipientInfo
});
// await pushTx.pushChangeOrder(pushTx.TXSTATUS.POSTING, result.delivery_code, {
// qualification: result.qualification,
// recipientInfo: pobj.recipientInfo
// });
return this.db.transaction(async (t) => {
......@@ -346,19 +390,21 @@ class DeliverService extends ServiceBase {
id: material.id
}, t);
await this.dao.updateByWhere({
delivery_status: system.SERVERSESTATUS.POSTING,
}, {
id: pobj.id
}, t);
if (result.source_name === "tencentCloud") {
await this.dao.updateByWhere({
delivery_status: system.SERVERSESTATUS.POSTING,
}, {
id: pobj.id
}, t);
this.statuslogDao.create({
flow_type: system.FLOWCODE.DELIVERY,
flow_id: pobj.id,
status_code: system.SERVERSESTATUS.POSTING,
salesman_id: pobj.userid,
salesman_name: pobj.username
});
this.statuslogDao.create({
flow_type: system.FLOWCODE.DELIVERY,
flow_id: pobj.id,
status_code: system.SERVERSESTATUS.POSTING,
salesman_id: pobj.userid,
salesman_name: pobj.username
});
}
return "success"
});
}
......@@ -420,11 +466,11 @@ class DeliverService extends ServiceBase {
}
// 推送年报信息
await pushTx.pushDeclareReport({ id: pobj.id, file: pobj.file }, deliverData);
// await pushTx.pushDeclareReport({ id: pobj.id, file: pobj.file }, deliverData);
//修改年报订单状态
if (isChange) {
await pushTx.pushChangeOrder(pushTx.TXSTATUS.SUCCESS, deliverData.delivery_code);
}
// if (isChange) {
// await pushTx.pushChangeOrder(pushTx.TXSTATUS.SUCCESS, deliverData.delivery_code);
// }
return this.db.transaction(async (t) => {
await this.annualreportDao.updateByWhere({
......
......@@ -359,6 +359,12 @@ System.SERVERSESTATUS = {
POSTING: "posting",//证书已邮寄
SUCCESS: "success",//服务已完成
CLOSED: "closed",//已关闭
USERCONFIRMATIONWAIT: "userConfirmationWait",//递交文件待确认
USERCONFIRMATIONREJECT: "userConfirmationReject",// 递交文件被驳回
USERCONFIRMATIONRESOLVE: "userConfirmationResolve",//用户已确认递交文件
ACCOUNTREGISTRATION: "accountRegistration",//账户注册
THROUGH: "through",//工信部通过
}
// 年报服务单状态
System.ANNUALREPORT = {
......
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