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
780c393f
Commit
780c393f
authored
Jul 07, 2026
by
刘小敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(agent): 新增禁用状态并支持状态变更日志
- 将代理商状态 frozen 重命名为 freeze,新增 forbidden 禁用状态 - 编辑与批量操作时校验状态值合法性并记录变更日志 - 详情页支持下拉菜单直接修改代理商状态 - 列表页新增状态列筛选及省份字段显示
parent
21dd5358
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
130 additions
and
14 deletions
+130
-14
Agent.php
application/admin/controller/shopro/agent/Agent.php
+69
-0
Agent.php
application/admin/controller/shopro/commission/Agent.php
+4
-0
agent.php
application/admin/lang/zh-cn/shopro/agent/agent.php
+4
-2
Agent.php
application/admin/model/shopro/Agent.php
+1
-1
Agent.php
application/admin/model/shopro/agent/Agent.php
+4
-2
index.html
application/admin/view/shopro/agent/agent/index.html
+2
-2
detail.html
application/admin/view/shopro/commission/agent/detail.html
+28
-5
agent.js
public/assets/js/backend/shopro/agent/agent.js
+2
-1
agent.js
public/assets/js/backend/shopro/commission/agent.js
+16
-1
No files found.
application/admin/controller/shopro/agent/Agent.php
View file @
780c393f
...
...
@@ -73,7 +73,13 @@ class Agent extends Backend
if
(
empty
(
$params
))
{
$this
->
error
(
__
(
'Parameter %s can not be empty'
,
''
));
}
// 校验 status 值合法性
$allowStatus
=
array_keys
(
$this
->
model
->
statusList
());
if
(
isset
(
$params
[
'status'
])
&&
!
in_array
(
$params
[
'status'
],
$allowStatus
))
{
$this
->
error
(
'无效的状态值'
);
}
$oldRate
=
$row
->
commission_rate
;
$oldStatus
=
$row
->
status
;
$result
=
false
;
\think\Db
::
startTrans
();
try
{
...
...
@@ -95,6 +101,10 @@ class Agent extends Backend
$this
->
error
(
$e
->
getMessage
());
}
if
(
$result
!==
false
)
{
// 记录代理商状态变更日志
if
(
isset
(
$params
[
'status'
])
&&
$params
[
'status'
]
!=
$oldStatus
)
{
custom_log
(
"代理商状态变更: agent_id=
{
$row
->
id
}
,
{
$oldStatus
}
->
{
$params
[
'status'
]
}
"
,
$this
->
auth
->
id
??
0
,
'agent_status_change'
,
'info'
);
}
$this
->
success
();
}
else
{
$this
->
error
(
__
(
'No rows updated'
));
...
...
@@ -106,6 +116,65 @@ class Agent extends Backend
}
/**
* 批量更新(重写以记录状态变更日志)
*/
public
function
multi
(
$ids
=
null
)
{
if
(
false
===
$this
->
request
->
isPost
())
{
$this
->
error
(
__
(
'Invalid parameters'
));
}
$ids
=
$ids
?:
$this
->
request
->
post
(
'ids'
);
if
(
empty
(
$ids
))
{
$this
->
error
(
__
(
'Parameter %s can not be empty'
,
'ids'
));
}
if
(
false
===
$this
->
request
->
has
(
'params'
))
{
$this
->
error
(
__
(
'No rows were updated'
));
}
parse_str
(
$this
->
request
->
post
(
'params'
),
$values
);
$values
=
$this
->
auth
->
isSuperAdmin
()
?
$values
:
array_intersect_key
(
$values
,
array_flip
(
is_array
(
$this
->
multiFields
)
?
$this
->
multiFields
:
explode
(
','
,
$this
->
multiFields
)));
if
(
empty
(
$values
))
{
$this
->
error
(
__
(
'You have no permission'
));
}
$adminIds
=
$this
->
getDataLimitAdminIds
();
if
(
is_array
(
$adminIds
))
{
$this
->
model
->
where
(
$this
->
dataLimitField
,
'in'
,
$adminIds
);
}
// 批量操作前记录旧状态(仅当变更 status 字段时)
$oldStatusMap
=
[];
if
(
isset
(
$values
[
'status'
]))
{
$oldStatusMap
=
$this
->
model
->
where
(
$this
->
model
->
getPk
(),
'in'
,
$ids
)
->
column
(
'status'
,
'id'
);
}
$count
=
0
;
\think\Db
::
startTrans
();
try
{
$list
=
$this
->
model
->
where
(
$this
->
model
->
getPk
(),
'in'
,
$ids
)
->
select
();
foreach
(
$list
as
$item
)
{
$count
+=
$item
->
allowField
(
true
)
->
isUpdate
(
true
)
->
save
(
$values
);
}
\think\Db
::
commit
();
}
catch
(
\PDOException
|
\Exception
$e
)
{
\think\Db
::
rollback
();
$this
->
error
(
$e
->
getMessage
());
}
if
(
$count
)
{
// 记录代理商状态变更日志
if
(
isset
(
$values
[
'status'
])
&&
!
empty
(
$oldStatusMap
))
{
$operatorId
=
$this
->
auth
->
id
??
0
;
foreach
(
$oldStatusMap
as
$agentId
=>
$oldStatus
)
{
if
(
$oldStatus
!=
$values
[
'status'
])
{
custom_log
(
"代理商状态变更: agent_id=
{
$agentId
}
,
{
$oldStatus
}
->
{
$values
[
'status'
]
}
"
,
$operatorId
,
'agent_status_change'
,
'info'
);
}
}
}
$this
->
success
();
}
$this
->
error
(
__
(
'No rows were updated'
));
}
/**
* 批量修改佣金比例
*/
public
function
batch_commission_rate
()
...
...
application/admin/controller/shopro/commission/Agent.php
View file @
780c393f
...
...
@@ -133,6 +133,10 @@ class Agent extends Common
// 修改状态
private
function
changeStatus
(
$row
,
$value
)
{
// 仅允许修改为 normal/freeze/forbidden,pending/reject 不允许通过后台直接设置
if
(
!
in_array
(
$value
,
[
'normal'
,
'freeze'
,
'forbidden'
]))
{
$this
->
error
(
'不允许的操作:状态值仅支持正常/冻结/禁用'
);
}
$result
=
$row
->
save
([
'status'
=>
$value
]);
if
(
$result
)
{
LogModel
::
add
(
$row
->
user_id
,
'agent'
,
[
'type'
=>
'status'
,
'value'
=>
$value
]);
...
...
application/admin/lang/zh-cn/shopro/agent/agent.php
View file @
780c393f
...
...
@@ -12,8 +12,10 @@ return [
'Status'
=>
'状态'
,
'Status normal'
=>
'正常'
,
'Set status to normal'
=>
'设为正常'
,
'Status frozen'
=>
'已冻结'
,
'Set status to frozen'
=>
'设为已冻结'
,
'Status freeze'
=>
'已冻结'
,
'Set status to freeze'
=>
'设为已冻结'
,
'Status forbidden'
=>
'已禁用'
,
'Set status to forbidden'
=>
'设为已禁用'
,
'Apply_id'
=>
'关联申请记录ID'
,
'Createtime'
=>
'创建时间'
,
'Updatetime'
=>
'更新时间'
,
...
...
application/admin/model/shopro/Agent.php
View file @
780c393f
...
...
@@ -32,7 +32,7 @@ class Agent extends Model
public
function
getStatusList
()
{
return
[
'normal'
=>
__
(
'Status normal'
),
'fr
ozen'
=>
__
(
'Status froz
en'
)];
return
[
'normal'
=>
__
(
'Status normal'
),
'fr
eeze'
=>
__
(
'Status freeze'
),
'forbidden'
=>
__
(
'Status forbidd
en'
)];
}
...
...
application/admin/model/shopro/agent/Agent.php
View file @
780c393f
...
...
@@ -16,13 +16,15 @@ class Agent extends Common
// 代理商状态
const
STATUS_NORMAL
=
'normal'
;
// 正常
const
STATUS_FROZEN
=
'frozen'
;
// 已冻结
const
STATUS_FREEZE
=
'freeze'
;
// 已冻结
const
STATUS_FORBIDDEN
=
'forbidden'
;
// 已禁用
public
function
statusList
()
{
return
[
self
::
STATUS_NORMAL
=>
'正常'
,
self
::
STATUS_FROZEN
=>
'已冻结'
,
self
::
STATUS_FREEZE
=>
'已冻结'
,
self
::
STATUS_FORBIDDEN
=>
'已禁用'
,
];
}
...
...
application/admin/view/shopro/agent/agent/index.html
View file @
780c393f
...
...
@@ -25,9 +25,9 @@
<div
class=
"dropdown btn-group {:$auth->check('shopro/agent/agent/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>
<ul
class=
"dropdown-menu text-left"
role=
"menu"
>
<!--
{foreach name="statusList" item="vo"}
{foreach name="statusList" item="vo"}
<li><a
class=
"btn btn-link btn-multi btn-disabled disabled"
href=
"javascript:"
data-params=
"status={$key}"
>
{:__('Set status to ' . $key)}
</a></li>
{/foreach}
-->
{/foreach}
<li
role=
"separator"
class=
"divider"
></li>
<li><a
class=
"btn btn-link btn-commission-rate btn-disabled disabled"
href=
"javascript:"
><i
class=
"fa fa-percent"
></i>
{:__('Batch_commission_rate')}
</a></li>
</ul>
...
...
application/admin/view/shopro/commission/agent/detail.html
View file @
780c393f
...
...
@@ -161,11 +161,34 @@
</div>
<el-form
size=
"small"
label-position=
"right"
label-width=
"76px"
>
<el-form-item
label=
"分销商状态:"
>
<span
class=
"status"
:style=
"{
color: statusStyle[state.data.status]?.color,
}"
>
{{ state.data.status_text }}
</span>
<template
v-if=
"allowEditStatus"
>
<el-dropdown
popper-class=
"agent-popover"
trigger=
"click"
@
command=
"onChangeStatus"
>
<span
class=
"status"
:style=
"{
color: statusStyle[state.data.status]?.color,
}"
>
{{ state.data.status_text }}
<el-icon>
<arrow-down
/>
</el-icon>
</span>
<template
#
dropdown
>
{if $auth->check('shopro/commission/agent/edit')}
<el-dropdown-menu>
<el-dropdown-item
v-for=
"item in editableStatusList"
:key=
"item.value"
:command=
"item.value"
:style=
"{ color: item.color }"
>
{{ item.label }}
</el-dropdown-item>
</el-dropdown-menu>
{/if}
</template>
</el-dropdown>
</template>
<template
v-else
>
<span
class=
"status"
:style=
"{
color: statusStyle[state.data.status]?.color,
}"
>
{{ state.data.status_text }}
</span>
</template>
</el-form-item>
<el-form-item
label=
"分销等级:"
>
<template
v-if=
"state.data.level_info"
>
...
...
public/assets/js/backend/shopro/agent/agent.js
View file @
780c393f
...
...
@@ -29,7 +29,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{
checkbox
:
true
},
{
field
:
'id'
,
title
:
__
(
'Id'
)},
{
field
:
'user_id'
,
title
:
__
(
'User_id'
)},
// {field: 'province_name', title: __('Province_name'), operate: 'LIKE'},
{
field
:
'province_name'
,
title
:
__
(
'Province_name'
),
operate
:
'LIKE'
},
{
field
:
'status'
,
title
:
__
(
'Status'
),
searchList
:
{
"normal"
:
__
(
'Status normal'
),
"freeze"
:
__
(
'Status freeze'
),
"forbidden"
:
__
(
'Status forbidden'
)},
formatter
:
Table
.
api
.
formatter
.
status
},
{
field
:
'real_name'
,
title
:
__
(
'Real_name'
),
operate
:
'LIKE'
},
{
field
:
'id_card'
,
title
:
__
(
'Id_card'
),
operate
:
'LIKE'
},
{
field
:
'commission_rate'
,
title
:
__
(
'Commission_rate'
),
operate
:
'BETWEEN'
},
...
...
public/assets/js/backend/shopro/commission/agent.js
View file @
780c393f
...
...
@@ -220,7 +220,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
createApp
(
'index'
,
index
);
},
detail
:
()
=>
{
const
{
reactive
,
onMounted
}
=
Vue
const
{
reactive
,
onMounted
,
computed
}
=
Vue
const
detail
=
{
setup
()
{
...
...
@@ -229,6 +229,19 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
data
:
{},
})
// 仅允许修改的分销商状态列表
const
editableStatusList
=
[
{
label
:
'正常'
,
value
:
'normal'
,
color
:
'#52c41a'
},
{
label
:
'冻结'
,
value
:
'freeze'
,
color
:
'#409eff'
},
{
label
:
'禁用'
,
value
:
'forbidden'
,
color
:
'#999999'
},
];
// 仅 normal/freeze/forbidden 可修改,pending/reject 不可修改
const
allowEditStatus
=
computed
(()
=>
{
const
editableValues
=
editableStatusList
.
map
(
item
=>
item
.
value
);
return
editableValues
.
includes
(
state
.
data
.
status
);
});
function
getDetail
()
{
Fast
.
api
.
ajax
({
url
:
`shopro/commission/agent/detail/id/
${
state
.
id
}
`
,
...
...
@@ -359,6 +372,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
...
Controller
.
data
(),
state
,
getDetail
,
editableStatusList
,
allowEditStatus
,
onChangeStatus
,
onChangeLevel
,
onChangeParentUser
,
...
...
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