Commit d508e63f by 杨树贤

修复脚本

parent ed3f9331
......@@ -1590,7 +1590,7 @@ class DataService
{
$redis = new RedisModel();
$cpTimeList = $redis->hgetall('supplier_sku_upload_ruler_v2');
foreach ($cpTimeList as $key =>$cpTime) {
foreach ($cpTimeList as $key => $cpTime) {
$cpTime = json_decode($cpTime, true);
if (empty($cpTime['upload_futures_goods_validity_period'])) {
$cpTime['upload_futures_goods_validity_period'] = 365;
......@@ -1615,7 +1615,7 @@ class DataService
$uploadRuler['futures_allow_moq_lte_0'] = 0;
$uploadRuler['futures_allow_price_null'] = 1;
$uploadRuler = json_encode($uploadRuler);
SupplierChannelModel::where('supplier_id',$supplier['supplier_id'])->update([
SupplierChannelModel::where('supplier_id', $supplier['supplier_id'])->update([
'sku_upload_ruler' => $uploadRuler,
]);
$redis->hset('supplier_sku_upload_ruler', $supplier['supplier_id'], $uploadRuler);
......@@ -1638,7 +1638,7 @@ class DataService
foreach ($brands as $brand) {
$redis->hset($prefixKey . 'brand', $brand['brand_id'], $brand['brand_name']);
$redis->hset($prefixKey . 'brand_info', $brand['brand_id'], json_encode($brand));
$redis->hset($prefixKey.'brand_name_all', md5(strtolower($brand['brand_name'])), $brand['brand_id']);
$redis->hset($prefixKey . 'brand_name_all', md5(strtolower($brand['brand_name'])), $brand['brand_id']);
}
//再去初始化标准品牌
......@@ -1667,4 +1667,42 @@ class DataService
]);
}
public function repairInvalidSpaceSupplierName()
{
$suppliers = SupplierChannelModel::where('is_type', 0)->select([
'supplier_name',
'supplier_id',
'tax_number',
'region'
])->get()->toArray();
foreach ($suppliers as $supplier) {
$oldSupplierName = $supplier['supplier_name'];
$supplier['supplier_name'] = replaceSpace($supplier['supplier_name']);
if ($oldSupplierName != $supplier['supplier_name']) {
dd($oldSupplierName,$supplier['supplier_name']);
}
continue;
$region = $supplier['region'];
$regionType = $region == SupplierChannelModel::REGION_CN ? 1 : 2;
$unitedCompanyInfo = (new CompanyService())->getUnitedCompanyInfo($supplier['supplier_name'], $supplier['tax_number'], $regionType);
$companyInfo = $unitedCompanyInfo['united_company_info'];
if (!empty($companyInfo)) {
$groupCode = array_get($companyInfo, 'group_code');
if ($groupCode) {
if ($oldSupplierName != $supplier['supplier_name']) {
dd($oldSupplierName,$supplier['supplier_name']);
continue;
//SupplierChannelModel::where('supplier_id', $supplier['supplier_id'])->update([
// 'supplier_name' => $supplier['supplier_name'],
// 'group_code' => $groupCode
//]);
}
}
}
}
}
}
......@@ -279,8 +279,8 @@ class SupplierTransformer
//转换表单数据
public function transformPostData($channel)
{
$channel['supplier_name'] = trim($channel['supplier_name']);
$channel['supplier_name'] = replaceSpace($channel['supplier_name']);
if (!empty($channel['stockup_type'])) {
$stockupType = array_keys($channel['stockup_type']);
$stockupType = !empty($stockupType) ? implode(",", $stockupType) : '';
......
......@@ -300,4 +300,13 @@ function getSpuSkuDb($id)
$data['table'] = 'spu_' . $tablecode;
}
return $data;
}
\ No newline at end of file
}
//去除特殊空格
function replaceSpace($str)
{
$str = str_replace(" ", " ", $str);
//头尾的空格去掉
$str = trim($str);
return $str;
}
......@@ -82,5 +82,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
Route::match(['get', 'post'], '/test', function () {
(new \App\Http\Services\SyncSupplierService())->receiveEntityResult('中山市汉仁电子有限公司',-2);
(new \App\Http\Services\DataService())->repairInvalidSpaceSupplierName();
});
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