Commit d6502125 by 任晓松

Merge remote-tracking branch 'origin/center-order' into center-order

parents d9d47b7f 9bc59bc7
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class IcpAPI extends APIBase {
constructor() {
super();
// this.utilsProductSve = system.getObject("service.utilsSve.utilsProductSve");
this.needsolutionSve = system.getObject("service.dbneed.needsolutionSve");
this.needinfoSve = system.getObject("service.dbneed.needinfoSve");
this.orderinfoSve = system.getObject("service.dbcorder.orderinfoSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
if (pobj.actionType == 'getPolicyNeedList' || pobj.actionType == 'submitPolicyNeedNotes') {
if (!pobj.userInfo) {
return system.getResult(system.noLogin, "user no login!");
}
if (!pobj.appInfo) {
return system.getResult(system.noLogin, "app is null!");
}
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
// case "submitIcpProgramme"://icp方案提交
// opResult = await this.needsolutionSve.submitIcpProgramme(pobj);
// break;
// case "submitIcpMaterial"://icp材料提交
// opResult = await this.needsolutionSve.submitIcpMaterial(pobj);
// break;
// case "acceptIcpPartnerNotification"://icp通知状态变更
// opResult = await this.needsolutionSve.acceptIcpPartnerNotification(pobj);
// break;
// case "abolishIcpProgramme"://服务商icp方案关闭
// opResult = await this.needsolutionSve.abolishIcpProgramme(pobj);
// break;
// case "getIcpProgrammeDetail"://获取icp方案
// opResult = await this.needsolutionSve.getIcpProgrammeDetail(pobj);
// break;
// case "getNeedSolutionDetailByUser"://获取方案详情
// opResult = await this.needsolutionSve.getNeedSolutionDetailByUser(pobj);
// break;
// case "receiveIcpStatusNotify"://接收渠道方案状态变更通知
// opResult = await this.needsolutionSve.receiveIcpStatusNotify(pobj);
// break;
// case "receiveIcpFeedback"://接收icp用户方案反馈
// opResult = await this.needsolutionSve.receiveIcpFeedback(pobj);
// break;
// case "getIcpProgrammeDetail"://获取方案详情(内部调用)
// opResult = await this.needsolutionSve.getIcpProgrammeDetail(pobj);
// break;
// case "getProgrammeInfoByChannelNeedNo"://获取需求方案列表
// opResult = await this.needsolutionSve.getProgrammeInfoByChannelNeedNo(pobj);
// break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = IcpAPI;
\ No newline at end of file
......@@ -43,7 +43,7 @@ class IcAPI extends APIBase {
opResult = await this.opNeedInfoSve.opNeedClose(pobj, pobj.actionBody, req);
break;
case "opGetItemByNeedNo"://获取需求详情
opResult = await this.needinfoSve.getItemByNeedNo(pobj);
opResult = await this.opNeedInfoSve.getItemByNeedNo(pobj);
break;
case "getStatisticsByUappId":
opResult = await this.opNeedInfoSve.getStatisticsByUappId(pobj);
......
......@@ -63,9 +63,9 @@ class QcAPI extends APIBase {
case "receiveIcpFeedback"://接收icp用户方案反馈2.2
opResult = await this.aliyunqcSve.receiveIcpFeedback(pobj);
break;
case "getIcpProgrammeDetail"://获取方案详情(内部调用)
opResult = await this.aliyunqcSve.getIcpProgrammeDetail(pobj);
break;
// case "getIcpProgrammeDetail"://获取方案详情(内部调用)
// opResult = await this.aliyunqcSve.getIcpProgrammeDetail(pobj);
// break;
case "getProgrammeInfoByChannelNeedNo"://获取需求方案列表
opResult = await this.aliyunqcSve.getProgrammeInfoByChannelNeedNo(pobj);
break;
......
......@@ -237,53 +237,6 @@ class NeedinfoService extends ServiceBase {
return system.getResultSuccess(item);
}
async writeCommunicationLog(pobj, actionBody) {
// 查询需求沟通记录
// 2020 0820 lin 修改channel传过来的参数 为 note/intentionBizId
actionBody.Note = ["noteTime", moment().format("YYYY-MM-DD HH:mm:ss"), "note", actionBody.note];
let needRes = await this.findOne({ channelNeedNo: actionBody.intentionBizId });
// 没有需求单直接返回
if (!needRes) {
return system.getResult("没有这个需求单");
}
// 如果未推送/以推送 修改为已跟进
if (needRes.status == "wts" || needRes.status == "yts") {
var sql = "update n_need_info set status=:status, statusName=:statusName where channelNeedNo=:BizId"
var paramWhere = {
statusName: '已跟进',
status: 'ygj',
BizId: actionBody.intentionBizId
};
var updateRes = await this.customUpdate(sql, paramWhere);
}
// 有需求单但没有沟通记录 直接set
if (!needRes.followContent) {
var sql = "update n_need_info set followContent=JSON_OBJECT(:followContent) where channelNeedNo=:BizId"
var paramWhere = {
followContent: actionBody.Note,
BizId: actionBody.intentionBizId
};
var updateRes = await this.customUpdate(sql, paramWhere);
if (updateRes[1]) {
return system.getResultSuccess();
}
return system.getResult("添加记录失败");
// 有需求单有沟通记录 json_array_append
} else {
var sql = "update n_need_info set followContent=json_array_append(followContent, '$', JSON_OBJECT(:Note)) where channelNeedNo=:BizId"
// var sql = "update n_need_info set followContent=json_array_append(followContent, '$', "+ "\"" + JSON.stringify(actionBody.Note) + "\""+") where channelNeedNo="+ "\"" +actionBody.BizId +"\"" +" "
var paramWhere = {
Note: actionBody.Note,
BizId: actionBody.intentionBizId
};
var updateRes = await this.customUpdate(sql, paramWhere);
if (updateRes[1]) {
return system.getResultSuccess();
}
return system.getResult("添加记录失败");
}
}
async submitIcpIntention(pobj, actionBody, req) {
var needNo = await this.getBusUid("n");
var nobj = {
......
......@@ -7,180 +7,6 @@ class NeedinfoService2 extends ServiceBase {
constructor() {
super("dbneed", ServiceBase.getDaoName(NeedinfoService2));
this.execlient = system.getObject("util.execClient");
this.needsolutionSve = system.getObject("service.dbneed.needsolutionSve");
this.needsolutionDao = system.getObject("db.dbneed.needsolutionDao");
this.needinfoDao = system.getObject("db.dbneed.needinfoDao");
}
async getItemByNeedNo(pobj) {
var item = await this.dao.getItemByNeedNo(pobj.actionBody.needNo);
console.log(system.getResultSuccess(item));
if (!item) {
return system.getResult(null, "需求数据为空,30210");
}
return system.getResultSuccess(item);
}
async getItemByChannelNeedNo(pobj) {
var item = await this.dao.getItemByChannelNeedNo(pobj.actionBody.needNo);
if (!item) {
return system.getResult(null, "需求数据为空,30210");
}
return system.getResultSuccess(item);
}
async needinfo2fq(pobj) {
pobj.actionBody.needNo = await this.getBusUid("n");
pobj.actionBody.uapp_id = pobj.appInfo.id;
var needinfo = await this.dao.create(pobj.actionBody);
var pobj = {
"idempotentId": needinfo.needNo,
"idempotentSource": needinfo.chanceType_code,
"idempotentSourceName": pobj.appInfo.app_name + "_" + pobj.actionBody.chanceTypeName,
"phone": needinfo.publishMobile,
"remark": needinfo.notes,
"customerName": needinfo.publishName
};
var rc = system.getObject("util.aliyunClient");
var rtn = await rc.post("https://yunfuapi.gongsibao.com/crm/opportunity/submit", pobj);
console.log(rtn)
return system.getResultSuccess();
// var opResultstr = await this.execlient.execPost(pobj, "https://yunfuapi-dev.gongsibao.com/crm/opportunity/submit");
// opResult = JSON.parse(opResultstr.stdout)
// if (opResultstr) {
// return system.getResultSuccess();
// }
}
// intentionBizId
// mobile
// userName
// description
// area
// type
// ext
async submitNeed(pobj, actionBody, req) {
var needNo = await this.getBusUid("n");
if (!actionBody.intentionBizId) {
return system.getResultFail(-5001, "intentionBizId不能为空");
}
if (!actionBody.mobile) {
return system.getResultFail(-5002, "mobile不能为空");
}
if (!actionBody.type) {
return system.getResultFail(-5003, "type不能为空");
}
var ninfo = await this.findOne({ channelNeedNo: actionBody.intentionBizId });
if (ninfo) {
return system.getResultSuccess(ninfo);
}
var nobj = {
uapp_id: pobj.appInfo.uapp_id,
channelNeedNo: actionBody.intentionBizId,
needNo: needNo,
channelUserId: actionBody.mobile,
publishName: actionBody.userName,
publishContent: actionBody.description,
publishMobile: actionBody.mobile,
city: actionBody.area || "",
// disposeNotes: actionBody.ext,
typeCode: actionBody.type_code,
typeName: actionBody.type_name,
channelTypeCode: actionBody.channel_type_code,
channelTypeName: actionBody.channel_type_name,
status: "wts",
level: actionBody.level || "",
probability: actionBody.probability || "",
notes: actionBody.notes
}
if (nobj.channelTypeCode == 7 || nobj.channelTypeCode == 5) {
nobj.province = nobj.city,
nobj.city = "";
}
var needInfo = await this.dao.create(nobj);
return system.getResultSuccess(needInfo);
}
/**
* 工商H5 免费咨询
* @param pobj
* @param actionBody
* @param req
* @returns {Promise<{msg: *, data: *, status: *}|{msg: *, data: (*|null), status: number}>}
*/
async submitNeedH5(pobj, actionBody, req) {
var needNo = await this.getBusUid("n");
var channelNeedNo = await this.getBusUid("i");
if (!actionBody.mobile) {
return system.getResultFail(-5002, "mobile不能为空");
}
if (!actionBody.type) {
return system.getResultFail(-5003, "type不能为空");
}
var ninfo = await this.findOne({ channelNeedNo: actionBody.intentionBizId });
if (ninfo) {
return system.getResultSuccess();
}
var nobj = {
uapp_id: pobj.appInfo.uapp_id,
channelNeedNo: channelNeedNo,
needNo: needNo,
channelUserId: actionBody.mobile,
publishName: actionBody.userName,
publishContent: actionBody.description,
publishMobile: actionBody.mobile,
city: actionBody.area || "",
typeCode: actionBody.type_code,
typeName: actionBody.type_name,
channelTypeCode: actionBody.channel_type_code,
channelTypeName: actionBody.channel_type_name,
status: "wts"
}
if (nobj.channelTypeCode == 7 || nobj.channelTypeCode == 5) {
nobj.province = nobj.city || "",
nobj.city = "";
}
await this.dao.create(nobj);
return system.getResultSuccess();
}
async needClose(pobj, actionBody, req) {
if (!actionBody.intentionBizId) {
return system.getResultFail(-5005, "intentionBizId不能为空");
}
var needinfo = await this.findOne({ channelNeedNo: actionBody.intentionBizId });
if (!needinfo) {
return system.getResultFail(-5004, "需求不存在");
}
if (needinfo.status == "ygb" || needinfo.status == "ycd") {
return system.getResultSuccess();
} else {
needinfo.status = "ygb";
// 2020 0821 lin 新增 修改增加 跟进者唯一码(非必填),跟进者手机号(必填)
needinfo.followManMobile = actionBody.followManMobile;
needinfo.followManUserId = actionBody.followManUserId;
var self = this;
await self.update(needinfo.dataValues);
await self.needsolutionSve.abolishProgrammeByNeed(pobj);
return system.getResultSuccess();
}
}
async flowinfo(obj) {
}
async getItemByChannelSolutionNo(pobj) {
var solutionitem = await this.needsolutionDao.findOne({ channelSolutionNo: pobj.actionBody.bizId });
if (!solutionitem) {
return system.getResult(null, "需求数据为空,30210");
}
var item = await this.dao.getItemByNeedNo(solutionitem.needNo);
item.solutionProvince = solutionitem.solutionContent.solution.Area + `(${solutionitem.solutionContent.solution.ActionType})`//北京(新办);
item.solutionContent = solutionitem.solutionContent
item.channelSolutionNo = solutionitem.channelSolutionNo
if (!item) {
return system.getResult(null, "需求数据为空,30210");
}
return system.getResultSuccess(item);
}
async writeCommunicationLog(pobj, actionBody) {
......@@ -274,108 +100,5 @@ class NeedinfoService2 extends ServiceBase {
}
async submitIcpIntention(pobj, actionBody, req) {
var needNo = await this.getBusUid("n");
var nobj = {
uapp_id: pobj.appInfo.uapp_id,
needNo: needNo,
channelUserId: pobj.userInfo.channel_userid,
publishName: actionBody.UserName,
publishContent: actionBody.Description,
publishMobile: actionBody.Mobile,
city: actionBody.Area || "",
typeCode: actionBody.type_code,
typeName: actionBody.type_name,
channelTypeCode: actionBody.channel_type_code,
channelTypeName: actionBody.channel_type_name,
status: "wts"
}
if (nobj.channelTypeCode == 7 || nobj.channelTypeCode == 5) {
nobj.province = nobj.city || "",
nobj.city = "";
}
await this.dao.create(nobj);
return system.getResultSuccess();
}
async queryIntentionList(pobj, actionBody, req) {
if (!actionBody.intentionBizId) {
return system.getResultFail(-5005, "intentionBizId不能为空");
}
var needinfo = await this.findOne({ channelNeedNo: actionBody.intentionBizId });
if (!needinfo) {
return system.getResultFail(-5004, "需求不存在");
}
if (needinfo.status == "ygb" || needinfo.status == "ycd") {
return system.getResultSuccess();
} else {
needinfo.status = "ygb";
// 2020 0821 lin 新增 修改增加 跟进者唯一码(非必填),跟进者手机号(必填)
needinfo.followManMobile = actionBody.followManMobile;
needinfo.followManUserId = actionBody.followManUserId;
var self = this;
await self.update(needinfo.dataValues);
await self.needsolutionSve.abolishProgrammeByNeed(pobj);
return system.getResultSuccess();
}
}
async confirmIcpIntention(pobj, actionBody, req) {
if (!actionBody.intentionBizId) {
return system.getResultFail(-5005, "intentionBizId不能为空");
}
var needinfo = await this.findOne({ channelNeedNo: actionBody.intentionBizId });
if (!needinfo) {
return system.getResultFail(-5004, "需求不存在");
}
if (needinfo.status == "ygb" || needinfo.status == "ycd") {
return system.getResultSuccess();
} else {
needinfo.status = "ygb";
// 2020 0821 lin 新增 修改增加 跟进者唯一码(非必填),跟进者手机号(必填)
needinfo.followManMobile = actionBody.followManMobile;
needinfo.followManUserId = actionBody.followManUserId;
var self = this;
await self.update(needinfo.dataValues);
await self.needsolutionSve.abolishProgrammeByNeed(pobj);
return system.getResultSuccess();
}
}
//查询未提交的需求
async getUnCreated (pobj, data, req) {
let stdate = new Date(pobj.actionBody.Begin);
let enddate = new Date(pobj.actionBody.End );
let query = {where:{}};
query.where["created_at"] = { [this.db.Op.between]: [stdate, enddate] };
try {
let res = await this.dao.model.findAndCountAll(query);
res = res.rows.map(n=>n.channelNeedNo);
res = pobj.actionBody.data.filter(ali=>!res.includes(ali.BizId));
return system.getResultSuccess(res)
} catch (error) {
return system.getResultFail(-1, error.message)
}
}
async produceNoticeAliEsp (pobj, actionBody) {
switch (actionBody.operationType) {
case "USER_PAY_PRODUCE":
break;
case "USER_PAY_PRODUCE":
break;
case "USER_PAY_PRODUCE":
break;
case "USER_PAY_PRODUCE":
break;
case "USER_PAY_PRODUCE":
break;
default:
return system.getResult(null, "operationType参数错误");
}
}
}
module.exports = NeedinfoService2;
// var a=new NeedinfoService();
// var b=a.getItemByChannelSolutionNo({actionBody:{bizId:"1593141330846"}});
\ No newline at end of file
......@@ -608,163 +608,7 @@ class NeedsolutionService extends ServiceBase {
//---------------------公司注册-end-----------------------------------------------------------------
//---------------------icp注册-start-----------------------------------------------------------------
//根据需求查看方案列表
async getProgrammeInfoByChannelNeedNo(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
ab["createUserId"] = user.id;
// followManMobile: DataTypes.STRING,//跟进人手机号(合伙人)
// followManOnlyCode: DataTypes.STRING(50),//跟进者唯一码
if (!ab.needNo) {
return system.getResultFail(-101, "需求号不能为空");
}
// if(!ab.followManMobile){
// return system.getResultFail(-102,"跟进人手机号不能为空");
// }
// if(!ab.followManOnlyCode){
// return system.getResultFail(-103,"跟进人唯一码不能为空");
// }
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { channelNeedNo: ab.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-102, "未知需求信息");
}
var ns = await this.dao.model.findAll({
where: { needNo: needinfo.needNo}, raw: true,
attributes: ["needNo", "solutionNo", "channelSolutionNo", "orderNo", "solutionContent", "status", "statusName"]
});
return system.getResultSuccess(ns);
}
//提交方案
async submitIcpProgramme(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, "渠道需求号不能为空");
}
if (!ab.solutionContent) {
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 = ab.solutionContent.bizType;//icp业务类型
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.dao.model.findAll({
where: { channelNeedNo: ab.needNo }, raw: true
});
for (var i = 0; i < ns.length; i++) {
var fa = ns[i];
if (fa.status != "yzf") {
return system.getResultFail(-207, "需求方案已存在,不能重复提交");
}
}
// ab.solutionContent.bizType=needinfo.channelTypeCode;
// bizType =needinfo.channelTypeCode;
if (!ab.solutionContent.solution) {
return system.getResultFail(-104, "业务方案信息不能为空");
}
var solution = ab.solutionContent.solution;
if (!solution) {
return system.getResultFail(-103, "方案交付信息有误");
}
if (needinfo.channelTypeCode == "7") {//edi
ab.solutionContent.solution.IcpType = 2;
}
if (needinfo.channelTypeCode == "5") {//icp
ab.solutionContent.solution.IcpType = 1;
}
ab.solutionContent.applicationStatusList = [{
"OfficialFileURL": "",
"ApplicationStatus": "submitIcpProgramme",
"ApplicationStatusName": "提交方案",
"created_at": new Date()
}];
if (!solution.CompanyName) {
return system.getResultFail(-105, "公司名不能为空");
}
if (!solution.CompanyAddress) {
return system.getResultFail(-106, "公司地址不能为空");
}
if (!solution.Area) {
return system.getResultFail(-107, "区域不能为空");
}
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";
ab.solutionContent["notes"] = "";
ab.solutionContent["totalSum"] = "";
ab.solutionContent = JSON.stringify(ab.solutionContent);
var self = this;
return await this.db.transaction(async function (t) {
ab["needNo"] = needinfo.needNo;
var od = await self.dao.create(ab, t);
if (od && od.id) {
var pushflag = 0;//推送标志 值为1推送小记
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;
pushflag = 1;
}
await self.needinfoDao.update(needObj, t);
needinfo = await self.needinfoDao.model.findOne({
where: { id: needinfo.id }, raw: true
});
needinfo["pushflag"] = pushflag;
return system.getResultSuccess({ needinfo: needinfo, needsolution: od });
} else {
return system.getResultFail(-202, "提交方案失败");
}
})
}
//修改icp方案-- 无效
async updateIcpProgramme(pobj) {
......@@ -847,119 +691,7 @@ class NeedsolutionService extends ServiceBase {
})
}
//服务商通知状态变更
async acceptIcpPartnerNotification(pobj) {
var ab = pobj.actionBody;
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.ApplicationStatus) {
return system.getResultFail(-102, "通知状态不能为空");
}
//获取方案信息
var needsolutioninfo = await this.dao.model.findOne({
attributes:["id","needNo","solutionContent","status"],
where: { channelSolutionNo: ab.BizId }, 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, "方案交付信息有误");
}
//获取需求信息
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") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
var applicationStatusList = solutionContent.applicationStatusList || [];
var solutionFlowList = solutionContent.solutionFlowList || [];
var statusObj = {
"OfficialFileURL": ab.OfficialFileURL || "",
"ApplicationStatus": ab.ApplicationStatus,
"ApplicationStatusName": ab.ApplicationStatus,
"created_at": new Date()
};
applicationStatusList.push(statusObj);
solutionContent.applicationStatusList = applicationStatusList;
if (ab.ApplicationStatus == 507) {//完成账户注册
solutionFlowList.push({
status: "ACCOUNT_REGISTERED", statusName: this.icpSolutionStatusReference.ACCOUNT_REGISTERED, updated_at: new Date()
});
solutionContent.status = "ACCOUNT_REGISTERED";
solutionContent.statusName = this.icpSolutionStatusReference.ACCOUNT_REGISTERED;
// this.icpSolutionStatusReference={
// UN_PAID:"未支付",PAID:"用户支付",USER_UPLOADED:"用户上传资料",MATERIAL_UNCONFIRM:"服务商递交⽂件"
// ,USER_CONFIRMED:"⽤户已确认递交⽂件",ACCOUNT_REGISTERED:"完成账户注册",MATERIAL_SUBMITTED:"完成资料递交",
// GXB_ACCEPT:"⼯信部已受理",GXB_REFUSE:"⼯信部不予受理",GXB_FAIL:"⼯信部未通过"
// ,CLOSE:"方案关闭"
// };
}
if (ab.ApplicationStatus == 508) {//"服务商完成提交资料到⼯信部
solutionFlowList.push({
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) {//⼯商部已受理
solutionFlowList.push({
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) {//⼯商部不予受理
solutionFlowList.push({
status: "GXB_REFUSE", statusName: this.icpSolutionStatusReference.GXB_REFUSE, updated_at: new Date()
});
solutionContent.status = "GXB_REFUSE";
needsolutioninfo.status = "yzf";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_REFUSE;
}
if (ab.ApplicationStatus == 511) {//⼯商部通过
solutionFlowList.push({
status: "GXB_SUCCESS", statusName: this.icpSolutionStatusReference.GXB_SUCCESS, updated_at: new Date()
});
needsolutioninfo.status = "ywc";
needsolutioninfo.status = "ywc";
solutionContent.status = "GXB_SUCCESS";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_SUCCESS;
}
if (ab.ApplicationStatus == 512) {//⼯信部未通过
solutionFlowList.push({
status: "GXB_FAIL", statusName: this.icpSolutionStatusReference.GXB_FAIL, updated_at: new Date()
});
solutionContent.status = "GXB_FAIL";
needsolutioninfo.status = "yzf";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_FAIL;
}
solutionContent.solutionFlowList = solutionFlowList;
needsolutioninfo.solutionContent = JSON.stringify(solutionContent);
var self = this;
return await this.db.transaction(async function (t) {
await self.dao.update(needsolutioninfo, t);
// needsolutioninfo = await self.dao.model.findOne({
// where: { channelSolutionNo: ab.BizId }, raw: true
// });
statusObj["BizId"] = ab.BizId;
return system.getResultSuccess(statusObj);
})
}
//服务商方案作废 -- abolishIcpProgramme
async abolishIcpProgramme(pobj) {
var ab = pobj.actionBody;
......@@ -1005,196 +737,7 @@ class NeedsolutionService extends ServiceBase {
});
return system.getResultSuccess(ns);
}
//确认方案
async confirmIcpIntention(pobj) {
return system.getResultFail();
}
//接收渠道方案状态变更通知
async receiveIcpStatusNotify(pobj) {
var ab = pobj.actionBody;
if (!ab.BizId) {
return system.getResultFail(-101, "渠道方案号不能为空");
}
if (!ab.status) {
return system.getResultFail(-102, "方案状态不能为空");
}
//获取方案信息
var ns = await this.dao.model.findOne({
where: { channelSolutionNo: ab.BizId }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-102, "未知方案");
}
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 + ",不能执行此操作");
}
if (ns.status != "dqr" && ns.status != "yzf") {
return system.getResultFail(-103, "方案状态错误,不能作废已完成方案-1");
}
var solutionContent = ns.solutionContent;
//方案流程列表
var solutionFlowList = solutionContent.solutionFlowList || [];
if (ab.status == "2") {//⽤户已上传
solutionFlowList.push({
status: "USER_UPLOADED", statusName: this.icpSolutionStatusReference.USER_UPLOADED, updated_at: new Date()
});
solutionContent.status = "USER_UPLOADED";
solutionContent.statusName = this.icpSolutionStatusReference.USER_UPLOADED;
}
if (ab.status == "4") {//⽤户已确认
solutionFlowList.push({
status: "USER_CONFIRMED", statusName: this.icpSolutionStatusReference.USER_CONFIRMED, updated_at: new Date()
});
solutionContent.status = "USER_CONFIRMED";
solutionContent.statusName = this.icpSolutionStatusReference.USER_CONFIRMED;
}
if (ab.status == "11") {//⽅案已关闭
solutionFlowList.push({
status: "CLOSE", statusName: this.icpSolutionStatusReference.CLOSE, updated_at: new Date()
});
solutionContent.status = "CLOSE";
solutionContent.statusName = this.icpSolutionStatusReference.CLOSE;
}
solutionContent.solutionFlowList = solutionFlowList;
var material = solutionContent.material || {};
if (ab.remark) {
solutionContent.notes = ab.remark;
}
if (ab.newbusinessLicense) {
material.PartnerBusinessLicense = ab.newbusinessLicense;
material.aliPartnerBusinessLicense = ab.businessLicense;
}
if (ab.newidCardUrlList && ab.newidCardUrlList.length > 0) {
material.PartnerIdCardList = ab.newidCardUrlList;
material.aliPartnerIdCardList = ab.idCardUrlList;
}
if (ab.newuserPlan) {
material.PartnerPlan = ab.newuserPlan;
material.aliPartnerPlan = ab.userPlan;
}
if (ab.newuserForeig) {
material.PartnerForeignInvestment = ab.newuserForeig;
material.aliPartnerForeignInvestment = ab.userForeig;
}
if (ab.newuserLaw) {
material.PartnerLaw = ab.newuserLaw;
material.aliPartnerLaw = ab.userLaw;
}
if (ab.newuserOtherList && ab.newuserOtherList.length > 0) {
material.PartnerSignAndStampOtherList = ab.newuserOtherList;
material.aliPartnerSignAndStampOtherList = ab.userOtherList;
}
solutionContent.material = material;
solutionContent = JSON.stringify(solutionContent);
var updateObj = {
id: ns.id, solutionContent: solutionContent
};
if (ab.status == "11") {//⽅案已关闭
updateObj["status"] = "yzf";
}
// else if(ab.status == "2" || ab.status == "4"){ //2, "⽤户已上传" 4, "⽤户已确认"
// updateObj["status"]="dqr";
// }
await this.dao.update(updateObj);//方案状态修改
ns = await this.dao.model.findOne({
where: { channelSolutionNo: ab.BizId }, 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") {
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
//获取方案信息
var ns = await this.dao.model.findOne({
where: { channelNeedNo: ab.intentionBizId, status: "dqr" }, raw: true
});
if (!ns) {
return system.getResultFail(-106, "未知方案");
}
var intentionStatusList = ["未知", "⽅案待服务商确认", "⽅案待⽤户确认", "处理中", "已完成", "已关闭"];
var updateObj = {
id: ns.id
};
var solutionContent = ns.solutionContent;
solutionContent.notes = ab.description;
solutionContent.needStatus = ab.intentionStatus;
if (ab.intentionStatus == 1 || ab.intentionStatus == 2 || ab.intentionStatus == 3) {
updateObj["status"] = "dqr";
} else if (ab.intentionStatus == 4) {
updateObj["status"] = "ywc";
} else if (ab.intentionStatus == 5) {
updateObj["status"] = "yzf";
} else {
return system.getResultFail(-107, "需求当前状态错误--" + ab.intentionStatus);
}
solutionContent.needStatusName = intentionStatusList[ab.intentionStatus];
solutionContent = JSON.stringify(solutionContent);
updateObj["solutionContent"] = solutionContent;
await this.dao.update(updateObj);//方案状态修改
return system.getResultSuccess();
}
//获取方案详情(内部调用)
async getIcpProgrammeDetail(pobj) {
var ab = pobj.actionBody;
if (!ab.BizId) {
return system.getResultFail(-101, "方案编号不能为空");
}
//获取方案信息
var ns = await this.dao.model.findAll({
where: { channelSolutionNo: ab.BizId }, 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.dao.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);
}
//---------------------icp注册-end-----------------------------------------------------------------
// --------------庄冰2020.10.23-------百度Icp接入使用--------start------------------
//接收方案状态及支付信息
......
......@@ -7,7 +7,6 @@ class NeedinfoService extends ServiceBase {
constructor () {
super("dbneed", ServiceBase.getDaoName(NeedinfoService));
this.execlient = system.getObject("util.execClient");
this.needsolutionSve = system.getObject("service.dbneed.needsolutionSve");
this.needsolutionDao = system.getObject("db.dbneed.needsolutionDao");
this.needinfoDao = system.getObject("db.dbneed.needinfoDao");
this.needinfofqDao = system.getObject("db.dbneed.needinfofqDao");
......
......@@ -70,57 +70,7 @@ class AliyunQcService {
"CERT_GXB_REFUSE": "⼯商部不予受理"
};
}
//根据需求关闭ICP方案(关闭需求后调用)
async 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"],
where: { channelNeedNo: ab.intentionBizId }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
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.orderNo) {
return system.getResultFail(-102, "该需求已生成订单,不能关闭!");
}
if (ns.status == "ywc") {
return system.getResultFail(-103, "方案状态错误,不能废弃已完成方案-3");
}
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) {
var needObj = {
id: needinfo.id, status: "ygb", notes: ab.note
};
await self.needinfoDao.update(needObj, t);//关闭需求
if (ns && ns.id) {
await self.needsolutionDao.model.update({ status: "yzf", isInvalid: 1 }, { where: { id: ns.id }, transaction: t });//方案废弃
return system.getResultSuccess(ns.orderNo);
}
return system.getResultSuccess();
})
}
//根据需求查看方案列表
async getProgrammeInfoByChannelNeedNo(pobj) {
var ab = pobj.actionBody;
......@@ -182,142 +132,6 @@ class AliyunQcService {
return system.getResultSuccess(ns);
}
//提交方案
async submitIcpProgramme(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, "渠道需求号不能为空");
}
if (!ab.solutionContent) {
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, "办理类型不能为空");
}
ab.solutionContent.solution.actionType = solution.ActionType
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 closeOrderDelivery(pobj) {
var ab = pobj.actionBody;
......@@ -390,22 +204,7 @@ class AliyunQcService {
});
return system.getResultSuccess(new_ns);
}
//交付商提交材料信息
async serviceProviderSubmitMaterial(pobj) {
var ab = pobj.actionBody;
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;
......@@ -484,173 +283,7 @@ class AliyunQcService {
})
}
//交付商通知状态变更
async serviceProviderNotification(pobj) {
var ab = pobj.actionBody;
if (!ab.orderNo) {
return system.getResultFail(-101, "订单号不能为空");
}
if (!ab.status) {
return system.getResultFail(-102, "交付状态不能为空");
} else {
ab["ApplicationStatus"] = ab.status;
}
if (ab.officialFileURL) {
ab["OfficialFileURL"] = ab.officialFileURL;
}
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;
ab["solutionNo"] = ns.solutionNo;
pobj.actionBody = ab;
return this.acceptIcpPartnerNotification(pobj);
}
//服务商通知状态变更
async acceptIcpPartnerNotification(pobj) {
var ab = pobj.actionBody;
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 || [];
if (ab.ApplicationStatus == 507) {//完成账户注册
// 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);
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
await self.needsolutionDao.update(needsolutioninfo, t);
statusObj["BizId"] = ab.BizId;
return system.getResultSuccess(statusObj);
})
}
//接收渠道方案状态变更通知
async receiveIcpStatusNotify(pobj) {
......
......@@ -119,66 +119,7 @@ class BaseQcService {
}
}
//根据需求查看方案列表
async getProgrammeInfoByChannelNeedNo(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 needinfo = await this.needinfoDao.model.findOne({
where: { channelNeedNo: ab.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-102, "未知需求信息");
}
var ns = await this.needsolutionDao.model.findAll({
where: { needNo: needinfo.needNo }, raw: true,
attributes: ["needNo", "solutionNo", "channelSolutionNo", "orderNo", "solutionContent", "status", "statusName"]
});
return system.getResultSuccess(ns);
}
//获取方案详情(内部调用)
async getIcpProgrammeDetail(pobj) {
var ab = pobj.actionBody;
if (!ab.BizId) {
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) {
......@@ -332,79 +273,7 @@ class BaseQcService {
})
}
//交付商关闭交付单
async closeOrderDelivery(pobj) {
var ab = pobj.actionBody;
if (!ab.orderNo) {
return system.getResultFail(-101, "订单号不能为空");
}
if (!ab.note) {
return system.getResultFail(-106, "关闭理由不能为空");
} else {
ab.Note = ab.note;
}
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.abolishIcpProgramme(pobj);
}
//服务商方案作废 -- abolishIcpProgramme
async abolishIcpProgramme(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
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;
......@@ -778,250 +647,6 @@ class BaseQcService {
})
}
//接收渠道方案状态变更通知
async receiveIcpStatusNotify(pobj) {
var ab = pobj.actionBody;
if (!ab.BizId) {
return system.getResultFail(-101, "渠道方案号不能为空");
}
if (!ab.status) {
return system.getResultFail(-102, "方案状态不能为空");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where: { channelSolutionNo: ab.BizId, isInvalid: 0 }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-102, "未知方案");
}
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: ns.needNo }, raw: true
});
if (!needinfo) {
return system.getResultFail(-104, "未知方案需求");
}
if (needinfo.status == "ygb") {
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
// if (ns.status == "yzf" || ns.status == "ywc") {
// return system.getResultFail(-103, "该方案状态为" + ns.statusName + ",不能执行此操作");
// }
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 || {};
if (ab.remark) {
solutionContent.customerRemark = ab.remark;
}
if (ab.newbusinessLicense) {
material.businessLicense = ab.newbusinessLicense;
material.aliBusinessLicense = ab.businessLicense;
}
if (ab.newidCardUrlList && ab.newidCardUrlList.length > 0) {
material.idCardUrlList = ab.newidCardUrlList;
material.aliIdCardUrlList = ab.idCardUrlList;
}
if (ab.newuserPlan) {
material.userPlan = ab.newuserPlan;
material.aliUserPlan = ab.userPlan;
}
if (ab.newuserForeig) {
material.userForeig = ab.newuserForeig;
material.aliUserForeig = ab.userForeig;
}
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) {
var ab = pobj.actionBody;
if (!ab.confirmUrl) {
return system.getResultFail(-101, "confirmUrl不能为空");
}
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 + ",不能执行此操作");
}
ns.solutionContent.confirmUrl = ab.confirmUrl;
var solutionContent = JSON.stringify(ns.solutionContent);
await this.needsolutionDao.model.update({ solutionContent: solutionContent }, { where: { id: ns.id } });//修改方案信息
return system.getResultSuccess();
}
/*
返回20位业务订单号
prefix:业务前缀
......@@ -1064,117 +689,6 @@ class BaseQcService {
return uuid.join('');
}
//接收渠道方案状态变更通知
async receiveEdiStatusNotify(pobj) {
var ab = pobj.actionBody;
if (!ab.BizId) {
return system.getResultFail(-101, "渠道方案号不能为空");
}
if (!ab.operationType) {
return system.getResultFail(-102, "方案状态不能为空");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
// 2020 0929 lin 修改ab.BizId 改为 ab.solutionBizId
where: { channelSolutionNo: ab.solutionBizId, isInvalid: 0 }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-102, "未知方案");
}
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: ns.needNo }, raw: true
});
if (!needinfo) {
return system.getResultFail(-104, "未知方案需求");
}
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, "状态错误-1");
}
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;
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