Jelajahi Sumber

待办页通知

ellisran 2 bulan lalu
induk
melakukan
18a84727cd
2 mengubah file dengan 17 tambahan dan 12 penghapusan
  1. 1 1
      app/controller/dashboard_controller.js
  2. 16 11
      app/service/notice_push.js

+ 1 - 1
app/controller/dashboard_controller.js

@@ -41,7 +41,7 @@ module.exports = app => {
             const auditStageAss = await ctx.service.stageAuditAss.getAuditStageAss(ctx.session.sessionUser.accountId, ctx.subProject.id);
             const auditFinancials = ctx.subProject.page_show.openFinancial ? await ctx.service.financialPayAudit.getAuditFinancial(ctx.session.sessionUser.accountId, ctx.subProject.id) : [];
             const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
-            const noticeList = await ctx.service.noticePush.getNotice(ctx.session.sessionProject.id, pa.id);
+            const noticeList = await ctx.service.noticePush.getNotice(ctx.session.sessionProject.id, pa.id, ctx.subProject.id);
             const projectData = await ctx.service.project.getDataById(ctx.session.sessionProject.id);
             // 获取销售人员数据
             const salesmanData = await ctx.service.manager.getDataById(projectData.manager_id);

+ 16 - 11
app/service/notice_push.js

@@ -34,7 +34,7 @@ module.exports = app => {
          * @param {Integer} pid - 项目id
          * @param {Integer} uid - 查询人id
          */
-        async getNotice(pid, uid = 0) {
+        async getNotice(pid, uid = 0, spid = '') {
             // const noticeList = [];
             // for (const type in auditConst.pushType) {
             //     const wheres = { pid, type: auditConst.pushType[type] };
@@ -55,16 +55,21 @@ module.exports = app => {
             //     noticeList.push(...notice);
             // }
             // return this._.orderBy(noticeList, ['create_time'], ['desc']);
-            const wheres = { pid };
-            if (uid !== 0) {
-                wheres.uid = uid;
-            }
-            let notice = await this.db.select(this.tableName, {
-                where: wheres,
-                orders: [['create_time', 'desc']],
-                limit: 30,
-                offset: 0
-            });
+            // const wheres = { pid };
+            // if (uid !== 0) {
+            //     wheres.uid = uid;
+            // }
+            // let notice = await this.db.select(this.tableName, {
+            //     where: wheres,
+            //     orders: [['create_time', 'desc']],
+            //     limit: 30,
+            //     offset: 0
+            // });
+            const uidSql = uid ? ' AND a.`uid` = ' + uid : '';
+            const spidSql = spid ? ' AND (a.`spid` = "' + spid + '" OR t.`spid` = "' + spid + '")': '';
+            const sql = 'SELECT a.* FROM ?? AS a LEFT JOIN ?? AS t ON a.`tid` = t.`id` WHERE a.`pid` = ?' + uidSql + spidSql + ' ORDER BY a.`create_time` DESC LIMIT 0,30';
+            const params = [this.tableName, this.ctx.service.tender.tableName, pid];
+            let notice = await this.db.query(sql, params);
             notice = notice.map(v => {
                 const extra = JSON.parse(v.content);
                 delete v.content;