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
69530911
authored
Feb 01, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
导出供应商脚本
parent
38ccd26c
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
6 deletions
app/Http/Services/DataService.php
app/Http/routes.php
vendor/_laravel_idea/_ide_helper_facades.php
app/Http/Services/DataService.php
View file @
69530911
...
...
@@ -830,12 +830,49 @@ class DataService
}
}
public
function
repairData
(
)
public
static
function
exportSupplierByDepartment
(
$topDepartmentId
)
{
dd
(
SupplierChannelModel
::
where
(
'supplier_id'
,
13854
)
->
first
());
SupplierChannelModel
::
where
(
'supplier_id'
,
13854
)
->
update
([
'status'
=>
SupplierChannelModel
::
STATUS_IN_REVIEW
,
'update_time'
=>
time
()
]);
Excel
::
create
(
'采购供应商数据导出'
,
function
(
$excel
)
use
(
$topDepartmentId
)
{
$departmentIds
=
DepartmentModel
::
where
(
'parent_id'
,
$topDepartmentId
)
->
pluck
(
'department_id'
)
->
toArray
();
$userIds
=
UserInfoModel
::
whereIn
(
'department_id'
,
$departmentIds
)
->
pluck
(
'userId'
)
->
toArray
();
$suppliers2022
=
$suppliersZhangQi2022
=
$suppliersAll
=
$suppliersZhangQi
=
[];
//找出相关用户创建的所有供应商
$suppliersAll
=
SupplierChannelModel
::
whereIn
(
'create_uid'
,
$userIds
)
->
where
(
'is_type'
,
0
)
->
get
()
->
toArray
();
foreach
(
$suppliersAll
as
$supplier
)
{
$createTime
=
date
(
'Y-m-d H:i:s'
,
$supplier
[
'create_time'
]);
$creatName
=
UserInfoModel
::
where
(
'userId'
,
$supplier
[
'create_uid'
])
->
value
(
'name'
);
$data
=
[
$creatName
,
$supplier
[
'supplier_name'
],
$createTime
,
];
if
(
$supplier
[
'create_time'
]
>=
1640966400
-
3600
*
24
*
365
)
{
$suppliers2022
[]
=
$data
;
if
(
$supplier
[
'pay_type'
]
==
1
)
{
$suppliersZhangQi2022
[]
=
$data
;
}
}
if
(
$supplier
[
'pay_type'
]
==
1
)
{
$suppliersZhangQi
[]
=
$data
;
}
}
$header
=
[
'创建人'
,
'供应商名称'
,
'创建时间'
];
// dd($suppliersZhangQi,$header);
$excel
->
sheet
(
'2022年创建的供应商'
,
function
(
$sheet
)
use
(
$header
,
$suppliers2022
)
{
array_unshift
(
$suppliers2022
,
$header
);
$sheet
->
fromArray
(
$suppliers2022
);
});
$excel
->
sheet
(
'2022年创建的账期供应商'
,
function
(
$sheet
)
use
(
$header
,
$suppliersZhangQi2022
)
{
array_unshift
(
$suppliersZhangQi2022
,
$header
);
$sheet
->
fromArray
(
$suppliersZhangQi2022
);
});
$excel
->
sheet
(
'全部账期供应商'
,
function
(
$sheet
)
use
(
$header
,
$suppliersZhangQi
)
{
array_unshift
(
$suppliersZhangQi
,
$header
);
$sheet
->
fromArray
(
$suppliersZhangQi
);
});
})
->
export
(
'xlsx'
);
}
}
\ No newline at end of file
app/Http/routes.php
View file @
69530911
...
...
@@ -63,4 +63,9 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
$departmentId
=
request
()
->
input
(
'department_id'
);
if
(
empty
(
$departmentId
))
{
return
'部门id不能为空'
;
}
\App\Http\Services\DataService
::
exportSupplierByDepartment
(
$departmentId
);
});
vendor/_laravel_idea/_ide_helper_facades.php
View file @
69530911
This diff is collapsed.
Click to expand it.
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