Commit 6e08c279 by Sxy

feat: 阿里流程

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