lrf402788946 3 vuotta sitten
vanhempi
commit
57cfa87ab5

+ 5 - 0
app/controller/patent/.sell.js

@@ -6,6 +6,7 @@ module.exports = {
       "name",
       "inventor",
       "type",
+      "money_type",
       "sell_type",
       "sell_money",
       "contacts",
@@ -27,6 +28,7 @@ module.exports = {
       "name",
       "inventor",
       "type",
+      "money_type",
       "sell_type",
       "sell_money",
       "contacts",
@@ -51,9 +53,12 @@ module.exports = {
         status: "status",
         create_number: "create_number",
         name: "name",
+        money_type: "money_type",
         type: "type",
         sell_type: "sell_type",
         contacts: "contacts",
+        "sell_money@start": "sell_money@start",
+        "sell_money@end": "sell_money@end",
       },
       // options: {
       //   "meta.state": 0 // 默认条件

+ 4 - 1
app/model/patent/sell.js

@@ -12,7 +12,8 @@ const sell = {
   inventor: { type: String }, // 权利人
   type: { type: String }, // 申请类型
   sell_type: { type: String }, // 交易类型:许可,转移,质押
-  sell_money: { type: String }, // 交易金额
+  money_type: { type: String }, // 交易金额方式
+  sell_money: { type: Number }, // 交易金额
   contacts: { type: String }, // 联系人
   phone: { type: String }, // 手机号
   email: { type: String }, // 邮箱
@@ -27,8 +28,10 @@ schema.index({ create_number: 1 });
 schema.index({ name: 1 });
 schema.index({ type: 1 });
 schema.index({ sell_type: 1 });
+schema.index({ money_type: 1 });
 schema.index({ contacts: 1 });
 schema.index({ status: 1 });
+schema.index({ sell_money: 1 });
 schema.index({ 'meta.createdAt': 1 });
 schema.plugin(metaPlugin);
 module.exports = app => {

+ 2 - 0
app/service/patent/sell.js

@@ -15,6 +15,7 @@ class SellService extends CrudService {
   }
   async query(query, { skip = 0, limit = 0 }) {
     query = await this.resetCode(query);
+    console.log(query);
     const res = await this.model.find(query).skip(parseInt(skip)).limit(parseInt(limit))
       .sort({ 'meta.createdAt': -1 });
     return res;
@@ -26,6 +27,7 @@ class SellService extends CrudService {
   }
 
   async resetCode(query) {
+    query = this.ctx.service.util.util.dealQuery(query);
     const { code } = query;
     let ids = [];
     if (code) {

+ 13 - 9
app/service/util/util.js

@@ -157,19 +157,23 @@ class UtilService extends CrudService {
     for (const k of keys) {
       if (k.includes('@')) {
         const karr = k.split('@');
-        //  因为是针对处理范围日期,所以必须只有,开始时间和结束时间
         if (karr.length === 2) {
           const type = karr[1];
           if (type === 'start') {
-            filter[karr[0]] = {
-              ..._.get(filter, karr[0], {}),
-              $gte: filter[k],
-            };
+            if (filter[k] && filter[k] !== '') {
+              filter[karr[0]] = {
+                ..._.get(filter, karr[0], {}),
+                $gte: filter[k],
+              };
+            }
+
           } else {
-            filter[karr[0]] = {
-              ..._.get(filter, karr[0], {}),
-              $lte: filter[k],
-            };
+            if (filter[k] && filter[k] !== '') {
+              filter[karr[0]] = {
+                ..._.get(filter, karr[0], {}),
+                $lte: filter[k],
+              };
+            }
           }
           delete filter[k];
         }