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
f8ea5d91
authored
May 26, 2026
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'ysx-数据维护员权限-20260521'
parents
775542e7
2095f697
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
139 additions
and
32 deletions
app/Http/Controllers/Api/SkuApiController.php
app/Http/Controllers/Filter/SkuListFilter.php
app/Http/Controllers/Filter/SupplierAccountFilter.php
app/Http/Services/SkuUploadLogService.php
app/Http/Services/SyncSupplierService.php
app/Http/Controllers/Api/SkuApiController.php
View file @
f8ea5d91
...
...
@@ -60,16 +60,59 @@ class SkuApiController extends Controller
$supplierCode
=
$request
->
get
(
'supplier_code'
);
$brandId
=
$request
->
get
(
'brand_ids'
);
$brandId
=
str_replace
(
','
,
''
,
$brandId
);
// $updateTime = $request->get('update_time');
if
(
empty
(
$supplierCode
))
{
$this
->
response
(
-
1
,
'请选择供应商'
);
}
// $startTime = $endTime = 0;
// if ($updateTime) {
// $updateTime = explode('~', $updateTime);
// $startTime = $updateTime[0];
// $endTime = $updateTime[1];
// }
$supplier
=
SupplierChannelModel
::
where
(
'supplier_code'
,
$supplierCode
)
->
first
();
if
(
empty
(
$supplier
))
{
$this
->
response
(
-
1
,
'供应商不存在'
);
}
if
(
!
checkPerm
(
'ViewAllSku'
))
{
$userId
=
$request
->
user
->
userId
;
$codeId
=
$request
->
user
->
codeId
;
$canViewSubordinate
=
checkPerm
(
'ViewSubordinateSku'
);
if
(
$canViewSubordinate
)
{
$departmentService
=
new
\App\Http\Services\DepartmentService
();
$subordinateUserIds
=
$departmentService
->
getSubordinateUserIds
(
$userId
);
$adminUserService
=
new
\App\Http\Services\AdminUserService
();
$subordinateCodeIds
=
$adminUserService
->
getCodeIdsByUserIds
(
$subordinateUserIds
)
->
toArray
();
$subordinateCodeIds
[]
=
$codeId
;
$isAuthorized
=
false
;
if
(
in_array
(
$supplier
->
purchase_uid
,
$subordinateCodeIds
))
{
$isAuthorized
=
true
;
}
if
(
!
empty
(
$supplier
->
channel_uid
))
{
$channelUids
=
explode
(
','
,
trim
(
$supplier
->
channel_uid
,
','
));
foreach
(
$channelUids
as
$channelUid
)
{
if
(
in_array
(
$channelUid
,
$subordinateCodeIds
))
{
$isAuthorized
=
true
;
break
;
}
}
}
if
(
!
$isAuthorized
)
{
$this
->
response
(
-
1
,
'无权限操作该供应商的SKU'
);
}
}
else
{
$isAuthorized
=
false
;
if
(
$supplier
->
purchase_uid
==
$codeId
)
{
$isAuthorized
=
true
;
}
if
(
!
empty
(
$supplier
->
channel_uid
))
{
$channelUids
=
explode
(
','
,
trim
(
$supplier
->
channel_uid
,
','
));
if
(
in_array
(
$codeId
,
$channelUids
))
{
$isAuthorized
=
true
;
}
}
if
(
!
$isAuthorized
)
{
$this
->
response
(
-
1
,
'无权限操作该供应商的SKU'
);
}
}
}
$uploadLogId
=
SkuUploadLogModel
::
where
(
'supplier_code'
,
$supplierCode
)
->
where
(
'status'
,
SkuUploadLogModel
::
STATUS_HANDLED
)
->
orderBy
(
'id'
,
'desc'
)
...
...
@@ -89,7 +132,6 @@ class SkuApiController extends Controller
'log_id'
=>
$uploadLogId
,
"down_type"
=>
1
,
];
//改成队列
(
new
SkuService
())
->
batchOffShelfSkuQueue
(
$data
);
$this
->
response
(
0
,
'批量下架任务已经发送,请等待任务完成,期间你可以刷新列表查看下架情况'
);
}
...
...
@@ -131,6 +173,59 @@ class SkuApiController extends Controller
'operate_type'
,
'cp_time'
,
]);
$supplierCodes
=
explode
(
','
,
$data
[
'supplier_codes'
]);
if
(
!
checkPerm
(
'ViewAllSku'
))
{
$userId
=
$request
->
user
->
userId
;
$codeId
=
$request
->
user
->
codeId
;
$canViewSubordinate
=
checkPerm
(
'ViewSubordinateSku'
);
if
(
$canViewSubordinate
)
{
$departmentService
=
new
\App\Http\Services\DepartmentService
();
$subordinateUserIds
=
$departmentService
->
getSubordinateUserIds
(
$userId
);
$adminUserService
=
new
\App\Http\Services\AdminUserService
();
$subordinateCodeIds
=
$adminUserService
->
getCodeIdsByUserIds
(
$subordinateUserIds
)
->
toArray
();
$subordinateCodeIds
[]
=
$codeId
;
$suppliers
=
SupplierChannelModel
::
whereIn
(
'supplier_code'
,
$supplierCodes
)
->
get
();
foreach
(
$suppliers
as
$supplier
)
{
$isAuthorized
=
false
;
if
(
in_array
(
$supplier
->
purchase_uid
,
$subordinateCodeIds
))
{
$isAuthorized
=
true
;
}
if
(
!
empty
(
$supplier
->
channel_uid
))
{
$channelUids
=
explode
(
','
,
trim
(
$supplier
->
channel_uid
,
','
));
foreach
(
$channelUids
as
$channelUid
)
{
if
(
in_array
(
$channelUid
,
$subordinateCodeIds
))
{
$isAuthorized
=
true
;
break
;
}
}
}
if
(
!
$isAuthorized
)
{
$this
->
response
(
-
1
,
'无权限操作供应商 '
.
$supplier
->
supplier_code
.
' 的SKU'
);
}
}
}
else
{
$suppliers
=
SupplierChannelModel
::
whereIn
(
'supplier_code'
,
$supplierCodes
)
->
get
();
foreach
(
$suppliers
as
$supplier
)
{
$isAuthorized
=
false
;
if
(
$supplier
->
purchase_uid
==
$codeId
)
{
$isAuthorized
=
true
;
}
if
(
!
empty
(
$supplier
->
channel_uid
))
{
$channelUids
=
explode
(
','
,
trim
(
$supplier
->
channel_uid
,
','
));
if
(
in_array
(
$codeId
,
$channelUids
))
{
$isAuthorized
=
true
;
}
}
if
(
!
$isAuthorized
)
{
$this
->
response
(
-
1
,
'无权限操作供应商 '
.
$supplier
->
supplier_code
.
' 的SKU'
);
}
}
}
}
if
(
$data
[
'operate_type'
]
==
SkuService
::
OPERATE_TYPE_PUTAWAY
)
{
if
(
$data
[
'is_long_term'
]
==
-
1
&&
empty
(
$data
[
'cp_time'
]))
{
$this
->
response
(
-
1
,
'请设置上架有效期'
);
...
...
app/Http/Controllers/Filter/SkuListFilter.php
View file @
f8ea5d91
...
...
@@ -32,18 +32,37 @@ class SkuListFilter
unset
(
$map
[
'create_time'
]);
}
$userId
=
request
()
->
user
->
userId
;
$codeId
=
request
()
->
user
->
codeId
;
if
(
checkPerm
(
'ViewAllSku'
))
{
}
else
if
(
checkPerm
(
'ViewSubordinateSku'
))
{
//查看下级
$departmentService
=
new
DepartmentService
();
//下属用户id(结果包括自己的id)
$subordinateUserIds
=
$departmentService
->
getSubordinateUserIds
(
$userId
);
$adminUserService
=
new
AdminUserService
();
$subordinateCodeIds
=
$adminUserService
->
getCodeIdsByUserIds
(
$subordinateUserIds
);
$subordinateCodeIds
=
$subordinateCodeIds
->
toArray
();
$map
[
'encoded/eqs'
]
=
implode
(
','
,
$subordinateCodeIds
);
$supplierCodes
=
SupplierChannelModel
::
where
(
function
(
$query
)
use
(
$subordinateCodeIds
)
{
$query
->
whereIn
(
'purchase_uid'
,
$subordinateCodeIds
)
->
orWhereRaw
(
"channel_uid REGEXP '"
.
implode
(
'|'
,
$subordinateCodeIds
)
.
"'"
);
})
->
whereNotNull
(
'supplier_code'
)
->
where
(
'supplier_code'
,
'!='
,
''
)
->
pluck
(
'supplier_code'
)
->
toArray
();
if
(
!
empty
(
$supplierCodes
))
{
$map
[
'canal_new/eqs'
]
=
implode
(
','
,
$supplierCodes
);
}
else
{
$map
[
'canal_new/eqs'
]
=
'NO_MATCH'
;
}
}
else
{
$map
[
'encoded/condition'
]
=
request
()
->
user
->
codeId
;
$map
[
'encoded/condition'
]
=
$codeId
;
$supplierCodes
=
SupplierChannelModel
::
where
(
function
(
$query
)
use
(
$codeId
)
{
$query
->
where
(
'purchase_uid'
,
$codeId
)
->
orWhere
(
'channel_uid'
,
'like'
,
'%'
.
$codeId
.
'%'
);
})
->
whereNotNull
(
'supplier_code'
)
->
where
(
'supplier_code'
,
'!='
,
''
)
->
pluck
(
'supplier_code'
)
->
toArray
();
if
(
!
empty
(
$supplierCodes
))
{
$map
[
'canal_new/eqs'
]
=
implode
(
','
,
$supplierCodes
);
}
else
{
$map
[
'canal_new/eqs'
]
=
'NO_MATCH'
;
}
}
if
((
!
empty
(
$map
[
'update_time'
])))
{
$times
=
explode
(
'~'
,
$map
[
'update_time'
]);
...
...
@@ -74,22 +93,6 @@ class SkuListFilter
unset
(
$map
[
'data_channel_uid'
]);
}
//根据数据维护员(purchase_uid)查询对应的供应商编码,多个一起请求
if
(
!
empty
(
$map
[
'purchase_uid'
]))
{
$supplierCodes
=
SupplierChannelModel
::
where
(
'purchase_uid'
,
$map
[
'purchase_uid'
])
->
whereNotNull
(
'supplier_code'
)
->
where
(
'supplier_code'
,
'!='
,
''
)
->
pluck
(
'supplier_code'
)
->
toArray
();
if
(
!
empty
(
$supplierCodes
))
{
$map
[
'canal_new/eqs'
]
=
implode
(
','
,
$supplierCodes
);
}
else
{
// 没有匹配的供应商,传一个不存在的值以确保查不到数据
$map
[
'canal_new/eqs'
]
=
'NO_MATCH'
;
}
unset
(
$map
[
'purchase_uid'
]);
}
if
(
!
empty
(
$map
[
'source_type'
]))
{
switch
(
$map
[
'source_type'
])
{
case
'all'
:
...
...
app/Http/Controllers/Filter/SupplierAccountFilter.php
View file @
f8ea5d91
...
...
@@ -22,17 +22,16 @@ class SupplierAccountFilter
if
(
!
checkPerm
(
'ViewAllSupplierAccount'
))
{
if
(
checkPerm
(
'ViewSubSupplierAccount'
))
{
$departmentService
=
new
DepartmentService
();
//下属用户id(结果包括自己的id)
$subordinateUserIds
=
$departmentService
->
getSubordinateUserIds
(
$request
->
user
->
userId
);
$adminUserService
=
new
AdminUserService
();
$subordinateCodeIds
=
$adminUserService
->
getCodeIdsByUserIds
(
$subordinateUserIds
);
$subordinateCodeIds
=
$subordinateCodeIds
->
toArray
();
$likeSqlRaw
=
implode
(
'|'
,
$subordinateCodeIds
);
$supplierIds
=
SupplierChannelModel
::
whereRaw
(
DB
::
raw
(
"(channel_uid REGEXP '
$likeSqlRaw
')"
))
->
pluck
(
'supplier_id'
)
->
toArray
();
$inCodeIdSql
=
implode
(
','
,
$subordinateCodeIds
);
$supplierIds
=
SupplierChannelModel
::
whereRaw
(
DB
::
raw
(
"(channel_uid REGEXP '
$likeSqlRaw
' OR purchase_uid IN (
$inCodeIdSql
))"
))
->
pluck
(
'supplier_id'
)
->
toArray
();
$query
->
whereIn
(
'supplier_id'
,
$supplierIds
);
}
else
{
//否则只能查看自己的
$supplierIds
=
SupplierChannelModel
::
whereRaw
(
DB
::
raw
(
"(channel_uid REGEXP '
$codeId
')"
))
->
pluck
(
'supplier_id'
)
->
toArray
();
$supplierIds
=
SupplierChannelModel
::
whereRaw
(
DB
::
raw
(
"(channel_uid REGEXP '
$codeId
' OR purchase_uid = '
$codeId
')"
))
->
pluck
(
'supplier_id'
)
->
toArray
();
$query
->
whereIn
(
'supplier_id'
,
$supplierIds
);
}
}
...
...
app/Http/Services/SkuUploadLogService.php
View file @
f8ea5d91
...
...
@@ -9,6 +9,7 @@ use App\Http\Transformers\SupplierTransformer;
use
App\Model\LogModel
;
use
App\Model\SkuUploadLogModel
;
use
App\Model\SupplierChannelModel
;
use
Illuminate\Support\Facades\DB
;
class
SkuUploadLogService
{
...
...
@@ -26,7 +27,6 @@ class SkuUploadLogService
return
$list
;
}
//获取上传次数
public
function
getSkuUploadLogCount
(
$supplierId
)
{
$supplierCode
=
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplierId
)
->
value
(
'supplier_code'
);
...
...
app/Http/Services/SyncSupplierService.php
View file @
f8ea5d91
...
...
@@ -463,6 +463,16 @@ class SyncSupplierService
}
}
}
if
(
!
empty
(
$supplier
[
'purchase_uid'
]))
{
$purchaseUids
=
explode
(
','
,
$supplier
[
'purchase_uid'
]);
$purchaseUserList
=
(
new
AdminUserService
())
->
getAdminUserListByCodeIds
(
$purchaseUids
);
foreach
(
$purchaseUserList
as
$purchaseUser
)
{
if
(
!
empty
(
$purchaseUser
[
'email'
]))
{
(
new
MessageService
())
->
sendMessage
(
'supplier_entity_notice_purchase'
,
$data
,
$purchaseUser
[
'email'
],
true
);
}
}
}
}
}
}
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