LogTransformer.php
1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace App\Http\Transformers;
use App\Http\Services\LogService;
class LogTransformer
{
public function transformList($list)
{
foreach ($list as &$item) {
$item = $this->transformInfo($item);
unset($item['remark']);
}
unset($item);
return $list;
}
public function transformInfo($item)
{
$item['add_time'] = date('Y-m-d H:i:s', $item['add_time']);
$item['type'] = array_get(config('fixed.LogType'), $item['type']);
$logService = new LogService();
//如果action是修改供应商,就要做对比处理
if ($item['action'] === '修改供应商基本资料') {
if ($item['content'] === '修改供应商') {
$remark = json_decode($item['remark'], true);
$oldSupplier = array_get($remark, 'old_supplier');
$newSupplier = array_get($remark, 'new_supplier');
$content = $logService->compareSupplierChange($newSupplier, $oldSupplier);
$item['content'] = $content;
}
if (!is_array($item['content'])&&strpos($item['content'], '联系') !== false) {
$item['content'] = $item['content'] .':'.$logService->getContactDesc($item['remark']);
}
$item['content'] = $item['content'] ?: '没有内容变化';
}
return $item;
}
}