Commit b1a658a0 by 杨树贤

批量修改SKU采购员

parent 8f4aaeda
......@@ -543,12 +543,28 @@ class SupplierApiController extends Controller
$user = $adminService->getAdminUserInfoByCodeId($channelUid);
$logService = new LogService();
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '设置SKU采购员', '设置SKU采购员为 : ' . $user['name']);
$this->response(0, '设置云芯采购成功');
$this->response(0, '设置SKU采购成功');
} else {
$this->response(-1, '设置云芯采购失败');
$this->response(-1, '设置SKU采购失败');
}
}
public function BatchAllocateYunxinChannelUser($request)
{
$channelUid = $request->get('channel_uid');
$supplierIds = $request->get('supplier_ids');
$supplierIds = explode(',', $supplierIds);
$supplierService = new SupplierService();
if (empty($channelUid)) {
$this->response(-1, '请选择SKU采购员');
}
if (!$supplierService->checkCanAllocatYunxinChannelUid($supplierIds, $channelUid)) {
$this->response(-1, '选择的供应商里面不存在对应的SKU采购员');
}
$supplierService->batchAllocateYunxinChannelUser($supplierIds, $channelUid);
$this->response(0, '批量分配SKU采购员成功');
}
//检查能否能申请审核
public function CheckCanApplyInReview($request)
{
......
......@@ -323,6 +323,22 @@ class SupplierController extends Controller
return $this->view('审核供应商');
}
//批量分配SKU采购员
public function BatchAllocateYunxinChannelUser($request)
{
$supplierIds = $request->get('supplier_ids');
$this->data['supplierIds'] = $supplierIds;
$supplierIds = explode(',', $supplierIds);
$model = new SupplierChannelModel();
$suppliers = $model->whereIn('supplier_id', $supplierIds)->get()->toArray();
$transformer = new SupplierTransformer();
$suppliers = $transformer->transformList($suppliers);
$this->data['suppliers'] = $suppliers;
$intraCodeModel = new IntracodeModel();
$this->data['userCodes'] = $intraCodeModel->getChannelUsersEncode(false);
return $this->view('批量分配渠道开发员');
}
//拉黑供应商
public function BlockSupplier($request)
{
......
......@@ -20,6 +20,14 @@ class AdminUserService
return $userInfoModel->where('userId', $adminId)->first();
}
public function getAdminUserNameByCodeId($codeId)
{
$intraCodeModel = new IntracodeModel();
$userInfoModel = new UserInfoModel();
$adminId = $intraCodeModel->where('code_id', $codeId)->value('admin_id');
return $userInfoModel->where('userId', $adminId)->value('name');
}
public function getAdminUserListByCodeIds($codeIds = [])
{
$intraCodeModel = new IntracodeModel();
......
......@@ -9,6 +9,7 @@ use App\Model\DepartmentModel;
use App\Model\IntracodeModel;
use App\Model\LogModel;
use App\Model\RedisModel;
use App\Model\SkuUploadLogModel;
use App\Model\StandardBrandModel;
use App\Model\SupplierAccountModel;
use App\Model\SupplierAttachmentModel;
......@@ -764,7 +765,7 @@ class DataService
'supplier_type' => SupplierChannelModel::SUPPLIER_TYPE_TEMPORARY
]);
}
}else {
} else {
if ($isUpdate) {
SupplierChannelModel::where('supplier_id', $supplier['supplier_id'])->update([
'level' => '',
......@@ -773,5 +774,32 @@ class DataService
}
}
}
}
//同步基石的sku上传内部编码到供应商的SKU采购员
public function syncFootstoneSkuUploadEncoded($isUpdate = false)
{
$suppliers = SupplierChannelModel::select(['supplier_code', 'yunxin_channel_uid'])->where('is_type',
0)->get()->toArray();
foreach ($suppliers as $supplier) {
//去基石的上传表找
$lastEncoded = SkuUploadLogModel::where('supplier_code', $supplier['supplier_code'])
->orderBy('create_time', 'desc')->value('encoded');
if (!$lastEncoded) {
continue;
}
//判断是否已经有SKU采购员了,有的话跳过
$hasSkuChannelUid = SupplierChannelModel::where('supplier_code', $supplier['supplier_code'])
->where('yunxin_channel_uid', '!=', 0)->exists();
if ($hasSkuChannelUid) {
echo "已经有SKU采购员,供应商编码为 : ${supplier['supplier_code']} , 跳过" . PHP_EOL;
continue;
}
echo "修改SKU采购员 : ${supplier['supplier_code']} => ${lastEncoded}" . PHP_EOL;
if ($isUpdate) {
SupplierChannelModel::where('supplier_code', $supplier['supplier_code'])
->update(['yunxin_channel_uid' => $lastEncoded]);
}
}
}
}
\ No newline at end of file
......@@ -29,6 +29,26 @@ class LogService
$model->insert($data);
}
//添加忽略审核的日志
public function AddIgnoreAuditCheckLog($supplierId, $type, $action, $content, $remark = '')
{
$adminId = request()->user->userId;
$adminName = request()->user->name;
$data = [
'supplier_id' => $supplierId,
'type' => $type,
'action' => $action,
'content' => $content,
'remark' => $remark,
'admin_id' => $adminId,
'admin_name' => $adminName,
'add_time' => time(),
'ignore_audit_check' => 1,
];
$model = new LogModel();
$model->insert($data);
}
//添加日志
public function AddAdminLog($supplierId, $type, $action, $content, $remark = '')
{
......
......@@ -144,8 +144,10 @@ class SupplierAuditService
$supplier = $supplierModel->where('supplier_id', $supplierId)->first()->toArray();
$auditUserId = request()->user->userId;
$logModel = new LogModel();
//找出不能跳过审核检查并且是更新操作的日志,默认都是不能跳过
$log = $logModel->where('supplier_id', $supplierId)
->where('type', LogModel::UPDATE_OPERATE)->orderBy('id', 'desc')->first();
->where('type', LogModel::UPDATE_OPERATE)
->where('ignore_audit_check', 0)->orderBy('id', 'desc')->first();
$log = $log ? $log->toArray() : [];
//判断供应商,如果是第一次新增的供应商,要去判断创建人是否属于审核人相关的部门
......
......@@ -396,7 +396,7 @@ class SupplierService
$purchaseUserName = array_get($purchaseUser, 'name', '');
$logService = new LogService();
$content = "将渠道开发员由 [${prePurchaseUserName}] 改为 [${purchaseUserName}]";
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '分配渠道开发员', $content);
$logService->AddIgnoreAuditCheckLog($supplierId, LogModel::UPDATE_OPERATE, '分配渠道开发员', $content);
}
});
......@@ -413,6 +413,40 @@ class SupplierService
return true;
}
//批量分配SKU采购员
public function batchAllocateYunxinChannelUser($supplierIds, $yunxinChannelUid)
{
$yunxinChannelUserName = (new AdminUserService())->getAdminUserNameByCodeId($yunxinChannelUid);
$logService = new LogService();
foreach ($supplierIds as $supplierId) {
$preYunxinChannelUid = SupplierChannelModel::where('supplier_id', $supplierId)->value('yunxin_channel_uid');
SupplierChannelModel::where('supplier_id', $supplierId)->update([
'yunxin_channel_uid' => $yunxinChannelUid
]);
$preYunxinChannelUserName = (new AdminUserService())->getAdminUserNameByCodeId($preYunxinChannelUid);
$content = "将SKU采购员由 [${preYunxinChannelUserName}] 改为 [${yunxinChannelUserName}]";
$logService->AddIgnoreAuditCheckLog($supplierId, LogModel::UPDATE_OPERATE, '分配渠道开发员', $content);
}
return true;
}
//检测是否可以批量分配SKU采购员(分配的采购员必须供应商要有的)
//$filterChannelUid筛选出来的采购员ID
public function checkCanAllocatYunxinChannelUid($supplierIds, $skuChannelUid)
{
foreach ($supplierIds as $supplierId) {
$channelUid = SupplierChannelModel::where('supplier_id', $supplierId)->value('channel_uid');
if (empty($channelUid)) {
return false;
}
$channelUid = explode(',', trim($channelUid, ','));
if (!in_array($skuChannelUid, $channelUid)) {
return false;
}
}
return true;
}
//分配采购员
public function allocateChannelUser($supplierId, $channelUid, $needLog = true)
{
......@@ -468,7 +502,7 @@ class SupplierService
$channelUserName = array_get($channelUser, 'name', ' ');
$logService = new LogService();
$content = "添加采购员 : " . $channelUserName;
$logService->AddLog($supplierId, LogModel::UPDATE_OPERATE, '添加采购员', $content);
$logService->AddIgnoreAuditCheckLog($supplierId, LogModel::UPDATE_OPERATE, '添加采购员', $content);
}
return $contactResult;
});
......
......@@ -38,6 +38,7 @@ class SupplierTransformer
$supplier['update_time'] = $supplier['update_time'] ? date('Y-m-d H:i:s', $supplier['update_time']) : '';
$supplier['channel_username'] = $this->getChannelUserNames($supplier['channel_uid']);
$supplier['purchase_username'] = array_get($users, $supplier['purchase_uid']);
$supplier['yunxin_channel_username'] = array_get($users, $supplier['yunxin_channel_uid']);
$supplier['status_name'] = array_get(config('fixed.SupplierStatus'), $supplier['status']);
$supplier['supplier_type_name'] = array_get(config('field.SupplierType'), $supplier['supplier_type']);
$supplier['company_nature_name'] = array_get(config('field.CompanyNature'), $supplier['company_nature']);
......
......@@ -33,7 +33,7 @@ class SupplierAccountValidator
$yunxinChannelUid = $supplierModel->where('supplier_code',
$account['supplier_code'])->value('yunxin_channel_uid');
if (empty($yunxinChannelUid)) {
return '该供应商没有绑定云芯采购,请完善相关信息';
return '该供应商没有绑定SKU采购,请完善相关信息';
}
$model = new SupplierAccountModel();
$supplierCount = $model->where('supplier_code', $account['supplier_code'])
......
......@@ -62,5 +62,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
Route::match(['get', 'post'], '/test', function () {
(new \App\Http\Services\DataService())->repairLevelESupplierData(false);
(new \App\Http\Services\DataService())->syncFootstoneSkuUploadEncoded(false);
});
<script>
layui.use(['table', 'form', 'element', 'table', 'layer', 'admin'], function () {
let admin = layui.admin;
let form = layui.form;
let table = layui.table
let element = layui.element;
form.on('submit(allocate)', function (data) {
admin.showLoading({
type: 3
});
let supplierIds = getQueryVariable('supplier_ids');
let url = '/api/supplier/BatchAllocateYunxinChannelUser?supplier_ids=' + supplierIds;
$.ajax({
url: url,
type: 'POST',
async: true,
data: data.field,
dataType: 'json',
timeout: 20000,
success: function (res) {
admin.removeLoading();
if (res.err_code === 0) {
admin.closeThisDialog();
parent.layer.msg(res.err_msg, {icon: 6});
} else {
parent.layer.msg(res.err_msg, {icon: 5});
}
},
error: function () {
admin.removeLoading();
parent.layer.msg('网络错误', {icon: 5});
}
});
return false;
});
form.on('submit(cancel)', function (data) {
admin.closeThisDialog();
});
});
</script>
\ No newline at end of file
......@@ -144,6 +144,7 @@
{field: 'channel_username', title: '采购员', align: 'center', width: 130},
{field: 'purchase_username', title: '渠道开发员', align: 'center', width: 110},
{field: 'last_update_name', title: '最新修改人', align: 'center', width: 110},
{field: 'yunxin_channel_username', title: 'SKU采购员', align: 'center', width: 110},
{field: 'has_sku', title: 'SKU上传', align: 'center', width: 80},
{
field: 'uploaded_sku', title: 'SKU合作', align: 'center', width: 80, templet: function (data) {
......@@ -604,6 +605,27 @@
}
});
//设置SKU采购
$("#batch_allocate_yunxin_channel_user").click(function () {
let checkStatus = table.checkStatus('list');
let data = checkStatus.data;
let supplierIds = Array.from(data, ({supplier_id}) => supplier_id);
supplierIds = supplierIds.join(',');
if (!data.length) {
layer.msg('请先选择要操作的供应商', {icon: 5})
} else {
layer.open({
type: 2,
content: '/supplier/BatchAllocateYunxinChannelUser?view=iframe&supplier_ids=' + supplierIds,
area: ['80%', '80%'],
title: '批量配置SKU采购员',
end: function () {
table.reload('list');
}
});
}
})
//点击查询按钮
form.on('submit(load)', function (data) {
//罗盘选项会跳回全部
......
......@@ -53,7 +53,7 @@
});
})
//设置云芯采购
//设置SKU采购
$("#set_yunxin_channel_user").click(function () {
let supplierId = getQueryVariable('supplier_id');
layer.open({
......
<style>
.layui-form-item {
margin-bottom: 5px;
}
</style>
<div class="layui-card">
<div class="layui-card-header" style="height: 170px">
<blockquote class="layui-elem-quote layui-text">
<b>渠道开发员设置</b>
</blockquote>
<form class="layui-form" action="">
<input type="hidden" name="supplier_ids" value="{{$supplierIds}}">
<div class="layui-form-item">
<div class="layui-inline" style="margin-left: -30px">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('channel_uid','SKU采购员',null,
$userCodes,['required'=>true,'width'=>'150px']) !!}
</div>
</div>
<div class="layui-form-item">
<div align="center" style="margin-top: 10px;text-align: right">
<button type="button" class="layui-btn layui-btn-sm layui-btn-info submit-loading" lay-submit
lay-filter="allocate">确认
</button>
<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" lay-submit
lay-filter="cancel">取消
</button>
</div>
</div>
</form>
</div>
<div class="layui-card-body">
<blockquote class="layui-elem-quote layui-text">
<b>当前选中需要批量修改SKU采购员的供应商列表 <span style="color: red"> (注意需要分配的SKU采购员必须是下列供应商都有的采购才行) </span></b>
</blockquote>
<table class="layui-table">
<colgroup>
<col width="300">
<col width="500">
<col width="100">
<col>
</colgroup>
<thead>
<tr>
<th>供应商名称</th>
<th>当前采购员</th>
<th>当前SKU采购员</th>
</tr>
</thead>
<tbody>
@foreach($suppliers as $supplier)
<tr>
<td>{{$supplier['supplier_name']}}</td>
<td>{{$supplier['channel_username']}}</td>
<td>{{$supplier['yunxin_channel_username']}}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
......@@ -10,7 +10,7 @@
<div class="layui-form-item">
<div class="layui-inline" style="margin-left: -30px">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('yunxin_channel_uid','云芯采购',$supplier['yunxin_channel_uid'],
{!! $statusPresenter->render('yunxin_channel_uid','SKU采购',$supplier['yunxin_channel_uid'],
$userCodes,['required'=>true,'width'=>'150px']) !!}
</div>
</div>
......
......@@ -30,9 +30,9 @@
{{-- 申请审核--}}
{{-- </button>--}}
@if(checkPerm('BlockSupplier'))
{{-- <button type="button" class="layui-btn layui-btn-sm" id="block_supplier">--}}
{{-- 拉黑--}}
{{-- </button>--}}
{{-- <button type="button" class="layui-btn layui-btn-sm" id="block_supplier">--}}
{{-- 拉黑--}}
{{-- </button>--}}
@endif
@if(request()->user->userId==1000)
<button type="button" class="layui-btn layui-btn-sm" title="该操作可以将供应商同步到供应商" id="sync_supplier_to_erp">
......@@ -62,6 +62,9 @@
新增供应商标签
</button>
@endif
@if(checkPerm('BatchAllocateYunxinChannelUser'))
<button type="button" class="layui-btn layui-btn-sm" id="batch_allocate_yunxin_channel_user">设置SKU采购</button>
@endif
</div>
<button type="button" id="refreshWindow" style="display: none">刷新页面</button>
<table class="layui-table" id="list" lay-filter="list"></table>
......
......@@ -14,7 +14,7 @@
<button type="button" class="layui-btn layui-btn-sm" id="batchDelete">删除</button>
@endif
@if(checkPerm('SetYunxinChannelUser'))
<button type="button" class="layui-btn layui-btn-sm" id="set_yunxin_channel_user">设置云芯采购</button>
<button type="button" class="layui-btn layui-btn-sm" id="set_yunxin_channel_user">设置SKU采购</button>
@endif
</div>
@endif
......
......@@ -164,8 +164,8 @@
</div>
<div class="layui-inline">
@inject('multiTransformableSelectPresenter','App\Presenters\Filter\MultiTransformableSelectPresenter')
{!! $multiTransformableSelectPresenter->render(['has_sku'=>'SKU上传','sku_tag'=>'SKU标准','sku_mode'=>'SKU模式','uploaded_sku' => '历史SKU合作','outside_contact_type' => 'SKU上传方式'],
['has_sku'=>[1=>'是',-1=>'否'],'sku_tag'=>config('field.SkuTag'),'sku_mode'=>config('field.SkuMode'),'outside_contact_type'=>config('field.OutsideContactType')]) !!}
{!! $multiTransformableSelectPresenter->render(['has_sku'=>'SKU上传','sku_tag'=>'SKU标准','sku_mode'=>'SKU模式','uploaded_sku' => '历史SKU合作','outside_contact_type' => 'SKU上传方式','yunxin_channel_uid' => 'SKU采购员'],
['has_sku'=>[1=>'是',-1=>'否'],'sku_tag'=>config('field.SkuTag'),'sku_mode'=>config('field.SkuMode'),'outside_contact_type'=>config('field.OutsideContactType'),'yunxin_channel_uid' => $userCodes]) !!}
</div>
<div class="layui-inline">
@inject('multiSelectorPresenter','App\Presenters\MultiSelectorPresenter')
......
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