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
8179c67a
Commit
8179c67a
authored
Jul 02, 2026
by
刘小敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(agent): 增加佣金流水搜索、导出及批量修改功能
parent
e626a715
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
496 additions
and
191 deletions
+496
-191
Agent.php
application/admin/controller/shopro/agent/Agent.php
+188
-23
apply.php
application/admin/lang/zh-cn/shopro/agent/apply.php
+1
-1
AgentOrderCommission.php
...ication/admin/model/shopro/agent/AgentOrderCommission.php
+6
-6
detail.html
application/admin/view/shopro/agent/agent/detail.html
+45
-153
detail.html
application/admin/view/shopro/agent/apply/detail.html
+2
-2
agent.js
public/assets/js/backend/shopro/agent/agent.js
+249
-3
apply.js
public/assets/js/backend/shopro/agent/apply.js
+5
-3
No files found.
application/admin/controller/shopro/agent/Agent.php
View file @
8179c67a
...
...
@@ -175,24 +175,30 @@ class Agent extends Backend
// 2) param() — 兼容 query string (?ids=1) 和 url_common_param
$ids
=
$this
->
request
->
param
(
'ids'
);
}
if
(
empty
(
$ids
))
{
// 3) get() — 直接读 GET 参数
$ids
=
$this
->
request
->
get
(
'ids'
);
}
if
(
empty
(
$ids
))
{
// 4) pathinfo 正则解析 /ids/数字 或 /ids/数字.html
$pathinfo
=
$this
->
request
->
pathinfo
();
if
(
preg_match
(
'#/ids/(\d+)[.\b]#'
,
$pathinfo
,
$m
))
{
$ids
=
$m
[
1
];
}
}
// if (empty($ids)) {
// // 3) get() — 直接读 GET 参数
// $ids = $this->request->get('ids');
// }
// if (empty($ids)) {
// // 4) pathinfo 正则解析 /ids/数字 或 /ids/数字.html
// $pathinfo = $this->request->pathinfo();
// if (preg_match('#/ids/(\d+)[.\b]#', $pathinfo, $m)) {
// $ids = $m[1];
// }
// }
// echo '[detail] row=' . var_export($row, true), 'notice'; '[detail] ids来源检测: method=' . var_export(func_get_arg(0), true) .
// ' param=' . var_export($this->request->param('ids'), true) .
// ' get=' . var_export($this->request->get('ids'), true) .
// ' pathinfo=' . $this->request->pathinfo() .
// ' 最终ids=' . var_export($ids, true), 'notice';
// 临时调试日志(问题定位后可删除)
\think\Log
::
write
(
'[detail] ids来源检测: method='
.
var_export
(
func_get_arg
(
0
),
true
)
.
' param='
.
var_export
(
$this
->
request
->
param
(
'ids'
),
true
)
.
' get='
.
var_export
(
$this
->
request
->
get
(
'ids'
),
true
)
.
' pathinfo='
.
$this
->
request
->
pathinfo
()
.
' 最终ids='
.
var_export
(
$ids
,
true
),
'notice'
);
//
\think\Log::write('[detail] ids来源检测: method=' . var_export(func_get_arg(0), true) .
//
' param=' . var_export($this->request->param('ids'), true) .
//
' get=' . var_export($this->request->get('ids'), true) .
//
' pathinfo=' . $this->request->pathinfo() .
//
' 最终ids=' . var_export($ids, true), 'notice');
if
(
empty
(
$ids
))
{
if
(
$this
->
request
->
isAjax
())
{
...
...
@@ -201,7 +207,8 @@ class Agent extends Backend
$this
->
error
(
__
(
'Parameter %s can not be empty'
,
'ids'
));
}
$row
=
$this
->
model
->
with
(
'user'
)
->
find
(
$ids
);
$row
=
$this
->
model
->
find
(
$ids
);
if
(
!
$row
)
{
if
(
$this
->
request
->
isAjax
())
{
return
json
([
'code'
=>
0
,
'msg'
=>
'代理商不存在'
,
'total'
=>
0
,
'rows'
=>
[]]);
...
...
@@ -219,6 +226,48 @@ class Agent extends Backend
$sort
=
$this
->
request
->
request
(
'sort'
,
'id'
);
$order
=
$this
->
request
->
request
(
'order'
,
'desc'
);
// 搜索过滤
$searchFields
=
[
'order_id'
=>
'='
,
'order_sn'
=>
'like'
,
'goods_title'
=>
'like'
,
'order_status'
=>
'in'
,
];
foreach
(
$searchFields
as
$field
=>
$op
)
{
$val
=
$this
->
request
->
request
(
$field
,
''
);
if
(
$val
!==
''
)
{
if
(
$op
===
'like'
)
{
$where
[
$field
]
=
[
'like'
,
'%'
.
$val
.
'%'
];
}
elseif
(
$op
===
'in'
)
{
$where
[
$field
]
=
[
'in'
,
explode
(
','
,
$val
)];
}
else
{
$where
[
$field
]
=
$val
;
}
}
}
// 日期范围过滤:创建时间
$createtimeStart
=
$this
->
request
->
request
(
'createtime_range_start'
,
''
);
$createtimeEnd
=
$this
->
request
->
request
(
'createtime_range_end'
,
''
);
if
(
$createtimeStart
!==
''
&&
$createtimeEnd
!==
''
)
{
$where
[
'createtime'
]
=
[
'between'
,
[
strtotime
(
$createtimeStart
),
strtotime
(
$createtimeEnd
.
' 23:59:59'
)]];
}
elseif
(
$createtimeStart
!==
''
)
{
$where
[
'createtime'
]
=
[
'>='
,
strtotime
(
$createtimeStart
)];
}
elseif
(
$createtimeEnd
!==
''
)
{
$where
[
'createtime'
]
=
[
'<='
,
strtotime
(
$createtimeEnd
.
' 23:59:59'
)];
}
// 日期范围过滤:订单创建时间
$orderCreatetimeStart
=
$this
->
request
->
request
(
'order_createtime_range_start'
,
''
);
$orderCreatetimeEnd
=
$this
->
request
->
request
(
'order_createtime_range_end'
,
''
);
if
(
$orderCreatetimeStart
!==
''
&&
$orderCreatetimeEnd
!==
''
)
{
$where
[
'order_createtime'
]
=
[
'between'
,
[
$orderCreatetimeStart
,
$orderCreatetimeEnd
]];
}
elseif
(
$orderCreatetimeStart
!==
''
)
{
$where
[
'order_createtime'
]
=
[
'>='
,
$orderCreatetimeStart
];
}
elseif
(
$orderCreatetimeEnd
!==
''
)
{
$where
[
'order_createtime'
]
=
[
'<='
,
$orderCreatetimeEnd
];
}
// 白名单校验排序字段,防止 SQL 注入
$allowSort
=
[
'id'
,
'commission_amount'
,
'createtime'
,
'order_createtime'
];
if
(
!
in_array
(
$sort
,
$allowSort
))
{
...
...
@@ -235,20 +284,136 @@ class Agent extends Backend
->
select
();
$total
=
$commissionModel
->
where
(
$where
)
->
count
();
return
json
([
'code'
=>
1
,
'total'
=>
$total
,
'rows'
=>
$list
,
]);
$this
->
success
(
'获取佣金流水成功'
,
null
,[
'total'
=>
$total
,
'rows'
=>
$list
]);
}
// 弹窗视图
$this
->
view
->
assign
(
'row'
,
$row
);
$this
->
view
->
assign
(
'statusList'
,
$commissionModel
->
statusList
());
$this
->
view
->
assign
(
'statusList'
,
$this
->
model
->
statusList
());
$this
->
view
->
assign
(
'commissionStatusList'
,
$commissionModel
->
statusList
());
$this
->
view
->
assign
(
'orderStatusList'
,
(
new
\app\admin\model\shopro\order\Order
)
->
statusList
());
return
$this
->
view
->
fetch
();
}
/**
* 导出佣金流水(批量/选中导出)
*/
public
function
export_commission_log
()
{
$ids
=
$this
->
request
->
param
(
'ids'
,
''
);
if
(
empty
(
$ids
))
{
$this
->
error
(
'请选择要导出的记录'
);
}
$idArr
=
array_filter
(
array_map
(
'intval'
,
explode
(
','
,
$ids
)));
if
(
empty
(
$idArr
))
{
$this
->
error
(
'导出数据为空'
);
}
$commissionModel
=
new
\app\admin\model\shopro\agent\AgentOrderCommission
;
$list
=
$commissionModel
->
where
(
'id'
,
'in'
,
$idArr
)
->
order
(
'id'
,
'desc'
)
->
select
();
if
(
empty
(
$list
))
{
$this
->
error
(
'未找到导出数据'
);
}
$statusMap
=
$commissionModel
->
statusList
();
// 生成 Excel
$spreadsheet
=
new
\PhpOffice\PhpSpreadsheet\Spreadsheet
();
$sheet
=
$spreadsheet
->
getActiveSheet
();
// 表头
$headers
=
[
'ID'
,
'订单ID'
,
'订单号'
,
'订单创建时间'
,
'售后订单号'
,
'订单状态'
,
'代理商ID'
,
'代理商用户ID'
,
'买家用户ID'
,
'收货省份'
,
'商品标题'
,
'商品支付金额'
,
'佣金比例快照(%)'
,
'佣金金额'
,
'结算状态'
,
'订单确认时间'
,
'创建时间'
];
$col
=
'A'
;
foreach
(
$headers
as
$header
)
{
$sheet
->
setCellValue
(
$col
.
'1'
,
$header
);
$col
++
;
}
// 数据行
$row
=
2
;
foreach
(
$list
as
$item
)
{
$sheet
->
setCellValue
(
'A'
.
$row
,
$item
->
id
);
$sheet
->
setCellValue
(
'B'
.
$row
,
$item
->
order_id
);
$sheet
->
setCellValue
(
'C'
.
$row
,
$item
->
order_sn
);
$fmt
=
function
(
$time
)
{
if
(
empty
(
$time
))
return
'-'
;
return
is_numeric
(
$time
)
?
date
(
'Y-m-d H:i:s'
,
(
int
)
$time
)
:
$time
;
};
$sheet
->
setCellValue
(
'D'
.
$row
,
$fmt
(
$item
->
order_createtime
));
$sheet
->
setCellValue
(
'E'
.
$row
,
$item
->
aftersale_order_sn
??
'-'
);
$sheet
->
setCellValue
(
'F'
.
$row
,
$item
->
order_status
??
'-'
);
$sheet
->
setCellValue
(
'G'
.
$row
,
$item
->
agent_id
);
$sheet
->
setCellValue
(
'H'
.
$row
,
$item
->
agent_user_id
);
$sheet
->
setCellValue
(
'I'
.
$row
,
$item
->
buyer_user_id
);
$sheet
->
setCellValue
(
'J'
.
$row
,
$item
->
receive_province_name
??
'-'
);
$sheet
->
setCellValue
(
'K'
.
$row
,
$item
->
goods_title
??
'-'
);
$sheet
->
setCellValue
(
'L'
.
$row
,
$item
->
goods_pay_price
?:
0
);
$sheet
->
setCellValue
(
'M'
.
$row
,
$item
->
commission_rate_snapshot
);
$sheet
->
setCellValue
(
'N'
.
$row
,
$item
->
commission_amount
?:
0
);
$sheet
->
setCellValue
(
'O'
.
$row
,
$statusMap
[
$item
->
status
]
??
'-'
);
$sheet
->
setCellValue
(
'P'
.
$row
,
$fmt
(
$item
->
order_confirm_time
));
$sheet
->
setCellValue
(
'Q'
.
$row
,
$fmt
(
$item
->
createtime
));
$row
++
;
}
// 设置列宽
foreach
(
range
(
'A'
,
'Q'
)
as
$c
)
{
$sheet
->
getColumnDimension
(
$c
)
->
setAutoSize
(
true
);
}
// 下载
$fileName
=
'佣金流水_'
.
date
(
'YmdHis'
)
.
'.xlsx'
;
header
(
'Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
);
header
(
'Content-Disposition: attachment;filename="'
.
$fileName
.
'"'
);
header
(
'Cache-Control: max-age=0'
);
$writer
=
new
\PhpOffice\PhpSpreadsheet\Writer\Xlsx
(
$spreadsheet
);
$writer
->
save
(
'php://output'
);
exit
;
}
/**
* 批量修改结算状态
*/
public
function
batch_commission_status
()
{
if
(
!
$this
->
request
->
isPost
())
{
$this
->
error
(
__
(
'Invalid parameters'
));
}
$ids
=
$this
->
request
->
post
(
'ids'
,
''
);
$status
=
$this
->
request
->
post
(
'status'
);
if
(
empty
(
$ids
))
{
$this
->
error
(
'请选择要修改的记录'
);
}
if
(
$status
===
null
||
$status
===
''
)
{
$this
->
error
(
'请选择结算状态'
);
}
$idArr
=
is_array
(
$ids
)
?
$ids
:
explode
(
','
,
$ids
);
$commissionModel
=
new
\app\admin\model\shopro\agent\AgentOrderCommission
;
$allowStatus
=
array_keys
(
$commissionModel
->
statusList
());
if
(
!
in_array
((
int
)
$status
,
$allowStatus
))
{
$this
->
error
(
'无效的结算状态'
);
}
$count
=
$commissionModel
->
where
(
'id'
,
'in'
,
$idArr
)
->
update
([
'status'
=>
(
int
)
$status
]);
if
(
$count
!==
false
)
{
$statusText
=
$commissionModel
->
statusList
()[(
int
)
$status
]
??
$status
;
$this
->
success
(
"已成功更新
{
$count
}
条记录的结算状态为「
{
$statusText
}
」"
);
}
else
{
$this
->
error
(
'更新失败'
);
}
}
/**
* 查看
*/
public
function
index
()
...
...
application/admin/lang/zh-cn/shopro/agent/apply.php
View file @
8179c67a
...
...
@@ -6,7 +6,7 @@ return [
'Province_name'
=>
'省份名称'
,
'Real_name'
=>
'真实姓名'
,
'Id_card'
=>
'身份证号'
,
'Id_card_images'
=>
'身份证照片
(JSON数组)
'
,
'Id_card_images'
=>
'身份证照片'
,
'Status'
=>
'审核状态'
,
'Status pending'
=>
'审核中'
,
'Set status to pending'
=>
'设为审核中'
,
...
...
application/admin/model/shopro/agent/AgentOrderCommission.php
View file @
8179c67a
...
...
@@ -30,12 +30,12 @@ class AgentOrderCommission extends Common
];
}
public
function
getStatusTextAttr
(
$value
,
$data
)
{
$value
=
$value
??
(
$data
[
'status'
]
??
null
);
$map
=
$this
->
statusList
();
return
$map
[
$value
]
??
'-'
;
}
//
public function getStatusTextAttr($value, $data)
//
{
//
$value = $value ?? ($data['status'] ?? null);
//
$map = $this->statusList();
//
return $map[$value] ?? '-';
//
}
// 奖励金额 = 订单金额 * 5%
public
function
getRewardAmountAttr
(
$value
,
$data
)
...
...
application/admin/view/shopro/agent/agent/detail.html
View file @
8179c67a
<!-- 代理商详情弹窗 -->
<div
class=
"panel panel-default"
style=
"border:none;box-shadow:none;margin-bottom:0;"
>
<div
class=
"panel-body"
style=
"padding-top:0;"
>
<!-- 顶部:代理商资料 -->
<!-- 顶部:代理商资料 -->
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
{:__('Agent_info')}
</div>
<div
class=
"panel-body"
>
...
...
@@ -18,13 +17,7 @@
<td>
{$row.user_id}
</td>
</tr>
<tr>
<td><strong>
{:__('User_name')}
</strong></td>
<td>
{$row->user->nickname ?? '-'}
</td>
<td><strong>
{:__('Province_name')}
</strong></td>
<td>
{$row.province_name}
</td>
</tr>
<tr>
<td><strong>
{:__(' ')}
</strong></td>
<td><strong>
{:__('Real_name')}
</strong></td>
<td>
{$row.real_name}
</td>
<td><strong>
{:__('Id_card')}
</strong></td>
<td>
{$row.id_card}
</td>
...
...
@@ -50,8 +43,50 @@
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
{:__('Commission_flow_logs')}
</div>
<div
class=
"panel-body"
>
<div
id=
"commission-toolbar"
>
<!-- 搜索表单 -->
<form
id=
"commission-search-form"
class=
"form-inline"
style=
"margin-bottom:10px;"
>
<div
class=
"form-group"
>
<input
type=
"text"
name=
"order_id"
class=
"form-control"
placeholder=
"订单ID"
style=
"width:90px;"
autocomplete=
"off"
>
</div>
<div
class=
"form-group"
>
<input
type=
"text"
name=
"order_sn"
class=
"form-control"
placeholder=
"订单号"
style=
"width:150px;"
autocomplete=
"off"
>
</div>
<div
class=
"form-group"
>
<input
type=
"text"
name=
"createtime_range"
class=
"form-control datetimerange"
placeholder=
"创建时间"
style=
"width:210px;"
autocomplete=
"off"
readonly
>
</div>
<div
class=
"form-group"
>
<input
type=
"text"
name=
"order_createtime_range"
class=
"form-control datetimerange"
placeholder=
"订单创建时间"
style=
"width:210px;"
autocomplete=
"off"
readonly
>
</div>
<div
class=
"form-group"
>
<input
type=
"text"
name=
"goods_title"
class=
"form-control"
placeholder=
"商品标题"
style=
"width:150px;"
autocomplete=
"off"
>
</div>
<div
class=
"form-group"
>
<select
name=
"order_status"
class=
"form-control selectpicker"
multiple
title=
"订单状态"
data-style=
"btn-default"
data-width=
"180px"
data-selected-text-format=
"count>1"
data-actions-box=
"true"
data-live-search=
"false"
data-select-all-text=
"全选"
data-deselect-all-text=
"清空"
>
{foreach $orderStatusList as $key => $val}
<option
value=
"{$key}"
>
{$val}
</option>
{/foreach}
</select>
</div>
<button
type=
"submit"
class=
"btn btn-primary btn-commission-search"
><i
class=
"fa fa-search"
></i>
搜索
</button>
<button
type=
"reset"
class=
"btn btn-default btn-commission-reset"
><i
class=
"fa fa-undo"
></i>
重置
</button>
</form>
<!-- 批量操作按钮 -->
<div
class=
"commission-batch-actions"
style=
"margin-bottom:8px;"
>
<button
id=
"btn-batch-export"
class=
"btn btn-success btn-xs"
disabled
>
<i
class=
"fa fa-download"
></i>
批量导出
</button>
<button
id=
"btn-batch-status"
class=
"btn btn-warning btn-xs"
disabled
>
<i
class=
"fa fa-edit"
></i>
批量修改结算状态
</button>
</div>
</div>
<table
id=
"commission-table"
class=
"table table-striped table-bordered table-hover table-nowrap"
width=
"100%"
>
width=
"100%"
data-agent-id=
"{$row.id}"
data-status-list=
'{:htmlentities(json_encode($commissionStatusList ?? []))}'
data-order-status-list=
'{:htmlentities(json_encode($orderStatusList ?? []))}'
>
</table>
</div>
</div>
...
...
@@ -59,147 +94,4 @@
</div>
</div>
<script
type=
"text/javascript"
>
require
([
'jquery'
,
'bootstrap'
,
'table'
],
function
(
$
,
undefined
,
Table
)
{
var
commissionTable
=
$
(
"#commission-table"
);
// AJAX 请求地址
var
detailUrl
=
"{:url('shopro/agent/agent/detail', ['ids' => $row['id'] ?? 0])}"
;
// 自定义 AJAX:发送分页参数,调用 params.success 返回数据
var
commissionAjax
=
function
(
params
)
{
$
.
ajax
({
url
:
detailUrl
,
data
:
{
offset
:
params
.
data
.
offset
||
0
,
limit
:
params
.
data
.
limit
||
10
},
type
:
'get'
,
dataType
:
'json'
,
success
:
function
(
res
)
{
params
.
success
({
total
:
res
.
total
||
0
,
rows
:
res
.
rows
||
[]
});
},
error
:
function
(
xhr
,
status
,
error
)
{
console
.
error
(
'[佣金流水] AJAX 请求失败:'
,
status
,
error
,
xhr
.
responseText
);
params
.
success
({
total
:
0
,
rows
:
[]
});
}
});
};
commissionTable
.
bootstrapTable
({
url
:
detailUrl
,
sidePagination
:
'server'
,
pagination
:
true
,
pageSize
:
10
,
pageList
:
[
10
,
20
,
50
],
showRefresh
:
false
,
showToggle
:
false
,
showColumns
:
false
,
method
:
'get'
,
queryParams
:
function
(
params
)
{
return
{
offset
:
params
.
offset
||
0
,
limit
:
params
.
limit
||
10
,
sort
:
params
.
sort
||
''
,
order
:
params
.
order
||
''
};
},
responseHandler
:
function
(
res
)
{
return
{
total
:
res
.
total
||
0
,
rows
:
res
.
rows
||
[]
};
},
ajax
:
commissionAjax
,
columns
:
[
[
{
field
:
'id'
,
title
:
'ID'
,
width
:
60
,
align
:
'center'
,
sortable
:
true
},
{
field
:
'order_id'
,
title
:
'{:__("Order_id")}'
,
width
:
70
,
align
:
'center'
},
{
field
:
'order_sn'
,
title
:
'{:__("Order_sn")}'
,
width
:
160
,
align
:
'center'
},
{
field
:
'order_createtime'
,
title
:
'{:__("Order_createtime")}'
,
width
:
150
,
align
:
'center'
,
formatter
:
function
(
value
)
{
if
(
!
value
)
return
'-'
;
var
d
=
new
Date
(
parseInt
(
value
)
*
1000
);
return
d
.
getFullYear
()
+
'-'
+
(
'0'
+
(
d
.
getMonth
()
+
1
)).
slice
(
-
2
)
+
'-'
+
(
'0'
+
d
.
getDate
()).
slice
(
-
2
)
+
' '
+
(
'0'
+
d
.
getHours
()).
slice
(
-
2
)
+
':'
+
(
'0'
+
d
.
getMinutes
()).
slice
(
-
2
)
+
':'
+
(
'0'
+
d
.
getSeconds
()).
slice
(
-
2
);
}
},
{
field
:
'reward_amount'
,
title
:
'{:__("Reward_amount")}'
,
width
:
100
,
align
:
'center'
,
formatter
:
function
(
value
,
row
)
{
var
price
=
row
.
goods_pay_price
||
0
;
var
reward
=
(
price
*
0.05
).
toFixed
(
2
);
return
'<span style="color:#f39c12;">¥'
+
reward
+
'</span>'
;
}
},
{
field
:
'aftersale_order_sn'
,
title
:
'{:__("Aftersale_order_sn")}'
,
width
:
160
,
align
:
'center'
,
formatter
:
function
(
value
)
{
return
value
||
'-'
;
}
},
{
field
:
'order_status'
,
title
:
'{:__("Order_status")}'
,
width
:
90
,
align
:
'center'
,
formatter
:
function
(
value
)
{
return
value
||
'-'
;
}
},
{
field
:
'agent_id'
,
title
:
'{:__("Agent_id")}'
,
width
:
70
,
align
:
'center'
},
{
field
:
'agent_user_id'
,
title
:
'{:__("Agent_user_id")}'
,
width
:
80
,
align
:
'center'
},
{
field
:
'buyer_user_id'
,
title
:
'{:__("Buyer_user_id")}'
,
width
:
80
,
align
:
'center'
},
{
field
:
'receive_province_name'
,
title
:
'{:__("Receive_province_name")}'
,
width
:
100
,
align
:
'center'
,
formatter
:
function
(
value
)
{
return
value
||
'-'
;
}
},
{
field
:
'goods_title'
,
title
:
'{:__("Goods_title")}'
,
width
:
150
,
align
:
'left'
,
formatter
:
function
(
value
)
{
return
value
||
'-'
;
}
},
{
field
:
'goods_pay_price'
,
title
:
'{:__("Goods_pay_price")}'
,
width
:
100
,
align
:
'center'
,
formatter
:
function
(
value
)
{
return
value
?
'¥'
+
parseFloat
(
value
).
toFixed
(
2
)
:
'-'
;
}
},
{
field
:
'commission_rate_snapshot'
,
title
:
'{:__("Commission_rate_snapshot")}'
,
width
:
100
,
align
:
'center'
,
formatter
:
function
(
value
)
{
return
value
!==
null
&&
value
!==
undefined
?
value
+
'%'
:
'-'
;
}
},
{
field
:
'commission_amount'
,
title
:
'{:__("Commission_amount")}'
,
width
:
100
,
align
:
'center'
,
formatter
:
function
(
value
)
{
return
value
?
'¥'
+
parseFloat
(
value
).
toFixed
(
2
)
:
'-'
;
}
},
{
field
:
'status'
,
title
:
'{:__("Commission_status")}'
,
width
:
80
,
align
:
'center'
,
formatter
:
function
(
value
)
{
var
statusList
=
{:
json_encode
(
$statusList
??
[])};
return
statusList
[
value
]
||
'-'
;
}
},
{
field
:
'order_confirm_time'
,
title
:
'{:__("Order_confirm_time")}'
,
width
:
150
,
align
:
'center'
,
formatter
:
function
(
value
)
{
if
(
!
value
)
return
'-'
;
var
d
=
new
Date
(
parseInt
(
value
)
*
1000
);
return
d
.
getFullYear
()
+
'-'
+
(
'0'
+
(
d
.
getMonth
()
+
1
)).
slice
(
-
2
)
+
'-'
+
(
'0'
+
d
.
getDate
()).
slice
(
-
2
)
+
' '
+
(
'0'
+
d
.
getHours
()).
slice
(
-
2
)
+
':'
+
(
'0'
+
d
.
getMinutes
()).
slice
(
-
2
)
+
':'
+
(
'0'
+
d
.
getSeconds
()).
slice
(
-
2
);
}
},
{
field
:
'createtime'
,
title
:
'{:__("Createtime")}'
,
width
:
150
,
align
:
'center'
,
formatter
:
function
(
value
)
{
if
(
!
value
)
return
'-'
;
var
d
=
new
Date
(
parseInt
(
value
)
*
1000
);
return
d
.
getFullYear
()
+
'-'
+
(
'0'
+
(
d
.
getMonth
()
+
1
)).
slice
(
-
2
)
+
'-'
+
(
'0'
+
d
.
getDate
()).
slice
(
-
2
)
+
' '
+
(
'0'
+
d
.
getHours
()).
slice
(
-
2
)
+
':'
+
(
'0'
+
d
.
getMinutes
()).
slice
(
-
2
)
+
':'
+
(
'0'
+
d
.
getSeconds
()).
slice
(
-
2
);
}
}
]
]
});
});
</script>
application/admin/view/shopro/agent/apply/detail.html
View file @
8179c67a
...
...
@@ -14,10 +14,10 @@
<td>
{:__('User_id')}
</td>
<td>
{$row.user_id}
</td>
</tr>
<tr>
<
!-- <
tr>
<td>{:__('Province_name')}</td>
<td>{$row.province_name}</td>
</tr>
</tr>
-->
<tr>
<td>
{:__('Real_name')}
</td>
<td>
{$row.real_name}
</td>
...
...
public/assets/js/backend/shopro/agent/agent.js
View file @
8179c67a
...
...
@@ -17,7 +17,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
var
table
=
$
(
"#table"
);
// 初始化表格
//
代理商列表页-
初始化表格
table
.
bootstrapTable
({
url
:
$
.
fn
.
bootstrapTable
.
defaults
.
extend
.
index_url
,
pk
:
'id'
,
...
...
@@ -29,7 +29,7 @@ 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
:
'real_name'
,
title
:
__
(
'Real_name'
),
operate
:
'LIKE'
},
{
field
:
'id_card'
,
title
:
__
(
'Id_card'
),
operate
:
'LIKE'
},
{
field
:
'commission_rate'
,
title
:
__
(
'Commission_rate'
),
operate
:
'BETWEEN'
},
...
...
@@ -72,10 +72,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
// 弹窗查看详情
$
(
document
).
on
(
'click'
,
'.btn-detail'
,
function
()
{
var
id
=
$
(
this
).
closest
(
'tr'
).
data
(
'id'
)
||
Table
.
api
.
selectedids
(
table
);
// formatter.operate 按钮只有 data-row-index,没有 data-id
// 需要通过 row-index 从表格数据中获取行记录的 pk(id)
var
rowIndex
=
$
(
this
).
data
(
'row-index'
);
var
rowData
=
Table
.
api
.
getrowbyindex
(
table
,
rowIndex
);
var
id
=
rowData
?
rowData
.
id
:
Table
.
api
.
selectedids
(
table
);
console
.
log
(
'---id:'
+
id
);
if
(
!
id
)
return
;
Fast
.
api
.
open
(
'shopro/agent/agent/detail?ids='
+
id
,
__
(
'Detail'
),
{
callback
:
function
()
{
console
.
log
(
'---66666'
);
table
.
bootstrapTable
(
'refresh'
);
}
});
...
...
@@ -133,6 +139,246 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
edit
:
function
()
{
Controller
.
api
.
bindevent
();
},
detail
:
function
()
{
var
$table
=
$
(
"#commission-table"
);
if
(
!
$table
.
length
)
return
;
var
agentId
=
$table
.
data
(
'agent-id'
);
var
statusList
=
$table
.
data
(
'status-list'
)
||
{};
var
orderStatusList
=
$table
.
data
(
'order-status-list'
)
||
{};
var
detailUrl
=
'shopro/agent/agent/detail?ids='
+
agentId
;
// 初始化 selectpicker
require
([
'bootstrap-select'
],
function
()
{
$
(
'#commission-search-form .selectpicker'
).
selectpicker
();
});
// 初始化日期范围选择器
require
([
'bootstrap-daterangepicker'
],
function
()
{
$
(
'#commission-toolbar .datetimerange'
).
each
(
function
()
{
var
$input
=
$
(
this
);
var
begin
=
$input
.
data
(
'begin'
)
||
(
$input
.
attr
(
'name'
)
+
'_start'
);
var
end
=
$input
.
data
(
'end'
)
||
(
$input
.
attr
(
'name'
)
+
'_end'
);
// 创建隐藏的起止字段
if
(
$input
.
siblings
(
'[name="'
+
begin
+
'"]'
).
length
===
0
)
{
$input
.
after
(
'<input type="hidden" name="'
+
begin
+
'" value="">'
);
}
if
(
$input
.
siblings
(
'[name="'
+
end
+
'"]'
).
length
===
0
)
{
$input
.
after
(
'<input type="hidden" name="'
+
end
+
'" value="">'
);
}
$input
.
daterangepicker
({
autoUpdateInput
:
false
,
locale
:
{
format
:
'YYYY-MM-DD'
,
applyLabel
:
'确定'
,
cancelLabel
:
'取消'
,
daysOfWeek
:
[
'日'
,
'一'
,
'二'
,
'三'
,
'四'
,
'五'
,
'六'
],
monthNames
:
[
'一月'
,
'二月'
,
'三月'
,
'四月'
,
'五月'
,
'六月'
,
'七月'
,
'八月'
,
'九月'
,
'十月'
,
'十一月'
,
'十二月'
],
}
});
$input
.
on
(
'apply.daterangepicker'
,
function
(
ev
,
picker
)
{
$
(
this
).
val
(
picker
.
startDate
.
format
(
'YYYY-MM-DD'
)
+
' - '
+
picker
.
endDate
.
format
(
'YYYY-MM-DD'
));
$input
.
siblings
(
'[name="'
+
begin
+
'"]'
).
val
(
picker
.
startDate
.
format
(
'YYYY-MM-DD'
));
$input
.
siblings
(
'[name="'
+
end
+
'"]'
).
val
(
picker
.
endDate
.
format
(
'YYYY-MM-DD'
));
});
$input
.
on
(
'cancel.daterangepicker'
,
function
()
{
$
(
this
).
val
(
''
);
$input
.
siblings
(
'[name="'
+
begin
+
'"]'
).
val
(
''
);
$input
.
siblings
(
'[name="'
+
end
+
'"]'
).
val
(
''
);
});
});
});
// 构建查询参数
var
buildQueryParams
=
function
(
params
)
{
var
query
=
{
offset
:
params
.
offset
||
0
,
limit
:
params
.
limit
||
10
,
sort
:
params
.
sort
||
'id'
,
order
:
params
.
order
||
'desc'
};
// 处理普通表单字段
$
(
'#commission-search-form'
).
find
(
'input[type="text"],input[type="hidden"]'
).
each
(
function
()
{
var
name
=
$
(
this
).
attr
(
'name'
);
var
val
=
$
(
this
).
val
();
if
(
val
!==
''
&&
name
)
{
query
[
name
]
=
val
;
}
});
// 处理多选下拉框:收集所有选中值,用逗号连接
var
orderStatusSelect
=
$
(
'#commission-search-form select[name="order_status"]'
);
if
(
orderStatusSelect
.
length
&&
orderStatusSelect
.
val
()
&&
orderStatusSelect
.
val
().
length
>
0
)
{
query
.
order_status
=
orderStatusSelect
.
val
().
join
(
','
);
}
return
query
;
};
//代理商-佣金流水
$table
.
bootstrapTable
({
url
:
detailUrl
,
toolbar
:
'#commission-toolbar'
,
sidePagination
:
'server'
,
pagination
:
true
,
pageSize
:
10
,
pageList
:
[
10
,
20
,
50
,
100
],
showRefresh
:
true
,
showToggle
:
false
,
showColumns
:
true
,
showExport
:
true
,
exportDataType
:
'selected'
,
exportTypes
:
[
'excel'
],
exportOptions
:
{
fileName
:
'佣金流水_'
+
new
Date
().
toISOString
().
slice
(
0
,
10
),
ignoreColumn
:
[
0
]
},
method
:
'get'
,
clickToSelect
:
true
,
singleSelect
:
false
,
queryParams
:
buildQueryParams
,
responseHandler
:
function
(
res
)
{
var
data
=
res
.
data
||
res
;
return
{
total
:
data
.
total
||
0
,
rows
:
data
.
rows
||
[]
};
},
columns
:
[
[
{
checkbox
:
true
},
{
field
:
'id'
,
title
:
__
(
'Id'
),
width
:
60
,
align
:
'center'
,
sortable
:
true
},
{
field
:
'order_id'
,
title
:
__
(
'Order_id'
),
width
:
70
,
align
:
'center'
},
{
field
:
'order_sn'
,
title
:
__
(
'Order_sn'
),
width
:
160
,
align
:
'center'
},
{
field
:
'order_createtime'
,
title
:
__
(
'Order_createtime'
),
width
:
150
,
align
:
'center'
,
formatter
:
Table
.
api
.
formatter
.
datetime
},
{
field
:
'reward_amount'
,
title
:
__
(
'Reward_amount'
),
width
:
100
,
align
:
'center'
,
formatter
:
function
(
value
,
row
)
{
var
price
=
row
.
goods_pay_price
||
0
;
return
'<span style="color:#f39c12;">¥'
+
(
price
*
0.05
).
toFixed
(
2
)
+
'</span>'
;
}
},
{
field
:
'aftersale_order_sn'
,
title
:
__
(
'Aftersale_order_sn'
),
width
:
160
,
align
:
'center'
,
formatter
:
function
(
value
)
{
return
value
||
'-'
;
}
},
{
field
:
'order_status'
,
title
:
__
(
'Order_status'
),
width
:
90
,
align
:
'center'
,
formatter
:
function
(
value
)
{
return
orderStatusList
[
value
]
||
value
||
'-'
;
}
},
{
field
:
'agent_id'
,
title
:
__
(
'Agent_id'
),
width
:
70
,
align
:
'center'
},
{
field
:
'agent_user_id'
,
title
:
__
(
'Agent_user_id'
),
width
:
80
,
align
:
'center'
},
{
field
:
'buyer_user_id'
,
title
:
__
(
'Buyer_user_id'
),
width
:
80
,
align
:
'center'
},
{
field
:
'receive_province_name'
,
title
:
__
(
'Receive_province_name'
),
width
:
100
,
align
:
'center'
,
formatter
:
function
(
value
)
{
return
value
||
'-'
;
}
},
{
field
:
'goods_title'
,
title
:
__
(
'Goods_title'
),
width
:
150
,
align
:
'left'
,
formatter
:
function
(
value
)
{
return
value
||
'-'
;
}
},
{
field
:
'goods_pay_price'
,
title
:
__
(
'Goods_pay_price'
),
width
:
100
,
align
:
'center'
,
formatter
:
function
(
value
)
{
return
value
?
'¥'
+
parseFloat
(
value
).
toFixed
(
2
)
:
'-'
;
}
},
{
field
:
'commission_rate_snapshot'
,
title
:
__
(
'Commission_rate_snapshot'
),
width
:
100
,
align
:
'center'
,
formatter
:
function
(
value
)
{
return
value
!==
null
&&
value
!==
undefined
?
value
+
'%'
:
'-'
;
}
},
{
field
:
'commission_amount'
,
title
:
__
(
'Commission_amount'
),
width
:
100
,
align
:
'center'
,
formatter
:
function
(
value
)
{
return
value
?
'¥'
+
parseFloat
(
value
).
toFixed
(
2
)
:
'-'
;
}
},
{
field
:
'status'
,
title
:
__
(
'Commission_status'
),
width
:
80
,
align
:
'center'
,
formatter
:
function
(
value
)
{
return
statusList
[
value
]
||
'-'
;
}
},
{
field
:
'order_confirm_time'
,
title
:
__
(
'Order_confirm_time'
),
width
:
150
,
align
:
'center'
,
formatter
:
Table
.
api
.
formatter
.
datetime
},
{
field
:
'createtime'
,
title
:
__
(
'Createtime'
),
width
:
150
,
align
:
'center'
,
formatter
:
Table
.
api
.
formatter
.
datetime
}
]
]
});
Table
.
api
.
bindevent
(
$table
);
// 搜索按钮
$
(
document
).
on
(
'click'
,
'.btn-commission-search'
,
function
(
e
)
{
e
.
preventDefault
();
$table
.
bootstrapTable
(
'refresh'
);
});
// 重置按钮
$
(
document
).
on
(
'click'
,
'.btn-commission-reset'
,
function
(
e
)
{
e
.
preventDefault
();
$
(
'#commission-search-form'
)[
0
].
reset
();
// 重置 selectpicker
$
(
'#commission-search-form .selectpicker'
).
selectpicker
(
'deselectAll'
);
// 清空日期范围隐藏字段
$
(
'#commission-search-form .datetimerange'
).
val
(
''
).
trigger
(
'cancel.daterangepicker'
);
$table
.
bootstrapTable
(
'refresh'
);
});
// 勾选/取消勾选后控制按钮状态
$table
.
on
(
'check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table'
,
function
()
{
var
selectedIds
=
$
.
map
(
$table
.
bootstrapTable
(
'getSelections'
),
function
(
row
)
{
return
row
.
id
;
});
var
hasSelection
=
selectedIds
.
length
>
0
;
$
(
'#btn-batch-export, #btn-batch-status'
).
prop
(
'disabled'
,
!
hasSelection
);
});
// 批量导出(服务端导出)
$
(
document
).
on
(
'click'
,
'#btn-batch-export'
,
function
()
{
var
selectedIds
=
$
.
map
(
$table
.
bootstrapTable
(
'getSelections'
),
function
(
row
)
{
return
row
.
id
;
});
if
(
selectedIds
.
length
===
0
)
{
Toastr
.
error
(
'请先选择要导出的记录'
);
return
;
}
var
entry
=
location
.
pathname
.
split
(
'/'
)[
1
];
var
url
=
location
.
origin
+
'/'
+
entry
+
'/shopro/agent/agent/export_commission_log?ids='
+
selectedIds
.
join
(
','
);
window
.
open
(
url
);
});
// 批量修改结算状态
$
(
document
).
on
(
'click'
,
'#btn-batch-status'
,
function
()
{
var
selectedIds
=
$
.
map
(
$table
.
bootstrapTable
(
'getSelections'
),
function
(
row
)
{
return
row
.
id
;
});
if
(
selectedIds
.
length
===
0
)
{
Toastr
.
error
(
'请先选择要修改的记录'
);
return
;
}
var
optionsHtml
=
''
;
$
.
each
(
statusList
,
function
(
key
,
val
)
{
optionsHtml
+=
'<option value="'
+
key
+
'">'
+
val
+
'</option>'
;
});
Layer
.
open
({
type
:
1
,
title
:
'批量修改结算状态'
,
area
:
[
'420px'
,
'200px'
],
content
:
'<div style="padding:20px 25px;">'
+
'<div class="form-group">'
+
'<label class="control-label">结算状态</label>'
+
'<select id="c-batch-status" class="form-control">'
+
optionsHtml
+
'</select>'
+
'</div>'
+
'</div>'
,
btn
:
[
'确定'
,
'取消'
],
yes
:
function
(
index
)
{
var
status
=
$
(
'#c-batch-status'
).
val
();
Fast
.
api
.
ajax
({
url
:
'shopro/agent/agent/batch_commission_status'
,
data
:
{
ids
:
selectedIds
.
join
(
','
),
status
:
status
},
success
:
function
()
{
Layer
.
close
(
index
);
$table
.
bootstrapTable
(
'refresh'
);
}
});
}
});
});
},
api
:
{
bindevent
:
function
()
{
Form
.
api
.
bindevent
(
$
(
"form[role=form]"
));
...
...
public/assets/js/backend/shopro/agent/apply.js
View file @
8179c67a
...
...
@@ -51,7 +51,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{
field
:
'real_name'
,
title
:
__
(
'Real_name'
),
operate
:
'LIKE'
},
{
field
:
'id_card'
,
title
:
__
(
'Id_card'
),
operate
:
'LIKE'
},
{
field
:
'status'
,
title
:
__
(
'Status'
),
searchList
:
{
"pending"
:
__
(
'Status pending'
),
"approved"
:
__
(
'Status approved'
),
"rejected"
:
__
(
'Status rejected'
)},
formatter
:
Table
.
api
.
formatter
.
status
},
{
field
:
'reject_reason'
,
title
:
__
(
'Reject_reason'
),
operate
:
'LIKE'
,
table
:
table
,
class
:
'autocontent'
,
formatter
:
Table
.
api
.
formatter
.
content
},
{
field
:
'reject_reason'
,
title
:
__
(
'Reject_reason'
),
operate
:
'LIKE'
,
table
:
table
,
class
:
'autocontent'
,
formatter
:
function
(
value
)
{
return
value
?
value
:
'-'
;
}
},
{
field
:
'audit_user_id'
,
title
:
__
(
'Audit_user_id'
)},
{
field
:
'audit_time'
,
title
:
__
(
'Audit_time'
),
operate
:
'RANGE'
,
addclass
:
'datetimerange'
,
autocomplete
:
false
,
formatter
:
Table
.
api
.
formatter
.
datetime
},
{
field
:
'createtime'
,
title
:
__
(
'Createtime'
),
operate
:
'RANGE'
,
addclass
:
'datetimerange'
,
autocomplete
:
false
,
formatter
:
Table
.
api
.
formatter
.
datetime
},
...
...
@@ -73,14 +73,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
title
:
__
(
'Approve'
),
text
:
__
(
'Approve'
),
icon
:
'fa fa-check'
,
classname
:
'btn btn-success btn-xs btn-approve-one'
classname
:
'btn btn-success btn-xs btn-approve-one'
,
hidden
:
function
(
row
)
{
return
row
.
status
!==
'pending'
;
}
},
{
name
:
'reject'
,
title
:
__
(
'Reject'
),
text
:
__
(
'Reject'
),
icon
:
'fa fa-times'
,
classname
:
'btn btn-danger btn-xs btn-reject-one'
classname
:
'btn btn-danger btn-xs btn-reject-one'
,
hidden
:
function
(
row
)
{
return
row
.
status
!==
'pending'
;
}
}
],
table
:
table
,
...
...
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