Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
semour
/
semour_admin
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
093dbba3
authored
Nov 16, 2022
by
孙龙
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'master' of
http://git.ichunt.net/semour/semour_admin
parents
db787562
54c57f90
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
51 deletions
.env
app/Admin/Service/AutoAssignCustomer.php
app/Http/Middleware/Permission.php
app/helpers.php
config/perm.php
.env
View file @
093dbba3
...
@@ -57,7 +57,9 @@ START_IFRAME_TAB=true
...
@@ -57,7 +57,9 @@ START_IFRAME_TAB=true
LOGIN_DOMAIN=user.semourdev.net
LOGIN_DOMAIN=user.semourdev.net
PERM_URL=http://perm.semourdev.net/api/check
PERM_URL=http://perm.semourdev.net/api/check
PERM_ID=12
PERM_LIST=http://perm.semourdev.net/api/perms
PERM_ID=61
PERM_GOURL=http://perm.semourdev.net
PERM_GOURL=http://perm.semourdev.net
ADMIN_GROUP=1000,20000
ADMIN_GROUP=1000,20000
MENU_ID=2
MENU_ID=2
...
...
app/Admin/Service/AutoAssignCustomer.php
View file @
093dbba3
...
@@ -14,8 +14,7 @@ class AutoAssignCustomer
...
@@ -14,8 +14,7 @@ class AutoAssignCustomer
if
(
empty
(
$res
))
{
if
(
empty
(
$res
))
{
$assignInfo
=
\App\Models\AutoAssignCustomer
::
getInfoByOrderSort
();
$assignInfo
=
\App\Models\AutoAssignCustomer
::
getInfoByOrderSort
();
\App\Models\AutoAssignCustomer
::
updateAll
([
'is_now'
=>
\App\Models\AutoAssignCustomer
::
IS_NOW_NO
]);
\App\Models\AutoAssignCustomer
::
updateAll
([
'is_now'
=>
\App\Models\AutoAssignCustomer
::
IS_NOW_NO
]);
\App\Models\AutoAssignCustomer
::
updateById
(
$assignInfo
[
'id'
],
\App\Models\AutoAssignCustomer
::
updateById
(
$assignInfo
[
'id'
],
[
'is_now'
=>
\App\Models\AutoAssignCustomer
::
IS_NOW_YES
]);
[
'is_now'
=>
\App\Models\AutoAssignCustomer
::
IS_NOW_YES
]);
}
}
DB
::
commit
();
DB
::
commit
();
return
$assignInfo
;
return
$assignInfo
;
...
...
app/Http/Middleware/Permission.php
View file @
093dbba3
...
@@ -37,6 +37,10 @@ class Permission
...
@@ -37,6 +37,10 @@ class Permission
return
$this
->
view
(
'Auth'
,
'没有访问权限'
,
$permData
[
'go_url'
]);
return
$this
->
view
(
'Auth'
,
'没有访问权限'
,
$permData
[
'go_url'
]);
}
}
$request
->
menus
=
$menus
;
$request
->
menus
=
$menus
;
//获取权限放到头
$perms
=
$this
->
getPerms
();
$request
->
perms
=
$perms
;
}
}
if
(
!
in_array
(
$user
->
userId
,
$permData
[
'admin_group'
])
&&
$action
!=
'Dashboard'
)
{
//不是超级管理员
if
(
!
in_array
(
$user
->
userId
,
$permData
[
'admin_group'
])
&&
$action
!=
'Dashboard'
)
{
//不是超级管理员
$perm
=
$this
->
perm
(
$request
->
user
->
userId
,
$action
);
$perm
=
$this
->
perm
(
$request
->
user
->
userId
,
$action
);
...
@@ -47,6 +51,9 @@ class Permission
...
@@ -47,6 +51,9 @@ class Permission
return
$this
->
view
(
'Auth'
,
'没有访问权限'
,
$permData
[
'go_url'
]);
return
$this
->
view
(
'Auth'
,
'没有访问权限'
,
$permData
[
'go_url'
]);
}
}
}
}
return
$next
(
$request
,
$action
);
return
$next
(
$request
,
$action
);
}
}
...
@@ -129,16 +136,16 @@ class Permission
...
@@ -129,16 +136,16 @@ class Permission
}
}
//检查权限,仅支持验证单个权限
//检查权限,仅支持验证单个权限
function
perm
(
$userId
,
$perm
1
=
''
)
function
perm
(
$userId
,
$perm
=
''
)
{
{
$permArr
=
config
(
'perm.perm'
);
$permArr
=
config
(
'perm.perm'
);
$
N
otAuth
=
$permArr
[
'notAuth'
];
$
n
otAuth
=
$permArr
[
'notAuth'
];
$AdminID
=
$permArr
[
'adminGroup'
];
$AdminID
=
$permArr
[
'adminGroup'
];
if
((
!
in_array
(
$perm
1
,
$N
otAuth
))
&&
!
in_array
(
$userId
,
$AdminID
))
{
//过滤不用鉴权的方法与用户
if
((
!
in_array
(
$perm
,
$n
otAuth
))
&&
!
in_array
(
$userId
,
$AdminID
))
{
//过滤不用鉴权的方法与用户
$permID
=
$permArr
[
'id'
];
$permID
=
$permArr
[
'id'
];
$url
=
$permArr
[
'url'
]
.
'/'
.
$userId
.
'/'
.
$permID
.
'?perms='
.
$perm
1
;
$url
=
$permArr
[
'url'
]
.
'/'
.
$userId
.
'/'
.
$permID
.
'?perms='
.
$perm
;
$result
=
json_decode
(
curl
(
$url
,
''
,
0
),
true
);
$result
=
json_decode
(
curl
(
$url
,
''
,
0
),
true
);
if
(
!
isset
(
$result
[
'retcode'
])
||
$result
[
'retcode'
]
!==
0
||
$result
[
'data'
][
'perms'
][
$perm
1
]
==
false
)
{
if
(
!
isset
(
$result
[
'retcode'
])
||
$result
[
'retcode'
]
!==
0
||
$result
[
'data'
][
'perms'
][
$perm
]
==
false
)
{
return
false
;
return
false
;
}
else
{
}
else
{
return
true
;
return
true
;
...
@@ -147,4 +154,16 @@ class Permission
...
@@ -147,4 +154,16 @@ class Permission
return
true
;
return
true
;
}
}
}
}
public
function
getPerms
()
{
$userId
=
request
()
->
user
->
userId
;
$permsUrl
=
config
(
'perm.perm.list'
)
.
'/'
.
$userId
.
'/'
.
config
(
'perm.perm.id'
)
.
'/'
;
$permsResult
=
json_decode
(
curl
(
$permsUrl
),
true
);
$perms
=
[];
if
(
isset
(
$permsResult
[
'retcode'
])
&&
$permsResult
[
'retcode'
]
===
0
)
{
$perms
=
$permsResult
[
'data'
][
'perms'
];
}
return
$perms
;
}
}
}
app/helpers.php
View file @
093dbba3
...
@@ -2,18 +2,17 @@
...
@@ -2,18 +2,17 @@
use
Illuminate\Support\Arr
;
use
Illuminate\Support\Arr
;
define
(
"DIGITS_TWO"
,
2
);
define
(
"DIGITS_TWO"
,
2
);
define
(
"DIGITS_FOUR"
,
4
);
define
(
"DIGITS_FOUR"
,
4
);
define
(
"DIGITS_SIX"
,
6
);
define
(
"DIGITS_SIX"
,
6
);
if
(
!
function_exists
(
'user_admin_config'
))
{
if
(
!
function_exists
(
'user_admin_config'
))
{
function
user_admin_config
(
$key
=
null
,
$value
=
null
)
function
user_admin_config
(
$key
=
null
,
$value
=
null
)
{
{
$session
=
session
();
$session
=
session
();
if
(
!
$config
=
$session
->
get
(
'admin.config'
))
{
if
(
!
$config
=
$session
->
get
(
'admin.config'
))
{
$config
=
config
(
'admin'
);
$config
=
config
(
'admin'
);
$config
[
'lang'
]
=
config
(
'app.locale'
);
$config
[
'lang'
]
=
config
(
'app.locale'
);
}
}
...
@@ -22,9 +21,7 @@ if (! function_exists('user_admin_config')) {
...
@@ -22,9 +21,7 @@ if (! function_exists('user_admin_config')) {
foreach
(
$key
as
$k
=>
$v
)
{
foreach
(
$key
as
$k
=>
$v
)
{
Arr
::
set
(
$config
,
$k
,
$v
);
Arr
::
set
(
$config
,
$k
,
$v
);
}
}
$session
->
put
(
'admin.config'
,
$config
);
$session
->
put
(
'admin.config'
,
$config
);
return
;
return
;
}
}
...
@@ -90,23 +87,24 @@ function curl($url, $params = false, $ispost = 0, $https = 0, $cookie = '', $tim
...
@@ -90,23 +87,24 @@ function curl($url, $params = false, $ispost = 0, $https = 0, $cookie = '', $tim
* @$thousandsSymbol 千分位字符串隔开 1,200,3.4567
* @$thousandsSymbol 千分位字符串隔开 1,200,3.4567
*
*
* define("DIGITS_TWO",2);
* define("DIGITS_TWO",2);
define("DIGITS_FOUR",4);
*
define("DIGITS_FOUR",4);
define("DIGITS_SIX",6);
*
define("DIGITS_SIX",6);
*/
*/
if
(
!
function_exists
(
'decimal_number_format'
))
{
if
(
!
function_exists
(
'decimal_number_format'
))
{
function
decimal_number_format
(
$amount
,
$digits
=
DIGITS_TWO
,
$currency
=
""
,
$thousandsSymbol
=
""
){
function
decimal_number_format
(
$amount
,
$digits
=
DIGITS_TWO
,
$currency
=
""
,
$thousandsSymbol
=
""
)
{
$amount
=
floatval
(
strval
(
$amount
));
$amount
=
floatval
(
strval
(
$amount
));
//格式化币别
//格式化币别
if
(
$currency
)
{
if
(
$currency
)
{
$minus
=
$amount
<
0
?
'-'
:
''
;
$minus
=
$amount
<
0
?
'-'
:
''
;
$numerical
=
number_format
(
abs
(
$amount
),
$digits
,
"."
,
$thousandsSymbol
);
$numerical
=
number_format
(
abs
(
$amount
),
$digits
,
"."
,
$thousandsSymbol
);
$sign
=
Arr
::
get
(
config
(
"field.currency_sign"
),
intval
(
$currency
),
""
);
$sign
=
\Arr
::
get
(
config
(
"field.currency_sign"
),
intval
(
$currency
),
""
);
if
(
!
empty
(
$sign
))
{
if
(
!
empty
(
$sign
))
{
$numerical
=
$sign
.
$numerical
;
$numerical
=
$sign
.
$numerical
;
}
}
return
$minus
?
$minus
.
$numerical
:
$numerical
;
return
$minus
?
$minus
.
$numerical
:
$numerical
;
}
else
{
}
else
{
$numerical
=
number_format
(
$amount
,
$digits
,
"."
,
""
);
$numerical
=
number_format
(
$amount
,
$digits
,
"."
,
""
);
return
$numerical
;
return
$numerical
;
}
}
}
}
...
@@ -125,7 +123,8 @@ if (!function_exists('drawLetter')) {
...
@@ -125,7 +123,8 @@ if (!function_exists('drawLetter')) {
* 格式化型号, echo DrawLetter("LMGAGA 质量 &&*****") 输出:LMGAGA
* 格式化型号, echo DrawLetter("LMGAGA 质量 &&*****") 输出:LMGAGA
* @param $g string 关键词
* @param $g string 关键词
*/
*/
function
drawLetter
(
$g
){
function
drawLetter
(
$g
)
{
$g
=
preg_replace
(
'/[\x{4e00}-\x{9fff}]+/u'
,
''
,
$g
);
$g
=
preg_replace
(
'/[\x{4e00}-\x{9fff}]+/u'
,
''
,
$g
);
$g
=
preg_replace
(
'/[^A-Za-z0-9]+/'
,
''
,
$g
);
$g
=
preg_replace
(
'/[^A-Za-z0-9]+/'
,
''
,
$g
);
return
strtoupper
(
$g
);
return
strtoupper
(
$g
);
...
@@ -149,17 +148,19 @@ if (!function_exists('buildQuery')) {
...
@@ -149,17 +148,19 @@ if (!function_exists('buildQuery')) {
}
else
{
}
else
{
$query
->
where
(
$subWhere
[
0
],
$subWhere
[
1
]);
$query
->
where
(
$subWhere
[
0
],
$subWhere
[
1
]);
}
}
}
else
if
(
count
(
$subWhere
)
==
3
)
{
}
else
{
$fiels
=
$subWhere
[
0
]
??
""
;
if
(
count
(
$subWhere
)
==
3
)
{
$exp
=
$subWhere
[
1
]
??
null
;
$fiels
=
$subWhere
[
0
]
??
""
;
$value
=
$subWhere
[
2
]
??
null
;
$exp
=
$subWhere
[
1
]
??
null
;
if
(
empty
(
$fiels
)
||
$exp
===
null
||
$value
===
null
)
{
$value
=
$subWhere
[
2
]
??
null
;
continue
;
if
(
empty
(
$fiels
)
||
$exp
===
null
||
$value
===
null
)
{
}
continue
;
if
(
$exp
==
"in"
&&
is_array
(
$value
)
&&
!
empty
(
$value
))
{
}
$query
->
whereIn
(
$fiels
,
$value
);
if
(
$exp
==
"in"
&&
is_array
(
$value
)
&&
!
empty
(
$value
))
{
}
else
{
$query
->
whereIn
(
$fiels
,
$value
);
$query
->
where
(
$fiels
,
$exp
,
$value
);
}
else
{
$query
->
where
(
$fiels
,
$exp
,
$value
);
}
}
}
}
}
}
}
...
@@ -168,8 +169,9 @@ if (!function_exists('buildQuery')) {
...
@@ -168,8 +169,9 @@ if (!function_exists('buildQuery')) {
}
}
if
(
!
function_exists
(
'echoToSql'
))
{
if
(
!
function_exists
(
'echoToSql'
))
{
function
echoToSql
(
$query
){
function
echoToSql
(
$query
)
$tmp
=
str_replace
(
'?'
,
'"'
.
'%s'
.
'"'
,
$query
->
toSql
());
{
$tmp
=
str_replace
(
'?'
,
'"'
.
'%s'
.
'"'
,
$query
->
toSql
());
$tmp
=
vsprintf
(
$tmp
,
$query
->
getBindings
());
$tmp
=
vsprintf
(
$tmp
,
$query
->
getBindings
());
dd
(
$tmp
);
dd
(
$tmp
);
}
}
...
@@ -184,9 +186,10 @@ if (!function_exists('echoToSql')) {
...
@@ -184,9 +186,10 @@ if (!function_exists('echoToSql')) {
* @param $val
* @param $val
* @return array
* @return array
*/
*/
function
flipArrayPluck
(
$arr
,
$newKey
,
$seachKey
){
function
flipArrayPluck
(
$arr
,
$newKey
,
$seachKey
)
{
$newArr
=
[];
$newArr
=
[];
foreach
(
$arr
as
$v
)
{
foreach
(
$arr
as
$v
)
{
$newArr
[
$v
[
$newKey
]][]
=
$v
[
$seachKey
];
$newArr
[
$v
[
$newKey
]][]
=
$v
[
$seachKey
];
}
}
return
$newArr
;
return
$newArr
;
...
@@ -194,16 +197,17 @@ function flipArrayPluck($arr,$newKey,$seachKey){
...
@@ -194,16 +197,17 @@ function flipArrayPluck($arr,$newKey,$seachKey){
if
(
!
function_exists
(
'checkArrayValuesNotEmpty'
))
{
if
(
!
function_exists
(
'checkArrayValuesNotEmpty'
))
{
function
checkArrayValuesNotEmpty
(
$arr
=
[]){
function
checkArrayValuesNotEmpty
(
$arr
=
[])
{
$result
=
true
;
$result
=
true
;
if
(
is_array
(
$arr
))
{
if
(
is_array
(
$arr
))
{
foreach
(
$arr
as
$val
)
{
foreach
(
$arr
as
$val
)
{
if
(
empty
(
$val
))
{
if
(
empty
(
$val
))
{
$result
=
false
;
$result
=
false
;
break
;
break
;
}
}
}
}
}
else
{
}
else
{
$result
=
false
;
$result
=
false
;
}
}
return
$result
;
return
$result
;
...
@@ -379,12 +383,12 @@ function price_format($price, $sign = 0, $num = 2, $sep = '')
...
@@ -379,12 +383,12 @@ function price_format($price, $sign = 0, $num = 2, $sep = '')
$minus
=
$price
<
0
?
'-'
:
''
;
$minus
=
$price
<
0
?
'-'
:
''
;
$price
=
floatval
(
strval
(
$price
));
$price
=
floatval
(
strval
(
$price
));
$price
=
number_format
(
abs
(
$price
),
$num
,
'.'
,
$sep
);
$price
=
number_format
(
abs
(
$price
),
$num
,
'.'
,
$sep
);
$sign
=
\Arr
::
get
(
config
(
"field.currency_sign"
),
intval
(
$sign
),
""
);
$sign
=
\Arr
::
get
(
config
(
"field.currency_sign"
),
intval
(
$sign
),
""
);
if
(
!
empty
(
$sign
))
{
if
(
!
empty
(
$sign
))
{
$price
=
$sign
.
$price
;
$price
=
$sign
.
$price
;
}
}
if
(
$minus
)
{
if
(
$minus
)
{
return
$minus
.
$price
;
return
$minus
.
$price
;
}
}
return
$price
;
return
$price
;
}
}
...
@@ -417,4 +421,4 @@ function buildQueryTimeRange($time = "")
...
@@ -417,4 +421,4 @@ function buildQueryTimeRange($time = "")
$buildTimeQueryData
[
"begin_time"
]
=
isset
(
$time
[
0
])
?
$time
[
0
]
:
""
;
$buildTimeQueryData
[
"begin_time"
]
=
isset
(
$time
[
0
])
?
$time
[
0
]
:
""
;
$buildTimeQueryData
[
"end_time"
]
=
isset
(
$time
[
1
])
?
$time
[
1
]
:
""
;
$buildTimeQueryData
[
"end_time"
]
=
isset
(
$time
[
1
])
?
$time
[
1
]
:
""
;
return
$buildTimeQueryData
;
return
$buildTimeQueryData
;
}
}
\ No newline at end of file
config/perm.php
View file @
093dbba3
...
@@ -3,6 +3,7 @@ return [
...
@@ -3,6 +3,7 @@ return [
'perm'
=>
[
'perm'
=>
[
'id'
=>
env
(
'PERM_ID'
),
'id'
=>
env
(
'PERM_ID'
),
'url'
=>
env
(
'PERM_URL'
),
'url'
=>
env
(
'PERM_URL'
),
'list'
=>
env
(
'PERM_LIST'
),
'go_url'
=>
env
(
'PERM_GOURL'
),
'go_url'
=>
env
(
'PERM_GOURL'
),
'admin_group'
=>
explode
(
','
,
env
(
'ADMIN_GROUP'
)),
//管理员权限组,有所有权限
'admin_group'
=>
explode
(
','
,
env
(
'ADMIN_GROUP'
)),
//管理员权限组,有所有权限
'menu_id'
=>
env
(
'MENU_ID'
),
'menu_id'
=>
env
(
'MENU_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