Commit 03695764 by 兰国旗

laolan

parent c21fe127
......@@ -62,6 +62,10 @@ class RegAPI extends APIBase {
case "regSubmitSolution"://方案提交
opResult = await this.regCenterOrderSve.regSubmitSolution(pobj);
break;
case "updateSolution"://方案更新
opResult = await this.regCenterOrderSve.updateSolution(pobj);
break;
case "regWriteCommunicationLog"://新增沟通记录
opResult = await this.regCenterOrderSve.regWriteCommunicationLog(pobj);
break;
......
//工商注册
const system = require("../../../system");
const moment = require('moment');
const { where } = require("sequelize");
class RegCenterOrderService{
constructor() {
this.needsolutionDao = system.getObject("db.dbneed.needsolutionDao");
......@@ -608,21 +607,26 @@ class RegCenterOrderService{
//查询对应类型方案是否有提交,提交过的不能重复提交
var ns = await this.needsolutionDao.model.findAndCountAll({
where: { channelNeedNo: ab.needNo ,isInvalid: 0 }, raw: true, order: [["id", 'asc']]
where: { channelNeedNo: ab.needNo }, raw: true, order: [["id", 'asc']]
});
console.log('ns----', ns)
var nsRegType = [];
if (ns) {
var nsLength = ns.rows.length;
for (l = 0; l < nsLength; l++) {
nsRegType.push(ns[l].solutionContent.solution.regType)
if(ns.rows[l].isInvalid == 0){
nsRegType.push(ns.rows[l].solutionContent.solution.regType)
}
if(ns.rows[l].isInvalid == 1 && !ns.rows[l].solutionContent.solution.channelSolutionNo && ns.rows[l].status == "ybh"){
return system.getResultFail(-207, "该方案中包含已驳回方案,不能新建方案,只能修改方案");
}
}
var diff;
diff = nsRegType.find(item => solutionType.includes(item))
console.log('diff---', diff)
if (diff != undefined) {
return system.getResultFail(-207, "该方案中包含已提交过的方案,不能重复提交");
return system.getResultFail(-208, "该方案中包含已提交过的方案,不能重复提交");
}
}
for (j = 0; j < solutionListLength; j++) {
......@@ -631,7 +635,7 @@ class RegCenterOrderService{
ab.solutionList[j].solutionContent.typeCode = needinfo.typeCode;
ab.solutionList[j].solutionContent.typeName = needinfo.typeName;
for (k = 0; k < ns.rows.length; k++) {
var fa = ns[k];
var fa = ns.rows[k];
// if (fa.status == "dqr" || fa.status == "ywc") {
// return system.getResultFail(-207, "需求方案已存在,不能重复提交");
// }
......@@ -708,6 +712,91 @@ class RegCenterOrderService{
}
return system.getResultSuccess({ needinfo: needinfo, needsolutions: needsolutions });
}
//方案更新
async updateSolution(pobj){
console.log("pobj++updateSolution++",pobj)
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
ab["createUserId"] = user.id;
if (!ab.needNo) {
return system.getResultFail(-101, "渠道需求号不能为空");
}
var needsolutions = [];//最后返回结果用
console.log('ab.solutionList------', ab.solutionList)
if (!ab.solutionList[0].solutionContent) {
return system.getResultFail(-102, "方案信息有误");
}
if (!ab.solutionList[0].solutionContent.solution.channelSolutionNo) {
return system.getResultFail(-103, "渠道方案号不能为空");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { channelNeedNo: ab.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-104, "未知需求信息");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-105, "修改方案,该方案需求状态为" + needinfo.statusName + ",不能创建方案");
}
var bizType = needinfo.typeCode;//业务类型
if (!bizType) {
return system.getResultFail(-106, "修改方案,方案类型错误");
}
if (!needinfo.channelTypeCode) {
return system.getResultFail(-107, "修改方案,渠道方案类型错误");
}
//查询对应类型方案是否有驳回,驳回后直接更新
var bhns = await this.needsolutionDao.model.findOne({
where: { channelSolutionNo: ab.solutionList[0].solutionContent.solution.channelSolutionNo ,isInvalid : 1 ,status : "ybh"}, raw: true, order: [["id", 'asc']]
});
console.log('bhns----', bhns)
if (!bhns) {
return system.getResultFail(-108, "修改方案,不存在的驳回方案");
}else{
var self = this
ab.solutionList[0].solutionContent = JSON.stringify(ab.solutionList[0].solutionContent);
await this.needsolutionDao.db.transaction(async function (t) {
ab.solutionList[0]["status"] = "dqr";
ab.solutionList[0]["statusName"] = "待确认";
ab.solutionList[0]["isInvalid"] = 0;
var jsonDatas = ab.solutionList[0].solutionContent
var jsonData = JSON.parse(jsonDatas)
var od = await self.needsolutionDao.updateByWhere(ab.solutionList[0],{where:{channelSolutionNo : jsonData.solution.channelSolutionNo}}, t);
console.log("od-----",od)
if (od && od.length >0) {
var needObj = {
id: needinfo.id,
followManUserId: user.id,//跟进人id
followManName: user.channel_username,//跟进人姓名
followManMobile: user.mobile,//跟进人手机号(合伙人)
followManOnlyCode: user.channel_userid
};
var followContent = [{
followDate: new Date(),
content: "驳回后更新方案"
}];
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
});
needsolutions.push(bhns)
console.log('needsolutions-------', needsolutions)
}
})
}
return system.getResultSuccess({ needinfo: needinfo, needsolutions: needsolutions });
}
//方案推送baidu后,接收保存方案编号/链接
async saveReginfo(pobj) {
console.log('----pobj--',pobj)
......@@ -952,11 +1041,11 @@ class RegCenterOrderService{
if(orderdeliveryInfo[0] && orderdeliveryInfo[0].deliveryContent){
deliveryContent = orderdeliveryInfo[0].deliveryContent;
if(deliveryContent && deliveryContent.status && deliveryContent.ApplicationStatus && deliveryContent.solutionFlowList){
if (this.regStatus[deliveryContent.status] && this.regStatus[deliveryContent.status] > ab.ApplicationStatus) {
return system.getResultFail(-403, "操作失败,交付流程未按顺序执行");
}
if (this.regStatus[deliveryContent.ApplicationStatus] && this.regStatus[deliveryContent.ApplicationStatus] == ab.ApplicationStatus) {
return system.getResultFail(-405, "操作失败,该流程状态已提交,不能重复提交");
// if (this.regStatus[deliveryContent.status] && this.regStatus[deliveryContent.status] > ab.ApplicationStatus) {
// return system.getResultFail(-403, "操作失败,交付流程未按顺序执行");
// }
if (this.regStatus[deliveryContent.ApplicationStatus] && this.regStatus[deliveryContent.ApplicationStatus] == ab.ApplicationStatus && ab.ApplicationStatus == 705) {
return system.getResultFail(-405, "操作失败,该方案已完成,不能更改");
}
solutionFlowList = deliveryContent.solutionFlowList || [];
}
......@@ -999,9 +1088,17 @@ class RegCenterOrderService{
deliveryContent.status = "COLLECTING";
deliveryContent.statusName = this.regSolutionStatus.COLLECTING;
}
if (ab.ApplicationStatus == 703) {//工商审核环节
if (deliveryContent.status != "COLLECTING") {
return system.getResultFail(-703, "交付流程错误,材料收集");
var afterStatusList = [//用户支付后的流程状态
"COLLECTING", "AUDITING", "ENGRAVING" ,"SUCCESS"
];
if (!deliveryContent.status || afterStatusList.indexOf(deliveryContent.status) < 0){
return system.getResultFail(-703, "交付流程错误,请先完成材料收集");
}
if (deliveryContent.status == "SUCCESS") {
return system.getResultFail(-706, "该方案已完成,不可更改");
}
deliveryContent['ApplicationStatus'] = 703;
solutionFlowList.push({
......@@ -1015,9 +1112,15 @@ class RegCenterOrderService{
deliveryContent['deliveryContent'] = deliveryContents
}
if (ab.ApplicationStatus == 704) {//刻章环节
if (deliveryContent.status != "AUDITING") {
var afterStatusList = [//用户支付后的流程状态
"COLLECTING", "AUDITING", "ENGRAVING" ,"SUCCESS"
];
if (!deliveryContent.status || afterStatusList.indexOf(deliveryContent.status) < 0){
return system.getResultFail(-704, "交付流程错误,请先工商审核");
}
if (deliveryContent.status == "SUCCESS") {
return system.getResultFail(-706, "该方案已完成,不可更改");
}
deliveryContent['ApplicationStatus'] = 704;
solutionFlowList.push({
file: ab.OfficialFileURL || "",
......@@ -1030,6 +1133,9 @@ class RegCenterOrderService{
if (deliveryContent.status != "ENGRAVING") {
return system.getResultFail(-705, "交付流程错误,请先刻章");
}
if (deliveryContent.status == "SUCCESS") {
return system.getResultFail(-706, "该方案已完成,不可更改");
}
deliveryContent['ApplicationStatus'] = 705;
solutionFlowList.push({
file: ab.OfficialFileURL || "",
......
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