Commit 5361c981 by 兰国旗

laolan

parents 5fea7370 f1d87f1f
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class ediApi extends APIBase {
constructor() {
super();
this.orderinfoSve = system.getObject("service.dbcorder.orderinfoSve");
this.needinfoSve = system.getObject("service.dbneed.needinfoSve");
this.aliyunqcSve = system.getObject("service.qcutils.aliyunqcSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "produceNoticeAliEsp":// uk后端订单拉取功能
opResult = await this.needinfoSve.produceNoticeAliEsp(pobj,pobj.actionBody);
break;
case "receiveEdiStatusNotify"://接收渠道方案状态变更通知2.3
opResult = await this.aliyunqcSve.receiveEdiStatusNotify(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = ediApi;
\ No newline at end of file
......@@ -70,7 +70,7 @@ class NeedinfoService extends ServiceBase {
}
var ninfo = await this.findOne({ channelNeedNo: actionBody.intentionBizId });
if (ninfo) {
return system.getResultSuccess();
return system.getResultSuccess(ninfo);
}
var nobj = {
uapp_id: pobj.appInfo.uapp_id,
......@@ -175,6 +175,8 @@ class NeedinfoService extends ServiceBase {
}
var item = await this.dao.getItemByNeedNo(solutionitem.needNo);
item.solutionProvince = solutionitem.solutionContent.solution.Area;
item.solutionContent = solutionitem.solutionContent
item.channelSolutionNo = solutionitem.channelSolutionNo
if (!item) {
return system.getResult(null, "需求数据为空,30210");
}
......@@ -295,20 +297,38 @@ class NeedinfoService extends ServiceBase {
return system.getResultSuccess();
}
}
async getUnCreated (pobj, data, req) {
let stdate = new Date(pobj.actionBody.Begin);
let enddate = new Date(pobj.actionBody.End );
let query = {where:{}};
query.where["created_at"] = { [this.db.Op.between]: [stdate, enddate] };
try {
let res = await this.dao.model.findAndCountAll(query);
res = res.rows.map(n=>n.channelNeedNo);
res = pobj.actionBody.data.filter(ali=>!res.includes(ali.BizId));
return system.getResultSuccess(res)
} catch (error) {
return system.getResultFail(-1, error.message)
}
async getUnCreated (pobj, data, req) {
let stdate = new Date(pobj.actionBody.Begin);
let enddate = new Date(pobj.actionBody.End );
let query = {where:{}};
query.where["created_at"] = { [this.db.Op.between]: [stdate, enddate] };
try {
let res = await this.dao.model.findAndCountAll(query);
res = res.rows.map(n=>n.channelNeedNo);
res = pobj.actionBody.data.filter(ali=>!res.includes(ali.BizId));
return system.getResultSuccess(res)
} catch (error) {
return system.getResultFail(-1, error.message)
}
}
async produceNoticeAliEsp (pobj, actionBody) {
switch (actionBody.operationType) {
case "USER_PAY_PRODUCE":
break;
case "USER_PAY_PRODUCE":
break;
case "USER_PAY_PRODUCE":
break;
case "USER_PAY_PRODUCE":
break;
case "USER_PAY_PRODUCE":
break;
default:
return system.getResult(null, "operationType参数错误");
}
}
}
module.exports = NeedinfoService;
......
......@@ -17,6 +17,28 @@ class AliyunQcService {
GXB_ACCEPT: "⼯信部已受理", GXB_REFUSE: "⼯信部不予受理", GXB_FAIL: "⼯信部未通过", GXB_SUCCESS: "工信部通过"
, CLOSE: "方案关闭"
};
this.ediSolutionStatusReference = {
SOLUTION_SUBMIT: "服务单通知服务商",
USER_PAY_PRODUCE: "⽤户⽀付",
USER_CONFIRM_PRODUCE: "⽤户确认资料",
USER_REFUSE_PRODUCE: "资料退回修改",
ABC_CLOSE_PRODUCE: "⼩⼆后台关闭服务单",
USER_UPLOAD_PRODUCE: "⽤户补充基本资料"
};
this.ediProduceStatus = {
110: "⽤户⽀付",
30: "待⽤户确认",
105: "账户已注册",
35: "待提交审核",
109: "管局已通过",
106: "材料已递交⼯信部",
10: "已⽀付",
108: "管局不予受理",
0: "初始状态",
50: "订单关闭",
25: "待⽤户提交材料",
107: "管局已受理"
};
this.icpApplicationStatusReference = {
507: "完成账户注册",
508: "服务商完成提交资料到⼯信部",
......@@ -900,6 +922,98 @@ class AliyunQcService {
return uuid.join('');
}
//接收渠道方案状态变更通知
async receiveEdiStatusNotify(pobj) {
var ab = pobj.actionBody;
if (!ab.BizId) {
return system.getResultFail(-101, "渠道方案号不能为空");
}
if (!ab.operationType) {
return system.getResultFail(-102, "方案状态不能为空");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where: { channelSolutionNo: ab.BizId ,isInvalid:0}, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-102, "未知方案");
}
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: ns.needNo }, raw: true
});
if (!needinfo) {
return system.getResultFail(-104, "未知方案需求");
}
if (needinfo.status == "ygb") {
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
var solutionContent = ns.solutionContent;
var checkStatus = {ABC_CLOSE_PRODUCE: "⼩⼆后台关闭服务单"};
if(solutionContent.status && checkStatus[solutionContent.status]){
return system.getResultFail(-111, "方案已进入"+solutionContent.statusName+"流程,不能执行此操作");
}
//方案流程列表
var solutionFlowList = solutionContent.solutionFlowList || [];
if (ab.operationType == "USER_PAY_PRODUCE") {//⽤户已支付
solutionFlowList.push({
status: "USER_PAY_PRODUCE", statusName: this.ediSolutionStatusReference.USER_PAY_PRODUCE, updated_at: new Date()
});
solutionContent.status = "USER_PAY_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.USER_PAY_PRODUCE;
// 2020 0826 lin修改 n_need_info status为ycd 已成单
let needObj = {
id: needinfo.id, status: "ycd"
}
await this.needinfoDao.update(needObj);//关闭需求
}else if (ab.operationType == "USER_CONFIRM_PRODUCE") {//⽤户确认资料
solutionFlowList.push({
status: "USER_CONFIRM_PRODUCE", statusName: this.ediSolutionStatusReference.USER_CONFIRM_PRODUCE, updated_at: new Date()
});
solutionContent.status = "USER_CONFIRM_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.USER_CONFIRM_PRODUCE;
}else if (ab.operationType == "USER_REFUSE_PRODUCE") {//资料退回修改
solutionFlowList.push({
status: "USER_REFUSE_PRODUCE", statusName: this.ediSolutionStatusReference.USER_REFUSE_PRODUCE, updated_at: new Date()
});
solutionContent.status = "USER_REFUSE_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.USER_REFUSE_PRODUCE;
}else if (ab.operationType == "USER_UPLOAD_PRODUCE") {//⽤户补充基本资料
solutionFlowList.push({
status: "USER_UPLOAD_PRODUCE", statusName: this.ediSolutionStatusReference.USER_UPLOAD_PRODUCE, updated_at: new Date()
});
solutionContent.status = "USER_UPLOAD_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.USER_UPLOAD_PRODUCE;
}else if (ab.operationType == "ABC_CLOSE_PRODUCE") {//⽅案已关闭
solutionFlowList.push({
status: "ABC_CLOSE_PRODUCE", statusName: this.ediSolutionStatusReference.ABC_CLOSE_PRODUCE, updated_at: new Date()
});
solutionContent.status = "ABC_CLOSE_PRODUCE";
solutionContent.statusName = this.ediSolutionStatusReference.ABC_CLOSE_PRODUCE;
}else{
return system.getResultFail(-110, "状态错误");
}
solutionContent.solutionFlowList = solutionFlowList;
var material = solutionContent.customerMaterial || {};
if (ab.extInfo) {
material.businessLicenseArr = ab.extInfo.businessLicenseArr;
material.idCardListArr = ab.idCardListArr;
}
solutionContent.customerMaterial = material;
solutionContent = JSON.stringify(solutionContent);
var updateObj = {
id: ns.id, solutionContent: solutionContent
};
if (ab.operationType == "ABC_CLOSE_PRODUCE") {//⽅案已关闭
updateObj["status"] = "yzf";
updateObj["isInvalid"]=1;
}
await this.needsolutionDao.update(updateObj);//方案状态修改
var new_ns = await this.needsolutionDao.model.findOne({
where: { id: ns.id }, raw: true
});
return system.getResultSuccess(new_ns);
}
/**
* 服务商提交服务操作
......
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