Commit 8ccd9019 by 兰国旗

laolan

parent fe5719ca
//工商注册 //工商注册
var APIBase = require("../../api.base"); var APIBase = require("../../api.base");
var system = require("../../../system"); var system = require("../../../system");
class BaiduReg extends APIBase { class RegAPI extends APIBase {
constructor() { constructor() {
super(); super();
this.regCenterOrder = system.getObject("service.qcutils.regCenterOrder"); this.regCenterOrderSve = system.getObject("service.qcutils.regCenterOrderSve");
} }
/** /**
* 接口跳转-POST请求 * 接口跳转-POST请求
...@@ -32,34 +32,35 @@ class BaiduReg extends APIBase { ...@@ -32,34 +32,35 @@ class BaiduReg extends APIBase {
var opResult = null; var opResult = null;
switch (action_type) { switch (action_type) {
case "receiveSolutionPayInfoNew"://接收reg方案状态及支付信息(方案支付后创建订单时调用) case "receiveSolutionPayInfoNew"://接收reg方案状态及支付信息(方案支付后创建订单时调用)
opResult = await this.regCenterOrder.receiveSolutionPayInfoNew(pobj); opResult = await this.regCenterOrderSve.receiveSolutionPayInfoNew(pobj);
break; break;
case "getItemByChannelSolutionNo"://渠道方案号获取需求详情 case "getItemByChannelSolutionNo"://渠道方案号获取需求详情
opResult = await this.regCenterOrder.getItemByChannelSolutionNo(pobj, pobj.actionBody, req); opResult = await this.regCenterOrderSve.getItemByChannelSolutionNo(pobj, pobj.actionBody, req);
break; break;
case "getRegOrderStatus"://接收订单状态推送 百度reg 2.3 case "getRegOrderStatus"://接收订单状态推送 百度reg 2.3
opResult = await this.regCenterOrder.getRegOrderStatus(pobj); opResult = await this.regCenterOrderSve.getRegOrderStatus(pobj);
break; break;
case "addRegSalesmanInfo"://添加业务员信息,用于直接下单的reg订单 case "addRegSalesmanInfo"://添加业务员信息,用于直接下单的reg订单
opResult = await this.regCenterOrder.addRegSalesmanInfo(pobj); opResult = await this.regCenterOrderSve.addRegSalesmanInfo(pobj);
break; break;
case "submitRegNeed"://提交需求 case "submitRegNeed"://提交需求
opResult = await this.regCenterOrder.submitRegNeed(pobj, pobj.actionBody, req); opResult = await this.regCenterOrderSve.submitRegNeed(pobj, pobj.actionBody, req);
break; break;
case "submitBdRegSolution"://方案提交
opResult = await this.regCenterOrder.submitBdRegSolution(pobj); case "submitRegSolution"://方案提交
opResult = await this.regCenterOrderSve.submitRegSolution(pobj);
break; break;
case "writeRegCommunicationLog"://新增沟通记录 case "writeRegCommunicationLog"://新增沟通记录
opResult = await this.regCenterOrder.writeRegCommunicationLog(pobj); opResult = await this.regCenterOrderSve.writeRegCommunicationLog(pobj);
break; break;
case "queryExpertRegCommunicationLogs"://获取沟通记录 case "queryExpertRegCommunicationLogs"://获取沟通记录
opResult = await this.regCenterOrder.queryExpertRegCommunicationLogs(pobj); opResult = await this.regCenterOrderSve.queryExpertRegCommunicationLogs(pobj);
break; break;
case "updateOrdertatus"://提交交付信息/修改订单状态 case "updateRegOrdertatus"://提交交付信息/修改订单状态
opResult = await this.regCenterOrder.updateOrdertatus(pobj); opResult = await this.regCenterOrderSve.updateRegOrdertatus(pobj);
break; break;
case "closeBdRegNeed"://需求关闭 case "closeRegNeed"://需求关闭
opResult = await this.regCenterOrder.closeBdRegNeed(pobj); opResult = await this.regCenterOrderSve.closeRegNeed(pobj);
break; break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
...@@ -68,4 +69,4 @@ class BaiduReg extends APIBase { ...@@ -68,4 +69,4 @@ class BaiduReg extends APIBase {
return opResult; return opResult;
} }
} }
module.exports = BaiduReg; module.exports = RegAPI;
\ No newline at end of file \ No newline at end of file
...@@ -312,8 +312,8 @@ class regCenterOrderService { ...@@ -312,8 +312,8 @@ class regCenterOrderService {
} }
//提交方案 //提交方案
async submitBdRegSolution(pobj) { async submitRegSolution(pobj) {
console.log("pobj++submitBdRegSolution++",pobj) console.log("pobj++submitRegSolution++",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) {
...@@ -323,8 +323,14 @@ class regCenterOrderService { ...@@ -323,8 +323,14 @@ class regCenterOrderService {
if (!ab.needNo) { if (!ab.needNo) {
return system.getResultFail(-101, "渠道需求号不能为空"); return system.getResultFail(-101, "渠道需求号不能为空");
} }
if (!ab.solutionContent) { var i=0;
return system.getResultFail(-102, "方案信息有误"); if(ab.solutionList){
var solutionListLength = ab.solutionList.length;
}
for(i=0;i<solutionListLength;i++){
if (!ab.solutionList[i].solutionContent) {
return system.getResultFail(-102, "方案信息有误");
}
} }
//获取需求信息 //获取需求信息
var needinfo = await this.needinfoDao.model.findOne({ var needinfo = await this.needinfoDao.model.findOne({
...@@ -337,109 +343,109 @@ class regCenterOrderService { ...@@ -337,109 +343,109 @@ class regCenterOrderService {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能创建方案"); return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能创建方案");
} }
var bizType = needinfo.typeCode;//ab.solutionContent.bizType;//业务类型 var bizType = needinfo.typeCode;//ab.solutionContent.bizType;//业务类型
ab.solutionContent.bizType = bizType;
if (!bizType) { if (!bizType) {
return system.getResultFail(-205, "方案类型错误"); return system.getResultFail(-205, "方案类型错误");
} }
if (!needinfo.channelTypeCode) { if (!needinfo.channelTypeCode) {
return system.getResultFail(-206, "渠道方案类型错误"); return system.getResultFail(-206, "渠道方案类型错误");
} }
ab.solutionContent.typeCode = needinfo.typeCode; var needsolutions = [];//最后返回结果用
ab.solutionContent.typeName = needinfo.typeName; var j=0;
var ns = await this.needsolutionDao.model.findAll({ for(j=0;j<solutionListLength;j++){
where: { channelNeedNo: ab.needNo }, raw: true, order: [["id", 'asc']] if (ab.solutionList[j].solutionContent) {
}); ab.solutionList[j].solutionContent.bizType = bizType;
for (var i = 0; i < ns.length; i++) { ab.solutionList[j].solutionContent.typeCode = needinfo.typeCode;
var fa = ns[i]; ab.solutionList[j].solutionContent.typeName = needinfo.typeName;
if (fa.status == "dqr" || fa.status == "ywc") {
return system.getResultFail(-207, "需求方案已存在,不能重复提交"); var ns = await this.needsolutionDao.model.findAll({
} where: { channelNeedNo: ab.needNo }, raw: true, order: [["id", 'asc']]
if (fa.status == "ybh") { });
ab.channelSolutionNo = fa.channelSolutionNo; var k = 0;
} for (k = 0; k < ns.length; k++) {
if (fa.status == "yzf") { var fa = ns[k];
ab.channelSolutionNo = ""; // if (fa.status == "dqr" || fa.status == "ywc") {
} // return system.getResultFail(-207, "需求方案已存在,不能重复提交");
} // }
var solution = ab.solutionContent.solution; if (fa.status == "ybh") {
if (!solution) { ab.solutionList[j].channelSolutionNo = fa.channelSolutionNo;
return system.getResultFail(-103, "方案交付信息有误"); }
} if (fa.status == "yzf") {
if (!needinfo.channelTypeCode) { ab.solutionList[j].channelSolutionNo = "";
return system.getResultFail(-104, "需求业务类型有误"); }
}
if (!solution.CompanyName) {
return system.getResultFail(-105, "公司名不能为空");
}
if (!solution.LicenseType) {
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.regSolutionStatus.SOLUTION_SUBMIT, updated_at: new Date()
});
ab.solutionContent.status = "SOLUTION_SUBMIT";
ab.solutionContent.statusName = this.regSolutionStatus.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.solution.SolutionPrice = (ab.solutionContent.solution.SolutionPrice) / 100 || "";//分转元
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: "nc提交方案"
}];
followContent = JSON.stringify(followContent);
needObj["followContent"] = followContent;
} }
await self.needinfoDao.update(needObj, t); // var solution = ab.solutionList[j].solutionContent.solution;
needinfo = await self.needinfoDao.model.findOne({
where: { id: needinfo.id }, raw: true var solutionFlowList = ab.solutionList[j].solutionContent.solutionFlowList || [];
solutionFlowList.push({
status: "SOLUTION_SUBMIT", statusName: this.regSolutionStatus.SOLUTION_SUBMIT, updated_at: new Date()
}); });
return system.getResultSuccess({ needinfo: needinfo, needsolution: od }); ab.solutionList[j].solutionContent.status = "SOLUTION_SUBMIT";
} else { ab.solutionList[j].solutionContent.statusName = this.regSolutionStatus.SOLUTION_SUBMIT;
return system.getResultFail(-302, "提交方案失败"); ab.solutionList[j].solutionContent.solutionFlowList = solutionFlowList;
ab.solutionList[j]["channelNeedNo"] = needinfo.channelNeedNo;
// var solutionNo = await this.getBusUid("ns");//chuangjian
var solutionNo = [];//chuangjian
solutionNo[j] = await this.getBusUid("ns")
console.log('solutionNo[j]----',solutionNo[j])
ab.solutionList[j]["solutionNo"] = solutionNo[j];
ab.solutionList[j]["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.solutionList[j].solutionContent["customerInfo"] = customerInfo;
ab.solutionList[j].solutionContent["salesmanInfo"] = salesmanInfo;
ab.solutionList[j].solutionContent.solution.solutionPrice = (ab.solutionList[j].solutionContent.solution.solutionPrice) / 100 || "";//分转元
ab.solutionList[j].solutionContent = JSON.stringify(ab.solutionList[j].solutionContent);
console.log('abababab---+++---++',ab)
var self = this;
var res = await this.needsolutionDao.db.transaction(async function (t) {
ab.solutionList[j]["needNo"] = needinfo.needNo;
var od = await self.needsolutionDao.create(ab.solutionList[j], 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: "reg提交方案"
}];
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 });
needsolutions.push(od.dataValues)
console.log('needsolutions-------',needsolutions)
}
// else {
// return system.getResultFail(-302, "提交方案失败");
// }
})
} }
}) }
return system.getResultSuccess({ needinfo: needinfo,needsolutions: needsolutions });
} }
//交付商通知状态变更 //交付商通知状态变更
......
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