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
45b7f3c3
authored
May 16, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
导出供应商脚本
parent
588f2adb
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
117 additions
and
2 deletions
.env
app/Http/Services/DataService.php
app/Http/routes.php
config/database.php
storage/exports/采购供应商数据导出_自营采购部.xlsx
.env
View file @
45b7f3c3
...
@@ -76,6 +76,13 @@ DB_SPU_USERNAME=spu
...
@@ -76,6 +76,13 @@ DB_SPU_USERNAME=spu
DB_SPU_PASSWORD=spu
DB_SPU_PASSWORD=spu
DB_SPU_PORT=3306
DB_SPU_PORT=3306
#大数据数据库
DB_BIG_DATA_HOST=192.168.1.252
DB_BIG_DATA_DATABASE=dashboard
DB_BIG_DATA_USERNAME=bigdata
DB_BIG_DATA_PASSWORD=bigdata2019
DB_BIG_DATA_PORT=3306
CACHE_DRIVER=file
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=redis
QUEUE_DRIVER=redis
...
...
app/Http/Services/DataService.php
View file @
45b7f3c3
...
@@ -5,6 +5,7 @@ namespace App\Http\Services;
...
@@ -5,6 +5,7 @@ namespace App\Http\Services;
//后台用户相关信息服务
//后台用户相关信息服务
use
App\Http\Transformers\SupplierContactTransformer
;
use
App\Http\Transformers\SupplierContactTransformer
;
use
App\Http\Transformers\SupplierTransformer
;
use
App\Http\Transformers\SupplierTransformer
;
use
App\Model\BigData\DataManageModel
;
use
App\Model\DepartmentModel
;
use
App\Model\DepartmentModel
;
use
App\Model\IntracodeModel
;
use
App\Model\IntracodeModel
;
use
App\Model\LogModel
;
use
App\Model\LogModel
;
...
@@ -1012,7 +1013,7 @@ class DataService
...
@@ -1012,7 +1013,7 @@ class DataService
'purchase_amount'
,
'purchase_amount'
,
'exchange_rate'
,
'exchange_rate'
,
'currency'
'currency'
])
->
where
(
'status'
,
'!='
,
-
3
)
->
get
()
->
toArray
();
])
->
where
(
'status'
,
'!='
,
-
3
)
->
get
()
->
toArray
();
//计算出采购金额
//计算出采购金额
$totalAmount
=
0
;
$totalAmount
=
0
;
foreach
(
$purchaseOrders
as
$purchaseOrder
)
{
foreach
(
$purchaseOrders
as
$purchaseOrder
)
{
...
@@ -1045,4 +1046,98 @@ class DataService
...
@@ -1045,4 +1046,98 @@ class DataService
});
});
})
->
store
(
'csv'
);
})
->
store
(
'csv'
);
}
}
public
function
exportSupplierBySourceType
()
{
//找出所有大数据的供应商
$bigDataSuppliers
=
DataManageModel
::
where
(
'is_type'
,
0
)
->
get
()
->
toArray
();
//如果platform_type不等于6,都是API采集
//剩下的是普通采集的
$apiSourceSupplierCodeList
=
$paSourceSupplierCodeList
=
[];
foreach
(
$bigDataSuppliers
as
$supplier
)
{
if
(
$supplier
[
'platform_type'
]
!=
6
)
{
$apiSourceSupplierCodeList
[]
=
$supplier
[
'canal'
];
}
else
{
$paSourceSupplierCodeList
[]
=
$supplier
[
'canal'
];
}
}
$intraCodeModel
=
new
IntracodeModel
();
$users
=
$intraCodeModel
->
getSampleName
(
true
);
$header
=
[
'供应商编码'
,
'供应商名称'
,
'sku采购员'
,
'采购组别'
];
//导出sku接入方式为专营API
$excelData
=
[];
//导出sku接入方式为专营API
foreach
(
$apiSourceSupplierCodeList
as
$code
)
{
$supplier
=
SupplierChannelModel
::
where
(
'supplier_code'
,
$code
)
->
first
();
if
(
empty
(
$supplier
))
{
continue
;
}
$skuUserNameRaw
=
array_get
(
$users
,
$supplier
[
'yunxin_channel_uid'
]);
$supplier
=
$supplier
->
toArray
();
$departmentName
=
(
new
DepartmentService
())
->
getDepartmentNameByUserName
(
$skuUserNameRaw
);
$excelData
[]
=
[
$supplier
[
'supplier_code'
],
$supplier
[
'supplier_name'
],
$skuUserNameRaw
,
$departmentName
,
];
}
array_unshift
(
$excelData
,
$header
);
Excel
::
create
(
'sku接入方式为专营API'
,
function
(
$excel
)
use
(
$excelData
)
{
$excel
->
sheet
(
'sheet1'
,
function
(
$sheet
)
use
(
$excelData
)
{
$sheet
->
fromArray
(
$excelData
);
});
})
->
store
(
'csv'
);
//专营采集的供应商
$excelData
=
[];
foreach
(
$paSourceSupplierCodeList
as
$code
)
{
$supplier
=
SupplierChannelModel
::
where
(
'supplier_code'
,
$code
)
->
first
();
if
(
empty
(
$supplier
))
{
continue
;
}
$skuUserNameRaw
=
array_get
(
$users
,
$supplier
[
'yunxin_channel_uid'
]);
$supplier
=
$supplier
->
toArray
();
$departmentName
=
(
new
DepartmentService
())
->
getDepartmentNameByUserName
(
$skuUserNameRaw
);
$excelData
[]
=
[
$supplier
[
'supplier_code'
],
$supplier
[
'supplier_name'
],
$skuUserNameRaw
,
$departmentName
,
];
}
array_unshift
(
$excelData
,
$header
);
Excel
::
create
(
'专营采集的供应商'
,
function
(
$excel
)
use
(
$excelData
)
{
$excel
->
sheet
(
'sheet1'
,
function
(
$sheet
)
use
(
$excelData
)
{
$sheet
->
fromArray
(
$excelData
);
});
})
->
store
(
'csv'
);
//供应商性质为“分销平台”的有上传过sku的供应商
$excelData
=
[];
$uploadedSkuSuppliers
=
SupplierChannelModel
::
where
(
'supplier_group'
,
5
)
->
where
(
'is_type'
,
0
)
->
where
(
'uploaded_sku'
,
1
)
->
get
()
->
toArray
();
foreach
(
$uploadedSkuSuppliers
as
$code
)
{
$supplier
=
SupplierChannelModel
::
where
(
'supplier_code'
,
$code
)
->
first
();
if
(
empty
(
$supplier
))
{
continue
;
}
$skuUserNameRaw
=
array_get
(
$users
,
$supplier
[
'yunxin_channel_uid'
]);
$supplier
=
$supplier
->
toArray
();
$departmentName
=
(
new
DepartmentService
())
->
getDepartmentNameByUserName
(
$skuUserNameRaw
);
$excelData
[]
=
[
$supplier
[
'supplier_code'
],
$supplier
[
'supplier_name'
],
$skuUserNameRaw
,
$departmentName
,
];
}
array_unshift
(
$excelData
,
$header
);
Excel
::
create
(
'供应商性质为“分销平台”的有上传过sku的供应商'
,
function
(
$excel
)
use
(
$excelData
)
{
$excel
->
sheet
(
'sheet1'
,
function
(
$sheet
)
use
(
$excelData
)
{
$sheet
->
fromArray
(
$excelData
);
});
})
->
store
(
'csv'
);
}
}
}
\ No newline at end of file
app/Http/routes.php
View file @
45b7f3c3
...
@@ -67,5 +67,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
...
@@ -67,5 +67,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
});
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
// (new \App\Http\Services\DataService())->exportNotUploadSkuSupplier
();
(
new
\App\Http\Services\DataService
())
->
exportSupplierBySourceType
();
});
});
config/database.php
View file @
45b7f3c3
...
@@ -344,6 +344,18 @@ return [
...
@@ -344,6 +344,18 @@ return [
'prefix'
=>
'lie_'
,
'prefix'
=>
'lie_'
,
'strict'
=>
false
,
'strict'
=>
false
,
],
],
'big_data'
=>
[
'driver'
=>
'mysql'
,
'host'
=>
env
(
'DB_BIG_DATA_HOST'
,
''
),
'database'
=>
'dashboard'
,
'username'
=>
env
(
'DB_BIG_DATA_USERNAME'
,
''
),
'password'
=>
env
(
'DB_BIG_DATA_PASSWORD'
,
''
),
'port'
=>
env
(
'DB_BIG_DATA_PORT'
,
3306
),
'charset'
=>
'utf8'
,
'collation'
=>
'utf8_general_ci'
,
'prefix'
=>
'lie_'
,
'strict'
=>
false
,
],
'rabbitmq'
=>
[
'rabbitmq'
=>
[
'driver'
=>
'rabbitmq'
,
'driver'
=>
'rabbitmq'
,
'host'
=>
env
(
'RABBITMQ_HOST'
,
'127.0.0.1'
),
'host'
=>
env
(
'RABBITMQ_HOST'
,
'127.0.0.1'
),
...
...
storage/exports/采购供应商数据导出_自营采购部.xlsx
deleted
100644 → 0
View file @
588f2adb
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