Commit c058592b by mushishixian

日志

parent 0719929c
......@@ -11,6 +11,7 @@ use App\Http\Services\SupplierService;
use App\Http\Services\SyncSupplierService;
use App\Http\Transformers\SupplierTransformer;
use App\Http\Validators\SupplierValidator;
use App\Model\LogModel;
use App\Model\RedisModel;
use App\Model\SupplierChannelModel;
use Illuminate\Http\Request;
......@@ -137,6 +138,9 @@ class SupplierApiController extends Controller
'status' => $model::STATUS_IN_REVIEW,
]);
if ($result) {
//写日志
$logService = new LogService();
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '禁用', '禁用供应商');
//发送队列消息同步到金蝶
$service = new SyncSupplierService();
$service->syncSupplierToErp($supplierId);
......@@ -186,7 +190,7 @@ class SupplierApiController extends Controller
//保存日志
$logService = new LogService();
$action = array_get(config('fixed.SupplierStatus'), $status);
$logService->AddLog($supplierId, 1, $action, $action . '-' . $supplier['supplier_name']);
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, $action, $action . '-' . $supplier['supplier_name']);
if (!$result) {
$this->response(-1, '修改状态失败');
}
......
......@@ -39,6 +39,9 @@ class SupplierLogApiController extends Controller
if (empty($data['type']) || empty($data['desc'])) {
$this->response(-1, '类型或者描述都不能为空');
}
if (strlen($data['desc']) > 500) {
$this->response(-1, '描述不能超过500个字');
}
$data['admin_id'] = $request->user->userId;
$data['admin_name'] = $request->user->name;
$data['add_time'] = time();
......
......@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Http\Services\LogService;
use App\Http\Services\RoleService;
use App\Http\Services\SupplierContactService;
use App\Http\Services\SupplierService;
......@@ -70,10 +71,18 @@ class SupplierController extends Controller
$supplierId = $request->get('supplier_id');
$supplierService = new SupplierService();
$supplier = $supplierService->getSupplier($supplierId);
// dd($supplier);
if (empty($supplier)) {
return '供应商不存在';
}
//记录查看日志(1个小时内查看的跳过)
$logModel = new LogModel();
$lastViewAddTime = $logModel->where('supplier_id', $supplierId)->where('admin_id', $request->user->userId)
->where('type', LogModel::VIEW_OPERATE)->value('add_time');
$oneHourTimestamp = 3600;
if (time() - $lastViewAddTime > $oneHourTimestamp) {
$logService = new LogService();
$logService->AddLog($supplierId, LogModel::VIEW_OPERATE, '查看', '查看供应商详情');
}
$this->data['operate'] = 'detail';
$this->data['supplier'] = $supplier;
$this->data['address'] = $supplierService->getAddress($supplierId);
......@@ -168,8 +177,8 @@ class SupplierController extends Controller
$intracodeModel = new IntracodeModel();
$this->data['userCodes'] = $intracodeModel->getSampleEncode();
$logModel = new LogModel();
$this->data['logs'] = $logModel->where('supplier_id',$supplierId)
->where('action','allocate_purchase_user')->orderBy('id','desc')
$this->data['logs'] = $logModel->where('supplier_id', $supplierId)
->where('action', 'allocate_purchase_user')->orderBy('id', 'desc')
->limit(10)->get();
return $this->view('审核供应商');
}
......
......@@ -4,6 +4,7 @@
namespace App\Http\Services;
use App\Model\LogModel;
use App\Model\SupplierAddressModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
......@@ -47,7 +48,7 @@ class SupplierAddressService
$result = $addressModel->insert($returnData);
}
$logService = new LogService();
$logService->AddLog($map['supplier_id'], 2, '保存地址信息', ' ');
$logService->AddLog($map['supplier_id'], LogModel::UPDATE_OPERATE, '保存地址信息', ' ');
return $result;
}
}
\ No newline at end of file
......@@ -4,11 +4,11 @@
namespace App\Http\Services;
use App\Http\Transformers\SupplierTransformer;
use App\Model\LogModel;
use App\Model\SupplierAddressModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
use Illuminate\Support\Facades\DB;
use RedisDB;
class SupplierAuditService
{
......@@ -20,6 +20,13 @@ class SupplierAuditService
'status' => $status,
'reject_reason' => $rejectReason,
]);
if ($result) {
//记录日志
$auditStatus = $status == 2 ? '审核通过' : '审核不通过,原因是 : ' . $rejectReason;
$logService = new LogService();
$content = $auditStatus;
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '审核供应商', $content);
}
return $result;
}
......
......@@ -212,14 +212,12 @@ class SupplierService
'update_time' => time(),
'purchase_uid' => $purchaseUid,
]);
$toFollowUp = false;
if ($result) {
//重新分配渠道开发并且开发人员有变更的时候,就去检查是否需要跟进
if ($supplier['purchase_uid'] != $purchaseUid) {
$auditService = new SupplierAuditService();
//还要判断是否为待跟进供应商
if (!$auditService->checkIsNeedToFollowUpSupplier($supplierId)) {
$toFollowUp = true;
$model->where('supplier_id', $supplierId)->update([
'to_follow_up' => 1,
]);
......@@ -233,9 +231,8 @@ class SupplierService
$purchaseUser = $adminUserService->getAdminUserInfoByCodeId($purchaseUid);
$purchaseUserName = array_get($purchaseUser, 'name', '');
$logService = new LogService();
$name = request()->user->name;
$content = "将渠道开发员由 [${prePurchaseUserName}] 改为 [${purchaseUserName}]";
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, 'allocate_purchase_user',$content);
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '分配渠道开发员',$content);
}
return $result;
......
......@@ -5,7 +5,8 @@ return [
'NotAuth' => [
'ChoiceSupplierList',
'HoldItems',
'ObtainSkuList'
'ObtainSkuList',
'SupplierLog'
],
//api不用授权方法
'ApiNotAuth' => [
......
......@@ -27,11 +27,15 @@
</div>
<div class="layui-col-md8"></div>
</div>
<div class="layui-row">
<a id="updateSupplierUrl"
href="/supplier/UpdateSupplier?view=iframe&supplier_id={{$supplier['supplier_id']}}"
style="margin-bottom: 25px;margin-top: 5px" class="layui-btn layui-btn">点击修改</a>
</div>
@if($supplier['status']==\App\Model\SupplierChannelModel::STATUS_PENDING
||$supplier['status']==\App\Model\SupplierChannelModel::STATUS_PASSED
||$supplier['status']==\App\Model\SupplierChannelModel::STATUS_REJECT)
<div class="layui-row">
<a id="updateSupplierUrl"
href="/supplier/UpdateSupplier?view=iframe&supplier_id={{$supplier['supplier_id']}}"
style="margin-bottom: 25px;margin-top: 5px" class="layui-btn layui-btn">点击修改</a>
</div>
@endif
</div>
<div class="layui-card-body">
<div class="layui-tab">
......
......@@ -2,63 +2,80 @@
<div class="layui-card-body">
<div class="layui-tab">
<ul class="layui-tab-title">
<li style="padding: 0" class="layui-this" id="base_info">全部</li>
<li style="padding: 0" id="contact">修改记录</li>
<li style="padding: 0" id="ruler">查看记录</li>
<li style="padding: 0" id="ruler">信息记录</li>
@if(checkPerm('ViewAllLog'))
<li style="padding: 0" class="layui-this" id="base_info">全部</li>
@endif
@if(checkPerm('ViewUpdateLog'))
<li style="padding: 0" id="contact">修改记录</li>
@endif
@if(checkPerm('ViewLog'))
<li style="padding: 0" id="ruler">查看记录</li>
@endif
@if(checkPerm('ViewSupplierLog'))
<li style="padding: 0" id="ruler">信息记录</li>
@endif
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
<form class="layui-form" action="">
<div class="layui-form-item" style="margin-left: -70px;margin-bottom: 0">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('type','类型',
'',config('fixed.SupplierLogType'),['required'=>false]) !!}
@if(checkPerm('ViewAllLog'))
@if(checkPerm('AddSupplierLog'))
<form class="layui-form" action="">
<div class="layui-form-item" style="margin-left: -70px;margin-bottom: 0">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('type','类型',
'',config('fixed.SupplierLogType'),['required'=>false]) !!}
</div>
<div class="layui-form-item layui-form-text" style="margin-left: -70px">
<div class="layui-input-block">
<textarea name="desc" placeholder="请输入具体的信息内容"
class="layui-textarea"></textarea>
</div>
</div>
<div class="layui-form-item">
<div align="left" style="margin-top: 20px;margin-left: 40px">
<button type="button" class="layui-btn layui-btn-info layui-btn-sm" lay-submit
lay-filter="addSupplierLog">添加信息记录
</button>
</div>
</div>
</form>
@endif
<div id="logs" style="margin-left: 5px">
{{--所有操作记录列表查看--}}
@foreach($logs as $log)
<p>{{$log['action']}} : {{$log['content']}}</p>
<p style="color: grey">{{date('Y-m-d H:i:s',$log['add_time']).' '.$log['admin_name']}}</p>
<hr/>
@endforeach
</div>
<div class="layui-form-item layui-form-text" style="margin-left: -70px">
<div class="layui-input-block">
<textarea name="desc" placeholder="请输入具体的信息内容" class="layui-textarea"></textarea>
</div>
</div>
<div class="layui-form-item">
<div align="left" style="margin-top: 20px;margin-left: 40px">
<button type="button" class="layui-btn layui-btn-info layui-btn-sm" lay-submit
lay-filter="addSupplierLog">添加信息记录
</button>
</div>
</div>
</form>
<div id="logs" style="margin-left: 5px">
{{--所有操作记录列表查看--}}
@foreach($logs as $log)
<p>{{$log['action']}} : {{$log['content']}}</p>
@endif
</div>
<div class="layui-tab-item">
@if(checkPerm('ViewAllLog'))
@foreach($updateLogs as $log)
<p>{{$log['content']}}</p>
<p style="color: grey">{{date('Y-m-d H:i:s',$log['add_time']).' '.$log['admin_name']}}</p>
<hr/>
@endforeach
</div>
</div>
<div class="layui-tab-item">
@foreach($updateLogs as $log)
<p>{{$log['content']}}</p>
<p style="color: grey">{{date('Y-m-d H:i:s',$log['add_time']).' '.$log['admin_name']}}</p>
<hr/>
@endforeach
@endif
</div>
<div class="layui-tab-item">
@if(checkPerm('ViewAllLog'))
@foreach($viewLogs as $log)
<p>{{$log['content']}}</p>
<p style="color: grey">{{date('Y-m-d H:i:s',$log['add_time']).' '.$log['admin_name']}}</p>
<hr/>
@endforeach
@endif
</div>
<div class="layui-tab-item">
@if(checkPerm('ViewAllLog'))
@foreach($supplierLogs as $log)
<p>{{$log['desc']}}</p>
<p style="color: grey">{{date('Y-m-d H:i:s',$log['add_time']).' '.$log['admin_name']}}</p>
<hr/>
@endforeach
@endif
</div>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment