Commit a97af938 by 宋毅

tj

parents a5f85fd4 52724d3c
...@@ -31,13 +31,13 @@ class IcAPI extends APIBase { ...@@ -31,13 +31,13 @@ class IcAPI extends APIBase {
var opResult = null; var opResult = null;
switch (action_type) { switch (action_type) {
case "submitNeed"://提交需求 case "submitNeed"://提交需求
opResult = await this.needinfoSve.submitNeed(pobj); opResult = await this.needinfoSve.submitNeed(pobj,pobj.actionBody,req);
break; break;
case "getItemByNeedNo"://获取需求详情 case "getItemByNeedNo"://获取需求详情
opResult = await this.needinfoSve.getItemByNeedNo(pobj); opResult = await this.needinfoSve.getItemByNeedNo(pobj);
break; break;
case "needClose"://需求关闭 case "needClose"://需求关闭
opResult = await this.needinfoSve.needClose(pobj); opResult = await this.needinfoSve.needClose(pobj,pobj.actionBody,req);
break; break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
......
...@@ -20,13 +20,14 @@ module.exports = (db, DataTypes) => { ...@@ -20,13 +20,14 @@ module.exports = (db, DataTypes) => {
productType_id: DataTypes.STRING,//产品类型Id productType_id: DataTypes.STRING,//产品类型Id
notes: DataTypes.STRING,//备注 notes: DataTypes.STRING,//备注
disposeNotes: DataTypes.STRING,//处理的备注 disposeNotes: DataTypes.STRING,//处理的备注
statusName: DataTypes.STRING,
status: { status: {
//wts未推送,yts已推送,ygj已跟进,ycd已成单 //wts未推送,yts已推送,ygj已跟进,ycd已成单
type: DataTypes.ENUM, type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.push_chance_type), values: Object.keys(uiconfig.config.pdict.push_chance_type),
set: function (val) { set: function (val) {
this.setDataValue("chanceType", val); this.setDataValue("status", val);
this.setDataValue("chanceTypeName", uiconfig.config.pdict.push_chance_type[val]); this.setDataValue("statusName", uiconfig.config.pdict.push_chance_type[val]);
} }
}, },
city: DataTypes.STRING(50), // 城市 city: DataTypes.STRING(50), // 城市
......
...@@ -6,6 +6,7 @@ class NeedinfoService extends ServiceBase { ...@@ -6,6 +6,7 @@ class NeedinfoService extends ServiceBase {
constructor() { constructor() {
super("dbneed", ServiceBase.getDaoName(NeedinfoService)); super("dbneed", ServiceBase.getDaoName(NeedinfoService));
this.execlient = system.getObject("util.execClient"); this.execlient = system.getObject("util.execClient");
this.needsolutionSve = system.getObject("service.dbneed.needsolutionSve");
} }
async getItemByNeedNo(pobj) { async getItemByNeedNo(pobj) {
var item = await this.dao.getItemByNeedNo(pobj.actionBody.needNo); var item = await this.dao.getItemByNeedNo(pobj.actionBody.needNo);
...@@ -50,41 +51,75 @@ class NeedinfoService extends ServiceBase { ...@@ -50,41 +51,75 @@ class NeedinfoService extends ServiceBase {
if (actionBody.intentionBizId) { if (actionBody.intentionBizId) {
return system.getResult(null, "intentionBizId不能为空"); return system.getResult(null, "intentionBizId不能为空");
} }
if (actionBody.mobile) { if (!actionBody.mobile) {
return system.getResult(null, "mobile不能为空"); return system.getResult(null, "mobile不能为空");
} }
if (actionBody.type) { if (!actionBody.type) {
return system.getResult(null, "type不能为空"); return system.getResult(null, "type不能为空");
} }
var ninfo = await this.findOne({ channelNeedNo: actionBody.intentionBizId });
if (ninfo) {
return {
"requestId": req.requestId,
"success": true,
"errorMsg": "已存在",
"errorCode": "ok"
};
}
var nobj = { var nobj = {
uapp_id: pobj.appInfo.uapp_id, uapp_id: pobj.appInfo.uapp_id,
channelNeedNo: actionBody.intentionBizId, channelNeedNo: actionBody.intentionBizId,
needNo: needNo, needNo: needNo,
channelUserId: pobj.userInfo.channel_userid, channelUserId: actionBody.mobile,
publishName: actionBody.userName, publishName: actionBody.userName,
publishContent: actionBody.description, publishContent: actionBody.description,
publishMobile: actionBody.mobile, publishMobile: actionBody.mobile,
city: actionBody.area, city: actionBody.area,
disposeNotes: actionBody.ext, // disposeNotes: actionBody.ext,
channelTypeCode: actionBody.type channelTypeCode: actionBody.type,
status: "wts"
} }
return await this.dao.create(nobj); await this.dao.create(nobj);
return {
"requestId": req.requestId,
"success": true,
"errorMsg": "",
"errorCode": "ok"
};
} }
async needClose(pobj) { async needClose(pobj, actionBody, req) {
if (actionBody.intentionBizId) { if (!actionBody.intentionBizId) {
return system.getResult(null, "intentionBizId不能为空"); return system.getResult(null, "intentionBizId不能为空");
} }
var needinfo = await this.findOne({ channelNeedNo: actionBody.intentionBizId }); var needinfo = await this.findOne({ channelNeedNo: actionBody.intentionBizId });
needinfo.status = "ygb"; if (!needinfo) {
var self = this; return {
return await self.db.transaction(async function (t) { "requestId": req.requestId,
await self.update(needinfo, t); "success": false,
var needsolutioninfo = await self.needsolutionDao.findOne({ channelNeedNo: pobj.actionBody.intentionBizId }, t) "errorMsg": "需求不存在",
needsolutioninfo.status = "yzf"; "errorCode": "ok"
await self.needsolutionDao.update(needsolutioninfo, t); };
// await }
}) if (needinfo.status == "ygb" || needinfo.status == "ycd") {
return {
"requestId": req.requestId,
"success": true,
"errorMsg": "需求已关闭",
"errorCode": "ok"
};
} else {
needinfo.status = "ygb";
var self = this;
await self.update(needinfo.dataValues);
await self.needsolutionSve.abolishProgrammeByNeed(pobj);
return {
"requestId": req.requestId,
"success": true,
"errorMsg": "",
"errorCode": "ok"
};
}
} }
async flowinfo(obj) { async flowinfo(obj) {
......
...@@ -36,7 +36,7 @@ class NeedsolutionService extends ServiceBase { ...@@ -36,7 +36,7 @@ class NeedsolutionService extends ServiceBase {
return system.getResultFail(-104,"业务方案信息不能为空"); return system.getResultFail(-104,"业务方案信息不能为空");
} }
var solution = ab.solutionContent.solution; var solution = ab.solutionContent.solution;
if(bizType=="companyreg"){//普通公司注册 if(bizType=="esp.companyreg"){//普通公司注册
if(!solution.companyName){ if(!solution.companyName){
return system.getResultFail(-105,"公司名称不能为空"); return system.getResultFail(-105,"公司名称不能为空");
} }
...@@ -62,7 +62,7 @@ class NeedsolutionService extends ServiceBase { ...@@ -62,7 +62,7 @@ class NeedsolutionService extends ServiceBase {
return system.getResultFail(-112,"经营范围不能为空"); return system.getResultFail(-112,"经营范围不能为空");
} }
} }
if(bizType=="companyreg_cloud"){//云上公司注册 if(bizType=="esp.companyreg_cloud"){//云上公司注册
if(!solution.park){ if(!solution.park){
return system.getResultFail(-113,"注册园区不能为空"); return system.getResultFail(-113,"注册园区不能为空");
} }
...@@ -85,12 +85,43 @@ class NeedsolutionService extends ServiceBase { ...@@ -85,12 +85,43 @@ class NeedsolutionService extends ServiceBase {
ab["solutionNo"] = solutionNo; ab["solutionNo"] = solutionNo;
ab["status"] = "dqr"; ab["status"] = "dqr";
ab.solutionContent = JSON.stringify(ab.solutionContent); ab.solutionContent = JSON.stringify(ab.solutionContent);
var od = await this.dao.create(ab); var self = this;
if(od && od.id){ return await this.db.transaction(async function (t) {
return system.getResultSuccess({needinfo:needinfo,needsolution:od}); var od = await self.dao.create(ab,t);
}else{ if(od && od.id){
return system.getResultFail(-202, "提交方案失败"); 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:"提交到方案"
};
followContent = JSON.stringify(followContent);
needObj["followContent"] = followContent;
pushflag = 1;
}
await self.needinfoDao.update(needObj,t);
needinfo = await self.needinfoDao.model.findOne({
where:{needNo:ab.needNo},raw:true
});
needinfo["pushflag"]=pushflag;
return system.getResultSuccess({needinfo:needinfo,needsolution:od});
}else{
return system.getResultFail(-202, "提交方案失败");
}
})
} }
//接收方案编号(方案推送至阿里后,接收保存方案信息) //接收方案编号(方案推送至阿里后,接收保存方案信息)
async receiveProgrammeNo(pobj){ async receiveProgrammeNo(pobj){
...@@ -153,7 +184,7 @@ class NeedsolutionService extends ServiceBase { ...@@ -153,7 +184,7 @@ class NeedsolutionService extends ServiceBase {
if (pageSize > 500) { if (pageSize > 500) {
pageSize = 500; pageSize = 500;
} }
var bizType = ab.bizType || "companyreg";// companyreg_cloud var bizType = ab.bizType || "esp.companyreg";// esp.companyreg_cloud
var pageIndex = Number(ab.pageIndex || 1); var pageIndex = Number(ab.pageIndex || 1);
var from = pageIndex == 1 ? 0 : Number((pageIndex - 1) * pageSize); var from = pageIndex == 1 ? 0 : Number((pageIndex - 1) * pageSize);
//select * from log where data->'$.id' = 142; //select * from log where data->'$.id' = 142;
...@@ -179,7 +210,7 @@ class NeedsolutionService extends ServiceBase { ...@@ -179,7 +210,7 @@ class NeedsolutionService extends ServiceBase {
sqlCount += " and status = :status"; sqlCount += " and status = :status";
paramWhere.status = ab.status; paramWhere.status = ab.status;
} }
if(bizType=="companyreg"){//普通公司注册 if(bizType=="esp.companyreg"){//普通公司注册
if (ab.companyName) {//企业名称 if (ab.companyName) {//企业名称
sql = sql+" and solutionContent->'$.solution.companyName' = :companyName"; sql = sql+" and solutionContent->'$.solution.companyName' = :companyName";
sqlCount = sqlCount+" and solutionContent->'$.solution.companyName' = :companyName"; sqlCount = sqlCount+" and solutionContent->'$.solution.companyName' = :companyName";
...@@ -211,7 +242,7 @@ class NeedsolutionService extends ServiceBase { ...@@ -211,7 +242,7 @@ class NeedsolutionService extends ServiceBase {
paramWhere.companyCategory = ab.companyCategory; paramWhere.companyCategory = ab.companyCategory;
} }
} }
if(bizType=="companyreg_cloud"){//云上公司注册 if(bizType=="esp.companyreg_cloud"){//云上公司注册
if (ab.park) {//注册园区 if (ab.park) {//注册园区
sql = sql+" and solutionContent->'$.solution.park' = :park"; sql = sql+" and solutionContent->'$.solution.park' = :park";
sqlCount = sqlCount+" and solutionContent->'$.solution.park' = :park"; sqlCount = sqlCount+" and solutionContent->'$.solution.park' = :park";
...@@ -329,52 +360,59 @@ class NeedsolutionService extends ServiceBase { ...@@ -329,52 +360,59 @@ class NeedsolutionService extends ServiceBase {
return system.getResultSuccess(); return system.getResultSuccess();
} }
// //立即支付下单保存方案 //立即支付下单保存方案
// async createSolutionByOrder(pobj){ async createSolutionByOrder(pobj){
// var ab = pobj.actionBody; var ab = pobj.actionBody;
// var app = pobj.appInfo; var app = pobj.appInfo;
// if(!app || !app.uapp_id){ if(!app || !app.uapp_id){
// return system.getResultFail(-100,"未知渠道"); return system.getResultFail(-100,"未知渠道");
// } }
// if(!ab.solutionBizid){ if(!ab.solutionBizid){
// return system.getResultFail(-101,"需求编号不能为空"); return system.getResultFail(-101,"需求编号不能为空");
// } }
// var needinfo = await this.needinfoDao.model.findOne({ var needinfo = await this.needinfoDao.model.findOne({
// where:{channelNeedNo:ab.intentionBizId,uapp_id:app.uapp_id},raw:true where:{channelNeedNo:ab.intentionBizId,uapp_id:app.uapp_id},raw:true
// }); });
// if(!needinfo || !needinfo.id){ if(!needinfo || !needinfo.id){
// return system.getResultFail(-102,"未知需求信息"); return system.getResultFail(-102,"未知需求信息");
// } }
// var solution = { var solution = "";
// "companyName":ab.companyName, var bizType = "esp.companyreg";
// "area":ab.area, if(ab.companyName){
// "city": ab.city, solution = {
// "companyCategory": ab.companyCategory, "companyName":ab.companyName,
// "companyType": ab.companyType, "area":ab.area,
// "orgType" :ab.orgType, "city": ab.city,
// "industryType": ab,industryType, "companyCategory": ab.companyCategory,
// "scope": ab.scope, "companyType": ab.companyType,
// "remark":ab.remark "orgType" :ab.orgType,
// }; "industryType": ab,industryType,
// var { "scope": ab.scope,
// "notes":"方案备注", "remark":ab.remark
// "bizType":"companyreg", };
// "solution":{ }else if(ab.park){
// "area":"区", solution = {
// "city":"市", "park":ab.park,
// "scope":"经营范围", "productType":ab.productType,
// "remark":"方案备注", "remark":ab.remark
// "orgType":"组织类型", };
// "companyName":"测试公司名称", bizType = "esp.companyreg_cloud";
// "companyType":"公司性质", }
// "industryType":"行业", var solutionContent = {
// "companyCategory":"纳税人类型" "bizType":bizType,
// } "solution":solution
// } };
// var reqObj = { solutionContent = JSON.stringify(solutionContent);
// ab["channelNeedNo"] = needinfo.channelNeedNo;
// } // ab["solutionNo"] = solutionNo;
// } var solutionNo = await this.getBusUid("ns");
var reqObj = {
solutionContent:solutionContent,solutionNo:solutionNo,status:"ywc",needNo:needinfo.needNo,
channelNeedNo:needinfo.channelNeedNo,orderNo:ab.orderNo,createUserId:needinfo.followManUserId
};
await this.dao.create(reqObj);
return system.getResultSuccess();
}
} }
module.exports = NeedsolutionService; module.exports = NeedsolutionService;
...@@ -391,4 +429,4 @@ module.exports = NeedsolutionService; ...@@ -391,4 +429,4 @@ module.exports = NeedsolutionService;
// industryType // industryType
// scope // scope
// remark // remark
// solutionBizid // solutionBizidchannelNeedNo
\ No newline at end of file \ No newline at end of file
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