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 "{{%full_reduce_activity}}". |
|
9 |
* |
|
10 |
* @property int $id |
|
11 |
* @property int $mall_id |
|
12 |
* @property string $name 活动标题 |
|
13 |
* @property string $content |
|
14 |
* @property int $status 状态 0下架 1上架 |
|
15 |
* @property string $created_at |
|
16 |
* @property string $updated_at |
|
17 |
* @property string $deleted_at |
|
18 |
* @property string $start_at |
|
19 |
* @property string $end_at |
|
20 |
* @property int $appoint_type 1:全部商品 |
|
21 |
2:全部自营商品 |
|
22 |
3:指定商品参加 |
|
23 |
4:指定商品不参加 |
|
24 |
* @property int $rule_type 1:阶梯满减 |
|
25 |
2:循环满减 |
|
26 |
* @property string $discount_rule 阶梯满减规则 |
|
27 |
* @property string $loop_discount_rule 循环满减规则 |
|
28 |
* @property string $appoint_goods |
|
29 |
* @property string $noappoint_goods |
|
30 |
* @property int $is_delete |
|
31 |
*/ |
|
32 |
class FullReduceActivity extends \app\models\ModelActiveRecord |
|
33 |
{ |
|
34 |
/** |
|
35 |
* {@inheritdoc} |
|
36 |
*/ |
|
37 |
public static function tableName() |
|
38 |
{ |
|
39 |
return '{{%full_reduce_activity}}'; |
|
40 |
} |
|
41 |
|
|
42 |
/** |
|
43 |
* {@inheritdoc} |
|
44 |
*/ |
|
45 |
public function rules() |
|
46 |
{ |
|
47 |
return [ |
|
48 |
[['mall_id', 'name', 'created_at', 'updated_at', 'deleted_at', 'start_at', 'end_at', 'appoint_type', 'rule_type', 'appoint_goods', 'noappoint_goods'], 'required'], |
|
49 |
[['mall_id', 'status', 'appoint_type', 'rule_type', 'is_delete'], 'integer'], |
|
50 |
[['created_at', 'updated_at', 'deleted_at', 'start_at', 'end_at'], 'safe'], |
|
51 |
[['appoint_goods', 'noappoint_goods'], 'string'], |
|
52 |
[['name'], 'string', 'max' => 255], |
|
53 |
[['content'], 'string', 'max' => 8192], |
|
54 |
[['discount_rule'], 'string', 'max' => 512], |
|
55 |
[['loop_discount_rule'], 'string', 'max' => 128], |
|
56 |
]; |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 |
* {@inheritdoc} |
|
61 |
*/ |
|
62 |
public function attributeLabels() |
|
63 |
{ |
|
64 |
return [ |
|
65 |
'id' => 'ID', |
|
66 |
'mall_id' => 'Mall ID', |
|
67 |
'name' => 'Name', |
|
68 |
'content' => 'Content', |
|
69 |
'status' => 'Status', |
|
70 |
'created_at' => 'Created At', |
|
71 |
'updated_at' => 'Updated At', |
|
72 |
'deleted_at' => 'Deleted At', |
|
73 |
'start_at' => 'Start At', |
|
74 |
'end_at' => 'End At', |
|
75 |
'appoint_type' => 'Appoint Type', |
|
76 |
'rule_type' => 'Rule Type', |
|
77 |
'discount_rule' => 'Discount Rule', |
|
78 |
'loop_discount_rule' => 'Loop Discount Rule', |
|
79 |
'appoint_goods' => 'Appoint Goods', |
|
80 |
'noappoint_goods' => 'Noappoint Goods', |
|
81 |
'is_delete' => 'Is Delete', |
|
82 |
]; |
|
83 |
} |
|
84 |
|
|
85 |
/** |
|
86 |
* 获取当前正在进行中的活动 |
|
87 |
* @param string $select |
|
88 |
* @return array|\yii\db\ActiveRecord|null |
|
89 |
*/ |
|
90 |
public static function getNowActivity($select = '*') |
|
91 |
{ |
|
92 |
return self::find()->where([ |
|
93 |
'mall_id' => \Yii::$app->mall->id, |
|
94 |
'is_delete' => 0, |
|
95 |
'status' => 1 |
|
96 |
])->select($select) |
|
97 |
->andWhere(['<=', 'start_at', date('y-m-d H:i:s')]) |
|
98 |
->andWhere(['>=', 'end_at', date('y-m-d H:i:s')]) |
|
99 |
->limit(1) |
|
100 |
->one(); |
|
101 |
} |
|
102 |
} |