Commit f10e68f9 by linboxuan

new opNeed

parent b33aba45
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class IcAPI extends APIBase {
constructor() {
super();
this.opNeedInfoSve = system.getObject("service.dbneed.opNeedInfoSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
if (pobj.actionType == 'getPolicyNeedList' || pobj.actionType == 'submitPolicyNeedNotes') {
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;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "submitNeed"://提交需求 2020 0807 lin 新增
opResult = await this.opNeedInfoSve.submitNeed(pobj, pobj.actionBody, req);
break;
case "needList"://需求列表
opResult = await this.opNeedInfoSve.needList(pobj, pobj.actionBody);
break;
case "needClose"://关闭需求
opResult = await this.opNeedInfoSve.needClose(pobj, pobj.actionBody, req);
break;
case "getItemByNeedNo"://获取需求详情
opResult = await this.needinfoSve.getItemByNeedNo(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = IcAPI;
\ No newline at end of file
const uuidv4 = require('uuid/v4');
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
var moment = require('moment')
class NeedinfoService extends ServiceBase {
constructor() {
super("dbneed", ServiceBase.getDaoName(NeedinfoService));
this.execlient = system.getObject("util.execClient");
this.needsolutionSve = system.getObject("service.dbneed.needsolutionSve");
this.needsolutionDao = system.getObject("db.dbneed.needsolutionDao");
this.needinfoDao = system.getObject("db.dbneed.needinfoDao");
}
async getItemByNeedNo(pobj) {
var item = await this.dao.getItemByNeedNo(pobj.actionBody.needNo);
console.log(system.getResultSuccess(item));
if (!item) {
return system.getResult(null, "需求数据为空,30210");
}
return system.getResultSuccess(item);
}
async submitNeed(pobj, actionBody, req) {
var needNo = await this.getBusUid("n");
if (!actionBody.mobile) {
return system.getResultFail(-5002, "mobile不能为空");
}
if (!actionBody.type) {
return system.getResultFail(-5003, "type不能为空");
}
var nobj = {
uapp_id: pobj.appInfo.uapp_id,
channelNeedNo: needNo, // 2020 0807 lin 修改内容 渠道需求号改为企服通需求号 不再单独获取新的uuid
needNo: needNo,
channelUserId: pobj.userInfo.channel_userid,
publishName: actionBody.userName,
publishContent: actionBody.description,
publishMobile: actionBody.mobile,
city: actionBody.area,
typeCode: actionBody.type_code,
typeName: actionBody.type_name,
channelTypeCode: actionBody.channel_type_code,
channelTypeName: actionBody.channel_type_name,
status: "wts"
}
await this.dao.create(nobj);
return system.getResultSuccess();
}
async needClose(pobj, actionBody, req) {
var needinfo = await this.findOne({ channelNeedNo: actionBody.needNo });
if (!needinfo) {
return system.getResultFail(-5004, "需求不存在");
}
if (needinfo.status == "ygb" || needinfo.status == "ycd") {
return system.getResultSuccess();
} else {
needinfo.status = "ygb";
var self = this;
await self.update(needinfo.dataValues);
return system.getResultSuccess();
}
}
}
module.exports = NeedinfoService;
// var a=new NeedinfoService();
// var b=a.getItemByChannelSolutionNo({actionBody:{bizId:"1593141330846"}});
\ 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