|
@@ -212,14 +212,14 @@ module.exports = app => {
|
|
|
* @returns {Promise<boolean>}
|
|
|
*/
|
|
|
async start(revise, times = 1) {
|
|
|
- const audit = await this.getDataByCondition({ rid: revise.id, times, audit_order: 1 })
|
|
|
- if (!audit) throw '审核人信息错误'
|
|
|
- const time = new Date()
|
|
|
+ const audit = await this.getDataByCondition({ rid: revise.id, times, audit_order: 1 });
|
|
|
+ if (!audit) throw '审核人信息错误';
|
|
|
+ const time = new Date();
|
|
|
|
|
|
// 拷贝备份台账数据
|
|
|
- const [billsHis, posHis] = await this.ctx.service.ledgerRevise.backupReviseHistoryFile(revise)
|
|
|
+ const [billsHis, posHis] = await this.ctx.service.ledgerRevise.backupReviseHistoryFile(revise);
|
|
|
|
|
|
- const transaction = await this.db.beginTransaction()
|
|
|
+ const transaction = await this.db.beginTransaction();
|
|
|
try {
|
|
|
await transaction.update(this.tableName, {
|
|
|
id: audit.id,
|
|
@@ -227,29 +227,29 @@ module.exports = app => {
|
|
|
begin_time: time,
|
|
|
bills_file: revise.bills_file,
|
|
|
pos_file: revise.pos_file
|
|
|
- })
|
|
|
+ });
|
|
|
const reviseData = {
|
|
|
id: revise.id,
|
|
|
status: auditConst.status.checking,
|
|
|
bills_file: billsHis,
|
|
|
pos_file: posHis
|
|
|
- }
|
|
|
+ };
|
|
|
if (revise.times === 1) {
|
|
|
reviseData.begin_time = time
|
|
|
}
|
|
|
- await transaction.update(this.ctx.service.ledgerRevise.tableName, reviseData)
|
|
|
+ await transaction.update(this.ctx.service.ledgerRevise.tableName, reviseData);
|
|
|
|
|
|
// 添加短信通知-需要审批提醒功能
|
|
|
// 下一人
|
|
|
// await this.ctx.helper.sendUserSms(audit.audit_id, smsTypeConst.const.XD,
|
|
|
// smsTypeConst.judge.approval.toString(), '台帐修订需要您审批,请登录系统处理。');
|
|
|
- await this.ctx.helper.sendAliSms(audit.audit_id, smsTypeConst.const.XD, smsTypeConst.judge.approval.toString(), SmsAliConst.template.revise_check)
|
|
|
+ await this.ctx.helper.sendAliSms(audit.audit_id, smsTypeConst.const.XD, smsTypeConst.judge.approval.toString(), SmsAliConst.template.revise_check);
|
|
|
// 其他参与人
|
|
|
const auditList = await this.getAuditors(revise.id, times)
|
|
|
const users = this._.pull(this._.map(auditList, 'user_id'), audit.id)
|
|
|
// await this.ctx.helper.sendUserSms(users, smsTypeConst.const.XD,
|
|
|
// smsTypeConst.judge.result.toString(), '台账修订已上报。');
|
|
|
- await this.ctx.helper.sendAliSms(users, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_report)
|
|
|
+ await this.ctx.helper.sendAliSms(users, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_report);
|
|
|
|
|
|
await transaction.commit()
|
|
|
} catch (err) {
|
|
@@ -260,37 +260,37 @@ module.exports = app => {
|
|
|
}
|
|
|
|
|
|
async _replaceLedgerByRevise(transaction, revise) {
|
|
|
- const sqlParam = [revise.tid]
|
|
|
- await transaction.delete(this.ctx.service.ledger.tableName, { tender_id: revise.tid })
|
|
|
+ const sqlParam = [revise.tid];
|
|
|
+ await transaction.delete(this.ctx.service.ledger.tableName, { tender_id: revise.tid });
|
|
|
const bSql =
|
|
|
'Insert Into ' +
|
|
|
this.ctx.service.ledger.tableName +
|
|
|
' (id, code, b_code, name, unit, source, remark, ledger_id, ledger_pid, level, `order`, full_path, is_leaf,' +
|
|
|
' quantity, total_price, unit_price, drawing_code, memo, dgn_qty1, dgn_qty2, deal_qty, deal_tp,' +
|
|
|
' sgfh_qty, sgfh_tp, sjcl_qty, sjcl_tp, qtcl_qty, qtcl_tp, node_type, crid, tender_id, is_tp,' +
|
|
|
- ' sgfh_expr, sjcl_expr, qtcl_expr)' +
|
|
|
+ ' sgfh_expr, sjcl_expr, qtcl_expr, gxby_status, dagl_status)' +
|
|
|
' Select id, code, b_code, name, unit, source, remark, ledger_id, ledger_pid, level, `order`, full_path, is_leaf,' +
|
|
|
' quantity, total_price, unit_price, drawing_code, memo, dgn_qty1, dgn_qty2, deal_qty, deal_tp,' +
|
|
|
' sgfh_qty, sgfh_tp, sjcl_qty, sjcl_tp, qtcl_qty, qtcl_tp, node_type, crid, tender_id, is_tp, ' +
|
|
|
- ' sgfh_expr, sjcl_expr, qtcl_expr' +
|
|
|
+ ' sgfh_expr, sjcl_expr, qtcl_expr, gxby_status, dagl_status' +
|
|
|
' From ' +
|
|
|
this.ctx.service.reviseBills.tableName +
|
|
|
- ' Where `tender_id` = ?'
|
|
|
- await transaction.query(bSql, sqlParam)
|
|
|
- await transaction.delete(this.ctx.service.pos.tableName, { tid: revise.tid })
|
|
|
+ ' Where `tender_id` = ?';
|
|
|
+ await transaction.query(bSql, sqlParam);
|
|
|
+ await transaction.delete(this.ctx.service.pos.tableName, { tid: revise.tid });
|
|
|
const pSql =
|
|
|
'Insert Into ' +
|
|
|
this.ctx.service.pos.tableName +
|
|
|
' (id, tid, lid, name, drawing_code, quantity, add_stage, add_times, add_user,' +
|
|
|
' sgfh_qty, sjcl_qty, qtcl_qty, crid, porder, position, ' +
|
|
|
- ' sgfh_expr, sjcl_expr, qtcl_expr)' +
|
|
|
+ ' sgfh_expr, sjcl_expr, qtcl_expr, gxby_status, dagl_status)' +
|
|
|
' Select id, tid, lid, name, drawing_code, quantity, add_stage, add_times, add_user,' +
|
|
|
' sgfh_qty, sjcl_qty, qtcl_qty, crid, porder, position,' +
|
|
|
- ' sgfh_expr, sjcl_expr, qtcl_expr' +
|
|
|
+ ' sgfh_expr, sjcl_expr, qtcl_expr, gxby_status, dagl_status' +
|
|
|
' From ' +
|
|
|
this.ctx.service.revisePos.tableName +
|
|
|
- ' Where `tid` = ?'
|
|
|
- await transaction.query(pSql, sqlParam)
|
|
|
+ ' Where `tid` = ?';
|
|
|
+ await transaction.query(pSql, sqlParam);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -332,24 +332,24 @@ module.exports = app => {
|
|
|
status: checkType,
|
|
|
content: noticeContent
|
|
|
})
|
|
|
- })
|
|
|
+ });
|
|
|
await transaction.insert('zh_notice', records)
|
|
|
|
|
|
// 整理当前流程审核人状态更新
|
|
|
- const time = new Date()
|
|
|
+ const time = new Date();
|
|
|
// 更新当前审核流程
|
|
|
await transaction.update(this.tableName, {
|
|
|
id: audit.id,
|
|
|
status: checkType,
|
|
|
opinion,
|
|
|
end_time: time
|
|
|
- })
|
|
|
+ });
|
|
|
if (checkType === auditConst.status.checked) {
|
|
|
const nextAudit = await this.getDataByCondition({
|
|
|
rid: revise.id,
|
|
|
times,
|
|
|
audit_order: audit.audit_order + 1
|
|
|
- })
|
|
|
+ });
|
|
|
// 无下一审核人表示,审核结束
|
|
|
if (nextAudit) {
|
|
|
await transaction.update(this.tableName, {
|
|
@@ -364,10 +364,10 @@ module.exports = app => {
|
|
|
// smsTypeConst.judge.approval.toString(), '台帐修订需要您审批,请登录系统处理。');
|
|
|
await this.ctx.helper.sendAliSms(nextAudit.user_id, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_result, {
|
|
|
status: SmsAliConst.status.success
|
|
|
- })
|
|
|
+ });
|
|
|
// 其他参与人
|
|
|
- const users = this._.pull(this._.map(auditList, 'user_id'), audit.id)
|
|
|
- users.push(revise.uid)
|
|
|
+ const users = this._.pull(this._.map(auditList, 'user_id'), audit.id);
|
|
|
+ users.push(revise.uid);
|
|
|
// await this.ctx.helper.sendUserSms(users, smsTypeConst.const.XD,
|
|
|
// smsTypeConst.judge.result.toString(), '台账修订审批通过。');
|
|
|
await this.ctx.helper.sendAliSms(users, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_result2, {
|
|
@@ -379,26 +379,26 @@ module.exports = app => {
|
|
|
id: revise.id,
|
|
|
status: checkType,
|
|
|
end_time: time
|
|
|
- })
|
|
|
+ });
|
|
|
// 最新一期跟台账相关的缓存数据应过期
|
|
|
- const lastStage = await this.ctx.service.stage.getLastestStage(revise.tid, true)
|
|
|
- const cacheTime = new Date()
|
|
|
+ const lastStage = await this.ctx.service.stage.getLastestStage(revise.tid, true);
|
|
|
+ const cacheTime = new Date();
|
|
|
if (lastStage)
|
|
|
await transaction.update(this.ctx.service.stage.tableName, {
|
|
|
id: lastStage.id,
|
|
|
cache_time_l: cacheTime,
|
|
|
cache_time_r: cacheTime
|
|
|
- })
|
|
|
+ });
|
|
|
// 拷贝修订数据至台账
|
|
|
- await this._replaceLedgerByRevise(transaction, revise)
|
|
|
+ await this._replaceLedgerByRevise(transaction, revise);
|
|
|
const sum = await this.ctx.service.reviseBills.addUp({
|
|
|
tender_id: revise.tid /* , is_leaf: true*/
|
|
|
- })
|
|
|
+ });
|
|
|
await transaction.update(this.ctx.service.tender.tableName, {
|
|
|
id: revise.tid,
|
|
|
total_price: sum.total_price,
|
|
|
deal_tp: sum.deal_tp
|
|
|
- })
|
|
|
+ });
|
|
|
// 短信通知-审批通过提醒功能
|
|
|
// 下一人
|
|
|
// const msg = '台账修订审批通过,请登录系统处理。';
|
|
@@ -406,7 +406,7 @@ module.exports = app => {
|
|
|
// smsTypeConst.judge.result.toString(), msg);
|
|
|
await this.ctx.helper.sendAliSms(revise.uid, smsTypeConst.const.XD, smsTypeConst.judge.result.toString(), SmsAliConst.template.revise_result, {
|
|
|
status: SmsAliConst.status.success
|
|
|
- })
|
|
|
+ });
|
|
|
// 其他参与人
|
|
|
const users = this._.pull(this._.map(auditList, 'user_id'), audit.id)
|
|
|
// await this.ctx.helper.sendUserSms(users, smsTypeConst.const.XD,
|
|
@@ -421,18 +421,18 @@ module.exports = app => {
|
|
|
id: revise.id,
|
|
|
times: times + 1,
|
|
|
status: checkType
|
|
|
- })
|
|
|
+ });
|
|
|
// 拷贝新一次审核流程列表
|
|
|
const auditors = await this.getAllDataByCondition({
|
|
|
where: { rid: revise.id, times },
|
|
|
columns: ['tender_id', 'rid', 'audit_order', 'audit_id']
|
|
|
- })
|
|
|
+ });
|
|
|
for (const a of auditors) {
|
|
|
- a.times = times + 1
|
|
|
- a.status = auditConst.status.uncheck
|
|
|
- a.in_time = time
|
|
|
+ a.times = times + 1;
|
|
|
+ a.status = auditConst.status.uncheck;
|
|
|
+ a.in_time = time;
|
|
|
}
|
|
|
- await transaction.insert(this.tableName, auditors)
|
|
|
+ await transaction.insert(this.tableName, auditors);
|
|
|
|
|
|
// 短信通知-审批退回提醒功能
|
|
|
// 下一人
|