123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014 |
- 'use strict';
- /**
- * 台账审批流程表
- *
- * @author Mai
- * @date 2018/5/25
- * @version
- */
- const auditConst = require('../const/audit').ledger;
- const auditType = require('../const/audit').auditType;
- const smsTypeConst = require('../const/sms_type');
- const SMS = require('../lib/sms');
- const SmsAliConst = require('../const/sms_alitemplate');
- const wxConst = require('../const/wechat_template');
- const shenpiConst = require('../const/shenpi');
- const pushType = require('../const/audit').pushType;
- const pushOperate = require('../const/spec_3f').pushOperate;
- module.exports = app => {
- class LedgerAudit extends app.BaseService {
- /**
- * 构造函数
- *
- * @param {Object} ctx - egg全局变量
- * @return {void}
- */
- constructor(ctx) {
- super(ctx);
- this.tableName = 'ledger_audit';
- }
- /**
- * 获取标段审核人信息
- *
- * @param {Number} tenderId - 标段id
- * @param {Number} auditorId - 审核人id
- * @param {Number} times - 第几次审批
- * @return {Promise<*>}
- */
- async getAuditor(tenderId, auditorId, times = 1) {
- const sql = 'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`audit_order`, la.`audit_type`, la.`audit_ledger_id`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
- ' FROM ?? AS la Left Join ?? AS pa ON la.`audit_id` = pa.`id`' +
- ' WHERE la.`tender_id` = ? and la.`audit_id` = ? and la.`times` = ?';
- const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, auditorId, times];
- return await this.db.queryOne(sql, sqlParam);
- }
- async getAuditorByOrder(tenderId, order, times = 1) {
- const sql = 'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`audit_order`, la.`audit_type`, la.`audit_ledger_id`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
- ' FROM ?? AS la Left Join ?? AS pa ON la.`audit_id` = pa.`id`' +
- ' WHERE la.`tender_id` = ? and la.`audit_order` = ? and la.`times` = ?';
- const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, order, times];
- return await this.db.queryOne(sql, sqlParam);
- }
- async getAuditorsByOrder(tenderId, order, times) {
- const sql =
- 'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`,' +
- ' la.`times`, la.`audit_order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time`, la.audit_type, la.audit_ledger_id ' +
- ' FROM ' + this.tableName + ' AS la' +
- ' Left Join ' + this.ctx.service.projectAccount.tableName + ' AS pa ON la.`audit_id` = pa.`id`' +
- ' WHERE la.`tender_id` = ? and la.`audit_order` = ? and la.`times` = ?' +
- ' ORDER BY `audit_order` DESC';
- const sqlParam = [tenderId, order, times ? times: 1];
- return await this.db.query(sql, sqlParam);
- }
- async getLastestAuditor(tenderId, times, status) {
- const sql =
- 'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`,' +
- ' la.`times`, la.`audit_order`, la.`audit_type`, la.`audit_ledger_id`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
- ' FROM ' + this.tableName + ' AS la' +
- ' Left Join ' + this.ctx.service.projectAccount.tableName + ' AS pa ON la.`audit_id` = pa.`id`' +
- ' WHERE la.`tender_id` = ? and la.`status` = ? and la.`times` = ?' +
- ' ORDER BY `audit_order` DESC';
- const sqlParam = [tenderId, status, times ? times : 1];
- return await this.db.queryOne(sql, sqlParam);
- }
- async getLastestAuditors(tenderId, times, status) {
- const sql =
- 'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.audit_type, la.audit_order, la.audit_ledger_id,' +
- ' la.`times`, la.`audit_order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
- ' FROM ' + this.tableName + ' AS la' +
- ' Left Join ' + this.ctx.service.projectAccount.tableName + ' AS pa ON la.`audit_id` = pa.`id`' +
- ' WHERE la.`tender_id` = ? and la.`status` = ? and la.`times` = ?' +
- ' ORDER BY `audit_order` DESC';
- const sqlParam = [tenderId, status, times ? times: 1];
- const result = await this.db.query(sql, sqlParam);
- if (result.length === 0) return [];
- return result.filter(x => { return x.audit_order === result[0].audit_order });
- }
- /**
- * 获取标段审核列表信息
- *
- * @param {Number} tenderId - 标段id
- * @param {Number} times - 第几次审批
- * @return {Promise<*>}
- */
- async getAuditors(tenderId, times = 1, order_sort = 'asc') {
- const sql = 'SELECT la.id, la.audit_id, la.times, la.audit_order, la.audit_type, la.audit_ledger_id, la.status, la.opinion, la.begin_time, la.end_time, ' +
- ' pa.name, pa.company, pa.role, pa.mobile, pa.telephone, pa.sign_path' +
- ` FROM ${this.tableName} la LEFT JOIN ${this.ctx.service.projectAccount.tableName} pa ON la.audit_id = pa.id` +
- ' WHERE la.tender_id = ? AND la.times = ?' +
- ' ORDER BY la.audit_order ' + order_sort;
- const sqlParam = [tenderId, times];
- const result = await this.db.query(sql, sqlParam);
- const max_sort = this._.max(result.map(x => { return x.audit_order; }));
- for (const i in result) {
- result[i].max_sort = max_sort;
- }
- return result;
- }
- /**
- * 获取标段当前审核人
- *
- * @param {Number} tenderId - 标段id
- * @param {Number} times - 第几次审批
- * @return {Promise<*>}
- */
- async getCurAuditor(tenderId, times = 1) {
- const sql =
- 'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`audit_order`, la.`audit_type`, la.`audit_ledger_id`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
- ' FROM ?? AS la Left Join ?? AS pa On la.`audit_id` = pa.`id`' +
- ' WHERE la.`tender_id` = ? and la.`status` = ? and la.`times` = ?';
- const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, auditConst.status.checking, times];
- return await this.db.queryOne(sql, sqlParam);
- }
- async getCurAuditors(tenderId, times = 1) {
- const sql =
- 'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`audit_order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time`, la.audit_type, la.audit_order, la.audit_ledger_id ' +
- ' FROM ?? AS la Left Join ?? AS pa On la.`audit_id` = pa.`id`' +
- ' WHERE la.`tender_id` = ? and la.`status` = ? and la.`times` = ?';
- const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, auditConst.status.checking, times];
- return await this.db.query(sql, sqlParam);
- }
- async getAuditorGroup(tenderId, times) {
- const auditors = await this.getAuditors(tenderId, times); // 全部参与的审批人
- return this.ctx.helper.groupAuditors(auditors, 'audit_order');
- }
- async getUserGroup(tenderId, times) {
- const group = await this.getAuditorGroup(tenderId, times);
- const sql =
- 'SELECT pa.`id` As audit_id, pa.`name`, pa.`company`, pa.`role`, ? As times, ? As tender_id, 0 As audit_order, 1 As audit_type' +
- ' FROM ' + this.ctx.service.tender.tableName + ' As t' +
- ' LEFT JOIN ' + this.ctx.service.projectAccount.tableName + ' As pa' +
- ' ON t.user_id = pa.id' +
- ' WHERE t.id = ?';
- const sqlParam = [times, tenderId, tenderId];
- const user = await this.db.queryOne(sql, sqlParam);
- group.unshift([ user ]);
- return group;
- }
- groupAuditorsUniq(group) {
- const helper = this.ctx.helper;
- const uniqGroup = [];
- for (const g of group) {
- const curAuditId = g.map(x => { return x.audit_id; });
- const sameGroup = uniqGroup.find(x => {
- if (!x) return false;
- if (x[0].audit_type !== g[0].audit_type) return false;
- const auditId = x.map(xa => { return xa.audit_id; });
- helper._.remove(auditId, function(a) { return curAuditId.indexOf(a) >= 0; });
- return auditId.length === 0;
- });
- if (!sameGroup) uniqGroup[g[0].audit_order] = g;
- }
- return uniqGroup.filter(x => { return !!x });
- }
- async getUniqUserGroup(tenderId, times) {
- const group = await this.getAuditorGroup(tenderId, times);
- const sql =
- 'SELECT pa.`id` As audit_id, pa.`name`, pa.`company`, pa.`role`, ? As times, ? As tender_id, 0 As audit_order, 1 As audit_type' +
- ' FROM ' + this.ctx.service.tender.tableName + ' As t' +
- ' LEFT JOIN ' + this.ctx.service.projectAccount.tableName + ' As pa' +
- ' ON t.user_id = pa.id' +
- ' WHERE t.id = ?';
- const sqlParam = [times, tenderId, tenderId];
- const user = await this.db.queryOne(sql, sqlParam);
- group.unshift([ user ]);
- return this.groupAuditorsUniq(group);
- }
- async getAuditorHistory(tenderId, times, reverse = false) {
- const history = [];
- if (times >= 1) {
- for (let i = 1; i <= times; i++) {
- const auditors = await this.getAuditors(tenderId, i);
- const group = this.ctx.helper.groupAuditors(auditors, 'audit_order');
- const historyGroup = [];
- const max_order = group.length > 0 && group[group.length - 1].length > 0 ? group[group.length - 1][0].audit_order : -1;
- for (const g of group) {
- const his = {
- beginYear: '', beginDate: '', beginTime: '', endYear: '', endDate: '', endTime: '', begin_time: null, end_time: null,
- audit_type: g[0].audit_type, audit_order: g[0].audit_order,
- auditors: g
- };
- if (his.audit_type === auditType.key.common) {
- his.name = g[0].name;
- } else {
- his.name = this.ctx.helper.transFormToChinese(his.audit_order) + '审';
- }
- his.is_final = his.audit_order === max_order;
- if (g[0].begin_time) {
- his.begin_time = g[0].begin_time;
- const beginTime = this.ctx.moment(g[0].begin_time);
- his.beginYear = beginTime.format('YYYY');
- his.beginDate = beginTime.format('MM-DD');
- his.beginTime = beginTime.format('HH:mm:ss');
- }
- let end_time;
- g.forEach(x => {
- if (x.status === auditConst.status.checkSkip) return;
- if (!his.status || x.status === auditConst.status.checking) his.status = x.status;
- if (x.end_time && (!end_time || x.end_time > end_time)) {
- end_time = x.end_time;
- if (his.status !== auditConst.status.checking) his.status = x.status;
- }
- });
- if (end_time) {
- his.end_time = end_time;
- const endTime = this.ctx.moment(end_time);
- his.endYear = endTime.format('YYYY');
- his.endDate = endTime.format('MM-DD');
- his.endTime = endTime.format('HH:mm:ss');
- }
- historyGroup.push(his);
- }
- if (reverse) {
- history.push(historyGroup.reverse());
- } else {
- history.push(historyGroup);
- }
- }
- }
- return history;
- }
- async getUniqAuditor(tenderId, times) {
- const auditors = await this.getAuditors(tenderId, times); // 全部参与的审批人
- const result = [];
- auditors.forEach(x => {
- if (result.findIndex(r => { return x.audit_id === r.audit_id && x.audit_order === r.audit_order; }) < 0) {
- result.push(x);
- }
- });
- return result;
- }
- async loadLedgerUser(tender) {
- const status = auditConst.status;
- const accountId = this.ctx.session.sessionUser.accountId;
- tender.user = await this.ctx.service.projectAccount.getAccountInfoById(tender.user_id);
- tender.auditors = await this.getAuditors(tender.id, tender.ledger_times); // 全部参与的审批人
- tender.auditorIds = this._.map(tender.auditors, 'audit_id');
- tender.curAuditors = tender.auditors.filter(x => { return x.status === status.checking; }); // 当前流程中审批中的审批人
- tender.curAuditorIds = this._.map(tender.curAuditors, 'audit_id');
- tender.flowAuditors = tender.curAuditors.length > 0 ? tender.auditors.filter(x => { return x.audit_order === tender.curAuditors[0].audit_order; }) : []; // 当前流程中参与的审批人(包含会签时,审批通过的人)
- tender.flowAuditorIds = this._.map(tender.flowAuditors, 'audit_id');
- tender.nextAuditors = tender.curAuditors.length > 0 ? tender.auditors.filter(x => { return x.audit_order === tender.curAuditors[0].audit_order + 1; }) : [];
- tender.nextAuditorIds = this._.map(tender.nextAuditors, 'audit_id');
- tender.auditorGroups = this.ctx.helper.groupAuditors(tender.auditors, 'audit_order');
- tender.userGroups = this.groupAuditorsUniq(tender.auditorGroups);
- tender.userGroups.unshift([{
- audit_id: tender.user.id, order: 0, times: tender.ledger_times, audit_order: 0, audit_type: auditType.key.common,
- name: tender.user.name, role: tender.user.role, company: tender.user.company
- }]);
- tender.finalAuditorIds = tender.userGroups[tender.userGroups.length - 1].map(x => { return x.audit_id; });
- tender.relaAuditor = tender.auditors.find(x => { return x.audit_id === accountId });
- tender.assists = [];// await this.service.ledgerAuditAss.getData(tender); // 全部协同人
- tender.assists = tender.assists.filter(x => {
- return x.user_id === tender.user_id || tender.auditorIds.indexOf(x.user_id) >= 0;
- }); // 过滤无效协同人
- tender.userAssists = tender.assists.filter(x => { return x.user_id === tender.user_id; }); // 原报协同人
- tender.userAssistIds = this._.map(tender.userAssists, 'ass_user_id');
- tender.auditAssists = tender.assists.filter(x => { return x.user_id !== tender.user_id; }); // 审批协同人
- tender.auditAssistIds = this._.map(tender.auditAssists, 'ass_user_id');
- tender.relaAssists = tender.assists.filter(x => { return x.user_id === accountId }); // 登录人的协同人
- tender.userIds = tender.ledger_status === status.uncheck // 当前流程下全部参与人id
- ? [tender.user_id]
- : [tender.user_id, ...tender.userAssistIds, ...tender.auditorIds, ...tender.auditAssistIds];
- }
- async loadLedgerAuditViewData(tender) {
- const times = tender.ledger_status === auditConst.status.checkNo ? tender.ledger_times - 1 : tender.ledger_times;
- if (!tender.user) tender.user = await this.ctx.service.projectAccount.getAccountInfoById(tender.user_id);
- tender.auditHistory = await this.getAuditorHistory(tender.id, times);
- // 获取审批流程中左边列表
- if (tender.status === auditConst.status.checkNo && tender.user_id !== this.ctx.session.sessionUser.accountId) {
- const auditors = await this.getAuditors(tender.id, times); // 全部参与的审批人
- const auditorGroups = this.ctx.helper.groupAuditors(auditors, 'audit_order');
- tender.auditors2 = this.groupAuditorsUniq(auditorGroups);
- tender.auditors2.unshift([{
- audit_id: tender.user.id, order: 0, times: tender.ledger_times - 1, audit_order: 0, audit_type: auditType.key.common,
- name: tender.user.name, role: tender.user.role, company: tender.user.company
- }]);
- } else {
- tender.auditors2 = tender.userGroups;
- }
- if (tender.ledger_status === auditConst.status.uncheck || tender.ledger_status === auditConst.status.checkNo) {
- tender.auditorList = await this.getAuditors(tender.id, tender.ledger_times);
- }
- }
- /**
- * 获取标段审核人最后一位的名称
- *
- * @param {Number} tenderId - 标段id
- * @param {Number} auditorId - 审核人id
- * @param {Number} times - 第几次审批
- * @return {Promise<*>}
- */
- async getStatusName(tenderId, times) {
- const sql = 'SELECT pa.`name` FROM ?? AS la Left Join ?? AS pa ON la.`audit_id` = pa.`id`' +
- ' WHERE la.`tender_id` = ? and la.`status` != ? ORDER BY la.`times` DESC, la.`audit_order` DESC';
- const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, auditConst.status.uncheck];
- return await this.db.queryOne(sql, sqlParam);
- }
- async getFinalAuditGroup(tenderId, times = 1) {
- const sql =
- 'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, pa.`sign_path`, la.`times`, la.`tender_id`, Max(la.`audit_order`) as max_order ' +
- ' FROM ?? AS la Left Join ?? AS pa On la.`audit_id` = pa.`id`' +
- ' WHERE la.`tender_id` = ? and la.`times` = ? GROUP BY la.`audit_id` ORDER BY la.`audit_order`';
- const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, times];
- const result = await this.db.query(sql, sqlParam);
- for (const r of result) {
- const auditor = await this.getDataByCondition({tender_id: tenderId, times: r.times, audit_order: r.max_order});
- r.status = auditor.status;
- r.opinion = auditor.opinion;
- r.begin_time = auditor.begin_time;
- r.end_time = auditor.end_time;
- }
- return result;
- }
- /**
- * 获取最新审核顺序
- *
- * @param {Number} tenderId - 标段id
- * @param {Number} times - 第几次审批
- * @return {Promise<number>}
- */
- async getNewOrder(tenderId, times = 1) {
- const sql = 'SELECT Max(??) As max_order FROM ?? Where `tender_id` = ? and `times` = ?';
- const sqlParam = ['audit_order', this.tableName, tenderId, times];
- const result = await this.db.queryOne(sql, sqlParam);
- return result && result.max_order ? result.max_order + 1 : 1;
- }
- /**
- * 新增审核人
- *
- * @param {Number} tenderId - 标段id
- * @param {Number} auditorId - 审核人id
- * @param {Number} times - 第几次审批
- * @return {Promise<number>}
- */
- async addAuditor(tenderId, auditorId, times = 1, is_gdzs = 0) {
- const transaction = await this.db.beginTransaction();
- try {
- let newOrder = await this.getNewOrder(tenderId, times);
- // 判断是否存在固定终审,存在则newOrder - 1并使终审order+1
- newOrder = is_gdzs === 1 ? newOrder - 1 : newOrder;
- if (is_gdzs) await this._syncOrderByDelete(transaction, tenderId, newOrder, times, '+');
- const data = {
- tender_id: tenderId,
- audit_id: auditorId,
- times,
- audit_order: newOrder,
- status: auditConst.status.uncheck,
- };
- const result = await transaction.insert(this.tableName, data);
- await transaction.commit();
- return (result.effectRows = 1);
- } catch (err) {
- await transaction.rollback();
- throw err;
- }
- return false;
- }
- /**
- * 移除审核人时,同步其后审核人order
- * @param transaction - 事务
- * @param {Number} tenderId - 标段id
- * @param {Number} auditorId - 审核人id
- * @param {Number} times - 第几次审批
- * @return {Promise<*>}
- * @private
- */
- async _syncOrderByDelete(transaction, tenderId, order, times, selfOperate = '-') {
- this.initSqlBuilder();
- this.sqlBuilder.setAndWhere('tender_id', {
- value: tenderId,
- operate: '=',
- });
- this.sqlBuilder.setAndWhere('audit_order', {
- value: order,
- operate: '>=',
- });
- this.sqlBuilder.setAndWhere('times', {
- value: times,
- operate: '=',
- });
- this.sqlBuilder.setUpdateData('audit_order', {
- value: 1,
- selfOperate: selfOperate,
- });
- const [sql, sqlParam] = this.sqlBuilder.build(this.tableName, 'update');
- const data = await transaction.query(sql, sqlParam);
- return data;
- }
- /**
- * 移除审核人
- *
- * @param {Number} tenderId - 标段id
- * @param {Number} auditorId - 审核人id
- * @param {Number} times - 第几次审批
- * @return {Promise<boolean>}
- */
- async deleteAuditor(tenderId, auditorId, times = 1) {
- const transaction = await this.db.beginTransaction();
- try {
- const condition = { tender_id: tenderId, audit_id: auditorId, times };
- const auditor = await this.getDataByCondition(condition);
- if (!auditor) {
- throw '该审核人不存在';
- }
- await this._syncOrderByDelete(transaction, tenderId, auditor.audit_order, times);
- await transaction.delete(this.tableName, condition);
- await transaction.commit();
- } catch (err) {
- await transaction.rollback();
- throw err;
- }
- return true;
- }
- /**
- * 开始审批
- *
- * @param {Number} tenderId - 标段id
- * @param {Number} times - 第几次审批
- * @return {Promise<boolean>}
- */
- async start(tenderId, times = 1) {
- const audits = await this.getAllDataByCondition({ where: { tender_id: tenderId, times, audit_order: 1 } });
- if (audits.length === 0) {
- if(this.ctx.tender.info.shenpi.ledger === shenpiConst.sp_status.gdspl) {
- throw '请联系管理员添加审批人';
- } else {
- throw '请先选择审批人,再上报数据';
- }
- }
- const sum = await this.ctx.service.ledger.addUp({ tender_id: tenderId /* , is_leaf: true*/ });
- // 拷贝备份台账数据
- const his_id = await this.ctx.service.ledgerHistory.backupLedgerHistory(this.ctx.tender.data);
- const transaction = await this.db.beginTransaction();
- try {
- const begin_time = new Date();
- const updateAuditData = audits.map(a => { return { id: a.id, status: auditConst.status.checking, begin_time }; });
- await transaction.updateRows(this.tableName, updateAuditData);
- await transaction.update(this.ctx.service.tender.tableName, {
- id: tenderId,
- ledger_status: auditConst.status.checking,
- total_price: sum.total_price,
- deal_tp: sum.deal_tp,
- his_id: his_id,
- });
- await this.ctx.service.tenderCache.updateLedgerCache4Start(transaction, tenderId, auditConst.status.checking, audits, sum);
- // 添加短信通知-需要审批提醒功能
- const auditorIds = audits.map(x => { return x.audit_id; });
- await this.ctx.helper.sendAliSms(auditorIds, smsTypeConst.const.TZ, smsTypeConst.judge.approval.toString(), SmsAliConst.template.ledger_check);
- // 微信模板通知
- const wechatData = {
- status: wxConst.status.check,
- tips: wxConst.tips.check,
- begin_time: Date.parse(new Date()),
- };
- await this.ctx.helper.sendWechat(auditorIds, smsTypeConst.const.TZ, smsTypeConst.judge.approval.toString(), wxConst.template.ledger, wechatData);
- for (const audit of audits) {
- await this.ctx.service.noticeAgain.addNoticeAgain(transaction, smsTypeConst.const.TZ, {
- pid: this.ctx.session.sessionProject.id,
- tid: tenderId,
- uid: audit.audit_id,
- sp_type: 'ledger',
- sp_id: audit.id,
- table_name: this.tableName,
- template: wxConst.template.ledger,
- wx_data: wechatData,
- });
- }
- await transaction.commit();
- } catch (err) {
- await transaction.rollback();
- throw err;
- }
- return true;
- }
- async _checkNo(tenderId, opinion, times) {
- const accountId = this.ctx.session.sessionUser.accountId;
- const pid = this.ctx.session.sessionProject.id;
- const auditors = await this.getAllDataByCondition({ where: { tender_id: tenderId, times, status: auditConst.status.checking } });
- if (auditors.length === 0) throw '审核数据错误';
- const selfAuditor = auditors.find(x => { return x.audit_id === accountId; });
- if (!selfAuditor) throw '当前标段您无权审批';
- const beginAuditors = await this.getAllDataByCondition({ where: { tender_id: tenderId, audit_order: 1, times } });
- const time = new Date();
- const noticeContent = await this.getNoticeContent(selfAuditor.tender_id, pid, accountId, opinion);
- const defaultNoticeRecord = { pid, type: pushType.ledger, status: auditConst.status.checkNo, content: noticeContent };
- const transaction = await this.db.beginTransaction();
- try {
- // 获取审核人列表,添加提醒
- const records = [{ uid: this.ctx.tender.data.user_id, ...defaultNoticeRecord } ];
- const auditList = await this.getAuditors(tenderId, times);
- auditList.forEach(audit => {
- records.push({ uid: audit.audit_id, ...defaultNoticeRecord});
- });
- await transaction.insert('zh_notice', records);
- const users = this._.uniq(this._.concat(this._.map(auditList, 'audit_id'), this.ctx.tender.data.user_id));
- // 更新当前审核流程
- const updateAuditData = auditors.map(x => {
- return {
- id: x.id,
- status: x.audit_id === selfAuditor.audit_id ? auditConst.status.checkNo : auditConst.status.checkSkip,
- opinion: x.audit_id === selfAuditor.audit_id ? opinion : '',
- end_time: x.audit_id === selfAuditor.audit_id ? time : null,
- };
- });
- await transaction.updateRows(this.tableName, updateAuditData);
- // 审批提醒
- await this.ctx.service.noticeAgain.stopNoticeAgain(transaction, this.tableName, this._.map(auditors, 'id'));
- // 同步标段信息
- await transaction.update(this.ctx.service.tender.tableName, {
- id: tenderId, ledger_times: times + 1, ledger_status: auditConst.status.checkNo,
- });
- await this.ctx.service.tenderCache.updateLedgerCache(transaction, tenderId, auditConst.status.checkNo, auditConst.status.checkNo, [{ audit_id: this.ctx.tender.data.user_id }]);
- // 拷贝新一次审核流程列表
- const orgAuditors = await this.getAllDataByCondition({
- where: { tender_id: tenderId, times },
- columns: ['tender_id', 'audit_order', 'audit_id', 'audit_type', 'audit_ledger_id'],
- });
- const insertAuditors = orgAuditors.map(x => {
- return { ...x, times: times + 1, status: auditConst.status.uncheck };
- });
- await transaction.insert(this.tableName, insertAuditors);
- await this.ctx.helper.sendAliSms(users, smsTypeConst.const.TZ, smsTypeConst.judge.result.toString(), SmsAliConst.template.ledger_result, {
- status: SmsAliConst.status.back,
- });
- // 微信模板通知
- const wechatData = {
- status: wxConst.status.back,
- tips: wxConst.tips.back,
- begin_time: Date.parse(beginAuditors[0].begin_time),
- };
- await this.ctx.helper.sendWechat(users, smsTypeConst.const.TZ, smsTypeConst.judge.result.toString(), wxConst.template.ledger, wechatData);
- await transaction.commit();
- } catch (err) {
- await transaction.rollback();
- throw err;
- }
- }
- async _checked(tenderId, opinion, times) {
- const accountId = this.ctx.session.sessionUser.accountId;
- const pid = this.ctx.session.sessionProject.id;
- const auditors = await this.getAllDataByCondition({ where: { tender_id: tenderId, times, status: auditConst.status.checking } });
- if (auditors.length === 0) throw '审核数据错误';
- const selfAuditor = auditors.find(x => { return x.audit_id === accountId; });
- if (!selfAuditor) throw '当前标段您无权审批';
- const flowAuditors = await this.getAllDataByCondition({ where: { tender_id: tenderId, times, audit_order: selfAuditor.audit_order } });
- const nextAuditors = await this.getAllDataByCondition({ where: { tender_id: tenderId, times, audit_order: selfAuditor.audit_order + 1 } });
- const beginAuditors = await this.getAllDataByCondition({ where: { tender_id: tenderId, audit_order: 1, times } });
- const time = new Date();
- const noticeContent = await this.getNoticeContent(selfAuditor.tender_id, pid, accountId, opinion);
- const defaultNoticeRecord = { pid, type: pushType.ledger, status: auditConst.status.checked, content: noticeContent };
- const transaction = await this.db.beginTransaction();
- try {
- // 获取审核人列表,添加提醒
- const records = [{ uid: this.ctx.tender.data.user_id, ...defaultNoticeRecord } ];
- const auditList = await this.getAuditors(tenderId, times);
- auditList.forEach(audit => {
- records.push({ uid: audit.audit_id, ...defaultNoticeRecord});
- });
- await transaction.insert('zh_notice', records);
- const users = this._.uniq(this._.concat(this._.map(auditList, 'audit_id'), this.ctx.tender.data.user_id));
- // 更新当前审核流程
- await transaction.update(this.tableName, { id: selfAuditor.id, status: auditConst.status.checked, opinion, end_time: time });
- // 审批提醒
- await this.ctx.service.noticeAgain.stopNoticeAgain(transaction, this.tableName, this._.map(auditors, 'id'));
- if (auditors.length === 1 || selfAuditor.audit_type === auditType.key.or) {
- // 或签更新他人审批状态
- if (selfAuditor.audit_type === auditType.key.or) {
- const updateOther = [];
- for (const audit of auditors) {
- if (audit.audit_id === selfAuditor.audit_id) continue;
- updateOther.push({ id: audit.id, status: auditConst.status.checkSkip, opinion: '', end_time: time });
- }
- if (updateOther.length > 0) {
- await transaction.updateRows(this.tableName, updateOther);
- await this.ctx.service.noticeAgain.stopNoticeAgain(transaction, this.tableName, updateOther.map(x => { return x.id}));
- }
- }
- // 无下一审核人表示,审核结束
- if (nextAuditors.length > 0) {
- const nextAuditUpdateData = nextAuditors.map(x => { return {id: x.id, status: auditConst.status.checking, begin_time: time }; });
- await transaction.updateRows(this.tableName, nextAuditUpdateData);
- await this.ctx.service.tenderCache.updateLedgerCache(transaction, tenderId, auditConst.status.checking, auditConst.status.checked, nextAuditors);
- const nextAuditorIds = nextAuditors.map(x => { return x.audit_id; });
- await this.ctx.helper.sendAliSms(nextAuditorIds, smsTypeConst.const.TZ, smsTypeConst.judge.approval.toString(), SmsAliConst.template.ledger_check);
- // 微信模板通知
- const wechatData = {
- status: wxConst.status.check,
- tips: wxConst.tips.check,
- begin_time: Date.parse(beginAuditors[0].begin_time),
- };
- await this.ctx.helper.sendWechat(nextAuditorIds, smsTypeConst.const.TZ, smsTypeConst.judge.approval.toString(), wxConst.template.ledger, wechatData);
- for (const audit of nextAuditors) {
- await this.ctx.service.noticeAgain.addNoticeAgain(transaction, smsTypeConst.const.TZ, {
- pid: this.ctx.session.sessionProject.id,
- tid: tenderId,
- uid: audit.audit_id,
- sp_type: 'ledger',
- sp_id: audit.id,
- table_name: this.tableName,
- template: wxConst.template.ledger,
- wx_data: wechatData,
- });
- }
- } else {
- // 同步标段信息
- await transaction.update(this.ctx.service.tender.tableName, {
- id: tenderId, ledger_status: auditConst.status.checked,
- });
- await this.ctx.service.tenderCache.updateLedgerCache(transaction, tenderId, auditConst.status.checked, auditConst.status.checked);
- // 审批通过,添加标记
- await this.ctx.service.tenderTag.saveTenderTag(tenderId, { ledger_time: time }, transaction);
- await this.ctx.helper.sendAliSms(users, smsTypeConst.const.TZ, smsTypeConst.judge.result.toString(), SmsAliConst.template.ledger_result, {
- status: SmsAliConst.status.success,
- });
- // 微信模板通知
- const wechatData = {
- status: wxConst.status.success,
- tips: wxConst.tips.success,
- begin_time: Date.parse(beginAuditors[0].begin_time),
- };
- await this.ctx.helper.sendWechat(users, smsTypeConst.const.TZ, smsTypeConst.judge.result.toString(), wxConst.template.ledger, wechatData);
- // 审批通过 - 检查三方特殊推送
- await this.ctx.service.specMsg.addLedgerMsg(transaction, pid, this.ctx.tender, pushOperate.ledger.checked);
- }
- }
- await transaction.commit();
- } catch (err) {
- await transaction.rollback();
- throw err;
- }
- }
- /**
- * 审批
- * @param {Number} tenderId - 标段id
- * @param {auditConst.status.checked|auditConst.status.checkNo} checkType - 审批结果
- * @param {String} opinion 审批意见
- * @param {Number} times - 第几次审批
- * @return {Promise<void>}
- */
- async check(tenderId, checkType, opinion, times = 1) {
- switch (checkType) {
- case auditConst.status.checked: await this._checked(tenderId, opinion, times); break;
- case auditConst.status.checkNo: await this._checkNo(tenderId, opinion, times); break;
- default: throw '提交数据错误';
- }
- }
- /**
- * 重新审批
- * @param {Number} tenderId - 标段id
- * @param {Number} times - 第几次审批
- * @return {Promise<void>}
- */
- async checkAgain(tenderId, times = 1) {
- const time = new Date();
- const accountId = this.ctx.session.sessionUser.accountId;
- // 整理当前流程审核人状态更新
- const auditors = await this.getAllDataByCondition({
- where: { tender_id: tenderId, times },
- orders: [['audit_order', 'desc']],
- });
- if (auditors.length <= 0) throw '台账审核数据错误';
- const flowAuditors = auditors.filter(x => { return x.audit_order === auditors[0].audit_order; });
- const selfAudit = flowAuditors.find(x => { return x.audit_id === accountId; });
- if (!selfAudit) throw '当前台账您无权重审';
- const tender = this.ctx.service.tender.getDataById(tenderId);
- if (!tender) throw '标段数据错误';
- let otherAuditIds = [tender.user_id, ...auditors.map(x => { return x.audit_id })];
- otherAuditIds = this._.uniq(otherAuditIds).filter(x => { return x !== selfAudit.audit_id; });
- const checkAgainAuditor = flowAuditors.map(x => {
- return {
- tender_id: tenderId, times, audit_order: x.audit_order + 1, audit_id: x.audit_id,
- audit_type: x.audit_type, audit_ledger_id: x.audit_ledger_id,
- begin_time: time, end_time: time, opinion: '',
- status: x.audit_id === accountId ? auditConst.status.checkAgain : auditConst.status.checkSkip,
- }
- });
- const checkingAuditor = flowAuditors.map(x => {
- return {
- tender_id: tenderId, times, audit_order: x.audit_order + 2, audit_id: x.audit_id,
- audit_type: x.audit_type, audit_ledger_id: x.audit_ledger_id,
- begin_time: time, end_time: null, opinion: '', status: auditConst.status.checking,
- };
- });
- const transaction = await this.db.beginTransaction();
- try {
- // 当前审批人2次添加至流程中
- await transaction.insert(this.tableName, checkAgainAuditor);
- const checking_result = await transaction.insert(this.tableName, checkingAuditor);
- // 同步标段信息
- await transaction.update(this.ctx.service.tender.tableName, {
- id: tenderId,
- ledger_status: auditConst.status.checking,
- });
- await this.ctx.service.tenderCache.updateLedgerCache(transaction, tenderId, auditConst.status.checking, auditConst.status.checkAgain, checkingAuditor);
- if (otherAuditIds.length > 0) {
- await this.ctx.helper.sendAliSms(otherAuditIds, smsTypeConst.const.TZ, smsTypeConst.judge.approval.toString(), SmsAliConst.template.ledger_check);
- // 微信模板通知
- const wechatData = {
- status: wxConst.status.check,
- tips: wxConst.tips.check,
- begin_time: Date.parse(time),
- };
- await this.ctx.helper.sendWechat(selfAudit.audit_id, smsTypeConst.const.TZ, smsTypeConst.judge.approval.toString(), wxConst.template.ledger, wechatData);
- await this.ctx.service.noticeAgain.addNoticeAgain(transaction, smsTypeConst.const.TZ, {
- pid: this.ctx.session.sessionProject.id,
- tid: this.ctx.tender.id,
- uid: selfAudit.audit_id,
- sp_type: 'ledger',
- sp_id: checking_result.insertId,
- table_name: this.tableName,
- template: wxConst.template.ledger,
- wx_data: wechatData,
- });
- }
- await transaction.commit();
- } catch (err) {
- await transaction.rollback();
- throw err;
- }
- }
- /**
- * 获取审核人需要审核的标段列表
- *
- * @param auditorId
- * @return {Promise<*>}
- */
- async getAuditTender(auditorId) {
- const sql =
- 'SELECT la.`audit_id`, la.`times`, la.`audit_order`, la.`begin_time`, la.`end_time`, t.`id`, t.`name`, t.`project_id`, t.`type`, t.`user_id`, t.`ledger_status` ' +
- ' FROM ?? AS la Left Join ?? AS t ON la.`tender_id` = t.`id` ' +
- ' WHERE ((la.`audit_id` = ? and la.`status` = ?) OR (t.`user_id` = ? and t.`ledger_status` = ? and la.`status` = ? and la.`times` = (t.`ledger_times`-1)))' +
- ' ORDER BY la.`begin_time` DESC';
- const sqlParam = [
- this.tableName,
- this.ctx.service.tender.tableName,
- auditorId,
- auditConst.status.checking,
- auditorId,
- auditConst.status.checkNo,
- auditConst.status.checkNo,
- ];
- return await this.db.query(sql, sqlParam);
- }
- /**
- * 获取审核人审核的次数
- *
- * @param auditorId
- * @return {Promise<*>}
- */
- async getCountByChecked(auditorId) {
- return await this.db.count(this.tableName, { audit_id: auditorId, status: [auditConst.status.checked, auditConst.status.checkNo] });
- }
- /**
- * 获取最近一次审批结束时间
- *
- * @param auditorId
- * @return {Promise<*>}
- */
- async getLastEndTimeByChecked(auditorId) {
- const sql = 'SELECT `end_time` FROM ?? WHERE `audit_id` = ? ' +
- 'AND `status` in (' + this.ctx.helper.getInArrStrSqlFilter([auditConst.status.checked, auditConst.status.checkNo]) + ') ORDER BY `end_time` DESC';
- const sqlParam = [this.tableName, auditorId];
- const result = await this.db.queryOne(sql, sqlParam);
- return result ? result.end_time : null;
- }
- /**
- * 用于添加推送所需的content内容
- * @param {Number} id 标段id
- * @param {Number} pid 项目id
- * @param {Number} uid 审核人id
- */
- async getNoticeContent(id, pid, uid, opinion = '') {
- const noticeSql =
- 'SELECT * FROM (SELECT ' +
- ' t.`id` As `tid`, t.`name`, pa.`name` As `su_name`, pa.role As `su_role`' +
- ' FROM (SELECT * FROM ?? WHERE `id` = ? ) As t' +
- ' LEFT JOIN ?? As pa ON pa.`id` = ?' +
- ' WHERE t.`project_id` = ? ) as new_t GROUP BY new_t.`tid`';
- const noticeSqlParam = [this.ctx.service.tender.tableName, id, this.ctx.service.projectAccount.tableName, uid, pid];
- const content = await this.db.query(noticeSql, noticeSqlParam);
- if (content.length) {
- content[0].opinion = opinion;
- }
- return content.length ? JSON.stringify(content[0]) : '';
- }
- /**
- * 获取审核人流程列表
- * @param {Number} tender_id - 标段id
- * @param {Number} times 审核次数
- * @return {Promise<Array>} 查询结果集
- */
- async getAuditGroupByList(tender_id, times = 1, transaction = null) {
- // const sql =
- // 'SELECT la.`audit_id`, la.`status`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`tender_id`, la.`audit_order` ' +
- // ' FROM ?? AS la Left Join ?? AS pa On la.`audit_id` = pa.`id`' +
- // ' WHERE la.`tender_id` = ? and la.`times` = ? GROUP BY la.`audit_id` ORDER BY la.`audit_order`';
- // const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tender_id, times];
- // return transaction ? await transaction.query(sql, sqlParam) : await this.db.query(sql, sqlParam);
- const sql =
- 'SELECT la.`audit_id`, la.`status`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`tender_id`, la.`audit_order` ' +
- ' FROM ?? AS la Left Join ?? AS pa On la.`audit_id` = pa.`id`' +
- ' WHERE la.`tender_id` = ? and la.`times` = ? ORDER BY la.`audit_order` DESC';
- const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tender_id, times];
- const result = transaction ? await transaction.query(sql, sqlParam) : await this.db.query(sql, sqlParam);
- const audits = [];
- for (const r of result) {
- if (audits.findIndex(a => a.audit_id === r.audit_id) === -1) {
- audits.push(r);
- }
- }
- return audits.reverse();
- }
- /**
- * 获取审核人流程列表(包括原报)
- * @param {Number} tender_id - 标段id
- * @param {Number} times 审核次数
- * @return {Promise<Array>} 查询结果集(包括原报)
- */
- async getAuditorsWithOwner(tender_id, times = 1) {
- const result = await this.getAuditGroupByList(tender_id, times);
- const sql =
- 'SELECT pa.`id` As audit_id, pa.`name`, pa.`company`, pa.`role`, ? As times, ? As tender_id, 0 As `audit_order`' +
- ' FROM ' + this.ctx.service.tender.tableName + ' As s' +
- ' LEFT JOIN ' + this.ctx.service.projectAccount.tableName + ' As pa' +
- ' ON s.user_id = pa.id' +
- ' WHERE s.id = ?';
- const sqlParam = [times, tender_id, tender_id];
- const user = await this.db.queryOne(sql, sqlParam);
- result.unshift(user);
- return result;
- }
- async updateNewAuditList(tender, newList) {
- const transaction = await this.db.beginTransaction();
- try {
- // 先删除旧的审批流,再添加新的
- await transaction.delete(this.tableName, { tender_id: tender.id, times: tender.ledger_times });
- const newAuditors = [];
- for (const auditor of newList) {
- newAuditors.push({
- tender_id: tender.id, audit_id: auditor.audit_id,
- times: tender.ledger_times, audit_order: auditor.audit_order, status: auditConst.status.uncheck,
- audit_type: auditor.audit_type, audit_ledger_id: auditor.audit_type === auditType.key.union ? auditor.audit_ledger_id : '',
- })
- }
- if(newAuditors.length > 0) await transaction.insert(this.tableName, newAuditors);
- await transaction.commit();
- } catch (err) {
- await transaction.rollback();
- throw err;
- }
- }
- async updateLastAudit(tender, auditList, lastId) {
- const transaction = await this.db.beginTransaction();
- try {
- // 先判断auditList里的audit_id是否与lastId相同,相同则删除并重新更新order
- const existAudit = auditList.find(x => { return x.audit_id === lastId });
- let order = auditList.length > 0 ? auditList.reduce((rst, a) => { return Math.max(rst, a.audit_order)}, 0) + 1 : 1; // 最大值 + 1
- if (existAudit) {
- await transaction.delete(this.tableName, { sid: stage.id, times: stage.times, audit_id: lastId });
- const sameOrder = auditList.filter(x => { return x.audit_order === existAudit.audit_order });
- if (sameOrder.length === 1) {
- const updateData = [];
- auditList.forEach(x => {
- if (x.audit_order <= existAudit.audit_order) return;
- updateData.push({id: x.id, audit_order: x.audit_order - 1});
- });
- if (updateData.length > 0) {
- await transaction.updateRows(updateData);
- }
- order = order - 1;
- }
- }
- // 添加终审
- const newAuditor = {
- tender_id: tender.id, audit_id: lastId,
- times: tender.ledger_times, audit_order: order, status: auditConst.status.uncheck,
- };
- await transaction.insert(this.tableName, newAuditor);
- await transaction.commit();
- } catch (err) {
- await transaction.rollback();
- throw err;
- }
- }
- /**
- * 删除本次审批流程
- * @param {Number} tenderId - 标段id
- * @param {Number} times - 第几次审批
- * @param {Object} data - 更改参数
- * @return {Promise<void>}
- */
- async saveAudit(tenderId, times, data) {
- const transaction = await this.db.beginTransaction();
- try {
- const auditors = await this.getAuditGroupByList(tenderId, times);
- const now_audit = this._.find(auditors, { audit_id: data.old_aid });
- if (data.operate === 'add') {
- if (now_audit.status !== auditConst.status.uncheck && now_audit.status !== auditConst.status.checking) {
- throw '当前人下无法操作新增';
- }
- const newAudit = {
- tender_id: tenderId,
- audit_id: data.new_aid,
- audit_order: now_audit.audit_order + 1,
- times,
- status: auditConst.status.uncheck,
- };
- // order+1
- await this._syncOrderByDelete(transaction, tenderId, now_audit.audit_order + 1, times, '+');
- await transaction.insert(this.tableName, newAudit);
- // 更新审批流程页数据,如果存在
- } else if (data.operate === 'del') {
- if (now_audit.status !== auditConst.status.uncheck) {
- throw '当前人无法操作删除';
- }
- await transaction.delete(this.tableName, { tender_id: tenderId, times, audit_id: now_audit.audit_id, audit_order: now_audit.audit_order });
- await this._syncOrderByDelete(transaction, tenderId, now_audit.audit_order, times);
- } else if (data.operate === 'change') {
- const nowAudit = await this.getDataByCondition({ tender_id: tenderId, times, audit_id: now_audit.audit_id, audit_order: now_audit.audit_order });
- if (now_audit.status !== auditConst.status.uncheck || !nowAudit) {
- throw '当前人无法操作替换';
- }
- nowAudit.audit_id = data.new_aid;
- await transaction.update(this.tableName, nowAudit);
- }
- if (this.ctx.tender.info.shenpi.ledger === shenpiConst.sp_status.gdspl || this.ctx.tender.info.shenpi.ledger === shenpiConst.sp_status.gdzs) {
- const newAuditors = await this.getAuditGroupByList(tenderId, times, transaction);
- await this.ctx.service.shenpiAudit.updateAuditList(transaction, this.ctx.tender.id, this.ctx.tender.info.shenpi.ledger, shenpiConst.sp_type.ledger, this._.map(newAuditors, 'audit_id'));
- }
- // 更新到审批流程方法
- await transaction.commit();
- } catch (err) {
- await transaction.rollback();
- throw err;
- }
- }
- }
- return LedgerAudit;
- };
|