|
@@ -10,6 +10,8 @@
|
|
|
|
|
|
const auditConst = require('../const/audit').material;
|
|
|
const pushType = require('../const/audit').pushType;
|
|
|
+const smsTypeConst = require('../const/sms_type');
|
|
|
+const wxConst = require('../const/wechat_template');
|
|
|
|
|
|
module.exports = app => {
|
|
|
class MaterialAudit extends app.BaseService {
|
|
@@ -222,6 +224,19 @@ module.exports = app => {
|
|
|
}
|
|
|
await transaction.insert(this.ctx.service.materialBillsHistory.tableName, mbhList);
|
|
|
|
|
|
+ // 微信模板通知
|
|
|
+ const materialInfo = await this.ctx.service.material.getDataById(materialId);
|
|
|
+ const wechatData = {
|
|
|
+ qi: materialInfo.order,
|
|
|
+ status: wxConst.status.check,
|
|
|
+ tips: wxConst.tips.check,
|
|
|
+ begin_time: Date.parse(new Date()),
|
|
|
+ m_tp: this.ctx.helper.round(materialInfo.m_tp, 2),
|
|
|
+ hs_m_tp: this.ctx.helper.round(this.ctx.helper.mul(materialInfo.m_tp, 1+materialInfo.rate/100), 2),
|
|
|
+ };
|
|
|
+ await this.ctx.helper.sendWechat(audit.aid, smsTypeConst.const.TC, smsTypeConst.judge.approval.toString(), wxConst.template.material, wechatData);
|
|
|
+
|
|
|
+
|
|
|
// 添加短信通知-需要审批提醒功能
|
|
|
// const smsUser = await this.ctx.service.projectAccount.getDataById(audit.aid);
|
|
|
// if (smsUser.auth_mobile !== '' && smsUser.auth_mobile !== undefined && smsUser.sms_type !== '') {
|
|
@@ -274,6 +289,12 @@ module.exports = app => {
|
|
|
records.push({ pid, type: pushType.material, uid: audit.aid, status: auditConst.status.checked, content: noticeContent });
|
|
|
});
|
|
|
await transaction.insert('zh_notice', records);
|
|
|
+ const begin_audit = await this.getDataByCondition({
|
|
|
+ mid: materialId,
|
|
|
+ order: 1,
|
|
|
+ });
|
|
|
+ const materialInfo = await this.ctx.service.material.getDataById(materialId);
|
|
|
+
|
|
|
// 无下一审核人表示,审核结束
|
|
|
if (nextAudit) {
|
|
|
// 复制一份下一审核人数据
|
|
@@ -286,6 +307,17 @@ module.exports = app => {
|
|
|
id: materialId, status: auditConst.status.checking,
|
|
|
});
|
|
|
|
|
|
+ // 微信模板通知
|
|
|
+ const wechatData = {
|
|
|
+ qi: materialInfo.order,
|
|
|
+ status: wxConst.status.check,
|
|
|
+ tips: wxConst.tips.check,
|
|
|
+ begin_time: Date.parse(begin_audit.begin_time),
|
|
|
+ m_tp: this.ctx.helper.round(materialInfo.m_tp, 2),
|
|
|
+ hs_m_tp: this.ctx.helper.round(this.ctx.helper.mul(materialInfo.m_tp, 1+materialInfo.rate/100), 2),
|
|
|
+ };
|
|
|
+ await this.ctx.helper.sendWechat(nextAudit.id, smsTypeConst.const.TC, smsTypeConst.judge.approval.toString(), wxConst.template.material, wechatData);
|
|
|
+
|
|
|
|
|
|
// 添加短信通知-需要审批提醒功能
|
|
|
// const smsUser = await this.ctx.service.projectAccount.getDataById(nextAudit.aid);
|
|
@@ -312,6 +344,18 @@ module.exports = app => {
|
|
|
id: materialId, status: checkData.checkType,
|
|
|
});
|
|
|
|
|
|
+ // 微信模板通知
|
|
|
+ const users = this._.uniq(this._.concat(this._.map(auditors, 'aid'), materialInfo.user_id));
|
|
|
+ const wechatData = {
|
|
|
+ qi: materialInfo.order,
|
|
|
+ status: wxConst.status.success,
|
|
|
+ tips: wxConst.tips.success,
|
|
|
+ begin_time: Date.parse(begin_audit.begin_time),
|
|
|
+ m_tp: this.ctx.helper.round(materialInfo.m_tp, 2),
|
|
|
+ hs_m_tp: this.ctx.helper.round(this.ctx.helper.mul(materialInfo.m_tp, 1+materialInfo.rate/100), 2),
|
|
|
+ };
|
|
|
+ await this.ctx.helper.sendWechat(users, smsTypeConst.const.TC, smsTypeConst.judge.result.toString(), wxConst.template.material, wechatData);
|
|
|
+
|
|
|
// 添加短信通知-审批通过提醒功能
|
|
|
// const mobile_array = [];
|
|
|
// const stageInfo = await this.ctx.service.stage.getDataById(stageId);
|
|
@@ -387,6 +431,23 @@ module.exports = app => {
|
|
|
order: this.ctx.material.order,
|
|
|
});
|
|
|
|
|
|
+ // 微信模板通知
|
|
|
+ const begin_audit = await this.getDataByCondition({
|
|
|
+ mid: materialId,
|
|
|
+ order: 1,
|
|
|
+ });
|
|
|
+ const materialInfo = await this.ctx.service.material.getDataById(materialId);
|
|
|
+ const users = this._.uniq(this._.concat(this._.map(auditors, 'aid'), materialInfo.user_id));
|
|
|
+ const wechatData = {
|
|
|
+ qi: materialInfo.order,
|
|
|
+ status: wxConst.status.back,
|
|
|
+ tips: wxConst.tips.back,
|
|
|
+ begin_time: Date.parse(begin_audit.begin_time),
|
|
|
+ m_tp: this.ctx.helper.round(materialInfo.m_tp, 2),
|
|
|
+ hs_m_tp: this.ctx.helper.round(this.ctx.helper.mul(materialInfo.m_tp, 1+materialInfo.rate/100), 2),
|
|
|
+ };
|
|
|
+ await this.ctx.helper.sendWechat(users, smsTypeConst.const.TC, smsTypeConst.judge.result.toString(), wxConst.template.material, wechatData);
|
|
|
+
|
|
|
// 计算该审批人最终数据
|
|
|
// await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
|
|
|
// 复制一份最新数据给原报
|
|
@@ -468,6 +529,22 @@ module.exports = app => {
|
|
|
times: audit.times, order: audit.order + 2, status: auditConst.status.uncheck,
|
|
|
});
|
|
|
|
|
|
+ // 微信模板通知
|
|
|
+ const begin_audit = await this.getDataByCondition({
|
|
|
+ mid: materialId,
|
|
|
+ order: 1,
|
|
|
+ });
|
|
|
+ const materialInfo = await this.ctx.service.material.getDataById(materialId);
|
|
|
+ const wechatData = {
|
|
|
+ qi: materialInfo.order,
|
|
|
+ status: wxConst.status.check,
|
|
|
+ tips: wxConst.tips.check,
|
|
|
+ begin_time: Date.parse(begin_audit.begin_time),
|
|
|
+ m_tp: this.ctx.helper.round(materialInfo.m_tp, 2),
|
|
|
+ hs_m_tp: this.ctx.helper.round(this.ctx.helper.mul(materialInfo.m_tp, 1+materialInfo.rate/100), 2),
|
|
|
+ };
|
|
|
+ await this.ctx.helper.sendWechat(audit.aid, smsTypeConst.const.TC, smsTypeConst.judge.approval.toString(), wxConst.template.material, wechatData);
|
|
|
+
|
|
|
await transaction.insert(this.tableName, newAuditors);
|
|
|
await transaction.commit();
|
|
|
} catch (error) {
|