Commit 71b7ad42 by Sxy

feat: 网文

parent 45339f19
var system = require("../../../system");
const http = require("http");
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const moment = require("moment");
class WangwenCtl extends CtlBase {
constructor() {
super("delivery", CtlBase.getServiceName(WangwenCtl));
}
// 查询 详情
async findInfo(pobj, qobj, req) {
try {
if (!pobj.id) {
throw new Error("参数错误")
}
const rs = await this.service.findInfo(pobj);
return system.getResult(rs);
} catch (err) {
return system.getResult(null, err.message)
}
}
// 提交材料
async submitMaterials(pobj, qobj, req) {
try {
if (!pobj.deliver_id) {
throw new Error("参数错误")
}
const rs = await this.service.submitMaterials(pobj);
return system.getResult(rs);
} catch (err) {
return system.getResult(null, err.message)
}
}
// 更改状态
async changeDeliveryStatus(pobj, qobj, req) {
try {
if (!pobj.deliver_id) {
throw new Error("参数错误")
}
const rs = await this.service.changeDeliveryStatus(pobj);
return system.getResult(rs);
} catch (err) {
return system.getResult(null, err.message)
}
}
}
module.exports = WangwenCtl;
...@@ -114,6 +114,10 @@ class DbFactory { ...@@ -114,6 +114,10 @@ class DbFactory {
this.db.models.material.belongsTo(this.db.models.deliver, { constraints: false, }); this.db.models.material.belongsTo(this.db.models.deliver, { constraints: false, });
this.db.models.deliver.hasOne(this.db.models.material, { constraints: false, }); this.db.models.deliver.hasOne(this.db.models.material, { constraints: false, });
// 交付表 1:1 网文材料表
this.db.models.wangwenmaterial.belongsTo(this.db.models.deliver, { constraints: false, });
this.db.models.deliver.hasOne(this.db.models.wangwenmaterial, { constraints: false, });
// 交付表 1:1 资质信息表 // 交付表 1:1 资质信息表
this.db.models.qualification.belongsTo(this.db.models.deliver, { constraints: false, }); this.db.models.qualification.belongsTo(this.db.models.deliver, { constraints: false, });
this.db.models.deliver.hasOne(this.db.models.qualification, { constraints: false, }); this.db.models.deliver.hasOne(this.db.models.qualification, { constraints: false, });
......
...@@ -27,6 +27,7 @@ class DeliverDao extends Dao { ...@@ -27,6 +27,7 @@ class DeliverDao extends Dao {
qc.raw = true; qc.raw = true;
let type = qobj.bizpath.split('/')[1]; let type = qobj.bizpath.split('/')[1];
if (type === 'deliveryManagement') { if (type === 'deliveryManagement') {
qc.where.product_code = qc.where.product_code && [system.SERVICECODE.EDI, system.SERVICECODE.ICP].includes(qc.where.product_code) ? qc.where.product_code : { qc.where.product_code = qc.where.product_code && [system.SERVICECODE.EDI, system.SERVICECODE.ICP].includes(qc.where.product_code) ? qc.where.product_code : {
$in: [system.SERVICECODE.EDI, system.SERVICECODE.ICP] $in: [system.SERVICECODE.EDI, system.SERVICECODE.ICP]
...@@ -107,8 +108,40 @@ class DeliverDao extends Dao { ...@@ -107,8 +108,40 @@ class DeliverDao extends Dao {
break break
} }
} else if (type === "wangwenManagement") {
let filters = [];
filters.push({
product_code: "wangwen"
})
switch (qobj.bizpath) {
case "/wangwenManagement/wait":
filters.push({
delivery_status: {
$notIn: [system.SERVERSESTATUS.SUCCESS, system.SERVERSESTATUS.CLOSED]
}
});
break
case "/wangwenManagement/deliveryAllocated":
filters.push({
delivery_man_opcode: {
$ne: null
}
});
break
case "/wangwenManagement/deliveryNoAllocate":
filters.push({
delivery_man_opcode: {
$eq: null
}
});
break
case "/wangwenManagement/all":
break
}
qc.where["$and"] = filters;
} else {
throw new Error("页面路径错误")
} }
return qw; return qw;
} }
...@@ -146,5 +179,21 @@ class DeliverDao extends Dao { ...@@ -146,5 +179,21 @@ class DeliverDao extends Dao {
}); });
return result; return result;
} }
async findInfoByWangwen(pobj) {
const result = await this.model.findOne({
where: {
id: pobj.id
},
include: [
{
model: this.db.models.wangwenmaterial,
raw: false
}
],
raw: false
});
return result;
}
} }
module.exports = DeliverDao; module.exports = DeliverDao;
const Dao = require("../../dao.base");
class WangwenmaterialDao extends Dao {
constructor() {
super(Dao.getModelName(WangwenmaterialDao));
}
async createOrUpdate(pobj, t) {
const materialData = await this.findOne({
deliver_id: pobj.deliver_id
});
let result = {};
let dataInfo = {
basicInfo: pobj.cache_info.basicInfo,
materialList: pobj.cache_info.materialList,
deliver_id: pobj.deliver_id,
}
if (materialData) {
//更新
await this.updateByWhere(dataInfo, {
deliver_id: pobj.deliver_id
}, t);
result = { id: materialData.id }
} else {
// 创建
let data = await this.create(dataInfo, t);
result = { id: data.id };
}
return result
}
}
module.exports = WangwenmaterialDao;
...@@ -102,7 +102,14 @@ module.exports = (db, DataTypes) => { ...@@ -102,7 +102,14 @@ module.exports = (db, DataTypes) => {
allowNull: true, allowNull: true,
type: DataTypes.STRING type: DataTypes.STRING
}, },
v_action_type: {//证件类型
allowNull: true,
type: DataTypes.STRING
},
v_license_type: { // ⽹⽂类型
allowNull: true,
type: DataTypes.STRING
},
}, { }, {
paranoid: false,//假的删除 paranoid: false,//假的删除
underscored: true, underscored: true,
......
const system = require("../../../system");
const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig();
/**
* 材料表
*/
module.exports = (db, DataTypes) => {
return db.define("wangwenmaterial", {
basicInfo: {
allowNull: false,
type: DataTypes.JSON
},
materialList: {
allowNull: false,
type: DataTypes.JSON
}
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'wangwen_materials_info',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
...@@ -205,51 +205,24 @@ class DeliverService extends ServiceBase { ...@@ -205,51 +205,24 @@ class DeliverService extends ServiceBase {
throw new Error("没有此交付单"); throw new Error("没有此交付单");
} }
/** /**
* 腾讯云 *
* 1. 交付单起始状态 为 已接单
* 2.点详情 更新为 收集材料中
*/
if (deliverData.source_number === "tencentCloud") {
if (system.SERVERSESTATUS.RECEIVED === deliverData.delivery_status) {
// await pushTx.pushChangeOrder(pushTx.TXSTATUS.COLLECTING, deliverData.delivery_code);
await this.dao.updateByWhere({
delivery_status: system.SERVERSESTATUS.COLLECTING
}, {
id: pobj.id
});
this.statuslogDao.create({
flow_type: system.FLOWCODE.DELIVERY,
flow_id: pobj.id,
status_code: system.SERVERSESTATUS.COLLECTING,
salesman_id: pobj.userid,
salesman_name: pobj.username
});
}
}
/**
* 阿里云
* 1. 交付单起始状态 为 已接单 * 1. 交付单起始状态 为 已接单
* 2. 点击详情 更新为 用户待上传材料 * 2. 点击详情 更新为 用户待上传材料
* 3. 当用户上传完材料 自动更新为 收集材料中 * 3. 当用户上传完材料 自动更新为 收集材料中
*/ */
if (deliverData.source_number === "aliCloud") { if (system.SERVERSESTATUS.RECEIVED === deliverData.delivery_status) {
if (system.SERVERSESTATUS.RECEIVED === deliverData.delivery_status) { await this.dao.updateByWhere({
// await pushTx.pushChangeOrder(pushTx.TXSTATUS.COLLECTING, deliverData.delivery_code); delivery_status: system.SERVERSESTATUS.USERUPLOADWAIT
}, {
await this.dao.updateByWhere({ id: pobj.id
delivery_status: system.SERVERSESTATUS.USERUPLOADWAIT });
}, { this.statuslogDao.create({
id: pobj.id flow_type: system.FLOWCODE.DELIVERY,
}); flow_id: pobj.id,
this.statuslogDao.create({ status_code: system.SERVERSESTATUS.USERUPLOADWAIT,
flow_type: system.FLOWCODE.DELIVERY, salesman_id: pobj.userid,
flow_id: pobj.id, salesman_name: pobj.username
status_code: system.SERVERSESTATUS.USERUPLOADWAIT, });
salesman_id: pobj.userid,
salesman_name: pobj.username
});
}
} }
return "success" return "success"
......
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
const moment = require("moment");
const System = require("../../../system");
const pushQft = require("../../../utils/toqifutongClient")
class WangwenService extends ServiceBase {
constructor() {
super("delivery", ServiceBase.getDaoName(WangwenService));
this.cacheinfoDao = system.getObject("db.delivery.cacheinfoDao");
this.deliveryDao = system.getObject("db.delivery.deliverDao");
this.wangwenmaterialDao = system.getObject("db.delivery.wangwenmaterialDao");
this.statuslogDao = system.getObject("db.bizchance.statuslogDao");
}
async findInfo(pobj, qobj, req) {
let result = await this.deliveryDao.findInfoByWangwen({
id: pobj.id
});
if (!result) {
throw new Error("交付单不可查看");
}
return result;
}
async submitMaterials(pobj, qobj, req) {
const deliverData = await this.deliveryDao.findOne({
id: pobj.deliver_id
});
if (!deliverData) {
throw new Error("查不到此交付单");
}
if ([system.SERVERSESTATUS.COLLECTING, system.SERVERSESTATUS.USERCONFIRMATIONREJECT].includes(deliverData.delivery_status)) {
await pushQft.wangwenSubmitOption(deliverData, pobj.cache_info);
}
return this.db.transaction(async (t) => {
await this.cacheinfoDao.createOrUpdate(pobj, t);
await this.wangwenmaterialDao.createOrUpdate(pobj, t);
if ([system.SERVERSESTATUS.COLLECTING, system.SERVERSESTATUS.USERCONFIRMATIONREJECT].includes(deliverData.delivery_status)) {
await this.deliveryDao.updateByWhere({
delivery_status: system.SERVERSESTATUS.USERCONFIRMATIONWAIT
}, {
id: pobj.deliver_id
}, t);
this.statuslogDao.create({
flow_type: system.FLOWCODE.DELIVERY,
flow_id: pobj.deliver_id,
status_code: system.SERVERSESTATUS.USERCONFIRMATIONWAIT,
salesman_id: pobj.userid,
salesman_name: pobj.username
});
}
return "SUCCESS"
});
}
async changeDeliveryStatus(pobj, qobj, req) {
const deliverData = await this.deliveryDao.findOne({
id: pobj.deliver_id
});
if (!deliverData) {
throw new Error("没有此交付单");
}
let status;
switch (deliverData.delivery_status) {
case system.SERVERSESTATUS.USERCONFIRMATIONRESOLVE:
status = system.SERVERSESTATUS.ACCOUNTREGISTRATION;
await pushQft.wangwenSubmitOption(deliverData);
break
case system.SERVERSESTATUS.ACCOUNTREGISTRATION:
status = system.SERVERSESTATUS.SUBMITING;
await pushQft.wangwenSubmitOption(deliverData);
break
case system.SERVERSESTATUS.SUBMITING:
status = system.SERVERSESTATUS.DISPOSEING;
await pushQft.wangwenSubmitOption(deliverData);
break
case system.SERVERSESTATUS.DISPOSEING:
status = system.SERVERSESTATUS.THROUGH;
await pushQft.wangwenSubmitOption(deliverData);
break
case system.SERVERSESTATUS.THROUGH:
status = system.SERVERSESTATUS.SUCCESS;
break
default:
throw new Error("此状态手动不能更改");
break
}
await this.deliveryDao.updateByWhere({
delivery_status: status
}, {
id: pobj.deliver_id
})
this.statuslogDao.create({
flow_type: system.FLOWCODE.DELIVERY,
flow_id: pobj.deliver_id,
status_code: status,
salesman_id: pobj.userid,
salesman_name: pobj.username
});
return "success"
}
}
module.exports = WangwenService;
...@@ -333,7 +333,8 @@ System.SERVICECODE = { ...@@ -333,7 +333,8 @@ System.SERVICECODE = {
ICP: "ICP", ICP: "ICP",
EDI: 'EDI', EDI: 'EDI',
ICPANNUALREPORT: "ICPANNUALREPORT", ICPANNUALREPORT: "ICPANNUALREPORT",
EDIANNUALREPORT: "EDIANNUALREPORT" EDIANNUALREPORT: "EDIANNUALREPORT",
WANGWEN: "wangwen"
} }
// 商机状态 // 商机状态
System.BUSSTATUS = { System.BUSSTATUS = {
......
...@@ -162,6 +162,75 @@ const submitMaterials = async (deliverData, materials) => { ...@@ -162,6 +162,75 @@ const submitMaterials = async (deliverData, materials) => {
}); });
} }
/**
* 文网文 递交材料
601: "完成账户注册",
602: "服务商提交资料",
603: "服务商完成提交资料到⼯信部",
604: "⼯商部已受理",
605: "⼯商部不予受理",
606: "⼯商部通过",
607: "⼯商部未通过"
*/
const wangwenSubmitOption = async (deliverData, materials) => {
let req = {};
switch (deliverData.delivery_status) {
case system.SERVERSESTATUS.COLLECTING:
case system.SERVERSESTATUS.USERCONFIRMATIONREJECT:
let { basicInfo, materialList } = materials;
let extInfo = {};
for (let val in basicInfo) {
if (basicInfo[val]) {
extInfo[val] = basicInfo[val];
}
}
for (let val of materialList) {
if (val.files || val.files.length > 0) {
let urls = [];
for (let file of val.files) {
if (file && file.url) {
urls.push(file.url);
}
}
if (urls.length > 0) {
extInfo[val.key] = urls
}
}
}
req = {
"ApplicationStatus": 601,
"extInfo": JSON.stringify(extInfo)
}
break
case system.SERVERSESTATUS.USERCONFIRMATIONRESOLVE:
req.ApplicationStatus = 602;
break
case system.SERVERSESTATUS.ACCOUNTREGISTRATION:
req.ApplicationStatus = 603;
break
case system.SERVERSESTATUS.SUBMITING:
req.ApplicationStatus = 604;
break
case system.SERVERSESTATUS.DISPOSEING:
req.ApplicationStatus = 606;
break
default:
throw new Error("此状态手动不能更改");
}
await pushQiFuTong(deliverData.salesman_phone, {
actionType: "serviceSubmitOption",
actionBody: {
"channelTpye": "esp.wangwen",
"solutionNo": deliverData.scheme_number,
...req,
}
});
}
/** /**
* 改变 状态 * 改变 状态
* @param {*} status * @param {*} status
...@@ -218,7 +287,6 @@ const batchCreateBiz = async (data) => { ...@@ -218,7 +287,6 @@ const batchCreateBiz = async (data) => {
} }
/** /**
* 推送到 启服通 * 推送到 启服通
* @param {*} mobile * @param {*} mobile
...@@ -229,7 +297,6 @@ const pushQiFuTong = async (mobile, data) => { ...@@ -229,7 +297,6 @@ const pushQiFuTong = async (mobile, data) => {
await postRequest(`${qifutongUrl}/web/action/qcapi/springBoard`, data, header); await postRequest(`${qifutongUrl}/web/action/qcapi/springBoard`, data, header);
} }
/** /**
* 发送请求 * 发送请求
* @param {*} url * @param {*} url
...@@ -238,7 +305,9 @@ const pushQiFuTong = async (mobile, data) => { ...@@ -238,7 +305,9 @@ const pushQiFuTong = async (mobile, data) => {
const postRequest = async (url, data, headers = {}) => { const postRequest = async (url, data, headers = {}) => {
try { try {
console.log("推送启服通请求数据 ------- "); console.log("推送启服通请求数据 ------- ");
console.log(url)
console.log(JSON.stringify(data)) console.log(JSON.stringify(data))
console.log(JSON.stringify(headers))
let result = await axios.post(url, data, { let result = await axios.post(url, data, {
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
...@@ -289,5 +358,6 @@ module.exports = { ...@@ -289,5 +358,6 @@ module.exports = {
ALISTATUS, ALISTATUS,
changeStatus, changeStatus,
closeDelivery, closeDelivery,
batchCreateBiz batchCreateBiz,
wangwenSubmitOption
} }
\ No newline at end of file
var url = require("url"); var url = require("url");
var system = require("../../base/system"); var system = require("../../base/system");
var metaCtl=system.getObject("web.common.metaCtl"); var metaCtl = system.getObject("web.common.metaCtl");
module.exports = function (app) { module.exports = function (app) {
app.get('/web/:gname/:qname/:method', function (req, res) { app.get('/web/:gname/:qname/:method', function (req, res) {
var classPath = req.params["qname"]; var classPath = req.params["qname"];
var methodName = req.params["method"]; var methodName = req.params["method"];
var gname=req.params["gname"]; var gname = req.params["gname"];
classPath=gname+"."+classPath; classPath = gname + "." + classPath;
var params = []; var params = [];
params.push(methodName); params.push(methodName);
params.push(req.body); params.push(req.body);
params.push(req.query); params.push(req.query);
params.push(req); params.push(req);
var p = null; var p = null;
var invokeObj = system.getObject("web." + classPath); var invokeObj = system.getObject("web." + classPath);
if (invokeObj["doexec"]) { if (invokeObj["doexec"]) {
...@@ -24,25 +24,26 @@ module.exports = function (app) { ...@@ -24,25 +24,26 @@ module.exports = function (app) {
app.post('/web/:gname/:qname/:method', function (req, res) { app.post('/web/:gname/:qname/:method', function (req, res) {
req.codepath = req.headers["codepath"]; req.codepath = req.headers["codepath"];
var classPath = req.params["qname"]; var classPath = req.params["qname"];
var methodName = req.params["method"]; var methodName = req.params["method"];
var gname=req.params["gname"]; var gname = req.params["gname"];
var params = []; var params = [];
classPath=gname+"."+classPath; classPath = gname + "." + classPath;
var tClientIp = system.get_client_ip(req); var tClientIp = system.get_client_ip(req);
req.body.clientIp = tClientIp; req.body.clientIp = tClientIp;
req.body.agent= req.headers["user-agent"]; req.body.agent = req.headers["user-agent"];
req.body.classname=classPath; req.body.classname = classPath;
params.push(methodName); params.push(methodName);
params.push(req.body); params.push(req.body);
params.push(req.query); params.push(req.query);
params.push(req); params.push(req);
var p = null; var p = null;
var invokeObj = system.getObject("web." + classPath); var invokeObj = system.getObject("web." + classPath);
if (invokeObj["doexec"]) { if (invokeObj["doexec"]) {
p = invokeObj["doexec"].apply(invokeObj, params); p = invokeObj["doexec"].apply(invokeObj, params);
} }
p.then(r => { p.then(r => {
res.end(JSON.stringify(r)); // res.end(JSON.stringify(r));
res.json(r);
}); });
}); });
}; };
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