Commit 288118de by 宋毅

Merge branch 'center-order' of gitlab.gongsibao.com:jiangyong/zhichan into center-order

parents 7913f0d4 82adbd40
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 "updateStausByRefundOrder"://修改退款方案状态
// opResult = await this.needsolutionSve.updateStausByRefundOrder(pobj);
// break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = IcpAPI;
\ No newline at end of file
......@@ -10,6 +10,7 @@ class NeedsolutionService extends ServiceBase {
// this.push2aliSve = system.getObject("service.common.push2aliSve");
this.orderinfoDao = system.getObject("db.dbcorder.orderinfoDao");
}
//---------------------公司注册-start-----------------------------------------------------------------
//提交方案
async submitProgramme(pobj){
var ab = pobj.actionBody;
......@@ -523,6 +524,526 @@ class NeedsolutionService extends ServiceBase {
await this.dao.model.update(reqObj, { where: { id: ns.id }});//修改方案信息
return system.getResultSuccess();
}
//---------------------公司注册-end-----------------------------------------------------------------
//---------------------icp注册-start-----------------------------------------------------------------
//提交方案
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,"渠道方案类型错误");
}
var ns = await this.dao.model.findAll({
where:{needNo: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,"方案交付信息有误");
}
ab.solutionContent.solution.IcpType = needinfo.channelTypeCode;
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,"区域不能为空");
}
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){
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.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,"方案交付信息有误");
}
ab.solutionContent.solution.IcpType = needinfo.channelTypeCode;
if(!solution.CompanyName){
return system.getResultFail(-105,"公司名不能为空");
}
if(!solution.CompanyAddress){
return system.getResultFail(-106,"公司地址不能为空");
}
if(!solution.Area){
return system.getResultFail(-107,"区域不能为空");
}
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 submitIcpMaterial(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.material){
return system.getResultFail(-102,"材料信息有误");
}
//获取方案信息
var needsolutioninfo = await this.dao.model.findOne({
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 material = ab.material;
if(!material.Domain){
return system.getResultFail(-101,"备案域名不能为空");
}
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,"域名证书不能为空");
}
if(!material.PartnerPreviewOtherList || material.PartnerPreviewOtherList.length<1){
return system.getResultFail(-107,"合作方递交其他供预览文件不能为空");
}
solutionContent.material = ab.material;
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
});
return system.getResultSuccess(needsolutioninfo);
})
}
//通知状态变更
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({
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 statusObj={
"OfficialFileURL":ab.OfficialFileURL || "",
"ApplicationStatus":ab.ApplicationStatus,
"created_at":new Date()
};
applicationStatusList.push(statusObj);
solutionContent.applicationStatusList = applicationStatusList;
// solutionContent.status = ab.ApplicationStatus;
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;
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(-105,"关闭理由不能为空");
}
//获取方案信息
var ns = await this.dao.model.findOne({
where:{channelSolutionNo: ab.BizId,createUserId:user.id},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"){
return system.getResultFail(-103,"方案状态错误,只能废弃待确认方案");
}
var solutionContent = ns.solutionContent;
solutionContent.solution.Note = ab.Note;
solutionContent = JSON.stringify(solutionContent);
await this.dao.update({id:ns.id,status:"yzf",solutionContent:solutionContent});//方案废弃
//获取方案信息
ns = await this.dao.model.findOne({
where:{channelSolutionNo: ab.BizId,createUserId:user.id},raw:true
});
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"){
return system.getResultFail(-103,"方案状态错误,只能废弃待确认方案");
}
var solutionContent = ns.solutionContent;
solutionContent.status = ab.status;
var material = solutionContent.material || {};
if(ab.remark){
solutionContent.notes = ab.remark;
}
if(ab.businessLicense){
material.PartnerBusinessLicense = ab.businessLicense;
}
if(ab.idCardUrlList && ab.idCardUrlList.length>0){
material.PartnerIdCardList = ab.idCardUrlList;
}
if(ab.userPlan){
material.PartnerPlan = ab.userPlan;
}
if(ab.userForeig){
material.PartnerForeignInvestment = ab.userForeig;
}
if(ab.userLaw){
material.PartnerLaw = ab.userLaw;
}
if(ab.userOtherList && ab.userOtherList.length>0){
material.PartnerSignAndStampOtherList = 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);
}
//---------------------icp注册-end-----------------------------------------------------------------
}
module.exports = NeedsolutionService;
// var task = new NeedsolutionService();
......
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