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
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
72 additions
and
42 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
...
@@ -38,7 +38,7 @@ class SetSupplierFollowUp extends Command
// $service->importSupplierGroup(true);
// $service->importSupplierGroup(true);
// $service->changeSupplierType();
// $service->changeSupplierType();
// $service->generateYunxinAccount(true);
// $service->generateYunxinAccount(true);
$service
->
importSupplierLevel
();
$service
->
exportSupplierForUnionData
();
// $service->makeSupplierSystemTagAbnormal();
// $service->makeSupplierSystemTagAbnormal();
}
}
}
}
app/Http/Services/DataService.php
View file @
a2af5d84
...
@@ -469,49 +469,69 @@ class DataService
...
@@ -469,49 +469,69 @@ class DataService
//导出供应商
//导出供应商
public
function
exportSupplierForUnionData
()
public
function
exportSupplierForUnionData
()
{
{
$suppliers
=
SupplierChannelModel
::
select
([
$suppliers
=
SupplierChannelModel
::
where
(
'is_type'
,
0
)
->
whereRaw
(
'supplier_name NOT LIKE "%-1"'
)
->
get
();
'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
();
$excelData
=
[];
$excelData
=
[];
$header
=
[
$header
=
[
'ID'
,
'供应商名称'
,
'原系统供应商名称'
,
'主营品牌'
,
'标准供应商名称'
,
'性质'
,
'创建时间'
,
'等级'
,
'采购'
,
'品质协议是否签署'
,
'部门组别'
,
'是否平台供应商'
,
'所有采购'
,
'是否云芯商家'
,
'是否SKU上架中'
,
'现有SKU采购员或者意向分配采购员'
,
'采购所在采购部门'
,
];
];
$intraCodeModel
=
new
IntracodeModel
();
$users
=
$intraCodeModel
->
getSampleName
(
true
);
foreach
(
$suppliers
as
$supplier
)
{
foreach
(
$suppliers
as
$supplier
)
{
$firstChannelUserName
=
$firstChannelUserDepartmentName
=
$allChannelUserName
=
''
;
$mainBrands
=
(
new
SupplierTransformer
())
->
getMainBrandNames
(
$supplier
[
'main_brands'
]);
$channelUids
=
$supplier
[
'channel_uid'
]
?
explode
(
','
,
$supplier
[
'channel_uid'
])
:
[];
$attachmentsField
=
SupplierAttachmentsModel
::
where
(
'supplier_id'
,
$supplier
[
'supplier_id'
])
->
pluck
(
'field_name'
)
->
toArray
();
if
(
$channelUids
)
{
$hasPinzhi
=
$hasHezuo
=
'无'
;
$channelUsers
=
(
new
AdminUserService
())
->
getAdminUserListByCodeIds
(
$channelUids
);
if
(
in_array
(
'quality_assurance_agreement'
,
$attachmentsField
))
{
if
(
!
empty
(
$channelUsers
))
{
$hasPinzhi
=
'有'
;
$firstChannelUser
=
$channelUsers
[
0
];
}
$firstChannelUserDepartmentName
=
(
new
DepartmentModel
())
->
where
(
'department_id'
,
if
(
in_array
(
'cooperation_agreement'
,
$attachmentsField
))
{
$firstChannelUser
[
'department_id'
])
$hasHezuo
=
'有'
;
->
value
(
'department_name'
);
}
$firstChannelUserName
=
$firstChannelUser
[
'name'
];
$isYunxin
=
'否'
;
$allChannelUserName
=
implode
(
','
,
array_column
(
$channelUsers
,
'name'
));
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
.
'(采购系统下单最多)'
;
}
}
}
$skuUserDepartment
=
''
;
if
(
$skuUserNameRaw
)
{
$skuUserDepartment
=
(
new
DepartmentService
())
->
getDepartmentNameByUserName
(
$skuUserNameRaw
);
}
}
$itemData
=
[
$itemData
=
[
$supplier
[
'supplier_id'
],
$supplier
[
'supplier_name'
],
$supplier
[
'supplier_name'
],
''
,
$mainBrands
,
$supplier
[
'create_time'
]
?
date
(
'Y-m-d H:i:s'
,
$supplier
[
'create_time'
])
:
''
,
array_get
(
config
(
'fixed.SupplierGroup'
),
$supplier
[
'supplier_group'
],
'未设置'
),
$firstChannelUserName
,
$supplier
[
'level'
],
$firstChannelUserDepartmentName
,
$hasPinzhi
,
$allChannelUserName
,
$hasHezuo
,
$isYunxin
,
$supplier
[
'sku_num'
]
>
0
?
"是"
:
"否"
,
$skuUserName
,
$skuUserDepartment
];
];
$excelData
[]
=
$itemData
;
$excelData
[]
=
$itemData
;
}
}
...
@@ -520,7 +540,7 @@ class DataService
...
@@ -520,7 +540,7 @@ class DataService
$excel
->
sheet
(
'sheet1'
,
function
(
$sheet
)
use
(
$excelData
)
{
$excel
->
sheet
(
'sheet1'
,
function
(
$sheet
)
use
(
$excelData
)
{
$sheet
->
fromArray
(
$excelData
);
$sheet
->
fromArray
(
$excelData
);
});
});
})
->
export
(
'csv'
);
})
->
store
(
'csv'
);
}
}
public
function
exportSupplierJsonForUnited
()
public
function
exportSupplierJsonForUnited
()
...
...
app/Http/Transformers/SupplierTransformer.php
View file @
a2af5d84
...
@@ -248,7 +248,7 @@ class SupplierTransformer
...
@@ -248,7 +248,7 @@ class SupplierTransformer
return
$supplier
;
return
$supplier
;
}
}
p
rivate
function
getMainBrandNames
(
$mainBrandsIds
)
p
ublic
function
getMainBrandNames
(
$mainBrandsIds
)
{
{
$mainBrandsIds
=
explode
(
','
,
$mainBrandsIds
);
$mainBrandsIds
=
explode
(
','
,
$mainBrandsIds
);
$redis
=
new
RedisModel
();
$redis
=
new
RedisModel
();
...
...
app/Http/routes.php
View file @
a2af5d84
...
@@ -63,7 +63,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
...
@@ -63,7 +63,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
});
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
Route
::
match
([
'get'
,
'post'
],
'/test'
,
function
()
{
\App\Model\SupplierChannelModel
::
where
(
'supplier_code'
,
'L0014845'
)
->
update
([
(
new
\App\Http\Services\DataService
())
->
exportSupplierForUnionData
();
'supplier_name'
=>
'HK GANGJIANXIANG TRADE CO LTD'
,
]);
});
});
app/Model/IntracodeModel.php
View file @
a2af5d84
...
@@ -79,6 +79,18 @@ class IntracodeModel extends Model
...
@@ -79,6 +79,18 @@ class IntracodeModel extends Model
return
$result
;
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
()
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