Commit 7880b1f3 by mushishixian

暂时

parent 66bb8d31
...@@ -145,9 +145,9 @@ class SupplierApiController extends Controller ...@@ -145,9 +145,9 @@ class SupplierApiController extends Controller
//发送队列消息同步到金蝶 //发送队列消息同步到金蝶
$service = new SyncSupplierService(); $service = new SyncSupplierService();
$service->syncSupplierToErp($supplierId); $service->syncSupplierToErp($supplierId);
$this->response(0, '禁用成功'); $this->response(0, '操作成功,进入审核状态');
} else { } else {
$this->response(-1, '禁用失败'); $this->response(-1, '操作失败,进入审核状态');
} }
} }
......
...@@ -19,15 +19,21 @@ class SupplierContactApiController extends Controller ...@@ -19,15 +19,21 @@ class SupplierContactApiController extends Controller
$this->$id($request, $id); $this->$id($request, $id);
} }
//获取供应商收款信息 //获取供应商联系人
public function GetSupplierContactList($request) public function GetSupplierContactList($request)
{ {
$supplierId = $request->get('supplier_id'); $supplierId = $request->get('supplier_id');
$limit = $request->get('limit', 10); $limit = $request->get('limit', 10);
$canViewAllSupplierContact = checkPerm('ViewAllSupplierContact');
$model = new SupplierContactModel(); $model = new SupplierContactModel();
$model->where('supplier_id', $supplierId)->paginate(); $query = $model->where('supplier_id', $supplierId)->orderBy('contact_id', 'desc');
$list = $model->where('supplier_id', $supplierId)->orderBy('contact_id', 'desc') //不能查看所有的,就是说只能看绑定的采购的
->paginate($limit)->toArray(); if (!$canViewAllSupplierContact) {
$adminId = $request->user->userId;
$codeId = $request->user->codeId;
$query->whereRaw("(can_check_uids = $codeId or admin_id = $adminId)");
}
$list = $query->paginate($limit)->toArray();
$transformer = new SupplierContactTransformer(); $transformer = new SupplierContactTransformer();
$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']);
...@@ -97,12 +103,11 @@ class SupplierContactApiController extends Controller ...@@ -97,12 +103,11 @@ class SupplierContactApiController extends Controller
$this->response(-1, '删除失败'); $this->response(-1, '删除失败');
} }
//修改为审核状态 //修改为审核状态
//$supplierModel->where('supplier_id', $supplierId)->update([ $supplierModel = new SupplierChannelModel();
// 'update_time' => time(), $supplierModel->where('supplier_id', $contact['supplier_id'])->update([
// 'status' => 1, 'update_time' => time(),
//]); 'status' => 1,
]);
$this->response(0, '删除成功'); $this->response(0, '删除成功');
} }
$this->response(-1, '找不到删除对象'); $this->response(-1, '找不到删除对象');
......
...@@ -153,7 +153,7 @@ class SupplierFilter ...@@ -153,7 +153,7 @@ class SupplierFilter
$adminUserService = new AdminUserService(); $adminUserService = new AdminUserService();
$resignedUsers = $adminUserService->getResignedUsers(); $resignedUsers = $adminUserService->getResignedUsers();
$resignedUserCodes = array_column($resignedUsers, 'code_id'); $resignedUserCodes = array_column($resignedUsers, 'code_id');
//因为可以查看自己部下相关的采购员,开发员的供应商,所以要构建复杂likeIn语句需要的数据 //因为可以查看相关的采购员的供应商,所以要构建复杂likeIn语句需要的数据
//注意下面三个条件最外层要用()包围起来,要不然mysql数据会有问题,具体自己查询mysql的and和or的语法注意事项 //注意下面三个条件最外层要用()包围起来,要不然mysql数据会有问题,具体自己查询mysql的and和or的语法注意事项
$likeSqlRaw = implode('|', $resignedUserCodes); $likeSqlRaw = implode('|', $resignedUserCodes);
$query->whereRaw(DB::raw("(channel_uid REGEXP '$likeSqlRaw')")); $query->whereRaw(DB::raw("(channel_uid REGEXP '$likeSqlRaw')"));
......
...@@ -13,7 +13,7 @@ class SupplierLogFilter ...@@ -13,7 +13,7 @@ class SupplierLogFilter
public function listFilter($query) public function listFilter($query)
{ {
$map = request()->all(); $map = request()->all();
$query = $query->orderBy('id', 'desc'); $query = $query->orderBy('add_time', 'desc');
$query = $this->defaultFilter($query); $query = $this->defaultFilter($query);
return $query; return $query;
} }
......
...@@ -4,6 +4,7 @@ namespace App\Http\Controllers; ...@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\Http\Controllers\Filter\LogFilter; use App\Http\Controllers\Filter\LogFilter;
use App\Http\Controllers\Filter\SupplierLogFilter; use App\Http\Controllers\Filter\SupplierLogFilter;
use App\Http\Services\LogService;
use App\Model\ApplyExamineUserModel; use App\Model\ApplyExamineUserModel;
use App\Model\ApplyModel; use App\Model\ApplyModel;
use App\Model\DingTalk; use App\Model\DingTalk;
...@@ -43,9 +44,10 @@ class LogController extends Controller ...@@ -43,9 +44,10 @@ class LogController extends Controller
public function SupplierLog($request) public function SupplierLog($request)
{ {
$supplierId = $request->get('supplier_id', 1); $supplierId = $request->get('supplier_id', 1);
$logs = $this->getLogs($supplierId); $logService = new LogService();
$updateLogs = $this->getLogs($supplierId, LogModel::UPDATE_OPERATE); $logs = $logService->getLogs($supplierId);
$viewLogs = $this->getLogs($supplierId, LogModel::VIEW_OPERATE); $updateLogs = $logService->getLogs($supplierId, LogModel::UPDATE_OPERATE);
$viewLogs = $logService->getLogs($supplierId, LogModel::VIEW_OPERATE);
$supplierLogFilter = new SupplierLogFilter(); $supplierLogFilter = new SupplierLogFilter();
$query = $supplierLogFilter->listFilter(new SupplierLogModel()); $query = $supplierLogFilter->listFilter(new SupplierLogModel());
...@@ -63,18 +65,4 @@ class LogController extends Controller ...@@ -63,18 +65,4 @@ class LogController extends Controller
return $this->view('供应商日志'); return $this->view('供应商日志');
} }
private function getLogs($supplierId, $type = '')
{
$model = new LogModel();
$query = $model->where('id', '>', 0);
//显示默认的数据(有权限逻辑)
$filter = new LogFilter();
$query = $filter->defaultFilter($query);
if ($type) {
return $query->where('supplier_id', $supplierId)->where('type', $type)->get();
} else {
return $query->where('supplier_id', $supplierId)->get();
}
}
} }
...@@ -2,12 +2,14 @@ ...@@ -2,12 +2,14 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Http\Services\AdminUserService;
use App\Http\Services\LogService; use App\Http\Services\LogService;
use App\Http\Services\RoleService; use App\Http\Services\RoleService;
use App\Http\Services\SupplierContactService; use App\Http\Services\SupplierContactService;
use App\Http\Services\SupplierService; use App\Http\Services\SupplierService;
use App\Http\Services\SupplierStatisticsService; use App\Http\Services\SupplierStatisticsService;
use App\Http\Services\ViewCheckService; use App\Http\Services\ViewCheckService;
use App\Http\Transformers\LogTransformer;
use App\Http\Transformers\SupplierTransformer; use App\Http\Transformers\SupplierTransformer;
use App\Model\IntracodeModel; use App\Model\IntracodeModel;
use App\Model\LogModel; use App\Model\LogModel;
...@@ -77,7 +79,7 @@ class SupplierController extends Controller ...@@ -77,7 +79,7 @@ class SupplierController extends Controller
//记录查看日志(1个小时内查看的跳过) //记录查看日志(1个小时内查看的跳过)
$logModel = new LogModel(); $logModel = new LogModel();
$lastViewAddTime = $logModel->where('supplier_id', $supplierId)->where('admin_id', $request->user->userId) $lastViewAddTime = $logModel->where('supplier_id', $supplierId)->where('admin_id', $request->user->userId)
->where('type', LogModel::VIEW_OPERATE)->orderBy('id','desc')->value('add_time'); ->where('type', LogModel::VIEW_OPERATE)->orderBy('id', 'desc')->value('add_time');
$oneHourTimestamp = 3600; $oneHourTimestamp = 3600;
if (time() - $lastViewAddTime > $oneHourTimestamp) { if (time() - $lastViewAddTime > $oneHourTimestamp) {
$logService = new LogService(); $logService = new LogService();
...@@ -159,7 +161,13 @@ class SupplierController extends Controller ...@@ -159,7 +161,13 @@ class SupplierController extends Controller
$model = new SupplierChannelModel(); $model = new SupplierChannelModel();
$supplier = $model->where('supplier_id', $supplierId)->first(); $supplier = $model->where('supplier_id', $supplierId)->first();
//获取最后一条非分配渠道员的日志 //获取最后一条非分配渠道员的日志
//todo $logModel = new LogModel();
$auditContent = $logModel->where('supplier_id', $supplierId)->where('action', '!=', '分配渠道开发员')
->where('type', '!=', 3)
->orderBy('id', 'desc')->first();
$logTransformer = new LogTransformer();
$auditContent = $logTransformer->transformInfo($auditContent);
$this->data['auditContent'] = $auditContent;
$this->data['supplier'] = $supplier ? $supplier->toArray() : []; $this->data['supplier'] = $supplier ? $supplier->toArray() : [];
return $this->view('审核供应商'); return $this->view('审核供应商');
} }
...@@ -175,6 +183,8 @@ class SupplierController extends Controller ...@@ -175,6 +183,8 @@ class SupplierController extends Controller
$supplier = $transformer->transformInfo($supplier); $supplier = $transformer->transformInfo($supplier);
$this->data['supplier'] = $supplier; $this->data['supplier'] = $supplier;
$intracodeModel = new IntracodeModel(); $intracodeModel = new IntracodeModel();
$adminUserService = new AdminUserService();
$users = $adminUserService->getPurchaseUsers();
$this->data['userCodes'] = $intracodeModel->getSampleEncode(); $this->data['userCodes'] = $intracodeModel->getSampleEncode();
$logModel = new LogModel(); $logModel = new LogModel();
$this->data['logs'] = $logModel->where('supplier_id', $supplierId) $this->data['logs'] = $logModel->where('supplier_id', $supplierId)
......
...@@ -46,4 +46,13 @@ class AdminUserService ...@@ -46,4 +46,13 @@ class AdminUserService
$intracodeModel = new IntracodeModel(); $intracodeModel = new IntracodeModel();
return $intracodeModel->whereIn('admin_id', $userIds)->pluck('code_id'); return $intracodeModel->whereIn('admin_id', $userIds)->pluck('code_id');
} }
//获取渠道开发员(运营部)的所有用户信息
public function getPurchaseUsers()
{
$departmentName = '运营部';
$departmentService = new DepartmentService();
$departmentId = $departmentService->getDepartmentId($departmentName);
return $departmentService->getUserByDepartmentId($departmentId);
}
} }
\ No newline at end of file
...@@ -2,11 +2,18 @@ ...@@ -2,11 +2,18 @@
namespace App\Http\Services; namespace App\Http\Services;
use DB; use DB;
//部门数据服务 //部门数据服务
class DepartmentService class DepartmentService
{ {
public function getDepartmentId($departmentName)
{
return DB::table('user_department')->where('department_name', $departmentName)->value('department_id');
}
public function getSubordinateUserIds($adminId) public function getSubordinateUserIds($adminId)
{ {
$departmentId = DB::table('user_info')->where('userId', $adminId)->value('department_id'); $departmentId = DB::table('user_info')->where('userId', $adminId)->value('department_id');
...@@ -15,19 +22,19 @@ class DepartmentService ...@@ -15,19 +22,19 @@ class DepartmentService
} }
// 获取部门人员 // 获取部门人员
public function getUserByDepartmentId($departmentId, $status='', $filter='') public function getUserByDepartmentId($departmentId, $status = '', $filter = '')
{ {
$departmentIds = []; $departmentIds = [];
$this->getSubDepartmentId($departmentId, $departmentIds); $this->getSubDepartmentId($departmentId, $departmentIds);
return DB::table('user_info')->whereIn('department_id', $departmentIds) return DB::table('user_info')->whereIn('department_id', $departmentIds)
->where(function($query) use($status) { ->where(function ($query) use ($status) {
if ($status !== '') { if ($status !== '') {
$query->where('status', '=', $status); $query->where('status', '=', $status);
} }
}) })
->where(function($query) use($filter) { ->where(function ($query) use ($filter) {
if ($filter) { if ($filter) {
$query->whereRaw($filter); $query->whereRaw($filter);
} }
...@@ -40,7 +47,8 @@ class DepartmentService ...@@ -40,7 +47,8 @@ class DepartmentService
public function getSubDepartmentId($departmentId, &$departmentIds) public function getSubDepartmentId($departmentId, &$departmentIds)
{ {
// 获取下级部门 // 获取下级部门
$sub_department = DB::table('user_department')->where('parent_id', $departmentId)->select('department_id', 'department_name')->get(); $sub_department = DB::table('user_department')->where('parent_id', $departmentId)->select('department_id',
'department_name')->get();
if ($sub_department) { if ($sub_department) {
foreach ($sub_department as $v) { foreach ($sub_department as $v) {
$this->getSubDepartmentId($v['department_id'], $departmentIds); $this->getSubDepartmentId($v['department_id'], $departmentIds);
......
...@@ -4,7 +4,11 @@ ...@@ -4,7 +4,11 @@
namespace App\Http\Services; namespace App\Http\Services;
//后台用户相关信息服务 //后台用户相关信息服务
use App\Http\Controllers\Filter\LogFilter;
use App\Http\Transformers\LogTransformer;
use App\Http\Transformers\SupplierTransformer;
use App\Model\LogModel; use App\Model\LogModel;
use App\Model\SupplierChannelModel;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
class LogService class LogService
...@@ -14,6 +18,7 @@ class LogService ...@@ -14,6 +18,7 @@ class LogService
public $fieldMapToLogContent = [ public $fieldMapToLogContent = [
'supplier_name' => '供应商名称', 'supplier_name' => '供应商名称',
]; ];
//添加日志 //添加日志
public function AddLog($supplierId, $type, $action, $content, $remark = '') public function AddLog($supplierId, $type, $action, $content, $remark = '')
{ {
...@@ -32,4 +37,70 @@ class LogService ...@@ -32,4 +37,70 @@ class LogService
$model = new LogModel(); $model = new LogModel();
$model->insert($data); $model->insert($data);
} }
public function getLogs($supplierId, $type = '',$limit = 100)
{
$model = new LogModel();
$query = $model->where('id', '>', 0);
//显示默认的数据(有权限逻辑)
$filter = new LogFilter();
$query = $filter->defaultFilter($query);
if ($type) {
$logs = $query->where('supplier_id', $supplierId)->where('type', $type)->limit($limit)->get();
} else {
$logs = $query->where('supplier_id', $supplierId)->limit($limit)->get();
}
$transformer = new LogTransformer();
$logs = $transformer->transformList($logs);
return $logs;
}
//比对供应商修改前后的变化数据
public function compareSupplierChange($newSupplier, $oldSupplier)
{
$transformer = new SupplierTransformer();
$newSupplier = $transformer->transformInfo($newSupplier);
$oldSupplier = $transformer->transformInfo($oldSupplier);
//二维数组转成一维数组,因为array_diff只支持一维,反正二维的内容还要更细致的比较
$newSupplier = array_map(function ($value) {
if (is_array($value)) {
$value = json_encode($value);
}
return $value;
}, $newSupplier);
$oldSupplier = array_map(function ($value) {
if (is_array($value)) {
$value = json_encode($value);
}
return $value;
}, $oldSupplier);
$diff = array_diff($newSupplier, $oldSupplier);
$result = [];
foreach ($diff as $key => $item) {
$columnMap = config('validate.SupplierNeedLogColumn');
if (in_array($key, array_keys($columnMap))) {
$oldValue = array_get($oldSupplier, $key, '空');
$newValue = array_get($newSupplier, $key, '空');
$content = array_get($columnMap, $key) . '由 [ ' . $oldValue . ' ] 改成 [ ' . $newValue .' ]';
} else {
// switch ($key) {
// case 'qualification_photos':
// $newSupplier['qualification_photos'] = json_decode($newSupplier['qualification_photos'], true);
// $oldSupplier['qualification_photos'] = json_decode($oldSupplier['qualification_photos'], true);
//// dd(array_diff($newSupplier['qualification_photos'],$oldSupplier['qualification_photos']));
// case 'extra_fee':
// $newSupplier['extra_fee'] = json_decode($newSupplier['extra_fee'], true);
// $oldSupplier['extra_fee'] = json_decode($oldSupplier['extra_fee'], true);
//// dd(array_diff($newSupplier['extra_fee'],$oldSupplier['extra_fee']));
// }
}
if (!empty($content)) {
$result[] = $content;
}
$result = array_unique($result);
}
return $result;
}
} }
\ No newline at end of file
...@@ -5,6 +5,7 @@ namespace App\Http\Services; ...@@ -5,6 +5,7 @@ namespace App\Http\Services;
use App\Http\Transformers\SupplierTransformer; use App\Http\Transformers\SupplierTransformer;
use App\Model\LogModel; use App\Model\LogModel;
use App\Model\RedisModel;
use App\Model\SupplierAddressModel; use App\Model\SupplierAddressModel;
use App\Model\SupplierChannelModel; use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel; use App\Model\SupplierContactModel;
...@@ -15,14 +16,32 @@ class SupplierAuditService ...@@ -15,14 +16,32 @@ class SupplierAuditService
public function auditSupplier($supplierId, $status, $rejectReason) public function auditSupplier($supplierId, $status, $rejectReason)
{ {
$model = new SupplierChannelModel(); $model = new SupplierChannelModel();
//判断当前要审核的供应商是不是想要被禁用的
$redis = new RedisModel();
$disableExist = $redis->hget('audit_disable_supplier_list', $supplierId);
if ($disableExist) {
if ($status == 2) {
$status = SupplierChannelModel::STATUS_DISABLE;
} else {
$status = 2;
}
}
$result = $model->where('supplier_id', $supplierId)->update([ $result = $model->where('supplier_id', $supplierId)->update([
'update_time' => time(), 'update_time' => time(),
'status' => $status, 'status' => $status,
'reject_reason' => $rejectReason, 'reject_reason' => $rejectReason,
]); ]);
if ($disableExist) {
$redis->hdel('audit_disable_supplier_list', $supplierId);
}
if ($result) { if ($result) {
//记录日志 //记录日志
if ($disableExist) {
$auditStatus = $status == -2 ? '审核通过,禁用供应商' : '审核不通过,原因是 : ' . $rejectReason;
} else {
$auditStatus = $status == 2 ? '审核通过' : '审核不通过,原因是 : ' . $rejectReason; $auditStatus = $status == 2 ? '审核通过' : '审核不通过,原因是 : ' . $rejectReason;
}
$logService = new LogService(); $logService = new LogService();
$content = $auditStatus; $content = $auditStatus;
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '审核供应商', $content); $logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '审核供应商', $content);
......
...@@ -56,6 +56,7 @@ class SupplierContactService ...@@ -56,6 +56,7 @@ class SupplierContactService
$result = $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();
$contact['admin_id'] = request()->user->userId;
$result = $model->insert($contact); $result = $model->insert($contact);
} }
//不存在则写入 //不存在则写入
...@@ -67,12 +68,12 @@ class SupplierContactService ...@@ -67,12 +68,12 @@ class SupplierContactService
'update_time' => time(), 'update_time' => time(),
]); ]);
if ($result) { if ($result) {
// //修改供应商为审核状态 //修改供应商为审核状态
// $supplierModel = new SupplierChannelModel(); $supplierModel = new SupplierChannelModel();
// $supplierModel->where('supplier_id', $contact['supplier_id'])->update([ $supplierModel->where('supplier_id', $contact['supplier_id'])->update([
// 'update_time' => time(), 'update_time' => time(),
// 'status' => 1, 'status' => 1,
// ]); ]);
$logService = new LogService(); $logService = new LogService();
$content = !empty($contact['contact_id'])?'修改联系人':'添加联系人'; $content = !empty($contact['contact_id'])?'修改联系人':'添加联系人';
$remark = json_encode($contact); $remark = json_encode($contact);
......
...@@ -14,6 +14,8 @@ use Illuminate\Support\Facades\DB; ...@@ -14,6 +14,8 @@ use Illuminate\Support\Facades\DB;
class SupplierService class SupplierService
{ {
public $newSupplierId = 0;
public function getSupplier($supplierId) public function getSupplier($supplierId)
{ {
$model = new SupplierChannelModel(); $model = new SupplierChannelModel();
...@@ -64,8 +66,17 @@ class SupplierService ...@@ -64,8 +66,17 @@ class SupplierService
unset($channel['upload_file']); unset($channel['upload_file']);
$channel['established_time'] = strtotime($channel['established_time']); $channel['established_time'] = strtotime($channel['established_time']);
$channel['sku_upload_ruler'] = $this->getSkuRulerData($channel['sku_upload_ruler']); $channel['sku_upload_ruler'] = $this->getSkuRulerData($channel['sku_upload_ruler']);
$logService = new LogService();
$model = new SupplierChannelModel();
//获取未修改前的供应商,做数据比较存储
$oldSupplier = $newSupplier = [];
if(!empty($channel['supplier_id'])){
$oldSupplier = $model->where('supplier_id', $channel['supplier_id'])->first();
}
//走事务 //走事务
return DB::connection('web')->transaction(function () use ($channel) { $dataResult = DB::connection('web')->transaction(function () use ($channel) {
$model = new SupplierChannelModel(); $model = new SupplierChannelModel();
$extraFax = [ $extraFax = [
'supplier_id' => $channel['supplier_id'], 'supplier_id' => $channel['supplier_id'],
...@@ -91,45 +102,39 @@ class SupplierService ...@@ -91,45 +102,39 @@ class SupplierService
return $value; return $value;
}, $channel); }, $channel);
$channel['status'] = SupplierChannelModel::STATUS_PENDING; $channel['status'] = SupplierChannelModel::STATUS_PENDING;
$supplierId = $model->insertGetId($channel); $supplierId = $this->newSupplierId = $model->insertGetId($channel);
$this->saveSupplierCode($supplierId); $this->saveSupplierCode($supplierId);
$logAction = "新增供应商";
$logContent = '新增供应商';
$newSupplier = $model->where('supplier_id', $supplierId)->first();
$logRemark = json_encode($newSupplier);
} else { } else {
$supplierAddressService = new SupplierAddressService(); $supplierAddressService = new SupplierAddressService();
$supplierAddressService->saveAddress($address); $supplierAddressService->saveAddress($address);
$extraFaxService = new SupplierExtraFeeService(); $extraFaxService = new SupplierExtraFeeService();
$extraFaxService->saveSupplierExtraFee($extraFax); $extraFaxService->saveSupplierExtraFee($extraFax);
$supplierId = $channel['supplier_id']; $supplierId = $this->newSupplierId = $channel['supplier_id'];
$oldSupplier = $model->where('supplier_id', $supplierId)->first();
$channel['status'] = SupplierChannelModel::STATUS_IN_REVIEW; $channel['status'] = SupplierChannelModel::STATUS_IN_REVIEW;
$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 = "更新供应商";
$logContent = "更新供应商";
$logRemark = json_encode([
'old' => $oldSupplier,
'new' => $newSupplier
]);
} }
//插入系数到redis //插入系数到redis
$this->saveRatioToRedis($supplierId); $this->saveRatioToRedis($supplierId);
//重新生成外部显示的编码 //重新生成外部显示的编码
$supplierSn = $this->generateSupplierSn($supplierId, $channel['supplier_group']); $supplierSn = $this->generateSupplierSn($supplierId, $channel['supplier_group']);
//保存日志
$logService = new LogService();
$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->sendSupplierMessage($supplierId, $channel['status']);
return true; return true;
}); });
//如果是重新入驻的,写重新入驻的日志
//保存日志
$newSupplier = $model->where('supplier_id', $this->newSupplierId)->first();
$logType = !empty($channel['supplier_id']) ? LogModel::UPDATE_OPERATE : LogModel::ADD_OPERATE;
$logAction = !empty($channel['supplier_id']) ? "修改供应商基本资料" : "新增供应商";
$logContent = !empty($channel['supplier_id']) ? '修改供应商' : '新增供应商';
$logService->AddLog($this->newSupplierId, $logType, $logAction, $logContent, json_encode([
'old_supplier' => $oldSupplier,
'new_supplier' => $newSupplier
]));
return $dataResult;
} }
public function getPhotosData($uploadFiles) public function getPhotosData($uploadFiles)
...@@ -240,7 +245,7 @@ class SupplierService ...@@ -240,7 +245,7 @@ class SupplierService
//还要去记录日志 //还要去记录日志
$adminUserService = new AdminUserService(); $adminUserService = new AdminUserService();
$prePurchaseUser = $adminUserService->getAdminUserInfoByCodeId($prePurchaseUid); $prePurchaseUser = $adminUserService->getAdminUserInfoByCodeId($prePurchaseUid);
$prePurchaseUserName = array_get($prePurchaseUser, 'name', ''); $prePurchaseUserName = array_get($prePurchaseUser, 'name', ' ');
$purchaseUser = $adminUserService->getAdminUserInfoByCodeId($purchaseUid); $purchaseUser = $adminUserService->getAdminUserInfoByCodeId($purchaseUid);
$purchaseUserName = array_get($purchaseUser, 'name', ''); $purchaseUserName = array_get($purchaseUser, 'name', '');
$logService = new LogService(); $logService = new LogService();
......
...@@ -4,17 +4,34 @@ ...@@ -4,17 +4,34 @@
namespace App\Http\Transformers; namespace App\Http\Transformers;
use App\Http\Services\LogService;
class LogTransformer class LogTransformer
{ {
public function transformList($list) public function transformList($list)
{ {
foreach ($list as &$item) { foreach ($list as &$item) {
$item['add_time'] = date('Y-m-d H:i:s', $item['add_time']); $item = $this->transformInfo($item);
$item['type'] = array_get(config('fixed.LogType'), $item['type']); unset($item['remark']);
} }
unset($item); unset($item);
return $list; 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']);
//如果action是修改供应商,就要做对比处理
if ($item['action'] === '修改供应商基本资料') {
$logService = new LogService();
$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;
}
return $item;
}
} }
\ No newline at end of file
...@@ -138,6 +138,8 @@ class SupplierTransformer ...@@ -138,6 +138,8 @@ class SupplierTransformer
private function transformDeliveryTimeData($supplier) private function transformDeliveryTimeData($supplier)
{ {
$supplier['cn_delivery_time_full'] = $supplier['cn_delivery_time'];
$supplier['us_delivery_time_full'] = $supplier['us_delivery_time'];
$supplier['cn_delivery_time_period'] = strpos($supplier['cn_delivery_time'], '天') !== false ? '天' : '周'; $supplier['cn_delivery_time_period'] = strpos($supplier['cn_delivery_time'], '天') !== false ? '天' : '周';
$supplier['us_delivery_time_period'] = strpos($supplier['us_delivery_time'], '天') !== false ? '天' : '周'; $supplier['us_delivery_time_period'] = strpos($supplier['us_delivery_time'], '天') !== false ? '天' : '周';
$supplier['cn_delivery_time'] = str_replace('天', '', $supplier['cn_delivery_time']); $supplier['cn_delivery_time'] = str_replace('天', '', $supplier['cn_delivery_time']);
......
...@@ -86,7 +86,7 @@ class SupplierValidator ...@@ -86,7 +86,7 @@ class SupplierValidator
'supplier_name.required' => '供应商名称不能为空', 'supplier_name.required' => '供应商名称不能为空',
'stockup_type.required' => '合作类型不能为空', 'stockup_type.required' => '合作类型不能为空',
'register_company_name.required' => '注册公司名不能为空', 'register_company_name.required' => '注册公司名不能为空',
'supplier_group.required' => '行业性质不能为空', 'supplier_group.required' => '公司性质不能为空',
'region.required' => '所在区域不能为空', 'region.required' => '所在区域不能为空',
'purchase_uid.required' => '渠道开发员不能为空', 'purchase_uid.required' => '渠道开发员不能为空',
'cn_ratio.min' => '人民币系数必须是大于1的浮点数', 'cn_ratio.min' => '人民币系数必须是大于1的浮点数',
......
...@@ -22,7 +22,7 @@ class TransformableSelectPresenter ...@@ -22,7 +22,7 @@ class TransformableSelectPresenter
</div> </div>
<div class="layui-col-md7" style="margin-left: -3px"> <div class="layui-col-md7" style="margin-left: -3px">
<div class="layui-input-inline"> <div class="layui-input-inline">
<select class="value_select" name="$defaultKey" lay-filter="$selectUnique"> <select class="value_select" name="$defaultKey" lay-filter="$selectUnique" lay-search="">
{$this->selectOptionsRender($data)} {$this->selectOptionsRender($data)}
</select> </select>
</div> </div>
......
...@@ -11,5 +11,36 @@ return [ ...@@ -11,5 +11,36 @@ return [
'supplier_group' => '公司性质', 'supplier_group' => '公司性质',
'business_license' => '营业执照', 'business_license' => '营业执照',
'contact' => '联系方式', 'contact' => '联系方式',
],
//供应商需要记录日志字段对应的中文
'SupplierNeedLogColumn' => [
'supplier_name' => '供应商名称',
'stockup_type' => '合作方式',
'pay_type_name' => '付款类型',
'supplier_address' => '公司详细地址',
'currency_name' => '默认结算币种',
'remark' => '附加备注',
'supplier_group_name' => '供应商分组',
'channel_user_name' => '采购员',
'purchase_user_name' => '开发员',
'tax_number' => '税务登记号',
'cn_ratio' => '人民币系数',
'us_ratio' => '美金系数',
'is_type' => '转正供应商',
'supplier_name_en' => '供应商英文名称',
'main_brand_names' => '主营品牌',
'region_name' => '所属区域',
'legal_representative' => '法人代表',
'established_time' => '公司成立时间',
'credit_investigation' => '资信调查',
// 'qualification_photos' => '资质照片',
'sku_upload_ruler' => '上传sku的规则',
'register_company_name' => '注册公司名',
'trading_method_name' => '交易方式',
'channel_username' => '采购员',
'purchase_username' => '渠道开发员',
'us_delivery_time_full' => '香港交期',
'cn_delivery_time_full' => '国内交期',
] ]
]; ];
\ No newline at end of file
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
</head> </head>
<body class="gray-bg"> <body class="gray-bg">
<div style="text-align: center">
<div class="middle-box text-center animated fadeInDown"> <div class="middle-box text-center animated fadeInDown">
<h1>{{$errcode}}</h1> <h1>{{$errcode}}</h1>
<h3 class="font-bold">{{$errinfo}}</h3> <h3 class="font-bold">{{$errinfo}}</h3>
...@@ -19,10 +20,14 @@ ...@@ -19,10 +20,14 @@
@if(!empty($url)) @if(!empty($url))
<div class="error-desc"> <div class="error-desc">
没有访问权限<br/> 没有访问权限<br/>
请前往权限系统申请权限 <br/> 请前往权限系统申请权限
<br/>
<br/>
<a href="{{$url}}" target="_blank"><i class="fa fa-mail-reply"></i>Go</a> <a href="{{$url}}" target="_blank"><i class="fa fa-mail-reply"></i>Go</a>
</div> </div>
@endif @endif
</div> </div>
</div>
</body> </body>
</html> </html>
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
, where: whereCondition , where: whereCondition
}); });
}); });
let cols = [ let cols = [
{type: 'radio'}, {type: 'radio'},
{field: 'supplier_id', title: '供应商ID', align: 'center', width: 80}, {field: 'supplier_id', title: '供应商ID', align: 'center', width: 80},
......
...@@ -12,7 +12,13 @@ ...@@ -12,7 +12,13 @@
}); });
form.on('submit(updateSupplier)', function (data) { form.on('submit(updateSupplier)', function (data) {
layer.confirm('确定要修改供应商信息吗?一旦修改,该供应商就会再次进入审核阶段', function (index) { let confirmMessage = '';
if (data.status === -2) {
confirmMessage = '确定要重新入驻吗,该供应商就会再次进入审核阶段'
} else {
confirmMessage = '确定要修改供应商信息吗?一旦修改,该供应商就会再次进入审核阶段'
}
layer.confirm(confirmMessage, function (index) {
let res = ajax('/api/supplier/UpdateSupplier', data.field) let res = ajax('/api/supplier/UpdateSupplier', data.field)
if (res.err_code === 0) { if (res.err_code === 0) {
table.reload('receiptList') table.reload('receiptList')
......
...@@ -9,16 +9,23 @@ ...@@ -9,16 +9,23 @@
<input type="hidden" name="supplier_id" value="{{$supplier['supplier_id']}}"> <input type="hidden" name="supplier_id" value="{{$supplier['supplier_id']}}">
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">基本信息 : </label> <label class="layui-form-label">基本信息 : </label>
<div class="layui-input-inline"> <div class="layui-input-block block-42" style="padding-top: 7px">
{{$supplier['supplier_name']}} {{$supplier['supplier_name']}}
<a style="color: dodgerblue;margin-left: 20px" <a style="color: dodgerblue;margin-left: 20px"
href="/supplier/SupplierDetail?view=iframe&supplier_id={{$supplier['supplier_id']}}">{{$supplier['supplier_code']}}</a> ew-href="/supplier/SupplierDetail?view=iframe&supplier_id={{$supplier['supplier_id']}}"
ew-title='供应商详情 - {{$supplier['supplier_code']}}'
>{{$supplier['supplier_code']}}</a>
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">审核内容 : </label> <label class="layui-form-label">审核内容 : </label>
<div class="layui-input-inline"> <div class="layui-input-block block-42" style="padding-top: 7px">
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx {{$auditContent['action'] .' : '}}
@if(is_array($auditContent['content']))
@foreach($auditContent['content'] as $content)
{{$content}} ;
@endforeach
@endif
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
......
<style> <style>
.fix-top { .fix-top {
height: 140px; height: 140px;
margin-top: 15px; margin-top: 0;
padding: 10px 15px; margin-left: -30px;
padding: 10px 45px;
position: fixed; position: fixed;
top: 0; top: 0;
background: white; background: white;
...@@ -37,7 +38,10 @@ ...@@ -37,7 +38,10 @@
合作类型 :{{$supplier['stockup_type_name']}} 合作类型 :{{$supplier['stockup_type_name']}}
</div> </div>
<div class="layui-col-md8"></div> <div class="layui-col-md3">
采购员 : {{$supplier['channel_username']}}
</div>
<div class="layui-col-md5"></div>
</div> </div>
@if($supplier['status']==\App\Model\SupplierChannelModel::STATUS_PENDING @if($supplier['status']==\App\Model\SupplierChannelModel::STATUS_PENDING
||$supplier['status']==\App\Model\SupplierChannelModel::STATUS_PASSED ||$supplier['status']==\App\Model\SupplierChannelModel::STATUS_PASSED
...@@ -55,8 +59,13 @@ ...@@ -55,8 +59,13 @@
style="margin-bottom: 25px;margin-top: 5px" class="layui-btn layui-btn">申请重新入驻</a> style="margin-bottom: 25px;margin-top: 5px" class="layui-btn layui-btn">申请重新入驻</a>
</div> </div>
@endif @endif
@if($supplier['status']==\App\Model\SupplierChannelModel::STATUS_IN_REVIEW)
<div class="layui-row">
<button type="button" style="margin-bottom: 25px;margin-top: 5px" class="layui-btn layui-btn layui-btn-disabled">审核中,不能修改</button>
</div>
@endif
</div> </div>
<div class="layui-card-body" style="margin-top: 160px"> <div class="layui-card-body" style="margin-top: 140px">
<div class="layui-tab"> <div class="layui-tab">
<ul class="layui-tab-title"> <ul class="layui-tab-title">
<li class="layui-this" id="base_info">基本信息</li> <li class="layui-this" id="base_info">基本信息</li>
......
...@@ -43,36 +43,55 @@ ...@@ -43,36 +43,55 @@
<div id="logs" style="margin-left: 5px"> <div id="logs" style="margin-left: 5px">
{{--所有操作记录列表查看--}} {{--所有操作记录列表查看--}}
@foreach($logs as $log) @foreach($logs as $log)
@if(is_array($log['content']))
<p>{{$log['action']}} : </p>
@foreach($log['content'] as $content)
<p>{{$content}}</p>
@endforeach
@else
<p>{{$log['action']}} : {{$log['content']}}</p> <p>{{$log['action']}} : {{$log['content']}}</p>
<p style="color: grey">{{date('Y-m-d H:i:s',$log['add_time']).' '.$log['admin_name']}}</p> @endif
<p style="color: grey">{{$log['add_time'].' '.$log['admin_name']}}</p>
<hr/> <hr/>
@endforeach @endforeach
</div> </div>
@endif @endif
</div> </div>
<div class="layui-tab-item"> <div class="layui-tab-item">
@if(checkPerm('ViewAllLog')) @if(checkPerm('ViewUpdateLog'))
@foreach($updateLogs as $log) @foreach($updateLogs as $log)
<p>{{$log['content']}}</p> @if(is_array($log['content']))
<p style="color: grey">{{date('Y-m-d H:i:s',$log['add_time']).' '.$log['admin_name']}}</p> <p>{{$log['action']}} : </p>
@foreach($log['content'] as $content)
<p>{{$content}}</p>
@endforeach
@else
<p>{{$log['action']}} : {{$log['content']}}</p>
@endif
<hr/> <hr/>
@endforeach @endforeach
@endif @endif
</div> </div>
<div class="layui-tab-item"> <div class="layui-tab-item">
@if(checkPerm('ViewAllLog')) @if(checkPerm('ViewLog'))
@foreach($viewLogs as $log) @foreach($viewLogs as $log)
<p>{{$log['content']}}</p> @if(is_array($log['content']))
<p style="color: grey">{{date('Y-m-d H:i:s',$log['add_time']).' '.$log['admin_name']}}</p> <p>{{$log['action']}} : </p>
@foreach($log['content'] as $content)
<p>{{$content}}</p>
@endforeach
@else
<p>{{$log['action']}} : {{$log['content']}}</p>
@endif
<hr/> <hr/>
@endforeach @endforeach
@endif @endif
</div> </div>
<div class="layui-tab-item"> <div class="layui-tab-item">
@if(checkPerm('ViewAllLog')) @if(checkPerm('ViewSupplierLog'))
@foreach($supplierLogs as $log) @foreach($supplierLogs as $log)
<p>{{$log['desc']}}</p> <p>{{$log['desc']}}</p>
<p style="color: grey">{{date('Y-m-d H:i:s',$log['add_time']).' '.$log['admin_name']}}</p> <p style="color: grey">{{$log['add_time'].' '.$log['admin_name']}}</p>
<hr/> <hr/>
@endforeach @endforeach
@endif @endif
......
...@@ -14,8 +14,9 @@ ...@@ -14,8 +14,9 @@
.fix-top { .fix-top {
height: 140px; height: 140px;
margin-top: 15px; margin-top: 0;
padding: 10px 15px; margin-left: -30px;
padding: 10px 45px;
position: fixed; position: fixed;
top: 0; top: 0;
background: white; background: white;
...@@ -58,7 +59,10 @@ ...@@ -58,7 +59,10 @@
<div class="layui-col-md2"> <div class="layui-col-md2">
合作类型:{{$supplier['stockup_type_name']}} 合作类型:{{$supplier['stockup_type_name']}}
</div> </div>
<div class="layui-col-md8"></div> <div class="layui-col-md3">
采购员 : {{$supplier['channel_username']}}
</div>
<div class="layui-col-md5"></div>
</div> </div>
<div class="layui-row" style="margin-bottom: 25px;margin-top: 5px"> <div class="layui-row" style="margin-bottom: 25px;margin-top: 5px">
<button type="button" class="layui-btn layui-btn" lay-submit <button type="button" class="layui-btn layui-btn" lay-submit
...@@ -69,7 +73,7 @@ ...@@ -69,7 +73,7 @@
class="layui-btn layui-btn-primary">取消</a> class="layui-btn layui-btn-primary">取消</a>
</div> </div>
</div> </div>
<div class="layui-card-body" style="margin-top: 160px"> <div class="layui-card-body" style="margin-top: 140px">
<input type="hidden" name="supplier_id" value="{{$supplier['supplier_id']}}"> <input type="hidden" name="supplier_id" value="{{$supplier['supplier_id']}}">
<input type="hidden" name="supplier_code" value="{{$supplier['supplier_code']}}"> <input type="hidden" name="supplier_code" value="{{$supplier['supplier_code']}}">
<div class="layui-tab"> <div class="layui-tab">
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<label class="layui-form-label"><span class="require">*</span>注册公司名 : </label> <label class="layui-form-label"><span class="require">*</span>注册公司名 : </label>
<div class="layui-input-block"> <div class="layui-input-block">
<input type="text" name="register_company_name" id="register_company_name" <input type="text" name="register_company_name" id="register_company_name"
placeholder="请输入注册公司名,注册公司名一旦设置,后续无法更改" class="layui-input @if(!empty($supplier))layui-disabled @endif" placeholder="请输入注册公司名" class="layui-input @if(!empty($supplier))layui-disabled @endif"
value="{{$supplier['register_company_name'] or ''}}"> value="{{$supplier['register_company_name'] or ''}}">
</div> </div>
</div> </div>
......
...@@ -8,8 +8,10 @@ ...@@ -8,8 +8,10 @@
<div class="layui-card-body" style="padding: 0;"> <div class="layui-card-body" style="padding: 0;">
<div class="split-group" style="height: 130px;"> <div class="split-group" style="height: 130px;">
<div class="split-item" id="s1"> <div class="split-item" id="s1">
<div class="layui-row">
<a class="main_filter layui-badge layui-bg-green" id="all">全部({{$statistics['total']}})</a> <a class="main_filter layui-badge layui-bg-green" id="all">全部({{$statistics['total']}})</a>
</div> </div>
</div>
<div class="split-item" id="s2" style="text-align: center"> <div class="split-item" id="s2" style="text-align: center">
@if(checkPerm('SupplierPendingList')) @if(checkPerm('SupplierPendingList'))
<div class="layui-row"> <div class="layui-row">
......
...@@ -124,14 +124,14 @@ ...@@ -124,14 +124,14 @@
</div> </div>
</div> </div>
<div class="layui-form-item"> {{--<div class="layui-form-item">--}}
<div class="layui-inline"> {{-- <div class="layui-inline">--}}
<label class="layui-form-label">审核内容配置 : </label> {{-- <label class="layui-form-label">审核内容配置 : </label>--}}
<div class="layui-input-inline" style="width: 50px"> {{-- <div class="layui-input-inline" style="width: 50px">--}}
</div> {{-- </div>--}}
</div> {{-- </div>--}}
</div> {{--</div>--}}
@include('script.supplier.SupplierRulerScript') @include('script.supplier.SupplierRulerScript')
\ No newline at end of file
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