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
e5ce16e7
authored
Apr 23, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修改导出方式
parent
f257d8b6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
16 deletions
app/Http/Services/DataService.php
app/Http/Services/DataService.php
View file @
e5ce16e7
...
...
@@ -488,7 +488,8 @@ class DataService
$users
=
$intraCodeModel
->
getSampleName
(
true
);
foreach
(
$suppliers
as
$supplier
)
{
$mainBrands
=
(
new
SupplierTransformer
())
->
getMainBrandNames
(
$supplier
[
'main_brands'
]);
$attachmentsField
=
SupplierAttachmentsModel
::
where
(
'supplier_id'
,
$supplier
[
'supplier_id'
])
->
pluck
(
'field_name'
)
->
toArray
();
$attachmentsField
=
SupplierAttachmentsModel
::
where
(
'supplier_id'
,
$supplier
[
'supplier_id'
])
->
pluck
(
'field_name'
)
->
toArray
();
$hasPinzhi
=
$hasHezuo
=
'否'
;
if
(
in_array
(
'quality_assurance_agreement'
,
$attachmentsField
))
{
$hasPinzhi
=
'是'
;
...
...
@@ -498,7 +499,7 @@ class DataService
}
$isYunxin
=
'否'
;
if
(
$supplier
[
'stockup_type'
])
{
if
(
strpos
(
$supplier
[
'stockup_type'
],
"5"
)
!==
false
)
{
if
(
strpos
(
$supplier
[
'stockup_type'
],
"5"
)
!==
false
)
{
dump
(
"是云芯"
);
$isYunxin
=
'是'
;
}
...
...
@@ -507,18 +508,19 @@ class DataService
$skuUserName
=
$skuUserNameRaw
=
''
;
if
(
$supplier
[
'yunxin_channel_uid'
])
{
$skuUserNameRaw
=
array_get
(
$users
,
$supplier
[
'yunxin_channel_uid'
]);
$skuUserName
=
$skuUserNameRaw
.
'(供应商系统设置)'
;
}
else
{
$skuUserName
=
$skuUserNameRaw
.
'(供应商系统设置)'
;
}
else
{
//去采购系统找最多单的用户id
$mostPurchaseOrderUser
=
PurchaseOrderModel
::
selectRaw
(
'purchase_uid,supplier_id,COUNT(*) AS purchase_order_num'
)
->
where
(
'supplier_id'
,
$supplier
[
'supplier_id'
])
->
groupBy
(
'purchase_uid'
)
->
orderBy
(
'purchase_order_num'
,
'DESC'
)
->
first
();
->
where
(
'supplier_id'
,
$supplier
[
'supplier_id'
])
->
groupBy
(
'purchase_uid'
)
->
orderBy
(
'purchase_order_num'
,
'DESC'
)
->
first
();
if
(
!
empty
(
$mostPurchaseOrderUser
))
{
$mostPurchaseOrderUser
=
$mostPurchaseOrderUser
->
toArray
();
$codeId
=
IntracodeModel
::
where
(
'admin_id'
,
$mostPurchaseOrderUser
[
'purchase_uid'
])
->
value
(
'code_id'
);
$codeId
=
IntracodeModel
::
where
(
'admin_id'
,
$mostPurchaseOrderUser
[
'purchase_uid'
])
->
value
(
'code_id'
);
if
(
$codeId
)
{
$skuUserNameRaw
=
array_get
(
$users
,
$codeId
);
$skuUserName
=
$skuUserNameRaw
.
'(采购系统下单最多)'
;
$skuUserName
=
$skuUserNameRaw
.
'(采购系统下单最多)'
;
}
}
}
...
...
@@ -866,7 +868,7 @@ class DataService
if
(
$topDepartmentId
==
72
)
{
$append
=
'联营二部'
;
}
Excel
::
create
(
'采购供应商数据导出_'
.
$append
,
function
(
$excel
)
use
(
$topDepartmentId
)
{
Excel
::
create
(
'采购供应商数据导出_'
.
$append
,
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
=
[];
...
...
@@ -876,7 +878,7 @@ class DataService
foreach
(
$suppliersAll
as
$supplier
)
{
$createTime
=
date
(
'Y-m-d H:i:s'
,
$supplier
[
'create_time'
]);
$creatName
=
UserInfoModel
::
where
(
'userId'
,
$supplier
[
'create_uid'
])
->
value
(
'name'
);
$supplierGroup
=
array_get
(
config
(
'fixed.SupplierGroup'
),
$supplier
[
'supplier_group'
]);
$supplierGroup
=
array_get
(
config
(
'fixed.SupplierGroup'
),
$supplier
[
'supplier_group'
]);
$data
=
[
$creatName
,
$supplier
[
'supplier_name'
],
...
...
@@ -895,7 +897,7 @@ class DataService
}
$suppliersAllList
[]
=
$data
;
}
$header
=
[
'创建人'
,
'供应商名称'
,
'供应商性质'
,
'创建时间'
];
$header
=
[
'创建人'
,
'供应商名称'
,
'供应商性质'
,
'创建时间'
];
// dd($suppliersZhangQi,$header);
// $excel->sheet('2022年创建的供应商', function ($sheet) use ($header, $suppliers2022) {
// array_unshift($suppliers2022, $header);
...
...
@@ -934,22 +936,38 @@ class DataService
'创建时间'
,
'首次上传sku时间'
,
];
$users
=
(
new
IntracodeModel
())
->
getSampleEncode
(
true
);
$map
=
[
'source_type'
=>
'all'
,
'uploaded_sku'
=>
1
,
'is_export'
=>
1
,
'is_type'
=>
0
,
];
$suppliers
=
(
new
SupplierService
())
->
getSupplierList
(
$map
);
$transformer
=
new
SupplierTransformer
();
$suppliers
=
$transformer
->
transformList
(
$suppliers
);
$suppliers
=
SupplierChannelModel
::
where
(
'uploaded_sku'
,
1
)
->
where
(
'is_type'
,
0
)
->
whereRaw
(
'supplier_name NOT LIKE "%-1"'
)
->
get
()
->
toArray
();
//获取最近修改信息
$logModel
=
new
LogModel
();
$firstUploadSkuTimes
=
SkuService
::
getUploadTimeBySupplierCodes
(
array_column
(
$suppliers
,
'supplier_code'
),
'first'
);
foreach
(
$suppliers
as
$supplier
)
{
$log
=
$logModel
->
where
(
'supplier_id'
,
$supplier
[
'supplier_id'
])
->
where
(
'type'
,
LogModel
::
UPDATE_OPERATE
)
->
orderBy
(
'id'
,
'desc'
)
->
first
();
$supplier
[
'last_update_name'
]
=
$log
[
'admin_name'
]
?:
'无'
;
if
(
empty
(
$supplier
[
'create_name'
]))
{
$userInfo
=
(
new
AdminUserService
())
->
getAdminUserInfo
(
$supplier
[
'create_uid'
]);
$supplier
[
'create_name'
]
=
array_get
(
$userInfo
,
'name'
);
}
$supplier
[
'create_time'
]
=
$supplier
[
'create_time'
]
?
date
(
'Y-m-d H:i:s'
,
$supplier
[
'create_time'
])
:
''
;
$supplier
[
'first_upload_sku_time'
]
=
array_get
(
$firstUploadSkuTimes
,
$supplier
[
'supplier_code'
])
?
date
(
'Y-m-d H:i:s'
,
$firstUploadSkuTimes
[
$supplier
[
'supplier_code'
]])
:
''
;
$supplier
[
'supplier_group'
]
=
array_get
(
config
(
'fixed.SupplierGroup'
),
$supplier
[
'supplier_group'
],
'未设置'
);
$itemData
=
[
$supplier
[
'supplier_code'
],
$supplier
[
'supplier_name'
],
$supplier
[
'supplier_group'
],
$supplier
[
'channel_username'
]
,
$supplier
[
'yunxin_channel_username'
]
,
(
new
SupplierTransformer
())
->
getChannelUserNames
(
$supplier
[
'channel_uid'
])
,
array_get
(
$users
,
$supplier
[
'yunxin_channel_uid'
])
,
$supplier
[
'last_update_name'
],
$supplier
[
'create_name'
],
$supplier
[
'create_time'
],
...
...
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