|
@@ -366,9 +366,10 @@ module.exports = app => {
|
|
|
camount: clInfo[6],
|
|
|
samount: '',
|
|
|
detail: clInfo[7],
|
|
|
+ spamount: clInfo[6],
|
|
|
};
|
|
|
insertCL.push(clArray);
|
|
|
- total_price = this.ctx.helper.accAdd(total_price, this.ctx.helper.accMul(clArray.unit_price, clArray.camount));
|
|
|
+ total_price = this.ctx.helper.accAdd(total_price, this.ctx.helper.accMul(clArray.unit_price, clArray.spamount));
|
|
|
}
|
|
|
await this.transaction.insert(this.ctx.service.changeAuditList.tableName, insertCL);
|
|
|
}
|
|
@@ -449,6 +450,7 @@ module.exports = app => {
|
|
|
const list_update = {
|
|
|
id: lid,
|
|
|
audit_amount: audit_amount.join(','),
|
|
|
+ spamount: parseFloat(amount),
|
|
|
};
|
|
|
if (postData.audit_next_id === undefined) {
|
|
|
list_update.samount = amount;
|
|
@@ -461,18 +463,24 @@ module.exports = app => {
|
|
|
change_update.status = audit.flow.status.checked;
|
|
|
change_update.p_code = postData.p_code;
|
|
|
change_update.sin_time = Date.parse(new Date()) / 1000;
|
|
|
- change_update.total_price = total_price;
|
|
|
|
|
|
// 添加短信通知-审批通过提醒功能
|
|
|
- const smsUser = await this.ctx.service.projectAccount.getDataById(changeData.uid);
|
|
|
- if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
|
|
|
- const smsType = JSON.parse(smsUser.sms_type);
|
|
|
- if (smsType[smsTypeConst.const.BG] !== undefined && smsType[smsTypeConst.const.BG].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
|
|
|
- const sms = new SMS(this.ctx);
|
|
|
- const content = '【纵横计量支付】' + changeData.code + '变更,审批通过。';
|
|
|
- sms.send(smsUser.auth_mobile, content);
|
|
|
+ const mobile_array = [];
|
|
|
+ const auditList = await this.ctx.service.changeAudit.getListGroupByTimes(changeData.cid, changeData.times);
|
|
|
+ for (const user of auditList) {
|
|
|
+ const smsUser = await this.ctx.service.projectAccount.getDataById(user.uid);
|
|
|
+ if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
|
|
|
+ const smsType = JSON.parse(smsUser.sms_type);
|
|
|
+ if (smsType[smsTypeConst.const.BG] !== undefined && smsType[smsTypeConst.const.BG].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
|
|
|
+ mobile_array.push(smsUser.auth_mobile);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ if (mobile_array.length > 0) {
|
|
|
+ const sms = new SMS(this.ctx);
|
|
|
+ const content = '【纵横计量支付】' + changeData.code + '变更,审批通过。';
|
|
|
+ sms.send(mobile_array, content);
|
|
|
+ }
|
|
|
} else {
|
|
|
// 设置下一个审批人为审批状态
|
|
|
const nextAudit_update = {
|
|
@@ -494,6 +502,7 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ change_update.total_price = total_price;
|
|
|
const options = {
|
|
|
where: {
|
|
|
cid: postData.change_id,
|
|
@@ -592,12 +601,19 @@ module.exports = app => {
|
|
|
usort++;
|
|
|
}
|
|
|
await this.transaction.insert(this.ctx.service.changeAudit.tableName, insert_audit_array);
|
|
|
+ // 变更金额也退回
|
|
|
+ const changeList = await this.ctx.service.changeAuditList.getAllDataByCondition({ where: { cid: changeInfo.cid } });
|
|
|
+ let total_price = 0;
|
|
|
+ for (const cl of changeList) {
|
|
|
+ total_price += this.ctx.helper.accMul(cl.unit_price, cl.camount);
|
|
|
+ }
|
|
|
// 设置变更令退回
|
|
|
const change_update = {
|
|
|
w_code: postData.w_code,
|
|
|
status: audit.flow.status.back,
|
|
|
times: newTimes,
|
|
|
cin_time: Date.parse(new Date()) / 1000,
|
|
|
+ total_price,
|
|
|
};
|
|
|
const options = {
|
|
|
where: {
|
|
@@ -609,16 +625,22 @@ module.exports = app => {
|
|
|
result = true;
|
|
|
|
|
|
// 添加短信通知-审批退回提醒功能
|
|
|
- const smsUser = await this.ctx.service.projectAccount.getDataById(changeData.uid);
|
|
|
- if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
|
|
|
- const smsType = JSON.parse(smsUser.sms_type);
|
|
|
- if (smsType[smsTypeConst.const.BG] !== undefined && smsType[smsTypeConst.const.BG].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
|
|
|
- const sms = new SMS(this.ctx);
|
|
|
- const code = await sms.contentChange(changeData.code);
|
|
|
- const content = '【纵横计量支付】' + code + '变更,审批退回。';
|
|
|
- sms.send(smsUser.auth_mobile, content);
|
|
|
+ const mobile_array = [];
|
|
|
+ for (const user of insert_audit_array) {
|
|
|
+ const smsUser = await this.ctx.service.projectAccount.getDataById(user.uid);
|
|
|
+ if (smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
|
|
|
+ const smsType = JSON.parse(smsUser.sms_type);
|
|
|
+ if (smsType[smsTypeConst.const.BG] !== undefined && smsType[smsTypeConst.const.BG].indexOf(smsTypeConst.judge.result.toString()) !== -1) {
|
|
|
+ mobile_array.push(smsUser.auth_mobile);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ if (mobile_array.length > 0) {
|
|
|
+ const sms = new SMS(this.ctx);
|
|
|
+ const code = await sms.contentChange(changeData.code);
|
|
|
+ const content = '【纵横计量支付】' + code + '变更,审批退回。';
|
|
|
+ sms.send(mobile_array, content);
|
|
|
+ }
|
|
|
} catch (error) {
|
|
|
await this.transaction.rollback();
|
|
|
result = false;
|
|
@@ -698,13 +720,17 @@ module.exports = app => {
|
|
|
|
|
|
// 审批列表数据也要回退
|
|
|
const changeList = await this.ctx.service.changeAuditList.getAllDataByCondition({ where: { cid: changeInfo.cid } });
|
|
|
+ let total_price = 0;
|
|
|
for (const cl of changeList) {
|
|
|
const audit_amount = cl.audit_amount.split(',');
|
|
|
+ const last_amount = audit_amount[audit_amount.length - 1];
|
|
|
audit_amount.splice(-1, 1);
|
|
|
const list_update = {
|
|
|
id: cl.id,
|
|
|
audit_amount: audit_amount.join(','),
|
|
|
+ spamount: parseFloat(last_amount),
|
|
|
};
|
|
|
+ total_price += this.ctx.helper.accMul(cl.unit_price, parseFloat(last_amount));
|
|
|
await this.transaction.update(this.ctx.service.changeAuditList.tableName, list_update);
|
|
|
}
|
|
|
|
|
@@ -713,6 +739,7 @@ module.exports = app => {
|
|
|
w_code: postData.w_code,
|
|
|
status: audit.flow.status.backnew,
|
|
|
cin_time: Date.parse(new Date()) / 1000,
|
|
|
+ total_price,
|
|
|
};
|
|
|
const options = {
|
|
|
where: {
|