Browse Source

Merge branch 'dev' of pointToNetwork/server into master

lrf 2 years ago
parent
commit
94947e001a

+ 2 - 0
app/controller/trade/config/.orderDetail.js

@@ -19,6 +19,7 @@ module.exports = {
       'address',
       'no',
       'transport',
+      'transport_type',
       'goods',
       'total_detail',
       'buy_time',
@@ -52,6 +53,7 @@ module.exports = {
         group: 'group',
         out_bill: 'out_bill',
         goods: '%goods.goods.name%',
+        transport_type: 'transport_type',
       },
       // options: {
       //   "meta.state": 0 // 默认条件

+ 2 - 2
app/model/trade/afterSale.js

@@ -4,10 +4,10 @@ const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
 const MoneyPlugin = require('naf-framework-mongoose-free/lib/model/type-money-plugin');
 const transport = {
   customer_transport_no: { type: String, zh: '客户的快递单号' },
-  customer_transport_type: { type: String, zh: '客户的快递公司' },
+  customer_transport_company: { type: String, zh: '客户的快递公司' },
   customer_receive: { type: Boolean, zh: '客户是否签收' },
   shop_transport_no: { type: String, zh: '店家的快递单号' },
-  shop_transport_type: { type: String, zh: '店家的快递公司' },
+  shop_transport_company: { type: String, zh: '店家的快递公司' },
   shop_receive: { type: Boolean, zh: '店铺是否签收' },
 };
 // 售后进度

+ 3 - 1
app/model/trade/orderDetail.js

@@ -1,7 +1,7 @@
 'use strict';
 const transport = {
   shop_transport_no: '运单号',
-  shop_transport_type: '快递公司类型',
+  shop_transport_company: '快递公司类型',
 };
 
 const Schema = require('mongoose').Schema;
@@ -30,6 +30,7 @@ const orderDetail = {
   group: { type: String, required: false, zh: '所属团', ref: 'Group.Group' }, //
   out_bill: { type: String, required: false, default: '1', zh: '是否出账' }, // 字典:tf
   inviter: { type: String, required: false, zh: '推荐商品人', ref: 'User.User' }, // 返现部分
+  transport_type: { type: String, required: false, zh: '快递类型' }, // 字典:transport_type
 };
 const schema = new Schema(orderDetail, { toJSON: { getters: true, virtuals: true } });
 schema.index({ id: 1 });
@@ -46,6 +47,7 @@ schema.index({ type: 1 });
 schema.index({ group: 1 });
 schema.index({ out_bill: 1 });
 schema.index({ inviter: 1 });
+schema.index({ transport_type: 1 });
 
 schema.plugin(metaPlugin);
 

+ 3 - 5
app/service/shop/goodsRate.js

@@ -42,8 +42,8 @@ class GoodsRateService extends CrudService {
     const length = arr.length;
     let mid,
       midIndex;
-    const wl = [],
-      gl = [];
+    const gl = [];
+    let wl = [];
     if (length % 2 !== 0) {
       midIndex = this.ctx.plus(Math.floor(length / 2), 1);
       mid = arr[midIndex];
@@ -56,9 +56,7 @@ class GoodsRateService extends CrudService {
       else wl.push(i);
     }
     const offset = _.floor(this.ctx.divide(gl.length, 10));
-    for (let i = 0; i < offset.length; i++) {
-      wl.pop();
-    }
+    wl = wl.splice(1, offset);
     score = this.ctx.minus(score, this.ctx.multiply(wl.length, 0.01));
     return score;
   }

+ 3 - 3
app/service/statistics/admin.js

@@ -242,6 +242,7 @@ class AdminService extends CrudService {
       const obj = { date: d, money: 0 };
       if (r) obj.money = r.money;
       result.push(obj);
+      if (type === 'day') break;
     }
     return result;
   }
@@ -306,9 +307,8 @@ class AdminService extends CrudService {
   getDefaultRange(type) {
     let result;
     if (type === 'day') {
-      const start = moment().startOf('day').format(this.tf);
-      const end = moment(start).add(1, 'day').subtract(1, 'second')
-        .format(this.tf);
+      const start = moment().startOf('day').format(`${this.tf}`);
+      const end = moment(start).add(1, 'day').format(`${this.tf}`);
       result = [ start, end ];
     } else if (type === 'week') {
       const start = moment().startOf('week').format(this.tf);

+ 5 - 5
app/service/trade/afterSale.js

@@ -473,15 +473,15 @@ class AfterSaleService extends CrudService {
     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 { customer_transport_no, customer_transport_company, shop_transport_no, shop_transport_company } = transport;
     const result = {};
-    if (customer_transport_no && customer_transport_type) {
-      const q = { no: customer_transport_no, type: customer_transport_type };
+    if (customer_transport_no && customer_transport_company) {
+      const q = { no: customer_transport_no, type: customer_transport_company };
       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 };
+    if (shop_transport_no && shop_transport_company) {
+      const q = { no: shop_transport_no, type: shop_transport_company };
       const shop = await this.ctx.service.util.kd100.search(q);
       result.shop = shop;
     }

+ 1 - 1
app/service/trade/orderDetail.js

@@ -21,7 +21,7 @@ class OrderDetailService extends CrudService {
     const orderDetail = await this.model.findById(id);
     if (!id) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到订单信息');
     const { transport = {} } = orderDetail;
-    const { shop_transport_no: no, shop_transport_type: type } = transport;
+    const { shop_transport_no: no, shop_transport_company: type } = transport;
     if (!no || !type) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '缺少快递信息');
     const res = await this.ctx.service.util.kd100.search({ no, type });
     return res;