Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
haishi
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
冷斌
haishi
Commits
8b3d2ac1
Commit
8b3d2ac1
authored
May 11, 2020
by
冷斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
788880ea
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
51 deletions
+57
-51
application/Admin/Controller/PromotersController.class.php
+57
-51
No files found.
application/Admin/Controller/PromotersController.class.php
View file @
8b3d2ac1
...
...
@@ -4,7 +4,7 @@ namespace Admin\Controller;
use
Common\Controller\AdminbaseController
;
class
PromotersController
extends
AdminbaseController
{
protected
$users_model
,
$role_model
;
function
_initialize
()
{
parent
::
_initialize
();
$this
->
users_model
=
D
(
"Common/Users"
);
...
...
@@ -22,18 +22,18 @@ class PromotersController extends AdminbaseController{
$user
=
$this
->
users_model
->
where
(
"id=
{
$_SESSION
[
'ADMIN_ID'
]
}
"
)
->
find
();
if
(
$user
[
'tg_type'
]
==
0
){
//平台方
}
else
{
//代理和主播
$path
=
setpath
(
$user
[
'id'
]);
$uids
=
$Proxy
->
where
(
"type=-1 and path like '%
{
$path
}
%'"
)
->
getField
(
'uid'
,
true
);
if
(
$uids
){
$where
[
"id"
]
=
array
(
'in'
,
$uids
);
}
else
{
$where
[
"id"
]
=
array
(
'in'
,
array
(
'0'
));
}
}
$isshow
=
0
;
if
(
$user
[
'tg_type'
]
==
4
){
//主播才有添加业务员的权限
...
...
@@ -67,15 +67,22 @@ class PromotersController extends AdminbaseController{
$total_charge
=
'0'
;
}
$v
[
'total_charge'
]
=
$total_charge
;
$map2
=
[];
$map2
[
'id'
]
=
array
(
'in'
,
$uids
);
$total_coin
=
$User
->
where
(
"user_type=2"
)
->
where
(
$map2
)
->
sum
(
'consumption'
);
if
(
!
$total_coin
){
$total_coin
=
'0'
;
}
$v
[
'total_coin'
]
=
$total_coin
;
// $map2=[];
// $map2['id'] = array('in',$uids);
// $total_coin=$User->where("user_type=2")->where($map2)->sum('consumption');
// if(!$total_coin){
// $total_coin='0';
// }
// $v['total_coin']=$total_coin;
$results
=
M
(
'users_coinrecord'
)
// ->select("sum('totalcoin') as sum")
->
where
(
"uid =
{
$v
[
'id'
]
}
and type='expend' and action in ('sendgift','sendbarrage')"
)
->
sum
(
'totalcoin'
);
$v
[
'total_coin'
]
=
(
int
)
$results
;
$map3
=
[];
$map3
[
'uid'
]
=
array
(
'in'
,
$uids
);
$total_votes
=
$Votes
->
where
(
"type='income'"
)
->
where
(
$map3
)
->
sum
(
'votes'
);
...
...
@@ -83,28 +90,28 @@ class PromotersController extends AdminbaseController{
$total_votes
=
'0'
;
}
$v
[
'total_votes'
]
=
$total_votes
;
$users
[
$k
]
=
$v
;
}
$this
->
assign
(
'isshow'
,
$isshow
);
$this
->
assign
(
'formget'
,
$_GET
);
$this
->
assign
(
"page"
,
$page
->
show
(
'Admin'
));
$this
->
assign
(
"users"
,
$users
);
$this
->
display
();
}
function
add
(){
$this
->
assign
(
'tg_type'
,
5
);
$this
->
assign
(
"role_id"
,
7
);
$code
=
$this
->
createCode
();
$this
->
assign
(
"code"
,
$code
);
$this
->
display
();
}
//添加推广员
...
...
@@ -113,7 +120,7 @@ class PromotersController extends AdminbaseController{
if
(
!
empty
(
$_POST
[
'role_id'
])
&&
is_array
(
$_POST
[
'role_id'
])){
$role_ids
=
$_POST
[
'role_id'
];
unset
(
$_POST
[
'role_id'
]);
if
(
$this
->
users_model
->
create
())
{
$result
=
$this
->
users_model
->
add
();
if
(
$result
!==
false
)
{
...
...
@@ -127,7 +134,7 @@ class PromotersController extends AdminbaseController{
$path
=
$isexist
[
'path'
]
.
$path
;
}
M
(
'users_proxy'
)
->
add
(
array
(
"uid"
=>
$result
,
"type"
=>
'-1'
,
"path"
=>
$path
,
'addtime'
=>
time
()));
$action
=
"添加推广员:
{
$result
}
"
;
setAdminLog
(
$action
);
$this
->
success
(
"添加成功!"
);
...
...
@@ -140,14 +147,14 @@ class PromotersController extends AdminbaseController{
}
else
{
$this
->
error
(
"请为此用户指定角色!"
);
}
}
}
function
edit
(){
$id
=
intval
(
I
(
"get.id"
));
$where
=
[];
$where
[
'u.user_type'
]
=
'1'
;
$where
[
'r.role_id'
]
=
'6'
;
...
...
@@ -164,7 +171,7 @@ class PromotersController extends AdminbaseController{
$proxys
[
$k
]
=
$v
;
}
$this
->
assign
(
"proxys"
,
$proxys
);
$adminid
=
$_SESSION
[
'ADMIN_ID'
];
$admin_roleid
=
$_SESSION
[
'role_id'
];
$isshow
=
0
;
...
...
@@ -172,15 +179,15 @@ class PromotersController extends AdminbaseController{
$isshow
=
1
;
}
$this
->
assign
(
"isshow"
,
$isshow
);
$proxyinfo
=
M
(
'users_proxy'
)
->
where
(
"uid=
{
$id
}
"
)
->
find
();
$this
->
assign
(
"proxyinfo"
,
$proxyinfo
);
$user
=
$this
->
users_model
->
where
(
array
(
"id"
=>
$id
))
->
find
();
$this
->
assign
(
$user
);
$this
->
display
();
}
function
edit_post
(){
if
(
IS_POST
)
{
if
(
!
empty
(
$_POST
[
'role_id'
])
&&
is_array
(
$_POST
[
'role_id'
])){
...
...
@@ -189,7 +196,7 @@ class PromotersController extends AdminbaseController{
}
$role_ids
=
$_POST
[
'role_id'
];
unset
(
$_POST
[
'role_id'
]);
$adminid
=
$_SESSION
[
'ADMIN_ID'
];
$admin_roleid
=
$_SESSION
[
'role_id'
];
$one_id
=
$adminid
;
...
...
@@ -200,7 +207,7 @@ class PromotersController extends AdminbaseController{
}
unset
(
$_POST
[
'one_id'
]);
}
if
(
$this
->
users_model
->
create
())
{
$result
=
$this
->
users_model
->
save
();
if
(
$result
!==
false
)
{
...
...
@@ -210,15 +217,15 @@ class PromotersController extends AdminbaseController{
foreach
(
$role_ids
as
$role_id
){
$role_user_model
->
add
(
array
(
"role_id"
=>
$role_id
,
"user_id"
=>
$uid
));
}
$path
=
setpath
(
$one_id
);
$isexist
=
M
(
'users_proxy'
)
->
where
(
"uid=
{
$one_id
}
"
)
->
find
();
if
(
$isexist
){
$path
=
$isexist
[
'path'
]
.
$path
;
}
M
(
'users_proxy'
)
->
where
(
"uid=
{
$uid
}
"
)
->
save
(
array
(
"path"
=>
$path
)
);
$action
=
"编辑推广员:
{
$uid
}
"
;
setAdminLog
(
$action
);
$this
->
success
(
"保存成功!"
);
...
...
@@ -231,10 +238,10 @@ class PromotersController extends AdminbaseController{
}
else
{
$this
->
error
(
"请为此用户指定角色!"
);
}
}
}
/**
* 删除
*/
...
...
@@ -243,7 +250,7 @@ class PromotersController extends AdminbaseController{
if
(
$id
==
1
){
$this
->
error
(
"最高推广员不能删除!"
);
}
if
(
$this
->
users_model
->
where
(
"id=
$id
"
)
->
delete
()
!==
false
)
{
M
(
"RoleUser"
)
->
where
(
array
(
"user_id"
=>
$id
))
->
delete
();
$action
=
"删除推广员:
{
$id
}
"
;
...
...
@@ -269,7 +276,7 @@ class PromotersController extends AdminbaseController{
$this
->
error
(
'数据传入失败!'
);
}
}
function
cancelban
(){
$id
=
intval
(
$_GET
[
'id'
]);
if
(
$id
)
{
...
...
@@ -285,12 +292,12 @@ class PromotersController extends AdminbaseController{
$this
->
error
(
'数据传入失败!'
);
}
}
/* 生成邀请码 */
function
createCode
(
$len
=
6
,
$format
=
'ALL2'
){
$is_abc
=
$is_numer
=
0
;
$password
=
$tmp
=
''
;
$password
=
$tmp
=
''
;
switch
(
$format
){
case
'ALL'
:
$chars
=
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
;
...
...
@@ -308,7 +315,7 @@ class PromotersController extends AdminbaseController{
$chars
=
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
;
break
;
}
while
(
strlen
(
$password
)
<
$len
){
$tmp
=
substr
(
$chars
,(
mt_rand
()
%
strlen
(
$chars
)),
1
);
if
((
$is_numer
<>
1
&&
is_numeric
(
$tmp
)
&&
$tmp
>
0
)
||
$format
==
'CHAR'
){
...
...
@@ -323,14 +330,14 @@ class PromotersController extends AdminbaseController{
$password
=
$this
->
createCode
(
$len
,
$format
);
}
if
(
$password
!=
''
){
$oneinfo
=
M
(
"users"
)
->
field
(
"id"
)
->
where
(
"user_activation_key='
{
$password
}
'"
)
->
find
();
if
(
!
$oneinfo
){
return
$password
;
}
}
}
$password
=
$this
->
createCode
(
$len
,
$format
);
return
$password
;
}
}
\ No newline at end of file
}
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