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
b2f59072
authored
Mar 02, 2026
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
优化设置
parent
6a18da4f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
36 deletions
app/Http/Controllers/Api/SupplierContactApiController.php
app/Http/Services/SupplierService.php
resources/views/script/supplier/SupplierContactScript.blade.php
app/Http/Controllers/Api/SupplierContactApiController.php
View file @
b2f59072
...
@@ -129,48 +129,74 @@ class SupplierContactApiController extends Controller
...
@@ -129,48 +129,74 @@ class SupplierContactApiController extends Controller
public
function
DeleteSupplierContact
(
$request
)
public
function
DeleteSupplierContact
(
$request
)
{
{
$contactId
=
$request
->
get
(
'contact_id'
);
$contactId
=
$request
->
get
(
'contact_id'
);
if
(
$contactId
)
{
if
(
empty
(
$contactId
))
{
$model
=
new
SupplierContactModel
();
$this
->
response
(
-
1
,
'请选择要删除的联系人'
);
$contact
=
$model
->
where
(
'contact_id'
,
$contactId
)
->
first
();
}
$contactCount
=
$model
->
where
(
'supplier_id'
,
$contact
[
'supplier_id'
])
->
count
();
if
(
$contactCount
==
1
)
{
// 支持批量删除,contact_id可以是数组或单个值
$contactIds
=
is_array
(
$contactId
)
?
$contactId
:
[
$contactId
];
$model
=
new
SupplierContactModel
();
$contacts
=
$model
->
whereIn
(
'contact_id'
,
$contactIds
)
->
get
();
if
(
$contacts
->
isEmpty
())
{
$this
->
response
(
-
1
,
'找不到删除对象'
);
}
// 按供应商分组处理
$groupedContacts
=
$contacts
->
groupBy
(
'supplier_id'
);
foreach
(
$groupedContacts
as
$supplierId
=>
$supplierContacts
)
{
// 检查删除后是否至少还有一个联系人
$remainingCount
=
$model
->
where
(
'supplier_id'
,
$supplierId
)
->
whereNotIn
(
'contact_id'
,
$contactIds
)
->
count
();
if
(
$remainingCount
<
1
)
{
$this
->
response
(
-
1
,
'供应商至少要有一个联系方式'
);
$this
->
response
(
-
1
,
'供应商至少要有一个联系方式'
);
}
}
//从主表里面删除对应的采购
//先去判断这个采购是不是唯一的
// 处理每个联系人对应的采购员
$canCheckUids
=
$contact
[
'can_check_uids'
];
foreach
(
$supplierContacts
as
$contact
)
{
$userNum
=
$model
->
where
(
'supplier_id'
,
$contact
[
'supplier_id'
])
->
where
(
$canCheckUids
=
$contact
[
'can_check_uids'
];
'can_check_uids'
,
$userNum
=
$model
->
where
(
'supplier_id'
,
$supplierId
)
$canCheckUids
->
where
(
'can_check_uids'
,
$canCheckUids
)
)
->
count
();
->
whereNotIn
(
'contact_id'
,
$contactIds
)
if
(
$userNum
===
1
)
{
->
count
();
//如果只有一个,那就可以去主表删除对应的采购员了
$supplierModel
=
new
SupplierChannelModel
();
if
(
$userNum
===
0
)
{
$supplier
=
$supplierModel
->
where
(
'supplier_id'
,
$contact
[
'supplier_id'
])
->
first
();
// 删除后没有其他联系人使用这个采购员,从主表删除
$channelUid
=
explode
(
','
,
$supplier
[
'channel_uid'
]);
$supplierModel
=
new
SupplierChannelModel
();
if
(
in_array
(
$canCheckUids
,
$channelUid
))
{
$supplier
=
$supplierModel
->
where
(
'supplier_id'
,
$supplierId
)
->
first
();
//删除
$channelUid
=
explode
(
','
,
$supplier
[
'channel_uid'
]);
$channelUid
=
array_filter
(
$channelUid
,
function
(
$value
)
use
(
$canCheckUids
)
{
if
(
in_array
(
$canCheckUids
,
$channelUid
))
{
return
$value
!=
$canCheckUids
;
$channelUid
=
array_filter
(
$channelUid
,
function
(
$value
)
use
(
$canCheckUids
)
{
});
return
$value
!=
$canCheckUids
;
$supplierModel
->
where
(
'supplier_id'
,
$contact
[
'supplier_id'
])
->
update
([
});
'channel_uid'
=>
implode
(
','
,
$channelUid
),
$supplierModel
->
where
(
'supplier_id'
,
$supplierId
)
->
update
([
'update_time'
=>
time
(),
'channel_uid'
=>
implode
(
','
,
$channelUid
),
]);
'update_time'
=>
time
(),
]);
}
}
}
}
}
$result
=
$model
->
whereIn
(
'contact_id'
,
$contactId
)
->
delete
();
}
if
(
!
$result
)
{
$this
->
response
(
-
1
,
'删除失败'
);
}
$logService
=
new
LogService
();
// 执行批量删除
$result
=
$model
->
whereIn
(
'contact_id'
,
$contactIds
)
->
delete
();
if
(
!
$result
)
{
$this
->
response
(
-
1
,
'删除失败'
);
}
// 记录日志
$logService
=
new
LogService
();
foreach
(
$contacts
as
$contact
)
{
$content
=
'删除联系人'
;
$content
=
'删除联系人'
;
$remark
=
json_encode
([
'old_contact'
=>
$contact
,
'new_contact'
=>
[]]);
$remark
=
json_encode
([
'old_contact'
=>
$contact
->
toArray
()
,
'new_contact'
=>
[]]);
$logService
->
AddLog
(
$contact
[
'supplier_id'
],
LogModel
::
UPDATE_OPERATE
,
'修改供应商基本资料'
,
$content
,
$remark
);
$logService
->
AddLog
(
$contact
[
'supplier_id'
],
LogModel
::
UPDATE_OPERATE
,
'修改供应商基本资料'
,
$content
,
$remark
);
$this
->
response
(
0
,
'删除成功'
);
}
}
$this
->
response
(
-
1
,
'找不到删除对象'
);
$this
->
response
(
0
,
'删除成功'
);
}
}
public
function
GetSupplierContact
(
$request
)
public
function
GetSupplierContact
(
$request
)
...
...
app/Http/Services/SupplierService.php
View file @
b2f59072
...
@@ -1071,6 +1071,19 @@ class SupplierService
...
@@ -1071,6 +1071,19 @@ class SupplierService
{
{
$adminUserService
=
new
AdminUserService
();
$adminUserService
=
new
AdminUserService
();
// 检查供应商是否已有猎芯采购和数据跟单员,如果两者都有则跳过
$hasLiexinPurchase
=
SupplierContactModel
::
where
(
'supplier_id'
,
$supplierId
)
->
where
(
'channel_user_type'
,
SupplierContactModel
::
CHANNEL_USER_TYPE_LIEXIN
)
->
exists
();
$hasDataFollower
=
SupplierContactModel
::
where
(
'supplier_id'
,
$supplierId
)
->
where
(
'channel_user_type'
,
SupplierContactModel
::
CHANNEL_USER_TYPE_INVENTORY
)
->
exists
();
if
(
$hasLiexinPurchase
&&
$hasDataFollower
)
{
// 已有猎芯采购和数据跟单员,跳过自动分配
return
true
;
}
// 获取SKU采购员信息
// 获取SKU采购员信息
$skuPurchaseUser
=
$adminUserService
->
getAdminUserInfoByCodeId
(
$skuPurchaseCodeId
);
$skuPurchaseUser
=
$adminUserService
->
getAdminUserInfoByCodeId
(
$skuPurchaseCodeId
);
if
(
empty
(
$skuPurchaseUser
))
{
if
(
empty
(
$skuPurchaseUser
))
{
...
@@ -1129,7 +1142,6 @@ class SupplierService
...
@@ -1129,7 +1142,6 @@ class SupplierService
if
(
$codeId
)
{
if
(
$codeId
)
{
$assignCodeIds
[]
=
$codeId
;
$assignCodeIds
[]
=
$codeId
;
}
}
dump
(
$assignCodeIds
);
}
}
}
elseif
(
$isXinZhiGongYingLian
)
{
}
elseif
(
$isXinZhiGongYingLian
)
{
// 属于新质供应链部:默认欧阳海梅
// 属于新质供应链部:默认欧阳海梅
...
...
resources/views/script/supplier/SupplierContactScript.blade.php
View file @
b2f59072
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
last
:
false
,
//不显示尾页
last
:
false
,
//不显示尾页
cols
:
[[
cols
:
[[
{
{
type
:
'
radio
'
,
type
:
'
checkbox
'
,
},
},
{
{
field
:
'supplier_consignee'
,
field
:
'supplier_consignee'
,
...
...
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