1 | <?php |
||
24 | class Order extends \yii\db\ActiveRecord |
||
25 | { |
||
26 | const PAYMENT_METHOD_ALIPAY = 1; |
||
27 | const PAYMENT_METHOD_WECHATPAY = 2; |
||
28 | const STATUS_DELETED = -2; //已删除 |
||
29 | const STATUS_CANCELED = -1; //已取消 |
||
30 | const STATUS_UNPAID = 0; //未支付 |
||
31 | const STATUS_PAID = 1; //已支付 |
||
32 | const STATUS_CONSUMED = 2; //已消费 |
||
33 | |||
34 | /** |
||
35 | * @inheritdoc |
||
36 | */ |
||
37 | 1 | public static function tableName() |
|
41 | |||
42 | /** |
||
43 | * @inheritdoc |
||
44 | */ |
||
45 | 1 | public function rules() |
|
54 | |||
55 | /** |
||
56 | * @inheritdoc |
||
57 | */ |
||
58 | 1 | public function attributeLabels() |
|
75 | |||
76 | /** |
||
77 | * @inheritdoc |
||
78 | */ |
||
79 | 3 | public function behaviors() |
|
87 | |||
88 | 1 | public function beforeSave($insert) |
|
89 | { |
||
90 | 1 | if ($insert) { |
|
91 | 1 | $this->sn = $this->createSN(); |
|
92 | } |
||
93 | 1 | return parent::beforeSave($insert); |
|
94 | } |
||
95 | |||
96 | /** |
||
97 | * 产生序列号 |
||
98 | * @param string $prefix 序列号前缀 |
||
99 | * @return string |
||
100 | * @link http://goo.gl/TZYwZo 参考说明 |
||
101 | */ |
||
102 | 1 | public function createSN($prefix = '') |
|
103 | { |
||
104 | 1 | return $prefix . date('Y') . strtoupper(dechex(date('m'))) . date('d') . substr(time(), -5) . substr(microtime(), 2, 5) . sprintf('%02d', rand(0, 99)); |
|
105 | } |
||
106 | |||
107 | 1 | public function getStatusList() |
|
117 | } |
||
118 |