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
a2af5d84
authored
Apr 19, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
供应商导出
parent
c137e3cd
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
43 deletions
app/Console/Commands/SetSupplierFollowUp.php
app/Http/Services/DataService.php
app/Http/Transformers/SupplierTransformer.php
app/Http/routes.php
app/Model/IntracodeModel.php
storage/exports/供应商导出.csv
app/Console/Commands/SetSupplierFollowUp.php
View file @
a2af5d84
...
...
@@ -38,7 +38,7 @@ class SetSupplierFollowUp extends Command
// $service->importSupplierGroup(true);
// $service->changeSupplierType();
// $service->generateYunxinAccount(true);
$service
->
importSupplierLevel
();
$service
->
exportSupplierForUnionData
();
// $service->makeSupplierSystemTagAbnormal();
}
}
app/Http/Services/DataService.php
View file @
a2af5d84
...
...
@@ -469,49 +469,69 @@ class DataService
//导出供应商
public
function
exportSupplierForUnionData
()
{
$suppliers
=
SupplierChannelModel
::
select
([
'supplier_id'
,
'supplier_code'
,
'supplier_name'
,
'channel_uid'
,
'create_time'
,
])
->
where
(
'is_type'
,
0
)
->
where
(
'create_time'
,
'>'
,
1655778780
)
->
where
(
'update_time'
,
'>'
,
1655778780
)
->
where
(
'group_code'
,
'!='
,
''
)
->
whereRaw
(
'supplier_name NOT LIKE "%-1"'
)
->
get
();
$suppliers
=
SupplierChannelModel
::
where
(
'is_type'
,
0
)
->
whereRaw
(
'supplier_name NOT LIKE "%-1"'
)
->
get
();
$excelData
=
[];
$header
=
[
'ID'
,
'原系统供应商名称'
,
'标准供应商名称'
,
'创建时间'
,
'采购'
,
'部门组别'
,
'所有采购'
,
'供应商名称'
,
'主营品牌'
,
'性质'
,
'等级'
,
'品质协议是否签署'
,
'是否平台供应商'
,
'是否云芯商家'
,
'是否SKU上架中'
,
'现有SKU采购员或者意向分配采购员'
,
'采购所在采购部门'
,
];
$intraCodeModel
=
new
IntracodeModel
();
$users
=
$intraCodeModel
->
getSampleName
(
true
);
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
))
{
$firstChannelUser
=
$channelUsers
[
0
];
$firstChannelUserDepartmentName
=
(
new
DepartmentModel
())
->
where
(
'department_id'
,
$firstChannelUser
[
'department_id'
])
->
value
(
'department_name'
);
$firstChannelUserName
=
$firstChannelUser
[
'name'
];
$allChannelUserName
=
implode
(
','
,
array_column
(
$channelUsers
,
'name'
));
$mainBrands
=
(
new
SupplierTransformer
())
->
getMainBrandNames
(
$supplier
[
'main_brands'
]);
$attachmentsField
=
SupplierAttachmentsModel
::
where
(
'supplier_id'
,
$supplier
[
'supplier_id'
])
->
pluck
(
'field_name'
)
->
toArray
();
$hasPinzhi
=
$hasHezuo
=
'无'
;
if
(
in_array
(
'quality_assurance_agreement'
,
$attachmentsField
))
{
$hasPinzhi
=
'有'
;
}
if
(
in_array
(
'cooperation_agreement'
,
$attachmentsField
))
{
$hasHezuo
=
'有'
;
}
$isYunxin
=
'否'
;
if
(
str_contains
(
"5"
,
$supplier
[
'stockup_type'
]))
{
$isYunxin
=
'是'
;
}
$skuUserName
=
$skuUserNameRaw
=
''
;
if
(
$supplier
[
'yunxin_channel_uid'
])
{
$skuUserNameRaw
=
array_get
(
$users
,
$supplier
[
'yunxin_channel_uid'
]);
$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
();
if
(
!
empty
(
$mostPurchaseOrderUser
))
{
$mostPurchaseOrderUser
=
$mostPurchaseOrderUser
->
toArray
();
$codeId
=
IntracodeModel
::
where
(
'admin_id'
,
$mostPurchaseOrderUser
[
'purchase_uid'
])
->
value
(
'code_id'
);
if
(
$codeId
)
{
$skuUserNameRaw
=
array_get
(
$users
,
$codeId
);
$skuUserName
=
$skuUserNameRaw
.
'(采购系统下单最多)'
;
}
}
}
$itemData
=
[
$supplier
[
'supplier_id'
],
$supplier
[
'supplier_name'
],
''
,
$supplier
[
'create_time'
]
?
date
(
'Y-m-d H:i:s'
,
$supplier
[
'create_time'
])
:
''
,
$firstChannelUserName
,
$firstChannelUserDepartmentName
,
$allChannelUserName
,
$skuUserDepartment
=
''
;
if
(
$skuUserNameRaw
)
{
$skuUserDepartment
=
(
new
DepartmentService
())
->
getDepartmentNameByUserName
(
$skuUserNameRaw
);
}
$itemData
=
[
$supplier
[
'supplier_name'
],
$mainBrands
,
array_get
(
config
(
'fixed.SupplierGroup'
),
$supplier
[
'supplier_group'
],
'未设置'
),
$supplier
[
'level'
],
$hasPinzhi
,
$hasHezuo
,
$isYunxin
,
$supplier
[
'sku_num'
]
>
0
?
"是"
:
"否"
,
$skuUserName
,
$skuUserDepartment
];
$excelData
[]
=
$itemData
;
}
...
...
@@ -520,7 +540,7 @@ class DataService
$excel
->
sheet
(
'sheet1'
,
function
(
$sheet
)
use
(
$excelData
)
{
$sheet
->
fromArray
(
$excelData
);
});
})
->
export
(
'csv'
);
})
->
store
(
'csv'
);
}
public
function
exportSupplierJsonForUnited
()
...
...
app/Http/Transformers/SupplierTransformer.php
View file @
a2af5d84
...
...
@@ -248,7 +248,7 @@ class SupplierTransformer
return
$supplier
;
}
p
rivate
function
getMainBrandNames
(
$mainBrandsIds
)
p
ublic
function
getMainBrandNames
(
$mainBrandsIds
)
{
$mainBrandsIds
=
explode
(
','
,
$mainBrandsIds
);
$redis
=
new
RedisModel
();
...
...
app/Http/routes.php
View file @
a2af5d84
...
...
@@ -63,7 +63,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
\App\Model\SupplierChannelModel
::
where
(
'supplier_code'
,
'L0014845'
)
->
update
([
'supplier_name'
=>
'HK GANGJIANXIANG TRADE CO LTD'
,
]);
(
new
\App\Http\Services\DataService
())
->
exportSupplierForUnionData
();
});
app/Model/IntracodeModel.php
View file @
a2af5d84
...
...
@@ -79,6 +79,18 @@ class IntracodeModel extends Model
return
$result
;
}
//获取简单的内部用户数据
//默认不包含离职的
public
function
getSampleName
(
$includeResigned
=
false
)
{
$codeList
=
$this
->
getEncode
(
$includeResigned
);
$result
=
[];
foreach
(
$codeList
as
$code
)
{
$result
[
$code
[
'code_id'
]]
=
$code
[
'name'
];
}
return
$result
;
}
//获取简单的内部用户数据(包含离职)
public
function
getAllSampleEncode
()
{
...
...
storage/exports/供应商导出.csv
0 → 100644
View file @
a2af5d84
This diff could not be displayed because it is too large.
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