Commit a97af938 by 宋毅

tj

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