Browse Source

增加3方数据埋点

MaiXinRong 1 year ago
parent
commit
f3a123f940

+ 16 - 3
app/const/spec_3f.js

@@ -9,13 +9,26 @@
  */
 
 const pushTiming = [
+    { value:'ledger.flow', name: '台账-上报/审批' },
     { value:'ledger.checked', name: '台账-审批通过' },
-    { value:'stage.checked', name: '期-审批通过' },
+    { value:'revise.flow', name: '台账修订-上报/审批' },
+    { value:'revise.checked', name: '台账修订-审批通过' },
+    { value:'advance.flow', name: '预付款-上报/审批' },
+    { value:'advance.checked', name: '预付款-审批通过' },
     { value:'stage.flow', name: '期-上报/审批' },
-    { value:'settle.checked', name: '结算期-审批通过' },
+    { value:'stage.checked', name: '期-审批通过' },
+    { value:'material.flow', name: '材差-上报/审批' },
+    { value:'material.checked', name: '材差-审批通过' },
     { value:'settle.flow', name: '结算期-上报/审批' },
-    { value:'revise.checked', name: '台账修订-审批通过' },
+    { value:'settle.checked', name: '结算期-审批通过' },
+    { value:'change.flow', name: '变更令-上报/审批' },
     { value:'change.checked', name: '变更令-审批通过' },
+    { value:'change_apply.flow', name: '变更申请-上报/审批' },
+    { value:'change_apply.checked', name: '变更申请-审批通过' },
+    { value:'change_plan.flow', name: '变更方案-上报/审批' },
+    { value:'change_plan.checked', name: '变更方案-审批通过' },
+    { value:'change_project.flow', name: '变更立项-上报/审批' },
+    { value:'change_project.checked', name: '变更立项-审批通过' },
     { value:'report.file', name: '报表-推送归档' },
 ];
 

+ 12 - 0
app/service/advance_audit.js

@@ -3,6 +3,7 @@
 const auditConst = require('../const/audit').advance;
 const shenpiConst = require('../const/shenpi');
 const pushType = require('../const/audit').pushType;
+const pushOperate = require('../const/spec_3f').pushOperate;
 const smsTypeConst = require('../const/sms_type');
 const wxConst = require('../const/wechat_template.js');
 const advanceConst = require('../const/advance');
@@ -241,6 +242,8 @@ module.exports = app => {
                     code: this.ctx.session.sessionProject.code,
                 };
                 await this.ctx.helper.sendWechat(audit.audit_id, smsTypeConst.const.YFK, smsTypeConst.judge.approval.toString(), wxConst.template.advance, wechatData);
+                // 审批通过 - 检查三方特殊推送
+                await this.ctx.service.specMsg.addAdvanceMsg(transaction, pid, advanceInfo, pushOperate.advance.flow);
                 await transaction.commit();
             } catch (err) {
                 await transaction.rollback();
@@ -302,6 +305,8 @@ module.exports = app => {
                         code: this.ctx.session.sessionProject.code,
                     };
                     await this.ctx.helper.sendWechat(nextAudit.audit_id, smsTypeConst.const.YFK, smsTypeConst.judge.approval.toString(), wxConst.template.advance, wechatData);
+                    // 审批通过 - 检查三方特殊推送
+                    await this.ctx.service.specMsg.addAdvanceMsg(transaction, pid, advanceInfo, pushOperate.advance.flow);
                 } else {
                     await transaction.update(this.ctx.service.advance.tableName, {
                         id: advanceId,
@@ -320,6 +325,9 @@ module.exports = app => {
                         code: this.ctx.session.sessionProject.code,
                     };
                     await this.ctx.helper.sendWechat(users, smsTypeConst.const.YFK, smsTypeConst.judge.result.toString(), wxConst.template.advance, wechatData);
+                    // 审批通过 - 检查三方特殊推送
+                    await this.ctx.service.specMsg.addAdvanceMsg(transaction, pid, advanceInfo, pushOperate.advance.flow);
+                    await this.ctx.service.specMsg.addAdvanceMsg(transaction, pid, advanceInfo, pushOperate.advance.checked);
                 }
                 await transaction.commit();
                 if (!nextAudit) this.ctx.service.tenderCache.updateAdvanceCache(audit.tid);
@@ -381,6 +389,8 @@ module.exports = app => {
                 await this.ctx.helper.sendWechat(users, smsTypeConst.const.YFK, smsTypeConst.judge.result.toString(), wxConst.template.advance, wechatData);
                 // 拷贝新一次审核流程列表
                 await transaction.insert(this.tableName, auditors);
+                // 检查三方特殊推送
+                await this.ctx.service.specMsg.addAdvanceMsg(transaction, pid, advanceInfo, pushOperate.advance.flow);
                 await transaction.commit();
             } catch (err) {
                 await transaction.rollback();
@@ -451,6 +461,8 @@ module.exports = app => {
                 };
                 await this.ctx.helper.sendWechat(preAuditor.audit_id, smsTypeConst.const.YFK, smsTypeConst.judge.approval.toString(), wxConst.template.advance, wechatData);
                 await transaction.insert(this.tableName, newAuditors);
+                // 检查三方特殊推送
+                await this.ctx.service.specMsg.addAdvanceMsg(transaction, pid, advanceInfo, pushOperate.advance.flow);
                 await transaction.commit();
             } catch (error) {
                 await transaction.rollback();

+ 12 - 1
app/service/change_apply_audit.js

@@ -10,6 +10,7 @@
 
 const auditConst = require('../const/audit').changeApply;
 const pushType = require('../const/audit').pushType;
+const pushOperate = require('../const/spec_3f').pushOperate;
 const shenpiConst = require('../const/shenpi');
 const smsTypeConst = require('../const/sms_type');
 const SMS = require('../lib/sms');
@@ -288,6 +289,8 @@ module.exports = app => {
                 await this.ctx.helper.sendWechat(audit.aid, smsTypeConst.const.BG, smsTypeConst.judge.approval.toString(), wxConst.template.change, wechatData);
                 await transaction.delete(this.ctx.service.changeApplyHistory.tableName, { caid: caId });
                 // todo 更新标段tender状态 ?
+                //  检查三方特殊推送
+                await this.ctx.service.specMsg.addChangeApplyMsg(transaction, pid, this.ctx.change, pushOperate.change_apply.flow);
                 await transaction.commit();
             } catch (err) {
                 await transaction.rollback();
@@ -433,6 +436,8 @@ module.exports = app => {
                         c_name: this.ctx.change.name,
                     };
                     await this.ctx.helper.sendWechat(nextAudit.aid, smsTypeConst.const.BG, smsTypeConst.judge.approval.toString(), wxConst.template.change, wechatData);
+                    //  检查三方特殊推送
+                    await this.ctx.service.specMsg.addChangeApplyMsg(transaction, pid, this.ctx.change, pushOperate.change_apply.flow);
                 } else {
                     // 本期结束
                     // 生成截止本期数据 final数据
@@ -454,6 +459,9 @@ module.exports = app => {
                         c_name: this.ctx.change.name,
                     };
                     await this.ctx.helper.sendWechat(users, smsTypeConst.const.BG, smsTypeConst.judge.result.toString(), wxConst.template.change, wechatData);
+                    //  检查三方特殊推送
+                    await this.ctx.service.specMsg.addChangeApplyMsg(transaction, pid, this.ctx.change, pushOperate.change_apply.flow);
+                    await this.ctx.service.specMsg.addChangeApplyMsg(transaction, pid, this.ctx.change, pushOperate.change_apply.checked);
                 }
                 await transaction.commit();
             } catch (err) {
@@ -528,6 +536,8 @@ module.exports = app => {
                     where: { caid: caId },
                 });
                 await this.ctx.service.changeApplyHistory.saveHistory(transaction, changeData, changeList);
+                //  检查三方特殊推送
+                await this.ctx.service.specMsg.addChangeApplyMsg(transaction, pid, this.ctx.change, pushOperate.change_apply.flow);
                 await transaction.commit();
             } catch (err) {
                 await transaction.rollback();
@@ -832,7 +842,6 @@ module.exports = app => {
                     status: auditConst.status.revise,
                     times: change.times + 1,
                 });
-
                 await transaction.commit();
                 result = true;
             } catch (error) {
@@ -946,6 +955,8 @@ module.exports = app => {
                     notice_uid: null,
                     decimal: null,
                 });
+                //  检查三方特殊推送
+                await this.ctx.service.specMsg.addChangeApplyMsg(transaction, pid, this.ctx.change, pushOperate.change_apply.flow);
                 await transaction.commit();
                 result = true;
             } catch (error) {

+ 9 - 0
app/service/change_plan_audit.js

@@ -10,6 +10,7 @@
 
 const auditConst = require('../const/audit').changePlan;
 const pushType = require('../const/audit').pushType;
+const pushOperate = require('../const/spec_3f').pushOperate;
 const shenpiConst = require('../const/shenpi');
 const smsTypeConst = require('../const/sms_type');
 const SMS = require('../lib/sms');
@@ -290,6 +291,8 @@ module.exports = app => {
                     c_name: this.ctx.change.name,
                 };
                 await this.ctx.helper.sendWechat(audit.aid, smsTypeConst.const.BG, smsTypeConst.judge.approval.toString(), wxConst.template.change, wechatData);
+                //  检查三方特殊推送
+                await this.ctx.service.specMsg.addChangePlanMsg(transaction, pid, this.ctx.change, pushOperate.change_plan.flow);
                 await transaction.delete(this.ctx.service.changePlanHistory.tableName, { cpid: cpId });
                 // todo 更新标段tender状态 ?
                 await transaction.commit();
@@ -444,6 +447,8 @@ module.exports = app => {
                         c_name: this.ctx.change.name,
                     };
                     await this.ctx.helper.sendWechat(nextAudit.aid, smsTypeConst.const.BG, smsTypeConst.judge.approval.toString(), wxConst.template.change, wechatData);
+                    //  检查三方特殊推送
+                    await this.ctx.service.specMsg.addChangePlanMsg(transaction, pid, this.ctx.change, pushOperate.change_plan.flow);
                 } else {
                     // 本期结束
                     // 生成截止本期数据 final数据
@@ -467,6 +472,8 @@ module.exports = app => {
                         c_name: this.ctx.change.name,
                     };
                     await this.ctx.helper.sendWechat(users, smsTypeConst.const.BG, smsTypeConst.judge.result.toString(), wxConst.template.change, wechatData);
+                    //  检查三方特殊推送
+                    await this.ctx.service.specMsg.addChangePlanMsg(transaction, pid, this.ctx.change, pushOperate.change_plan.flow);
                 }
                 await transaction.commit();
             } catch (err) {
@@ -536,6 +543,8 @@ module.exports = app => {
                     c_name: this.ctx.change.name,
                 };
                 await this.ctx.helper.sendWechat(users, smsTypeConst.const.BG, smsTypeConst.judge.result.toString(), wxConst.template.change, wechatData);
+                //  检查三方特殊推送
+                await this.ctx.service.specMsg.addChangePlanMsg(transaction, pid, this.ctx.change, pushOperate.change_plan.flow);
                 // 生成内容保存表至zh_change_project_history中,用于撤回
                 // 回退spamount值数据
                 const changeList = await this.ctx.service.changePlanList.getAllDataByCondition({

+ 12 - 0
app/service/change_project_audit.js

@@ -10,6 +10,7 @@
 
 const auditConst = require('../const/audit').changeProject;
 const pushType = require('../const/audit').pushType;
+const pushOperate = require('../const/spec_3f').pushOperate;
 const shenpiConst = require('../const/shenpi');
 const smsTypeConst = require('../const/sms_type');
 const SMS = require('../lib/sms');
@@ -290,6 +291,8 @@ module.exports = app => {
                 await this.ctx.helper.sendWechat(audit.aid, smsTypeConst.const.BG, smsTypeConst.judge.approval.toString(), wxConst.template.change, wechatData);
                 await transaction.delete(this.ctx.service.changeProjectHistory.tableName, { cpid: cpId });
                 // todo 更新标段tender状态 ?
+                //  检查三方特殊推送
+                await this.ctx.service.specMsg.addChangeProjectMsg(transaction, pid, this.ctx.change, pushOperate.change_project.flow);
                 await transaction.commit();
             } catch (err) {
                 await transaction.rollback();
@@ -438,6 +441,8 @@ module.exports = app => {
                         c_name: this.ctx.change.name,
                     };
                     await this.ctx.helper.sendWechat(nextAudit.aid, smsTypeConst.const.BG, smsTypeConst.judge.approval.toString(), wxConst.template.change, wechatData);
+                    //  检查三方特殊推送
+                    await this.ctx.service.specMsg.addChangeProjectMsg(transaction, pid, this.ctx.change, pushOperate.change_project.flow);
                 } else {
                     // 本期结束
                     // 生成截止本期数据 final数据
@@ -456,6 +461,9 @@ module.exports = app => {
                         c_name: this.ctx.change.name,
                     };
                     await this.ctx.helper.sendWechat(users, smsTypeConst.const.BG, smsTypeConst.judge.result.toString(), wxConst.template.change, wechatData);
+                    //  检查三方特殊推送
+                    await this.ctx.service.specMsg.addChangeProjectMsg(transaction, pid, this.ctx.change, pushOperate.change_project.flow);
+                    await this.ctx.service.specMsg.addChangeProjectMsg(transaction, pid, this.ctx.change, pushOperate.change_project.checked);
                 }
                 await transaction.commit();
             } catch (err) {
@@ -522,6 +530,8 @@ module.exports = app => {
                 await this.ctx.helper.sendWechat(users, smsTypeConst.const.BG, smsTypeConst.judge.result.toString(), wxConst.template.change, wechatData);
                 // 生成内容保存表至zh_change_project_history中,用于撤回
                 await this.ctx.service.changeProjectHistory.saveHistory(transaction, changeData);
+                //  检查三方特殊推送
+                await this.ctx.service.specMsg.addChangeProjectMsg(transaction, pid, this.ctx.change, pushOperate.change_project.flow);
                 await transaction.commit();
             } catch (err) {
                 await transaction.rollback();
@@ -571,6 +581,8 @@ module.exports = app => {
                     c_name: this.ctx.change.name,
                 };
                 await this.ctx.helper.sendWechat(users, smsTypeConst.const.BG, smsTypeConst.judge.result.toString(), wxConst.template.change, wechatData);
+                //  检查三方特殊推送
+                await this.ctx.service.specMsg.addChangeProjectMsg(transaction, pid, this.ctx.change, pushOperate.change_project.flow);
                 await transaction.commit();
             } catch (err) {
                 await transaction.rollback();

+ 14 - 1
app/service/material_audit.js

@@ -10,6 +10,7 @@
 
 const auditConst = require('../const/audit').material;
 const pushType = require('../const/audit').pushType;
+const pushOperate = require('../const/spec_3f').pushOperate;
 const smsTypeConst = require('../const/sms_type');
 const wxConst = require('../const/wechat_template');
 const shenpiConst = require('../const/shenpi');
@@ -291,6 +292,8 @@ module.exports = app => {
                 // }
 
                 // todo 更新标段tender状态 ?
+                // 检查三方特殊推送
+                await this.ctx.service.specMsg.addMaterialMsg(transaction, pid, materialInfo, pushOperate.material.flow);
                 await transaction.commit();
             } catch (err) {
                 await transaction.rollback();
@@ -358,7 +361,8 @@ module.exports = app => {
                         hs_m_tp: this.ctx.helper.add(this.ctx.helper.round(this.ctx.helper.mul(materialInfo.m_tp, 1+materialInfo.rate/100), material_decimal.tp), this.ctx.helper.round(this.ctx.helper.mul(materialInfo.ex_tp, 1+materialInfo.exponent_rate/100), material_decimal.tp)),
                     };
                     await this.ctx.helper.sendWechat(nextAudit.aid, smsTypeConst.const.TC, smsTypeConst.judge.approval.toString(), wxConst.template.material, wechatData);
-
+                    // 检查三方特殊推送
+                    await this.ctx.service.specMsg.addMaterialMsg(transaction, pid, materialInfo, pushOperate.material.flow);
 
                     // 添加短信通知-需要审批提醒功能
                     // const smsUser = await this.ctx.service.projectAccount.getDataById(nextAudit.aid);
@@ -445,6 +449,9 @@ module.exports = app => {
                         hs_m_tp: this.ctx.helper.add(this.ctx.helper.round(this.ctx.helper.mul(materialInfo.m_tp, 1+materialInfo.rate/100), material_decimal.tp), this.ctx.helper.round(this.ctx.helper.mul(materialInfo.ex_tp, 1+materialInfo.exponent_rate/100), material_decimal.tp)),
                     };
                     await this.ctx.helper.sendWechat(users, smsTypeConst.const.TC, smsTypeConst.judge.result.toString(), wxConst.template.material, wechatData);
+                    // 检查三方特殊推送
+                    await this.ctx.service.specMsg.addMaterialMsg(transaction, pid, materialInfo, pushOperate.material.flow);
+                    await this.ctx.service.specMsg.addMaterialMsg(transaction, pid, materialInfo, pushOperate.material.checked);
 
                     // 添加短信通知-审批通过提醒功能
                     // const mobile_array = [];
@@ -545,6 +552,8 @@ module.exports = app => {
                     hs_m_tp: this.ctx.helper.add(this.ctx.helper.round(this.ctx.helper.mul(materialInfo.m_tp, 1+materialInfo.rate/100), material_decimal.tp), this.ctx.helper.round(this.ctx.helper.mul(materialInfo.ex_tp, 1+materialInfo.exponent_rate/100), material_decimal.tp)),
                 };
                 await this.ctx.helper.sendWechat(users, smsTypeConst.const.TC, smsTypeConst.judge.result.toString(), wxConst.template.material, wechatData);
+                // 检查三方特殊推送
+                await this.ctx.service.specMsg.addMaterialMsg(transaction, pid, materialInfo, pushOperate.material.flow);
 
                 // 添加短信通知-审批退回提醒功能
                 // const mobile_array = [];
@@ -640,6 +649,8 @@ module.exports = app => {
                     hs_m_tp: this.ctx.helper.add(this.ctx.helper.round(this.ctx.helper.mul(materialInfo.m_tp, 1+materialInfo.rate/100), material_decimal.tp), this.ctx.helper.round(this.ctx.helper.mul(materialInfo.ex_tp, 1+materialInfo.exponent_rate/100), material_decimal.tp)),
                 };
                 await this.ctx.helper.sendWechat(preAuditor.aid, smsTypeConst.const.TC, smsTypeConst.judge.approval.toString(), wxConst.template.material, wechatData);
+                // 检查三方特殊推送
+                await this.ctx.service.specMsg.addMaterialMsg(transaction, pid, materialInfo, pushOperate.material.flow);
 
                 await transaction.insert(this.tableName, newAuditors);
                 await transaction.commit();
@@ -748,6 +759,8 @@ module.exports = app => {
                     hs_m_tp: this.ctx.helper.add(this.ctx.helper.round(this.ctx.helper.mul(materialInfo.m_tp, 1+materialInfo.rate/100), material_decimal.tp), this.ctx.helper.round(this.ctx.helper.mul(materialInfo.ex_tp, 1+materialInfo.exponent_rate/100), material_decimal.tp)),
                 };
                 await this.ctx.helper.sendWechat(audit.aid, smsTypeConst.const.TC, smsTypeConst.judge.approval.toString(), wxConst.template.material, wechatData);
+                // 检查三方特殊推送
+                await this.ctx.service.specMsg.addMaterialMsg(transaction, pid, materialInfo, pushOperate.material.flow);
                 await transaction.commit();
             } catch (err) {
                 await transaction.rollback();

+ 33 - 3
app/service/spec_msg.js

@@ -59,6 +59,18 @@ module.exports = app => {
             await transaction.insert(this.tableName, { pid, tid: stage.tid, sid: stage.id, timing });
         }
 
+        async addAdvanceMsg(transaction, pid, advance, timing) {
+            const needMsg = await this.tenderNeedMsg(pid, advance.id, timing);
+            if (!needMsg) return;
+            await transaction.insert(this.tableName, { pid, tid: advance.tid, advance_id: advance.id, timing });
+        }
+
+        async addMaterialMsg(transaction, pid, material, timing) {
+            const needMsg = await this.tenderNeedMsg(pid, material.tid, timing);
+            if (!needMsg) return;
+            await transaction.insert(this.tableName, { pid, tid: material.tid, material_id: material.id, timing });
+        }
+
         async addSettleMsg(transaction, pid, settle, timing) {
             const needMsg = await this.tenderNeedMsg(pid, settle.tid, timing);
             if (!needMsg) return;
@@ -71,13 +83,31 @@ module.exports = app => {
             await transaction.insert(this.tableName, { pid, tid: change.tid, cid: change.cid, timing });
         }
 
-        async addReportMsg(transaction, pid, tender, stage, timing) {
+        async addChangeApplyMsg(transaction, pid, change_apply, timing) {
+            const needMsg = await this.tenderNeedMsg(pid, change_apply.tid, timing);
+            if (!needMsg) return;
+            await transaction.insert(this.tableName, { pid, tid: change_apply.tid, c_apply_id: change_apply.id, timing });
+        }
+
+        async addChangeProjectMsg(transaction, pid, change_project, timing) {
+            const needMsg = await this.tenderNeedMsg(pid, change_project.tid, timing);
+            if (!needMsg) return;
+            await transaction.insert(this.tableName, { pid, tid: change_project.tid, c_proj_id: change_project.id, timing });
+        }
+
+        async addChangePlanMsg(transaction, pid, change_plan, timing) {
+            const needMsg = await this.tenderNeedMsg(pid, change_plan.tid, timing);
+            if (!needMsg) return;
+            await transaction.insert(this.tableName, { pid, tid: change_plan.tid, c_plan_id: change_plan.id, timing });
+        }
+
+        async addReportMsg(transaction, pid, tender, stage, timing, subInfo) {
             const needMsg = await this.tenderNeedMsg(pid, stage.tid, timing);
             if (!needMsg) return;
             if (transaction) {
-                await transaction.insert(this.tableName, { pid, tid: tender.id, sid: stage ? stage.id : 0, timing });
+                await transaction.insert(this.tableName, { pid, tid: tender.id, sid: stage ? stage.id : 0, timing, extra_info: JSON.stringify(subInfo || {}) });
             } else {
-                await this.db.insert(this.tableName, { pid, tid: tender.id, sid: stage ? stage.id : 0, timing });
+                await this.db.insert(this.tableName, { pid, tid: tender.id, sid: stage ? stage.id : 0, timing, extra_info: JSON.stringify(subInfo || {}) });
             }
         }
     }

+ 8 - 0
sql/update.sql

@@ -31,3 +31,11 @@ ADD COLUMN `settle_order`  tinyint(4) NOT NULL DEFAULT -1 AFTER `settle_id`;
 ALTER TABLE `zh_ledger_attachment`
 ADD COLUMN `settle_id`  int(11) NOT NULL DEFAULT -1 COMMENT '结算id' AFTER `tid`,
 ADD COLUMN `settle_order`  tinyint(4) NOT NULL DEFAULT -1 COMMENT '结算期序号' AFTER `settle_id`;
+
+ALTER TABLE `zh_s2b_spec_msg`
+ADD COLUMN `advance_id`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '预付款期id' AFTER `rid`,
+ADD COLUMN `material_id`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '材差期id' AFTER `advance_id`,
+ADD COLUMN `c_apply_id`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '变更申请id' AFTER `material_id`,
+ADD COLUMN `c_proj_id`  int(11) UNSIGNED NOT NULL COMMENT '变更立项id' AFTER `c_apply_id`,
+ADD COLUMN `c_plan_id`  int(11) UNSIGNED NOT NULL COMMENT '变更方案id' AFTER `c_proj_id`,
+ADD COLUMN `extra_info`  varchar(1000) NOT NULL DEFAULT '' COMMENT '附加信息(主要用于报表)' AFTER `timing`;