lrf 2 роки тому
батько
коміт
2678744362

+ 0 - 2
app/controller/home.js

@@ -5,8 +5,6 @@ const Controller = require('egg').Controller;
 class HomeController extends Controller {
   async index() {
     const { ctx } = this;
-    // throw new BusinessError(ErrorCode.DATA_NOT_EXIST,'数据不存在')
-    this.newtest();
     ctx.body = 'hi, egg';
   }
   async m1() {

+ 0 - 1
app/middleware/errorEmail.js

@@ -2,7 +2,6 @@
 const _ = require('lodash');
 module.exports = options => {
   return async function errorEmail(ctx, next) {
-    console.log('line 5 in function:');
     try {
       await next();
     } catch (e) {

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

@@ -132,6 +132,9 @@ class AfterSaleService extends CrudService {
     // 如果有,就说明该优惠券可以退了,没有影响任何一单了
     const payOrder = _.get(orderDetail, 'order');
     await this.checkToReturnUserCoupon(payOrder, tran);
+    // 退积分,退多钱就退多少积分
+    const { customer } = orderDetail;
+    await this.ctx.service.user.point.refundPoint({ customer, money: refundMoney, source_id: afterSale_id, source: '-1' }, tran);
   }
 
   /**

+ 5 - 1
app/service/user/point.js

@@ -24,7 +24,6 @@ class PointService extends CrudService {
     return total;
   }
 
-
   /**
    * 添加积分;将处理添加至事务之中
    * @param {String} orderDetail_id 订单详情id
@@ -51,6 +50,11 @@ class PointService extends CrudService {
     const num = await this.model.count({ customer, source_id, source });
     return num > 0;
   }
+
+  async refundPoint({ customer, money, source, source_id }, tran) {
+    const data = { customer, money, time: moment().format('YYYY-MM-DD HH:mm:ss'), status: '1', source, source_id };
+    tran.insert(data);
+  }
 }
 
 module.exports = PointService;