commit | author | age
|
2207d6
|
1 |
<?php |
W |
2 |
/** |
|
3 |
* Created by PhpStorm. |
|
4 |
* User: 风哀伤 |
|
5 |
* Date: 2019/2/14 |
|
6 |
* Time: 15:56 |
|
7 |
* @copyright: ©2019 浙江禾匠信息科技 |
|
8 |
* @link: http://www.zjhejiang.com |
|
9 |
*/ |
|
10 |
|
|
11 |
namespace app\jobs; |
|
12 |
|
|
13 |
|
|
14 |
use app\models\CoreActionLog; |
|
15 |
use yii\base\Component; |
|
16 |
use yii\queue\JobInterface; |
|
17 |
|
|
18 |
class UserActionJob extends BaseJob implements JobInterface |
|
19 |
{ |
|
20 |
public $newBeforeUpdate; |
|
21 |
public $newAfterUpdate; |
|
22 |
public $modelName; |
|
23 |
public $modelId; |
|
24 |
public $remark; |
|
25 |
|
|
26 |
public $user_id; |
|
27 |
public $mall_id; |
|
28 |
|
|
29 |
public function execute($queue) |
|
30 |
{ |
|
31 |
try { |
|
32 |
// $this->setRequest(); |
|
33 |
$form = new CoreActionLog(); |
|
34 |
$form->mall_id = $this->mall_id; |
|
35 |
$form->user_id = $this->user_id; |
|
36 |
$form->model_id = $this->modelId; |
|
37 |
$form->model = $this->modelName; |
|
38 |
$form->before_update = \Yii::$app->serializer->encode($this->newBeforeUpdate); |
|
39 |
$form->after_update = \Yii::$app->serializer->encode($this->newAfterUpdate); |
|
40 |
$form->remark = $this->remark ?: '数据更新'; |
|
41 |
$res = $form->save(); |
|
42 |
|
|
43 |
\Yii::warning('操作日志存储成功,日志ID:' . $form->id); |
|
44 |
return $res; |
|
45 |
} catch (\Exception $e) { |
|
46 |
\Yii::error('操作日志存储失败,日志ID:' . $form->id); |
|
47 |
\Yii::error($e->getMessage()); |
|
48 |
} |
|
49 |
} |
|
50 |
} |