Browse Source

售后快递查询

lrf 2 years ago
parent
commit
1903a0f9e4

+ 3 - 0
app/controller/trade/config/.afterSale.js

@@ -79,4 +79,7 @@ module.exports = {
   orderCancel: {
     requestBody: ['order_detail', 'desc'],
   },
+  getTransportInfo: {
+    params: ['!id'],
+  },
 };

+ 25 - 0
app/service/trade/afterSale.js

@@ -404,6 +404,31 @@ class AfterSaleService extends CrudService {
     res = await this.afterFetch(filter, res);
     return res;
   }
+
+  /**
+   * 查询售后快递
+   * @param {Object} query 查询参数
+   * @param {String} query.id 售后id
+   */
+  async getTransportInfo({ id }) {
+    const data = await this.model.findById(id);
+    if (!data) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到售后数据');
+    const { transport } = data;
+    if (!transport) return;
+    const { customer_transport_no, customer_transport_type, shop_transport_no, shop_transport_type } = transport;
+    const result = {};
+    if (customer_transport_no && customer_transport_type) {
+      const q = { no: customer_transport_no, type: customer_transport_type };
+      const customer = await this.ctx.service.util.kd100.search(q);
+      result.customer = customer;
+    }
+    if (shop_transport_no && shop_transport_type) {
+      const q = { no: shop_transport_no, type: shop_transport_type };
+      const shop = await this.ctx.service.util.kd100.search(q);
+      result.shop = shop;
+    }
+    return result;
+  }
 }
 
 module.exports = AfterSaleService;

+ 0 - 1
app/service/util/kd100.js

@@ -30,7 +30,6 @@ class Kd100Service extends CrudService {
       if (!returnCode) {
         const list = this.resetData(data);
         const is_check = this.isCheck(ischeck);
-        console.log(is_check);
         return { list, is_check, no: nu, status };
       } else if (returnCode !== '200') throw new BusinessError(ErrorCode.SERVICE_FAUL, message);
     }

+ 1 - 0
app/z_router/trade/afterSale.js

@@ -7,6 +7,7 @@ const rkey = 'afterSale';
 const ckey = 'trade.afterSale';
 const keyZh = '售后';
 const routes = [
+  { method: 'get', path: `${rkey}/getTransportInfo/:id`, controller: `${ckey}.getTransportInfo`, name: `${ckey}getTransportInfo`, zh: `${keyZh}查询售后快递` },
   { method: 'post', path: `${rkey}/orderCancel`, controller: `${ckey}.orderCancel`, name: `${ckey}orderCancel`, zh: '取消订单' },
   { method: 'post', path: `${rkey}/cgfr`, controller: `${ckey}.cgfr`, name: `${ckey}cgfr`, zh: '查询退货商品的金额设置' },
   { method: 'get', path: `${rkey}`, controller: `${ckey}.index`, name: `${ckey}Query`, zh: `${keyZh}列表查询` },