Commit 5e14e691 by 宋毅

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

parents 70082e7b 0e713377
......@@ -68,6 +68,12 @@ class PolicyAPI extends APIBase {
case "policySubscribeQuery"://政策订阅检索列表(通过订阅信息查询订阅的政策信息)
opResult = this.policysubscribeSve.policySubscribeQuery(pobj);
break;
case "getPolicyBusinessFq"://政策商机(蜂擎)
opResult = this.policyneedSve.getPolicyBusinessFq(pobj);
break;
case "getPolicyNeedInfo"://政策需求信息(icompany)
opResult = this.policyneedSve.getPolicyNeedInfo(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
......@@ -164,5 +164,121 @@ class PolicyneedService extends ServiceBase {
var newPolicyNeed = await this.dao.update(paramObj);
return system.getResultSuccess();
}
//政策商机(蜂擎)
async getPolicyBusinessFq(pobj){
var app = pobj.appInfo;
var obj = pobj.actionBody || {};
var pageSize = Number(obj.pageSize || 20);
var pageIndex = Number(obj.pageIndex || 1);
var from = pageIndex == 1 ? 0 : Number((pageIndex - 1) * pageSize);
if (pageSize > 200) {
pageSize = 200;
}
var sql ="select need.created_at,need.region,need.mobile,need.industry,need.contacts,policy.policyNo,policy.policyName,policy.policyType,policy.policyTypeName,"+
"need.company,need.popularizeUserCode,policy.policyLinkUrl,policy.policyProvince from "+
"(select created_at,id,contacts,company,industry,region,mobile,policy_id,applyDate,opNotes,popularizeUserCode "+
"from b_policy_need where 1=1 ";
var sqlCount ="select count(1) as dataCount from "+
"(select created_at,id,contacts,company,industry,region,mobile,policy_id,applyDate,opNotes,popularizeUserCode "+
"from b_policy_need where 1=1 ";
if(obj.salesmanMobile){
sql=sql+" and popularizeUserCode='"+obj.salesmanMobile+"' ";
sqlCount=sqlCount+" and popularizeUserCode='"+obj.salesmanMobile+"' ";
}
sql=sql+" ) as need "+
"LEFT JOIN "+
"(select id, policyNo,policyName,policyType,policyTypeName,policySource,policyLinkUrl,"+
"policyDate,policyProvince,policyCity from b_policy_info) as policy "+
"on need.policy_id=policy.id where 1=1 ";
sqlCount=sqlCount+" ) as need "+
"LEFT JOIN "+
"(select id, policyNo,policyName,policyType,policyTypeName,policySource,policyLinkUrl,"+
"policyDate,policyProvince,policyCity from b_policy_info) as policy "+
"on need.policy_id=policy.id where 1=1 ";
if(obj.policyName){
sql=sql+" and policyName like '%"+obj.policyName+"%'";
sqlCount=sqlCount+" and policyName like '%"+obj.policyName+"%'";
}
if(obj.policyProvince){
sql=sql+" and policyProvince ='"+obj.policyProvince+"'";
sqlCount=sqlCount+" and policyProvince ='"+obj.policyProvince+"'";
if(obj.policyCity){
sql=sql+" and policyCity ='"+obj.policyCity+"'";
sqlCount=sqlCount+" and policyCity ='"+obj.policyCity+"'";
}
}
if(obj.policyType){
sql=sql+" and policyType = '"+obj.policyType+"'";
sqlCount=sqlCount+" and policyType = '"+obj.policyType+"'";
}
if(obj.customerIntention){
sql=sql+" and customerIntention = '"+obj.customerIntention+"'";
sqlCount=sqlCount+" and customerIntention = '"+obj.customerIntention+"'";
}
if(obj.startDate){
sql=sql+" and created_at >= '"+obj.startDate+"'";
sqlCount=sqlCount+" and created_at >= '"+obj.startDate+"'";
}
if(obj.endDate){
sql=sql+" and created_at <= '"+obj.endDate+"'";
sqlCount=sqlCount+" and created_at <= '"+obj.endDate+"'";
}
sql=sql+" order by need.id desc LIMIT " + pageSize + " OFFSET " + from + "";
console.log(sql);
var tmpResult = await this.customQuery(sql,{});
var tmpResultCount = await this.customQuery(sqlCount,{});
var result = system.getResultSuccess(tmpResult);
result.dataCount = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
return result;
}
//政策需求信息(icompany)
async getPolicyNeedInfo(pobj){
var obj = pobj.actionBody || {};
var pageSize = Number(obj.pageSize || 20);
var pageIndex = Number(obj.pageIndex || 1);
var from = pageIndex == 1 ? 0 : Number((pageIndex - 1) * pageSize);
if (pageSize > 200) {
pageSize = 200;
}
var sql ="select contacts,company,industry,region,mobile,created_at "+
"from b_policy_need where 1=1 ";
var sqlCount ="select count(1) as dataCount from b_policy_need where 1=1 ";
if(obj.contacts){
sql=sql+" and contacts = '"+obj.contacts+"'";
sqlCount=sqlCount+" and contacts = '"+obj.contacts+"'";
}
if(obj.mobile){
sql=sql+" and mobile = '"+obj.mobile+"'";
sqlCount=sqlCount+" and mobile = '"+obj.mobile+"'";
}
if(obj.industry){
sql=sql+" and industry = '"+obj.industry+"'";
sqlCount=sqlCount+" and industry = '"+obj.industry+"'";
}
if(obj.region){
sql=sql+" and region = '"+obj.region+"'";
sqlCount=sqlCount+" and region = '"+obj.region+"'";
}
if(obj.company){
sql=sql+" and company = '"+obj.company+"'";
sqlCount=sqlCount+" and company = '"+obj.company+"'";
}
if(obj.startDate){
sql=sql+" and created_at >= '"+obj.startDate+"'";
sqlCount=sqlCount+" and created_at >= '"+obj.startDate+"'";
}
if(obj.endDate){
sql=sql+" and created_at <= '"+obj.endDate+"'";
sqlCount=sqlCount+" and created_at <= '"+obj.endDate+"'";
}
sql=sql+" order by created_at desc LIMIT " + pageSize + " OFFSET " + from + "";
console.log(sql);
var tmpResult = await this.customQuery(sql,{});
var tmpResultCount = await this.customQuery(sqlCount,{});
var result = system.getResultSuccess(tmpResult);
result.dataCount = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
return result;
}
}
module.exports = PolicyneedService;
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