Commit aef138ec by mushishixian

日志

parent c058592b
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Api; namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Services\LogService;
use App\Http\Services\SupplierContactService; use App\Http\Services\SupplierContactService;
use App\Http\Transformers\SupplierContactTransformer; use App\Http\Transformers\SupplierContactTransformer;
use App\Http\Validators\SupplierContactValidator; use App\Http\Validators\SupplierContactValidator;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Api; namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Services\LogService;
use App\Http\Transformers\LogTransformer; use App\Http\Transformers\LogTransformer;
use App\Http\Transformers\ReceiptTransformer; use App\Http\Transformers\ReceiptTransformer;
use App\Http\Validators\ReceiptValidator; use App\Http\Validators\ReceiptValidator;
...@@ -24,12 +25,12 @@ class SupplierReceiptApiController extends Controller ...@@ -24,12 +25,12 @@ class SupplierReceiptApiController extends Controller
$supplierId = $request->get('supplier_id'); $supplierId = $request->get('supplier_id');
$limit = $request->get('limit', 10); $limit = $request->get('limit', 10);
$model = new SupplierReceiptModel(); $model = new SupplierReceiptModel();
$model->where('supplier_id',$supplierId)->paginate(); $model->where('supplier_id', $supplierId)->paginate();
$list = $model->where('supplier_id', $supplierId)->orderBy('receipt_id', 'desc') $list = $model->where('supplier_id', $supplierId)->orderBy('receipt_id', 'desc')
->paginate($limit)->toArray(); ->paginate($limit)->toArray();
$transformer = new ReceiptTransformer(); $transformer = new ReceiptTransformer();
$list['data'] = $transformer->transformList($list['data']); $list['data'] = $transformer->transformList($list['data']);
$this->response(0, 'ok', $list['data'],$list['total']); $this->response(0, 'ok', $list['data'], $list['total']);
} }
//获取供应商信息变更记录 //获取供应商信息变更记录
...@@ -65,6 +66,10 @@ class SupplierReceiptApiController extends Controller ...@@ -65,6 +66,10 @@ class SupplierReceiptApiController extends Controller
$result = $model->insert($receipt); $result = $model->insert($receipt);
} }
if ($result) { if ($result) {
$logService = new LogService();
$content = !empty($receipt['receipt_id']) ? '修改银行信息' : '添加银行信息';
$remark = json_encode($receipt);
$logService->AddLog($receipt['supplier_id'], LogModel::UPDATE_OPERATE, '修改供应商基本资料', $content, $remark);
$this->response(0, '操作成功'); $this->response(0, '操作成功');
} }
$this->response(-1, '操作失败'); $this->response(-1, '操作失败');
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
namespace App\Http\Services; namespace App\Http\Services;
use App\Model\LogModel;
use App\Model\SupplierContactModel; use App\Model\SupplierContactModel;
class SupplierContactService class SupplierContactService
...@@ -43,11 +44,16 @@ class SupplierContactService ...@@ -43,11 +44,16 @@ class SupplierContactService
//判断新增还是编辑 //判断新增还是编辑
if (!empty($contact['contact_id'])) { if (!empty($contact['contact_id'])) {
$contact['update_time'] = time(); $contact['update_time'] = time();
return $model->where('contact_id', $contact['contact_id'])->update($contact); $result = $model->where('contact_id', $contact['contact_id'])->update($contact);
} else { } else {
$contact['add_time'] = time(); $contact['add_time'] = time();
return $model->insert($contact); $result = $model->insert($contact);
} }
$logService = new LogService();
$content = !empty($contact['contact_id'])?'修改联系人':'添加联系人';
$remark = json_encode($contact);
$logService->AddLog($contact['supplier_id'], LogModel::UPDATE_OPERATE, '修改供应商基本资料', $content, $remark);
return $result;
} }
//批量保存联系方式,要区分新增还是修改还是删除 //批量保存联系方式,要区分新增还是修改还是删除
...@@ -57,8 +63,8 @@ class SupplierContactService ...@@ -57,8 +63,8 @@ class SupplierContactService
$model = new SupplierContactModel(); $model = new SupplierContactModel();
$originContactIds = $model->where('supplier_id', $supplierId)->pluck('contact_id')->toArray(); $originContactIds = $model->where('supplier_id', $supplierId)->pluck('contact_id')->toArray();
$newContactIds = array_column($contacts, 'contact_id'); $newContactIds = array_column($contacts, 'contact_id');
$needDeleteContactIds = array_diff_assoc($originContactIds,$newContactIds); $needDeleteContactIds = array_diff_assoc($originContactIds, $newContactIds);
$model->whereIn('contact_id',$needDeleteContactIds)->delete(); $model->whereIn('contact_id', $needDeleteContactIds)->delete();
foreach ($contacts as $key => $contact) { foreach ($contacts as $key => $contact) {
//新增 //新增
if (empty($contact['contact_id'])) { if (empty($contact['contact_id'])) {
......
...@@ -92,17 +92,22 @@ class SupplierService ...@@ -92,17 +92,22 @@ class SupplierService
$this->saveSupplierCode($supplierId); $this->saveSupplierCode($supplierId);
$logAction = "新增供应商"; $logAction = "新增供应商";
$logContent = '新增供应商'; $logContent = '新增供应商';
$logRemark = ''; $newSupplier = $model->where('supplier_id', $supplierId)->first();
$logRemark = json_encode($newSupplier);
} else { } else {
$extraFaxService = new SupplierExtraFeeService(); $extraFaxService = new SupplierExtraFeeService();
$extraFaxService->saveSupplierExtraFee($extraFax); $extraFaxService->saveSupplierExtraFee($extraFax);
$supplierId = $channel['supplier_id']; $supplierId = $channel['supplier_id'];
$supplierData = $model->where('supplier_id', $supplierId)->first(); $oldSupplier = $model->where('supplier_id', $supplierId)->first();
$model->where('supplier_id', $supplierId)->update($channel); $model->where('supplier_id', $supplierId)->update($channel);
$newSupplier = $model->where('supplier_id', $supplierId)->first();
$this->saveSupplierCode($supplierId); $this->saveSupplierCode($supplierId);
$logAction = "更新供应商"; $logAction = "更新供应商";
$logContent = "更新供应商"; $logContent = "更新供应商";
$logRemark = json_encode($supplierData); $logRemark = json_encode([
'old' => $oldSupplier,
'new' => $newSupplier
]);
} }
//插入系数到redis //插入系数到redis
$this->saveRatioToRedis($supplierId); $this->saveRatioToRedis($supplierId);
...@@ -110,7 +115,8 @@ class SupplierService ...@@ -110,7 +115,8 @@ class SupplierService
$supplierSn = $this->generateSupplierSn($supplierId, $channel['supplier_group']); $supplierSn = $this->generateSupplierSn($supplierId, $channel['supplier_group']);
//保存日志 //保存日志
$logService = new LogService(); $logService = new LogService();
$logService->AddLog($supplierId, 1, $logAction, $logContent, $logRemark); $logType = !empty($channel['supplier_id']) ? LogModel::UPDATE_OPERATE : LogModel::ADD_OPERATE;
$logService->AddLog($supplierId, $logType, $logAction, $logContent, $logRemark);
//修改数据 //修改数据
$model->where('supplier_id', $supplierId)->update(['supplier_sn' => $supplierSn]); $model->where('supplier_id', $supplierId)->update(['supplier_sn' => $supplierSn]);
// $messageService = new MessageService(); // $messageService = new MessageService();
...@@ -232,7 +238,7 @@ class SupplierService ...@@ -232,7 +238,7 @@ class SupplierService
$purchaseUserName = array_get($purchaseUser, 'name', ''); $purchaseUserName = array_get($purchaseUser, 'name', '');
$logService = new LogService(); $logService = new LogService();
$content = "将渠道开发员由 [${prePurchaseUserName}] 改为 [${purchaseUserName}]"; $content = "将渠道开发员由 [${prePurchaseUserName}] 改为 [${purchaseUserName}]";
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '分配渠道开发员',$content); $logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '分配渠道开发员', $content);
} }
return $result; return $result;
......
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