lrf402788946 4 years ago
parent
commit
22fc659ac9
4 changed files with 426 additions and 57 deletions
  1. 1 0
      app/controller/bill/.bill.js
  2. 7 0
      app/model/bill.js
  3. 72 33
      app/service/order/order.js
  4. 346 24
      app/service/order/transport.js

+ 1 - 0
app/controller/bill/.bill.js

@@ -9,6 +9,7 @@ module.exports = {
     parameters: {
       query: {
         client: "client",
+        title:'title',
         owner:"owner",
         "create_time@start": "create_time@start",
         "create_time@end": "create_time@end",

+ 7 - 0
app/model/bill.js

@@ -4,6 +4,11 @@ const moment = require('moment');
 const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
 // 结算单
 const Bill = {
+  title: {
+    type: String,
+    maxLength: 200,
+    default: `${moment().format('YYYY-MM-DD HH:mm:ss')}结算单`,
+  }, // 结算单标题
   client: {
     type: String,
     required: true,
@@ -12,6 +17,8 @@ const Bill = {
   },
   ids: { type: Array },
   owner: { type: String, required: true }, // 创建人
+  remark: { type: String, maxLength: 200 }, // 备注
+  params: { type: Object }, // 额外参数
   create_time: {
     type: String,
     default: moment().format('YYYY-MM-DD HH:mm:ss'),

+ 72 - 33
app/service/order/order.js

@@ -311,13 +311,15 @@ class OrderService extends CrudService {
     else if (method === 'in') record.message = `${username}修改收入`;
     else if (method === 'out') record.message = `${username}修改支出`;
     else if (method === 'split') record.message = `${username}拆分货物`;
+    else if (method === 'js') record.message = `${username}结算订单`;
     else if (
       method === 'send' ||
       method === 'arrive' ||
-      method === 'principal'
+      method === 'principal' ||
+      method === 'outJs'
     ) {
       record.message = `${message}`;
-    } else if (method === 'js') record.message = `${username}结算订单`;
+    }
     order.record.push(record);
     await order.save();
   }
@@ -479,7 +481,7 @@ class OrderService extends CrudService {
       const res = i.replace(reg, '');
       return res;
     });
-    let lastData = this.toResetExcelData(pkeys, arr);
+    let lastData = arr.map(i => ({ content: i }));// this.toResetExcelData(pkeys, arr);
     lastData.push({ content: header });
     const alignment = { vertical: 'middle', horizontal: 'center' };
     lastData = lastData.map(i => ({ ...i, alignment }));
@@ -582,29 +584,29 @@ class OrderService extends CrudService {
       content[`AB${i + os}`] = sh_ys;
       content[`AC${i + os}`] = sh_ss;
       // 订单
-      content[`A${os}`] = _.get(order, 'order_no');
-      content[`AD${os}`] = _.get(order, 'remark');
+      content[`A${i + os}`] = _.get(order, 'order_no');
+      content[`AD${i + os}`] = _.get(order, 'remark');
       // 客户部分一定合并,不在这里处理
-      content[`B${os}`] = _.get(order.client, 'name');
-      content[`C${os}`] = _.get(order.client, 'address');
-      content[`D${os}`] = _.get(order.client, 'legal');
-      content[`E${os}`] = _.get(order.client, 'mobile');
-      content[`F${os}`] = _.get(order.client, 'taxes_no');
-      content[`G${os}`] = _.get(order.client, 'account_bank');
-      content[`H${os}`] = _.get(order.client, 'account');
+      content[`B${i + os}`] = _.get(order.client, 'name');
+      content[`C${i + os}`] = _.get(order.client, 'address');
+      content[`D${i + os}`] = _.get(order.client, 'legal');
+      content[`E${i + os}`] = _.get(order.client, 'mobile');
+      content[`F${i + os}`] = _.get(order.client, 'taxes_no');
+      content[`G${i + os}`] = _.get(order.client, 'account_bank');
+      content[`H${i + os}`] = _.get(order.client, 'account');
       // 合同部分
-      content[`I${os}`] = _.get(order.treaty, 'number');
-      content[`J${os}`] = _.get(order.treaty, 'jf');
-      content[`K${os}`] = _.get(order.treaty, 'yf');
-      content[`L${os}`] = _.get(order.treaty, 'period');
-      content[`M${os}`] = _.get(order.treaty, 'settle_up');
+      content[`I${i + os}`] = _.get(order.treaty, 'number');
+      content[`J${i + os}`] = _.get(order.treaty, 'jf');
+      content[`K${i + os}`] = _.get(order.treaty, 'yf');
+      content[`L${i + os}`] = _.get(order.treaty, 'period');
+      content[`M${i + os}`] = _.get(order.treaty, 'settle_up');
       // 项目
-      content[`N${os}`] = _.get(order.item, 'name');
-      content[`O${os}`] = _.get(order.item, 'taxes');
+      content[`N${i + os}`] = _.get(order.item, 'name');
+      content[`O${i + os}`] = _.get(order.item, 'taxes');
       // 线路
-      content[`P${os}`] = _.get(order.route, 'name');
-      content[`Q${os}`] = _.get(order.route, 's_p');
-      content[`R${os}`] = _.get(order.route, 'e_p');
+      content[`P${i + os}`] = _.get(order.route, 'name');
+      content[`Q${i + os}`] = _.get(order.route, 's_p');
+      content[`R${i + os}`] = _.get(order.route, 'e_p');
     }
     arr.push(content);
     return content;
@@ -618,15 +620,13 @@ class OrderService extends CrudService {
    */
   getOtherInExcelData(order, os, inList) {
     const obj = {};
-    const { in_bill, goods } = order;
-    for (let i = 0; i < goods.length; i++) {
-      for (const oin of inList) {
-        const { key, item, value } = oin;
-        const r = in_bill.find(f => f.item === item);
-        // console.log(key, item, value, r);
-        if (r) {
-          obj[`${key}${i + os}`] = _.get(r, value);
-        }
+    const { in_bill } = order;
+    for (const oin of inList) {
+      const { key, item, value } = oin;
+      const r = in_bill.find(f => f.item === item);
+      // console.log(key, item, value, r);
+      if (r) {
+        obj[`${key}${os}`] = _.get(r, value);
       }
     }
     return obj;
@@ -712,11 +712,12 @@ class OrderService extends CrudService {
    * 订单结算
    * @param {Object} {ids} 要结算的订单
    */
-  async js({ ids, client, owner }) {
+  async js({ ids, client, owner, ...info }) {
     assert(ids, '缺少订单信息');
     assert(client, '缺少客户信息');
     assert(owner, '缺少创建人信息');
-    const bill = await this.ctx.model.Bill.create({ ids, client, owner });
+    const params = { ids, client, owner };
+    const bill = await this.ctx.model.Bill.create({ params, client, owner, ...info });
     if (!bill) { throw new BusinessError(ErrorCode.DATABASE_FAULT, '结算单创建失败'); }
     const res = await this.model.updateMany(
       { _id: ids.map(i => ObjectId(i)) },
@@ -731,6 +732,44 @@ class OrderService extends CrudService {
     }
   }
 
+
+  /**
+   * 支出结算
+   * @param {Object} {ids,client,car_no} ids:订单id列表,client:客户id,car_no:车牌号(第三方)/车辆id(自运)
+   */
+  async outJs({ ids, client, car_no }) {
+    const orderList = await this.model.find({ _id: ids.map(i => ObjectId(i)) });
+    for (const order of orderList) {
+      const { out_bill, _id } = order;
+      let target;
+      let res;
+      if (client) {
+        res = out_bill.filter(f => f.client === client);
+        const cInfo = await this.ctx.model.Client.findById(client);
+        if (!cInfo) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定供应商');
+        target = _.get(cInfo, 'name');
+      } else {
+        res = out_bill.filter(f => f.car_no === car_no);
+        const reg = new RegExp('[\\u4E00-\\u9FFF]+', 'g');
+        if (reg.test(car_no)) {
+          target = car_no;
+        } else {
+          const cInfo = await this.ctx.model.Car.findById(car_no);
+          if (!cInfo) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定车辆');
+          target = cInfo.car_no;
+        }
+      }
+      for (const bill of res) {
+        bill.is_js = true;
+      }
+      order.save();
+      try {
+        this.record(_id, { method: 'outJs', message: `结算 ${target} 支出` });
+      } catch (error) {
+        this.logger.error(`订单id:${res.id}记录创建失败:${error.toString()}`);
+      }
+    }
+  }
 }
 
 module.exports = OrderService;

+ 346 - 24
app/service/order/transport.js

@@ -340,11 +340,20 @@ class TransportService extends CrudService {
    */
   async supplierCalculate(query) {
     query = this.util.turnDateRangeQuery(this.util.turnFilter(query));
-    console.log(query);
     const sclient = _.get(query, 'supplier.client');
     const scar = _.get(query, 'supplier.car_no');
-    if (sclient && scar) throw new BusinessError(ErrorCode.BUSINESS, '请只选择 供应商 或 第三方车号 方式之一进行查询');
-    if (!(sclient || scar)) throw new BusinessError(ErrorCode.BUSINESS, '请至少选择 供应商 或 第三方车号 方式之一进行查询');
+    if (sclient && scar) {
+      throw new BusinessError(
+        ErrorCode.BUSINESS,
+        '请只选择 供应商 或 第三方车号 方式之一进行查询'
+      );
+    }
+    if (!(sclient || scar)) {
+      throw new BusinessError(
+        ErrorCode.BUSINESS,
+        '请至少选择 供应商 或 第三方车号 方式之一进行查询'
+      );
+    }
     let list;
     list = await this.model.find({ ...query, is_js: false });
     if (list.length > 0) list = JSON.parse(JSON.stringify(list));
@@ -353,56 +362,369 @@ class TransportService extends CrudService {
       list.map(i => i.goods.map(ii => ObjectId(ii.split_id)))
     );
     // 运输单列表的所有货物所在的订单列表
-    const orderList = await this.ctx.model.Order.find({ 'split._id': split_ids });
+    const orderList = await this.ctx.model.Order.find({
+      'split._id': split_ids,
+    });
     // 进行匹配,拼接订单号
     list = list.map(i => {
       const orders = orderList.filter(o => {
         const { split } = o;
         if (!(split && _.isArray(split))) return false;
-        const r = split.find(og => i.goods.find(tg => ObjectId(tg.split_id).equals(og._id)));
+        const r = split.find(og =>
+          i.goods.find(tg => ObjectId(tg.split_id).equals(og._id))
+        );
         return r;
       });
       i.order_nos = orders.map(i => i.order_no).join(';');
-      i.t_sh_ys = i.goods.reduce((p, n) => p + (n.sh_ys || 0), 0);
-      i.t_sq_ys = i.goods.reduce((p, n) => p + (n.sq_ys || 0), 0);
+      i.sh_ys = i.goods.reduce((p, n) => p + (n.sh_ys || 0), 0);
+      i.sq_ys = i.goods.reduce((p, n) => p + (n.sq_ys || 0), 0);
+      i.cost_item = '运费';
       i.taxes = _.get(_.head(i.goods), 'taxes', '1');
       return i;
     });
-
-    // 支出的钱有2部分: 货物(运费)+货物对应订单的该供应商的支出数据(该供应商的额外支出费用)
+    // 支出的钱有2部分: 货物(运费)+订单的该供应商的支出数据(该供应商的额外支出费用)
+    // 还需要查出如果这个车只是某订单中的中间环节的支出
+    const orderQuery = _.omitBy(query, (value, key) => key.includes('supplier'));
+    if (sclient) orderQuery['out_bill.client'] = _.get(query, 'supplier.client');
+    else orderQuery['out_bill.car_no'] = _.get(query, 'supplier.car_no');
+    let outOrderList = await this.ctx.model.Order.find(orderQuery);
+    if (outOrderList.length > 0) outOrderList = JSON.parse(JSON.stringify(outOrderList));
+    let arr = [];
+    for (const order of outOrderList) {
+      const { order_no: order_nos, out_bill, _id: order_id } = order;
+      let lr = out_bill.filter(f => {
+        if (sclient) return f.client === orderQuery['out_bill.client'];
+        return f.car_no === orderQuery['out_bill.car_no'];
+      });
+      if (lr.length > 0) {
+        // 结算的不要
+        lr = lr.filter(f => !f.is_js);
+        lr = lr.map(i => ({ ...i, order_nos, order_id }));
+        arr.push(lr);
+      }
+    }
+    arr = _.flattenDeep(arr);
+    list = [ ...list, ...arr ];
     return list;
   }
 
   /**
-   * 选择指定的运输单,导出收入excel
+   * 选择指定的支出,导出收入excel
+   * excel的形式最后要拆到货物对应的供应商身上
    * @param {Object} query 查询条件
    * @property Array ids 订单id集合
    */
-  async supplierExport(query) {}
+  async supplierExport(query) {
+    console.log(query);
+    const { ids, outOrderIds, ...params } = query;
+    // 查出选择的运输单
+    let list = await this.model.find({ _id: ids.map(i => ObjectId(i)) });
+    if (list.length > 0) list = JSON.parse(JSON.stringify(list));
+    // 检查是否是供应商类型,如果是的话,需要将合同,客户名称
+    list = await this.checkSupplier(list);
+    const split_ids = _.flattenDeep(
+      list.map(i => i.goods.map(ii => ObjectId(ii.split_id)))
+    );
+    // 运输单列表的所有货物所在的订单列表
+    const orderList = await this.ctx.model.Order.find({
+      'split._id': split_ids,
+    });
+    for (const i of list) {
+      for (const g of i.goods) {
+        for (const o of orderList) {
+          const { split, order_no } = o;
+          if (!(split && _.isArray(split))) return false;
+          const r = split.find(og =>
+            i.goods.find(tg => ObjectId(tg.split_id).equals(og._id))
+          );
+          if (r) {
+            g.order_no = order_no;
+            break;
+          }
+        }
+      }
+    }
+    // 以上整理完了运费相关的数据;下面该把选择的非运费收费项拿出来了
+    let outOrderList = await this.ctx.model.Order.find({ _id: outOrderIds.map(i => ObjectId(i)) });
+    if (outOrderList.length > 0) outOrderList = JSON.parse(JSON.stringify(outOrderList));
+    let orderOut = outOrderList.map(i => {
+      const { out_bill, order_no } = i;
+      const { client, car_no } = params;
+      let l = out_bill.filter(f => {
+        if (client) return f.client === client;
+        return f.car_no === car_no;
+      });
+      // 将客户这部分信息整合成一致的形式
+      if (l.length > 0) l = l.map(i => ({ ...i, order_no, supplier: { taxes: i.taxes } }));
+      return l;
+    });
+    orderOut = _.flattenDeep(orderOut);
+    orderOut = await this.otherCheckSupplier(orderOut);
+    // 数据整理完了,该拼了
+    const midData = this.setData(list, orderOut);
+    const header = this.getHeader();
+    let pkeys = Object.keys(header);
+    pkeys = pkeys.map(i => {
+      const reg = /[^a-zA-Z]/i;
+      const res = i.replace(reg, '');
+      return res;
+    });
+
+    let lastData = midData; // this.toResetExcelData(pkeys, midData)
+    lastData.push({ content: header });
+    const alignment = { vertical: 'middle', horizontal: 'center' };
+    lastData = lastData.map(i => ({ ...i, alignment }));
+    // console.log(lastData);
+    const res = await this.ctx.service.util.excel.toExcel({ data: lastData });
+    console.log(res);
+
+  }
+
+  /**
+   * 检查其他支出项是否是供应商类型,是的话就把信息转换了
+   * @param {Array} list 其他支出项
+   */
+  async otherCheckSupplier(list) {
+    const is_supplier = list.every(e => e.supply_type === '1');
+    if (!is_supplier) return list;
+    let rl = await this.dynamicData('client', list.map(i => i.client));
+    list = list.map(i => {
+      const id = _.get(i, 'client');
+      if (!id) return i;
+      const r = rl.find(f => ObjectId(f._id).equals(id));
+      if (r) i.supplier.client = r;
+      return i;
+    });
+    rl = await this.dynamicData('treaty', list.map(i => i.treaty));
+    list = list.map(i => {
+      const id = _.get(i, 'treaty');
+      if (!id) return i;
+      const r = rl.find(f => ObjectId(f._id).equals(id));
+      if (r) i.supplier.treaty = r;
+      return i;
+    });
+    rl = await this.dynamicData('item', list.map(i => i.item));
+    list = list.map(i => {
+      const id = _.get(i, 'item');
+      if (!id) return i;
+      const r = rl.find(f => ObjectId(f._id).equals(id));
+      if (r) i.supplier.item = r;
+      return i;
+    });
+    return list;
+  }
+
+  /**
+   * 检查运输单是否是供应商类型,如果是供应商类型,就需要把供应商部分的信息转换过来
+   * @param {Array} list 运输单列表
+   */
+  async checkSupplier(list) {
+    // 使用every是因为一定只选择一个供应商/车号的内容,所以这里其实多余判断
+    const is_supplier = list.every(e => e.supply_type === '1');
+    if (!is_supplier) return list;
+    list = await this.dynamicGetSupplier('client', list);
+    list = await this.dynamicGetSupplier('treaty', list);
+    list = await this.dynamicGetSupplier('item', list);
+    list = await this.dynamicGetSupplier('route', list);
+    list = await this.dynamicGetSupplier('mode', list);
+    return list;
+  }
+
+  /**
+   * 动态查询供应商信息
+   * @param {String} type 表/字段名
+   * @param {Array} list 数据列表
+   */
+  async dynamicGetSupplier(type, list) {
+    const toCheck = _.compact(list.map(i => ObjectId(_.get(i.supplier, type))));
+    if (toCheck.length <= 0) return list;
+    const res = await this.dynamicData(type, toCheck);
+    for (const i of list) {
+      const { supplier } = i;
+      if (!supplier) continue;
+      const id = _.get(supplier, type);
+      if (!id) continue;
+      const r = await res.find(f => ObjectId(f._id).equals(id));
+      if (r) supplier[type] = r;
+    }
+    return list;
+  }
+
+  /**
+   * 动态查询
+   * @param {String} type 表/字段名
+   * @param {Array} ids id数组
+   */
+  async dynamicData(type, ids) {
+    let res = await this.ctx.model[`${_.capitalize(type)}`].find({
+      _id: ids,
+    });
+    if (res.length > 0) res = JSON.parse(JSON.stringify(res));
+    return res;
+  }
+
+
+  /**
+   * 整理导出字段
+   * @param {Array} transport 运输单数组
+   * @param {Array} orderOut 支出
+   */
+  setData(transport, orderOut) {
+    let tarr = transport.map(i => {
+      const { supplier, goods, route } = i;
+      const list = goods.map(g => ({ ...g, supplier, route }));
+      return list;
+    });
+    tarr = _.flattenDeep(tarr);
+    let list = [ ...tarr, ...orderOut ];
+    list = _.orderBy(list, [ 'order_no' ], [ 'asc' ]);
+    // 给头预留的位置
+    list.unshift({});
+    const arr = [];
+    for (let i = 1; i < list.length; i++) {
+      const e = list[i];
+      const os = i + 1;
+      const { supplier } = e;
+      const content = {};
+      content[`A${os}`] = _.get(e, 'order_no'); // 订单号
+      // 客户部分
+      content[`B${os}`] = _.get(supplier.client, 'name');
+      content[`C${os}`] = _.get(supplier.client, 'address');
+      content[`D${os}`] = _.get(supplier.client, 'legal');
+      content[`E${os}`] = _.get(supplier.client, 'mobile');
+      content[`F${os}`] = _.get(supplier.client, 'taxes_no');
+      content[`G${os}`] = _.get(supplier.client, 'account_bank');
+      content[`H${os}`] = _.get(supplier.client, 'account');
+      // 合同部分
+      content[`I${os}`] = _.get(supplier.treaty, 'number');
+      content[`J${os}`] = _.get(supplier.treaty, 'jf');
+      content[`K${os}`] = _.get(supplier.treaty, 'yf');
+      content[`L${os}`] = _.get(supplier.treaty, 'period');
+      content[`M${os}`] = _.get(supplier.treaty, 'settle_up');
+      // 项目
+      content[`N${os}`] = _.get(supplier.item, 'name');
+      // 线路
+      content[`O${os}`] = _.get(e, 'route');
+      // 费用相关
+      content[`P${os}`] = _.get(e, 'name');
+      content[`Q${os}`] = _.get(e, 'cost_item', '运费');
+      content[`R${os}`] = _.get(e, 'taxes');
+      content[`S${os}`] = _.get(e, 'sq_ys');
+      content[`T${os}`] = _.get(e, 'sq_ss');
+      content[`U${os}`] = _.get(e, 'sh_ys');
+      content[`V${os}`] = _.get(e, 'sh_ss');
+      content[`W${os}`] = _.get(e, 'remark');
+      arr.push({ content });
+    }
+    return arr;
+  }
+
+
+  /**
+   * 合并处理数据
+   * @param {Array} keys 列字母数组
+   * @param {Array} data excel数据(不含头)
+   */
+  toResetExcelData(keys, data) {
+    const reg = /[^a-zA-Z]/i;
+    const arr = [];
+    const clear = [];
+    console.log(keys);
+    for (const key of keys) {
+      // 找出每列的内容
+      const col = data.map(i => {
+        const lks = Object.keys(i);
+        const r = lks.find(f => {
+          const rr = f.replace(reg, '');
+          return rr === key;
+        });
+        if (r) return { key: r, value: _.get(i, r) };
+      });
+      console.log(col);
+      // 同一列满足以下条件可以合并:
+      // 1,值相同;2数字连贯;3指定范围内
+      // 先查范围
+      const head = _.head(col);
+      if (!head) continue;
+      const l = col.length;
+      const ul = _.uniqBy(col, 'value').length;
+      if (ul === l) continue;
+      // 可以合并,需要重新拼个Object,{scell,ecell,content}
+      // scell 是上面head的key, ecell是last获取key,content,随意拿出一个就行
+      const obj = {};
+      obj.scell = _.get(head, 'key');
+      obj.ecell = _.get(_.last(col), 'key');
+      obj.content = _.get(head, 'value');
+      clear.push(_.get(head, 'key'), _.get(_.last(col), 'key'));
+      arr.push(obj);
+    }
+    // 将scell和ecell都干掉
+    data = data.map(i => {
+      i = _.omitBy(i, (value, key) => {
+        return clear.includes(key);
+      });
+      return { content: i };
+    });
+    data = [ ...data, ...arr ];
+    return data;
+  }
+
+  /**
+   * 获取导出的excel头
+   */
+  getHeader() {
+    const obj = {};
+    obj.A1 = '订单编号';
+    // 客户部分
+    obj.B1 = '客户名称';
+    obj.C1 = '地址';
+    obj.D1 = '法人';
+    obj.E1 = '联系电话';
+    obj.F1 = '税号';
+    obj.G1 = '开户行';
+    obj.H1 = '银行账号';
+    // 合同部分
+    obj.I1 = '合同编号';
+    obj.J1 = '甲方';
+    obj.K1 = '乙方';
+    obj.L1 = '合同周期';
+    obj.M1 = '结算方式';
+    // 项目部分
+    obj.N1 = '项目名称';
+    // 线路部分
+    obj.O1 = '线路';
+    // 费用相关
+    obj.P1 = '货物';
+    obj.Q1 = '费用名称';
+    obj.R1 = '税率';
+    obj.S1 = '税前应收';
+    obj.T1 = '税前实收';
+    obj.U1 = '税后应收';
+    obj.V1 = '税后实收';
+    obj.W1 = '备注';
+    return obj;
+  }
 
   /**
    * 供应商结算
-   * @param {Object} {ids} 要结算的订单
+   * @param {Object} {ids, outOrderIds} 供应商要结算的运费,供应商给订单服务的支出结算
    */
-  async js({ ids, client, owner }) {
-    assert(ids, '缺少订单信息');
-    assert(client, '缺少客户信息');
+  async js({ ids, outOrderIds, client, car_no, owner, ...info }) {
+    assert(client, '缺少供应商信息');
     assert(owner, '缺少创建人信息');
-    const bill = await this.ctx.model.Bill.create({ ids, client, owner });
+    const params = { ids, outOrderIds, client, car_no, owner, info };
+    const bill = await this.ctx.model.Bill.create({ client: client || car_no, owner, ...info, params });
     if (!bill) {
       throw new BusinessError(ErrorCode.DATABASE_FAULT, '结算单创建失败');
     }
-    const res = await this.model.updateMany(
+    await this.model.updateMany(
       { _id: ids.map(i => ObjectId(i)) },
       { is_js: true }
     );
-    try {
-      for (const id of ids) {
-        this.record(id, { method: 'js' });
-      }
-    } catch (error) {
-      this.logger.error(`订单id:${res.id}记录创建失败:${error.toString()}`);
-    }
+    // 修改订单的支出状态,并记录
+    await this.ctx.service.order.order.outJs({ ids: outOrderIds, client, car_no });
   }
+
+
 }
 module.exports = TransportService;