Commit fdc1669c by 王栋源

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

parents 0765a212 c0cf194a
...@@ -39,6 +39,9 @@ class IcAPI extends APIBase { ...@@ -39,6 +39,9 @@ class IcAPI extends APIBase {
case "receiveProgrammeNo"://接收方案编号(方案推送至阿里后,接收保存方案信息) case "receiveProgrammeNo"://接收方案编号(方案推送至阿里后,接收保存方案信息)
opResult = await this.needsolutionSve.receiveProgrammeNo(pobj); opResult = await this.needsolutionSve.receiveProgrammeNo(pobj);
break; break;
case "getProgrammeListByUser"://获取方案列表(获取用户所有方案)
opResult = await this.needsolutionSve.getProgrammeListByUser(pobj);
break;
case "getProgrammeInfoByNeedNo"://根据需求查看方案列表 case "getProgrammeInfoByNeedNo"://根据需求查看方案列表
opResult = await this.needsolutionSve.getProgrammeInfoByNeedNo(pobj); opResult = await this.needsolutionSve.getProgrammeInfoByNeedNo(pobj);
break; break;
......
...@@ -72,7 +72,7 @@ module.exports = { ...@@ -72,7 +72,7 @@ module.exports = {
"push_chance_type": { "wts": "未推送", "yts": "已推送", "ygj": "已跟进", "ycd": "已成单","ygb" :"已关闭"}, "push_chance_type": { "wts": "未推送", "yts": "已推送", "ygj": "已跟进", "ycd": "已成单","ygb" :"已关闭"},
"policy_type":{'fzbt':'租金减免','jrdk':'金融贷款','zdfc':'行政措施','ssjm':'税收优惠','rlzy':'人力资源'}, "policy_type":{'fzbt':'租金减免','jrdk':'金融贷款','zdfc':'行政措施','ssjm':'税收优惠','rlzy':'人力资源'},
"customer_intention":{"dgj":"待跟进","yyx":"有意向","wyx":"无意向"}, "customer_intention":{"dgj":"待跟进","yyx":"有意向","wyx":"无意向"},
"solution_status":{"ytj":"已提交","yfk":"已付款","yzf":"已作废","ytk":"已退款"}, "solution_status":{"dqr":"待确认","ywc":"已完成","yzf":"已作废"},
}, },
} }
......
...@@ -20,6 +20,7 @@ module.exports = (db, DataTypes) => { ...@@ -20,6 +20,7 @@ module.exports = (db, DataTypes) => {
} }
}, },
statusName: DataTypes.STRING(50), //状态名称 statusName: DataTypes.STRING(50), //状态名称
createUserId: DataTypes.INTEGER, //创建者id
}, { }, {
paranoid: true,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
......
...@@ -12,6 +12,11 @@ class NeedsolutionService extends ServiceBase { ...@@ -12,6 +12,11 @@ class NeedsolutionService extends ServiceBase {
//提交方案 //提交方案
async submitProgramme(pobj){ async submitProgramme(pobj){
var ab = pobj.actionBody; var ab = pobj.actionBody;
var user = pobj.userInfo;
if(!user || !user.id){
return system.getResultFail(-100,"未知用户");
}
ab["createUserId"]=user.id;
if(!ab.needNo){ if(!ab.needNo){
return system.getResultFail(-101,"需求号不能为空"); return system.getResultFail(-101,"需求号不能为空");
} }
...@@ -40,7 +45,7 @@ class NeedsolutionService extends ServiceBase { ...@@ -40,7 +45,7 @@ class NeedsolutionService extends ServiceBase {
ab["channelNeedNo"] = needinfo.channelNeedNo; ab["channelNeedNo"] = needinfo.channelNeedNo;
var solutionNo = await this.getBusUid("ns"); var solutionNo = await this.getBusUid("ns");
ab["solutionNo"] = solutionNo; ab["solutionNo"] = solutionNo;
ab["status"] = "ytj"; ab["status"] = "dqr";
ab.solutionContent = JSON.stringify(ab.solutionContent); ab.solutionContent = JSON.stringify(ab.solutionContent);
var od = await this.dao.create(ab); var od = await this.dao.create(ab);
if(od && od.id){ if(od && od.id){
...@@ -70,9 +75,22 @@ class NeedsolutionService extends ServiceBase { ...@@ -70,9 +75,22 @@ class NeedsolutionService extends ServiceBase {
//根据需求查看方案列表 //根据需求查看方案列表
async getProgrammeInfoByNeedNo(pobj){ async getProgrammeInfoByNeedNo(pobj){
var ab = pobj.actionBody; 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){ if(!ab.needNo){
return system.getResultFail(-101,"需求号不能为空"); 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({ var needinfo = await this.needinfoDao.model.findOne({
where:{needNo:ab.needNo},raw:true where:{needNo:ab.needNo},raw:true
...@@ -81,11 +99,104 @@ class NeedsolutionService extends ServiceBase { ...@@ -81,11 +99,104 @@ class NeedsolutionService extends ServiceBase {
return system.getResultFail(-102,"未知需求信息"); return system.getResultFail(-102,"未知需求信息");
} }
var ns = await this.dao.model.findAll({ var ns = await this.dao.model.findAll({
where:{needNo:ab.needNo},raw:true, where:{needNo:ab.needNo,createUserId:user.id},raw:true,
attributes:["needNo","solutionNo","orderNo","solutionContent","status","statusName"] attributes:["needNo","solutionNo","orderNo","solutionContent","status","statusName"]
}); });
return system.getResultSuccess(ns); return system.getResultSuccess(ns);
} }
//获取方案列表(获取用户所有方案)
async getProgrammeListByUser(pobj){
var ab = pobj.actionBody;
var user = pobj.userInfo;
if(!user || !user.id){
return system.getResultFail(-100,"未知用户");
}
var pageSize = Number(ab.pageSize || 20);
if (pageSize > 500) {
pageSize = 500;
}
var bizType = ab.bizType || "companyreg";// companyreg_cloud
var pageIndex = Number(ab.pageIndex || 1);
var from = pageIndex == 1 ? 0 : Number((pageIndex - 1) * pageSize);
//select * from log where data->'$.id' = 142;
var sql = "select id,needNo,solutionNo,orderNo,solutionContent,status,statusName,created_at from n_need_solution where 1=1 ";
var sqlCount = "select count(1) as dataCount from n_need_solution where 1=1 ";
sql = sql+" and createUserId="+user.id;
sqlCount = sqlCount+" and createUserId="+user.id;
sql = sql+" and solutionContent->'$.bizType' = '"+bizType+"'";
sqlCount = sqlCount+" and solutionContent->'$.bizType' = '"+bizType+"'";
var paramWhere = {};
if (ab.solutionNo) {//方案号
sql += " and solutionNo = :solutionNo";
sqlCount += " and solutionNo = :solutionNo";
paramWhere.solutionNo = ab.solutionNo;
}
if (ab.orderNo) {//服务单号
sql += " and orderNo = :orderNo";
sqlCount += " and orderNo = :orderNo";
paramWhere.orderNo = ab.orderNo;
}
if (ab.status) {//方案状态
sql += " and status = :status";
sqlCount += " and status = :status";
paramWhere.status = ab.status;
}
if(bizType=="companyreg"){//普通公司注册
if (ab.entName) {//企业名称
sql = sql+" and solutionContent->'$.solution.entName' = :entName";
sqlCount = sqlCount+" and solutionContent->'$.solution.entName' = :entName";
paramWhere.entName = ab.entName;
}//
if (ab.organizationType) {//组织类型
sql = sql+" and solutionContent->'$.solution.organizationType' = :organizationType";
sqlCount = sqlCount+" and solutionContent->'$.solution.organizationType' = :organizationType";
paramWhere.organizationType = ab.organizationType;
}
if (ab.entNature) {//公司性质
sql = sql+" and solutionContent->'$.solution.entNature' = :entNature";
sqlCount = sqlCount+" and solutionContent->'$.solution.entNature' = :entNature";
paramWhere.entNature = ab.entNature;
}
if (ab.city) {//城市
sql = sql+" and solutionContent->'$.solution.city' = :city";
sqlCount = sqlCount+" and solutionContent->'$.solution.city' = :city";
paramWhere.city = ab.city;
}
if (ab.province) {//省份
sql = sql+" and solutionContent->'$.solution.province' = :province";
sqlCount = sqlCount+" and solutionContent->'$.solution.province' = :province";
paramWhere.province = ab.province;
}
if (ab.taxpayerType) {//纳税人类型
sql = sql+" and solutionContent->'$.solution.taxpayerType' = :taxpayerType";
sqlCount = sqlCount+" and solutionContent->'$.solution.taxpayerType' = :taxpayerType";
paramWhere.taxpayerType = ab.taxpayerType;
}
}
if(bizType=="companyreg_cloud"){//云上公司注册
if (ab.regPark) {//注册园区
sql = sql+" and solutionContent->'$.solution.regPark' = :regPark";
sqlCount = sqlCount+" and solutionContent->'$.solution.regPark' = :regPark";
paramWhere.regPark = ab.regPark;
}
if (ab.productType) {//产品类型
sql = sql+" and solutionContent->'$.solution.productType' = :productType";
sqlCount = sqlCount+" and solutionContent->'$.solution.productType' = :productType";
paramWhere.productType = ab.productType;
}
}
sql += " order by id desc LIMIT " + pageSize + " OFFSET " + from;
var list = await this.customQuery(sql, paramWhere);
var result = system.getResultSuccess(list);
var tmpResultCount = await this.customQuery(sqlCount, paramWhere);
result.dataCount = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
return result;
}
//接收方案反馈信息(即方案作废) //接收方案反馈信息(即方案作废)
async receiveFeedback(pobj){ async receiveFeedback(pobj){
var ab = pobj.actionBody; var ab = pobj.actionBody;
...@@ -106,13 +217,13 @@ class NeedsolutionService extends ServiceBase { ...@@ -106,13 +217,13 @@ class NeedsolutionService extends ServiceBase {
if(ab.operateType=="INVALID"){// INVALID:作废 if(ab.operateType=="INVALID"){// INVALID:作废
status="yzf"; status="yzf";
}else if(ab.operateType=="REFUND"){// REFUND:退款 }else if(ab.operateType=="REFUND"){// REFUND:退款
status="ytk"; status="yzf";
}else if(ab.operateType=="PAID"){// PAID:支付 }else if(ab.operateType=="PAID"){// PAID:支付
status="yfk"; status="ywc";
}else{ }else{
return system.getResultFail(-104,"操作类型有误"); return system.getResultFail(-104,"操作类型有误");
} }
var solution_status={"ytj":"已提交","yfk":"已付款","yzf":"已作废","ytk":"已退款"}; var solution_status={"dqr":"待确认","ywc":"已完成","yzf":"已作废"};
solutionContent["deliveryStatus"] = status; solutionContent["deliveryStatus"] = status;
solutionContent["deliveryStatusName"] = solution_status[status]; solutionContent["deliveryStatusName"] = solution_status[status];
solutionContent["updated"] = new Date(); solutionContent["updated"] = new Date();
...@@ -129,20 +240,29 @@ class NeedsolutionService extends ServiceBase { ...@@ -129,20 +240,29 @@ class NeedsolutionService extends ServiceBase {
//服务商方案作废 //服务商方案作废
async abolishProgramme(pobj){ async abolishProgramme(pobj){
var ab = pobj.actionBody; var ab = pobj.actionBody;
var user = pobj.userInfo;
if(!user || !user.id){
return system.getResultFail(-100,"未知用户");
}
if(!ab.solutionNo){ if(!ab.solutionNo){
return system.getResultFail(-101,"方案号不能为空"); return system.getResultFail(-101,"方案号不能为空");
} }
//获取方案信息 //获取方案信息
var ns = await this.dao.model.findOne({ var ns = await this.dao.model.findOne({
where:{solutionNo:ab.solutionNo},raw:true where:{solutionNo:ab.solutionNo,createUserId:user.id},raw:true
}); });
if(!ns || !ns.id){ if(!ns || !ns.id){
return system.getResultFail(-102,"未知方案"); return system.getResultFail(-102,"未知方案");
} }
if(ns.status!="dqr"){
return system.getResultFail(-103,"方案状态错误,只能废弃待确认方案");
}
await this.dao.update({id:ns.id,status:"yzf"});//方案废弃 await this.dao.update({id:ns.id,status:"yzf"});//方案废弃
return system.getResultSuccess(); return system.getResultSuccess();
} }
} }
module.exports = NeedsolutionService; module.exports = NeedsolutionService;
\ 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