Commit 1b29ad7b by sxy

fix: 资质信息交付流程联调调整

parent 6f7f9378
...@@ -23,7 +23,7 @@ class SchemeCtl extends CtlBase { ...@@ -23,7 +23,7 @@ class SchemeCtl extends CtlBase {
if (!pobj.bizopt_id) { if (!pobj.bizopt_id) {
return system.getResult(null, "bizopt_id can not be empty,100290"); return system.getResult(null, "bizopt_id can not be empty,100290");
} }
const rs = await this.service.findOne(pobj); const rs = await this.service.findOne({ bizopt_id: pobj.bizopt_id });
return system.getResult(rs); return system.getResult(rs);
} }
} }
......
...@@ -14,9 +14,10 @@ class DeliverCtl extends CtlBase { ...@@ -14,9 +14,10 @@ class DeliverCtl extends CtlBase {
const rs = await this.service.findAndCountAll(pobj); const rs = await this.service.findAndCountAll(pobj);
let result = []; let result = [];
for (let val of rs.results.rows) { for (let val of rs.results.rows) {
val.company_name = val.delivery_info.company; val.company_name = val.delivery_info.companyName;
val.customer_number = val.delivery_info.phone; val.customer_number = val.delivery_info.contactsPhone;
val.customer_name = val.delivery_info.person; val.customer_name = val.delivery_info.contactsName;
val.service_address = val.delivery_info.serviceName;
val.updated_at = moment(val.updated_at).format('YYYY-MM-DD HH:mm:ss'); val.updated_at = moment(val.updated_at).format('YYYY-MM-DD HH:mm:ss');
val.created_at = moment(val.created_at).format('YYYY-MM-DD HH:mm:ss'); val.created_at = moment(val.created_at).format('YYYY-MM-DD HH:mm:ss');
if (val.delivery_status === system.ANNUALREPORT.TAKEEFFECT) { if (val.delivery_status === system.ANNUALREPORT.TAKEEFFECT) {
...@@ -155,5 +156,17 @@ class DeliverCtl extends CtlBase { ...@@ -155,5 +156,17 @@ class DeliverCtl extends CtlBase {
return system.getResult(null, err.message) return system.getResult(null, err.message)
} }
} }
async toCollecting(pobj) {
if (!pobj.id) {
return system.getResult(null, "deliver_id can not be empty,100290");
}
try {
let rs = await this.service.toCollecting(pobj);
return system.getResult(rs);
} catch (err) {
return system.getResult(null, err.message)
}
}
} }
module.exports = DeliverCtl; module.exports = DeliverCtl;
...@@ -252,5 +252,17 @@ class MaterialCtl extends CtlBase { ...@@ -252,5 +252,17 @@ class MaterialCtl extends CtlBase {
}); });
return system.getResultSuccess(); return system.getResultSuccess();
} }
// 返回 下载url
async getUrl(pobj) {
if (!pobj.deliver_id) {
return system.getResult(null, "id can not be empty,100290");
}
const rs = await this.service.findOne({ deliver_id: pobj.deliver_id }, ["downloadUrl", "ifDownload"]);
if (!rs) {
return system.getResult(null, "查不到数据");
}
return system.getResult(rs);
}
} }
module.exports = MaterialCtl; module.exports = MaterialCtl;
...@@ -260,8 +260,12 @@ class Dao { ...@@ -260,8 +260,12 @@ class Dao {
} }
return await this.model.findAndCountAll(tmpWhere); return await this.model.findAndCountAll(tmpWhere);
} }
async findOne(obj) { async findOne(obj, attributes = []) {
return this.model.findOne({ "where": obj, row: true }); if (attributes.length > 0) {
return this.model.findOne({ "where": obj, attributes, row: true });
} else {
return this.model.findOne({ "where": obj, row: true });
}
} }
async findById(oid) { async findById(oid) {
return this.model.findById(oid); return this.model.findById(oid);
......
const system = require("../../../system"); const system = require("../../../system");
const Sequelize = require('sequelize');
const Dao = require("../../dao.base"); const Dao = require("../../dao.base");
const url = require("url"); const url = require("url");
class BizoptDao extends Dao { class BizoptDao extends Dao {
...@@ -10,18 +11,35 @@ class BizoptDao extends Dao { ...@@ -10,18 +11,35 @@ class BizoptDao extends Dao {
} }
extraWhere(qobj, qw, qc) { extraWhere(qobj, qw, qc) {
qc.raw = true; qc.raw = true;
qc.where.business_type = qc.where.business_type && [system.SERVICECODE.EDI, system.SERVICECODE.ICP].includes(qc.where.business_type) ? qc.where.business_type : { qc.where.business_type = qc.where.business_type ? qc.where.business_type : {
[this.db.Op.in]: [system.SERVICECODE.EDI, system.SERVICECODE.ICP] $in: [system.SERVICECODE.EDI, system.SERVICECODE.ICP]
} }
switch (qobj.bizpath) { switch (qobj.bizpath) {
case "/businessManagement/wailt": case "/businessManagement/wailt":
qc.where.business_status = qc.where.business_status || { qc.where.business_status = qc.where.business_status || {
[this.db.Op.in]: [system.BUSSTATUS.WAITINGSCHEME, system.BUSSTATUS.WAITINGCONFIRM] $in: [system.BUSSTATUS.WAITINGSCHEME, system.BUSSTATUS.WAITINGCONFIRM]
} }
break break
case "/businessManagement/all": case "/businessManagement/all":
break break
} }
// ---- JSON 查询 start-----
qc.where["$and"] = []
if (qc.where.linkman) {
qc.where["$and"].push(Sequelize.where(
Sequelize.literal('business_info->"$.contactsName"'),
qc.where.linkman));
delete qc.where.linkman;
}
if (qc.where.phone_number) {
qc.where["$and"].push(Sequelize.where(
Sequelize.literal('business_info->"$.contactsPhone"'),
qc.where.phone_number));
delete qc.where.phone_number;
}
// ---- JSON 查询 end-----
qc.include = [ qc.include = [
{ {
model: this.db.models.scheme, model: this.db.models.scheme,
......
const Sequelize = require('sequelize'); const Sequelize = require('sequelize');
const settings = require("../../../../config/settings") const settings = require("../../../../config/settings")
const Op = Sequelize.Op
const fs = require("fs") const fs = require("fs")
const path = require("path"); const path = require("path");
var glob = require("glob"); var glob = require("glob");
...@@ -9,9 +10,47 @@ class DbFactory { ...@@ -9,9 +10,47 @@ class DbFactory {
this.db = new Sequelize(dbConfig.dbname, this.db = new Sequelize(dbConfig.dbname,
dbConfig.user, dbConfig.user,
dbConfig.password, dbConfig.password,
dbConfig.config); {
...dbConfig.config,
operatorsAliases: {
$eq: Op.eq,
$ne: Op.ne,
$gte: Op.gte,
$gt: Op.gt,
$lte: Op.lte,
$lt: Op.lt,
$not: Op.not,
$in: Op.in,
$notIn: Op.notIn,
$is: Op.is,
$like: Op.like,
$notLike: Op.notLike,
$iLike: Op.iLike,
$notILike: Op.notILike,
$regexp: Op.regexp,
$notRegexp: Op.notRegexp,
$iRegexp: Op.iRegexp,
$notIRegexp: Op.notIRegexp,
$between: Op.between,
$notBetween: Op.notBetween,
$overlap: Op.overlap,
$contains: Op.contains,
$contained: Op.contained,
$adjacent: Op.adjacent,
$strictLeft: Op.strictLeft,
$strictRight: Op.strictRight,
$noExtendRight: Op.noExtendRight,
$noExtendLeft: Op.noExtendLeft,
$and: Op.and,
$or: Op.or,
$any: Op.any,
$all: Op.all,
$values: Op.values,
$col: Op.col
}
});
this.db.Sequelize = Sequelize; this.db.Sequelize = Sequelize;
this.db.Op = Sequelize.Op; this.db.Op = Op;
this.initModels(); this.initModels();
this.initRelations(); this.initRelations();
} }
......
...@@ -13,13 +13,13 @@ class DeliverDao extends Dao { ...@@ -13,13 +13,13 @@ class DeliverDao extends Dao {
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 : {
[this.db.Op.in]: [system.SERVICECODE.EDI, system.SERVICECODE.ICP] $in: [system.SERVICECODE.EDI, system.SERVICECODE.ICP]
} }
switch (qobj.bizpath) { switch (qobj.bizpath) {
case "/deliveryManagement/wait": case "/deliveryManagement/wait":
qc.where.delivery_status = qc.where.delivery_status || { qc.where.delivery_status = qc.where.delivery_status || {
[this.db.Op.in]: [system.SERVERSESTATUS.RECEIVED, system.SERVERSESTATUS.COLLECTING, $in: [system.SERVERSESTATUS.RECEIVED, system.SERVERSESTATUS.COLLECTING,
system.SERVERSESTATUS.SUBMITING, system.SERVERSESTATUS.DISPOSEING, system.SERVERSESTATUS.POSTING system.SERVERSESTATUS.SUBMITING, system.SERVERSESTATUS.DISPOSEING, system.SERVERSESTATUS.POSTING
] ]
} }
...@@ -29,7 +29,7 @@ class DeliverDao extends Dao { ...@@ -29,7 +29,7 @@ class DeliverDao extends Dao {
} }
} else if (type === "annualReport") { } else if (type === "annualReport") {
qc.where.product_code = qc.where.product_code && [system.SERVICECODE.ICPANNUALREPORT, system.SERVICECODE.EDIANNUALREPORT].includes(qc.where.product_code) ? qc.where.product_code : { qc.where.product_code = qc.where.product_code && [system.SERVICECODE.ICPANNUALREPORT, system.SERVICECODE.EDIANNUALREPORT].includes(qc.where.product_code) ? qc.where.product_code : {
[this.db.Op.in]: [system.SERVICECODE.EDIANNUALREPORT, system.SERVICECODE.ICPANNUALREPORT] $in: [system.SERVICECODE.EDIANNUALREPORT, system.SERVICECODE.ICPANNUALREPORT]
} }
// ---- 兼容 年报 状态 未申报、已申报 start // ---- 兼容 年报 状态 未申报、已申报 start
...@@ -45,7 +45,7 @@ class DeliverDao extends Dao { ...@@ -45,7 +45,7 @@ class DeliverDao extends Dao {
attributes: ['status', "year"], attributes: ['status', "year"],
where: { where: {
year: { year: {
[this.db.Op.or]: [ $or: [
new Date().getFullYear(), new Date().getFullYear(),
null null
] ]
...@@ -66,12 +66,12 @@ class DeliverDao extends Dao { ...@@ -66,12 +66,12 @@ class DeliverDao extends Dao {
switch (qobj.bizpath) { switch (qobj.bizpath) {
case "/annualReport/wait": case "/annualReport/wait":
qc.where.delivery_status = qc.where.delivery_status || { qc.where.delivery_status = qc.where.delivery_status || {
[this.db.Op.in]: [system.ANNUALREPORT.TAKEEFFECT] $in: [system.ANNUALREPORT.TAKEEFFECT]
} }
break break
case "/annualReport/all": case "/annualReport/all":
qc.where.delivery_status = qc.where.delivery_status || { qc.where.delivery_status = qc.where.delivery_status || {
[this.db.Op.in]: [system.ANNUALREPORT.TAKEEFFECT, system.ANNUALREPORT.SUCCESS] $in: [system.ANNUALREPORT.TAKEEFFECT, system.ANNUALREPORT.SUCCESS]
} }
break break
} }
......
...@@ -52,7 +52,7 @@ class DeliverService extends ServiceBase { ...@@ -52,7 +52,7 @@ class DeliverService extends ServiceBase {
} }
// 推送到商城 // 推送到商城
await pushTx.submitMaterials(deliverData, pobj.cache_info) await pushTx.submitMaterials(deliverData, JSON.parse(JSON.stringify(pobj.cache_info)))
return this.db.transaction(async (t) => { return this.db.transaction(async (t) => {
...@@ -114,7 +114,7 @@ class DeliverService extends ServiceBase { ...@@ -114,7 +114,7 @@ class DeliverService extends ServiceBase {
break break
} }
await pushTx.pushChangeOrder(txstatus, deliverData.source_number); await pushTx.pushChangeOrder(txstatus, deliverData.delivery_code);
await this.dao.updateByWhere({ await this.dao.updateByWhere({
delivery_status: status delivery_status: status
...@@ -131,6 +131,34 @@ class DeliverService extends ServiceBase { ...@@ -131,6 +131,34 @@ class DeliverService extends ServiceBase {
return "success" return "success"
} }
// 点击详情 将 订单状态 从 已接单更新为收集材料中
async toCollecting(pobj) {
const deliverData = await this.dao.findOne({
id: pobj.id
});
if (!deliverData) {
throw new Error("没有此交付单");
}
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
});
}
return "success"
}
async addQualification(pobj) { async addQualification(pobj) {
/** /**
* 1. 保存资质信息 * 1. 保存资质信息
...@@ -147,11 +175,13 @@ class DeliverService extends ServiceBase { ...@@ -147,11 +175,13 @@ class DeliverService extends ServiceBase {
} }
let annualReportData; let annualReportData;
let annualReportArry = []; let annualReportArry = [];
if (deliverData.master_source_number) {
// 年报逻辑
if (deliverData.master_source_number && deliverData.delivery_info && deliverData.delivery_info.annualReport) {
annualReportData = await this.dao.findOne({ annualReportData = await this.dao.findOne({
master_source_number: deliverData.master_source_number, master_source_number: deliverData.master_source_number,
id: { id: {
[this.db.Op.ne]: deliverData.id $ne: deliverData.id
} }
}); });
if (annualReportData && annualReportData.delivery_status === System.ANNUALREPORT.RECEIVED) { if (annualReportData && annualReportData.delivery_status === System.ANNUALREPORT.RECEIVED) {
...@@ -206,21 +236,22 @@ class DeliverService extends ServiceBase { ...@@ -206,21 +236,22 @@ class DeliverService extends ServiceBase {
throw new Error("该交付单状态下不可提交"); throw new Error("该交付单状态下不可提交");
} }
// 推送 关闭交付 // 推送 关闭交付
await pushTx.pushChangeOrder(pushTx.TXSTATUS.CLOSED, deliverData.source_number, { await pushTx.pushChangeOrder(pushTx.TXSTATUS.CLOSED, deliverData.delivery_code, {
close_reason: pobj.close_reason close_reason: pobj.close_reason
}); });
// 年报逻辑
let annualReportData; let annualReportData;
if (deliverData.master_source_number) { if (deliverData.master_source_number && deliverData.delivery_info && deliverData.delivery_info.annualReport) {
annualReportData = await this.dao.findOne({ annualReportData = await this.dao.findOne({
master_source_number: deliverData.master_source_number, master_source_number: deliverData.master_source_number,
id: { id: {
[this.db.Op.ne]: deliverData.id $ne: deliverData.id
} }
}); });
// 推送 关闭交付 资质 // 推送 关闭交付 资质
if (annualReportData) { if (annualReportData) {
await pushTx.pushChangeOrder(pushTx.TXSTATUS.CLOSED, annualReportData.source_number, { await pushTx.pushChangeOrder(pushTx.TXSTATUS.CLOSED, annualReportData.demand_code, {
close_reason: "对应的资质交付关闭了" close_reason: "对应的资质交付关闭了"
}); });
} }
...@@ -280,7 +311,7 @@ class DeliverService extends ServiceBase { ...@@ -280,7 +311,7 @@ class DeliverService extends ServiceBase {
proposerInfo.recipientInfo = pobj.recipientInfo; proposerInfo.recipientInfo = pobj.recipientInfo;
await pushTx.pushChangeOrder(pushTx.TXSTATUS.POSTING, result.source_number, { await pushTx.pushChangeOrder(pushTx.TXSTATUS.POSTING, result.delivery_code, {
qualification: result.qualification, qualification: result.qualification,
recipientInfo: pobj.recipientInfo recipientInfo: pobj.recipientInfo
}); });
...@@ -321,7 +352,7 @@ class DeliverService extends ServiceBase { ...@@ -321,7 +352,7 @@ class DeliverService extends ServiceBase {
let data = await this.dao.findOne({ let data = await this.dao.findOne({
master_source_number: annualReportResult.master_source_number, master_source_number: annualReportResult.master_source_number,
id: { id: {
[this.db.Op.ne]: annualReportResult.id $ne: annualReportResult.id
} }
}); });
if (!data) { if (!data) {
...@@ -351,6 +382,7 @@ class DeliverService extends ServiceBase { ...@@ -351,6 +382,7 @@ class DeliverService extends ServiceBase {
const deliverData = await this.dao.findOne({ const deliverData = await this.dao.findOne({
id: annualReportData.deliver_id id: annualReportData.deliver_id
}); });
// 年报逻辑
let isChange = false; let isChange = false;
if (deliverData && deliverData.delivery_status === system.ANNUALREPORT.TAKEEFFECT) { if (deliverData && deliverData.delivery_status === system.ANNUALREPORT.TAKEEFFECT) {
const annualReports = await this.annualreportDao.findAll({ const annualReports = await this.annualreportDao.findAll({
...@@ -367,8 +399,9 @@ class DeliverService extends ServiceBase { ...@@ -367,8 +399,9 @@ class DeliverService extends ServiceBase {
// 推送年报信息 // 推送年报信息
await pushTx.pushDeclareReport({ id: pobj.id, file: pobj.file }, deliverData); await pushTx.pushDeclareReport({ id: pobj.id, file: pobj.file }, deliverData);
//修改年报订单状态
if (isChange) { if (isChange) {
await pushTx.pushChangeOrder(pushTx.TXSTATUS.SUCCESS, deliverData.source_number); await pushTx.pushChangeOrder(pushTx.TXSTATUS.SUCCESS, deliverData.delivery_code);
} }
return this.db.transaction(async (t) => { return this.db.transaction(async (t) => {
......
...@@ -69,8 +69,8 @@ class ServiceBase { ...@@ -69,8 +69,8 @@ class ServiceBase {
async getPageList(pageIndex, pageSize, whereObj = null, orderObj = null, attributesObj = null, includeObj = null) { async getPageList(pageIndex, pageSize, whereObj = null, orderObj = null, attributesObj = null, includeObj = null) {
return this.dao.getPageList(pageIndex, pageSize, whereObj, orderObj, attributesObj, includeObj); return this.dao.getPageList(pageIndex, pageSize, whereObj, orderObj, attributesObj, includeObj);
} }
async findOne(obj) { async findOne(obj, attributes = []) {
return this.dao.findOne(obj); return this.dao.findOne(obj, attributes);
} }
async findById(oid) { async findById(oid) {
return this.dao.findById(oid); return this.dao.findById(oid);
......
...@@ -8,6 +8,7 @@ const BUSINESSTYPE = { ...@@ -8,6 +8,7 @@ const BUSINESSTYPE = {
EDI: "/qcfw/edi/" EDI: "/qcfw/edi/"
} }
const TXSTATUS = { const TXSTATUS = {
COLLECTING: "70",//手机材料中
SUBMITING: "80",//递交材料中 SUBMITING: "80",//递交材料中
DISPOSEING: "90",//工信部处理中 DISPOSEING: "90",//工信部处理中
POSTING: "150",//证书已邮寄 POSTING: "150",//证书已邮寄
...@@ -39,7 +40,11 @@ const pushScheme = async (bizData, schemeData) => { ...@@ -39,7 +40,11 @@ const pushScheme = async (bizData, schemeData) => {
solutionContent: { solutionContent: {
scheme_info: schemeData.scheme_info, scheme_info: schemeData.scheme_info,
remark_info: schemeData.remark_info, remark_info: schemeData.remark_info,
businessType: BUSINESSTYPE[bizData.business_type] businessType: BUSINESSTYPE[bizData.business_type],
servicerName: bizData.facilitator_name,
servicerCode: bizData.facilitator_id,
clerkName: bizData.salesman_name,
clerkPhone: bizData.salesman_phone
} }
} }
} }
...@@ -94,13 +99,21 @@ const pushChangeOrder = async (status, orderNum, data = {}) => { ...@@ -94,13 +99,21 @@ const pushChangeOrder = async (status, orderNum, data = {}) => {
*/ */
const submitMaterials = async (deliverData, materials) => { const submitMaterials = async (deliverData, materials) => {
let status; let status;
if (deliverData.delivery_status === system.SERVERSESTATUS.COLLECTING) { if (deliverData.delivery_status === system.SERVERSESTATUS.COLLECTING || deliverData.delivery_status === system.SERVERSESTATUS.SUBMITING) {
status = TXSTATUS.SUBMITING; status = TXSTATUS.SUBMITING;
} }
if (deliverData.delivery_status === system.SERVERSESTATUS.DISPOSEING) { if (deliverData.delivery_status === system.SERVERSESTATUS.DISPOSEING) {
status = TXSTATUS.DISPOSEING; status = TXSTATUS.DISPOSEING;
} }
await pushChangeOrder(status, deliverData.source_number, materials); materials.proposerInfo.businessInformation.ifListed = materials.proposerInfo.businessInformation.ifListed === "true"
await pushChangeOrder(status, deliverData.delivery_code, {
servicerName: deliverData.facilitator_name,
servicerCode: deliverData.facilitator_id,
clerkId: deliverData.salesman_id,
clerkName: deliverData.salesman_name,
clerkPhone: deliverData.salesman_phone,
...materials
});
} }
const pushDeclareReport = async (annualReport, deliverData) => { const pushDeclareReport = async (annualReport, deliverData) => {
...@@ -115,7 +128,7 @@ const pushDeclareReport = async (annualReport, deliverData) => { ...@@ -115,7 +128,7 @@ const pushDeclareReport = async (annualReport, deliverData) => {
item.status = item.status === system.ANNUALREPORT.WAITDECLARE ? "待申报" : "已申报" item.status = item.status === system.ANNUALREPORT.WAITDECLARE ? "待申报" : "已申报"
return item return item
}) })
await pushChangeOrder(TXSTATUS.DECLARESUCCESS, deliverData.source_number, result) await pushChangeOrder(TXSTATUS.DECLARESUCCESS, deliverData.delivery_code, result)
} }
......
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