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
410da8a8
authored
May 19, 2026
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
部分
parent
7115c632
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
59 deletions
app/Http/Services/SupplierAuditService.php
app/Http/Services/SupplierAuditService.php
View file @
410da8a8
...
...
@@ -8,6 +8,7 @@ use App\Model\LogModel;
use
App\Model\SupplierChannelModel
;
use
App\Model\SupplierContactModel
;
use
App\Http\Services\CrmService
;
use
Illuminate\Support\Facades\DB
;
class
SupplierAuditService
{
...
...
@@ -603,23 +604,40 @@ class SupplierAuditService
*/
public
function
auditCustomerConvertSupplier
(
$supplierId
,
$approvalStatus
,
$remark
,
$channelUid
=
''
)
{
// 获取审核单据信息
$auditBillInfo
=
AuditCenterService
::
getAuditInfoByIdAndType
(
$supplierId
,
AuditCenterService
::
TYPE_CUSTOMER_CONVERT_SUPPLIER_AUDIT
);
if
(
empty
(
$auditBillInfo
))
{
throw
new
\Exception
(
"客户转化供应商审核单据不存在"
);
}
// 使用审核中心流程
$result
=
$this
->
auditCustomerConvertByAuditCenter
(
$auditBillInfo
[
'id'
],
$approvalStatus
,
$remark
,
$channelUid
);
return
$result
?
true
:
false
;
}
/**
* 客户转化供应商 - 通过审核中心审核
*/
private
function
auditCustomerConvertByAuditCenter
(
$billId
,
$approvalStatus
,
$remark
,
$channelUid
=
''
)
{
$billInfo
=
AuditCenterService
::
getAuditInfoByBillId
(
$billId
);
if
(
empty
(
$billInfo
))
{
throw
new
\Exception
(
"单据不存在"
);
}
$approvalUid
=
request
()
->
user
->
userId
;
// 调用审核中心审核接口
if
(
in_array
(
$
auditB
illInfo
[
'approval_status'
],
[
if
(
in_array
(
$
b
illInfo
[
'approval_status'
],
[
AuditCenterService
::
APPROVAL_STATUS_WAIT
,
AuditCenterService
::
APPROVAL_STATUS_ING
]))
{
$
auditBillInfo
=
AuditCenterService
::
audit
(
$auditBillInfo
[
'id'
]
,
$approvalUid
,
$approvalStatus
,
$remark
);
$
billInfo
=
AuditCenterService
::
audit
(
$billId
,
$approvalUid
,
$approvalStatus
,
$remark
);
}
// 处理审核结果
$this
->
handleCustomerConvertAuditResult
(
$
supplierId
,
$auditB
illInfo
,
$approvalStatus
,
$remark
,
$channelUid
);
$this
->
handleCustomerConvertAuditResult
(
$
billInfo
[
'source_id'
],
$b
illInfo
,
$approvalStatus
,
$remark
,
$channelUid
);
return
true
;
}
...
...
@@ -629,65 +647,67 @@ class SupplierAuditService
*/
private
function
handleCustomerConvertAuditResult
(
$supplierId
,
$billInfo
,
$approvalStatus
,
$remark
,
$channelUid
=
''
)
{
$approverName
=
request
()
->
user
->
name
;
if
(
$approvalStatus
==
1
)
{
// 通过
if
(
$billInfo
[
'approval_status'
]
==
AuditCenterService
::
APPROVAL_STATUS_FINISH
)
{
// 最终审核完成,状态改为待提审,并分配采购员
$updateData
=
[
'status'
=>
SupplierChannelModel
::
STATUS_PENDING
,
'update_time'
=>
time
(),
];
if
(
!
empty
(
$channelUid
))
{
$updateData
[
'channel_uid'
]
=
$channelUid
;
DB
::
connection
(
'web'
)
->
transaction
(
function
()
use
(
$supplierId
,
$billInfo
,
$approvalStatus
,
$remark
,
$channelUid
)
{
$approverName
=
request
()
->
user
->
name
;
if
(
$approvalStatus
==
1
)
{
// 通过
if
(
$billInfo
[
'approval_status'
]
==
AuditCenterService
::
APPROVAL_STATUS_FINISH
)
{
// 最终审核完成,状态改为待提审,并分配采购员
$updateData
=
[
'status'
=>
SupplierChannelModel
::
STATUS_PENDING
,
'update_time'
=>
time
(),
];
if
(
!
empty
(
$channelUid
))
{
$updateData
[
'channel_uid'
]
=
$channelUid
;
}
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
update
(
$updateData
);
SupplierContactModel
::
where
(
'supplier_id'
,
$supplierId
)
->
update
([
'can_check_uids'
=>
$channelUid
,
]);
// 回传CRM系统:转化供应商状态更新为完成
$supplierName
=
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
value
(
'supplier_name'
);
CrmService
::
confirmCrmSupplier
(
$supplierName
,
$approverName
,
'completed'
,
$remark
);
// 记录审批日志
$logContent
=
"确认客户转化供应商:审核通过"
;
if
(
!
empty
(
$channelUid
))
{
$adminUserService
=
new
AdminUserService
();
$channelUser
=
$adminUserService
->
getAdminUserInfoByCodeId
(
$channelUid
);
$channelUserName
=
\array_get
(
$channelUser
,
'name'
,
''
);
$logContent
.=
",分配采购员:
{
$channelUserName
}
"
;
}
$logService
=
new
LogService
();
$logService
->
AddLog
(
$supplierId
,
LogModel
::
UPDATE_OPERATE
,
'客户转化供应商审核'
,
$logContent
);
}
else
{
// 中间节点审核通过,记录日志
$logContent
=
"确认客户转化供应商:审核通过"
;
$logService
=
new
LogService
();
$logService
->
AddLog
(
$supplierId
,
LogModel
::
UPDATE_OPERATE
,
'客户转化供应商审核'
,
$logContent
);
}
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
update
(
$updateData
);
SupplierContactModel
::
where
(
'supplier_id'
,
$supplierId
)
->
update
([
'can_check_uids'
=>
$channelUid
,
]);
// 回传CRM系统:转化供应商状态更新为完成
$supplierName
=
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
value
(
'supplier_name'
);
CrmService
::
confirmCrmSupplier
(
$supplierName
,
$approverName
,
'completed'
,
$remark
);
// 记录审批日志
$logContent
=
"确认客户转化供应商:审核通过"
;
if
(
!
empty
(
$channelUid
))
{
$adminUserService
=
new
AdminUserService
();
$channelUser
=
$adminUserService
->
getAdminUserInfoByCodeId
(
$channelUid
);
$channelUserName
=
\array_get
(
$channelUser
,
'name'
,
''
);
$logContent
.=
",分配采购员:
{
$channelUserName
}
"
;
}
else
{
// 拒绝
if
(
$billInfo
[
'approval_status'
]
==
AuditCenterService
::
APPROVAL_STATUS_REFUSE
)
{
// 最终审核拒绝,状态恢复为待确认
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
update
([
'status'
=>
SupplierChannelModel
::
STATUS_CONFIRM
,
'update_time'
=>
time
(),
]);
// 回传CRM系统:转化供应商状态更新为采购驳回
$supplierName
=
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
value
(
'supplier_name'
);
CrmService
::
confirmCrmSupplier
(
$supplierName
,
$approverName
,
'purchase_rejected'
,
$remark
);
// 记录审批日志
$logContent
=
"确认客户转化供应商:审核未通过"
;
$logService
=
new
LogService
();
$logService
->
AddLog
(
$supplierId
,
LogModel
::
UPDATE_OPERATE
,
'客户转化供应商审核'
,
$logContent
);
}
else
{
// 中间节点拒绝
$logContent
=
"确认客户转化供应商:审核未通过"
;
$logService
=
new
LogService
();
$logService
->
AddLog
(
$supplierId
,
LogModel
::
UPDATE_OPERATE
,
'客户转化供应商审核'
,
$logContent
);
}
$logService
=
new
LogService
();
$logService
->
AddLog
(
$supplierId
,
LogModel
::
UPDATE_OPERATE
,
'客户转化供应商审核'
,
$logContent
);
}
else
{
// 中间节点审核通过,记录日志
$logContent
=
"确认客户转化供应商:审核通过"
;
$logService
=
new
LogService
();
$logService
->
AddLog
(
$supplierId
,
LogModel
::
UPDATE_OPERATE
,
'客户转化供应商审核'
,
$logContent
);
}
}
else
{
// 拒绝
if
(
$billInfo
[
'approval_status'
]
==
AuditCenterService
::
APPROVAL_STATUS_REFUSE
)
{
// 最终审核拒绝,状态恢复为待确认
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
update
([
'status'
=>
SupplierChannelModel
::
STATUS_CONFIRM
,
'update_time'
=>
time
(),
]);
// 回传CRM系统:转化供应商状态更新为采购驳回
$supplierName
=
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
value
(
'supplier_name'
);
CrmService
::
confirmCrmSupplier
(
$supplierName
,
$approverName
,
'purchase_rejected'
,
$remark
);
// 记录审批日志
$logContent
=
"确认客户转化供应商:审核未通过"
;
$logService
=
new
LogService
();
$logService
->
AddLog
(
$supplierId
,
LogModel
::
UPDATE_OPERATE
,
'客户转化供应商审核'
,
$logContent
);
}
else
{
// 中间节点拒绝
$logContent
=
"确认客户转化供应商:审核未通过"
;
$logService
=
new
LogService
();
$logService
->
AddLog
(
$supplierId
,
LogModel
::
UPDATE_OPERATE
,
'客户转化供应商审核'
,
$logContent
);
}
}
});
}
//获取审核流程
...
...
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