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 "{{%postage_rules}}". |
|
9 |
* |
|
10 |
* @property int $id |
|
11 |
* @property int $mall_id |
|
12 |
* @property int $mch_id |
|
13 |
* @property string $name |
|
14 |
* @property string $detail 规则详情 |
|
15 |
* @property int $status 是否默认 |
|
16 |
* @property int $type 计费方式【1=>按重计费、2=>按件计费】 |
|
17 |
* @property string $created_at |
|
18 |
* @property string $updated_at |
|
19 |
* @property string $deleted_at |
|
20 |
* @property int $is_delete |
|
21 |
*/ |
|
22 |
class PostageRules extends ModelActiveRecord |
|
23 |
{ |
|
24 |
/** |
|
25 |
* {@inheritdoc} |
|
26 |
*/ |
|
27 |
public static function tableName() |
|
28 |
{ |
|
29 |
return '{{%postage_rules}}'; |
|
30 |
} |
|
31 |
|
|
32 |
/** |
|
33 |
* {@inheritdoc} |
|
34 |
*/ |
|
35 |
public function rules() |
|
36 |
{ |
|
37 |
return [ |
|
38 |
[['mall_id', 'detail', 'created_at', 'updated_at', 'deleted_at'], 'required'], |
|
39 |
[['mall_id', 'status', 'type', 'is_delete', 'mch_id'], 'integer'], |
|
40 |
[['detail'], 'string'], |
|
41 |
[['created_at', 'updated_at', 'deleted_at'], 'safe'], |
|
42 |
[['name'], 'string', 'max' => 65], |
|
43 |
]; |
|
44 |
} |
|
45 |
|
|
46 |
/** |
|
47 |
* {@inheritdoc} |
|
48 |
*/ |
|
49 |
public function attributeLabels() |
|
50 |
{ |
|
51 |
return [ |
|
52 |
'id' => 'ID', |
|
53 |
'mall_id' => 'Mall ID', |
|
54 |
'mch_id' => 'Mch ID', |
|
55 |
'name' => 'Name', |
|
56 |
'detail' => 'Detail', |
|
57 |
'status' => 'Status', |
|
58 |
'type' => 'Type', |
|
59 |
'created_at' => 'Created At', |
|
60 |
'updated_at' => 'Updated At', |
|
61 |
'deleted_at' => 'Deleted At', |
|
62 |
'is_delete' => 'Is Delete', |
|
63 |
]; |
|
64 |
} |
|
65 |
|
|
66 |
public function decodeDetail() |
|
67 |
{ |
|
68 |
$detail = Yii::$app->serializer->decode($this->detail); |
|
69 |
foreach ($detail as &$item) { |
|
70 |
foreach ($item as &$value) { |
|
71 |
if (is_numeric($value)) { |
|
72 |
$value = floatval($value); |
|
73 |
} |
|
74 |
} |
|
75 |
unset($value); |
|
76 |
} |
|
77 |
unset($item); |
|
78 |
return $detail; |
|
79 |
} |
|
80 |
} |