lrf 2 سال پیش
والد
کامیت
6870e4f977

+ 19 - 1
app/controller/trade/config/.afterSale.js

@@ -25,7 +25,24 @@ module.exports = {
   },
   update: {
     params: ['!id'],
-    requestBody: ['deal_person', 'money', 'order_detail', 'customer', 'shop', 'goods', 'type', 'reason', 'desc', 'file', 'transport', 'apply_time', 'end_time', 'status', 'result'],
+    requestBody: [
+      'out_bill',
+      'deal_person',
+      'money',
+      'order_detail',
+      'customer',
+      'shop',
+      'goods',
+      'type',
+      'reason',
+      'desc',
+      'file',
+      'transport',
+      'apply_time',
+      'end_time',
+      'status',
+      'result',
+    ],
   },
   show: {
     parameters: {
@@ -46,6 +63,7 @@ module.exports = {
         'end_time@end': 'end_time@end',
         status: 'status',
         deal_person: 'deal_person',
+        out_bill: 'out_bill',
       },
       // options: {
       //   "meta.state": 0 // 默认条件

+ 19 - 1
app/controller/trade/config/.orderDetail.js

@@ -8,7 +8,24 @@ module.exports = {
   },
   update: {
     params: ['!id'],
-    requestBody: ['type', 'group', 'remarks', 'order', 'shop', 'customer', 'address', 'no', 'transport', 'goods', 'total_detail', 'buy_time', 'pay_time', 'discount', 'status'],
+    requestBody: [
+      'out_bill',
+      'type',
+      'group',
+      'remarks',
+      'order',
+      'shop',
+      'customer',
+      'address',
+      'no',
+      'transport',
+      'goods',
+      'total_detail',
+      'buy_time',
+      'pay_time',
+      'discount',
+      'status',
+    ],
   },
   show: {
     parameters: {
@@ -33,6 +50,7 @@ module.exports = {
         status: 'status',
         type: 'type',
         group: 'group',
+        out_bill: 'out_bill',
       },
       // options: {
       //   "meta.state": 0 // 默认条件

+ 5 - 0
app/model/trade/afterSale.js

@@ -3,6 +3,9 @@ const Schema = require('mongoose').Schema;
 const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
 const MoneyPlugin = require('naf-framework-mongoose-free/lib/model/type-money-plugin');
 
+/**
+ * 与订单不同,此处是1订单1规格模式,对完账就对完了
+ */
 // 售后进度
 const afterSale = {
   order_detail: { type: String, required: false, zh: '订单详情', ref: 'Trade.OrderDetail' }, //
@@ -19,6 +22,7 @@ const afterSale = {
   status: { type: String, required: false, zh: '售后状态' }, // 字典:afterSale_status
   result: { type: Object, required: false, zh: '售后结果' }, // 售后完成后需要补充的内容,例如:退款的金额
   deal_person: { type: String, required: false, zh: '处理人', ref: 'User.Admin' }, //
+  out_bill: { type: String, required: false, default: '1', zh: '是否出账' }, // 字典:tf
 };
 const schema = new Schema(afterSale, { toJSON: { getters: true, virtuals: true } });
 schema.index({ id: 1 });
@@ -27,6 +31,7 @@ schema.index({ type: 1 });
 schema.index({ apply_time: 1 });
 schema.index({ end_time: 1 });
 schema.index({ deal_person: 1 });
+schema.index({ out_bill: 1 });
 
 schema.plugin(metaPlugin);
 schema.plugin(MoneyPlugin({ zh: '退款金额', required: false, key: 'money' }));

+ 6 - 0
app/model/trade/orderDetail.js

@@ -6,6 +6,10 @@ const transport = {
 
 const Schema = require('mongoose').Schema;
 const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+/**
+ * goods中会标记已对账的规格(out_bill:true),已对账的商品将不会再出现在对账单
+ * 所有的规格对账后,该订单也将变为已对账状态
+ */
 
 // 订单详情
 const orderDetail = {
@@ -24,6 +28,7 @@ const orderDetail = {
   remarks: { type: String, required: false, zh: '订单备注' }, //
   type: { type: String, required: false, default: '0', zh: '订单类型' }, // 字典:order_type
   group: { type: String, required: false, zh: '所属团', ref: 'Group.Group' }, //
+  out_bill: { type: String, required: false, default: '1', zh: '是否出账' }, // 字典:tf
 };
 const schema = new Schema(orderDetail, { toJSON: { getters: true, virtuals: true } });
 schema.index({ id: 1 });
@@ -38,6 +43,7 @@ schema.index({ pay_time: 1 });
 schema.index({ status: 1 });
 schema.index({ type: 1 });
 schema.index({ group: 1 });
+schema.index({ out_bill: 1 });
 
 schema.plugin(metaPlugin);
 

+ 3 - 1
app/service/trade/afterSale.js

@@ -115,7 +115,9 @@ class AfterSaleService extends CrudService {
       const res = await this.ctx.service.trade.pay.refund(obj);
       if (res.errcode && res.errcode !== 0) throw new BusinessError(ErrorCode.SERVICE_FAULT, res.errmsg);
     }
-    if (data.status === '1') tran.update('AfterSale', afterSale_id, { status: '-1' });
+    if (data.status === '1') {
+      tran.update('AfterSale', afterSale_id, { status: '-1', end_time: moment().format('YYYY-MM-DD HH:mm:ss') });
+    }
     // #region 团购部分
     const status = _.get(orderDetail, 'status');
     // 团购单,且未收货的单子,才需要走退团逻辑,否则不需要走退团逻辑