1234567891011121314151617181920212223242526272829 |
- 'use strict';
- const { CrudService } = require('naf-framework-mongoose-free/lib/service');
- const { BusinessError, ErrorCode } = require('naf-core').Error;
- const _ = require('lodash');
- const assert = require('assert');
- //
- class OrderDetailService extends CrudService {
- constructor(ctx) {
- super(ctx, 'orderdetail');
- this.model = this.ctx.model.Trade.OrderDetail;
- this.orderModel = this.ctx.model.Trade.Order;
- }
- /**
- * 创建用户支付完成后的订单
- * @param {Object} body 请求参数体
- * @param body.order_id 下单的id
- */
- async create({ order_id }) {
- const order = await this.orderModel.findById(order_id);
- if (!order) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到支付订单的数据');
- const { customer, address, goods, no, status, buy_time } = order;
- if (status === '0') throw new BusinessError(ErrorCode.DATA_INVALID, '订单未支付');
- const orderDetailData = { customer, address, order: order_id };
- }
- }
- module.exports = OrderDetailService;
|