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,9 +323,15 @@ class regCenterOrderService { ...@@ -323,9 +323,15 @@ class regCenterOrderService {
if (!ab.needNo) { if (!ab.needNo) {
return system.getResultFail(-101, "渠道需求号不能为空"); return system.getResultFail(-101, "渠道需求号不能为空");
} }
if (!ab.solutionContent) { var i=0;
if(ab.solutionList){
var solutionListLength = ab.solutionList.length;
}
for(i=0;i<solutionListLength;i++){
if (!ab.solutionList[i].solutionContent) {
return system.getResultFail(-102, "方案信息有误"); return system.getResultFail(-102, "方案信息有误");
} }
}
//获取需求信息 //获取需求信息
var needinfo = await this.needinfoDao.model.findOne({ var needinfo = await this.needinfoDao.model.findOne({
where: { channelNeedNo: ab.needNo }, raw: true where: { channelNeedNo: ab.needNo }, raw: true
...@@ -337,61 +343,52 @@ class regCenterOrderService { ...@@ -337,61 +343,52 @@ 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;
for(j=0;j<solutionListLength;j++){
if (ab.solutionList[j].solutionContent) {
ab.solutionList[j].solutionContent.bizType = bizType;
ab.solutionList[j].solutionContent.typeCode = needinfo.typeCode;
ab.solutionList[j].solutionContent.typeName = needinfo.typeName;
var ns = await this.needsolutionDao.model.findAll({ var ns = await this.needsolutionDao.model.findAll({
where: { channelNeedNo: ab.needNo }, raw: true, order: [["id", 'asc']] where: { channelNeedNo: ab.needNo }, raw: true, order: [["id", 'asc']]
}); });
for (var i = 0; i < ns.length; i++) { var k = 0;
var fa = ns[i]; for (k = 0; k < ns.length; k++) {
if (fa.status == "dqr" || fa.status == "ywc") { var fa = ns[k];
return system.getResultFail(-207, "需求方案已存在,不能重复提交"); // if (fa.status == "dqr" || fa.status == "ywc") {
} // return system.getResultFail(-207, "需求方案已存在,不能重复提交");
// }
if (fa.status == "ybh") { if (fa.status == "ybh") {
ab.channelSolutionNo = fa.channelSolutionNo; ab.solutionList[j].channelSolutionNo = fa.channelSolutionNo;
} }
if (fa.status == "yzf") { if (fa.status == "yzf") {
ab.channelSolutionNo = ""; ab.solutionList[j].channelSolutionNo = "";
}
}
var solution = ab.solutionContent.solution;
if (!solution) {
return system.getResultFail(-103, "方案交付信息有误");
}
if (!needinfo.channelTypeCode) {
return system.getResultFail(-104, "需求业务类型有误");
} }
if (!solution.CompanyName) {
return system.getResultFail(-105, "公司名不能为空");
} }
if (!solution.LicenseType) { // var solution = ab.solutionList[j].solutionContent.solution;
return system.getResultFail(-106, "业务类型不能为空");
} var solutionFlowList = ab.solutionList[j].solutionContent.solutionFlowList || [];
if (!solution.Area) {
return system.getResultFail(-107, "区域不能为空");
}
if (!solution.ActionType) {
return system.getResultFail(-108, "办理类型不能为空");
}
var solutionFlowList = ab.solutionContent.solutionFlowList || [];
solutionFlowList.push({ solutionFlowList.push({
status: "SOLUTION_SUBMIT", statusName: this.regSolutionStatus.SOLUTION_SUBMIT, updated_at: new Date() status: "SOLUTION_SUBMIT", statusName: this.regSolutionStatus.SOLUTION_SUBMIT, updated_at: new Date()
}); });
ab.solutionContent.status = "SOLUTION_SUBMIT"; ab.solutionList[j].solutionContent.status = "SOLUTION_SUBMIT";
ab.solutionContent.statusName = this.regSolutionStatus.SOLUTION_SUBMIT; ab.solutionList[j].solutionContent.statusName = this.regSolutionStatus.SOLUTION_SUBMIT;
ab.solutionContent.solutionFlowList = solutionFlowList; ab.solutionList[j].solutionContent.solutionFlowList = solutionFlowList;
ab["channelNeedNo"] = needinfo.channelNeedNo; ab.solutionList[j]["channelNeedNo"] = needinfo.channelNeedNo;
var solutionNo = await this.getBusUid("ns"); // var solutionNo = await this.getBusUid("ns");//chuangjian
ab["solutionNo"] = solutionNo; var solutionNo = [];//chuangjian
ab["status"] = "dqr"; 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 = {//客户信息 var customerInfo = {//客户信息
"publishName": needinfo.publishName, "publishName": needinfo.publishName,
"publishMobile": needinfo.publishMobile "publishMobile": needinfo.publishMobile
...@@ -402,14 +399,15 @@ class regCenterOrderService { ...@@ -402,14 +399,15 @@ class regCenterOrderService {
"salesmanId": user.id, "salesmanId": user.id,
"salesmanChannelId": user.channel_userid "salesmanChannelId": user.channel_userid
}; };
ab.solutionContent["customerInfo"] = customerInfo; ab.solutionList[j].solutionContent["customerInfo"] = customerInfo;
ab.solutionContent["salesmanInfo"] = salesmanInfo; ab.solutionList[j].solutionContent["salesmanInfo"] = salesmanInfo;
ab.solutionContent.solution.SolutionPrice = (ab.solutionContent.solution.SolutionPrice) / 100 || "";//分转元 ab.solutionList[j].solutionContent.solution.solutionPrice = (ab.solutionList[j].solutionContent.solution.solutionPrice) / 100 || "";//分转元
ab.solutionContent = JSON.stringify(ab.solutionContent); ab.solutionList[j].solutionContent = JSON.stringify(ab.solutionList[j].solutionContent);
console.log('abababab---+++---++',ab)
var self = this; var self = this;
return await this.needsolutionDao.db.transaction(async function (t) { var res = await this.needsolutionDao.db.transaction(async function (t) {
ab["needNo"] = needinfo.needNo; ab.solutionList[j]["needNo"] = needinfo.needNo;
var od = await self.needsolutionDao.create(ab, t); var od = await self.needsolutionDao.create(ab.solutionList[j], t);
if (od && od.id) { if (od && od.id) {
var needObj = { var needObj = {
id: needinfo.id id: needinfo.id
...@@ -426,7 +424,7 @@ class regCenterOrderService { ...@@ -426,7 +424,7 @@ class regCenterOrderService {
if (!needinfo.followContent) { if (!needinfo.followContent) {
var followContent = [{ var followContent = [{
followDate: new Date(), followDate: new Date(),
content: "nc提交方案" content: "reg提交方案"
}]; }];
followContent = JSON.stringify(followContent); followContent = JSON.stringify(followContent);
needObj["followContent"] = followContent; needObj["followContent"] = followContent;
...@@ -435,12 +433,20 @@ class regCenterOrderService { ...@@ -435,12 +433,20 @@ 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 }); // return system.getResultSuccess({ needinfo: needinfo, needsolution: od });
} else { needsolutions.push(od.dataValues)
return system.getResultFail(-302, "提交方案失败"); console.log('needsolutions-------',needsolutions)
} }
// else {
// return system.getResultFail(-302, "提交方案失败");
// }
}) })
} }
}
return system.getResultSuccess({ needinfo: needinfo,needsolutions: needsolutions });
}
//交付商通知状态变更 //交付商通知状态变更
async ncNotification(pobj) { async ncNotification(pobj) {
......
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