Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_supplier
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d508e63f
authored
Dec 04, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修复脚本
parent
ed3f9331
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
7 deletions
app/Http/Services/DataService.php
app/Http/Transformers/SupplierTransformer.php
app/Http/function.php
app/Http/routes.php
app/Http/Services/DataService.php
View file @
d508e63f
...
...
@@ -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
//]);
}
}
}
}
}
}
app/Http/Transformers/SupplierTransformer.php
View file @
d508e63f
...
...
@@ -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
)
:
''
;
...
...
app/Http/function.php
View file @
d508e63f
...
...
@@ -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
;
}
app/Http/routes.php
View file @
d508e63f
...
...
@@ -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
(
);
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment