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
03d412a7
authored
Jul 08, 2022
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'master' into ysx-供应商新建-20220701
parents
e79fedb2
c4e86d79
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
13 deletions
app/Http/Services/DataService.php
app/Http/routes.php
app/Http/Services/DataService.php
View file @
03d412a7
...
...
@@ -16,6 +16,7 @@ use App\Model\SupplierAttachmentsModel;
use
App\Model\SupplierChannelModel
;
use
App\Model\SupplierContactModel
;
use
App\Model\SupplierPayTypeModel
;
use
App\Model\UserInfoModel
;
use
Carbon\Carbon
;
use
GuzzleHttp\Client
;
use
GuzzleHttp\RequestOptions
;
...
...
@@ -662,18 +663,6 @@ class DataService
}
}
public
function
reSyncSupplierToErp
()
{
ini_set
(
'memory_limit'
,
-
1
);
$suppliers
=
SupplierChannelModel
::
select
([
'supplier_id'
,
'supplier_name'
])
->
where
(
'is_type'
,
0
)
->
where
(
'status'
,
2
)
->
offset
(
200
)
->
limit
(
200
)
->
get
()
->
toArray
();
foreach
(
$suppliers
as
$supplier
)
{
if
(
!
empty
(
$supplier
[
'supplier_name'
]))
{
echo
"同步供应商到金蝶 : "
.
$supplier
[
'supplier_name'
]
.
PHP_EOL
;
(
new
SyncSupplierService
())
->
syncSupplierToErp
(
$supplier
[
'supplier_id'
]);
}
}
}
//导出重复的供应商
public
function
findDuplicateSupplier
()
...
...
@@ -708,5 +697,50 @@ class DataService
});
})
->
export
(
'xlsx'
);
}
public
function
exportHalfYearSupplier
()
{
$starTime
=
Carbon
::
now
()
->
startOfYear
()
->
timestamp
;
$suppliers
=
SupplierChannelModel
::
where
(
'create_time'
,
'>='
,
$starTime
)
->
select
([
'supplier_name'
,
'supplier_code'
,
'create_uid'
,
])
->
get
();
$excelData
=
[];
$header
=
[
'供应商名字'
,
'编码'
,
'建档采购员'
,
'采购主管'
,
];
foreach
(
$suppliers
as
$supplier
)
{
$supervisor
=
''
;
$user
=
UserInfoModel
::
where
(
'userId'
,
$supplier
[
'create_uid'
])
->
first
();
$user
=
!
empty
(
$user
)
?
$user
->
toArray
()
:
[];
$supervisorDepartmentId
=
$user
[
'department_id'
];
$positionId
=
\DB
::
table
(
'user_position'
)
->
where
(
'department_id'
,
$supervisorDepartmentId
)
->
where
(
'position_name'
,
'采购总监'
)
->
value
(
'position_id'
);
if
(
empty
(
$positionId
))
{
$positionId
=
\DB
::
table
(
'user_position'
)
->
where
(
'position_name'
,
'运营总监'
)
->
value
(
'position_id'
);
}
$supervisor
=
UserInfoModel
::
where
(
'position_id'
,
$positionId
)
->
value
(
'name'
);
$excelData
[]
=
[
$supplier
[
'supplier_name'
],
$supplier
[
'supplier_code'
],
array_get
(
$user
,
'name'
),
$supervisor
,
];
}
array_unshift
(
$excelData
,
$header
);
dd
(
$excelData
);
Excel
::
create
(
'2022年新建供应商导出'
,
function
(
$excel
)
use
(
$excelData
)
{
$excel
->
sheet
(
'sheet1'
,
function
(
$sheet
)
use
(
$excelData
)
{
$sheet
->
fromArray
(
$excelData
);
});
})
->
export
(
'csv'
);
}
}
app/Http/routes.php
View file @
03d412a7
...
...
@@ -60,5 +60,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
// (new \App\Http\Services\DataService())->findDuplicate
Supplier();
(
new
\App\Http\Services\DataService
())
->
exportHalfYear
Supplier
();
});
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