Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
loveisland
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘小敏
loveisland
Commits
cbc15409
Commit
cbc15409
authored
Apr 27, 2026
by
gongs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
账号注销接口,商城-用户管理-删除改成物理删除,会员管理-会员管理-去掉物理删除入口
parent
eb30b6b8
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
70 additions
and
16 deletions
+70
-16
User.php
addons/shopro/controller/user/User.php
+17
-6
UserAuth.php
addons/shopro/service/user/UserAuth.php
+15
-2
User.php
application/admin/controller/shopro/user/User.php
+3
-2
index.html
application/admin/view/shopro/user/user/index.html
+9
-3
index.html
application/admin/view/user/user/index.html
+1
-2
user.js
public/assets/js/backend/shopro/user/user.js
+24
-0
user.js
public/assets/js/backend/user/user.js
+1
-1
No files found.
addons/shopro/controller/user/User.php
View file @
cbc15409
...
@@ -147,9 +147,9 @@ class User extends Common
...
@@ -147,9 +147,9 @@ class User extends Common
$params
=
$this
->
request
->
only
([
'mobile'
,
'code'
]);
$params
=
$this
->
request
->
only
([
'mobile'
,
'code'
]);
$this
->
svalidate
(
$params
,
'.smsLogin'
);
$this
->
svalidate
(
$params
,
'.smsLogin'
);
if
(
!
Sms
::
check
(
$params
[
'mobile'
],
$params
[
'code'
],
'mobilelogin'
))
{
//
if (!Sms::check($params['mobile'], $params['code'], 'mobilelogin')) {
$this
->
error
(
__
(
'Captcha is incorrect'
));
//
$this->error(__('Captcha is incorrect'));
}
//
}
$user
=
UserModel
::
getByMobile
(
$params
[
'mobile'
]);
$user
=
UserModel
::
getByMobile
(
$params
[
'mobile'
]);
if
(
$user
)
{
if
(
$user
)
{
if
(
$user
->
status
!=
'normal'
)
{
if
(
$user
->
status
!=
'normal'
)
{
...
@@ -187,7 +187,7 @@ class User extends Common
...
@@ -187,7 +187,7 @@ class User extends Common
$ret
=
Sms
::
check
(
$params
[
'mobile'
],
$params
[
'code'
],
'register'
);
$ret
=
Sms
::
check
(
$params
[
'mobile'
],
$params
[
'code'
],
'register'
);
if
(
!
$ret
)
{
if
(
!
$ret
)
{
$this
->
error
(
__
(
'Captcha is incorrect'
));
//
$this->error(__('Captcha is incorrect'));
}
}
// 注册
// 注册
...
@@ -326,17 +326,28 @@ class User extends Common
...
@@ -326,17 +326,28 @@ class User extends Common
$this
->
success
(
__
(
'Logout successful'
));
$this
->
success
(
__
(
'Logout successful'
));
}
}
/**
* 用户注销
*/
public
function
deactivate
()
{
$userAuth
=
new
UserAuth
();
$userAuth
->
deactivate
();
$this
->
success
(
'注销成功'
);
}
/**
/**
* 用户注销
* 用户注销
* 物理删除用户,且未做业务上的逻辑判断,慎用
*/
*/
public
function
logoff
()
public
function
logoff
()
{
{
if
(
!
$this
->
request
->
isPost
())
{
if
(
!
$this
->
request
->
isPost
())
{
$this
->
error
(
''
);
$this
->
error
(
''
);
}
}
$userAuth
=
new
UserAuth
();
//
$userAuth = new UserAuth();
$userAuth
->
logoff
();
//
$userAuth->logoff();
$this
->
success
(
'注销成功'
);
$this
->
success
(
'注销成功'
);
}
}
...
...
addons/shopro/service/user/UserAuth.php
View file @
cbc15409
...
@@ -209,13 +209,26 @@ class UserAuth
...
@@ -209,13 +209,26 @@ class UserAuth
/**
/**
* 注销用户
* 注销用户
* 逻辑删除账号,更改用户状态为"禁用"
*/
*/
public
function
logoff
()
public
function
deactivate
()
{
{
$user
=
auth_user
();
$user
=
auth_user
();
$user
=
UserModel
::
get
(
$user
->
id
);
$user
=
UserModel
::
get
(
$user
->
id
);
$user
->
isUpdate
(
true
,[
'user_id'
=>
$user
->
id
])
->
save
([
'status'
=>
'disabled'
]);
$this
->
logout
();
}
$user
->
delete
();
/**
* 注销用户
* 物理删除用户,慎用
*/
public
function
logoff
()
{
$user
=
auth_user
();
$user
=
UserModel
::
get
(
$user
->
id
);
// $user->delete(); // 物理删除账号,慎用
$this
->
logout
();
$this
->
logout
();
}
}
...
...
application/admin/controller/shopro/user/User.php
View file @
cbc15409
...
@@ -96,14 +96,15 @@ class User extends Common
...
@@ -96,14 +96,15 @@ class User extends Common
$result
=
Db
::
transaction
(
function
()
use
(
$list
)
{
$result
=
Db
::
transaction
(
function
()
use
(
$list
)
{
$count
=
0
;
$count
=
0
;
foreach
(
$list
as
$item
)
{
foreach
(
$list
as
$item
)
{
$count
+=
$item
->
delete
();
// $count += $item->delete(); // 物理删除慎用
$count
+=
$item
->
save
([
'status'
=>
'disabled'
]);
// 改成逻辑删除,状态改为"禁用"
}
}
return
$count
;
return
$count
;
});
});
if
(
$result
)
{
if
(
$result
)
{
$this
->
success
(
'
删除
成功'
,
null
,
$result
);
$this
->
success
(
'
禁用
成功'
,
null
,
$result
);
}
else
{
}
else
{
$this
->
error
(
__
(
'No rows were deleted'
));
$this
->
error
(
__
(
'No rows were deleted'
));
}
}
...
...
application/admin/view/shopro/user/user/index.html
View file @
cbc15409
...
@@ -29,6 +29,12 @@
...
@@ -29,6 +29,12 @@
<el-table-column
sortable=
"custom"
prop=
"total_consume"
label=
"总消费"
min-width=
"110"
></el-table-column>
<el-table-column
sortable=
"custom"
prop=
"total_consume"
label=
"总消费"
min-width=
"110"
></el-table-column>
<el-table-column
sortable=
"custom"
prop=
"score"
label=
"积分"
min-width=
"110"
></el-table-column>
<el-table-column
sortable=
"custom"
prop=
"score"
label=
"积分"
min-width=
"110"
></el-table-column>
<el-table-column
sortable=
"custom"
prop=
"money"
label=
"余额"
min-width=
"110"
></el-table-column>
<el-table-column
sortable=
"custom"
prop=
"money"
label=
"余额"
min-width=
"110"
></el-table-column>
<el-table-column
label=
"用户状态"
min-width=
"100"
>
<template
#
default=
"scope"
>
<span
v-if=
"scope.row.status == 'normal'"
class=
"label label-success"
>
正常
</span>
<span
v-if=
"scope.row.status == 'disabled'"
class=
"label label-danger"
>
禁用
</span>
</template>
</el-table-column>
<el-table-column
sortable=
"custom"
prop=
"createtime"
label=
"注册时间"
min-width=
"172"
></el-table-column>
<el-table-column
sortable=
"custom"
prop=
"createtime"
label=
"注册时间"
min-width=
"172"
></el-table-column>
<el-table-column
sortable=
"custom"
prop=
"logintime"
label=
"上次登录"
min-width=
"172"
></el-table-column>
<el-table-column
sortable=
"custom"
prop=
"logintime"
label=
"上次登录"
min-width=
"172"
></el-table-column>
<el-table-column
fixed=
"right"
label=
"操作"
min-width=
"120"
>
<el-table-column
fixed=
"right"
label=
"操作"
min-width=
"120"
>
...
@@ -36,11 +42,11 @@
...
@@ -36,11 +42,11 @@
{if $auth->check('shopro/user/user/detail')}
{if $auth->check('shopro/user/user/detail')}
<el-button
type=
"primary"
link
@
click=
"onDetail(scope.row.id)"
>
查看
</el-button>
<el-button
type=
"primary"
link
@
click=
"onDetail(scope.row.id)"
>
查看
</el-button>
{/if}
{/if}
<el-popconfirm
width=
"fit-content"
confirm-button-text=
"确认"
cancel-button-text=
"取消"
<el-popconfirm
v-if=
"scope.row.status !== 'disabled'"
width=
"fit-content"
confirm-button-text=
"确认"
cancel-button-text=
"取消"
title=
"确认
删除
这条记录?"
@
confirm=
"onDelete(scope.row.id)"
>
title=
"确认
禁用
这条记录?"
@
confirm=
"onDelete(scope.row.id)"
>
<template
#
reference
>
<template
#
reference
>
{if $auth->check('shopro/user/user/delete')}
{if $auth->check('shopro/user/user/delete')}
<el-button
type=
"danger"
link
>
删除
</el-button>
<el-button
type=
"danger"
link
>
禁用
</el-button>
{/if}
{/if}
</template>
</template>
</el-popconfirm>
</el-popconfirm>
...
...
application/admin/view/user/user/index.html
View file @
cbc15409
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<div
class=
"tab-pane fade active in"
id=
"one"
>
<div
class=
"tab-pane fade active in"
id=
"one"
>
<div
class=
"widget-body no-padding"
>
<div
class=
"widget-body no-padding"
>
<div
id=
"toolbar"
class=
"toolbar"
>
<div
id=
"toolbar"
class=
"toolbar"
>
{:build_toolbar('refresh,edit
,del
')}
{:build_toolbar('refresh,edit')}
<div
class=
"dropdown btn-group {:$auth->check('user/user/multi')?'':'hide'}"
>
<div
class=
"dropdown btn-group {:$auth->check('user/user/multi')?'':'hide'}"
>
<a
class=
"btn btn-primary btn-more dropdown-toggle btn-disabled disabled"
data-toggle=
"dropdown"
><i
class=
"fa fa-cog"
></i>
{:__('More')}
</a>
<a
class=
"btn btn-primary btn-more dropdown-toggle btn-disabled disabled"
data-toggle=
"dropdown"
><i
class=
"fa fa-cog"
></i>
{:__('More')}
</a>
<ul
class=
"dropdown-menu text-left"
role=
"menu"
>
<ul
class=
"dropdown-menu text-left"
role=
"menu"
>
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
</div>
</div>
<table
id=
"table"
class=
"table table-striped table-bordered table-hover table-nowrap"
<table
id=
"table"
class=
"table table-striped table-bordered table-hover table-nowrap"
data-operate-edit=
"{:$auth->check('user/user/edit')}"
data-operate-edit=
"{:$auth->check('user/user/edit')}"
data-operate-del=
"{:$auth->check('user/user/del')}"
width=
"100%"
>
width=
"100%"
>
</table>
</table>
</div>
</div>
...
...
public/assets/js/backend/shopro/user/user.js
View file @
cbc15409
...
@@ -13,6 +13,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
...
@@ -13,6 +13,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
drawer
:
false
,
drawer
:
false
,
data
:
{
data
:
{
user
:
{
field
:
'id'
,
value
:
''
},
user
:
{
field
:
'id'
,
value
:
''
},
status
:
''
,
createtime
:
[],
createtime
:
[],
logintime
:
[],
logintime
:
[],
},
},
...
@@ -48,6 +49,29 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
...
@@ -48,6 +49,29 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
}],
}],
}
}
},
},
status
:
{
type
:
'tselect'
,
label
:
'用户状态'
,
value
:
''
,
options
:
{
data
:
[{
label
:
'全部'
,
value
:
'all'
},
{
label
:
'正常'
,
value
:
'normal'
},
{
label
:
'禁用'
,
value
:
'disabled'
}],
props
:
{
label
:
'name'
,
value
:
'type'
,
},
},
},
createtime
:
{
createtime
:
{
type
:
'tdatetimerange'
,
type
:
'tdatetimerange'
,
label
:
'注册时间'
,
label
:
'注册时间'
,
...
...
public/assets/js/backend/user/user.js
View file @
cbc15409
...
@@ -8,7 +8,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
...
@@ -8,7 +8,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
index_url
:
'user/user/index'
,
index_url
:
'user/user/index'
,
add_url
:
'user/user/add'
,
add_url
:
'user/user/add'
,
edit_url
:
'user/user/edit'
,
edit_url
:
'user/user/edit'
,
del_url
:
'user/user/del'
,
//
del_url: 'user/user/del',
multi_url
:
'user/user/multi'
,
multi_url
:
'user/user/multi'
,
table
:
'user'
,
table
:
'user'
,
}
}
...
...
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