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 "{{%import_data}}". |
|
9 |
* |
|
10 |
* @property int $id |
|
11 |
* @property int $mall_id |
|
12 |
* @property int $mch_id |
|
13 |
* @property int $user_id 操作账户ID |
|
14 |
* @property int $status 导入状态|1.全部失败|2.部分失败|3.全部成功 |
|
15 |
* @property string $file_name 导入文件名 |
|
16 |
* @property int $count |
|
17 |
* @property int $success_count |
|
18 |
* @property int $error_count |
|
19 |
* @property string $created_at |
|
20 |
* @property string $updated_at |
|
21 |
* @property string $deleted_at |
|
22 |
* @property int $is_delete |
|
23 |
* @property int $type |
|
24 |
* @property User $user |
|
25 |
*/ |
|
26 |
class ImportData extends ModelActiveRecord |
|
27 |
{ |
|
28 |
/** |
|
29 |
* {@inheritdoc} |
|
30 |
*/ |
|
31 |
public static function tableName() |
|
32 |
{ |
|
33 |
return '{{%import_data}}'; |
|
34 |
} |
|
35 |
|
|
36 |
/** |
|
37 |
* {@inheritdoc} |
|
38 |
*/ |
|
39 |
public function rules() |
|
40 |
{ |
|
41 |
return [ |
|
42 |
[['mall_id', 'user_id', 'status', 'count', 'success_count', 'error_count', 'created_at', 'updated_at', 'deleted_at'], 'required'], |
|
43 |
[['mall_id', 'user_id', 'status', 'count', 'success_count', 'error_count', 'is_delete', 'mch_id', 'type'], 'integer'], |
|
44 |
[['created_at', 'updated_at', 'deleted_at'], 'safe'], |
|
45 |
[['file_name'], 'string', 'max' => 191], |
|
46 |
]; |
|
47 |
} |
|
48 |
|
|
49 |
/** |
|
50 |
* {@inheritdoc} |
|
51 |
*/ |
|
52 |
public function attributeLabels() |
|
53 |
{ |
|
54 |
return [ |
|
55 |
'id' => 'ID', |
|
56 |
'mall_id' => 'Mall ID', |
|
57 |
'mch_id' => 'Mch ID', |
|
58 |
'user_id' => '操作账户ID', |
|
59 |
'status' => '导入状态|1.全部失败|2.部分失败|3.全部成功', |
|
60 |
'file_name' => '导入文件名', |
|
61 |
'count' => 'Goods Count', |
|
62 |
'success_count' => 'Success Count', |
|
63 |
'error_count' => 'Error Count', |
|
64 |
'created_at' => 'Created At', |
|
65 |
'updated_at' => 'Updated At', |
|
66 |
'deleted_at' => 'Deleted At', |
|
67 |
'is_delete' => 'Is Delete', |
|
68 |
'type' => '1.商品导入|2.分类导入', |
|
69 |
]; |
|
70 |
} |
|
71 |
|
|
72 |
public function getUser() |
|
73 |
{ |
|
74 |
return $this->hasOne(User::className(), ['id' => 'user_id']); |
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* @param ImportData $importData |
|
79 |
* @return string $status |
|
80 |
*/ |
|
81 |
public function getStatusText($importData) |
|
82 |
{ |
|
83 |
// 导入状态|1.全部失败|2.部分失败|3.全部成功 |
|
84 |
switch ($importData->status) { |
|
85 |
case 1: |
|
86 |
$status = '导入失败'; |
|
87 |
break; |
|
88 |
case 2: |
|
89 |
$status = '导入失败'; |
|
90 |
break; |
|
91 |
case 3: |
|
92 |
$status = '导入成功'; |
|
93 |
break; |
|
94 |
default: |
|
95 |
$status = '状态未知'; |
|
96 |
break; |
|
97 |
} |
|
98 |
|
|
99 |
return $status; |
|
100 |
} |
|
101 |
} |