orderDetail.js 1.0 KB

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const { CrudService } = require('naf-framework-mongoose-free/lib/service');
  3. const { BusinessError, ErrorCode } = require('naf-core').Error;
  4. const _ = require('lodash');
  5. const assert = require('assert');
  6. //
  7. class OrderDetailService extends CrudService {
  8. constructor(ctx) {
  9. super(ctx, 'orderdetail');
  10. this.model = this.ctx.model.Trade.OrderDetail;
  11. this.orderModel = this.ctx.model.Trade.Order;
  12. }
  13. /**
  14. * 创建用户支付完成后的订单
  15. * @param {Object} body 请求参数体
  16. * @param body.order_id 下单的id
  17. */
  18. async create({ order_id }) {
  19. const order = await this.orderModel.findById(order_id);
  20. if (!order) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到支付订单的数据');
  21. const { customer, address, goods, no, status, buy_time } = order;
  22. if (status === '0') throw new BusinessError(ErrorCode.DATA_INVALID, '订单未支付');
  23. const orderDetailData = { customer, address, order: order_id };
  24. }
  25. }
  26. module.exports = OrderDetailService;