Commit a9349f03 by 王栋源

Merge branch 'center-order' of gitlab.gongsibao.com:jiangyong/zhichan into center-order

parents 60cf842f b282c988
...@@ -33,36 +33,36 @@ class IcpAPI extends APIBase { ...@@ -33,36 +33,36 @@ class IcpAPI extends APIBase {
async opActionProcess(pobj, action_type, req) { async opActionProcess(pobj, action_type, req) {
var opResult = null; var opResult = null;
switch (action_type) { switch (action_type) {
case "submitIcpProgramme"://icp方案提交 // case "submitIcpProgramme"://icp方案提交
opResult = await this.needsolutionSve.submitIcpProgramme(pobj); // opResult = await this.needsolutionSve.submitIcpProgramme(pobj);
break; // break;
case "submitIcpMaterial"://icp材料提交 // case "submitIcpMaterial"://icp材料提交
opResult = await this.needsolutionSve.submitIcpMaterial(pobj); // opResult = await this.needsolutionSve.submitIcpMaterial(pobj);
break; // break;
case "acceptIcpPartnerNotification"://icp通知状态变更 // case "acceptIcpPartnerNotification"://icp通知状态变更
opResult = await this.needsolutionSve.acceptIcpPartnerNotification(pobj); // opResult = await this.needsolutionSve.acceptIcpPartnerNotification(pobj);
break; // break;
case "abolishIcpProgramme"://服务商icp方案关闭 // case "abolishIcpProgramme"://服务商icp方案关闭
opResult = await this.needsolutionSve.abolishIcpProgramme(pobj); // opResult = await this.needsolutionSve.abolishIcpProgramme(pobj);
break; // break;
case "getIcpProgrammeDetail"://获取icp方案 // case "getIcpProgrammeDetail"://获取icp方案
opResult = await this.needsolutionSve.getIcpProgrammeDetail(pobj); // opResult = await this.needsolutionSve.getIcpProgrammeDetail(pobj);
break; // break;
case "getNeedSolutionDetailByUser"://获取方案详情 // case "getNeedSolutionDetailByUser"://获取方案详情
opResult = await this.needsolutionSve.getNeedSolutionDetailByUser(pobj); // opResult = await this.needsolutionSve.getNeedSolutionDetailByUser(pobj);
break; // break;
case "receiveIcpStatusNotify"://接收渠道方案状态变更通知 // case "receiveIcpStatusNotify"://接收渠道方案状态变更通知
opResult = await this.needsolutionSve.receiveIcpStatusNotify(pobj); // opResult = await this.needsolutionSve.receiveIcpStatusNotify(pobj);
break; // break;
case "receiveIcpFeedback"://接收icp用户方案反馈 // case "receiveIcpFeedback"://接收icp用户方案反馈
opResult = await this.needsolutionSve.receiveIcpFeedback(pobj); // opResult = await this.needsolutionSve.receiveIcpFeedback(pobj);
break; // break;
case "getIcpProgrammeDetail"://获取方案详情(内部调用) // case "getIcpProgrammeDetail"://获取方案详情(内部调用)
opResult = await this.needsolutionSve.getIcpProgrammeDetail(pobj); // opResult = await this.needsolutionSve.getIcpProgrammeDetail(pobj);
break; // break;
case "getProgrammeInfoByChannelNeedNo"://获取需求方案列表 // case "getProgrammeInfoByChannelNeedNo"://获取需求方案列表
opResult = await this.needsolutionSve.getProgrammeInfoByChannelNeedNo(pobj); // opResult = await this.needsolutionSve.getProgrammeInfoByChannelNeedNo(pobj);
break; // break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
break; break;
......
...@@ -48,6 +48,9 @@ class IcAPI extends APIBase { ...@@ -48,6 +48,9 @@ class IcAPI extends APIBase {
case "getItemByChannelSolutionNo"://渠道方案号获取需求详情 case "getItemByChannelSolutionNo"://渠道方案号获取需求详情
opResult = await this.needinfoSve.getItemByChannelSolutionNo(pobj, pobj.actionBody, req); opResult = await this.needinfoSve.getItemByChannelSolutionNo(pobj, pobj.actionBody, req);
break; break;
case "writeCommunicationLog"://渠道方案号获取需求详情
opResult = await this.needinfoSve.writeCommunicationLog(pobj, pobj.actionBody, req);
break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
break; break;
......
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class QcAPI extends APIBase {
constructor() {
super();
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参数不能为空");
}
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 "receiveProgrammeNo"://接收方案编号(方案推送至阿里后,接收保存方案信息)
opResult = await this.aliyunqcSve.receiveProgrammeNo(pobj);
break;
case "submitIcpProgramme"://icp方案提交
opResult = await this.aliyunqcSve.submitIcpProgramme(pobj);
break;
// case "submitIcpMaterial"://icp材料提交
// opResult = await this.aliyunqcSve.submitIcpMaterial(pobj);
// break;
case "acceptIcpPartnerNotification"://icp通知状态变更
opResult = await this.aliyunqcSve.acceptIcpPartnerNotification(pobj);
break;
case "abolishIcpProgramme"://服务商icp方案关闭
opResult = await this.aliyunqcSve.abolishIcpProgramme(pobj);
break;
case "getIcpProgrammeDetail"://获取icp方案
opResult = await this.aliyunqcSve.getIcpProgrammeDetail(pobj);
break;
case "getNeedSolutionDetailByUser"://获取方案详情
opResult = await this.aliyunqcSve.getNeedSolutionDetailByUser(pobj);
break;
case "receiveIcpStatusNotify"://接收渠道方案状态变更通知2.3
opResult = await this.aliyunqcSve.receiveIcpStatusNotify(pobj);
break;
case "receiveIcpFeedback"://接收icp用户方案反馈2.2
opResult = await this.aliyunqcSve.receiveIcpFeedback(pobj);
break;
case "getIcpProgrammeDetail"://获取方案详情(内部调用)
opResult = await this.aliyunqcSve.getIcpProgrammeDetail(pobj);
break;
case "getProgrammeInfoByChannelNeedNo"://获取需求方案列表
opResult = await this.aliyunqcSve.getProgrammeInfoByChannelNeedNo(pobj);
break;
case "serviceProviderSubmitMaterial"://交付商提交材料信息
opResult = await this.aliyunqcSve.serviceProviderSubmitMaterial(pobj);
break;
case "serviceProviderNotification"://交付商通知状态变更
opResult = await this.aliyunqcSve.serviceProviderNotification(pobj);
break;
case "closeOrderDelivery"://交付商关闭交付单
opResult = await this.aliyunqcSve.closeOrderDelivery(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = QcAPI;
\ No newline at end of file
const system = require("../../../system"); const system = require("../../../system");
const Dao = require("../../dao.base"); const Dao = require("../../dao.base");
class OrderdeliveryofficialDao extends Dao { class OrderOfficialDao extends Dao {
constructor() { constructor() {
super(Dao.getModelName(OrderdeliveryofficialDao)); super(Dao.getModelName(OrderOfficialDao));
} }
} }
module.exports = OrderdeliveryofficialDao; module.exports = OrderOfficialDao;
...@@ -73,7 +73,7 @@ module.exports = { ...@@ -73,7 +73,7 @@ module.exports = {
"push_chance_type": { "wts": "未推送", "yts": "已推送", "ygj": "已跟进", "ycd": "已成单", "ygb": "已关闭" }, "push_chance_type": { "wts": "未推送", "yts": "已推送", "ygj": "已跟进", "ycd": "已成单", "ygb": "已关闭" },
"policy_type": { 'fzbt': '租金减免', 'jrdk': '金融贷款', 'zdfc': '行政措施', 'ssjm': '税收优惠', 'rlzy': '人力资源' }, "policy_type": { 'fzbt': '租金减免', 'jrdk': '金融贷款', 'zdfc': '行政措施', 'ssjm': '税收优惠', 'rlzy': '人力资源' },
"customer_intention": { "dgj": "待跟进", "yyx": "有意向", "wyx": "无意向" }, "customer_intention": { "dgj": "待跟进", "yyx": "有意向", "wyx": "无意向" },
"solution_status": { "dqr": "待确认", "ywc": "已完成", "yzf": "已作废" }, "solution_status": { "dqr": "待确认","ybh":"用户驳回", "ywc": "已完成", "yzf": "已作废" },
}, },
} }
......
...@@ -2,8 +2,8 @@ const system = require("../../../system"); ...@@ -2,8 +2,8 @@ const system = require("../../../system");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey); const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("orderOfficial", { return db.define("orderofficial", {
sourceNo: DataTypes.STRING(128), // 订单号 serviceNo: DataTypes.STRING(128), // 订单号
channelUserId: DataTypes.STRING(128), // 用户id channelUserId: DataTypes.STRING(128), // 用户id
officialInfo: DataTypes.JSON // 官文信息 officialInfo: DataTypes.JSON // 官文信息
}, { }, {
...@@ -12,7 +12,7 @@ module.exports = (db, DataTypes) => { ...@@ -12,7 +12,7 @@ module.exports = (db, DataTypes) => {
version: true, version: true,
freezeTableName: true, freezeTableName: true,
timestamps: true, timestamps: true,
updatedAt: true, updated_at: true,
tableName: 'c_delivery_official', tableName: 'c_delivery_official',
validate: { validate: {
......
...@@ -21,6 +21,7 @@ module.exports = (db, DataTypes) => { ...@@ -21,6 +21,7 @@ module.exports = (db, DataTypes) => {
}, },
statusName: DataTypes.STRING(50), //状态名称 statusName: DataTypes.STRING(50), //状态名称
createUserId: DataTypes.INTEGER, //创建者id createUserId: DataTypes.INTEGER, //创建者id
isInvalid:DataTypes.INTEGER, //是否废弃的无效的方案
}, { }, {
paranoid: true,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
......
const system = require("../../../system"); const system = require("../../../system");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
const ServiceBase = require("../../sve.base"); const ServiceBase = require("../../sve.base");
const uuidv4 = require('uuid/v4');
class OrderInfoService extends ServiceBase { class OrderInfoService extends ServiceBase {
constructor() { constructor() {
...@@ -11,7 +9,7 @@ class OrderInfoService extends ServiceBase { ...@@ -11,7 +9,7 @@ class OrderInfoService extends ServiceBase {
this.orderproductDao = system.getObject("db.dbcorder.orderproductDao"); this.orderproductDao = system.getObject("db.dbcorder.orderproductDao");
this.ordercontactsDao = system.getObject("db.dbcorder.ordercontactsDao"); this.ordercontactsDao = system.getObject("db.dbcorder.ordercontactsDao");
this.orderReceiptVoucherDao = system.getObject("db.dbcpay.orderreceiptvoucherDao"); this.orderReceiptVoucherDao = system.getObject("db.dbcpay.orderreceiptvoucherDao");
this.officialDao = system.getObject("db.dbcorder.orderdeliveryofficialDao"); this.officialDao = system.getObject("db.dbcorder.orderofficialDao");
this.centerChannelUrl = settings.centerChannelUrl(); this.centerChannelUrl = settings.centerChannelUrl();
} }
...@@ -180,23 +178,12 @@ class OrderInfoService extends ServiceBase { ...@@ -180,23 +178,12 @@ class OrderInfoService extends ServiceBase {
const applyUser = actionBody.deliveryData.applyUser; const applyUser = actionBody.deliveryData.applyUser;
//复审证据材料 //复审证据材料
const askForData = actionBody.deliveryData.askForData; const askForData = actionBody.deliveryData.askForData;
//商标驳回信息
const trademarkRejInfo = actionBody.deliveryData.trademarkRejInfo;
//补充材料
const supData = actionBody.deliveryData.supData;
//申请信息校验 //申请信息校验
let re1 = await this.checkApply(apply); let re1 = await this.checkApply(apply);
if (re1.status != 0) { if (re1.status != 0) {
return re1; return re1;
} }
//商标驳回信息校验
let re2= await this.checkRejInfo(trademarkRejInfo);
if (re2.status != 0) {
return re2;
}
if (Object.keys(applyUser).length === 0 || Object.keys(askForData).length === 0) { if (Object.keys(applyUser).length === 0 || Object.keys(askForData).length === 0) {
var deliveryStatusName = "待完善材料"; var deliveryStatusName = "待完善材料";
var recDate = ""; var recDate = "";
...@@ -206,7 +193,6 @@ class OrderInfoService extends ServiceBase { ...@@ -206,7 +193,6 @@ class OrderInfoService extends ServiceBase {
var recDate = deliveryData.reDate || ""; var recDate = deliveryData.reDate || "";
var askforDate = deliveryData.askforDate || ""; var askforDate = deliveryData.askforDate || "";
} }
pobj.actionBody.deliveryData.deliveryStatusName = deliveryStatusName; pobj.actionBody.deliveryData.deliveryStatusName = deliveryStatusName;
pobj.actionBody.deliveryData.reDate = recDate; pobj.actionBody.deliveryData.reDate = recDate;
pobj.actionBody.deliveryData.askforDate = askforDate; pobj.actionBody.deliveryData.askforDate = askforDate;
...@@ -221,28 +207,38 @@ class OrderInfoService extends ServiceBase { ...@@ -221,28 +207,38 @@ class OrderInfoService extends ServiceBase {
* @param orderNo * @param orderNo
*/ */
addOrderDelivery(data, orderNo) { addOrderDelivery(data, orderNo) {
var sql = "INSERT INTO `c_order_delivery` (`sourceOrderNo`,`deliveryContent`) VALUE('" + try{
orderNo + "','" + JSON.stringify(data) + "')"; var sql = "INSERT INTO `c_order_delivery` (`sourceOrderNo`,`deliveryContent`) VALUE('" +
this.customQuery(sql); orderNo + "','" + JSON.stringify(data) + "')";
this.customQuery(sql);
return system.getResultSuccess();
}catch (e) {
return system.getResultFail();
}
} }
/** /**
* 修改交付信息并推送到交付中心 * 修改交付信息
* @param pobj * @param pobj
* @param actionBody * @param actionBody
* @returns {Promise<{msg: *, data: (*|null), status: number}>} * @returns {Promise<{msg: *, data: (*|null), status: number}>}
*/ */
async submitReview(pobj, actionBody) { async submitReview(pobj, actionBody) {
var packagingTmResult = await this.packagingTmReDeliveryData(pobj, pobj.actionBody); try{
if (packagingTmResult.status != 0) { var packagingTmResult = await this.packagingTmReDeliveryData(pobj, pobj.actionBody);
return packagingTmResult; if (packagingTmResult.status != 0) {
return packagingTmResult;
}
const orderNo = actionBody.orderNo;
const deliveryData = JSON.stringify(pobj.actionBody.deliveryData);
let sql = `UPDATE c_order_delivery SET deliveryContent ='${deliveryData}' where sourceOrderNo='${orderNo}'`;
sql = sql.replace('\n', '');
const result = await this.customUpdate(sql);
return system.getResultSuccess();
}catch (e) {
return system.getResultFail();
} }
const orderNo = actionBody.orderNo;
const deliveryData = JSON.stringify(pobj.actionBody.deliveryData);
let sql = `UPDATE c_order_delivery SET deliveryContent ='${deliveryData}' where sourceOrderNo='${orderNo}'`;
sql = sql.replace('\n', '');
const result = await this.customUpdate(sql);
return system.getResultSuccess();
} }
//申请信息校验 //申请信息校验
...@@ -271,29 +267,6 @@ class OrderInfoService extends ServiceBase { ...@@ -271,29 +267,6 @@ class OrderInfoService extends ServiceBase {
return system.getResultSuccess(); return system.getResultSuccess();
} }
//复审证据材料校验
async checkRejInfo(trademarkRejInfo) {
if(!trademarkRejInfo.noticeDate){
return system.getResult(null,'收到通知书日期不能为空');
}
if(!trademarkRejInfo.noticeMode){
return system.getResult(null,'通知的方式不能为空');
}
if(!["电子版","纸质版"].includes(trademarkRejInfo.noticeMode)){
return system.getResult(null,'通知书的类型错误')
}
if(!trademarkRejInfo.zhichanNumber){
return system.getResult(null,'知识产权局发文号不能为空');
}
if(!trademarkRejInfo.rejNotice){
return system.getResult(null,'商标驳回通知书不能为空');
}
if(!trademarkRejInfo.quotedTrademark){
return system.getResult(null,'引证商标不能为空');
}
return system.getResultSuccess()
}
/** /**
* 商标驳回复审列表 + 模糊查询 * 商标驳回复审列表 + 模糊查询
* @param pobj * @param pobj
...@@ -325,7 +298,7 @@ class OrderInfoService extends ServiceBase { ...@@ -325,7 +298,7 @@ class OrderInfoService extends ServiceBase {
} }
if(actionBody.applicantName){ if(actionBody.applicantName){
sql += ` and json_extract(deliveryContent,'$.applyUser.applicantName') like '%${actionBody.applicantName}%'`; sql += ` and json_extract(deliveryContent,'$.applyUser.applicantName') like '%${actionBody.applicantName}%'`;
sqlCount += ` and json_extract(deliveryContent,'$.applyUser.applicantName') like '%${actionBody.applicantName}'%`; sqlCount += ` and json_extract(deliveryContent,'$.applyUser.applicantName') like '%${actionBody.applicantName}%'`;
} }
if(actionBody.status){ if(actionBody.status){
sql += ` and json_extract(deliveryContent,'$.deliveryStatusName')='${actionBody.status}'`; sql += ` and json_extract(deliveryContent,'$.deliveryStatusName')='${actionBody.status}'`;
...@@ -367,7 +340,7 @@ class OrderInfoService extends ServiceBase { ...@@ -367,7 +340,7 @@ class OrderInfoService extends ServiceBase {
let pageIndex = Number(actionBody.pageIndex || 1); let pageIndex = Number(actionBody.pageIndex || 1);
let from = pageIndex == 1 ? 0 : Number((pageIndex - 1) * pageSize); let from = pageIndex == 1 ? 0 : Number((pageIndex - 1) * pageSize);
let sql = `select o.serviceNo,json_extract(officialInfo,'$.applyUser') applyUser,json_extract(officialInfo,'$.askforId') askforId,json_extract(officialInfo,'$.tmType') tmType,json_extract(officialInfo,'$.tmPicUrl') tmPicUrl,json_extract(officialInfo,'$.applicantName') applicantName,json_extract(officialInfo,'$.fileType') fileType from c_order_info i left join c_delivery_official o on i.orderNo = o.serviceNo where i.uapp_id = ${pobj.appInfo.uapp_id}`; let sql = `select o.serviceNo,json_extract(officialInfo,'$.dir') dir,json_extract(officialInfo,'$.askforId') askforId,json_extract(officialInfo,'$.tradeType') tmType,json_extract(officialInfo,'$.tradeImg') tmPicUrl,json_extract(officialInfo,'$.applicantName') applicantName,json_extract(officialInfo,'$.fileType') fileType,json_extract(officialInfo,'$.received_at') received_at from c_order_info i left join c_delivery_official o on i.orderNo = o.serviceNo where i.uapp_id = ${pobj.appInfo.uapp_id}`;
let sqlCount = `select count(1) as dataCount from c_order_info i left join c_delivery_official o on i.orderNo = o.serviceNo where i.uapp_id = ${pobj.appInfo.uapp_id}` let sqlCount = `select count(1) as dataCount from c_order_info i left join c_delivery_official o on i.orderNo = o.serviceNo where i.uapp_id = ${pobj.appInfo.uapp_id}`
if (pobj.userInfo.channel_userid) { if (pobj.userInfo.channel_userid) {
...@@ -375,8 +348,8 @@ class OrderInfoService extends ServiceBase { ...@@ -375,8 +348,8 @@ class OrderInfoService extends ServiceBase {
sqlCount += ` and o.channelUserId='${pobj.userInfo.channel_userid}'`; sqlCount += ` and o.channelUserId='${pobj.userInfo.channel_userid}'`;
} }
if (actionBody.orderNo) { if (actionBody.orderNo) {
sql += ` and serviceNo='${actionBody.orderNo}'`; sql += ` and o.serviceNo='${actionBody.orderNo}'`;
sqlCount += ` and serviceNo='${actionBody.orderNo}'`; sqlCount += ` and o.serviceNo='${actionBody.orderNo}'`;
} }
if (actionBody.askforId) { if (actionBody.askforId) {
sql += ` and json_extract(officialInfo,'$.askforId')='${actionBody.askforId}'`; sql += ` and json_extract(officialInfo,'$.askforId')='${actionBody.askforId}'`;
...@@ -392,8 +365,8 @@ class OrderInfoService extends ServiceBase { ...@@ -392,8 +365,8 @@ class OrderInfoService extends ServiceBase {
} }
if (actionBody.startTime && actionBody.entTime) { if (actionBody.startTime && actionBody.entTime) {
var startTime = actionBody.startTime.trim() + " 00:00:00"; var startTime = actionBody.startTime.trim();
var endTime = actionBody.entTime + " 23:59:59"; var endTime = actionBody.entTime;
sql += ` and json_extract(officialInfo,'$.received_at') >='${startTime}' and json_extract(officialInfo,'$.received_at')<='${endTime}'`; sql += ` and json_extract(officialInfo,'$.received_at') >='${startTime}' and json_extract(officialInfo,'$.received_at')<='${endTime}'`;
sqlCount += ` and json_extract(officialInfo,'$.received_at') >='${startTime}' and json_extract(officialInfo,'$.received_at')<='${endTime}'`; sqlCount += ` and json_extract(officialInfo,'$.received_at') >='${startTime}' and json_extract(officialInfo,'$.received_at')<='${endTime}'`;
} }
...@@ -421,21 +394,26 @@ class OrderInfoService extends ServiceBase { ...@@ -421,21 +394,26 @@ class OrderInfoService extends ServiceBase {
if(!actionBody.orderNo){ if(!actionBody.orderNo){
return system.getResult(null,'orderNo can not be empty'); return system.getResult(null,'orderNo can not be empty');
} }
let orderSql = `select channelUserId from c_order_info where orderNo = '${actionBody.orderNo}'`; try{
let list = await this.customQuery(orderSql); let orderSql = `select channelUserId from c_order_info where orderNo = '${actionBody.orderNo}'`;
if (!list || list.length == 0) { let list = await this.customQuery(orderSql);
return system.getResult(null, "订单数据为空,30200"); if (!list || list.length == 0) {
} return system.getResult(null, "订单数据为空,30200");
let orderItem = list[0]; }
let orderItem = list[0];
let officialData = { let data = {
serviceNo: actionBody.orderNo, serviceNo: actionBody.orderNo,
channelUserId:orderItem.channelUserId, channelUserId:orderItem.channelUserId,
officialInfo: JSON.parse(actionBody.officialData), officialInfo: actionBody.officialData,
created_at: new Date(), created_at: new Date(),
updated_at: new Date() updated_at: new Date()
}
await this.officialDao.create(data);
return system.getResultSuccess();
}catch (e) {
return system.getResultFail();
} }
await this.officialDao.create(officialData,"");
} }
} }
......
...@@ -629,8 +629,8 @@ class OrderInfoService extends ServiceBase { ...@@ -629,8 +629,8 @@ class OrderInfoService extends ServiceBase {
orderStatus: 2 orderStatus: 2
} }
var item = await self.createOrder(pobj, orderNo, t); var item = await self.createOrder(pobj, orderNo, t);
needsolutioninfo.status = "ywc"; // needsolutioninfo.status = "ywc";
await self.needsolutionDao.update(needsolutioninfo, t); await self.needsolutionDao.update({id:needsolutioninfo.id,status:"dqr"}, t);
self.addOrderDelivery(pobj.actionBody.deliveryData, orderNo); self.addOrderDelivery(pobj.actionBody.deliveryData, orderNo);
return system.getResultSuccess({ return system.getResultSuccess({
orderNo: orderNo, orderNo: orderNo,
......
...@@ -2,12 +2,14 @@ const uuidv4 = require('uuid/v4'); ...@@ -2,12 +2,14 @@ const uuidv4 = require('uuid/v4');
const system = require("../../../system"); const system = require("../../../system");
const ServiceBase = require("../../sve.base"); const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
var moment = require('moment')
class NeedinfoService extends ServiceBase { 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"); this.needsolutionSve = system.getObject("service.dbneed.needsolutionSve");
this.needsolutionDao = system.getObject("db.dbneed.needsolutionDao"); this.needsolutionDao = system.getObject("db.dbneed.needsolutionDao");
this.needinfoDao = system.getObject("db.dbneed.needinfoDao");
} }
async getItemByNeedNo(pobj) { async getItemByNeedNo(pobj) {
var item = await this.dao.getItemByNeedNo(pobj.actionBody.needNo); var item = await this.dao.getItemByNeedNo(pobj.actionBody.needNo);
...@@ -172,6 +174,41 @@ class NeedinfoService extends ServiceBase { ...@@ -172,6 +174,41 @@ class NeedinfoService extends ServiceBase {
return system.getResultSuccess(item); return system.getResultSuccess(item);
} }
async writeCommunicationLog(pobj,actionBody){
// 查询需求沟通记录
actionBody.Note = ["noteTime",moment().format("YYYY-MM-DD HH:mm:ss"),"note",actionBody.Note];
let needRes = await this.findOne({channelNeedNo:actionBody.BizId});
// 没有需求单直接返回
if(!needRes) {
return system.getResult("没有这个需求单");
}
// 有需求单但没有沟通记录 直接set
if(!needRes.followContent) {
var sql = "update n_need_info set followContent=JSON_OBJECT(:followContent) where channelNeedNo=:BizId"
var paramWhere = {
followContent: actionBody.Note,
BizId: actionBody.BizId
};
var updateRes = await this.customUpdate(sql,paramWhere);
if(updateRes[1]) {
return system.getResultSuccess();
}
return system.getResult("添加记录失败");
// 有需求单有沟通记录 json_array_append
} else {
var sql = "update n_need_info set followContent=json_array_append(followContent, '$', JSON_OBJECT(:Note)) where channelNeedNo=:BizId"
// var sql = "update n_need_info set followContent=json_array_append(followContent, '$', "+ "\"" + JSON.stringify(actionBody.Note) + "\""+") where channelNeedNo="+ "\"" +actionBody.BizId +"\"" +" "
var paramWhere = {
Note: actionBody.Note,
BizId: actionBody.BizId
};
var updateRes = await this.customUpdate(sql,paramWhere);
if(updateRes[1]) {
return system.getResultSuccess();
}
return system.getResult("添加记录失败");
}
}
} }
module.exports = NeedinfoService; module.exports = NeedinfoService;
......
...@@ -413,7 +413,7 @@ class NeedsolutionService extends ServiceBase { ...@@ -413,7 +413,7 @@ class NeedsolutionService extends ServiceBase {
return system.getResultFail(-103, "方案状态错误,不能废弃已完成方案"); return system.getResultFail(-103, "方案状态错误,不能废弃已完成方案");
} }
} }
await this.dao.model.update({ status: "yzf" }, { where: { needNo: needinfo.needNo } });//方案废弃 await this.dao.model.update({ status: "yzf",isInvalid:1 }, { where: { needNo: needinfo.needNo } });//方案废弃
return system.getResultSuccess(); return system.getResultSuccess();
} }
...@@ -474,7 +474,7 @@ class NeedsolutionService extends ServiceBase { ...@@ -474,7 +474,7 @@ class NeedsolutionService extends ServiceBase {
// return system.getResultFail(-102,"状态不能为空"); // return system.getResultFail(-102,"状态不能为空");
// } // }
var needsolutioninfo = await this.dao.model.findOne({ var needsolutioninfo = await this.dao.model.findOne({
where: { channelSolutionNo: ab.channelSolutionNo }, raw: true where: { channelSolutionNo: ab.channelSolutionNo,isInvalid:0 }, raw: true
}); });
if (!needsolutioninfo || !needsolutioninfo.id) { if (!needsolutioninfo || !needsolutioninfo.id) {
return system.getResultFail(-400, "未知方案"); return system.getResultFail(-400, "未知方案");
...@@ -493,7 +493,7 @@ class NeedsolutionService extends ServiceBase { ...@@ -493,7 +493,7 @@ class NeedsolutionService extends ServiceBase {
} }
await this.dao.update(needsolutioninfo); await this.dao.update(needsolutioninfo);
var ns = await this.dao.model.findOne({ var ns = await this.dao.model.findOne({
where: { channelSolutionNo: ab.channelSolutionNo }, raw: true where: { id: needsolutioninfo.id }, raw: true
}); });
return system.getResultSuccess(ns); return system.getResultSuccess(ns);
} }
......
const system = require("../../../system");
const moment = require('moment')
/**
* 阿里云增值电信相关接口(ICP、EDI)
* created by zhuangbing
* created at 2020.07.27
*/
class AliyunQcService{
constructor() {
this.needsolutionDao = system.getObject("db.dbneed.needsolutionDao");
this.needinfoDao = system.getObject("db.dbneed.needinfoDao");
this.orderinfoDao = system.getObject("db.dbcorder.orderinfoDao");
this.icpSolutionStatusReference = {
SOLUTION_SUBMIT: "提交服务单",
UN_PAID: "未支付", PAID: "用户支付", USER_UPLOADED: "用户上传资料", MATERIAL_UNCONFIRM: "服务商递交⽂件"
, USER_CONFIRMED: "⽤户已确认递交⽂件", ACCOUNT_REGISTERED: "完成账户注册", MATERIAL_SUBMITTED: "完成资料递交",
GXB_ACCEPT: "⼯信部已受理", GXB_REFUSE: "⼯信部不予受理", GXB_FAIL: "⼯信部未通过", GXB_SUCCESS: "工信部通过"
, CLOSE: "方案关闭"
};
this.icpApplicationStatusReference={
507:"完成账户注册",
508:"服务商完成提交资料到⼯信部",
509:"⼯商部已受理",
510:"⼯商部不予受理",
511:"⼯商部通过",
512:"⼯商部未通过"
};
}
//根据需求查看方案列表
async getProgrammeInfoByChannelNeedNo(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
ab["createUserId"] = user.id;
if (!ab.needNo) {
return system.getResultFail(-101, "需求号不能为空");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { channelNeedNo: ab.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-102, "未知需求信息");
}
var ns = await this.needsolutionDao.model.findAll({
where: { needNo: needinfo.needNo, createUserId: user.id }, raw: true,
attributes: ["needNo", "solutionNo", "channelSolutionNo", "orderNo", "solutionContent", "status", "statusName"]
});
return system.getResultSuccess(ns);
}
//获取方案详情(内部调用)
async getIcpProgrammeDetail(pobj) {
var ab = pobj.actionBody;
if (!ab.BizId) {
return system.getResultFail(-101, "方案编号不能为空");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findAll({
where: { channelSolutionNo: ab.BizId,isInvalid:0 }, raw: true
});
return system.getResultSuccess(ns);
}
//获取方案详情(前端调用)
async getNeedSolutionDetailByUser(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
// ab["createUserId"]=user.id;
if (!ab.solutionNo) {
return system.getResultFail(-101, "方案编号不能为空");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where: { solutionNo: ab.solutionNo, createUserId: user.id }, raw: true
});
if (ns && ns.needNo) {
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: ns.needNo }, raw: true,
attributes: ["publishName", "publishMobile", "channelUserId"]
});
ns.needinfo = needinfo;
}
return system.getResultSuccess(ns);
}
//提交方案
async submitIcpProgramme(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
ab["createUserId"] = user.id;
if (!ab.needNo) {
return system.getResultFail(-101, "渠道需求号不能为空");
}
if (!ab.solutionContent) {
return system.getResultFail(-102, "方案信息有误");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { channelNeedNo: ab.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能创建方案");
}
var bizType = ab.solutionContent.bizType;//业务类型
if (!bizType || !needinfo.typeCode || bizType != needinfo.typeCode) {
return system.getResultFail(-205, "方案类型错误");
}
if (!needinfo.channelTypeCode) {
return system.getResultFail(-206, "渠道方案类型错误");
}
ab.solutionContent.typeCode = needinfo.typeCode;
ab.solutionContent.typeName = needinfo.typeName;
var ns = await this.needsolutionDao.model.findAll({
where: { channelNeedNo: ab.needNo }, raw: true,order: [["id", 'asc']]
});
for (var i = 0; i < ns.length; i++) {
var fa = ns[i];
if (fa.status == "dqr" || fa.status == "ywc") {
return system.getResultFail(-207, "需求方案已存在,不能重复提交");
}
if (fa.status == "ybh") {
ab.channelSolutionNo = fa.channelSolutionNo;
}
if (fa.status == "yzf") {
ab.channelSolutionNo = "";
}
}
var solution = ab.solutionContent.solution;
if (!solution) {
return system.getResultFail(-103, "方案交付信息有误");
}
if (needinfo.channelTypeCode == "7") {//edi
ab.solutionContent.solution.IcpType = 2;
}else if (needinfo.channelTypeCode == "5") {//icp
ab.solutionContent.solution.IcpType = 1;
}else{
return system.getResultFail(-208, "需求业务类型有误");
}
if (!solution.CompanyName) {
return system.getResultFail(-105, "公司名不能为空");
}
if (!solution.CompanyAddress) {
return system.getResultFail(-106, "公司地址不能为空");
}
if (!solution.Area) {
return system.getResultFail(-107, "区域不能为空");
}
var solutionFlowList = ab.solutionContent.solutionFlowList || [];
solutionFlowList.push({
status: "SOLUTION_SUBMIT", statusName: this.icpSolutionStatusReference.SOLUTION_SUBMIT, updated_at: new Date()
});
ab.solutionContent.status = "SOLUTION_SUBMIT";
ab.solutionContent.statusName = this.icpSolutionStatusReference.SOLUTION_SUBMIT;
ab.solutionContent.solutionFlowList = solutionFlowList;
ab["channelNeedNo"] = needinfo.channelNeedNo;
var solutionNo = await this.getBusUid("ns");
ab["solutionNo"] = solutionNo;
ab["status"] = "dqr";
var customerInfo = {//客户信息
"publishName":needinfo.publishName,
"publishMobile":needinfo.publishMobile
};
var salesmanInfo = {//业务员信息
"salesmanName":user.channel_username,
"salesmanMobile":user.mobile,
"salesmanId":user.id
};
ab.solutionContent["customerInfo"]= customerInfo;
ab.solutionContent["salesmanInfo"]= salesmanInfo;
ab.solutionContent = JSON.stringify(ab.solutionContent);
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
ab["needNo"] = needinfo.needNo;
var od = await self.needsolutionDao.create(ab, t);
if (od && od.id) {
var needObj = {
id: needinfo.id
};
if (!needinfo.followManUserId) {
needObj = {
id: needinfo.id,
followManUserId: user.id,//跟进人id
followManName: user.channel_username,//跟进人姓名
followManMobile: user.mobile,//跟进人手机号(合伙人)
followManOnlyCode: user.channel_userid
};
}
if (!needinfo.followContent) {
var followContent = [{
followDate: new Date(),
content: "icp提交方案"
}];
followContent = JSON.stringify(followContent);
needObj["followContent"] = followContent;
}
await self.needinfoDao.update(needObj, t);
needinfo = await self.needinfoDao.model.findOne({
where: { id: needinfo.id }, raw: true
});
return system.getResultSuccess({ needinfo: needinfo, needsolution: od });
} else {
return system.getResultFail(-302, "提交方案失败");
}
})
}
//交付商关闭交付单
async closeOrderDelivery(pobj){
var ab = pobj.actionBody;
if (!ab.orderNo) {
return system.getResultFail(-101, "订单号不能为空");
}
if (!ab.note) {
return system.getResultFail(-106, "关闭理由不能为空");
}else{
ab.Note = ab.note;
}
var ns = await this.needsolutionDao.model.findOne({
where:{orderNo:ab.orderNo},raw:true
});
if (!ns || !ns.id) {
return system.getResultFail(-301, "未知方案");
}
ab["BizId"] = ns.channelSolutionNo;
pobj.actionBody = ab;
return this.abolishIcpProgramme(pobj);
}
//服务商方案作废 -- abolishIcpProgramme
async abolishIcpProgramme(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
if (!ab.BizId) {
return system.getResultFail(-101, "渠道方案号不能为空");
}
if (!ab.Note) {
return system.getResultFail(-106, "关闭理由不能为空");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where: { channelSolutionNo: ab.BizId,isInvalid:0}, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-300, "未知方案");
}
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: ns.needNo }, raw: true
});
if (!needinfo) {
return system.getResultFail(-400, "未知方案需求");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-401, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
// if (ns.status != "dqr") {
// return system.getResultFail(-301, "方案状态错误,只能废弃待确认方案");
// }
var solutionContent = ns.solutionContent;
if (!solutionContent.status || ["USER_UPLOADED", "MATERIAL_UNCONFIRM", "USER_CONFIRMED", "ACCOUNT_REGISTERED", "MATERIAL_SUBMITTED"].indexOf(solutionContent.status) < 0) {
return system.getResultFail(-302, "方案流程状态错误,不能执行此操作");
}
solutionContent.serviceProviderNote = ab.Note;
var solutionFlowList = solutionContent.solutionFlowList || [];
solutionFlowList.push({
status: "CLOSE", statusName: this.icpSolutionStatusReference.CLOSE, updated_at: new Date()
});
solutionContent.status = "CLOSE";
solutionContent.statusName = this.icpSolutionStatusReference.CLOSE;
solutionContent = JSON.stringify(solutionContent);
await this.needsolutionDao.update({ id: ns.id, status: "yzf",isInvalid:1, solutionContent: solutionContent });//方案废弃
//获取方案信息
var new_ns = await this.needsolutionDao.model.findOne({
where: { id:ns.id}, raw: true
});
return system.getResultSuccess(new_ns);
}
//交付商提交材料信息
async serviceProviderSubmitMaterial(pobj){
var ab = pobj.actionBody;
if (!ab.orderNo) {
return system.getResultFail(-101, "订单号不能为空");
}
var ns = await this.needsolutionDao.model.findOne({
where:{orderNo:ab.orderNo},raw:true
});
if (!ns || !ns.id) {
return system.getResultFail(-301, "未知方案");
}
ab["BizId"] = ns.channelSolutionNo;
pobj.actionBody = ab;
return this.submitIcpMaterial(pobj);
}
//提交icp材料信息
async submitIcpMaterial(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
// ab["createUserId"] = user.id;
if (!ab.BizId) {
return system.getResultFail(-101, "渠道方案编号不能为空");
}
if (!ab.material) {
return system.getResultFail(-102, "材料信息有误");
}
//获取方案信息
var needsolutioninfo = await this.needsolutionDao.model.findOne({
attributes:["id","needNo","solutionContent"],
where: { channelSolutionNo: ab.BizId ,isInvalid:0}, raw: true
});
if (!needsolutioninfo || !needsolutioninfo.id) {
return system.getResultFail(-400, "未知方案");
}
if (!needsolutioninfo.needNo) {
return system.getResultFail(-401, "方案需求信息有误");
}
var solutionContent = needsolutioninfo.solutionContent;
if (!solutionContent) {
return system.getResultFail(-402, "方案交付信息有误");
}
if (solutionContent.status != "USER_UPLOADED") {
return system.getResultFail(-403, "用户未上传材料,不能执行此操作");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: needsolutioninfo.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
var material = ab.material;
if (!material.Domain) {
return system.getResultFail(-101, "备案域名不能为空");
}
//CorporateName 法⼈名称
if (!material.hasOwnProperty("IncludeForeignInvestment")) {
return system.getResultFail(-102, "包含外贸参数不能为空");
}
if (!material.PartnerBusinessLicense) {
return system.getResultFail(-103, "营业执照不能为空");
}
if (!material.PartnerIdCardList || material.PartnerIdCardList.length < 1) {
return system.getResultFail(-105, "相关人员身份证不能为空");
}
if (!material.PartnerDomainCertificate) {
return system.getResultFail(-106, "域名证书不能为空");
}
solutionContent.material = ab.material;
var solutionFlowList = solutionContent.solutionFlowList || [];
solutionFlowList.push({
status: "MATERIAL_UNCONFIRM", statusName: this.icpSolutionStatusReference.MATERIAL_UNCONFIRM, updated_at: new Date()
});
solutionContent.status = "MATERIAL_UNCONFIRM";
solutionContent.statusName = this.icpSolutionStatusReference.MATERIAL_UNCONFIRM;
needsolutioninfo.solutionContent = JSON.stringify(solutionContent);
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
await self.needsolutionDao.update(needsolutioninfo, t);
var new_needsolutioninfo = await self.needsolutionDao.model.findOne({
where: { id: needsolutioninfo.id }, raw: true
});
return system.getResultSuccess(new_needsolutioninfo);
})
}
//交付商通知状态变更
async serviceProviderNotification(pobj){
var ab = pobj.actionBody;
if (!ab.orderNo) {
return system.getResultFail(-101, "订单号不能为空");
}
if (!ab.status) {
return system.getResultFail(-102, "交付状态不能为空");
}else{
ab["ApplicationStatus"] = ab.status;
}
if (ab.officialFileURL) {
ab["OfficialFileURL"] = ab.officialFileURL;
}
var ns = await this.needsolutionDao.model.findOne({
where:{orderNo:ab.orderNo},raw:true
});
if (!ns || !ns.id) {
return system.getResultFail(-301, "未知方案");
}
ab["BizId"] = ns.channelSolutionNo;
ab["solutionNo"] = ns.solutionNo;
pobj.actionBody = ab;
return this.acceptIcpPartnerNotification(pobj);
}
//服务商通知状态变更
async acceptIcpPartnerNotification(pobj) {
var ab = pobj.actionBody;
var user = pobj.userInfo;
if (!user || !user.id) {
return system.getResultFail(-100, "未知用户");
}
// ab["createUserId"] = user.id;
// if (!ab.BizId) {
// return system.getResultFail(-101, "渠道方案编号不能为空");
// }
if (!ab.solutionNo) {
return system.getResultFail(-101, "方案编号不能为空");
}
if (!ab.ApplicationStatus) {
return system.getResultFail(-102, "通知状态不能为空");
}
//获取方案信息
var needsolutioninfo = await this.needsolutionDao.model.findOne({
attributes:["id","status","solutionContent","needNo"],
where: { solutionNo: ab.solutionNo }, raw: true
});
if (!needsolutioninfo || !needsolutioninfo.id) {
return system.getResultFail(-400, "未知方案");
}
if (!needsolutioninfo.needNo) {
return system.getResultFail(-401, "方案需求信息有误");
}
var solutionContent = needsolutioninfo.solutionContent;
if (!solutionContent) {
return system.getResultFail(-402, "方案交付信息有误");
}
if (solutionContent.applicationStatus && solutionContent.applicationStatus>ab.ApplicationStatus) {
return system.getResultFail(-403, "操作失败,交付流程未按顺序执行");
}
if (solutionContent.ApplicationStatus && solutionContent.ApplicationStatus==ab.ApplicationStatus) {
return system.getResultFail(-405, "操作失败,该流程状态已提交,不能重复提交");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: needsolutioninfo.needNo }, raw: true
});
if (!needinfo || !needinfo.id) {
return system.getResultFail(-201, "未知需求信息");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-202, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
var solutionFlowList = solutionContent.solutionFlowList || [];
if (ab.ApplicationStatus == 507) {//完成账户注册
if(solutionContent.status!="USER_CONFIRMED"){
return system.getResultFail(-508, "交付流程错误,用户确认递交⽂件后才能执行此操作");
}
solutionContent.ApplicationStatus = 507;
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "ACCOUNT_REGISTERED", statusName: this.icpSolutionStatusReference.ACCOUNT_REGISTERED, updated_at: new Date()
});
solutionContent.status = "ACCOUNT_REGISTERED";
solutionContent.statusName = this.icpSolutionStatusReference.ACCOUNT_REGISTERED;
}
if (ab.ApplicationStatus == 508) {//"服务商完成提交资料到⼯信部
if(solutionContent.status!="ACCOUNT_REGISTERED"){
return system.getResultFail(-508, "交付流程错误,请先完成账户注册");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "MATERIAL_SUBMITTED", statusName: this.icpSolutionStatusReference.MATERIAL_SUBMITTED, updated_at: new Date()
});
solutionContent.status = "MATERIAL_SUBMITTED";
solutionContent.statusName = this.icpSolutionStatusReference.MATERIAL_SUBMITTED;
}
if (ab.ApplicationStatus == 509) {//⼯商部已受理
if(solutionContent.status!="MATERIAL_SUBMITTED"){
return system.getResultFail(-509, "交付流程错误,请先完成资料递交");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "GXB_ACCEPT", statusName: this.icpSolutionStatusReference.GXB_ACCEPT, updated_at: new Date()
});
solutionContent.status = "GXB_ACCEPT";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_ACCEPT;
}
if (ab.ApplicationStatus == 510) {//⼯商部不予受理
if(solutionContent.status!="MATERIAL_SUBMITTED"){
return system.getResultFail(-510, "交付流程错误,请先完成资料递交");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "GXB_REFUSE", statusName: this.icpSolutionStatusReference.GXB_REFUSE, updated_at: new Date()
});
solutionContent.status = "GXB_REFUSE";
needsolutioninfo.status = "ywc";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_REFUSE;
}
if (ab.ApplicationStatus == 511) {//⼯商部通过
if(solutionContent.status!="GXB_ACCEPT"){
return system.getResultFail(-511, "交付流程错误,⼯信部已受理后才能执行此操作");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "GXB_SUCCESS", statusName: this.icpSolutionStatusReference.GXB_SUCCESS, updated_at: new Date()
});
needsolutioninfo.status = "ywc";
solutionContent.status = "GXB_SUCCESS";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_SUCCESS;
}
if (ab.ApplicationStatus == 512) {//⼯信部未通过
if(solutionContent.status!="GXB_ACCEPT"){
return system.getResultFail(-512, "交付流程错误,⼯信部已受理后才能执行此操作");
}
solutionFlowList.push({
file: ab.OfficialFileURL || "",
status: "GXB_FAIL", statusName: this.icpSolutionStatusReference.GXB_FAIL, updated_at: new Date()
});
solutionContent.status = "GXB_FAIL";
needsolutioninfo.status = "ywc";
solutionContent.statusName = this.icpSolutionStatusReference.GXB_FAIL;
}
solutionContent.solutionFlowList = solutionFlowList;
var applicationStatusList = solutionContent.applicationStatusList || [];
var statusObj = {
"OfficialFileURL": ab.OfficialFileURL || "",
"ApplicationStatus": ab.ApplicationStatus,
"ApplicationStatusName": this.icpApplicationStatusReference[ab.ApplicationStatus],
"created_at": new Date()
};
applicationStatusList.push(statusObj);
solutionContent.applicationStatusList = applicationStatusList;
solutionContent.applicationStatus = ab.ApplicationStatus;
needsolutioninfo.solutionContent = JSON.stringify(solutionContent);
var self = this;
return await this.needsolutionDao.db.transaction(async function (t) {
await self.needsolutionDao.update(needsolutioninfo, t);
statusObj["BizId"] = ab.BizId;
return system.getResultSuccess(statusObj);
})
}
//接收渠道方案状态变更通知
async receiveIcpStatusNotify(pobj) {
var ab = pobj.actionBody;
if (!ab.BizId) {
return system.getResultFail(-101, "渠道方案号不能为空");
}
if (!ab.status) {
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 + ",不能执行此操作");
}
// if (ns.status == "yzf" || ns.status == "ywc") {
// return system.getResultFail(-103, "该方案状态为" + ns.statusName + ",不能执行此操作");
// }
var solutionContent = ns.solutionContent;
var checkStatus = {ACCOUNT_REGISTERED: "完成账户注册", MATERIAL_SUBMITTED: "完成资料递交",
GXB_ACCEPT: "⼯信部已受理", GXB_REFUSE: "⼯信部不予受理", GXB_FAIL: "⼯信部未通过", GXB_SUCCESS: "工信部通过"
, CLOSE: "方案关闭"};
if(solutionContent.status && checkStatus[solutionContent.status]){
return system.getResultFail(-111, "方案已进入"+solutionContent.statusName+"流程,不能执行此操作");
}
//方案流程列表
var solutionFlowList = solutionContent.solutionFlowList || [];
if (ab.status == "2") {//⽤户已上传
if(solutionContent.status =="USER_CONFIRMED"){//防止用户确认后又否决
return system.getResultFail(-112, "操作失败,⽤户已确认递交⽂件");
}
solutionFlowList.push({
status: "USER_UPLOADED", statusName: this.icpSolutionStatusReference.USER_UPLOADED, updated_at: new Date()
});
solutionContent.status = "USER_UPLOADED";
solutionContent.statusName = this.icpSolutionStatusReference.USER_UPLOADED;
}else if (ab.status == "4") {//⽤户已确认
if(solutionContent.status !="MATERIAL_UNCONFIRM"){
return system.getResultFail(-113, "操作失败,服务商递交⽂件后才能执行此操作");
}
solutionFlowList.push({
status: "USER_CONFIRMED", statusName: this.icpSolutionStatusReference.USER_CONFIRMED, updated_at: new Date()
});
solutionContent.status = "USER_CONFIRMED";
solutionContent.statusName = this.icpSolutionStatusReference.USER_CONFIRMED;
}else if (ab.status == "11") {//⽅案已关闭
solutionFlowList.push({
status: "CLOSE", statusName: this.icpSolutionStatusReference.CLOSE, updated_at: new Date()
});
solutionContent.status = "CLOSE";
solutionContent.statusName = this.icpSolutionStatusReference.CLOSE;
}else{
return system.getResultFail(-110, "状态错误");
}
solutionContent.solutionFlowList = solutionFlowList;
var material = solutionContent.customerMaterial || {};
if (ab.remark) {
solutionContent.customerRemark = ab.remark;
}
if (ab.newbusinessLicense) {
material.businessLicense = ab.newbusinessLicense;
material.aliBusinessLicense = ab.businessLicense;
}
if (ab.newidCardUrlList && ab.newidCardUrlList.length > 0) {
material.idCardUrlList = ab.newidCardUrlList;
material.aliIdCardUrlList = ab.idCardUrlList;
}
if (ab.newuserPlan) {
material.userPlan = ab.newuserPlan;
material.aliUserPlan = ab.userPlan;
}
if (ab.newuserForeig) {
material.userForeig = ab.newuserForeig;
material.aliUserForeig = ab.userForeig;
}
if (ab.newuserLaw) {
material.userLaw = ab.newuserLaw;
material.aliUserLaw = ab.userLaw;
}
if (ab.newuserOtherList && ab.newuserOtherList.length > 0) {
material.userOtherList = ab.newuserOtherList;
material.aliUserOtherList = ab.userOtherList;
}
solutionContent.customerMaterial = material;
solutionContent = JSON.stringify(solutionContent);
var updateObj = {
id: ns.id, solutionContent: solutionContent
};
if (ab.status == "11") {//⽅案已关闭
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(ns);
}
//接收icp用户方案反馈
async receiveIcpFeedback(pobj) {
var ab = pobj.actionBody;
if (!ab.intentionBizId) {
return system.getResultFail(-101, "渠道需求编号错误");
}
if (!ab.description) {
return system.getResultFail(-102, "问题描述不能为空");
}
if (!ab.hasOwnProperty("intentionStatus")) {
return system.getResultFail(-103, "需求当前状态不能为空");
}
//获取需求信息
var needinfo = await this.needinfoDao.model.findOne({
where: { channelNeedNo: ab.intentionBizId }, raw: true
});
if (!needinfo) {
return system.getResultFail(-104, "未知方案需求");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
//获取方案信息
var ns = await this.needsolutionDao.model.findOne({
where: { channelNeedNo: ab.intentionBizId, isInvalid:0 }, raw: true
});
if (!ns) {
return system.getResultFail(-106, "未知方案");
}
var intentionStatusList = ["未知", "⽅案待服务商确认", "⽅案待⽤户确认", "处理中", "已完成", "已关闭"];
var updateObj = {
id: ns.id
};
var solutionContent = ns.solutionContent;
solutionContent.customerRemark = ab.description;
solutionContent.needStatus = ab.intentionStatus;
if(ab.intentionStatus == 1){
updateObj["status"] = "ybh";
updateObj["isInvalid"]=1;
}else if (ab.intentionStatus == 2) {
updateObj["status"] = "dqr";
}else if (ab.intentionStatus == 3) {
updateObj["status"] = "dqr";
} else if (ab.intentionStatus == 4) {
updateObj["status"] = "dqr";
} else if (ab.intentionStatus == 5) {
updateObj["status"] = "yzf";
updateObj["isInvalid"]=1;
} else {
return system.getResultFail(-107, "需求当前状态错误--" + ab.intentionStatus);
}
solutionContent.needStatusName = intentionStatusList[ab.intentionStatus];
solutionContent = JSON.stringify(solutionContent);
updateObj["solutionContent"] = solutionContent;
await this.needsolutionDao.update(updateObj);//方案状态修改
return system.getResultSuccess();
}
//接收方案编号(方案推送至阿里后,接收保存方案信息)
async receiveProgrammeNo(pobj) {
var ab = pobj.actionBody;
if (!ab.solutionBizId) {
return system.getResultFail(-101, "渠道方案业务编号不能为空");
}
if (!ab.solutionNo) {
return system.getResultFail(-102, "方案业务编号不能为空");
}
var ns = await this.needsolutionDao.model.findOne({
where: { solutionNo: ab.solutionNo,isInvalid:0 }, raw: true
});
if (!ns || !ns.id) {
return system.getResultFail(-103, "未知方案");
}
var needinfo = await this.needinfoDao.model.findOne({
where: { needNo: ns.needNo }, raw: true
});
if (!needinfo) {
return system.getResultFail(-104, "未知方案需求");
}
if (needinfo.status == "ycd" || needinfo.status == "ygb") {
return system.getResultFail(-105, "该方案需求状态为" + needinfo.statusName + ",不能执行此操作");
}
await this.needsolutionDao.model.update({ channelSolutionNo: ab.solutionBizId }, { where: { id: ns.id } });//修改方案信息
return system.getResultSuccess();
}
/*
返回20位业务订单号
prefix:业务前缀
*/
async getBusUid(prefix) {
prefix = (prefix || "");
if (prefix) {
prefix = prefix.toUpperCase();
}
var prefixlength = prefix.length;
var subLen = 8 - prefixlength;
var uidStr = "";
if (subLen > 0) {
uidStr = await this.getUidInfo(subLen, 60);
}
var timStr = moment().format("YYYYMMDDHHmm");
return prefix + timStr + uidStr;
}
/*
len:返回长度
radix:参与计算的长度,最大为62
*/
async getUidInfo(len, radix) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');//长度62,到yz长度为长36
var uuid = [], i;
radix = radix || chars.length;
if (len) {
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else {
var r;
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
uuid[14] = '4';
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
r = 0 | Math.random() * 16;
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
}
}
}
return uuid.join('');
}
}
module.exports = AliyunQcService;
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