Commit e06d083d by 宋毅

tj

parent 36106559
......@@ -25,6 +25,9 @@ class PolicyAPI extends APIBase {
if (!pobj.userInfo) {
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);
return result;
......@@ -36,13 +39,15 @@ class PolicyAPI extends APIBase {
opResult = await this.policyinfoSve.policyQuery(pobj);
break;
case "submitPolicyNeed"://政策申请提报
opResult = system.getResult(null, "接口开发中");
// opResult = system.getResult(null, "接口开发中");
opResult = this.policyneedSve.submitPolicyNeed(pobj);
break;
case "getPolicyNeedList"://获取政策申请列表
opResult = system.getResult(null, "接口开发中");
// opResult = system.getResult(null, "接口开发中");
opResult = this.policyneedSve.getPolicyNeedList(pobj);
break;
case "submitPolicyNeedNotes"://申请信息备注提交
opResult = system.getResult(null, "接口开发中");
opResult = this.policyneedSve.submitPolicyNeedNotes(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
......
......@@ -69,7 +69,8 @@ module.exports = {
//凭单类型
"direction_type": { "sr": "收", "zc": "支" },
"push_return_type": { "0": "推送失败", "1": "推送成功" },
"policy_type":{'zh':'综合','fzbt':'房租补贴','jrdk':'金融贷款','zdfc':'重点扶持','ssjm':'税收减免'},
"policy_type":{'fzbt':'租金减免','jrdk':'金融贷款','zdfc':'扶持措施','ssjm':'税收优惠','rlzy':'人力资源'},
"customer_intention":{"dgj":"待跟进","yyx":"有意向","wyx":"无意向"},
},
}
}
\ No newline at end of file
......@@ -9,12 +9,22 @@ module.exports = (db, DataTypes) => {
industry :DataTypes.STRING(100),// 行业名称
region :DataTypes.STRING(100),// 地区
mobile :DataTypes.STRING(100),// 联系电话
policy_id :DataTypes.INTEGER,// 政策id
policy_id :DataTypes.INTEGER,// 政策id
policySnapshot :DataTypes.TEXT('long'),// 政策快照
applyDate :DataTypes.DATE,// 申请日期
opNotes :DataTypes.TEXT('long'),// 备注
createUserId :DataTypes.INTEGER,// 创建用户id
popularizeUserId :DataTypes.INTEGER,// 推广人id,即业务员id
popularizeUserId :DataTypes.INTEGER,// 推广人id,即业务员id
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,//假的删除
underscored: true,
......
......@@ -10,7 +10,7 @@ class PolicyinfoService extends ServiceBase {
var obj = pobj.actionBody;
var app = pobj.appInfo;
var paramObj={uapp_id:app.uapp_id};
var attributes =["policyType","policyTypeName","policyDate","policyContent","policyCity","policyProvince",
var attributes =["id","policyType","policyTypeName","policyDate","policyContent","policyCity","policyProvince",
"policyLinkUrl","policySource","policyName","policyNo"];
if(obj){
if(obj.policyProvince){
......@@ -25,8 +25,8 @@ class PolicyinfoService extends ServiceBase {
console.log(paramObj);
}
var result = {};
//"policy_type":{'zh':'综合','fzbt':'房租补贴','jrdk':'金融贷款','zdfc':'重点扶持','ssjm':'税收减免'},
result["zh"]=await this.findByParams("zh",paramObj,attributes);
//"policy_type":{'fzbt':'租金减免','jrdk':'金融贷款','zdfc':'扶持措施','ssjm':'税收优惠','rlzy':'人力资源'},
result["rlzy"]=await this.findByParams("rlzy",paramObj,attributes);
result["fzbt"]=await this.findByParams("fzbt",paramObj,attributes);
result["jrdk"]=await this.findByParams("jrdk",paramObj,attributes);
result["zdfc"]=await this.findByParams("zdfc",paramObj,attributes);
......
......@@ -3,6 +3,134 @@ const ServiceBase = require("../../sve.base");
class PolicyneedService extends ServiceBase {
constructor() {
super("dbpolicy", ServiceBase.getDaoName(PolicyneedService));
this.policyinfoDao = system.getObject("db.dbpolicy.policyinfoDao");
}
//提交政策需求
async submitPolicyNeed(pobj){
var user = pobj.userInfo;
var app = pobj.appInfo;
var obj = pobj.actionBody;
var paramObj={uapp_id:app.uapp_id};
if(!obj.contacts){
return system.getResult(null, "联系人不能为空");
}
if(!obj.mobile){
return system.getResult(null, "联系电话不能为空");
}
if(obj.policy_id){
var policyinfo = await this.policyinfoDao.model.findOne({
where:{id:obj.policy_id},raw:true
});
if(policyinfo && policyinfo.id){
paramObj["policySnapshot"] = JSON.stringify(policyinfo);
paramObj["policy_id"] = obj.policy_id;
// paramObj["policyName"] = policyinfo.policyName;
}
}
paramObj["contacts"] = obj.contacts;
paramObj["mobile"] = obj.mobile;
paramObj["company"] = obj.company;
paramObj["industry"] = obj.industry;
paramObj["region"] = obj.region;
paramObj["applyDate"] = new Date();
if(obj.popularizeUserCode){
paramObj["popularizeUserCode"] = obj.popularizeUserCode;
}
var policyNeed = await this.dao.create(paramObj);
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;
}
//需求备注提交
async submitPolicyNeedNotes(pobj){
var user = pobj.userInfo;
var app = pobj.appInfo;
var obj = pobj.actionBody || {};
if(!user || !user.channel_userid){
return system.getResult(null, "未知用户");
}
if(!obj.needId){
return system.getResult(null, "需求id不能为空");
}
if(!obj.customerIntention){
return system.getResult(null, "客户意向不能为空");
}
if(!obj.intentionContent){
return system.getResult(null, "意向内容不能为空");
}
var policyneed = await this.dao.model.findOne({
where:{id:obj.needId,uapp_id:app.uapp_id},
raw:true
});
if(!policyneed || !policyneed.id){
return system.getResult(null, "未知政策需求");
}
if(policyneed.popularizeUserCode != user.channel_userid){
return system.getResult(null, "非法操作,只能修改本人数据");
}
var paramObj={id:obj.needId,customerIntention:obj.customerIntention};
var noteparam={customerIntention:obj.customerIntention,intentionContent:obj.intentionContent,submitDate:new Date()};
if(policyneed.opNotes){
var notes = JSON.parse(policyneed.opNotes);
var noteList = notes.data;
noteList.push(noteparam);
paramObj["opNotes"] = JSON.stringify({data:noteList});
}else{
paramObj["opNotes"] = JSON.stringify({data:[noteparam]});
}
var newPolicyNeed = await this.dao.update(paramObj);
return system.getResultSuccess();
}
}
module.exports = PolicyneedService;
示例:----------------------------------开始--------------------------------------------------------------------
示例:----------------------------------开始--------------------------------------------------------------------
......@@ -19,7 +19,7 @@ CREATE TABLE `b_policy_info` (
`uapp_id` int(11) NULL DEFAULT NULL,
`policyNo` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '政策编号',
`policyName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '政策名称',
`policyType` enum('zh','fzbt','jrdk','zdfc','ssjm') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'zh' COMMENT '政策类型 \'zh\':\'综合\',\'fzbt\':\'房租补贴\',\'jrdk\':\'金融贷款\',\'zdfc\':\'重点扶持\',\'ssjm\':\'税收减免\'',
`policyType` enum('rlzy','fzbt','jrdk','zdfc','ssjm') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'zh' COMMENT '政策类型 \'rlzy\':\'人力资源\',\'fzbt\':\'房租补贴\',\'jrdk\':\'金融贷款\',\'zdfc\':\'重点扶持\',\'ssjm\':\'税收减免\'',
`policyTypeName` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '政策类型名称',
`policySource` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '政策出处',
`policyLinkUrl` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '政策链接',
......@@ -53,5 +53,6 @@ CREATE TABLE `b_policy_need` (
`version` int(11) NOT NULL DEFAULT 0,
`createUserId` int(11) NULL DEFAULT NULL COMMENT '创建用户id',
`popularizeUserId` int(11) NULL DEFAULT NULL COMMENT '推广人id,即业务员id',
`popularizeUserCode` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '推广人帐号',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 14 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
\ 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