Browse Source

预警次数

guhongwei 3 years ago
parent
commit
caa2419035

+ 16 - 2
app/controller/patent/.patentearly.js

@@ -1,6 +1,13 @@
 module.exports = {
   create: {
-    requestBody: ["parent_id", "name", "inventor", "lose_date", "content"],
+    requestBody: [
+      "parent_id",
+      "name",
+      "inventor",
+      "lose_date",
+      "content",
+      "early_num",
+    ],
   },
   destroy: {
     params: ["!id"],
@@ -8,7 +15,14 @@ module.exports = {
   },
   update: {
     params: ["!id"],
-    requestBody: ["parent_id", "name", "inventor", "lose_date", "content"],
+    requestBody: [
+      "parent_id",
+      "name",
+      "inventor",
+      "lose_date",
+      "content",
+      "early_num",
+    ],
   },
   show: {
     parameters: {

+ 1 - 0
app/model/patent/patentearly.js

@@ -10,6 +10,7 @@ const patentearly = {
   inventor: { type: String }, // 发明人
   lose_date: { type: String }, // 失效日
   content: { type: String }, // 预警消息
+  early_num: { type: String }, // 预警次数,1:三个月,2:两个月,3:一个月
   user_id: { type: [ ObjectId ] }, // 接收人id
   remark: { type: String },
 };

+ 4 - 5
app/service/patent/patentearly.js

@@ -109,28 +109,27 @@ class PatentearlyService extends CrudService {
         // 判断是否是三个月的区间
         const r = moment().isBetween(start, end, null, '[]');
         // 判断是否在一个月的区间
-        const one_section = moment().isBetween(start_thr, end, null, '[]');
         if (r) {
           // 三个月内的第一天||两个月内第一天||一个月内的每天 发送消息
           // 是否发送的变量
           let dr = false;
           const toDay = moment().format('YYYY-MM-DD');
-          if (toDay === start || toDay === start_two || one_section) {
+          if (toDay === start || toDay === start_two || toDay === start_thr) {
             dr = true;
           }
           // 不发就继续
           if (!dr) continue;
           const { user_id } = i;
-          // 2021-11-04 修改,因为inventor修改为发明人[Object],所以发明人需要处理成字符串
           const users = user_id.map(i => i.user_id);
-          // // const inventorNameString = inventor.map(i => i.name).join(';');
-          // // const content = `发明人 【${inventorNameString}】 的已授权专利 【${name}】 即将失效,避免专利失效过期,请用户及时查看消息并处理! `;
+          // 判断预警次数
+          const early_num = toDay === start ? 1 : toDay === start_two ? 2 : toDay === start_thr ? 3 : '';
           const content = '您可能需缴年费了,具体以缴费通知书为准 ';
           const nobj = {
             ..._.omit(i, [ '_id', 'id', 'users' ]),
             content,
             parent_id: i._id,
             user_id: users,
+            early_num,
           };
           this.model.create(nobj);
           // 2021-11-04添加 向 patentexamine 表中添加数据