|
@@ -2,17 +2,16 @@
|
|
|
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');
|
|
|
-
|
|
|
// 订单
|
|
|
const order = {
|
|
|
- customer: { type: String, required: false, zh: '顾客', ref: 'User.User' }, //
|
|
|
+ customer: { type: String, required: false, zh: '顾客', ref: 'User.Customer' }, //
|
|
|
address: { type: String, required: false, zh: '邮寄地址', ref: 'User.address' }, //
|
|
|
- total_detail: { type: Array, required: false, zh: '总金额明细' }, // 运费,优惠,活动,商品原费用的和
|
|
|
+ goods: { type: Array, required: false, zh: '商品' }, // 按店铺分组,快照过来
|
|
|
+ total_detail: { type: Object, required: false, zh: '总金额明细' }, // 优惠,活动;商品总额和运费由商品而来
|
|
|
buy_time: { type: String, required: false, zh: '下单时间' }, //
|
|
|
pay_time: { type: String, required: false, zh: '支付时间' }, //
|
|
|
pay_id: { type: String, required: false, zh: '支付id' }, //
|
|
|
- pay_no: { type: String, required: false, zh: '支付订单号' }, //
|
|
|
+ no: { type: String, required: false, zh: '订单号' }, //
|
|
|
status: { type: String, required: false, zh: '订单状态' }, // 字典:order_process
|
|
|
};
|
|
|
const schema = new Schema(order, { toJSON: { getters: true, virtuals: true } });
|
|
@@ -21,10 +20,9 @@ schema.index({ 'meta.createdAt': 1 });
|
|
|
schema.index({ customer: 1 });
|
|
|
schema.index({ buy_time: 1 });
|
|
|
schema.index({ pay_id: 1 });
|
|
|
-schema.index({ pay_no: 1 });
|
|
|
+schema.index({ no: 1 });
|
|
|
|
|
|
schema.plugin(metaPlugin);
|
|
|
-schema.plugin(MoneyPlugin({ zh: '总金额', required: false, key: 'total' }));
|
|
|
|
|
|
module.exports = app => {
|
|
|
const { mongoose } = app;
|