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
f91b7f89
authored
Jul 28, 2021
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
优化代码
parent
7c39b3a1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
18 deletions
app/Http/Controllers/Api/SupplierShareApplyApiController.php
app/Http/Services/SupplierShareApplyService.php
app/Model/SupplierShareApplyModel.php
app/Http/Controllers/Api/SupplierShareApplyApiController.php
View file @
f91b7f89
...
...
@@ -36,7 +36,7 @@ class SupplierShareApplyApiController extends Controller
$this
->
response
(
-
1
,
'没有匹配到存在的供应商'
);
}
$applyService
=
new
SupplierShareApplyService
();
$departments
=
$applyService
->
checkApplySupplierShare
(
$supplier
);
$departments
=
$applyService
->
getApplyCanUseDepartments
(
$supplier
);
if
(
empty
(
$departments
))
{
$this
->
response
(
-
1
,
'该供应商不存在相关联的部门'
);
}
...
...
@@ -57,7 +57,7 @@ class SupplierShareApplyApiController extends Controller
$applyService
=
new
SupplierShareApplyService
();
$hasNoFinish
=
$applyService
->
checkHasNoFinishApply
(
$map
);
if
(
$hasNoFinish
)
{
$this
->
response
(
-
1
,
'你存在对该供应商的申请,正在审核流程中'
);
$this
->
response
(
-
1
,
'你存在对该供应商的申请,正在审核流程中
,请等待对应的审核流程走完方可针对该供应商进行新的共用申请
'
);
}
$result
=
$applyService
->
saveSupplierShareApply
(
$map
);
if
(
!
$result
)
{
...
...
app/Http/Services/SupplierShareApplyService.php
View file @
f91b7f89
...
...
@@ -6,23 +6,11 @@ namespace App\Http\Services;
//后台用户相关信息服务
use
App\Http\Transformers\SupplierShareApplyTransformer
;
use
App\Model\DepartmentModel
;
use
App\Model\SupplierShareApplyModel
;
//用于判断是否已经查看的服务
class
SupplierShareApplyService
{
//通过
const
STATUS_PASS
=
2
;
//待复审
const
STATUS_NEED_REVIEW
=
1
;
//待审核
const
STATUS_PENDING
=
0
;
//审核不通过
const
STATUS_AUDIT_REJECT
=
-
1
;
//复审不通过
const
STATUS_REVIEW_REJECT
=
-
2
;
public
function
getSupplierShareApplyList
(
$userId
)
{
$applyModel
=
new
SupplierShareApplyModel
();
...
...
@@ -40,7 +28,8 @@ class SupplierShareApplyService
return
$list
;
}
public
function
checkApplySupplierShare
(
$supplier
)
//获取申请可以选择的部门
public
function
getApplyCanUseDepartments
(
$supplier
)
{
$supplier
=
$supplier
->
toArray
();
//找出采购,开发员,创建者所属部门,一个供应商可能和多个部门相关,因为采购可能有自营或者联营的
...
...
@@ -64,6 +53,7 @@ class SupplierShareApplyService
foreach
(
$channelUids
as
$channelUid
)
{
$channelUser
=
$adminService
->
getAdminUserInfoByCodeId
(
$channelUid
);
$channelDepartment
=
$departmentService
->
getTopDepartmentByUserId
(
$channelUser
[
'userId'
]);
//为什么不判断只要有三个部门就跳出,因为以后可能会有其它部门的人当采购
if
(
!
in_array
(
$channelDepartment
,
$allDepartments
)
&&
!
empty
(
$channelDepartment
))
{
$allDepartments
[]
=
$channelDepartment
;
}
...
...
@@ -130,13 +120,13 @@ class SupplierShareApplyService
$applyModel
=
new
SupplierShareApplyModel
();
$apply
=
$applyModel
->
where
(
'id'
,
$id
)
->
first
()
->
toArray
();
//初审
if
(
$apply
[
'status'
]
==
self
::
STATUS_PENDING
)
{
$apply
[
'status'
]
=
$statusName
==
'pass'
?
self
::
STATUS_NEED_REVIEW
:
self
::
STATUS_AUDIT_REJECT
;
if
(
$apply
[
'status'
]
==
$applyModel
::
STATUS_PENDING
)
{
$apply
[
'status'
]
=
$statusName
==
'pass'
?
$applyModel
::
STATUS_NEED_REVIEW
:
$applyModel
::
STATUS_AUDIT_REJECT
;
$apply
[
'audit_uid'
]
=
$userId
;
$apply
[
'audit_time'
]
=
time
();
}
else
{
//复审
$apply
[
'status'
]
=
$statusName
==
'pass'
?
self
::
STATUS_PASS
:
self
::
STATUS_REVIEW_REJECT
;
$apply
[
'status'
]
=
$statusName
==
'pass'
?
$applyModel
::
STATUS_PASS
:
$applyModel
::
STATUS_REVIEW_REJECT
;
$apply
[
'review_time'
]
=
time
();
$apply
[
'review_uid'
]
=
$userId
;
//还要去将当前请求人的内部编码写到采购里面去
...
...
app/Model/SupplierShareApplyModel.php
View file @
f91b7f89
...
...
@@ -10,6 +10,18 @@ class SupplierShareApplyModel extends Model
protected
$table
=
'supplier_share_apply'
;
public
$timestamps
=
false
;
//通过
const
STATUS_PASS
=
2
;
//待复审
const
STATUS_NEED_REVIEW
=
1
;
//待审核
const
STATUS_PENDING
=
0
;
//审核不通过
const
STATUS_AUDIT_REJECT
=
-
1
;
//复审不通过
const
STATUS_REVIEW_REJECT
=
-
2
;
public
function
supplier
()
{
return
$this
->
hasOne
(
SupplierChannelModel
::
class
,
'supplier_id'
,
'supplier_id'
);
...
...
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