Commit b739a44e by 庄冰

policy

parent fbc9262c
...@@ -25,6 +25,9 @@ class PolicyAPI extends APIBase { ...@@ -25,6 +25,9 @@ class PolicyAPI extends APIBase {
if (!pobj.userInfo) { if (!pobj.userInfo) {
return system.getResult(system.noLogin, "user no login!"); return system.getResult(system.noLogin, "user no login!");
} }
if (!pobj.appInfo) {
return system.getResult(system.noLogin, "app is null!");
}
} }
var result = await this.opActionProcess(pobj, pobj.actionType, req); var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result; return result;
...@@ -40,7 +43,8 @@ class PolicyAPI extends APIBase { ...@@ -40,7 +43,8 @@ class PolicyAPI extends APIBase {
opResult = this.policyneedSve.submitPolicyNeed(pobj); opResult = this.policyneedSve.submitPolicyNeed(pobj);
break; break;
case "getPolicyNeedList"://获取政策申请列表 case "getPolicyNeedList"://获取政策申请列表
opResult = system.getResult(null, "接口开发中"); // opResult = system.getResult(null, "接口开发中");
opResult = this.policyneedSve.getPolicyNeedList(pobj);
break; break;
case "submitPolicyNeedNotes"://申请信息备注提交 case "submitPolicyNeedNotes"://申请信息备注提交
opResult = system.getResult(null, "接口开发中"); opResult = system.getResult(null, "接口开发中");
......
...@@ -70,6 +70,7 @@ module.exports = { ...@@ -70,6 +70,7 @@ module.exports = {
"direction_type": { "sr": "收", "zc": "支" }, "direction_type": { "sr": "收", "zc": "支" },
"push_return_type": { "0": "推送失败", "1": "推送成功" }, "push_return_type": { "0": "推送失败", "1": "推送成功" },
"policy_type":{'fzbt':'租金减免','jrdk':'金融贷款','zdfc':'扶持措施','ssjm':'税收优惠','rlzy':'人力资源'}, "policy_type":{'fzbt':'租金减免','jrdk':'金融贷款','zdfc':'扶持措施','ssjm':'税收优惠','rlzy':'人力资源'},
"customer_intention":{"dgj":"待跟进","yyx":"有意向","wyx":"无意向"},
}, },
} }
} }
\ No newline at end of file
...@@ -9,13 +9,22 @@ module.exports = (db, DataTypes) => { ...@@ -9,13 +9,22 @@ module.exports = (db, DataTypes) => {
industry :DataTypes.STRING(100),// 行业名称 industry :DataTypes.STRING(100),// 行业名称
region :DataTypes.STRING(100),// 地区 region :DataTypes.STRING(100),// 地区
mobile :DataTypes.STRING(100),// 联系电话 mobile :DataTypes.STRING(100),// 联系电话
policy_id :DataTypes.INTEGER,// 政策id policy_id :DataTypes.INTEGER,// 政策id
policySnapshot :DataTypes.TEXT('long'),// 政策快照 policySnapshot :DataTypes.TEXT('long'),// 政策快照
applyDate :DataTypes.DATE,// 申请日期 applyDate :DataTypes.DATE,// 申请日期
opNotes :DataTypes.TEXT('long'),// 备注 opNotes :DataTypes.TEXT('long'),// 备注
createUserId :DataTypes.INTEGER,// 创建用户id createUserId :DataTypes.INTEGER,// 创建用户id
popularizeUserId :DataTypes.INTEGER,// 推广人id,即业务员id popularizeUserId :DataTypes.INTEGER,// 推广人id,即业务员id
popularizeUserCode :DataTypes.STRING(64),// 推广人帐号 popularizeUserCode :DataTypes.STRING(64),// 推广人帐号
customerIntentionName: DataTypes.STRING(100),// 客户意向
customerIntention :{// "customer_intention":{"dgj":"待跟进","yyx":"有意向","wyx":"无意向"},
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.customer_intention),
set: function (val) {
this.setDataValue("customerIntention", val);
this.setDataValue("customerIntentionName", uiconfig.config.pdict.customer_intention[val]);
}
},
}, { }, {
paranoid: false,//假的删除 paranoid: false,//假的删除
underscored: true, underscored: true,
......
...@@ -24,6 +24,7 @@ class PolicyneedService extends ServiceBase { ...@@ -24,6 +24,7 @@ class PolicyneedService extends ServiceBase {
if(policyinfo && policyinfo.id){ if(policyinfo && policyinfo.id){
paramObj["policySnapshot"] = JSON.stringify(policyinfo); paramObj["policySnapshot"] = JSON.stringify(policyinfo);
paramObj["policy_id"] = obj.policy_id; paramObj["policy_id"] = obj.policy_id;
paramObj["policyName"] = policyinfo.policyName;
} }
} }
paramObj["contacts"] = obj.contacts; paramObj["contacts"] = obj.contacts;
...@@ -38,5 +39,56 @@ class PolicyneedService extends ServiceBase { ...@@ -38,5 +39,56 @@ class PolicyneedService extends ServiceBase {
var policyNeed = await this.dao.create(paramObj); var policyNeed = await this.dao.create(paramObj);
return system.getResultSuccess(); return system.getResultSuccess();
} }
//需求列表
async getPolicyNeedList(pobj){
var user = pobj.userInfo;
var app = pobj.appInfo;
var obj = pobj.actionBody || {};
if(!user || !user.channel_userid){
return system.getResult(null, "未知用户");
}
var pageSize = Number(obj.pageSize || 20);
var pageIndex = Number(obj.pageIndex || 1);
var from = pageIndex == 1 ? 0 : Number((pageIndex - 1) * pageSize);
if (pageSize > 50) {
pageSize = 50;
}
var sql ="select * from "+
"(select id,uapp_id,contacts,customerIntention,customerIntentionName,company,industry,region,mobile,policy_id,applyDate,opNotes,popularizeUserCode "+
"from b_policy_need where uapp_id="+app.uapp_id+" and popularizeUserCode='"+user.channel_userid+"') as need "+
"LEFT JOIN "+
"(select id, policyNo,policyName,policyType,policyTypeName,policySource,policyLinkUrl,"+
"policyDate,policyProvince,policyCity,policyContent from b_policy_info) as policy "+
"on need.policy_id=policy.id where 1=1 ";
// var sql = "SELECT * from b_policy_need where popularizeUserCode='"+user.channel_userid+"' and uapp_id="+app.uapp_id;
if(obj.policyName){
sql=sql+" and policyName like '%"+obj.policyName+"%'";
}
if(obj.policyProvince){
sql=sql+" and policyProvince ='"+obj.policyProvince+"'";
if(obj.policyCity){
sql=sql+" and policyCity ='"+obj.policyCity+"'";
}
}
if(obj.policyType){
sql=sql+" and policyType = '"+obj.policyType+"'";
}
if(obj.customerIntention){
sql=sql+" and customerIntention = '"+obj.customerIntention+"'";
}
sql=sql+" order by need.id desc LIMIT " + pageSize + " OFFSET " + from + "";
console.log(sql);
var sqlCount = "SELECT count(1) as dataCount FROM b_policy_need where " +
" popularizeUserCode='"+user.channel_userid+"' and uapp_id="+app.uapp_id;
var tmpResult = await this.customQuery(sql,{});
var tmpResultCount = await this.customQuery(sqlCount,{});
// if (!tmpResult || tmpResult.length == 0) {
// return system.getResultSuccess(null, "暂无数据");
// }
var result = system.getResultSuccess(tmpResult);
result.dataCount = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
return result;
}
} }
module.exports = PolicyneedService; 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