Commit b3dd4a11 by 蒋勇

d

parents 7100ae0b 40ffc754
const system = require("../system"); const system = require("../system");
const uuidv4 = require('uuid/v4'); const uuidv4 = require('uuid/v4');
const settings = require("../../config/settings"); const settings = require("../../config/settings");
class APIBase{ class APIBase {
constructor() { constructor() {
this.cacheManager = system.getObject("db.common.cacheManager"); this.cacheManager = system.getObject("db.common.cacheManager");
}
async setContextParams(pobj, qobj, req) {
let custtags = req.headers["x-consumetag"] ? req.headers["x-consumetag"].split("|") : null;
//当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值
req.xctx = {
appkey: req.headers["xappkey"],//用于系统管理区分应用,比如角色
companyid: custtags ? custtags[0].split("_")[1] : null,
password: custtags ? custtags[1].split("_")[1] : null,
username: req.headers["x-consumer-username"],
credid: req.headers["x-credential-identifier"],
companykey: req.headers["x-company-key"],//专用于自由用户注册,自由用户用于一定属于某个存在的公司
} }
async setContextParams(pobj, qobj, req) { if (!req.xctx.appkey) {
let custtags = req.headers["x-consumetag"]?req.headers["x-consumetag"].split("|"):null; return [-200, "请求头缺少应用x-app-key"]
//当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值 } else {
req.xctx = { // let app = await this.cacheManager["AppCache"].cache(req.xctx.appkey);
appkey: req.headers["xappkey"],//用于系统管理区分应用,比如角色 // req.xctx.appid = app.id;
companyid: custtags?custtags[0].split("_")[1]:null, // pobj.app_id = app.id;//传递参数对象里注入app_id
password: custtags?custtags[1].split("_")[1]:null, }
username: req.headers["x-consumer-username"], //平台注册时,companyid,companykey都为空
credid: req.headers["x-credential-identifier"], //自由注册时,companykey不能为空
companykey:req.headers["x-company-key"],//专用于自由用户注册,自由用户用于一定属于某个存在的公司 // if(!req.xctx.companyid && !req.xctx.companykey){
} // return [-200,"请求头缺少应用x-app-key"]
if(!req.xctx.appkey){ // }
return [-200,"请求头缺少应用x-app-key"]
}else{ if (req.xctx.companyid) {//在请求传递数据对象注入公司id
// let app=await this.cacheManager["AppCache"].cache(req.xctx.appkey); pobj.company_id = req.xctx.companyid;
// req.xctx.appid=app.id; }
// pobj.app_id=app.id;//传递参数对象里注入app_id }
} async doexec(gname, methodname, pobj, query, req) {
//平台注册时,companyid,companykey都为空 try {
//自由注册时,companykey不能为空 let xarg = await this.setContextParams(pobj, query, req);
// if(!req.xctx.companyid && !req.xctx.companykey){ if (xarg && xarg[0] < 0) {
// return [-200,"请求头缺少应用x-app-key"] return system.getResultFail(...xarg);
// }
if(!req.xctx.companyid && req.xctx.companykey){
let comptmp=await this.cacheManager["CompanyCache"].cache(req.xctx.companykey);
req.xctx.companyid=comptmp.id;
}
if(req.xctx.companyid){//在请求传递数据对象注入公司id
pobj.company_id=req.xctx.companyid;
}
} }
async doexec(gname, methodname, pobj, query, req) {
try { var rtn = await this[methodname](pobj, query, req);
let xarg=await this.setContextParams(pobj, query, req); return rtn;
if(xarg && xarg[0]<0){ } catch (e) {
return system.getResultFail(...xarg); console.log(e.stack, "api调用异常--error...................");
} var rtnerror = system.getResultFail(-200, "出现异常,请联系管理员");
return rtnerror;
var rtn = await this[methodname](pobj, query, req);
return rtn;
} catch (e) {
console.log(e.stack, "api调用异常--error...................");
var rtnerror = system.getResultFail(-200, "出现异常,请联系管理员");
return rtnerror;
}
} }
}
} }
module.exports = APIBase; module.exports = APIBase;
...@@ -8,6 +8,7 @@ class DeliverCtl extends CtlBase { ...@@ -8,6 +8,7 @@ class DeliverCtl extends CtlBase {
constructor() { constructor() {
super("delivery", CtlBase.getServiceName(DeliverCtl)); super("delivery", CtlBase.getServiceName(DeliverCtl));
} }
async findAndCountAll(pobj, qobj, req) { async findAndCountAll(pobj, qobj, req) {
//设置查询条件 //设置查询条件
const rs = await this.service.findAndCountAll(pobj); const rs = await this.service.findAndCountAll(pobj);
...@@ -23,13 +24,19 @@ class DeliverCtl extends CtlBase { ...@@ -23,13 +24,19 @@ class DeliverCtl extends CtlBase {
rs.results.rows = result; rs.results.rows = result;
return system.getResult(rs); return system.getResult(rs);
} }
// TODO: 交付单表关联材料表
async findOneById(pobj, qobj, req) { // 查询 详情
async findInfo(pobj, qobj, req) {
if (!pobj.id) { if (!pobj.id) {
return system.getResult(null, "id can not be empty,100290"); return system.getResult(null, "id can not be empty,100290");
} }
const rs = await this.service.findOne({ id: pobj.id }); try {
return system.getResult(rs); const rs = await this.service.findInfo(pobj);
return system.getResult(rs);
} catch (err) {
return system.getResult(null, err.message)
}
} }
async temporarySave(pobj, qobj, req) { async temporarySave(pobj, qobj, req) {
...@@ -66,7 +73,55 @@ class DeliverCtl extends CtlBase { ...@@ -66,7 +73,55 @@ class DeliverCtl extends CtlBase {
return system.getResult(null, err.message) return system.getResult(null, err.message)
} }
}
async changeDeliveryStatus(pobj, qobj, req) {
if (!pobj.id) {
return system.getResult(null, "deliver_id can not be empty,100290");
}
try {
let rs = await this.service.changeDeliveryStatus(pobj);
return system.getResult(rs);
} catch (err) {
return system.getResult(null, err.message)
}
}
async addQualification(pobj, qobj, req) {
if (!pobj.deliver_id) {
return system.getResult(null, "deliver_id can not be empty,100290");
}
try {
let rs = await this.service.addQualification(pobj);
return system.getResult(rs);
} catch (err) {
return system.getResult(null, err.message)
}
}
async closeDeliver(pobj) {
if (!pobj.id) {
return system.getResult(null, "id can not be empty,100290");
}
try {
let rs = await this.service.closeDeliver(pobj);
return system.getResult(rs);
} catch (err) {
return system.getResult(null, err.message)
}
}
async addMail(pobj) {
if (!pobj.id) {
return system.getResult(null, "id can not be empty,100290");
}
try {
let rs = await this.service.addMail(pobj);
return system.getResult(rs);
} catch (err) {
return system.getResult(null, err.message)
}
} }
} }
module.exports = DeliverCtl; module.exports = DeliverCtl;
...@@ -5,6 +5,9 @@ class BizoptDao extends Dao { ...@@ -5,6 +5,9 @@ class BizoptDao extends Dao {
constructor() { constructor() {
super(Dao.getModelName(BizoptDao)); super(Dao.getModelName(BizoptDao));
} }
orderBy() {
return [["updated_at", "DESC"]];
}
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 && [system.SERVICECODE.EDI, system.SERVICECODE.ICP].includes(qc.where.business_type) ? qc.where.business_type : {
......
...@@ -27,10 +27,10 @@ class DbFactory { ...@@ -27,10 +27,10 @@ class DbFactory {
console.log("init models...."); console.log("init models....");
} }
async initRelations() { async initRelations() {
this.db.models.dataauth.belongsTo(this.db.models.user, { constraints: false, }); // this.db.models.dataauth.belongsTo(this.db.models.user, { constraints: false, });
/*建立用户和角色之间的关系*/ // /*建立用户和角色之间的关系*/
this.db.models.user.belongsToMany(this.db.models.role, { as: "Roles", through: 'p_userrole', constraints: false, }); // this.db.models.user.belongsToMany(this.db.models.role, { as: "Roles", through: 'p_userrole', constraints: false, });
this.db.models.role.belongsToMany(this.db.models.user, { as: "Users", through: 'p_userrole', constraints: false, }); // this.db.models.role.belongsToMany(this.db.models.user, { as: "Users", through: 'p_userrole', constraints: false, });
/*组织机构自引用*/ /*组织机构自引用*/
//this.db.models.org.belongsTo(this.db.models.org,{constraints: false,}); //this.db.models.org.belongsTo(this.db.models.org,{constraints: false,});
//this.db.models.org.hasMany(this.db.models.org,{constraints: false,}); //this.db.models.org.hasMany(this.db.models.org,{constraints: false,});
...@@ -44,24 +44,24 @@ class DbFactory { ...@@ -44,24 +44,24 @@ class DbFactory {
// this.db.models.user.belongsTo(this.db.models.org,{constraints: false,}); // this.db.models.user.belongsTo(this.db.models.org,{constraints: false,});
// this.db.models.org.hasMany(this.db.models.user,{constraints: false,}); // this.db.models.org.hasMany(this.db.models.user,{constraints: false,});
this.db.models.user.belongsTo(this.db.models.app, { constraints: false, }); // this.db.models.user.belongsTo(this.db.models.app, { constraints: false, });
this.db.models.role.belongsTo(this.db.models.app, { constraints: false, }); // this.db.models.role.belongsTo(this.db.models.app, { constraints: false, });
this.db.models.auth.belongsTo(this.db.models.app, { constraints: false, }); // this.db.models.auth.belongsTo(this.db.models.app, { constraints: false, });
this.db.models.auth.belongsTo(this.db.models.company, { constraints: false, }); // this.db.models.auth.belongsTo(this.db.models.company, { constraints: false, });
this.db.models.auth.belongsTo(this.db.models.role, { constraints: false, }); // this.db.models.auth.belongsTo(this.db.models.role, { constraints: false, });
this.db.models.app.belongsTo(this.db.models.user, { as: "creator", constraints: false, }); // this.db.models.app.belongsTo(this.db.models.user, { as: "creator", constraints: false, });
this.db.models.user.belongsTo(this.db.models.company, { constraints: false, }); // this.db.models.user.belongsTo(this.db.models.company, { constraints: false, });
this.db.models.role.belongsTo(this.db.models.company, { constraints: false, }); // this.db.models.role.belongsTo(this.db.models.company, { constraints: false, });
// this.db.models.org.belongsTo(this.db.models.company,{constraints: false,}); // this.db.models.org.belongsTo(this.db.models.company,{constraints: false,});
this.db.models.route.belongsTo(this.db.models.app, { constraints: false, }); // this.db.models.route.belongsTo(this.db.models.app, { constraints: false, });
this.db.models.plugin.belongsTo(this.db.models.app, { constraints: false, }); // this.db.models.plugin.belongsTo(this.db.models.app, { constraints: false, });
// 商机表 1:1 方案表 // 商机表 1:1 方案表
this.db.models.scheme.belongsTo(this.db.models.bizopt, { constraints: false, }); this.db.models.scheme.belongsTo(this.db.models.bizopt, { constraints: false, });
...@@ -75,6 +75,10 @@ class DbFactory { ...@@ -75,6 +75,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.qualification.belongsTo(this.db.models.deliver, { constraints: false, });
this.db.models.deliver.hasOne(this.db.models.qualification, { constraints: false, });
} }
//async getCon(){,用于使用替换table模型内字段数据使用 //async getCon(){,用于使用替换table模型内字段数据使用
......
...@@ -5,6 +5,9 @@ class DeliverDao extends Dao { ...@@ -5,6 +5,9 @@ class DeliverDao extends Dao {
constructor() { constructor() {
super(Dao.getModelName(DeliverDao)); super(Dao.getModelName(DeliverDao));
} }
orderBy() {
return [["updated_at", "DESC"]];
}
extraWhere(qobj, qw, qc) { extraWhere(qobj, qw, qc) {
qc.raw = true; qc.raw = true;
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 : {
...@@ -15,7 +18,7 @@ class DeliverDao extends Dao { ...@@ -15,7 +18,7 @@ class DeliverDao extends Dao {
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, [this.db.Op.in]: [system.SERVERSESTATUS.RECEIVED, system.SERVERSESTATUS.COLLECTING,
system.SERVERSESTATUS.SUBMITING, system.SERVERSESTATUS.DISPOSEING system.SERVERSESTATUS.SUBMITING, system.SERVERSESTATUS.DISPOSEING, system.SERVERSESTATUS.POSTING
] ]
} }
break break
...@@ -24,5 +27,25 @@ class DeliverDao extends Dao { ...@@ -24,5 +27,25 @@ class DeliverDao extends Dao {
} }
return qw; return qw;
} }
async findInfo(pobj) {
const result = await this.model.findOne({
where: {
id: pobj.id
},
include: [
{
model: this.db.models.qualification,
attributes: ['id', 'certificateNumber', 'businessTypes', 'businessScope', 'serviceProject', 'startAt', 'endAt', 'file'],
raw: false
}, {
model: this.db.models.material,
raw: false
}
],
raw: false
});
return result;
}
} }
module.exports = DeliverDao; module.exports = DeliverDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
const url = require("url");
class QualificationDao extends Dao {
constructor() {
super(Dao.getModelName(QualificationDao));
}
async createOrUpdate(pobj, t) {
const qualificationData = await this.findOne({
deliver_id: pobj.deliver_id
});
let result = {};
let info = {
businessScope: pobj.businessScope,
businessTypes: pobj.businessTypes,
certificateNumber: pobj.certificateNumber,
endAt: pobj.endAt,
file: pobj.file,
serviceProject: pobj.serviceProject,
startAt: pobj.startAt,
deliver_id: pobj.deliver_id
}
if (qualificationData) {
//更新
await this.updateByWhere(info, {
deliver_id: pobj.deliver_id
}, t);
result = { id: qualificationData.id }
} else {
// 创建
let data = await this.create(info, t);
result = { id: data.id };
}
return result
}
}
module.exports = QualificationDao;
const system = require("../../../system"); const system = require("../../../system");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
const appconfig=system.getSysConfig(); const appconfig = system.getSysConfig();
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("company", { return db.define("company", {
name: { name: {
...@@ -29,46 +29,46 @@ module.exports = (db, DataTypes) => { ...@@ -29,46 +29,46 @@ module.exports = (db, DataTypes) => {
}, },
orgJson: DataTypes.TEXT,//功能清 orgJson: DataTypes.TEXT,//功能清
}, { }, {
paranoid: true,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
version: true, version: true,
freezeTableName: true, freezeTableName: true,
//freezeTableName: true, //freezeTableName: true,
// define the table's name // define the table's name
tableName: 'p_company', tableName: 'p_company',
validate: { validate: {
}, },
indexes: [ indexes: [
// Create a unique index on email // Create a unique index on email
// { // {
// unique: true, // unique: true,
// fields: ['email'] // fields: ['email']
// }, // },
// //
// // Creates a gin index on data with the jsonb_path_ops operator // // Creates a gin index on data with the jsonb_path_ops operator
// { // {
// fields: ['data'], // fields: ['data'],
// using: 'gin', // using: 'gin',
// operator: 'jsonb_path_ops' // operator: 'jsonb_path_ops'
// }, // },
// //
// // By default index name will be [table]_[fields] // // By default index name will be [table]_[fields]
// // Creates a multi column partial index // // Creates a multi column partial index
// { // {
// name: 'public_by_author', // name: 'public_by_author',
// fields: ['author', 'status'], // fields: ['author', 'status'],
// where: { // where: {
// status: 'public' // status: 'public'
// } // }
// }, // },
// //
// // A BTREE index with a ordered field // // A BTREE index with a ordered field
// { // {
// name: 'title_index', // name: 'title_index',
// method: 'BTREE', // method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}] // fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// } // }
] ]
}); });
} }
...@@ -5,7 +5,8 @@ const appconfig = system.getSysConfig(); ...@@ -5,7 +5,8 @@ const appconfig = system.getSysConfig();
* 公司主体表 * 公司主体表
*/ */
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("company", { //TODO:
return db.define("company1", {
name: { name: {
allowNull: false, allowNull: false,
type: DataTypes.STRING type: DataTypes.STRING
......
...@@ -81,8 +81,11 @@ module.exports = (db, DataTypes) => { ...@@ -81,8 +81,11 @@ module.exports = (db, DataTypes) => {
salesman_phone: { // 业务员联系方式 salesman_phone: { // 业务员联系方式
allowNull: true, allowNull: true,
type: DataTypes.STRING type: DataTypes.STRING
},
sku_code: {
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("qualification", {
certificateNumber: {
allowNull: false,
type: DataTypes.STRING
},
businessTypes: {
allowNull: false,
type: DataTypes.STRING
},
businessScope: {
allowNull: false,
type: DataTypes.STRING
},
serviceProject: {
allowNull: false,
type: DataTypes.STRING
},
startAt: {
allowNull: false,
type: DataTypes.DATE
},
endAt: {
allowNull: false,
type: DataTypes.DATE
},
file: {
allowNull: false,
type: DataTypes.JSON
}
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'qualification_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}]
// }
]
});
}
...@@ -6,15 +6,15 @@ class DeliverService extends ServiceBase { ...@@ -6,15 +6,15 @@ class DeliverService extends ServiceBase {
constructor() { constructor() {
super("delivery", ServiceBase.getDaoName(DeliverService)); super("delivery", ServiceBase.getDaoName(DeliverService));
this.cacheinfoDao = system.getObject("db.delivery.cacheinfoDao"); this.cacheinfoDao = system.getObject("db.delivery.cacheinfoDao");
this.companyDao = system.getObject("db.delivery.companyDao");
this.materialDao = system.getObject("db.delivery.materialDao"); this.materialDao = system.getObject("db.delivery.materialDao");
this.statuslogDao = system.getObject("db.bizchance.statuslogDao"); this.statuslogDao = system.getObject("db.bizchance.statuslogDao");
this.qualificationDao = system.getObject("db.delivery.qualificationDao");
} }
async temporarySave(pobj) { async temporarySave(pobj) {
const deliverData = await this.dao.findOne({ const deliverData = await this.dao.findOne({
id: pobj.deliver_id id: pobj.deliver_id
}) });
if (!deliverData) { if (!deliverData) {
throw new Error("没有关联的交付单"); throw new Error("没有关联的交付单");
} }
...@@ -33,10 +33,8 @@ class DeliverService extends ServiceBase { ...@@ -33,10 +33,8 @@ class DeliverService extends ServiceBase {
* 1.此状态下是否可以提交材料 * 1.此状态下是否可以提交材料
* 2.同步暂存数据表 * 2.同步暂存数据表
* 3.存储到材料表 * 3.存储到材料表
* 4.提取 公司主体信息 存储到公司表 * 4.更改 交付单流转状态
* 5.TODO:公司表 与 交付单 表 关联 * 5.推送到腾讯
* 6.更改 交付单流转状态
* 7.推送到腾讯
*/ */
const deliverData = await this.dao.findOne({ const deliverData = await this.dao.findOne({
id: pobj.deliver_id id: pobj.deliver_id
...@@ -63,14 +61,135 @@ class DeliverService extends ServiceBase { ...@@ -63,14 +61,135 @@ class DeliverService extends ServiceBase {
status_code: system.SERVERSESTATUS.SUBMITING status_code: system.SERVERSESTATUS.SUBMITING
}); });
} }
await this.companyDao.createOrUpdate({
...pobj.cache_info.proposerInfo.businessLicense,
lastContactInfo: pobj.cache_info.proposerInfo.contactInfo,
firstBuyTime: deliverData.created_at
}, t);
return "SUCCESS" return "SUCCESS"
}); });
} }
async findInfo(pobj) {
/**
* 交付单表 关联 材料表(材料基本信息、邮寄信息) 、 资质信息表
*/
let result = await this.dao.findInfo(pobj);
if (!result) {
throw new Error("交付单不可查看");
}
return result;
}
async changeDeliveryStatus(pobj) {
/**
* 判断 交付单状态下能否更新
*/
const deliverData = await this.dao.findOne({
id: pobj.id
});
if (!deliverData) {
throw new Error("没有此交付单");
}
if (![system.SERVERSESTATUS.SUBMITING, system.SERVERSESTATUS.POSTING].includes(deliverData.delivery_status)) {
throw new Error("此状态下不可手动更新办理状态");
}
let status;
switch (deliverData.delivery_status) {
case system.SERVERSESTATUS.SUBMITING:
status = system.SERVERSESTATUS.DISPOSEING
break
case system.SERVERSESTATUS.POSTING:
status = system.SERVERSESTATUS.SUCCESS
break
}
await this.dao.updateByWhere({
delivery_status: status
}, {
id: pobj.id
})
this.statuslogDao.create({
flow_type: system.FLOWCODE.DELIVERY,
flow_id: pobj.id,
status_code: status
});
return "success"
}
async addQualification(pobj) {
const deliverData = await this.dao.findOne({
id: pobj.deliver_id
});
if (!deliverData) {
throw new Error("查不到交付单");
}
if (deliverData.delivery_status !== system.SERVERSESTATUS.DISPOSEING) {
throw new Error("该交付单状态下不可提交");
}
let result = await this.qualificationDao.createOrUpdate(pobj);
return result;
}
async closeDeliver(pobj) {
const deliverData = await this.dao.findOne({
id: pobj.id
});
if (!deliverData) {
throw new Error("查不到交付单");
}
if (![system.SERVERSESTATUS.RECEIVED, system.SERVERSESTATUS.COLLECTING].includes(deliverData.delivery_status)) {
throw new Error("该交付单状态下不可提交");
}
await this.dao.updateByWhere({
delivery_status: system.SERVERSESTATUS.CLOSED,
close_reason: pobj.close_reason
}, {
id: pobj.id
});
this.statuslogDao.create({
flow_type: system.FLOWCODE.DELIVERY,
flow_id: pobj.id,
status_code: system.SERVERSESTATUS.CLOSED
});
return "success"
}
async addMail(pobj) {
/**
* 判断状态
* 保存 邮寄信息
* 更改流转状态
*/
let result = await this.dao.findInfo(pobj);
if (!result) {
throw new Error("交付单不可查看");
}
if (!result.qualification) {
throw new Error("请先上传资质信息");
}
if (result.delivery_status !== system.SERVERSESTATUS.DISPOSEING) {
throw new Error("该状态下不可填写邮寄信息");
}
const { material } = result;
let { proposerInfo } = material
proposerInfo.recipientInfo = pobj.recipientInfo;
return this.db.transaction(async (t) => {
await this.materialDao.updateByWhere({
proposerInfo
}, {
id: material.id
}, t);
await this.dao.updateByWhere({
delivery_status: system.SERVERSESTATUS.POSTING,
}, {
id: pobj.id
}, t);
this.statuslogDao.create({
flow_type: system.FLOWCODE.DELIVERY,
flow_id: pobj.id,
status_code: system.SERVERSESTATUS.POSTING
});
return "success"
});
}
} }
module.exports = DeliverService; module.exports = DeliverService;
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