Commit 4eccce74 by 庄冰

ic3

parent 882a6fa4
......@@ -37,6 +37,9 @@ class IcAPI extends APIBase {
case "receiveProgrammeNo"://接收方案编号(方案推送至阿里后,接收保存方案信息)
opResult = await this.needsolutionSve.receiveProgrammeNo(pobj);
break;
case "getProgrammeListByUser"://获取方案列表(获取用户所有方案)
opResult = await this.needsolutionSve.getProgrammeListByUser(pobj);
break;
case "getProgrammeInfoByNeedNo"://根据需求查看方案列表
opResult = await this.needsolutionSve.getProgrammeInfoByNeedNo(pobj);
break;
......
......@@ -75,6 +75,11 @@ class NeedsolutionService extends ServiceBase {
//根据需求查看方案列表
async getProgrammeInfoByNeedNo(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){
......@@ -88,17 +93,85 @@ class NeedsolutionService extends ServiceBase {
// }
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where:{needNo:ab.needNo,followManOnlyCode:ab.followManOnlyCode},raw:true
where:{needNo:ab.needNo},raw:true
});
if(!needinfo || !needinfo.id){
return system.getResultFail(-102,"未知需求信息");
}
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"]
});
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(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){
var ab = pobj.actionBody;
......@@ -161,5 +234,7 @@ class NeedsolutionService extends ServiceBase {
}
}
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