Commit 9ddf34bc by 兰国旗

laolan

parent 20a8e468
...@@ -6,1138 +6,1140 @@ const moment = require('moment'); ...@@ -6,1138 +6,1140 @@ const moment = require('moment');
* created at 2020.07.27 * created at 2020.07.27
*/ */
class BaseQcService { class BaseQcService {
constructor() { constructor() {
this.needsolutionDao = system.getObject("db.dbneed.needsolutionDao"); this.needsolutionDao = system.getObject("db.dbneed.needsolutionDao");
this.needinfoDao = system.getObject("db.dbneed.needinfoDao"); this.needinfoDao = system.getObject("db.dbneed.needinfoDao");
this.orderinfoDao = system.getObject("db.dbcorder.orderinfoDao"); this.orderinfoDao = system.getObject("db.dbcorder.orderinfoDao");
this.icpSolutionStatusReference = { this.icpSolutionStatusReference = {
SOLUTION_SUBMIT: "提交服务单", SOLUTION_SUBMIT: "提交服务单",
UN_PAID: "未支付", PAID: "用户支付", USER_UPLOADED: "用户上传资料", MATERIAL_UNCONFIRM: "服务商递交⽂件" UN_PAID: "未支付", PAID: "用户支付", USER_UPLOADED: "用户上传资料", MATERIAL_UNCONFIRM: "服务商递交⽂件"
, USER_CONFIRMED: "⽤户已确认递交⽂件", ACCOUNT_REGISTERED: "完成账户注册", MATERIAL_SUBMITTED: "完成资料递交", , USER_CONFIRMED: "⽤户已确认递交⽂件", ACCOUNT_REGISTERED: "完成账户注册", MATERIAL_SUBMITTED: "完成资料递交",
GXB_ACCEPT: "⼯信部已受理", GXB_REFUSE: "⼯信部不予受理", GXB_FAIL: "⼯信部未通过", GXB_SUCCESS: "工信部通过" GXB_ACCEPT: "⼯信部已受理", GXB_REFUSE: "⼯信部不予受理", GXB_FAIL: "⼯信部未通过", GXB_SUCCESS: "工信部通过"
, CLOSE: "方案关闭" , CLOSE: "方案关闭"
}; };
this.ediSolutionStatusReference = { this.ediSolutionStatusReference = {
SOLUTION_SUBMIT: "服务单通知服务商", SOLUTION_SUBMIT: "服务单通知服务商",
USER_PAY_PRODUCE: "⽤户⽀付", USER_PAY_PRODUCE: "⽤户⽀付",
USER_CONFIRM_PRODUCE: "⽤户确认资料", USER_CONFIRM_PRODUCE: "⽤户确认资料",
USER_REFUSE_PRODUCE: "资料退回修改", USER_REFUSE_PRODUCE: "资料退回修改",
ABC_CLOSE_PRODUCE: "⼩⼆后台关闭服务单", ABC_CLOSE_PRODUCE: "⼩⼆后台关闭服务单",
USER_UPLOAD_PRODUCE: "⽤户补充基本资料" USER_UPLOAD_PRODUCE: "⽤户补充基本资料"
}; };
this.ediProduceStatus = { this.ediProduceStatus = {
110: "⽤户⽀付", 110: "⽤户⽀付",
30: "待⽤户确认", 30: "待⽤户确认",
105: "账户已注册", 105: "账户已注册",
35: "待提交审核", 35: "待提交审核",
109: "管局已通过", 109: "管局已通过",
106: "材料已递交⼯信部", 106: "材料已递交⼯信部",
10: "已⽀付", 10: "已⽀付",
108: "管局不予受理", 108: "管局不予受理",
0: "初始状态", 0: "初始状态",
50: "订单关闭", 50: "订单关闭",
25: "待⽤户提交材料", 25: "待⽤户提交材料",
107: "管局已受理" 107: "管局已受理"
}; };
this.icpApplicationStatusReference = { this.icpApplicationStatusReference = {
507: "完成账户注册", 507: "完成账户注册",
508: "服务商完成提交资料到⼯信部", 508: "服务商完成提交资料到⼯信部",
509: "⼯商部已受理", 509: "⼯商部已受理",
510: "⼯商部不予受理", 510: "⼯商部不予受理",
511: "⼯商部通过", 511: "⼯商部通过",
512: "⼯商部未通过" 512: "⼯商部未通过"
}; };
//(文网文状态2020-9-26) //(文网文状态2020-9-26)
this.wangwenStatusReference = { this.wangwenStatusReference = {
601: "服务商提交资料", 601: "服务商提交资料",
602: "完成账户注册", 602: "完成账户注册",
603: "服务商完成提交资料到⼯信部", 603: "服务商完成提交资料到⼯信部",
604: "⼯商部已受理", 604: "⼯商部已受理",
605: "⼯商部不予受理", 605: "⼯商部不予受理",
606: "⼯商部通过", 606: "⼯商部通过",
607: "⼯商部未通过", 607: "⼯商部未通过",
608: "用户驳回" 608: "用户驳回"
}; };
//(文网文状态2020-9-26) //(文网文状态2020-9-26)
this.wangwenSolutionStatusReference = { this.wangwenSolutionStatusReference = {
"SOLUTION_SUBMIT": "提交服务单", "SOLUTION_SUBMIT": "提交服务单",
"PARTNER_SUBMIT_MATERIAL": "服务商提交资料", "PARTNER_SUBMIT_MATERIAL": "服务商提交资料",
"CERT_ACCOUNT_REGISTERED": "完成账户注册", "CERT_ACCOUNT_REGISTERED": "完成账户注册",
"CERT_MATERIAL_SUBMITTED": "服务商完成提交资料到⼯信部", "CERT_MATERIAL_SUBMITTED": "服务商完成提交资料到⼯信部",
"CERT_GXB_ACCEPT": "⼯商部已受理", "CERT_GXB_ACCEPT": "⼯商部已受理",
"CERT_GXB_SUCCESS": "⼯商部通过", "CERT_GXB_SUCCESS": "⼯商部通过",
"CERT_GXB_FAIL": "⼯商部未通过", "CERT_GXB_FAIL": "⼯商部未通过",
"CERT_GXB_REFUSE": "⼯商部不予受理" "CERT_GXB_REFUSE": "⼯商部不予受理"
}; };
} }
//根据需求关闭ICP方案(关闭需求后调用)
async abolishIcpProgrammeByNeed(pobj) {
console.log("abolishIcpProgrammeByNeed+++",pobj)
var ab = pobj.actionBody;
var app = pobj.appInfo;
if (!app || !app.uapp_id) {
return system.getResultFail(-100, "未知渠道");
}
if (!ab.intentionBizId) {
return system.getResultFail(-101, "需求编号不能为空");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
attributes: ["id", "status", "statusName", "needNo", "uapp_id"],//2020-10-29 laolan xinzeng uapp_id
where: { channelNeedNo: ab.intentionBizId }, raw: true
});
var uappId = {};
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}else{
//2020-12-11 laolan xiugai
uappId['uapp_id'] = needinfo.uapp_id;
}
if (needinfo.status == "ygb") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where: { needNo: needinfo.needNo, isInvalid: 0 }, raw: true
});
if (ns && ns.id) {
if (ns.status == "ywc") {
return system.getResultFail(-103, "方案状态错误,不能废弃已完成方案");
}
var flowStatus = ns.solutionContent && ns.solutionContent.status ? ns.solutionContent.status : "";
if (flowStatus && ["GXB_REFUSE", "CLOSE"].indexOf(flowStatus) < 0) {
return system.getResultFail(-104, "⽅案状态为关闭或不予受理才可关闭需求");
}
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) { //根据需求关闭ICP方案(关闭需求后调用)
var needObj = { async abolishIcpProgrammeByNeed(pobj) {
id: needinfo.id, status: "ygb", notes: ab.note console.log("abolishIcpProgrammeByNeed+++", pobj)
}; var ab = pobj.actionBody;
await self.needinfoDao.update(needObj, t);//关闭需求 var app = pobj.appInfo;
if (ns && ns.id) { if (!app || !app.uapp_id) {
await self.needsolutionDao.model.update({ status: "yzf", isInvalid: 1 }, { where: { id: ns.id }, transaction: t });//方案废弃 return system.getResultFail(-100, "未知渠道");
// return system.getResultSuccess(ns.orderNo); }
ns = ns ? ns : {}; if (!ab.intentionBizId) {
ns = Object.assign(ns,uappId) return system.getResultFail(-101, "需求编号不能为空");
console.log('guanbi ns +++',ns) }
return system.getResultSuccess(ns); //获取需求信息
} var needinfo = await this.needinfoDao.model.findOne({
}) attributes: ["id", "status", "statusName", "needNo", "uapp_id"],//2020-10-29 laolan xinzeng uapp_id
}else{ where: { channelNeedNo: ab.intentionBizId }, raw: true
return system.getResultSuccess(uappId); });
} var uappId = {};
} if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
} else {
//2020-12-11 laolan xiugai
uappId['uapp_id'] = needinfo.uapp_id;
}
if (needinfo.status == "ygb") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where: { needNo: needinfo.needNo, isInvalid: 0 }, raw: true
});
//根据需求查看方案列表 if (ns && ns.id) {
async getProgrammeInfoByChannelNeedNo(pobj) { if (ns.status == "ywc") {
var ab = pobj.actionBody; return system.getResultFail(-103, "方案状态错误,不能废弃已完成方案");
var user = pobj.userInfo; }
if (!user || !user.id) { var flowStatus = ns.solutionContent && ns.solutionContent.status ? ns.solutionContent.status : "";
return system.getResultFail(-100, "未知用户"); if (flowStatus && ["SOLUTION_SUBMIT", "USER_CONFIRM_PRODUCE"].indexOf(flowStatus) >= 0) {
} var self = this;
ab["createUserId"] = user.id; return await this.needsolutionDao.db.transaction(async function (t) {
if (!ab.needNo) { var needObj = {
return system.getResultFail(-101, "需求号不能为空"); id: needinfo.id, status: "ygb", notes: ab.note
} };
//获取需求信息 await self.needinfoDao.update(needObj, t);//关闭需求
var needinfo = await this.needinfoDao.model.findOne({ if (ns && ns.id) {
where: { channelNeedNo: ab.needNo }, raw: true await self.needsolutionDao.model.update({ status: "yzf", isInvalid: 1 }, { where: { id: ns.id }, transaction: t });//方案废弃
}); // return system.getResultSuccess(ns.orderNo);
if (!needinfo || !needinfo.id) { ns = ns ? ns : {};
return system.getResultFail(-102, "未知需求信息"); ns = Object.assign(ns, uappId)
} console.log('guanbi ns +++', ns)
var ns = await this.needsolutionDao.model.findAll({ return system.getResultSuccess(ns);
where: { needNo: needinfo.needNo }, raw: true, }
attributes: ["needNo", "solutionNo", "channelSolutionNo", "orderNo", "solutionContent", "status", "statusName"] })
}); } else {
return system.getResultSuccess(ns); if (flowStatus && ["GXB_REFUSE", "CLOSE"].indexOf(flowStatus) < 0) {
} return system.getResultFail(-104, "⽅案状态为关闭或不予受理才可关闭需求");
//获取方案详情(内部调用) }
async getIcpProgrammeDetail(pobj) { }
var ab = pobj.actionBody; } else {
if (!ab.BizId) { return system.getResultSuccess(uappId);
return system.getResultFail(-101, "方案编号不能为空"); }
} }
//获取方案信息
var ns = await this.needsolutionDao.model.findAll({
where: { channelSolutionNo: ab.BizId, isInvalid: 0 }, raw: true
});
return system.getResultSuccess(ns);
}
//获取方案详情(前端调用)
async getNeedSolutionDetailByUser(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
// ab["createUserId"]=user.id;
if (!ab.solutionNo) {
return system.getResultFail(-101, "方案编号不能为空");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where: { solutionNo: ab.solutionNo, createUserId: user.id }, raw: true
});
if (ns && ns.needNo) {
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: ns.needNo }, raw: true,
attributes: ["publishName", "publishMobile", "channelUserId"]
});
ns.needinfo = needinfo;
}
return system.getResultSuccess(ns);
}
//提交方案 //根据需求查看方案列表
async submitIcpProgramme(pobj) { async getProgrammeInfoByChannelNeedNo(pobj) {
console.log("pobj++++",pobj) var ab = pobj.actionBody;
var ab = pobj.actionBody; var user = pobj.userInfo;
var user = pobj.userInfo; if (!user || !user.id) {
if (!user || !user.id) { return system.getResultFail(-100, "未知用户");
return system.getResultFail(-100, "未知用户"); }
} ab["createUserId"] = user.id;
ab["createUserId"] = user.id; if (!ab.needNo) {
if (!ab.needNo) { return system.getResultFail(-101, "需求号不能为空");
return system.getResultFail(-101, "渠道需求号不能为空"); }
} //获取需求信息
if (!ab.solutionContent) { var needinfo = await this.needinfoDao.model.findOne({
return system.getResultFail(-102, "方案信息有误"); where: { channelNeedNo: ab.needNo }, raw: true
} });
//获取需求信息 if (!needinfo || !needinfo.id) {
var needinfo = await this.needinfoDao.model.findOne({ return system.getResultFail(-102, "未知需求信息");
where: { channelNeedNo: ab.needNo }, raw: true }
}); var ns = await this.needsolutionDao.model.findAll({
if (!needinfo || !needinfo.id) { where: { needNo: needinfo.needNo }, raw: true,
return system.getResultFail(-201, "未知需求信息"); attributes: ["needNo", "solutionNo", "channelSolutionNo", "orderNo", "solutionContent", "status", "statusName"]
} });
if (needinfo.status == "ycd" || needinfo.status == "ygb") { return system.getResultSuccess(ns);
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能创建方案"); }
} //获取方案详情(内部调用)
var bizType = needinfo.typeCode;//ab.solutionContent.bizType;//业务类型 async getIcpProgrammeDetail(pobj) {
ab.solutionContent.bizType = bizType; var ab = pobj.actionBody;
if (!bizType) { if (!ab.BizId) {
return system.getResultFail(-205, "方案类型错误"); return system.getResultFail(-101, "方案编号不能为空");
} }
// if (!bizType || !needinfo.typeCode || bizType != needinfo.typeCode) { //获取方案信息
// return system.getResultFail(-205, "方案类型错误"); var ns = await this.needsolutionDao.model.findAll({
// } where: { channelSolutionNo: ab.BizId, isInvalid: 0 }, raw: true
if (!needinfo.channelTypeCode) { });
return system.getResultFail(-206, "渠道方案类型错误"); return system.getResultSuccess(ns);
} }
ab.solutionContent.typeCode = needinfo.typeCode; //获取方案详情(前端调用)
ab.solutionContent.typeName = needinfo.typeName; async getNeedSolutionDetailByUser(pobj) {
var ns = await this.needsolutionDao.model.findAll({ var ab = pobj.actionBody;
where: { channelNeedNo: ab.needNo }, raw: true, order: [["id", 'asc']] var user = pobj.userInfo;
}); if (!user || !user.id) {
for (var i = 0; i < ns.length; i++) { return system.getResultFail(-100, "未知用户");
var fa = ns[i]; }
if (fa.status == "dqr" || fa.status == "ywc") { // ab["createUserId"]=user.id;
return system.getResultFail(-207, "需求方案已存在,不能重复提交"); if (!ab.solutionNo) {
} return system.getResultFail(-101, "方案编号不能为空");
if (fa.status == "ybh") { }
ab.channelSolutionNo = fa.channelSolutionNo; //获取方案信息
} var ns = await this.needsolutionDao.model.findOne({
if (fa.status == "yzf") { where: { solutionNo: ab.solutionNo, createUserId: user.id }, raw: true
ab.channelSolutionNo = ""; });
} if (ns && ns.needNo) {
} var needinfo = await this.needinfoDao.model.findOne({
var solution = ab.solutionContent.solution; where: { needNo: ns.needNo }, raw: true,
if (!solution) { attributes: ["publishName", "publishMobile", "channelUserId"]
return system.getResultFail(-103, "方案交付信息有误"); });
} ns.needinfo = needinfo;
if (needinfo.channelTypeCode == "7") {//edi }
ab.solutionContent.solution.IcpType = 2; return system.getResultSuccess(ns);
} else if (needinfo.channelTypeCode == "5") {//icp }
ab.solutionContent.solution.IcpType = 1;
} else {
return system.getResultFail(-208, "需求业务类型有误");
}
if (!solution.CompanyName) {
return system.getResultFail(-105, "公司名不能为空");
}
if (!solution.CompanyAddress) {
return system.getResultFail(-106, "公司地址不能为空");
}
if (!solution.Area) {
return system.getResultFail(-107, "区域不能为空");
}
if (!solution.ActionType) {
return system.getResultFail(-108, "办理类型不能为空");
}
var solutionFlowList = ab.solutionContent.solutionFlowList || [];
solutionFlowList.push({
status: "SOLUTION_SUBMIT", statusName: this.icpSolutionStatusReference.SOLUTION_SUBMIT, updated_at: new Date()
});
ab.solutionContent.status = "SOLUTION_SUBMIT";
ab.solutionContent.statusName = this.icpSolutionStatusReference.SOLUTION_SUBMIT;
ab.solutionContent.solutionFlowList = solutionFlowList;
ab["channelNeedNo"] = needinfo.channelNeedNo;
var solutionNo = await this.getBusUid("ns");
ab["solutionNo"] = solutionNo;
ab["status"] = "dqr";
var customerInfo = {//客户信息
"publishName": needinfo.publishName,
"publishMobile": needinfo.publishMobile
};
var salesmanInfo = {//业务员信息
"salesmanName": user.channel_username,
"salesmanMobile": user.mobile,
"salesmanId": user.id,
"salesmanChannelId": user.channel_userid
};
ab.solutionContent["customerInfo"] = customerInfo;
ab.solutionContent["salesmanInfo"] = salesmanInfo;
ab.solutionContent = JSON.stringify(ab.solutionContent);
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
ab["needNo"] = needinfo.needNo;
var od = await self.needsolutionDao.create(ab, t);
if (od && od.id) {
var needObj = {
id: needinfo.id
};
if (!needinfo.followManUserId) {
needObj = {
id: needinfo.id,
followManUserId: user.id,//跟进人id
followManName: user.channel_username,//跟进人姓名
followManMobile: user.mobile,//跟进人手机号(合伙人)
followManOnlyCode: user.channel_userid
};
}
if (!needinfo.followContent) {
var followContent = [{
followDate: new Date(),
content: "icp提交方案"
}];
followContent = JSON.stringify(followContent);
needObj["followContent"] = followContent;
}
await self.needinfoDao.update(needObj, t);
needinfo = await self.needinfoDao.model.findOne({
where: { id: needinfo.id }, raw: true
});
return system.getResultSuccess({ needinfo: needinfo, needsolution: od });
} else {
return system.getResultFail(-302, "提交方案失败");
}
})
} //提交方案
//交付商关闭交付单 async submitIcpProgramme(pobj) {
async closeOrderDelivery(pobj) { console.log("pobj++++", pobj)
var ab = pobj.actionBody; var ab = pobj.actionBody;
if (!ab.orderNo) { var user = pobj.userInfo;
return system.getResultFail(-101, "订单号不能为空"); if (!user || !user.id) {
} return system.getResultFail(-100, "未知用户");
if (!ab.note) { }
return system.getResultFail(-106, "关闭理由不能为空"); ab["createUserId"] = user.id;
} else { if (!ab.needNo) {
ab.Note = ab.note; return system.getResultFail(-101, "渠道需求号不能为空");
} }
var ns = await this.needsolutionDao.model.findOne({ if (!ab.solutionContent) {
where: { orderNo: ab.orderNo }, raw: true return system.getResultFail(-102, "方案信息有误");
}); }
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { channelNeedNo: ab.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能创建方案");
}
var bizType = needinfo.typeCode;//ab.solutionContent.bizType;//业务类型
ab.solutionContent.bizType = bizType;
if (!bizType) {
return system.getResultFail(-205, "方案类型错误");
}
// if (!bizType || !needinfo.typeCode || bizType != needinfo.typeCode) {
// return system.getResultFail(-205, "方案类型错误");
// }
if (!needinfo.channelTypeCode) {
return system.getResultFail(-206, "渠道方案类型错误");
}
ab.solutionContent.typeCode = needinfo.typeCode;
ab.solutionContent.typeName = needinfo.typeName;
var ns = await this.needsolutionDao.model.findAll({
where: { channelNeedNo: ab.needNo }, raw: true, order: [["id", 'asc']]
});
for (var i = 0; i < ns.length; i++) {
var fa = ns[i];
if (fa.status == "dqr" || fa.status == "ywc") {
return system.getResultFail(-207, "需求方案已存在,不能重复提交");
}
if (fa.status == "ybh") {
ab.channelSolutionNo = fa.channelSolutionNo;
}
if (fa.status == "yzf") {
ab.channelSolutionNo = "";
}
}
var solution = ab.solutionContent.solution;
if (!solution) {
return system.getResultFail(-103, "方案交付信息有误");
}
if (needinfo.channelTypeCode == "7") {//edi
ab.solutionContent.solution.IcpType = 2;
} else if (needinfo.channelTypeCode == "5") {//icp
ab.solutionContent.solution.IcpType = 1;
} else {
return system.getResultFail(-208, "需求业务类型有误");
}
if (!solution.CompanyName) {
return system.getResultFail(-105, "公司名不能为空");
}
if (!solution.CompanyAddress) {
return system.getResultFail(-106, "公司地址不能为空");
}
if (!solution.Area) {
return system.getResultFail(-107, "区域不能为空");
}
if (!solution.ActionType) {
return system.getResultFail(-108, "办理类型不能为空");
}
var solutionFlowList = ab.solutionContent.solutionFlowList || [];
solutionFlowList.push({
status: "SOLUTION_SUBMIT", statusName: this.icpSolutionStatusReference.SOLUTION_SUBMIT, updated_at: new Date()
});
ab.solutionContent.status = "SOLUTION_SUBMIT";
ab.solutionContent.statusName = this.icpSolutionStatusReference.SOLUTION_SUBMIT;
ab.solutionContent.solutionFlowList = solutionFlowList;
ab["channelNeedNo"] = needinfo.channelNeedNo;
var solutionNo = await this.getBusUid("ns");
ab["solutionNo"] = solutionNo;
ab["status"] = "dqr";
var customerInfo = {//客户信息
"publishName": needinfo.publishName,
"publishMobile": needinfo.publishMobile
};
var salesmanInfo = {//业务员信息
"salesmanName": user.channel_username,
"salesmanMobile": user.mobile,
"salesmanId": user.id,
"salesmanChannelId": user.channel_userid
};
ab.solutionContent["customerInfo"] = customerInfo;
ab.solutionContent["salesmanInfo"] = salesmanInfo;
ab.solutionContent = JSON.stringify(ab.solutionContent);
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
ab["needNo"] = needinfo.needNo;
var od = await self.needsolutionDao.create(ab, t);
if (od && od.id) {
var needObj = {
id: needinfo.id
};
if (!needinfo.followManUserId) {
needObj = {
id: needinfo.id,
followManUserId: user.id,//跟进人id
followManName: user.channel_username,//跟进人姓名
followManMobile: user.mobile,//跟进人手机号(合伙人)
followManOnlyCode: user.channel_userid
};
}
if (!needinfo.followContent) {
var followContent = [{
followDate: new Date(),
content: "icp提交方案"
}];
followContent = JSON.stringify(followContent);
needObj["followContent"] = followContent;
}
await self.needinfoDao.update(needObj, t);
needinfo = await self.needinfoDao.model.findOne({
where: { id: needinfo.id }, raw: true
});
return system.getResultSuccess({ needinfo: needinfo, needsolution: od });
} else {
return system.getResultFail(-302, "提交方案失败");
}
})
if (!ns || !ns.id) { }
return system.getResultFail(-301, "未知方案"); //交付商关闭交付单
} async closeOrderDelivery(pobj) {
ab["BizId"] = ns.channelSolutionNo; var ab = pobj.actionBody;
pobj.actionBody = ab; if (!ab.orderNo) {
return this.abolishIcpProgramme(pobj); return system.getResultFail(-101, "订单号不能为空");
} }
//服务商方案作废 -- abolishIcpProgramme if (!ab.note) {
async abolishIcpProgramme(pobj) { return system.getResultFail(-106, "关闭理由不能为空");
var ab = pobj.actionBody; } else {
var user = pobj.userInfo; ab.Note = ab.note;
if (!user || !user.id) { }
return system.getResultFail(-100, "未知用户"); var ns = await this.needsolutionDao.model.findOne({
} where: { orderNo: ab.orderNo }, raw: true
if (!ab.BizId) { });
return system.getResultFail(-101, "渠道方案号不能为空");
}
if (!ab.Note) {
return system.getResultFail(-106, "关闭理由不能为空");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where: { channelSolutionNo: ab.BizId, isInvalid: 0 }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-300, "未知方案");
}
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: ns.needNo }, raw: true
});
if (!needinfo) {
return system.getResultFail(-400, "未知方案需求");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-401, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
// if (ns.status != "dqr") {
// return system.getResultFail(-301, "方案状态错误,只能废弃待确认方案");
// }
var solutionContent = ns.solutionContent;
if (!solutionContent.status || ["USER_UPLOADED", "MATERIAL_UNCONFIRM", "USER_CONFIRMED", "ACCOUNT_REGISTERED", "MATERIAL_SUBMITTED"].indexOf(solutionContent.status) < 0) {
return system.getResultFail(-302, "方案流程状态错误,不能执行此操作");
}
solutionContent.serviceProviderNote = ab.Note;
var solutionFlowList = solutionContent.solutionFlowList || [];
solutionFlowList.push({
status: "CLOSE", statusName: this.icpSolutionStatusReference.CLOSE, updated_at: new Date()
});
solutionContent.status = "CLOSE";
solutionContent.statusName = this.icpSolutionStatusReference.CLOSE;
solutionContent = JSON.stringify(solutionContent);
await this.needsolutionDao.update({ id: ns.id, status: "yzf", isInvalid: 1, solutionContent: solutionContent });//方案废弃
//获取方案信息
var new_ns = await this.needsolutionDao.model.findOne({
where: { id: ns.id }, raw: true
});
return system.getResultSuccess(new_ns);
}
//交付商提交材料信息
async serviceProviderSubmitMaterial(pobj) {
var ab = pobj.actionBody;
console.log('ab++',ab)
if (!ab.orderNo) {
return system.getResultFail(-101, "订单号不能为空");
}
var ns = await this.needsolutionDao.model.findOne({
where: { orderNo: ab.orderNo }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-301, "未知方案");
}
ab["BizId"] = ns.channelSolutionNo;
pobj.actionBody = ab;
return this.submitIcpMaterial(pobj);
}
//提交icp材料信息
async submitIcpMaterial(pobj) {
var ab = pobj.actionBody;
console.log('ababab++',ab)
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
// ab["createUserId"] = user.id;
if (!ab.BizId) {
return system.getResultFail(-101, "渠道方案编号不能为空");
}
if (!ab.material) {
return system.getResultFail(-102, "材料信息有误");
}
//获取方案信息
var needsolutioninfo = await this.needsolutionDao.model.findOne({
attributes: ["id", "needNo", "orderNo", "solutionContent"],
where: { channelSolutionNo: ab.BizId, isInvalid: 0 }, raw: true
});
console.log('needsolutioninfo+++',needsolutioninfo)
if (!needsolutioninfo || !needsolutioninfo.id) {
return system.getResultFail(-400, "未知方案");
}
if (!needsolutioninfo.needNo) {
return system.getResultFail(-401, "方案需求信息有误");
}
var solutionContent = needsolutioninfo.solutionContent;
if (!solutionContent) {
return system.getResultFail(-402, "方案交付信息有误");
}
//----
var productType = solutionContent.solution;
if(productType && productType.IcpType){
productType = productType.IcpType
switch (productType) {
case "5":
productType = "ICP"
break;
case "7":
productType = "EDI"
break;
}
}
//----
// var orderInfo = await this.orderinfoDao.model.findOne({
// attributes: ["uapp_id"],
// where: {orderNo: needsolutioninfo.orderNo}, raw: true
// })
// if(orderInfo){
// var uappId = orderInfo.uapp_id
// }
// if(uappId == "18"){//ali
// if (solutionContent.status != "USER_UPLOADED") {
// return system.getResultFail(-403, "用户未上传材料,不能执行此操作");
// }
// }
//获取需求信息
// var needinfo = await this.needinfoDao.model.findOne({
// where: { needNo: needsolutioninfo.needNo }, raw: true
// });
// if (!needinfo || !needinfo.id) {
// return system.getResultFail(-201, "未知需求信息");
// }
// // if (needinfo.status == "ycd" || needinfo.status == "ygb") {
// if (needinfo.status == "ygb") {
// return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
// }
var material = ab.material;
if (!material.Domain) {
return system.getResultFail(-101, "备案域名不能为空");
}
//CorporateName 法⼈名称
if (!material.hasOwnProperty("IncludeForeignInvestment")) {
return system.getResultFail(-102, "包含外贸参数不能为空");
}
if (!material.PartnerBusinessLicense) {
return system.getResultFail(-103, "营业执照不能为空");
}
if (!material.PartnerIdCardList || material.PartnerIdCardList.length < 1) {
return system.getResultFail(-105, "相关人员身份证不能为空");
}
if (!material.PartnerDomainCertificate) {
return system.getResultFail(-106, "域名证书不能为空");
}
solutionContent.material = ab.material;
var solutionFlowList = solutionContent.solutionFlowList || [];
solutionFlowList.push({
status: "MATERIAL_UNCONFIRM", statusName: this.icpSolutionStatusReference.MATERIAL_UNCONFIRM, updated_at: new Date()
});
solutionContent.status = "MATERIAL_UNCONFIRM";
solutionContent.statusName = this.icpSolutionStatusReference.MATERIAL_UNCONFIRM;
needsolutioninfo.solutionContent = JSON.stringify(solutionContent);
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
await self.needsolutionDao.update(needsolutioninfo, t);
var new_needsolutioninfo = await self.needsolutionDao.model.findOne({
where: { id: needsolutioninfo.id }, raw: true
});
//2020-10-27 laolan start
var orderInfo = await self.orderinfoDao.model.findOne({
where: {orderNo: ab.orderNo}, raw: true
})
if(orderInfo){
var uappIds = orderInfo.uapp_id;
new_needsolutioninfo['orderChannelNo'] = orderInfo.channelOrderNo;
new_needsolutioninfo['uapp_id'] = uappIds;
new_needsolutioninfo['productType'] = productType;
}
console.log('new_needsolutioninfo+++',new_needsolutioninfo)
//2020-10-27 laolan end
return system.getResultSuccess(new_needsolutioninfo);
}) if (!ns || !ns.id) {
} return system.getResultFail(-301, "未知方案");
//交付商通知状态变更 }
async serviceProviderNotification(pobj) { ab["BizId"] = ns.channelSolutionNo;
var ab = pobj.actionBody; pobj.actionBody = ab;
if (!ab.orderNo) { return this.abolishIcpProgramme(pobj);
return system.getResultFail(-101, "订单号不能为空"); }
} //服务商方案作废 -- abolishIcpProgramme
if (!ab.status) { async abolishIcpProgramme(pobj) {
return system.getResultFail(-102, "交付状态不能为空"); var ab = pobj.actionBody;
} else { var user = pobj.userInfo;
ab["ApplicationStatus"] = ab.status; if (!user || !user.id) {
} return system.getResultFail(-100, "未知用户");
if (ab.officialFileURL) { }
ab["OfficialFileURL"] = ab.officialFileURL; if (!ab.BizId) {
} return system.getResultFail(-101, "渠道方案号不能为空");
}
if (!ab.Note) {
return system.getResultFail(-106, "关闭理由不能为空");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where: { channelSolutionNo: ab.BizId, isInvalid: 0 }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-300, "未知方案");
}
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: ns.needNo }, raw: true
});
if (!needinfo) {
return system.getResultFail(-400, "未知方案需求");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-401, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
// if (ns.status != "dqr") {
// return system.getResultFail(-301, "方案状态错误,只能废弃待确认方案");
// }
var solutionContent = ns.solutionContent;
if (!solutionContent.status || ["USER_UPLOADED", "MATERIAL_UNCONFIRM", "USER_CONFIRMED", "ACCOUNT_REGISTERED", "MATERIAL_SUBMITTED"].indexOf(solutionContent.status) < 0) {
return system.getResultFail(-302, "方案流程状态错误,不能执行此操作");
}
solutionContent.serviceProviderNote = ab.Note;
var solutionFlowList = solutionContent.solutionFlowList || [];
solutionFlowList.push({
status: "CLOSE", statusName: this.icpSolutionStatusReference.CLOSE, updated_at: new Date()
});
solutionContent.status = "CLOSE";
solutionContent.statusName = this.icpSolutionStatusReference.CLOSE;
solutionContent = JSON.stringify(solutionContent);
await this.needsolutionDao.update({ id: ns.id, status: "yzf", isInvalid: 1, solutionContent: solutionContent });//方案废弃
//获取方案信息
var new_ns = await this.needsolutionDao.model.findOne({
where: { id: ns.id }, raw: true
});
return system.getResultSuccess(new_ns);
}
//交付商提交材料信息
async serviceProviderSubmitMaterial(pobj) {
var ab = pobj.actionBody;
console.log('ab++', ab)
if (!ab.orderNo) {
return system.getResultFail(-101, "订单号不能为空");
}
var ns = await this.needsolutionDao.model.findOne({
where: { orderNo: ab.orderNo }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-301, "未知方案");
}
ab["BizId"] = ns.channelSolutionNo;
pobj.actionBody = ab;
return this.submitIcpMaterial(pobj);
}
//提交icp材料信息
async submitIcpMaterial(pobj) {
var ab = pobj.actionBody;
console.log('ababab++', ab)
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
// ab["createUserId"] = user.id;
if (!ab.BizId) {
return system.getResultFail(-101, "渠道方案编号不能为空");
}
if (!ab.material) {
return system.getResultFail(-102, "材料信息有误");
}
//获取方案信息
var needsolutioninfo = await this.needsolutionDao.model.findOne({
attributes: ["id", "needNo", "orderNo", "solutionContent"],
where: { channelSolutionNo: ab.BizId, isInvalid: 0 }, raw: true
});
console.log('needsolutioninfo+++', needsolutioninfo)
if (!needsolutioninfo || !needsolutioninfo.id) {
return system.getResultFail(-400, "未知方案");
}
if (!needsolutioninfo.needNo) {
return system.getResultFail(-401, "方案需求信息有误");
}
var solutionContent = needsolutioninfo.solutionContent;
if (!solutionContent) {
return system.getResultFail(-402, "方案交付信息有误");
}
//----
var productType = solutionContent.solution;
if (productType && productType.IcpType) {
productType = productType.IcpType
switch (productType) {
case "5":
productType = "ICP"
break;
case "7":
productType = "EDI"
break;
}
}
//----
// var orderInfo = await this.orderinfoDao.model.findOne({
// attributes: ["uapp_id"],
// where: {orderNo: needsolutioninfo.orderNo}, raw: true
// })
// if(orderInfo){
// var uappId = orderInfo.uapp_id
// }
// if(uappId == "18"){//ali
// if (solutionContent.status != "USER_UPLOADED") {
// return system.getResultFail(-403, "用户未上传材料,不能执行此操作");
// }
// }
//获取需求信息
// var needinfo = await this.needinfoDao.model.findOne({
// where: { needNo: needsolutioninfo.needNo }, raw: true
// });
// if (!needinfo || !needinfo.id) {
// return system.getResultFail(-201, "未知需求信息");
// }
// // if (needinfo.status == "ycd" || needinfo.status == "ygb") {
// if (needinfo.status == "ygb") {
// return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
// }
var material = ab.material;
if (!material.Domain) {
return system.getResultFail(-101, "备案域名不能为空");
}
//CorporateName 法⼈名称
if (!material.hasOwnProperty("IncludeForeignInvestment")) {
return system.getResultFail(-102, "包含外贸参数不能为空");
}
if (!material.PartnerBusinessLicense) {
return system.getResultFail(-103, "营业执照不能为空");
}
if (!material.PartnerIdCardList || material.PartnerIdCardList.length < 1) {
return system.getResultFail(-105, "相关人员身份证不能为空");
}
if (!material.PartnerDomainCertificate) {
return system.getResultFail(-106, "域名证书不能为空");
}
solutionContent.material = ab.material;
var solutionFlowList = solutionContent.solutionFlowList || [];
solutionFlowList.push({
status: "MATERIAL_UNCONFIRM", statusName: this.icpSolutionStatusReference.MATERIAL_UNCONFIRM, updated_at: new Date()
});
solutionContent.status = "MATERIAL_UNCONFIRM";
solutionContent.statusName = this.icpSolutionStatusReference.MATERIAL_UNCONFIRM;
needsolutioninfo.solutionContent = JSON.stringify(solutionContent);
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
await self.needsolutionDao.update(needsolutioninfo, t);
var new_needsolutioninfo = await self.needsolutionDao.model.findOne({
where: { id: needsolutioninfo.id }, raw: true
});
//2020-10-27 laolan start
var orderInfo = await self.orderinfoDao.model.findOne({
where: { orderNo: ab.orderNo }, raw: true
})
if (orderInfo) {
var uappIds = orderInfo.uapp_id;
new_needsolutioninfo['orderChannelNo'] = orderInfo.channelOrderNo;
new_needsolutioninfo['uapp_id'] = uappIds;
new_needsolutioninfo['productType'] = productType;
}
console.log('new_needsolutioninfo+++', new_needsolutioninfo)
//2020-10-27 laolan end
return system.getResultSuccess(new_needsolutioninfo);
var ns = await this.needsolutionDao.model.findOne({ })
where: { orderNo: ab.orderNo }, raw: true }
}); //交付商通知状态变更
if (!ns || !ns.id) { async serviceProviderNotification(pobj) {
return system.getResultFail(-301, "未知方案"); var ab = pobj.actionBody;
} if (!ab.orderNo) {
ab["BizId"] = ns.channelSolutionNo; return system.getResultFail(-101, "订单号不能为空");
ab["solutionNo"] = ns.solutionNo; }
pobj.actionBody = ab; if (!ab.status) {
return this.acceptIcpPartnerNotification(pobj); return system.getResultFail(-102, "交付状态不能为空");
} } else {
//服务商通知状态变更 ab["ApplicationStatus"] = ab.status;
async acceptIcpPartnerNotification(pobj) { }
console.log('服务商通知状态变更pobj++++',pobj) if (ab.officialFileURL) {
var ab = pobj.actionBody; ab["OfficialFileURL"] = ab.officialFileURL;
var user = pobj.userInfo; }
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
// ab["createUserId"] = user.id;
// if (!ab.BizId) {
// return system.getResultFail(-101, "渠道方案编号不能为空");
// }
if (!ab.solutionNo) {
return system.getResultFail(-101, "方案编号不能为空");
}
if (!ab.ApplicationStatus) {
return system.getResultFail(-102, "通知状态不能为空");
}
//获取方案信息
var needsolutioninfo = await this.needsolutionDao.model.findOne({
attributes: ["id", "status", "solutionContent", "needNo"],
where: { solutionNo: ab.solutionNo }, raw: true
});
if (!needsolutioninfo || !needsolutioninfo.id) {
return system.getResultFail(-400, "未知方案");
}
// if (!needsolutioninfo.needNo) {
// return system.getResultFail(-401, "方案需求信息有误");
// }
var solutionContent = needsolutioninfo.solutionContent;
if (!solutionContent) {
return system.getResultFail(-402, "方案交付信息有误");
}
if (solutionContent.applicationStatus && solutionContent.applicationStatus > ab.ApplicationStatus) {
return system.getResultFail(-403, "操作失败,交付流程未按顺序执行");
}
if (solutionContent.ApplicationStatus && solutionContent.ApplicationStatus == ab.ApplicationStatus) {
return system.getResultFail(-405, "操作失败,该流程状态已提交,不能重复提交");
}
//获取需求信息
// var needinfo = await this.needinfoDao.model.findOne({
// where: { needNo: needsolutioninfo.needNo }, raw: true
// });
// if (!needinfo || !needinfo.id) {
// return system.getResultFail(-201, "未知需求信息");
// }
// // if (needinfo.status == "ycd" || needinfo.status == "ygb") {
// if (needinfo.status == "ygb") {
// return system.getResultFail(-202, "serviceProviderSubmitMateria" + needinfo.statusName + ",不能执行此操作");
// }
var solutionFlowList = solutionContent.solutionFlowList || [];
var orderuappId = await this.orderinfoDao.model.findOne({
attributes:["uapp_id"],
where: {orderNo: ab.orderNo}, raw: true
})
console.log("orderuappId+++",orderuappId)
if(orderuappId){
var uappId = orderuappId.uapp_id;
}
if(uappId != '50'){
if (!needsolutioninfo.needNo) {
return system.getResultFail(-401, "方案需求信息有误");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: needsolutioninfo.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
if (needinfo.status == "ygb") {
return system.getResultFail(-202, "serviceProviderSubmitMateria" + needinfo.statusName + ",不能执行此操作");
}
}
if (ab.ApplicationStatus == 507) {//完成账户注册
if(uappId != '50'){
if (solutionContent.status != "USER_CONFIRMED") {
return system.getResultFail(-508, "交付流程错误,用户确认递交⽂件后才能执行此操作");
}
}
solutionContent.ApplicationStatus = 507;
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "ACCOUNT_REGISTERED", statusName: this.icpSolutionStatusReference.ACCOUNT_REGISTERED, updated_at: new Date()
});
solutionContent.status = "ACCOUNT_REGISTERED";
solutionContent.statusName = this.icpSolutionStatusReference.ACCOUNT_REGISTERED;
}
if (ab.ApplicationStatus == 508) {//"服务商完成提交资料到⼯信部
if (solutionContent.status != "ACCOUNT_REGISTERED") {
return system.getResultFail(-508, "交付流程错误,请先完成账户注册");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "MATERIAL_SUBMITTED", statusName: this.icpSolutionStatusReference.MATERIAL_SUBMITTED, updated_at: new Date()
});
solutionContent.status = "MATERIAL_SUBMITTED";
solutionContent.statusName = this.icpSolutionStatusReference.MATERIAL_SUBMITTED;
}
if (ab.ApplicationStatus == 509) {//⼯商部已受理
if (solutionContent.status != "MATERIAL_SUBMITTED") {
return system.getResultFail(-509, "交付流程错误,请先完成资料递交");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "GXB_ACCEPT", statusName: this.icpSolutionStatusReference.GXB_ACCEPT, updated_at: new Date()
});
solutionContent.status = "GXB_ACCEPT";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_ACCEPT;
}
if (ab.ApplicationStatus == 510) {//⼯商部不予受理
if (solutionContent.status != "MATERIAL_SUBMITTED") {
return system.getResultFail(-510, "交付流程错误,请先完成资料递交");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "GXB_REFUSE", statusName: this.icpSolutionStatusReference.GXB_REFUSE, updated_at: new Date()
});
solutionContent.status = "GXB_REFUSE";
needsolutioninfo.status = "ywc";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_REFUSE;
}
if (ab.ApplicationStatus == 511) {//⼯商部通过
if (solutionContent.status != "GXB_ACCEPT") {
return system.getResultFail(-511, "交付流程错误,⼯信部已受理后才能执行此操作");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "GXB_SUCCESS", statusName: this.icpSolutionStatusReference.GXB_SUCCESS, updated_at: new Date()
});
needsolutioninfo.status = "ywc";
solutionContent.status = "GXB_SUCCESS";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_SUCCESS;
}
if (ab.ApplicationStatus == 512) {//⼯信部未通过
if (solutionContent.status != "GXB_ACCEPT") {
return system.getResultFail(-512, "交付流程错误,⼯信部已受理后才能执行此操作");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "GXB_FAIL", statusName: this.icpSolutionStatusReference.GXB_FAIL, updated_at: new Date()
});
solutionContent.status = "GXB_FAIL";
needsolutioninfo.status = "ywc";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_FAIL;
}
solutionContent.solutionFlowList = solutionFlowList;
var applicationStatusList = solutionContent.applicationStatusList || [];
var statusObj = {
"OfficialFileURL": ab.OfficialFileURL || "",
"ApplicationStatus": ab.ApplicationStatus,
"ApplicationStatusName": this.icpApplicationStatusReference[ab.ApplicationStatus],
"created_at": new Date()
};
applicationStatusList.push(statusObj);
solutionContent.applicationStatusList = applicationStatusList;
solutionContent.applicationStatus = ab.ApplicationStatus;
needsolutioninfo.solutionContent = JSON.stringify(solutionContent);
console.log("ab.orderNo+++",ab.orderNo) var ns = await this.needsolutionDao.model.findOne({
var self = this; where: { orderNo: ab.orderNo }, raw: true
var orderInfo = await self.orderinfoDao.model.findOne({ });
attributes:["channelOrderNo"], if (!ns || !ns.id) {
where: {orderNo: ab.orderNo}, raw: true return system.getResultFail(-301, "未知方案");
}) }
console.log("orderInfo+++",orderInfo) ab["BizId"] = ns.channelSolutionNo;
if(orderInfo){ ab["solutionNo"] = ns.solutionNo;
var channelOrderNo = orderInfo.channelOrderNo pobj.actionBody = ab;
} return this.acceptIcpPartnerNotification(pobj);
return await this.needsolutionDao.db.transaction(async function (t) { }
await self.needsolutionDao.update(needsolutioninfo, t); //服务商通知状态变更
statusObj["BizId"] = ab.BizId; async acceptIcpPartnerNotification(pobj) {
//2020-10-27 laolan start console.log('服务商通知状态变更pobj++++', pobj)
statusObj['uapp_id'] = uappId; var ab = pobj.actionBody;
statusObj['channelOrderNo'] = channelOrderNo; var user = pobj.userInfo;
console.log('statusObj++',statusObj)
//2020-10-27 laolan start
return system.getResultSuccess(statusObj);
})
}
//接收渠道方案状态变更通知 if (!user || !user.id) {
async receiveIcpStatusNotify(pobj) { return system.getResultFail(-100, "未知用户");
var ab = pobj.actionBody; }
if (!ab.BizId) { // ab["createUserId"] = user.id;
return system.getResultFail(-101, "渠道方案号不能为空"); // if (!ab.BizId) {
} // return system.getResultFail(-101, "渠道方案编号不能为空");
if (!ab.status) { // }
return system.getResultFail(-102, "方案状态不能为空"); if (!ab.solutionNo) {
} return system.getResultFail(-101, "方案编号不能为空");
//获取方案信息 }
var ns = await this.needsolutionDao.model.findOne({ if (!ab.ApplicationStatus) {
where: { channelSolutionNo: ab.BizId, isInvalid: 0 }, raw: true return system.getResultFail(-102, "通知状态不能为空");
}); }
if (!ns || !ns.id) { //获取方案信息
return system.getResultFail(-102, "未知方案"); var needsolutioninfo = await this.needsolutionDao.model.findOne({
} attributes: ["id", "status", "solutionContent", "needNo"],
var needinfo = await this.needinfoDao.model.findOne({ where: { solutionNo: ab.solutionNo }, raw: true
where: { needNo: ns.needNo }, raw: true });
}); if (!needsolutioninfo || !needsolutioninfo.id) {
if (!needinfo) { return system.getResultFail(-400, "未知方案");
return system.getResultFail(-104, "未知方案需求"); }
} // if (!needsolutioninfo.needNo) {
if (needinfo.status == "ygb") { // return system.getResultFail(-401, "方案需求信息有误");
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作"); // }
} var solutionContent = needsolutioninfo.solutionContent;
// if (ns.status == "yzf" || ns.status == "ywc") { if (!solutionContent) {
// return system.getResultFail(-103, "该方案状态为" + ns.statusName + ",不能执行此操作"); return system.getResultFail(-402, "方案交付信息有误");
// } }
var solutionContent = ns.solutionContent; if (solutionContent.applicationStatus && solutionContent.applicationStatus > ab.ApplicationStatus) {
var checkStatus = { return system.getResultFail(-403, "操作失败,交付流程未按顺序执行");
ACCOUNT_REGISTERED: "完成账户注册", MATERIAL_SUBMITTED: "完成资料递交", }
GXB_ACCEPT: "⼯信部已受理", GXB_REFUSE: "⼯信部不予受理", GXB_FAIL: "⼯信部未通过", GXB_SUCCESS: "工信部通过" if (solutionContent.ApplicationStatus && solutionContent.ApplicationStatus == ab.ApplicationStatus) {
, CLOSE: "方案关闭" return system.getResultFail(-405, "操作失败,该流程状态已提交,不能重复提交");
}; }
if (solutionContent.status && checkStatus[solutionContent.status]) { //获取需求信息
return system.getResultFail(-111, "方案已进入" + solutionContent.statusName + "流程,不能执行此操作"); // var needinfo = await this.needinfoDao.model.findOne({
} // where: { needNo: needsolutioninfo.needNo }, raw: true
//方案流程列表 // });
var solutionFlowList = solutionContent.solutionFlowList || []; // if (!needinfo || !needinfo.id) {
if (ab.status == "1") {//⽤户已支付 // return system.getResultFail(-201, "未知需求信息");
var afterStatusList=[//用户支付后的流程状态 // }
"USER_UPLOADED", "MATERIAL_UNCONFIRM", "USER_CONFIRMED", "ACCOUNT_REGISTERED", // // if (needinfo.status == "ycd" || needinfo.status == "ygb") {
"MATERIAL_SUBMITTED","GXB_ACCEPT","GXB_REFUSE","GXB_FAIL","GXB_SUCCESS","CLOSE" // if (needinfo.status == "ygb") {
]; // return system.getResultFail(-202, "serviceProviderSubmitMateria" + needinfo.statusName + ",不能执行此操作");
if(!solutionContent.status || afterStatusList.indexOf(solutionContent.status)<0){ // }
solutionFlowList.push({ var solutionFlowList = solutionContent.solutionFlowList || [];
status: "PAID", statusName: this.icpSolutionStatusReference.PAID, updated_at: new Date() var orderuappId = await this.orderinfoDao.model.findOne({
}); attributes: ["uapp_id"],
solutionContent.status = "PAID"; where: { orderNo: ab.orderNo }, raw: true
solutionContent.statusName = this.icpSolutionStatusReference.PAID; })
} console.log("orderuappId+++", orderuappId)
// 2020 0826 lin修改 n_need_info status为ycd 已成单 if (orderuappId) {
let needObj = { var uappId = orderuappId.uapp_id;
id: needinfo.id, status: "ycd" }
} if (uappId != '50') {
await this.needinfoDao.update(needObj);//关闭需求 if (!needsolutioninfo.needNo) {
} else if (ab.status == "2") {//⽤户已上传 return system.getResultFail(-401, "方案需求信息有误");
if (solutionContent.status == "USER_CONFIRMED") {//防止用户确认后又否决 }
return system.getResultFail(-112, "操作失败,⽤户已确认递交⽂件"); //获取需求信息
} var needinfo = await this.needinfoDao.model.findOne({
solutionFlowList.push({ where: { needNo: needsolutioninfo.needNo }, raw: true
status: "USER_UPLOADED", statusName: this.icpSolutionStatusReference.USER_UPLOADED, updated_at: new Date() });
}); if (!needinfo || !needinfo.id) {
solutionContent.status = "USER_UPLOADED"; return system.getResultFail(-201, "未知需求信息");
solutionContent.statusName = this.icpSolutionStatusReference.USER_UPLOADED; }
} else if (ab.status == "4") {//⽤户已确认 if (needinfo.status == "ygb") {
if (solutionContent.status != "MATERIAL_UNCONFIRM") { return system.getResultFail(-202, "serviceProviderSubmitMateria" + needinfo.statusName + ",不能执行此操作");
return system.getResultFail(-113, "操作失败,服务商递交⽂件后才能执行此操作"); }
} }
solutionFlowList.push({ if (ab.ApplicationStatus == 507) {//完成账户注册
status: "USER_CONFIRMED", statusName: this.icpSolutionStatusReference.USER_CONFIRMED, updated_at: new Date() if (uappId != '50') {
}); if (solutionContent.status != "USER_CONFIRMED") {
solutionContent.status = "USER_CONFIRMED"; return system.getResultFail(-508, "交付流程错误,用户确认递交⽂件后才能执行此操作");
solutionContent.statusName = this.icpSolutionStatusReference.USER_CONFIRMED; }
} else if (ab.status == "11") {//⽅案已关闭 }
solutionFlowList.push({ solutionContent.ApplicationStatus = 507;
status: "CLOSE", statusName: this.icpSolutionStatusReference.CLOSE, updated_at: new Date() solutionFlowList.push({
}); file: ab.OfficialFileURL || "",
solutionContent.status = "CLOSE"; status: "ACCOUNT_REGISTERED", statusName: this.icpSolutionStatusReference.ACCOUNT_REGISTERED, updated_at: new Date()
solutionContent.statusName = this.icpSolutionStatusReference.CLOSE; });
} else { solutionContent.status = "ACCOUNT_REGISTERED";
return system.getResultFail(-110, "状态错误"); solutionContent.statusName = this.icpSolutionStatusReference.ACCOUNT_REGISTERED;
} }
solutionContent.solutionFlowList = solutionFlowList; if (ab.ApplicationStatus == 508) {//"服务商完成提交资料到⼯信部
if (solutionContent.status != "ACCOUNT_REGISTERED") {
return system.getResultFail(-508, "交付流程错误,请先完成账户注册");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "MATERIAL_SUBMITTED", statusName: this.icpSolutionStatusReference.MATERIAL_SUBMITTED, updated_at: new Date()
});
solutionContent.status = "MATERIAL_SUBMITTED";
solutionContent.statusName = this.icpSolutionStatusReference.MATERIAL_SUBMITTED;
}
if (ab.ApplicationStatus == 509) {//⼯商部已受理
if (solutionContent.status != "MATERIAL_SUBMITTED") {
return system.getResultFail(-509, "交付流程错误,请先完成资料递交");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "GXB_ACCEPT", statusName: this.icpSolutionStatusReference.GXB_ACCEPT, updated_at: new Date()
});
solutionContent.status = "GXB_ACCEPT";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_ACCEPT;
}
if (ab.ApplicationStatus == 510) {//⼯商部不予受理
if (solutionContent.status != "MATERIAL_SUBMITTED") {
return system.getResultFail(-510, "交付流程错误,请先完成资料递交");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "GXB_REFUSE", statusName: this.icpSolutionStatusReference.GXB_REFUSE, updated_at: new Date()
});
solutionContent.status = "GXB_REFUSE";
needsolutioninfo.status = "ywc";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_REFUSE;
}
if (ab.ApplicationStatus == 511) {//⼯商部通过
if (solutionContent.status != "GXB_ACCEPT") {
return system.getResultFail(-511, "交付流程错误,⼯信部已受理后才能执行此操作");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "GXB_SUCCESS", statusName: this.icpSolutionStatusReference.GXB_SUCCESS, updated_at: new Date()
});
needsolutioninfo.status = "ywc";
solutionContent.status = "GXB_SUCCESS";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_SUCCESS;
}
if (ab.ApplicationStatus == 512) {//⼯信部未通过
if (solutionContent.status != "GXB_ACCEPT") {
return system.getResultFail(-512, "交付流程错误,⼯信部已受理后才能执行此操作");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "GXB_FAIL", statusName: this.icpSolutionStatusReference.GXB_FAIL, updated_at: new Date()
});
solutionContent.status = "GXB_FAIL";
needsolutioninfo.status = "ywc";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_FAIL;
}
solutionContent.solutionFlowList = solutionFlowList;
var applicationStatusList = solutionContent.applicationStatusList || [];
var statusObj = {
"OfficialFileURL": ab.OfficialFileURL || "",
"ApplicationStatus": ab.ApplicationStatus,
"ApplicationStatusName": this.icpApplicationStatusReference[ab.ApplicationStatus],
"created_at": new Date()
};
applicationStatusList.push(statusObj);
solutionContent.applicationStatusList = applicationStatusList;
solutionContent.applicationStatus = ab.ApplicationStatus;
needsolutioninfo.solutionContent = JSON.stringify(solutionContent);
var material = solutionContent.customerMaterial || {}; console.log("ab.orderNo+++", ab.orderNo)
if (ab.remark) { var self = this;
solutionContent.customerRemark = ab.remark; var orderInfo = await self.orderinfoDao.model.findOne({
} attributes: ["channelOrderNo"],
if (ab.newbusinessLicense) { where: { orderNo: ab.orderNo }, raw: true
material.businessLicense = ab.newbusinessLicense; })
material.aliBusinessLicense = ab.businessLicense; console.log("orderInfo+++", orderInfo)
} if (orderInfo) {
if (ab.newidCardUrlList && ab.newidCardUrlList.length > 0) { var channelOrderNo = orderInfo.channelOrderNo
material.idCardUrlList = ab.newidCardUrlList; }
material.aliIdCardUrlList = ab.idCardUrlList; return await this.needsolutionDao.db.transaction(async function (t) {
} await self.needsolutionDao.update(needsolutioninfo, t);
if (ab.newuserPlan) { statusObj["BizId"] = ab.BizId;
material.userPlan = ab.newuserPlan; //2020-10-27 laolan start
material.aliUserPlan = ab.userPlan; statusObj['uapp_id'] = uappId;
} statusObj['channelOrderNo'] = channelOrderNo;
if (ab.newuserForeig) { console.log('statusObj++', statusObj)
material.userForeig = ab.newuserForeig; //2020-10-27 laolan start
material.aliUserForeig = ab.userForeig; return system.getResultSuccess(statusObj);
} })
if (ab.newuserLaw) { }
material.userLaw = ab.newuserLaw;
material.aliUserLaw = ab.userLaw;
}
if (ab.newuserOtherList && ab.newuserOtherList.length > 0) {
material.userOtherList = ab.newuserOtherList;
material.aliUserOtherList = ab.userOtherList;
}
solutionContent.customerMaterial = material;
solutionContent = JSON.stringify(solutionContent);
var updateObj = {
id: ns.id, solutionContent: solutionContent
};
if (ab.status == "11") {//⽅案已关闭
updateObj["status"] = "yzf";
updateObj["isInvalid"] = 1;
}
await this.needsolutionDao.update(updateObj);//方案状态修改
var new_ns = await this.needsolutionDao.model.findOne({
where: { id: ns.id }, raw: true
});
return system.getResultSuccess(ns);
}
//接收icp用户方案反馈
async receiveIcpFeedback(pobj) {
var ab = pobj.actionBody;
if (!ab.intentionBizId) {
return system.getResultFail(-101, "渠道需求编号错误");
}
if (!ab.description) {
return system.getResultFail(-102, "问题描述不能为空");
}
if (!ab.hasOwnProperty("intentionStatus")) {
return system.getResultFail(-103, "需求当前状态不能为空");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { channelNeedNo: ab.intentionBizId }, raw: true
});
if (!needinfo) {
return system.getResultFail(-104, "未知方案需求");
}
// if (needinfo.status == "ycd" || needinfo.status == "ygb") {
if (needinfo.status == "ygb") {
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where: { channelNeedNo: ab.intentionBizId, isInvalid: 0 }, raw: true
});
if (!ns) {
return system.getResultFail(-106, "未知方案");
}
var intentionStatusList = ["未知", "⽅案待服务商确认", "⽅案待⽤户确认", "处理中", "已完成", "已关闭"];
var updateObj = {
id: ns.id
};
var solutionContent = ns.solutionContent;
solutionContent.customerRemark = ab.description;
solutionContent.needStatus = ab.intentionStatus;
if (ab.intentionStatus == 1) {
updateObj["status"] = "ybh";
updateObj["isInvalid"] = 1;
} else if (ab.intentionStatus == 2) {
updateObj["status"] = "dqr";
} else if (ab.intentionStatus == 3) {
updateObj["status"] = "dqr";
} else if (ab.intentionStatus == 4) {
updateObj["status"] = "dqr";
} else if (ab.intentionStatus == 5) {
updateObj["status"] = "yzf";
updateObj["isInvalid"] = 1;
} else {
return system.getResultFail(-107, "需求当前状态错误--" + ab.intentionStatus);
}
solutionContent.needStatusName = intentionStatusList[ab.intentionStatus];
solutionContent = JSON.stringify(solutionContent);
updateObj["solutionContent"] = solutionContent;
await this.needsolutionDao.update(updateObj);//方案状态修改
return system.getResultSuccess();
}
//接收方案编号(方案推送至阿里后,接收保存方案信息)
async receiveProgrammeNo(pobj) {
var ab = pobj.actionBody;
if (!ab.solutionBizId) {
return system.getResultFail(-101, "渠道方案业务编号不能为空");
}
if (!ab.solutionNo) {
return system.getResultFail(-102, "方案业务编号不能为空");
}
var ns = await this.needsolutionDao.model.findOne({
where: { solutionNo: ab.solutionNo, isInvalid: 0 }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-103, "未知方案");
}
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: ns.needNo }, raw: true
});
if (!needinfo) {
return system.getResultFail(-104, "未知方案需求");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
await this.needsolutionDao.model.update({ channelSolutionNo: ab.solutionBizId }, { where: { id: ns.id } });//修改方案信息
return system.getResultSuccess();
}
//接收确认方案后阿里返回链接 //接收渠道方案状态变更通知
async receiveIcpConfirmUrl(pobj) { async receiveIcpStatusNotify(pobj) {
var ab = pobj.actionBody; var ab = pobj.actionBody;
if (!ab.confirmUrl) { if (!ab.BizId) {
return system.getResultFail(-101, "confirmUrl不能为空"); return system.getResultFail(-101, "渠道方案号不能为空");
} }
if (!ab.solutionNo) { if (!ab.status) {
return system.getResultFail(-102, "方案业务编号不能为空"); return system.getResultFail(-102, "方案状态不能为空");
} }
var ns = await this.needsolutionDao.model.findOne({ //获取方案信息
where: { solutionNo: ab.solutionNo, isInvalid: 0 }, raw: true var ns = await this.needsolutionDao.model.findOne({
}); where: { channelSolutionNo: ab.BizId, isInvalid: 0 }, raw: true
if (!ns || !ns.id) { });
return system.getResultFail(-103, "未知方案"); if (!ns || !ns.id) {
} return system.getResultFail(-102, "未知方案");
var needinfo = await this.needinfoDao.model.findOne({ }
where: { needNo: ns.needNo }, raw: true var needinfo = await this.needinfoDao.model.findOne({
}); where: { needNo: ns.needNo }, raw: true
if (!needinfo) { });
return system.getResultFail(-104, "未知方案需求"); if (!needinfo) {
} return system.getResultFail(-104, "未知方案需求");
if (needinfo.status == "ycd" || needinfo.status == "ygb") { }
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作"); if (needinfo.status == "ygb") {
} return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
ns.solutionContent.confirmUrl = ab.confirmUrl; }
var solutionContent = JSON.stringify(ns.solutionContent); // if (ns.status == "yzf" || ns.status == "ywc") {
await this.needsolutionDao.model.update({ solutionContent: solutionContent }, { where: { id: ns.id } });//修改方案信息 // return system.getResultFail(-103, "该方案状态为" + ns.statusName + ",不能执行此操作");
return system.getResultSuccess(); // }
} var solutionContent = ns.solutionContent;
var checkStatus = {
ACCOUNT_REGISTERED: "完成账户注册", MATERIAL_SUBMITTED: "完成资料递交",
GXB_ACCEPT: "⼯信部已受理", GXB_REFUSE: "⼯信部不予受理", GXB_FAIL: "⼯信部未通过", GXB_SUCCESS: "工信部通过"
, CLOSE: "方案关闭"
};
if (solutionContent.status && checkStatus[solutionContent.status]) {
return system.getResultFail(-111, "方案已进入" + solutionContent.statusName + "流程,不能执行此操作");
}
//方案流程列表
var solutionFlowList = solutionContent.solutionFlowList || [];
if (ab.status == "1") {//⽤户已支付
var afterStatusList = [//用户支付后的流程状态
"USER_UPLOADED", "MATERIAL_UNCONFIRM", "USER_CONFIRMED", "ACCOUNT_REGISTERED",
"MATERIAL_SUBMITTED", "GXB_ACCEPT", "GXB_REFUSE", "GXB_FAIL", "GXB_SUCCESS", "CLOSE"
];
if (!solutionContent.status || afterStatusList.indexOf(solutionContent.status) < 0) {
solutionFlowList.push({
status: "PAID", statusName: this.icpSolutionStatusReference.PAID, updated_at: new Date()
});
solutionContent.status = "PAID";
solutionContent.statusName = this.icpSolutionStatusReference.PAID;
}
// 2020 0826 lin修改 n_need_info status为ycd 已成单
let needObj = {
id: needinfo.id, status: "ycd"
}
await this.needinfoDao.update(needObj);//关闭需求
} else if (ab.status == "2") {//⽤户已上传
if (solutionContent.status == "USER_CONFIRMED") {//防止用户确认后又否决
return system.getResultFail(-112, "操作失败,⽤户已确认递交⽂件");
}
solutionFlowList.push({
status: "USER_UPLOADED", statusName: this.icpSolutionStatusReference.USER_UPLOADED, updated_at: new Date()
});
solutionContent.status = "USER_UPLOADED";
solutionContent.statusName = this.icpSolutionStatusReference.USER_UPLOADED;
} else if (ab.status == "4") {//⽤户已确认
if (solutionContent.status != "MATERIAL_UNCONFIRM") {
return system.getResultFail(-113, "操作失败,服务商递交⽂件后才能执行此操作");
}
solutionFlowList.push({
status: "USER_CONFIRMED", statusName: this.icpSolutionStatusReference.USER_CONFIRMED, updated_at: new Date()
});
solutionContent.status = "USER_CONFIRMED";
solutionContent.statusName = this.icpSolutionStatusReference.USER_CONFIRMED;
} else if (ab.status == "11") {//⽅案已关闭
solutionFlowList.push({
status: "CLOSE", statusName: this.icpSolutionStatusReference.CLOSE, updated_at: new Date()
});
solutionContent.status = "CLOSE";
solutionContent.statusName = this.icpSolutionStatusReference.CLOSE;
} else {
return system.getResultFail(-110, "状态错误");
}
solutionContent.solutionFlowList = solutionFlowList;
/* var material = solutionContent.customerMaterial || {};
返回20位业务订单号 if (ab.remark) {
prefix:业务前缀 solutionContent.customerRemark = ab.remark;
*/ }
async getBusUid(prefix) { if (ab.newbusinessLicense) {
prefix = (prefix || ""); material.businessLicense = ab.newbusinessLicense;
if (prefix) { material.aliBusinessLicense = ab.businessLicense;
prefix = prefix.toUpperCase(); }
} if (ab.newidCardUrlList && ab.newidCardUrlList.length > 0) {
var prefixlength = prefix.length; material.idCardUrlList = ab.newidCardUrlList;
var subLen = 8 - prefixlength; material.aliIdCardUrlList = ab.idCardUrlList;
var uidStr = ""; }
if (subLen > 0) { if (ab.newuserPlan) {
uidStr = await this.getUidInfo(subLen, 60); material.userPlan = ab.newuserPlan;
} material.aliUserPlan = ab.userPlan;
var timStr = moment().format("YYYYMMDDHHmm"); }
return prefix + timStr + uidStr; if (ab.newuserForeig) {
} material.userForeig = ab.newuserForeig;
/* material.aliUserForeig = ab.userForeig;
len:返回长度 }
radix:参与计算的长度,最大为62 if (ab.newuserLaw) {
*/ material.userLaw = ab.newuserLaw;
async getUidInfo(len, radix) { material.aliUserLaw = ab.userLaw;
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');//长度62,到yz长度为长36 }
var uuid = [], i; if (ab.newuserOtherList && ab.newuserOtherList.length > 0) {
radix = radix || chars.length; material.userOtherList = ab.newuserOtherList;
if (len) { material.aliUserOtherList = ab.userOtherList;
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix]; }
} else { solutionContent.customerMaterial = material;
var r; solutionContent = JSON.stringify(solutionContent);
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-'; var updateObj = {
uuid[14] = '4'; id: ns.id, solutionContent: solutionContent
for (i = 0; i < 36; i++) { };
if (!uuid[i]) { if (ab.status == "11") {//⽅案已关闭
r = 0 | Math.random() * 16; updateObj["status"] = "yzf";
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r]; updateObj["isInvalid"] = 1;
} }
} await this.needsolutionDao.update(updateObj);//方案状态修改
} var new_ns = await this.needsolutionDao.model.findOne({
return uuid.join(''); where: { id: ns.id }, raw: true
} });
return system.getResultSuccess(ns);
}
//接收icp用户方案反馈
async receiveIcpFeedback(pobj) {
var ab = pobj.actionBody;
if (!ab.intentionBizId) {
return system.getResultFail(-101, "渠道需求编号错误");
}
if (!ab.description) {
return system.getResultFail(-102, "问题描述不能为空");
}
if (!ab.hasOwnProperty("intentionStatus")) {
return system.getResultFail(-103, "需求当前状态不能为空");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { channelNeedNo: ab.intentionBizId }, raw: true
});
if (!needinfo) {
return system.getResultFail(-104, "未知方案需求");
}
// if (needinfo.status == "ycd" || needinfo.status == "ygb") {
if (needinfo.status == "ygb") {
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where: { channelNeedNo: ab.intentionBizId, isInvalid: 0 }, raw: true
});
if (!ns) {
return system.getResultFail(-106, "未知方案");
}
var intentionStatusList = ["未知", "⽅案待服务商确认", "⽅案待⽤户确认", "处理中", "已完成", "已关闭"];
var updateObj = {
id: ns.id
};
var solutionContent = ns.solutionContent;
solutionContent.customerRemark = ab.description;
solutionContent.needStatus = ab.intentionStatus;
if (ab.intentionStatus == 1) {
updateObj["status"] = "ybh";
updateObj["isInvalid"] = 1;
} else if (ab.intentionStatus == 2) {
updateObj["status"] = "dqr";
} else if (ab.intentionStatus == 3) {
updateObj["status"] = "dqr";
} else if (ab.intentionStatus == 4) {
updateObj["status"] = "dqr";
} else if (ab.intentionStatus == 5) {
updateObj["status"] = "yzf";
updateObj["isInvalid"] = 1;
} else {
return system.getResultFail(-107, "需求当前状态错误--" + ab.intentionStatus);
}
solutionContent.needStatusName = intentionStatusList[ab.intentionStatus];
solutionContent = JSON.stringify(solutionContent);
updateObj["solutionContent"] = solutionContent;
await this.needsolutionDao.update(updateObj);//方案状态修改
return system.getResultSuccess();
}
//接收方案编号(方案推送至阿里后,接收保存方案信息)
async receiveProgrammeNo(pobj) {
var ab = pobj.actionBody;
if (!ab.solutionBizId) {
return system.getResultFail(-101, "渠道方案业务编号不能为空");
}
if (!ab.solutionNo) {
return system.getResultFail(-102, "方案业务编号不能为空");
}
var ns = await this.needsolutionDao.model.findOne({
where: { solutionNo: ab.solutionNo, isInvalid: 0 }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-103, "未知方案");
}
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: ns.needNo }, raw: true
});
if (!needinfo) {
return system.getResultFail(-104, "未知方案需求");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
await this.needsolutionDao.model.update({ channelSolutionNo: ab.solutionBizId }, { where: { id: ns.id } });//修改方案信息
return system.getResultSuccess();
}
//接收渠道方案状态变更通知 //接收确认方案后阿里返回链接
async receiveEdiStatusNotify(pobj) { async receiveIcpConfirmUrl(pobj) {
var ab = pobj.actionBody; var ab = pobj.actionBody;
if (!ab.BizId) { if (!ab.confirmUrl) {
return system.getResultFail(-101, "渠道方案号不能为空"); return system.getResultFail(-101, "confirmUrl不能为空");
} }
if (!ab.operationType) { if (!ab.solutionNo) {
return system.getResultFail(-102, "方案状态不能为空"); return system.getResultFail(-102, "方案业务编号不能为空");
} }
//获取方案信息 var ns = await this.needsolutionDao.model.findOne({
var ns = await this.needsolutionDao.model.findOne({ where: { solutionNo: ab.solutionNo, isInvalid: 0 }, raw: true
// 2020 0929 lin 修改ab.BizId 改为 ab.solutionBizId });
where: { channelSolutionNo: ab.solutionBizId, isInvalid: 0 }, raw: true if (!ns || !ns.id) {
}); return system.getResultFail(-103, "未知方案");
if (!ns || !ns.id) { }
return system.getResultFail(-102, "未知方案"); var needinfo = await this.needinfoDao.model.findOne({
} where: { needNo: ns.needNo }, raw: true
var needinfo = await this.needinfoDao.model.findOne({ });
where: { needNo: ns.needNo }, raw: true if (!needinfo) {
}); return system.getResultFail(-104, "未知方案需求");
if (!needinfo) { }
return system.getResultFail(-104, "未知方案需求"); if (needinfo.status == "ycd" || needinfo.status == "ygb") {
} return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
if (needinfo.status == "ygb") { }
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作"); ns.solutionContent.confirmUrl = ab.confirmUrl;
} var solutionContent = JSON.stringify(ns.solutionContent);
var solutionContent = ns.solutionContent; await this.needsolutionDao.model.update({ solutionContent: solutionContent }, { where: { id: ns.id } });//修改方案信息
var checkStatus = { ABC_CLOSE_PRODUCE: "⼩⼆后台关闭服务单" }; return system.getResultSuccess();
if (solutionContent.status && checkStatus[solutionContent.status]) { }
return system.getResultFail(-111, "方案已进入" + solutionContent.statusName + "流程,不能执行此操作");
}
//方案流程列表
var solutionFlowList = solutionContent.solutionFlowList || [];
if (ab.operationType == "USER_PAY_PRODUCE") {//⽤户已支付
solutionFlowList.push({
status: "USER_PAY_PRODUCE", statusName: this.ediSolutionStatusReference.USER_PAY_PRODUCE, updated_at: new Date()
});
solutionContent.status = "USER_PAY_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.USER_PAY_PRODUCE;
// 2020 0826 lin修改 n_need_info status为ycd 已成单
let needObj = {
id: needinfo.id, status: "ycd"
}
await this.needinfoDao.update(needObj);//关闭需求
} else if (ab.operationType == "USER_CONFIRM_PRODUCE") {//⽤户确认资料
solutionFlowList.push({
status: "USER_CONFIRM_PRODUCE", statusName: this.ediSolutionStatusReference.USER_CONFIRM_PRODUCE, updated_at: new Date()
});
solutionContent.status = "USER_CONFIRM_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.USER_CONFIRM_PRODUCE;
} else if (ab.operationType == "USER_REFUSE_PRODUCE") {//资料退回修改
solutionFlowList.push({
status: "USER_REFUSE_PRODUCE", statusName: this.ediSolutionStatusReference.USER_REFUSE_PRODUCE, updated_at: new Date()
});
solutionContent.status = "USER_REFUSE_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.USER_REFUSE_PRODUCE;
} else if (ab.operationType == "USER_UPLOAD_PRODUCE") {//⽤户补充基本资料
solutionFlowList.push({
status: "USER_UPLOAD_PRODUCE", statusName: this.ediSolutionStatusReference.USER_UPLOAD_PRODUCE, updated_at: new Date()
});
solutionContent.status = "USER_UPLOAD_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.USER_UPLOAD_PRODUCE;
} else if (ab.operationType == "ABC_CLOSE_PRODUCE") {//⽅案已关闭
solutionFlowList.push({
status: "ABC_CLOSE_PRODUCE", statusName: this.ediSolutionStatusReference.ABC_CLOSE_PRODUCE, updated_at: new Date()
});
solutionContent.status = "ABC_CLOSE_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.ABC_CLOSE_PRODUCE;
} else {
return system.getResultFail(-110, "状态错误");
}
solutionContent.solutionFlowList = solutionFlowList;
var material = solutionContent.customerMaterial || {}; /*
if (ab.extInfo) { 返回20位业务订单号
// 退回修改理由 prefix:业务前缀
var extInfoJson = JSON.parse(ab.extInfo); */
// var extInfoJson = ab.extInfo async getBusUid(prefix) {
if(extInfoJson.rejectReason) { prefix = (prefix || "");
ab.rejectReason = extInfoJson.rejectReason, if (prefix) {
solutionContent.rejectReason = extInfoJson.rejectReason prefix = prefix.toUpperCase();
} }
material.businessLicenseArr = extInfoJson.businessLicenseArr; var prefixlength = prefix.length;
material.idCardListArr = extInfoJson.idCardListArr; var subLen = 8 - prefixlength;
} var uidStr = "";
solutionContent.customerMaterial = material; if (subLen > 0) {
solutionContent = JSON.stringify(solutionContent); uidStr = await this.getUidInfo(subLen, 60);
}
var timStr = moment().format("YYYYMMDDHHmm");
return prefix + timStr + uidStr;
}
/*
len:返回长度
radix:参与计算的长度,最大为62
*/
async getUidInfo(len, radix) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');//长度62,到yz长度为长36
var uuid = [], i;
radix = radix || chars.length;
if (len) {
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else {
var r;
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
uuid[14] = '4';
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
r = 0 | Math.random() * 16;
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
}
}
}
return uuid.join('');
}
var updateObj = { //接收渠道方案状态变更通知
id: ns.id, async receiveEdiStatusNotify(pobj) {
solutionContent: solutionContent, var ab = pobj.actionBody;
}; if (!ab.BizId) {
// 这里修改进去了 return system.getResultFail(-101, "渠道方案号不能为空");
if(ab.bizId != ns.channelDeliverId) { }
updateObj.channelDeliverId = ab.bizId if (!ab.operationType) {
} return system.getResultFail(-102, "方案状态不能为空");
if (ab.operationType == "ABC_CLOSE_PRODUCE") {//⽅案已关闭 }
updateObj["status"] = "yzf"; //获取方案信息
updateObj["isInvalid"] = 1; var ns = await this.needsolutionDao.model.findOne({
} // 2020 0929 lin 修改ab.BizId 改为 ab.solutionBizId
await this.needsolutionDao.update(updateObj);//方案状态修改 where: { channelSolutionNo: ab.solutionBizId, isInvalid: 0 }, raw: true
var new_ns = await this.needsolutionDao.model.findOne({ });
where: { id: ns.id }, raw: true if (!ns || !ns.id) {
}); return system.getResultFail(-102, "未知方案");
var orderInfo = await this.orderinfoDao.model.findOne({ }
where: {orderNo: new_ns.orderNo}, raw: true var needinfo = await this.needinfoDao.model.findOne({
}) where: { needNo: ns.needNo }, raw: true
if(orderInfo) { });
new_ns.channelOrderNo = orderInfo.channelOrderNo if (!needinfo) {
} return system.getResultFail(-104, "未知方案需求");
return system.getResultSuccess(new_ns); }
} if (needinfo.status == "ygb") {
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
var solutionContent = ns.solutionContent;
var checkStatus = { ABC_CLOSE_PRODUCE: "⼩⼆后台关闭服务单" };
if (solutionContent.status && checkStatus[solutionContent.status]) {
return system.getResultFail(-111, "方案已进入" + solutionContent.statusName + "流程,不能执行此操作");
}
//方案流程列表
var solutionFlowList = solutionContent.solutionFlowList || [];
if (ab.operationType == "USER_PAY_PRODUCE") {//⽤户已支付
solutionFlowList.push({
status: "USER_PAY_PRODUCE", statusName: this.ediSolutionStatusReference.USER_PAY_PRODUCE, updated_at: new Date()
});
solutionContent.status = "USER_PAY_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.USER_PAY_PRODUCE;
// 2020 0826 lin修改 n_need_info status为ycd 已成单
let needObj = {
id: needinfo.id, status: "ycd"
}
await this.needinfoDao.update(needObj);//关闭需求
} else if (ab.operationType == "USER_CONFIRM_PRODUCE") {//⽤户确认资料
solutionFlowList.push({
status: "USER_CONFIRM_PRODUCE", statusName: this.ediSolutionStatusReference.USER_CONFIRM_PRODUCE, updated_at: new Date()
});
solutionContent.status = "USER_CONFIRM_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.USER_CONFIRM_PRODUCE;
} else if (ab.operationType == "USER_REFUSE_PRODUCE") {//资料退回修改
solutionFlowList.push({
status: "USER_REFUSE_PRODUCE", statusName: this.ediSolutionStatusReference.USER_REFUSE_PRODUCE, updated_at: new Date()
});
solutionContent.status = "USER_REFUSE_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.USER_REFUSE_PRODUCE;
} else if (ab.operationType == "USER_UPLOAD_PRODUCE") {//⽤户补充基本资料
solutionFlowList.push({
status: "USER_UPLOAD_PRODUCE", statusName: this.ediSolutionStatusReference.USER_UPLOAD_PRODUCE, updated_at: new Date()
});
solutionContent.status = "USER_UPLOAD_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.USER_UPLOAD_PRODUCE;
} else if (ab.operationType == "ABC_CLOSE_PRODUCE") {//⽅案已关闭
solutionFlowList.push({
status: "ABC_CLOSE_PRODUCE", statusName: this.ediSolutionStatusReference.ABC_CLOSE_PRODUCE, updated_at: new Date()
});
solutionContent.status = "ABC_CLOSE_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.ABC_CLOSE_PRODUCE;
} else {
return system.getResultFail(-110, "状态错误");
}
solutionContent.solutionFlowList = solutionFlowList;
var material = solutionContent.customerMaterial || {};
if (ab.extInfo) {
// 退回修改理由
var extInfoJson = JSON.parse(ab.extInfo);
// var extInfoJson = ab.extInfo
if (extInfoJson.rejectReason) {
ab.rejectReason = extInfoJson.rejectReason,
solutionContent.rejectReason = extInfoJson.rejectReason
}
material.businessLicenseArr = extInfoJson.businessLicenseArr;
material.idCardListArr = extInfoJson.idCardListArr;
}
solutionContent.customerMaterial = material;
solutionContent = JSON.stringify(solutionContent);
var updateObj = {
id: ns.id,
solutionContent: solutionContent,
};
// 这里修改进去了
if (ab.bizId != ns.channelDeliverId) {
updateObj.channelDeliverId = ab.bizId
}
if (ab.operationType == "ABC_CLOSE_PRODUCE") {//⽅案已关闭
updateObj["status"] = "yzf";
updateObj["isInvalid"] = 1;
}
await this.needsolutionDao.update(updateObj);//方案状态修改
var new_ns = await this.needsolutionDao.model.findOne({
where: { id: ns.id }, raw: true
});
var orderInfo = await this.orderinfoDao.model.findOne({
where: { orderNo: new_ns.orderNo }, raw: true
})
if (orderInfo) {
new_ns.channelOrderNo = orderInfo.channelOrderNo
}
return system.getResultSuccess(new_ns);
}
} }
module.exports = BaseQcService; module.exports = BaseQcService;
...@@ -21,7 +21,6 @@ class RegCenterOrderService{ ...@@ -21,7 +21,6 @@ class RegCenterOrderService{
}; };
//工商注册状态 //工商注册状态
this.regStatus = { this.regStatus = {
'RECEIVED': 701, //已接单 'RECEIVED': 701, //已接单
'COLLECTING': 702, //材料收集环节 'COLLECTING': 702, //材料收集环节
...@@ -657,7 +656,7 @@ class RegCenterOrderService{ ...@@ -657,7 +656,7 @@ class RegCenterOrderService{
if (needinfo.status == "ycd" || needinfo.status == "ygb") { if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能创建方案"); return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能创建方案");
} }
var bizType = needinfo.typeCode;//ab.solutionContent.bizType;//业务类型 var bizType = needinfo.typeCode;//业务类型
if (!bizType) { if (!bizType) {
return system.getResultFail(-205, "方案类型错误"); return system.getResultFail(-205, "方案类型错误");
} }
...@@ -701,7 +700,6 @@ class RegCenterOrderService{ ...@@ -701,7 +700,6 @@ class RegCenterOrderService{
ab.solutionList[j].channelSolutionNo = ""; ab.solutionList[j].channelSolutionNo = "";
} }
} }
// var solution = ab.solutionList[j].solutionContent.solution;
var solutionFlowList = ab.solutionList[j].solutionContent.solutionFlowList || []; var solutionFlowList = ab.solutionList[j].solutionContent.solutionFlowList || [];
solutionFlowList.push({ solutionFlowList.push({
...@@ -711,7 +709,6 @@ class RegCenterOrderService{ ...@@ -711,7 +709,6 @@ class RegCenterOrderService{
ab.solutionList[j].solutionContent.statusName = this.regSolutionStatus.RECEIVED; ab.solutionList[j].solutionContent.statusName = this.regSolutionStatus.RECEIVED;
ab.solutionList[j].solutionContent.solutionFlowList = solutionFlowList; ab.solutionList[j].solutionContent.solutionFlowList = solutionFlowList;
ab.solutionList[j]["channelNeedNo"] = needinfo.channelNeedNo; ab.solutionList[j]["channelNeedNo"] = needinfo.channelNeedNo;
// var solutionNo = await this.getBusUid("ns");//chuangjian
var solutionNo = [];//chuangjian var solutionNo = [];//chuangjian
solutionNo[j] = await this.getBusUid("ns") solutionNo[j] = await this.getBusUid("ns")
console.log('solutionNo[j]----', solutionNo[j]) console.log('solutionNo[j]----', solutionNo[j])
...@@ -761,13 +758,9 @@ class RegCenterOrderService{ ...@@ -761,13 +758,9 @@ class RegCenterOrderService{
needinfo = await self.needinfoDao.model.findOne({ needinfo = await self.needinfoDao.model.findOne({
where: { id: needinfo.id }, raw: true where: { id: needinfo.id }, raw: true
}); });
// return system.getResultSuccess({ needinfo: needinfo, needsolution: od });
needsolutions.push(od.dataValues) needsolutions.push(od.dataValues)
console.log('needsolutions-------', needsolutions) console.log('needsolutions-------', needsolutions)
} }
// else {
// return system.getResultFail(-302, "提交方案失败");
// }
}) })
} }
} }
......
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