commit | author | age
|
90c639
|
1 |
<?php |
Z |
2 |
|
|
3 |
namespace app\models; |
|
4 |
|
|
5 |
use Yii; |
|
6 |
|
|
7 |
/** |
|
8 |
* This is the model class for table "{{%user_coupon}}". |
|
9 |
* |
|
10 |
* @property int $id |
|
11 |
* @property int $mall_id |
|
12 |
* @property int $user_id 用户 |
|
13 |
* @property int $coupon_id 优惠券 |
|
14 |
* @property string $sub_price 满减 |
|
15 |
* @property string $discount 折扣 |
|
16 |
* @property string $discount_limit 折扣优惠上限 |
|
17 |
* @property string $coupon_min_price 最低消费金额 |
|
18 |
* @property int $type 优惠券类型:1=折扣,2=满减 |
|
19 |
* @property string $start_time 有效期开始时间 |
|
20 |
* @property string $end_time 有效期结束时间 |
|
21 |
* @property int $is_use 是否已使用:0=未使用,1=已使用 |
|
22 |
* @property int $is_delete 删除 |
|
23 |
* @property string $created_at |
|
24 |
* @property string $updated_at |
|
25 |
* @property string $deleted_at |
|
26 |
* @property string $receive_type 获取方式 |
|
27 |
* @property string $coupon_data 优惠券信息json格式 |
|
28 |
* @property Coupon $coupon |
|
29 |
*/ |
|
30 |
class UserCoupon extends ModelActiveRecord |
|
31 |
{ |
|
32 |
/** |
|
33 |
* {@inheritdoc} |
|
34 |
*/ |
|
35 |
public static function tableName() |
|
36 |
{ |
|
37 |
return '{{%user_coupon}}'; |
|
38 |
} |
|
39 |
|
|
40 |
/** |
|
41 |
* {@inheritdoc} |
|
42 |
*/ |
|
43 |
public function rules() |
|
44 |
{ |
|
45 |
return [ |
|
46 |
[['mall_id', 'user_id', 'coupon_id', 'coupon_min_price', 'created_at', 'updated_at', 'deleted_at', 'coupon_data'], 'required'], |
|
47 |
[['mall_id', 'user_id', 'coupon_id', 'type', 'is_use', 'is_delete'], 'integer'], |
|
48 |
[['sub_price', 'discount', 'coupon_min_price', 'discount_limit'], 'number'], |
|
49 |
[['start_time', 'end_time', 'created_at', 'updated_at', 'deleted_at'], 'safe'], |
|
50 |
[['coupon_data'], 'string'], |
|
51 |
[['receive_type'], 'string', 'max' => 255], |
|
52 |
]; |
|
53 |
} |
|
54 |
|
|
55 |
/** |
|
56 |
* {@inheritdoc} |
|
57 |
*/ |
|
58 |
public function attributeLabels() |
|
59 |
{ |
|
60 |
return [ |
|
61 |
'id' => 'ID', |
|
62 |
'mall_id' => 'Mall ID', |
|
63 |
'user_id' => '用户', |
|
64 |
'coupon_id' => '优惠券', |
|
65 |
'sub_price' => '满减', |
|
66 |
'discount' => '折扣', |
|
67 |
'discount_limit' => '折扣优惠上限', |
|
68 |
'coupon_min_price' => '最低消费金额', |
|
69 |
'type' => '优惠券类型:1=折扣,2=满减', |
|
70 |
'start_time' => '有效期开始时间', |
|
71 |
'end_time' => '有效期结束时间', |
|
72 |
'is_use' => '是否已使用:0=未使用,1=已使用', |
|
73 |
'is_delete' => '删除', |
|
74 |
'created_at' => 'Created At', |
|
75 |
'updated_at' => 'Updated At', |
|
76 |
'deleted_at' => 'Deleted At', |
|
77 |
'receive_type' => '获取方式', |
|
78 |
'coupon_data' => '优惠券信息json格式', |
|
79 |
]; |
|
80 |
} |
|
81 |
|
|
82 |
public function getAuto() |
|
83 |
{ |
|
84 |
return $this->hasOne(UserCouponAuto::className(), ['user_coupon_id' => 'id']); |
|
85 |
} |
|
86 |
|
|
87 |
public function getCoupon() |
|
88 |
{ |
|
89 |
return $this->hasOne(Coupon::className(), ['id' => 'coupon_id']); |
|
90 |
} |
|
91 |
|
|
92 |
public function getUser() |
|
93 |
{ |
|
94 |
return $this->hasOne(User::className(), ['id' => 'user_id']); |
|
95 |
} |
|
96 |
} |