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
4e9cfcf8
authored
Sep 23, 2021
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix
parent
7ad79a80
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
5 deletions
app/Console/Commands/SetSupplierFollowUp.php
app/Http/Services/DataService.php
app/Http/routes.php
config/fixed.php
public/data/supplier_main_brand.xlsx
app/Console/Commands/SetSupplierFollowUp.php
View file @
4e9cfcf8
...
...
@@ -31,6 +31,6 @@ class SetSupplierFollowUp extends Command
public
function
handle
()
{
$service
=
new
DataService
();
$service
->
import
SupplierLevel
();
$service
->
import
MainBrandData
();
}
}
app/Http/Services/DataService.php
View file @
4e9cfcf8
...
...
@@ -8,6 +8,7 @@ use App\Http\Transformers\SupplierTransformer;
use
App\Model\IntracodeModel
;
use
App\Model\LogModel
;
use
App\Model\RedisModel
;
use
App\Model\StandardBrandModel
;
use
App\Model\SupplierAttachmentModel
;
use
App\Model\SupplierChannelModel
;
use
App\Model\SupplierContactModel
;
...
...
@@ -297,8 +298,6 @@ class DataService
{
$filePath
=
public_path
(
'data'
)
.
DIRECTORY_SEPARATOR
.
'supplier_level.xls'
;
try
{
// $excelData = Excel::load($filePath)->getSheet(0)->toArray();
// dd($excelData);
Excel
::
selectSheetsByIndex
(
0
)
->
load
(
$filePath
,
function
(
$reader
)
{
$supplierChannelModel
=
new
SupplierChannelModel
();
$reader
->
sheet
(
'供应商清单'
,
function
(
$sheet
)
use
(
$reader
,
$supplierChannelModel
)
{
...
...
@@ -331,7 +330,45 @@ class DataService
}
catch
(
\Exception
$exception
)
{
var_dump
(
$exception
);
}
}
//导入主营品牌数据
public
function
importMainBrandData
()
{
$filePath
=
public_path
(
'data'
)
.
DIRECTORY_SEPARATOR
.
'supplier_main_brand.xlsx'
;
try
{
Excel
::
selectSheetsByIndex
(
0
)
->
load
(
$filePath
,
function
(
$reader
)
{
$reader
->
sheet
(
'产出'
,
function
()
use
(
$reader
)
{
$supplierMainBrandData
=
[];
$standardBrandModel
=
new
StandardBrandModel
();
foreach
(
$reader
->
all
()
->
toArray
()
as
$key
=>
$item
)
{
$supplierName
=
trim
(
$item
[
0
]);
$brandName
=
$item
[
1
];
$brandId
=
$standardBrandModel
->
where
(
'brand_name'
,
trim
(
$brandName
))
->
value
(
'standard_brand_id'
);
if
(
empty
(
$brandId
))
{
continue
;
}
if
(
!
isset
(
$supplierMainBrandData
[
$supplierName
]))
{
$supplierMainBrandData
[
$supplierName
][]
=
$brandId
;
}
else
{
$supplierMainBrandData
[
$supplierName
][]
=
$brandId
;
}
}
$supplierModel
=
new
SupplierChannelModel
();
foreach
(
$supplierMainBrandData
as
$supplierName
=>
$mainBrandIds
)
{
$result
=
$supplierModel
->
where
(
'supplier_name'
,
$supplierName
)
->
update
([
'main_brands'
=>
implode
(
','
,
$mainBrandIds
),
]);
if
(
$result
)
{
var_dump
(
'更新供应商主营品牌成功,供应商 : '
.
$supplierName
);
}
}
});
});
}
catch
(
\Exception
$exception
)
{
var_dump
(
$exception
);
}
}
}
...
...
app/Http/routes.php
View file @
4e9cfcf8
...
...
@@ -46,7 +46,7 @@ Route::match(['get', 'post'], '/test', function () {
$service
=
new
\App\Http\Services\DataService
();
// $service->pushSupplierSKu();
// $service->makeSupplierSystemTag();
$service
->
import
SupplierLevel
();
$service
->
import
MainBrandData
();
// $service->transferFileData();
// $service->changeSupplierIsTypeByCheckChannelUidOrPurchaseUid();
// $service->replaceStandardBrandId();
...
...
config/fixed.php
View file @
4e9cfcf8
...
...
@@ -82,7 +82,7 @@ return [
7
=>
'原厂直供'
,
2
=>
'猎芯仓库'
,
4
=>
'现货寄售'
,
5
=>
'
猎芯期货
'
,
5
=>
'
云芯商家
'
,
],
'SupplierPayType'
=>
[
...
...
public/data/supplier_main_brand.xlsx
0 → 100644
View file @
4e9cfcf8
No preview for this file type
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