Browse Source

修改接口

zs 1 year ago
parent
commit
1115a87dd2
2 changed files with 49 additions and 0 deletions
  1. 10 0
      src/controller/OrderDetail.controller.ts
  2. 39 0
      src/service/OrderDetail.service.ts

+ 10 - 0
src/controller/OrderDetail.controller.ts

@@ -44,6 +44,16 @@ export class OrderDetailController extends BaseController {
     const total = list.total;
     return { data, total };
   }
+
+  @Get('/money')
+  @ApiQuery({ name: 'money' })
+  async money(@Query() filter: any) {
+    const list: any = await this.service.money(filter);
+    const data = list.list;
+    const total = list.total;
+    return { data, total };
+  }
+
   @Get('/')
   @ApiQuery({ name: 'query' })
   @ApiResponse({ type: QVO_OrderDetail })

+ 39 - 0
src/service/OrderDetail.service.ts

@@ -56,6 +56,45 @@ export class OrderDetailService extends BaseService<modelType> {
     }
     return { list, total };
   }
+  async money(filter): Promise<object> {
+    const { skip = 0, limit, goods, ...info } = filter;
+    let list: any = [];
+    let total: any = 0;
+    if (goods) {
+      const arr = await this.goodModel
+        .findOne({
+          name: {
+            $regex: goods,
+          },
+        })
+        .lean();
+      if (arr) info.good = arr._id;
+    }
+    info.$or = [
+      { status: '6' },
+      { status: '7' },
+      { status: '-7' },
+      { status: '8' },
+      { status: '-8' },
+    ];
+    list = await this.model.find(info).skip(skip).limit(limit).lean();
+    total = await this.model.count(info);
+    for (const val of list) {
+      let res;
+      res = await this.goodModel.findById(val.good).lean();
+      val.good_name = res.name;
+      val.good_file = res.file[0];
+      res = await this.specModel.findById(val.spec).lean();
+      val.spec_name = res.name;
+      val.spec_file = res.file[0];
+      res = await this.userModel.findById(val.user).lean();
+      val.user_name = res.name;
+      val.user_role = res.role;
+      res = await this.userModel.findById(val.supplier).lean();
+      val.supplier_name = res.name;
+    }
+    return { list, total };
+  }
   // 详情
   async detail(id) {
     const res = await this.model.findById(id).lean();