Commit 52724d3c by 王栋源

wdy

parent 843fcb5d
...@@ -31,13 +31,13 @@ class IcAPI extends APIBase { ...@@ -31,13 +31,13 @@ class IcAPI extends APIBase {
var opResult = null; var opResult = null;
switch (action_type) { switch (action_type) {
case "submitNeed"://提交需求 case "submitNeed"://提交需求
opResult = await this.needinfoSve.submitNeed(pobj); opResult = await this.needinfoSve.submitNeed(pobj,pobj.actionBody,req);
break; break;
case "getItemByNeedNo"://获取需求详情 case "getItemByNeedNo"://获取需求详情
opResult = await this.needinfoSve.getItemByNeedNo(pobj); opResult = await this.needinfoSve.getItemByNeedNo(pobj);
break; break;
case "needClose"://需求关闭 case "needClose"://需求关闭
opResult = await this.needinfoSve.needClose(pobj); opResult = await this.needinfoSve.needClose(pobj,pobj.actionBody,req);
break; break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
......
...@@ -20,13 +20,14 @@ module.exports = (db, DataTypes) => { ...@@ -20,13 +20,14 @@ module.exports = (db, DataTypes) => {
productType_id: DataTypes.STRING,//产品类型Id productType_id: DataTypes.STRING,//产品类型Id
notes: DataTypes.STRING,//备注 notes: DataTypes.STRING,//备注
disposeNotes: DataTypes.STRING,//处理的备注 disposeNotes: DataTypes.STRING,//处理的备注
statusName: DataTypes.STRING,
status: { status: {
//wts未推送,yts已推送,ygj已跟进,ycd已成单 //wts未推送,yts已推送,ygj已跟进,ycd已成单
type: DataTypes.ENUM, type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.push_chance_type), values: Object.keys(uiconfig.config.pdict.push_chance_type),
set: function (val) { set: function (val) {
this.setDataValue("chanceType", val); this.setDataValue("status", val);
this.setDataValue("chanceTypeName", uiconfig.config.pdict.push_chance_type[val]); this.setDataValue("statusName", uiconfig.config.pdict.push_chance_type[val]);
} }
}, },
city: DataTypes.STRING(50), // 城市 city: DataTypes.STRING(50), // 城市
......
...@@ -6,6 +6,7 @@ class NeedinfoService extends ServiceBase { ...@@ -6,6 +6,7 @@ class NeedinfoService extends ServiceBase {
constructor() { constructor() {
super("dbneed", ServiceBase.getDaoName(NeedinfoService)); super("dbneed", ServiceBase.getDaoName(NeedinfoService));
this.execlient = system.getObject("util.execClient"); this.execlient = system.getObject("util.execClient");
this.needsolutionSve = system.getObject("service.dbneed.needsolutionSve");
} }
async getItemByNeedNo(pobj) { async getItemByNeedNo(pobj) {
var item = await this.dao.getItemByNeedNo(pobj.actionBody.needNo); var item = await this.dao.getItemByNeedNo(pobj.actionBody.needNo);
...@@ -45,46 +46,80 @@ class NeedinfoService extends ServiceBase { ...@@ -45,46 +46,80 @@ class NeedinfoService extends ServiceBase {
// area // area
// type // type
// ext // ext
async submitNeed(pobj, actionBody) { async submitNeed(pobj, actionBody, req) {
var needNo = await this.getBusUid("n"); var needNo = await this.getBusUid("n");
if (actionBody.intentionBizId) { if (!actionBody.intentionBizId) {
return system.getResult(null, "intentionBizId不能为空"); return system.getResult(null, "intentionBizId不能为空");
} }
if (actionBody.mobile) { if (!actionBody.mobile) {
return system.getResult(null, "mobile不能为空"); return system.getResult(null, "mobile不能为空");
} }
if (actionBody.type) { if (!actionBody.type) {
return system.getResult(null, "type不能为空"); return system.getResult(null, "type不能为空");
} }
var ninfo = await this.findOne({ channelNeedNo: actionBody.intentionBizId });
if (ninfo) {
return {
"requestId": req.requestId,
"success": true,
"errorMsg": "已存在",
"errorCode": "ok"
};
}
var nobj = { var nobj = {
uapp_id: pobj.appInfo.uapp_id, uapp_id: pobj.appInfo.uapp_id,
channelNeedNo: actionBody.intentionBizId, channelNeedNo: actionBody.intentionBizId,
needNo: needNo, needNo: needNo,
channelUserId: pobj.userInfo.channel_userid, channelUserId: actionBody.mobile,
publishName: actionBody.userName, publishName: actionBody.userName,
publishContent: actionBody.description, publishContent: actionBody.description,
publishMobile: actionBody.mobile, publishMobile: actionBody.mobile,
city: actionBody.area, city: actionBody.area,
disposeNotes: actionBody.ext, // disposeNotes: actionBody.ext,
channelTypeCode: actionBody.type channelTypeCode: actionBody.type,
status: "wts"
} }
return await this.dao.create(nobj); await this.dao.create(nobj);
return {
"requestId": req.requestId,
"success": true,
"errorMsg": "",
"errorCode": "ok"
};
} }
async needClose(pobj) { async needClose(pobj, actionBody, req) {
if (actionBody.intentionBizId) { if (!actionBody.intentionBizId) {
return system.getResult(null, "intentionBizId不能为空"); return system.getResult(null, "intentionBizId不能为空");
} }
var needinfo = await this.findOne({ channelNeedNo: actionBody.intentionBizId }); var needinfo = await this.findOne({ channelNeedNo: actionBody.intentionBizId });
needinfo.status = "ygb"; if (!needinfo) {
var self = this; return {
return await self.db.transaction(async function (t) { "requestId": req.requestId,
await self.update(needinfo, t); "success": false,
var needsolutioninfo = await self.needsolutionDao.findOne({ channelNeedNo: pobj.actionBody.intentionBizId }, t) "errorMsg": "需求不存在",
needsolutioninfo.status = "yzf"; "errorCode": "ok"
await self.needsolutionDao.update(needsolutioninfo, t); };
// await }
}) if (needinfo.status == "ygb" || needinfo.status == "ycd") {
return {
"requestId": req.requestId,
"success": true,
"errorMsg": "需求已关闭",
"errorCode": "ok"
};
} else {
needinfo.status = "ygb";
var self = this;
await self.update(needinfo.dataValues);
await self.needsolutionSve.abolishProgrammeByNeed(pobj);
return {
"requestId": req.requestId,
"success": true,
"errorMsg": "",
"errorCode": "ok"
};
}
} }
async flowinfo(obj) { async flowinfo(obj) {
......
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