Commit b3c2f7d1 by 杨树贤

修复

parent 2548c326
...@@ -36,6 +36,6 @@ class SetSupplierFollowUp extends Command ...@@ -36,6 +36,6 @@ class SetSupplierFollowUp extends Command
//DealImageService::dealNewsImage(); //DealImageService::dealNewsImage();
//DealImageService::dealNewsImage(); //DealImageService::dealNewsImage();
//DealImageService::dealSkuDetailAndImage(); //DealImageService::dealSkuDetailAndImage();
DataService::refreshDataFollower(10000,true); DataService::resetPurchaseUid(true);
} }
} }
...@@ -31,6 +31,7 @@ use App\Model\SupplierAttachmentsModel; ...@@ -31,6 +31,7 @@ use App\Model\SupplierAttachmentsModel;
use App\Model\StandardBrandMappingModel; use App\Model\StandardBrandMappingModel;
use App\Model\Purchase\PurchaseOrderModel; use App\Model\Purchase\PurchaseOrderModel;
use App\Http\Transformers\SupplierTransformer; use App\Http\Transformers\SupplierTransformer;
use App\Http\Services\AdminUserService;
use PhpAmqpLib\Connection\AMQPStreamConnection; use PhpAmqpLib\Connection\AMQPStreamConnection;
//这个服务是处理数据的,比如导出信息,或者临时修复数据,所以代码会比较多 //这个服务是处理数据的,比如导出信息,或者临时修复数据,所以代码会比较多
...@@ -1957,11 +1958,121 @@ class DataService ...@@ -1957,11 +1958,121 @@ class DataService
} }
/** /**
* 删除所有京东采购员类型的联系人 * 重置所有供应商数据维护员
* 1. 删除SupplierContactModel表中channel_user_type=2的联系人 * 1. 清空所有供应商的purchase_uid
* 2. 更新SupplierChannelModel表的channel_uid字段,移除京东采购员ID * 2. 将指定供应商列表的purchase_uid设置为沈文娟
* 3. 更新redis缓存lie_supplier_info中的channel_uid字段
*/ */
public static function resetPurchaseUid($updateData = false)
{
ini_set('memory_limit', '512M');
$redis = new RedisModel();
$logService = new LogService();
// 获取沈文娟的code_id
$shenWenJuanCodeId = (new AdminUserService())->getCodeIdByUserName('沈文娟');
if (empty($shenWenJuanCodeId)) {
dump('错误: 找不到沈文娟的用户信息');
return;
}
dump('沈文娟的code_id: ' . $shenWenJuanCodeId);
// 指定要设置为沈文娟的供应商编码列表
$targetSupplierCodes = [
'L0016577', 'L0006434', 'L0003296', 'L0011060', 'L0015160', 'L0006157', 'L0016028', 'L0007467',
'L0018137', 'L0011585', 'L0015351', 'L0014399', 'L0011620', 'L0014564', 'L0018061', 'L0018395',
'L0006722', 'L0000258', 'L0008011', 'L0017757', 'L0017719', 'L0013856', 'L0018020', 'L0011975',
'L0018044', 'L0015941', 'L0005422', 'L0006549', 'L0015645', 'L0014112', 'L0006602', 'L0000035',
'L0016847', 'L0000106', 'L0007745', 'L0011901', 'L0017549', 'L0007708', 'L0000048', 'L0016369',
'L0000160', 'L0005971', 'L0011377', 'L0019282', 'L0011653', 'L0007994', 'L0000216', 'L0003266',
'L0016594', 'L0018946', 'L0000088', 'L0000081', 'L0005175', 'L0013692', 'L0015288', 'L0007825',
'L0013504', 'L0019006', 'L0017476', 'L0004252', 'L0007456', 'L0014119', 'L0014483', 'L0011411',
'L0011396', 'L0004800', 'L0007812', 'L0011729', 'L0018033', 'L0013681', 'L0018280', 'L0016501',
'L0011838', 'L0016289', 'L0011714', 'L0011608', 'L0011871', 'L0000129', 'L0017626', 'L0003148',
'L0016662', 'L0011383', 'L0014937',
];
// 获取所有供应商
$suppliers = SupplierChannelModel::select(['supplier_id', 'supplier_code', 'supplier_name', 'purchase_uid'])->get()->toArray();
$targetSuppliers = [];
$clearSuppliers = [];
foreach ($suppliers as $supplier) {
$supplierId = $supplier['supplier_id'];
$supplierCode = $supplier['supplier_code'];
if (in_array($supplierCode, $targetSupplierCodes)) {
$targetSuppliers[] = $supplier;
if ($updateData) {
dump("供应商ID: {$supplierId}, 供应商编码: {$supplierCode}, 供应商名称: {$supplier['supplier_name']}, 已设置数据维护员为: 沈文娟");
} else {
dump("供应商ID: {$supplierId}, 供应商编码: {$supplierCode}, 供应商名称: {$supplier['supplier_name']}, 待设置数据维护员为: 沈文娟");
}
} elseif (!empty($supplier['purchase_uid'])) {
$clearSuppliers[] = $supplier;
}
}
if ($updateData) {
$clearSupplierIds = array_column($clearSuppliers, 'supplier_id');
$targetSupplierIds = array_column($targetSuppliers, 'supplier_id');
// 批量清空非目标供应商的数据维护员
if (!empty($clearSupplierIds)) {
SupplierChannelModel::whereIn('supplier_id', $clearSupplierIds)->update([
'purchase_uid' => '',
]);
}
// 批量设置目标供应商的数据维护员为沈文娟
if (!empty($targetSupplierIds)) {
SupplierChannelModel::whereIn('supplier_id', $targetSupplierIds)->update([
'purchase_uid' => $shenWenJuanCodeId,
]);
}
// 逐个更新redis缓存(清空的供应商)
foreach ($clearSuppliers as $supplier) {
$supplierId = $supplier['supplier_id'];
$supplierCode = $supplier['supplier_code'];
$supplierName = $supplier['supplier_name'];
$existingData = $redis->hget('lie_supplier_info', $supplierId);
if ($existingData) {
$data = json_decode($existingData, true);
$data['purchase_uid'] = '';
$redis->hset('lie_supplier_info', $supplierId, json_encode($data));
dump("供应商ID: {$supplierId}, 供应商编码: {$supplierCode}, 供应商名称: {$supplierName}, 已清空Redis缓存");
}
}
// 逐个更新redis缓存并写日志(目标供应商)
foreach ($targetSuppliers as $supplier) {
$supplierId = $supplier['supplier_id'];
$supplierCode = $supplier['supplier_code'];
$supplierName = $supplier['supplier_name'];
$existingData = $redis->hget('lie_supplier_info', $supplierId);
if ($existingData) {
$data = json_decode($existingData, true);
$data['purchase_uid'] = $shenWenJuanCodeId;
$redis->hset('lie_supplier_info', $supplierId, json_encode($data));
dump("供应商ID: {$supplierId}, 供应商编码: {$supplierCode}, 供应商名称: {$supplierName}, 已更新Redis缓存为: 沈文娟");
}
$logService->AddIgnoreAuditCheckLog($supplierId, LogModel::UPDATE_OPERATE, '分配数据维护员', '将数据维护员重置为 沈文娟');
}
}
$clearCount = count($clearSuppliers);
$setCount = count($targetSuppliers);
dump("共找到目标供应商 " . count($targetSupplierCodes) . " 个");
dump("待清空/已清空 {$clearCount} 个供应商的数据维护员");
dump("待设置/已设置 {$setCount} 个供应商的数据维护员为沈文娟");
if (!$updateData) {
dump("当前为预览模式,如需执行,请传入 updateData=true");
} else {
dump("已执行完成");
}
}
public static function deleteAllJdChannelUser($updateData = false) public static function deleteAllJdChannelUser($updateData = false)
{ {
ini_set('memory_limit', '512M'); ini_set('memory_limit', '512M');
......
...@@ -97,5 +97,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function () ...@@ -97,5 +97,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
}); });
Route::match(['get', 'post'], '/test', function () { Route::match(['get', 'post'], '/test', function () {
DataService::deleteAllJdChannelUser(true); DataService::resetPurchaseUid(true);
}); });
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
<div class="layui-row"> <div class="layui-row">
<div class="layui-col-md3"> <div class="layui-col-md3">
@inject('statusPresenter','App\Presenters\StatusPresenter') @inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('purchase_uid','数据维护员 : ',$default_purchase_uid,$userCodes,['width'=>'150px']) !!} {!! $statusPresenter->render('purchase_uid','数据维护员 : ','',$userCodes,['width'=>'150px']) !!}
</div> </div>
<div class="layui-col-md3"> <div class="layui-col-md3">
<label class="layui-form-label"><span class="require">*</span>注册资金(万): </label> <label class="layui-form-label"><span class="require">*</span>注册资金(万): </label>
......
...@@ -247,8 +247,7 @@ ...@@ -247,8 +247,7 @@
</div> </div>
<div class="layui-inline"> <div class="layui-inline">
@inject('multiTransformableSelectPresenter','App\Presenters\Filter\MultiTransformableSelectPresenter') @inject('multiTransformableSelectPresenter','App\Presenters\Filter\MultiTransformableSelectPresenter')
{!! $multiTransformableSelectPresenter->render(['data_channel_uid' => '数据跟单员'], {!! $multiTransformableSelectPresenter->render(['data_channel_uid' => '数据跟单员'],['data_channel_uid' => $userCodes]) !!}
['data_channel_uid' => $userCodes]) !!}
</div> </div>
<div class="layui-row"> <div class="layui-row">
<div class="layui-inline" style="width: 600px"> <div class="layui-inline" style="width: 600px">
......
...@@ -274,8 +274,7 @@ ...@@ -274,8 +274,7 @@
</div> </div>
<div class="layui-inline"> <div class="layui-inline">
<?php $multiTransformableSelectPresenter = app('App\Presenters\Filter\MultiTransformableSelectPresenter'); ?> <?php $multiTransformableSelectPresenter = app('App\Presenters\Filter\MultiTransformableSelectPresenter'); ?>
<?php echo $multiTransformableSelectPresenter->render(['purchase_uid' => '线上采购员'], <?php echo $multiTransformableSelectPresenter->render(['data_channel_uid' => '数据跟单员'],['data_channel_uid' => $userCodes]); ?>
['purchase_uid' => $userCodes]); ?>
</div> </div>
<div class="layui-row"> <div class="layui-row">
......
...@@ -270,19 +270,6 @@ ...@@ -270,19 +270,6 @@
{field: 'purchase_username', title: '数据维护员', align: 'center', width: 110}, {field: 'purchase_username', title: '数据维护员', align: 'center', width: 110},
{field: 'yunxin_channel_username', title: '线上采购员', align: 'center', width: 110}, {field: 'yunxin_channel_username', title: '线上采购员', align: 'center', width: 110},
{ {
field: 'jd_channel_username', title: '京东采购员', align: 'center', width: 130, templet: function (data) {
if (data.jd_resign_channel_username) {
if (data.jd_on_job_channel_username) {
return `<span>${data.jd_on_job_channel_username}</span>` + `,<span style="color: #D7D7D7">${data.jd_resign_channel_username}</span>`;
} else {
return `<span style="color: #D7D7D7">${data.jd_resign_channel_username}</span>`
}
} else {
return `<span>${data.jd_on_job_channel_username}</span>`;
}
}
},
{
field: 'inventory_channel_username', title: '数据跟单员', align: 'center', width: 130, templet: function (data) { field: 'inventory_channel_username', title: '数据跟单员', align: 'center', width: 130, templet: function (data) {
if (data.inventory_resign_channel_username) { if (data.inventory_resign_channel_username) {
if (data.inventory_on_job_channel_username) { if (data.inventory_on_job_channel_username) {
......
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