commit | author | age
|
2207d6
|
1 |
<?php |
W |
2 |
|
|
3 |
namespace app\models; |
|
4 |
|
|
5 |
use Yii; |
|
6 |
|
|
7 |
/** |
|
8 |
* This is the model class for table "{{%free_delivery_rules}}". |
|
9 |
* |
|
10 |
* @property int $id |
|
11 |
* @property int $mall_id |
|
12 |
* @property int $mch_id |
|
13 |
* @property string $name |
|
14 |
* @property int $type 1:订单满额包邮 2:订单满件包邮 3:单商品满额包邮 4:单商品满件包邮 |
|
15 |
* @property string $price |
|
16 |
* @property string $detail |
|
17 |
* @property int $status 是否默认 0否 1是 |
|
18 |
* @property int $is_delete |
|
19 |
* @property string $created_at |
|
20 |
* @property string $updated_at |
|
21 |
* @property string $deleted_at |
|
22 |
*/ |
|
23 |
class FreeDeliveryRules extends ModelActiveRecord |
|
24 |
{ |
|
25 |
/** |
|
26 |
* {@inheritdoc} |
|
27 |
*/ |
|
28 |
public static function tableName() |
|
29 |
{ |
|
30 |
return '{{%free_delivery_rules}}'; |
|
31 |
} |
|
32 |
|
|
33 |
/** |
|
34 |
* {@inheritdoc} |
|
35 |
*/ |
|
36 |
public function rules() |
|
37 |
{ |
|
38 |
return [ |
|
39 |
[['mall_id', 'detail', 'created_at', 'updated_at', 'deleted_at'], 'required'], |
|
40 |
[['mall_id', 'is_delete', 'type', 'status', 'mch_id'], 'integer'], |
|
41 |
[['price'], 'number'], |
|
42 |
[['detail', 'name'], 'string'], |
|
43 |
[['created_at', 'updated_at', 'deleted_at'], 'safe'], |
|
44 |
]; |
|
45 |
} |
|
46 |
|
|
47 |
/** |
|
48 |
* {@inheritdoc} |
|
49 |
*/ |
|
50 |
public function attributeLabels() |
|
51 |
{ |
|
52 |
return [ |
|
53 |
'id' => 'ID', |
|
54 |
'mall_id' => 'Mall ID', |
|
55 |
'mch_id' => 'Mch ID', |
|
56 |
'name' => '包邮规则名称', |
|
57 |
'type' => 'Type', |
|
58 |
'price' => '包邮金额', |
|
59 |
'status' => '是否默认', |
|
60 |
'detail' => 'Detail', |
|
61 |
'is_delete' => 'Is Delete', |
|
62 |
'created_at' => 'Created At', |
|
63 |
'updated_at' => 'Updated At', |
|
64 |
'deleted_at' => 'Deleted At', |
|
65 |
]; |
|
66 |
} |
|
67 |
|
|
68 |
public function decodeDetail() |
|
69 |
{ |
|
70 |
$detail = Yii::$app->serializer->decode($this->detail); |
|
71 |
if (!isset($detail[0]['condition'])) { |
|
72 |
$newItem['condition'] = $this->price; |
|
73 |
$newItem['list'] = $detail; |
|
74 |
$detail = [$newItem]; |
|
75 |
} |
|
76 |
return $detail; |
|
77 |
} |
|
78 |
|
|
79 |
public function getTypeText() |
|
80 |
{ |
|
81 |
switch ($this->type) { |
|
82 |
case 1: |
|
83 |
return '订单满额包邮'; |
|
84 |
case 2: |
|
85 |
return '订单满件包邮'; |
|
86 |
case 3: |
|
87 |
return '单商品满额包邮'; |
|
88 |
case 4: |
|
89 |
return '单商品满件包邮'; |
|
90 |
default: |
|
91 |
return ''; |
|
92 |
} |
|
93 |
} |
|
94 |
} |