Commit 0eeccb97 by mushishixian

temp

parent 901d9859
......@@ -60,6 +60,7 @@ class SupplierApiController extends Controller
//附加费
'cn',
'hk',
// 'status',
//商品上传规则
'sku_upload_ruler',
......
......@@ -44,7 +44,7 @@ class SupplierFilter
//因为传过来的是内部编码,所以要转成admin_id
$adminService = new AdminUserService();
$user = $adminService->getAdminUserInfoByCodeId($map['create_uid']);
$adminId = $user['userId'];
$adminId = $user['admin_id'];
$query->where('create_uid', $adminId);
}
if (!empty($map['status'])) {
......
......@@ -25,6 +25,12 @@ class AdminUserService
return $intracodeModel->where('admin_id', $userId)->value('code_id');
}
public function getCodeIdsByUserIds($userIds)
{
$intracodeModel = new IntracodeModel();
return $intracodeModel->whereIn('admin_id', $userIds)->pluck('code_id');
}
public function getAdminUserInfo($userId)
{
$userInfoModel = new UserInfoModel();
......
......@@ -13,12 +13,6 @@ use Illuminate\Support\Facades\DB;
class LogService
{
//供应商不同数据库字段对应的中文,用于日志记录
public $fieldMapToLogContent = [
'supplier_name' => '供应商名称',
];
//添加日志
public function AddLog($supplierId, $type, $action, $content, $remark = '')
{
......@@ -59,8 +53,12 @@ class LogService
public function compareSupplierChange($newSupplier, $oldSupplier)
{
$transformer = new SupplierTransformer();
$newSupplier = $transformer->transformInfo($newSupplier);
$oldSupplier = $transformer->transformInfo($oldSupplier);
if (empty($newSupplier['status_name'])) {
//判断是否要转换,因为存储有两种格式的数据
$newSupplier = $transformer->transformInfo($newSupplier);
$oldSupplier = $transformer->transformInfo($oldSupplier);
}
//二维数组转成一维数组,因为array_diff只支持一维,反正二维的内容还要更细致的比较
$newSupplier = array_map(function ($value) {
if (is_array($value)) {
......@@ -82,6 +80,7 @@ class LogService
$oldValue = array_get($oldSupplier, $key, '空');
$newValue = array_get($newSupplier, $key, '空');
$content = array_get($columnMap, $key) . '由 [ ' . $oldValue . ' ] 改成 [ ' . $newValue . ' ];';
$result[] = $content;
} else {
if ($key == 'sku_upload_ruler') {
$oldValue = array_get($oldSupplier, $key, '空');
......@@ -90,21 +89,45 @@ class LogService
$oldValue = $rulerService->getSkuUploadRulerDesc($oldValue);
$newValue = $rulerService->getSkuUploadRulerDesc($newValue);
$content = 'Sku上传规则由 [ ' . $oldValue . ' ] 改成 [ ' . $newValue . ' ];';
$result[] = $content;
}
if ($key == 'sku_audit_ruler') {
$rulerService = new SupplierSkuAuditRulerService();
$newValue = $rulerService->getSkuAuditRulerDesc($newSupplier['sku_audit_ruler']);
$oldValue = $rulerService->getSkuAuditRulerDesc($oldSupplier['sku_audit_ruler']);
$content = 'Sku审核规则由 [ ' . $oldValue . ' ] 改成 [ ' . $newValue . ' ];';
$result[] = $content;
}
if ($key == 'qualification_photos') {
$oldFiles = json_decode($oldSupplier['qualification_photos'], true);
$oldFileNames = array_map(function ($file) {
return $file['file_name'];
}, $oldFiles);
$newFiles = json_decode($newSupplier['qualification_photos'], true);
$newFileNames = array_map(function ($file) {
return $file['file_name'];
}, $newFiles);
//对比文件名变化
$diffKeys = array_keys(array_diff($newFileNames, $oldFileNames));
$content = '';
foreach ($diffKeys as $key) {
$oldFileName = array_get($oldFileNames, $key);
$oldFileName = $oldFileName == '选择文件上传' ? '空' : $oldFileName;
$newFileName = array_get($newFileNames, $key);
$content .= array_get(config('fixed.FileNameMapping'),
$key) . '由 [' . $oldFileName . '] 修改为 [' . $newFileName . ']; ';
$result[] = $content;
}
}
if ($key == 'extra_fee') {
$oldFee = json_decode($oldSupplier['extra_fee'], true);
$newFee = json_decode($newSupplier['extra_fee'], true);
$content = "采购附加费由 [商品总价不满" . $oldFee['cn']['max'] . "元,收取" . $oldFee['cn']['price'] . "元;商品总价不满" .
$oldFee['cn']['max'] . "美金,收取" . $oldFee['cn']['price'] .
"元;] 修改为 [商品总价不满" . $newFee['cn']['max'] . "元,收取" . $newFee['cn']['price'] . "元;商品总价不满" .
$newFee['cn']['max'] . "美金,收取" . $newFee['cn']['price'] . "元;]";
$result[] = $content;
}
// 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);
}
......
......@@ -47,6 +47,11 @@ class SupplierAuditService
} else {
$auditStatus = $status == 2 ? '审核通过' : '审核不通过,原因是 : ' . $rejectReason;
}
// $auditService = new SupplierAuditService();
// $flag = $auditService->checkIsNeedToFollowUpSupplier($supplierId);
// $model->where('supplier_id',$supplierId)->update([
// 'to_follow_up' => $flag ? 1 : 0,
// ]);
$logService = new LogService();
$content = $auditStatus;
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '审核供应商', $content);
......@@ -62,7 +67,7 @@ class SupplierAuditService
//针对非禁止交易状态的供应商重新分配渠道员,且必填信息不完整
if (!empty($supplier) && ($supplier['status'] != SupplierChannelModel::STATUS_DISABLE)) {
//开始检查
return $this->checkHasAllRequireField($supplier);
return !$this->checkHasAllRequireField($supplier);
}
//或者单纯只是禁用状态的供应商重新分配渠道员,也是要处理待跟进状态
if (!empty($supplier) && ($supplier['status'] == SupplierChannelModel::STATUS_DISABLE)) {
......@@ -76,7 +81,7 @@ class SupplierAuditService
public function checkHasAllRequireField($supplier)
{
//先检查基础字段
if (empty($supplier['supplier_name']) || empty($supplier['register_company_name'] || empty($supplier['region']))) {
if (empty($supplier['supplier_name']) || empty($supplier['register_company_name'] || empty($supplier['region']) || empty($supplier['legal_representative']))) {
return false;
}
if (empty($supplier['stockup_type']) || empty($supplier['supplier_group']) || empty($supplier['qualification_photos'])) {
......
......@@ -63,6 +63,10 @@ class SupplierService
if (empty($channel['purchase_uid'])) {
unset($channel['purchase_uid']);
}
$channel['cn_ratio'] = empty($channel['cn_ratio']) ? 1 : $channel['cn_ratio'];
$channel['us_ratio'] = empty($channel['us_ratio']) ? 1 : $channel['us_ratio'];
$channel['cn_delivery_time'] = $channel['cn_delivery_time'] . $channel['cn_delivery_time_period'];
$channel['us_delivery_time'] = $channel['us_delivery_time'] . $channel['us_delivery_time_period'];
$channel['qualification_photos'] = $this->getPhotosData($channel['upload_file']);
......@@ -72,14 +76,17 @@ class SupplierService
$logService = new LogService();
$model = new SupplierChannelModel();
$supplierTransformer = new SupplierTransformer();
//获取未修改前的供应商,做数据比较存储
$oldSupplier = $newSupplier = [];
if(!empty($channel['supplier_id'])){
if (!empty($channel['supplier_id'])) {
$oldSupplier = $model->where('supplier_id', $channel['supplier_id'])->first();
$oldSupplier = $supplierTransformer->transformInfo($oldSupplier);
}
//走事务
$dataResult = DB::connection('web')->transaction(function () use ($channel) {
$redis = new RedisModel();
$model = new SupplierChannelModel();
$extraFax = [
'supplier_id' => $channel['supplier_id'],
......@@ -110,19 +117,21 @@ class SupplierService
$supplierId = $this->newSupplierId = $model->insertGetId($channel);
$this->saveSupplierCode($supplierId);
} else {
$supplierAddressService = new SupplierAddressService();
$supplierAddressService->saveAddress($address);
$extraFaxService = new SupplierExtraFeeService();
$extraFaxService->saveSupplierExtraFee($extraFax);
$supplierId = $this->newSupplierId = $channel['supplier_id'];
$channel['status'] = SupplierChannelModel::STATUS_IN_REVIEW;
$channel['update_time'] = time();
$model->where('supplier_id', $supplierId)->update($channel);
$this->saveSupplierCode($supplierId);
//不能直接插到数据库,要存到一个临时的地方,审核通过才写到数据库
$redis = $redis->hset("supplier_audit_list",$supplierId);
//插入系数到redis
$supplierAddressService = new SupplierAddressService();
$supplierAddressService->saveAddress($address);
$extraFaxService = new SupplierExtraFeeService();
$extraFaxService->saveSupplierExtraFee($extraFax);
$this->saveRatioToRedis($supplierId);
$this->saveSkuAuditRulerToRedis($supplierId, $channel['sku_audit_ruler']);
}
//插入系数到redis
$this->saveRatioToRedis($supplierId);
$this->saveSkuAuditRulerToRedis($supplierId,$channel['sku_audit_ruler']);
//重新生成外部显示的编码
$supplierSn = $this->generateSupplierSn($supplierId, $channel['supplier_group']);
//修改数据
......@@ -130,15 +139,14 @@ class SupplierService
return true;
});
//如果是重新入驻的,写重新入驻的日志
//保存日志
$newSupplier = $model->where('supplier_id', $this->newSupplierId)->first();
$newSupplier = $supplierTransformer->transformInfo($newSupplier);
$logType = !empty($channel['supplier_id']) ? LogModel::UPDATE_OPERATE : LogModel::ADD_OPERATE;
$logAction = !empty($channel['supplier_id']) ? "修改供应商基本资料" : "新增供应商";
$logContent = !empty($channel['supplier_id']) ? '修改供应商' : '新增供应商';
//判断是不是申请入驻
if ($oldSupplier['status'] === -2) {
if (!empty($oldSupplier['status']) && $oldSupplier['status'] === -2) {
$logAction = "申请重新入驻";
}
$logService->AddLog($this->newSupplierId, $logType, $logAction, $logContent, json_encode([
......@@ -202,7 +210,7 @@ class SupplierService
}
}
public function saveSkuAuditRulerToRedis($supplierId,$ruler)
public function saveSkuAuditRulerToRedis($supplierId, $ruler)
{
$redis = new RedisModel();
$redis->hset('supplier_sku_audit_ruler', $supplierId, $ruler);
......
......@@ -10,13 +10,24 @@ class SupplierSkuAuditRulerService
{
//获取商品上传规则的具体描述
public function getSkuAuditRulerDesc($rule)
public function getSkuAuditRulerDesc($ruler)
{
$rule = json_decode($rule, true);
if (empty($ruler)) {
return '允许库存为空:否 允许起订量为空:否 允许阶梯价为空:否';
}
$ruler = json_decode($ruler, true);
$skipDesc = $ruler['skip'] ? "无需审核" : "需要审核内容";
$auditRuler =$ruler['audit_ruler'];
$desc = '';
foreach ($rule as $name => $value) {
// $name = array_get(config('fixed.SkuAuditRuler'), $name);
// $desc .= $name . ":" . ($value ? "是" : "否") . ' ';
foreach ($auditRuler as $key => $value) {
$name = array_get(config('fixed.SkuAuditRuler.name_map'), $key);
$valueName = $value ? '是' : '否';
$desc .= $name . ':' . $valueName . ' | ';
}
if ($ruler['skip']) {
$desc = $skipDesc;
} else {
$desc = $skipDesc . ',' . $desc;
}
return $desc;
}
......@@ -26,9 +37,8 @@ class SupplierSkuAuditRulerService
{
if (empty($ruler)) {
return config('fixed.SkuAuditRuler');
}else{
} else {
return json_decode($ruler, true);
}
}
......
......@@ -42,8 +42,6 @@ class SupplierTransformer
$supplier['create_name'] = array_get($userInfo, 'name');
}
$supplier['is_channel_or_purchase_user_view'] = $this->getIsChannelOrPurchaseUserView($supplier);
//黑名单
if (!empty($supplier['blacklist'])) {
$supplier['blacklist_name'] = $supplier['blacklist']['blacklist_name'];
......@@ -83,25 +81,6 @@ class SupplierTransformer
return implode(',', $data);
}
//判断当前登陆的用户,是不是非创建者,但是是属于该供应商的采购或者开发,如果是采购或者开发,就没有操作权限
private function getIsChannelOrPurchaseUserView($supplier)
{
$supplier['is_channel_or_purchase_user_view'] = false;
$viewUserId = request()->user->userId;
$adminUserService = new AdminUserService();
$viewUserCode = $adminUserService->getCodeIdByUserId($viewUserId);
if (empty($viewUserCode)) {
return false;
}
if ($viewUserId != $supplier['create_uid']) {
if ($viewUserCode == $supplier['purchase_uid'] ||
strpos($supplier['channel_uid'], (string)$viewUserCode) !== false) {
return true;
}
}
return false;
}
public function transformInfo($supplier)
{
if (empty($supplier)) {
......@@ -129,8 +108,7 @@ class SupplierTransformer
$uploadRulerService = new SupplierSkuUploadRulerService();
$supplier['sku_upload_ruler'] = $uploadRulerService->getSkuUploadRuler($supplier['sku_upload_ruler']);
$ruleService = new SupplierSkuAuditRulerService();
$supplier['sku_audit_ruler'] = $ruleService->getSkuAuditRuler($supplier['sku_audit_ruler']);
$supplier['is_channel_or_purchase_user_view'] = $this->getIsChannelOrPurchaseUserView($supplier);
$supplier['sku_audit_ruler'] = $ruleService->getSkuAuditRuler(array_get($supplier, 'sku_audit_ruler'));
$supplier = $this->transformDeliveryTimeData($supplier);
$ExtendModel = new SupplierExtendModel();
//获取该supplier_code对应的数据
......@@ -139,8 +117,8 @@ class SupplierTransformer
$logModel = new LogModel();
$log = $logModel->where('supplier_id', $supplier['supplier_id'])
->where('type', LogModel::UPDATE_OPERATE)->orderBy('id', 'desc')->first();
$supplier['last_update_name'] = $log['admin_name'];
$supplier['last_update_time'] = date('Y-m-d H:i:s', $log['add_time']);
$supplier['last_update_name'] = $log['admin_name']?:'无';
$supplier['last_update_time'] = $supplier['last_update_time'] ? date('Y-m-d H:i:s', $log['add_time']) : '无';
return $supplier;
}
......
......@@ -18,6 +18,7 @@ class SupplierValidator
$requestData = $this->transformRequestData($requestData);
$rules = [
'supplier_name' => 'required',
'legal_representative' => 'required',
'register_company_name' => 'required',
'stockup_type' => 'required',
'supplier_group' => 'required',
......@@ -84,6 +85,7 @@ class SupplierValidator
{
return [
'supplier_name.required' => '供应商名称不能为空',
'legal_representative.required' => '法人代表不能为空',
'stockup_type.required' => '合作类型不能为空',
'register_company_name.required' => '注册公司名不能为空',
'supplier_group.required' => '公司性质不能为空',
......
......@@ -34,8 +34,6 @@ return [
'legal_representative' => '法人代表',
'established_time' => '公司成立时间',
'credit_investigation' => '资信调查',
// 'qualification_photos' => '资质照片',
// 'sku_upload_ruler' => '上传sku的规则',
'register_company_name' => '注册公司名',
'trading_method_name' => '交易方式',
'channel_username' => '采购员',
......
......@@ -53,7 +53,7 @@
// 默认加载主页
index.loadHome({
menuPath: '/Index/index?view=iframe',
menuPath: '/index/Index?view=iframe',
menuName: '<i class="layui-icon layui-icon-home"></i>'
});
......
......@@ -328,4 +328,9 @@
</div>
</div>
</div>
</div>
\ No newline at end of file
</div>
<div style="text-align: center; border-radius:50%;position: fixed;right: 1%;top: 80%;z-index: 4;
width: 50px;height: 50px;">
</div>
......@@ -45,12 +45,12 @@
{{--所有操作记录列表查看--}}
@foreach($logs as $log)
@if(is_array($log['content']))
<p>{{$log['action']}} : </p>
<p><b>{{$log['action']}}</b> : </p>
@foreach($log['content'] as $content)
<p>{{$content}}</p>
@endforeach
@else
<p>{{$log['action']}} : {{$log['content']}}</p>
<p><b>{{$log['action']}}</b> : {{$log['content']}}</p>
@endif
<p style="color: grey">{{$log['add_time'].' '.$log['admin_name']}}</p>
<hr/>
......@@ -62,12 +62,12 @@
@if(checkPerm('ViewUpdateLog'))
@foreach($updateLogs as $log)
@if(is_array($log['content']))
<p>{{$log['action']}} : </p>
<p><b>{{$log['action']}}</b> : </p>
@foreach($log['content'] as $content)
<p>{{$content}}</p>
@endforeach
@else
<p>{{$log['action']}} : {{$log['content']}}</p>
<p><b>{{$log['action']}}</b> : {{$log['content']}}</p>
@endif
<p style="color: grey">{{$log['add_time'].' '.$log['admin_name']}}</p>
<hr/>
......@@ -78,12 +78,12 @@
@if(checkPerm('ViewLog'))
@foreach($viewLogs as $log)
@if(is_array($log['content']))
<p>{{$log['action']}} : </p>
<p><b>{{$log['action']}}</b> : </p>
@foreach($log['content'] as $content)
<p>{{$content}}</p>
@endforeach
@else
<p>{{$log['action']}} : {{$log['content']}}</p>
<p><b>{{$log['action']}}</b> : {{$log['content']}}</p>
@endif
<p style="color: grey">{{$log['add_time'].' '.$log['admin_name']}}</p>
<hr/>
......
<style>
.fix-button {
height: 110px;
margin-top: 0;
margin-left: -30px;
padding: 10px 45px;
position: fixed;
bottom: 0;
background: white;
width: 100%;
z-index: 10;
}
</style>
<blockquote class="layui-elem-quote layui-text">
<b>基本信息</b>
</blockquote>
......@@ -20,6 +33,9 @@
value="{{$supplier['register_company_name'] or ''}}">
</div>
</div>
<div style="margin-top: -15px;margin-left: 20px">
<div class="layui-form-mid layui-word-aux">注册公司名必须同执照</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">英文名称 : </label>
<div class="layui-input-block">
......@@ -140,18 +156,40 @@
<div class="layui-form-item">
{!! $statusPresenter->render('purchase_uid','渠道开发员','',$userCodes,['required'=>true,'width'=>'150px']) !!}
</div>
<div class="layui-row" style="text-align: right">
{{-- <div class="layui-btn-group" style="margin-bottom: 25px;margin-top: 5px">--}}
@endif
@include('script.supplier.SupplierBaseScript')
@if($operate=='add')
<div style="height: 100px"></div>
<div class="fix-button">
<div class="layui-row" style="width: 90%;">
<hr>
<div class="layui-col-md8">
<p>
<b>特别说明:</b>
</p>
<p>
1.在创建新的供应商前,请先查询该供应商是否已经存在。如果供应商已存在,则不允许新增。
</p>
<p>
2.附件上传支持小于20M的PDF/ZIP/JPG/PNG/BMP格式,每个类型最多支持上传一个文件
</p>
<P>
3.此处新增供应商基本信息以及配置跟进人,其他信息补全必须进入编辑页面
</P>
</div>
<div class="layui-col-md4" style="margin-top: 30px">
<div class="layui-row" style="text-align: right">
<button type="button" class="layui-btn layui-btn submit-loading" lay-submit
lay-filter="addSupplier">确认
</button>
<button lay-filter="cancelAddSupplier"
type="button" lay-submit
class="layui-btn layui-btn-primary">取消</button>
{{-- </div>--}}
type="button" lay-submit
class="layui-btn layui-btn-primary">取消
</button>
</div>
</div>
@endif
@include('script.supplier.SupplierBaseScript')
@if($operate=='add')
</div>
</div>
</form>
@endif
\ No newline at end of file
......@@ -154,7 +154,7 @@
@else
@foreach(config('fixed.SkuAuditRuler.audit_ruler') as $key=>$flag)
<input type="checkbox" name="sku_audit_ruler[{{$key}}]"
lay-skin="primary" class="audit_ruler_item"
lay-skin="primary" checked class="audit_ruler_item"
title="{{array_get(config('fixed.SkuAuditRuler.name_map'),$key)}}">
@endforeach
@endif
......
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