zs 1 年之前
父节点
当前提交
54049775c7
共有 1 个文件被更改,包括 7 次插入5 次删除
  1. 7 5
      src/service/car.service.ts

+ 7 - 5
src/service/car.service.ts

@@ -11,15 +11,17 @@ export class CarService extends BaseService<modelType> {
   model: modelType;
   async queryList(filter) {
     const { skip = 0, limit, money, year, ...info } = filter;
+    // 处理车龄
+    if (year) info.age = { $lte: year.match(/(\S*)年/)[1] };
     // 处理价格
     if (money) {
-      if (money.includes('下') !== -1) {
-        info.total_money = { $lt: money.match(/(\S*)万/)[1] };
-      } else if (money.includes('上') !== -1) {
-        info.total_money = { $gt: money.match(/(\S*)万/)[1] };
+      if (money.indexOf('下') !== -1) {
+        info.total_money = { $lte: money.match(/(\S*)万/)[1] };
+      } else if (money.indexOf('上') !== -1) {
+        info.total_money = { $gte: money.match(/(\S*)万/)[1] };
       } else {
         const mon = money.substr(0, money.length - 1);
-        info.total_money = { $gt: mon.match(/(\S*)-/)[1], $lt: mon.match(/-(\S*)/)[1] };
+        info.total_money = { $gte: mon.match(/(\S*)-/)[1], $lte: mon.match(/-(\S*)/)[1] };
       }
     }
     const pipes: any[] = [