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
bb99ccb0
authored
Jun 20, 2022
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
导出数据
parent
bed61d3a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
4 deletions
app/Console/Commands/SetSupplierFollowUp.php
app/Http/Services/AdminUserService.php
app/Http/Services/DataService.php
app/Http/routes.php
app/Console/Commands/SetSupplierFollowUp.php
View file @
bb99ccb0
...
...
@@ -38,7 +38,7 @@ class SetSupplierFollowUp extends Command
// $service->importSupplierGroup(true);
// $service->changeSupplierType();
// $service->generateYunxinAccount(true);
$service
->
dealYunxinAccountCreateTime
();
$service
->
exportSupplierForUnionData
();
// $service->makeSupplierSystemTagAbnormal();
}
}
app/Http/Services/AdminUserService.php
View file @
bb99ccb0
...
...
@@ -20,6 +20,14 @@ class AdminUserService
return
$userInfoModel
->
where
(
'userId'
,
$adminId
)
->
first
();
}
public
function
getAdminUserListByCodeIds
(
$codeIds
=
[])
{
$intraCodeModel
=
new
IntracodeModel
();
$userInfoModel
=
new
UserInfoModel
();
$adminIds
=
$intraCodeModel
->
whereIn
(
'code_id'
,
$codeIds
)
->
pluck
(
'admin_id'
);
return
$userInfoModel
->
whereIn
(
'userId'
,
$adminIds
)
->
get
()
->
toArray
();
}
public
function
getCodeIdByUserName
(
$userName
)
{
$userId
=
UserInfoModel
::
where
(
'name'
,
$userName
)
->
value
(
'userId'
);
...
...
@@ -54,7 +62,7 @@ class AdminUserService
{
$userInfoModel
=
new
UserInfoModel
();
$count
=
$userInfoModel
->
leftJoin
(
'lie_intracode'
,
'user_info.userId'
,
'='
,
'lie_intracode.admin_id'
)
->
where
(
'lie_intracode.code_id'
,
$codeId
)
->
where
(
'lie_intracode.code_id'
,
$codeId
)
->
where
(
'user_info.status'
,
4
)
->
where
(
'lie_intracode.code_id'
,
'!='
,
''
)
->
count
();
return
(
bool
)
$count
;
}
...
...
app/Http/Services/DataService.php
View file @
bb99ccb0
...
...
@@ -5,6 +5,7 @@ namespace App\Http\Services;
//后台用户相关信息服务
use
App\Http\Transformers\SupplierContactTransformer
;
use
App\Http\Transformers\SupplierTransformer
;
use
App\Model\DepartmentModel
;
use
App\Model\IntracodeModel
;
use
App\Model\LogModel
;
use
App\Model\RedisModel
;
...
...
@@ -436,6 +437,61 @@ class DataService
}
}
}
//导出供应商
public
function
exportSupplierForUnionData
()
{
$suppliers
=
SupplierChannelModel
::
select
([
'supplier_code'
,
'supplier_name'
,
'channel_uid'
,
])
->
where
(
'is_type'
,
0
)
->
whereRaw
(
'supplier_name NOT LIKE "%-1"'
)
->
get
();
$excelData
=
[];
$header
=
[
'供应商编码'
,
'供应商名称'
,
'创建时间'
,
'对应采购员'
,
'采购组别'
,
'所有采购员'
,
'系统来源'
,
];
foreach
(
$suppliers
as
$supplier
)
{
$firstChannelUserName
=
$firstChannelUserDepartmentName
=
$allChannelUserName
=
''
;
$channelUids
=
$supplier
[
'channel_uid'
]
?
explode
(
','
,
$supplier
[
'channel_uid'
])
:
[];
if
(
$channelUids
)
{
$channelUsers
=
(
new
AdminUserService
())
->
getAdminUserListByCodeIds
(
$channelUids
);
if
(
empty
(
$channelUsers
))
{
continue
;
}
$firstChannelUser
=
$channelUsers
[
0
];
$firstChannelUserDepartmentName
=
(
new
DepartmentModel
())
->
where
(
'department_id'
,
$firstChannelUser
[
'department_id'
])
->
value
(
'department_name'
);
$firstChannelUserName
=
$firstChannelUser
[
'name'
];
$allChannelUserName
=
implode
(
','
,
array_column
(
$channelUsers
,
'name'
));
}
$itemData
=
[
$supplier
[
'supplier_code'
],
$supplier
[
'supplier_name'
],
$supplier
[
'create_time'
]
?
date
(
'Y-m-d H:i:s'
,
$supplier
[
'create_time'
])
:
''
,
$firstChannelUserName
,
$firstChannelUserDepartmentName
,
$allChannelUserName
,
'科技'
,
];
$excelData
[]
=
$itemData
;
}
array_unshift
(
$excelData
,
$header
);
Excel
::
create
(
'供应商导出'
,
function
(
$excel
)
use
(
$excelData
)
{
$excel
->
sheet
(
'sheet1'
,
function
(
$sheet
)
use
(
$excelData
)
{
$sheet
->
fromArray
(
$excelData
);
});
})
->
export
(
'xlsx'
);
}
}
app/Http/routes.php
View file @
bb99ccb0
...
...
@@ -54,6 +54,5 @@ Route::group(['middleware' => ['external'],'namespace' => 'Api'], function () {
});
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
$departmentService
=
new
DepartmentService
();
$subordinateUserIds
=
$departmentService
->
getSubordinateUserIds
(
1368
);
(
new
\App\Http\Services\DataService
())
->
exportSupplierForUnionData
();
});
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