wangzhibo
4 天以前 c19f1f7e21c93d1f13b4f44a8a615f65af577559
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import { BaseEntity } from '@cool-midway/core';
import { Column, Entity, Index } from 'typeorm';
import { UserAddressEntity } from '../../user/entity/address';
import { OrderGoodsEntity } from './goods';
 
/**
 * 订单信息
 */
@Entity('order_info')
export class OrderInfoEntity extends BaseEntity {
  @Index()
  @Column({ comment: '用户ID' })
  userId: string;
 
  @Column({ comment: '标题', nullable: true })
  title: string;
 
  @Column({ comment: '支付方式 0-待支付 1-微信 2-支付宝 3-碳积分', default: 0 })
  payType: number;
 
  @Column({ comment: '支付时间', type: 'datetime', nullable: true })
  payTime: Date;
 
  @Index()
  @Column({ comment: '订单号', nullable: true })
  orderNum: string;
 
  @Column({
    comment:
      '状态 0-待付款 1-待发货 2-待收货 3-待评价 4-交易完成 5-退款中 6-已退款 7-已关闭',
    type: 'tinyint',
    default: 0,
  })
  status: number;
 
  @Column({
    comment: '价格',
    type: 'decimal',
    precision: 12,
    scale: 2,
  })
  price: number;
 
  @Column({
    comment: '优惠金额',
    type: 'decimal',
    scale: 2,
    precision: 12,
    default: 0,
  })
  discountPrice: number;
 
  @Column({ comment: '优惠来源', type: 'json', nullable: true })
  discountSource: {
    // 0-优惠券
    type: number;
    // 对象ID
    objectId: number;
    // 信息
    info: any;
  };
 
  @Column({ comment: '地址', type: 'json', nullable: true })
  address: UserAddressEntity;
 
  @Column({ comment: '物流信息', type: 'json', nullable: true })
  logistics: {
    // 物流公司
    company: string;
    // 物流单号
    num: string;
  };
 
  @Column({ comment: '退款', type: 'json', nullable: true })
  refund: {
    // 退款单号
    orderNum: string;
    // 金额
    amount: number;
    // 实际退款金额
    realAmount: number;
    // 状态 0-申请中 1-已退款 2-拒绝
    status: number;
    // 申请时间
    applyTime: Date;
    // 退款时间
    time: Date;
    // 退款原因
    reason: string;
    // 拒绝原因
    refuseReason: string;
  };
 
  @Index()
  @Column({
    asExpression: "JSON_EXTRACT(refund, '$.status')",
    generatedType: 'VIRTUAL',
    comment: '退款状态',
    nullable: true,
  })
  refundStatus: number;
 
  @Index()
  @Column({
    asExpression: "JSON_EXTRACT(refund, '$.applyTime')",
    generatedType: 'VIRTUAL',
    comment: '退款申请时间',
    nullable: true,
  })
  refundApplyTime: Date;
 
  @Column({ comment: '备注', nullable: true })
  remark: string;
 
  @Column({ comment: '关闭备注', nullable: true })
  closeRemark: string;
 
  @Column({ comment: '已开票: 0-未开票 1-已开票', default: 0 })
  invoice: number;
 
  @Column({ comment: '微信类型 0-小程序 1-公众号 2-App', default: 0 })
  wxType: number;
 
  // 订单商品
  goodsList: OrderGoodsEntity[];
}