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
35973847
authored
Oct 16, 2024
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
重名供应商导出
parent
839e74cd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
30 deletions
app/Http/Services/DataService.php
app/Http/routes.php
app/Http/Services/DataService.php
View file @
35973847
...
...
@@ -635,21 +635,33 @@ class DataService
public
static
function
exportNameInvalid
()
{
$suppliers
=
DB
::
connection
(
'web'
)
->
select
(
'SELECT *, count(*) FROM lie_supplier_channel WHERE is_type=0 and group_code != "" GROUP BY supplier_name having count(*) > 1'
);
foreach
(
$suppliers
as
$supplier
)
{
}
$supplierNameList
=
array_column
(
$suppliers
,
'supplier_name'
);
$suppliers
=
SupplierChannelModel
::
whereIn
(
'supplier_name'
,
$supplierNameList
)
->
orderBy
(
'supplier_name'
,
'desc'
)
->
get
()
->
toArray
();
$transformer
=
new
SupplierTransformer
();
$suppliers
=
$transformer
->
transformList
(
$suppliers
);
Excel
::
create
(
'重名供应商导出'
,
function
(
$excel
)
use
(
$suppliers
)
{
$header
=
[
'供应商名字'
,
'供应商编码'
,
'集团编码'
,
'供应商名字'
,
'状态'
,
'供应商性质'
,
'采购员'
,
'线上采购员'
,
'最新上传SKU时间'
,
];
$excelData
=
[];
foreach
(
$suppliers
as
$supplier
)
{
$excelData
[]
=
[
$supplier
[
'supplier_name'
],
$supplier
[
'supplier_code'
],
$supplier
[
'group_code'
],
$supplier
[
'status_name'
],
$supplier
[
'supplier_group'
],
$supplier
[
'channel_username'
],
$supplier
[
'yunxin_channel_username'
],
$supplier
[
'last_upload_sku_time'
],
];
}
array_unshift
(
$excelData
,
$header
);
...
...
@@ -657,7 +669,7 @@ class DataService
$sheet
->
fromArray
(
$excelData
);
});
})
->
export
(
'
csv
'
);
})
->
export
(
'
xlsx
'
);
}
public
static
function
getSpuAttrs
()
...
...
@@ -672,33 +684,32 @@ class DataService
ini_set
(
'memory_limit'
,
'2048M'
);
$filePath
=
public_path
(
'data'
)
.
DIRECTORY_SEPARATOR
.
'爱智平台SKU汇总表-2024.09.19.xlsx'
;
Excel
::
selectSheetsByIndex
(
0
)
->
load
(
$filePath
,
function
(
$reader
)
use
(
$isUpdate
)
{
$reader
->
sheet
(
'细分商品分类'
,
function
()
use
(
$reader
,
$isUpdate
)
{
foreach
(
$reader
->
all
()
->
toArray
()
as
$key
=>
$item
)
{
if
(
$key
==
0
||
$key
>
100
)
{
continue
;
}
$skuId
=
trim
(
trim
(
$item
[
1
]),
"
\t
"
);
$oldSkuName
=
trim
(
trim
(
$item
[
2
],
"
\t
"
));
$newSkuName
=
trim
(
trim
(
$item
[
3
],
"
\t
"
));
dump
(
$skuId
,
$oldSkuName
,
$newSkuName
);
//直接去修改sku的sku_name
$dbInfo
=
getSpuSkuDb
(
$skuId
);
$connection
=
DB
::
connection
(
$dbInfo
[
"db"
]);
$table
=
$dbInfo
[
'table'
];
$skuName
=
$connection
->
table
(
$table
)
->
where
(
'goods_id'
,
$skuId
)
->
value
(
'goods_name'
);
if
(
empty
(
$skuName
))
{
dump
(
'sku_id找不到'
);
}
dump
(
$skuName
);
Excel
::
selectSheetsByIndex
(
0
)
->
load
(
$filePath
,
function
(
$reader
)
use
(
$isUpdate
)
{
$reader
->
sheet
(
'细分商品分类'
,
function
()
use
(
$reader
,
$isUpdate
)
{
foreach
(
$reader
->
all
()
->
toArray
()
as
$key
=>
$item
)
{
if
(
$key
==
0
||
$key
>
100
)
{
continue
;
}
});
$skuId
=
trim
(
trim
(
$item
[
1
]),
"
\t
"
);
$oldSkuName
=
trim
(
trim
(
$item
[
2
],
"
\t
"
));
$newSkuName
=
trim
(
trim
(
$item
[
3
],
"
\t
"
));
dump
(
$skuId
,
$oldSkuName
,
$newSkuName
);
//直接去修改sku的sku_name
$dbInfo
=
getSpuSkuDb
(
$skuId
);
$connection
=
DB
::
connection
(
$dbInfo
[
"db"
]);
$table
=
$dbInfo
[
'table'
];
$skuName
=
$connection
->
table
(
$table
)
->
where
(
'goods_id'
,
$skuId
)
->
value
(
'goods_name'
);
if
(
empty
(
$skuName
))
{
dump
(
'sku_id找不到'
);
}
dump
(
$skuName
);
}
});
});
}
}
app/Http/routes.php
View file @
35973847
...
...
@@ -84,6 +84,7 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
\App\Http\Services\DataService
::
exportNameInvalid
();
//$goodsId = request()->input('goods_id');
//if (empty($goodsId)) {
// return 'goods id null';
...
...
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