Commit b149eb8d by 杨树贤

Merge branch 'master' into ysx-供应商新建-20220701

parents 24714fdc 1894d739
......@@ -38,7 +38,7 @@ class SetSupplierFollowUp extends Command
// $service->importSupplierGroup(true);
// $service->changeSupplierType();
// $service->generateYunxinAccount(true);
$service->disableSupplier(true);
$service->reSyncSupplierToErp();
// $service->makeSupplierSystemTagAbnormal();
}
}
......@@ -303,9 +303,6 @@ class SupplierApiController extends Controller
//如果是编辑操作,则要忽略非当前
if ($supplierId) {
if (in_array($supplierId, config('field.NeedSkipSupplierNameCheckIds'))) {
$this->response(0, '供应商名称合理');
}
$originSupplierName = $model->where('supplier_id', $supplierId)->value('supplier_name');
$existedSupplierName = $model->where('supplier_name', $supplierName)->where('supplier_name', '!=',
$originSupplierName)
......
......@@ -646,5 +646,67 @@ class DataService
})->export('xlsx');
}
public function repairSupplierName()
{
$map = [
8581 => 'Holdwell Electronics(HK) Limited',
10245 => 'Micropower Communication Co.,Limited',
12021 => '深圳市卓美信电子科技有限公司',
12430 => '華创进出口有限公司',
12562 => 'Martec Unipersonale S.r.l.',
12577 => 'INELTEK Industrieelektronik und Technologien Ges.m.b.H.',
];
foreach ($map as $key => $value) {
SupplierChannelModel::where('supplier_id', $key)->update(['supplier_name' => $value]);
(new SyncSupplierService())->syncSupplierToUnited($key);
}
}
public function reSyncSupplierToErp()
{
ini_set('memory_limit', -1);
$suppliers = SupplierChannelModel::select(['supplier_id', 'supplier_name'])->where('is_type', 0)
->where('status', 2)->offset(200)->limit(200)->get()->toArray();
foreach ($suppliers as $supplier) {
if (!empty($supplier['supplier_name'])) {
echo "同步供应商到金蝶 : " . $supplier['supplier_name'] . PHP_EOL;
(new SyncSupplierService())->syncSupplierToErp($supplier['supplier_id']);
}
}
}
//导出重复的供应商
public function findDuplicateSupplier()
{
$suppliers = \DB::connection('web')->select('SELECT a.* FROM lie_supplier_channel a INNER JOIN (SELECT supplier_name FROM lie_supplier_channel GROUP BY supplier_name HAVING COUNT(supplier_id) > 1) b ON a.supplier_name = b.supplier_name ORDER BY supplier_name DESC');
$header = [
'供应商编码',
'供应商名称',
'采购员列表',
];
$excelData = [];
foreach ($suppliers as $supplier) {
$allChannelUserName = '';
$channelUids = $supplier['channel_uid'] ? explode(',', $supplier['channel_uid']) : [];
if ($channelUids) {
$channelUsers = (new AdminUserService())->getAdminUserListByCodeIds($channelUids);
if (!empty($channelUsers)) {
$allChannelUserName = implode(',', array_column($channelUsers, 'name'));
}
}
$excelData[] = [
$supplier['supplier_code'],
$supplier['supplier_name'],
$allChannelUserName,
];
}
array_unshift($excelData, $header);
Excel::create('重复供应商导出', function ($excel) use ($excelData) {
$excel->sheet('sheet1', function ($sheet) use ($excelData) {
$sheet->fromArray($excelData);
});
})->export('xlsx');
}
}
......@@ -20,6 +20,11 @@ class SupplierValidator
//整理下请求数据
$validateData = $this->transformRequestData($validateData);
//这里还有个很特殊的校验,就是如果是代购供应商,就直接跳过校验
if (in_array($validateData['supplier_name'], config('field.SkipChangeSupplierTypeNames'))) {
return null;
}
//没有忽略校验的权限并且供应商地区属于内地和港台才会去校验天眼查
if (!checkPerm('IgnoreCompanyCheck') && in_array($validateData['region'],
config('field.NeedCheckCompanyRegion'))) {
......@@ -63,12 +68,8 @@ class SupplierValidator
}
$count = SupplierChannelModel::where('supplier_name', $validateData['supplier_name'])->count();
} else {
$count = SupplierChannelModel::where('supplier_name', $validateData['supplier_name'])
->where('supplier_id', '!=', $supplierId)->count();
//特殊处理下一些已经重复的供应商,历史数据问题
if (in_array($supplierId, config('field.NeedSkipSupplierNameCheckIds'))) {
$count = 0;
}
//对接一体化以后,名称不能修改了,所以直接为0
$count = 0;
}
if ($count) {
return "该供应商名称已经存在,请核验后再提交";
......@@ -271,12 +272,8 @@ class SupplierValidator
$companyNameCount = SupplierChannelModel::where('register_company_name',
$validateData['register_company_name'])->where('register_company_name', '!=', '')->count();
} else {
$count = SupplierChannelModel::where('supplier_name', $validateData['supplier_name'])
->where('supplier_id', '!=', $supplierId)->count();
//特殊处理下一些已经重复的供应商,历史数据问题
if (in_array($supplierId, config('field.NeedSkipSupplierNameCheckIds'))) {
$count = 0;
}
//对接一体化以后,名称不能修改了,所以直接为0
$count = 0;
}
if ($count) {
$errorMessageList[] = "该供应商名称已经存在,请核验后再提交";
......
......@@ -60,5 +60,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
Route::match(['get', 'post'], '/test', function () {
(new \App\Http\Services\DataService())->exportSuppliers();
// (new \App\Http\Services\DataService())->findDuplicateSupplier();
});
......@@ -169,6 +169,8 @@ return [
"深圳前海硬之城信息技术有限公司",
"北京京北通宇电子元件有限公司济南分公司",
"HYPERNET TECHNOLOGY (HONGKONG) CO.,LIMITED",
"CHIP ONE STOP (HONG KONG) LIMITED",
"RS COMPONENTS LIMITED",
],
'CompanyNature' => [
'其它' => '其它',
......@@ -179,16 +181,5 @@ return [
'分销平台' => '分销平台',
'代工厂' => '代工厂',
],
//需要跳过重复校验的供应商ID
'NeedSkipSupplierNameCheckIds' => [
2619,
7443,
195,
12263,
4983,
33,
3454,
2895
],
'NeedCheckCompanyRegion' => [2, 4]
];
\ 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