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
a7408baf
Commit
a7408baf
authored
Jul 01, 2026
by
刘小敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(agent): 添加批量修改佣金比例及代理申请校验
parent
9f18d225
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
98 additions
and
24 deletions
+98
-24
Agent.php
addons/shopro/controller/user/Agent.php
+7
-1
ApplyService.php
addons/shopro/service/agent/ApplyService.php
+2
-15
Agent.php
application/admin/controller/shopro/agent/Agent.php
+31
-0
agent.php
application/admin/lang/zh-cn/shopro/agent/agent.php
+7
-5
index.html
application/admin/view/shopro/agent/agent/index.html
+5
-3
agent.js
public/assets/js/backend/shopro/agent/agent.js
+46
-0
No files found.
addons/shopro/controller/user/Agent.php
View file @
a7408baf
...
...
@@ -24,10 +24,16 @@ class Agent extends Common
$userId
=
$user
->
id
??
0
;
custom_log
(
'[agent.apply] 收到代理申请请求, user_id='
.
$userId
,
$userId
,
'share'
);
// 校验是否为分销商
$isDistributor
=
\app\admin\model\shopro\commission\Agent
::
where
(
'user_id'
,
$userId
)
->
find
();
if
(
!
$isDistributor
)
{
$this
->
error
(
'请先申请成为分销商'
);
}
$params
=
$this
->
request
->
only
([
'real_name'
,
'id_card'
,
'id_card_images'
]);
custom_log
(
'[agent.apply] 解析参数: '
.
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
),
$userId
,
'share'
);
$this
->
svalidate
(
$params
,
'
\addons\shopro\validate\user\User
.agentApply'
);
$this
->
svalidate
(
$params
,
'.agentApply'
);
custom_log
(
'[agent.apply] 参数校验通过'
,
$userId
,
'share'
);
$service
=
new
\addons\shopro\service\agent\ApplyService
(
$user
);
...
...
addons/shopro/service/agent/ApplyService.php
View file @
a7408baf
...
...
@@ -39,29 +39,16 @@ class ApplyService
throw
new
\think\Exception
(
'您已是代理商,无需重复申请'
);
}
// 3. 校验省份是否已被代理
if
(
AgentModel
::
hasActiveAgent
(
$params
[
'province_id'
]))
{
throw
new
\think\Exception
(
'该省份已有代理商'
);
}
// 4. 获取省份名称
$province
=
AreaModel
::
where
(
'id'
,
$params
[
'province_id'
])
->
where
(
'level'
,
'province'
)
->
find
();
if
(
!
$province
)
{
throw
new
\think\Exception
(
'省份不存在'
);
}
// 5. 写入申请记录
// 3. 写入申请记录
$apply
=
ApplyModel
::
create
([
'user_id'
=>
$userId
,
'province_id'
=>
$params
[
'province_id'
],
'province_name'
=>
$province
->
name
,
'real_name'
=>
$params
[
'real_name'
],
'id_card'
=>
$params
[
'id_card'
],
'id_card_images'
=>
$params
[
'id_card_images'
]
??
[],
'status'
=>
ApplyModel
::
STATUS_PENDING
,
]);
custom_log
(
'[agent.apply] 代理申请提交成功, apply_id='
.
$apply
->
id
.
', user_id='
.
$userId
.
', province='
.
$province
->
name
,
$userId
,
'share'
);
custom_log
(
'[agent.apply] 代理申请提交成功, apply_id='
.
$apply
->
id
.
', user_id='
.
$userId
,
$userId
,
'share'
);
return
$apply
;
}
...
...
application/admin/controller/shopro/agent/Agent.php
View file @
a7408baf
...
...
@@ -94,6 +94,37 @@ class Agent extends Backend
}
/**
* 批量修改佣金比例
*/
public
function
batch_commission_rate
()
{
if
(
!
$this
->
request
->
isPost
())
{
$this
->
error
(
__
(
'Invalid parameters'
));
}
$ids
=
$this
->
request
->
post
(
'ids'
);
if
(
empty
(
$ids
))
{
$this
->
error
(
__
(
'Parameter %s can not be empty'
,
'ids'
));
}
$rate
=
$this
->
request
->
post
(
'commission_rate'
);
if
(
$rate
===
null
||
$rate
===
''
)
{
$this
->
error
(
'请输入佣金比例'
);
}
$rate
=
round
(
floatval
(
$rate
),
2
);
if
(
$rate
<
0
||
$rate
>
100
)
{
$this
->
error
(
'佣金比例应在0-100之间'
);
}
$ids
=
is_array
(
$ids
)
?
$ids
:
explode
(
','
,
$ids
);
$count
=
$this
->
model
->
where
(
'id'
,
'in'
,
$ids
)
->
update
([
'commission_rate'
=>
$rate
]);
if
(
$count
!==
false
)
{
$this
->
success
(
"已成功更新
{
$count
}
条记录的佣金比例为
{
$rate
}
%"
);
}
else
{
$this
->
error
(
'更新失败'
);
}
}
/**
* 查看
*/
public
function
index
()
...
...
application/admin/lang/zh-cn/shopro/agent/agent.php
View file @
a7408baf
...
...
@@ -17,9 +17,11 @@ return [
'Apply_id'
=>
'关联申请记录ID'
,
'Createtime'
=>
'创建时间'
,
'Updatetime'
=>
'更新时间'
,
'Commission_logs'
=>
'佣金流水记录'
,
'Order_id'
=>
'订单ID'
,
'Amount'
=>
'佣金金额'
,
'Type'
=>
'流水类型'
,
'Remark'
=>
'备注'
,
'Commission_logs'
=>
'佣金流水记录'
,
'Order_id'
=>
'订单ID'
,
'Amount'
=>
'佣金金额'
,
'Type'
=>
'流水类型'
,
'Remark'
=>
'备注'
,
'Batch_commission_rate'
=>
'批量修改佣金比例'
,
'Please_input_commission_rate'
=>
'请输入佣金比例(0-100)'
,
];
application/admin/view/shopro/agent/agent/index.html
View file @
a7408baf
...
...
@@ -17,9 +17,9 @@
<div
class=
"widget-body no-padding"
>
<div
id=
"toolbar"
class=
"toolbar"
>
<a
href=
"javascript:;"
class=
"btn btn-primary btn-refresh"
title=
"{:__('Refresh')}"
><i
class=
"fa fa-refresh"
></i>
</a>
<
a
href=
"javascript:;"
class=
"btn btn-success btn-add {:$auth->check('shopro/agent/agent/add')?'':'hide'}"
title=
"{:__('Add')}"
><i
class=
"fa fa-plus"
></i>
{:__('Add')}
</a
>
<
a
href=
"javascript:;"
class=
"btn btn-success btn-edit btn-disabled disabled {:$auth->check('shopro/agent/agent/edit')?'':'hide'}"
title=
"{:__('Edit')}"
><i
class=
"fa fa-pencil"
></i>
{:__('Edit')}
</a
>
<
a
href=
"javascript:;"
class=
"btn btn-danger btn-del btn-disabled disabled {:$auth->check('shopro/agent/agent/del')?'':'hide'}"
title=
"{:__('Delete')}"
><i
class=
"fa fa-trash"
></i>
{:__('Delete')}
</a
>
<
!-- <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('shopro/agent/agent/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a> --
>
<
!-- <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('shopro/agent/agent/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a> --
>
<
!-- <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('shopro/agent/agent/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a> --
>
<div
class=
"dropdown btn-group {:$auth->check('shopro/agent/agent/multi')?'':'hide'}"
>
...
...
@@ -28,6 +28,8 @@
{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}
<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>
</div>
...
...
public/assets/js/backend/shopro/agent/agent.js
View file @
a7408baf
...
...
@@ -45,6 +45,52 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
// 为表格绑定事件
Table
.
api
.
bindevent
(
table
);
// 批量修改佣金比例按钮
$
(
document
).
on
(
'click'
,
'.btn-commission-rate'
,
function
()
{
var
ids
=
Table
.
api
.
selectedids
(
table
);
if
(
ids
.
length
===
0
)
{
Toastr
.
error
(
lang
(
'Please select at least one record'
));
return
;
}
Layer
.
open
({
type
:
1
,
title
:
__
(
'Batch_commission_rate'
),
area
:
[
'420px'
,
'220px'
],
content
:
'<div style="padding:20px 25px;">'
+
'<div class="form-group">'
+
'<label class="control-label">'
+
__
(
'Commission_rate'
)
+
'</label>'
+
'<input id="c-batch-rate" class="form-control" type="number" step="0.01" min="0" max="100" value="" placeholder="'
+
__
(
'Please_input_commission_rate'
)
+
'">'
+
'</div>'
+
'</div>'
,
btn
:
[
__
(
'Ok'
),
__
(
'Cancel'
)],
yes
:
function
(
index
)
{
var
rate
=
$
(
'#c-batch-rate'
).
val
();
if
(
rate
===
''
||
isNaN
(
rate
))
{
Toastr
.
error
(
'请输入有效的数字'
);
return
;
}
rate
=
parseFloat
(
rate
);
if
(
rate
<
0
||
rate
>
100
)
{
Toastr
.
error
(
'佣金比例应在0-100之间'
);
return
;
}
rate
=
Math
.
round
(
rate
*
100
)
/
100
;
Fast
.
api
.
ajax
({
url
:
'shopro/agent/agent/batch_commission_rate'
,
data
:
{
ids
:
ids
.
join
(
','
),
commission_rate
:
rate
},
success
:
function
()
{
Layer
.
close
(
index
);
table
.
bootstrapTable
(
'refresh'
);
}
});
}
});
});
},
add
:
function
()
{
Controller
.
api
.
bindevent
();
...
...
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