1.结算记录中新增结算信息
2.优化渠道页面样式
This commit is contained in:
@@ -32,5 +32,59 @@ class CommissionRecord extends Backend
|
||||
$this->model = new \app\common\model\AgentCommissionRecord();
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function _index(): Response
|
||||
{
|
||||
if ($this->request && $this->request->get('select')) {
|
||||
return $this->select($this->request);
|
||||
}
|
||||
|
||||
list($where, $alias, $limit, $order) = $this->queryBuilder();
|
||||
$res = $this->model
|
||||
->field($this->indexField)
|
||||
->withJoin($this->withJoinTable, $this->withJoinType)
|
||||
->with($this->withJoinTable)
|
||||
->alias($alias)
|
||||
->where($where)
|
||||
->order($order)
|
||||
->paginate($limit);
|
||||
|
||||
$list = $this->enrichCommissionRecordList($res->items());
|
||||
|
||||
return $this->success('', [
|
||||
'list' => $list,
|
||||
'total' => $res->total(),
|
||||
'remark' => get_route_remark(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, mixed> $items
|
||||
* @return array<int, mixed>
|
||||
*/
|
||||
private function enrichCommissionRecordList(array $items): array
|
||||
{
|
||||
if ($items === []) {
|
||||
return $items;
|
||||
}
|
||||
|
||||
$out = [];
|
||||
foreach ($items as $item) {
|
||||
$row = is_array($item) ? $item : (method_exists($item, 'toArray') ? $item->toArray() : []);
|
||||
$gross = strval($row['commission_amount'] ?? '0.00');
|
||||
$fee = strval($row['handling_fee'] ?? '0.00');
|
||||
$net = strval($row['net_commission_amount'] ?? '0.00');
|
||||
if (bccomp($net, '0', 2) <= 0 && (bccomp($gross, '0', 2) > 0 || bccomp($fee, '0', 2) > 0)) {
|
||||
$net = bcsub($gross, $fee, 2);
|
||||
if (bccomp($net, '0', 2) < 0) {
|
||||
$net = '0.00';
|
||||
}
|
||||
$row['net_commission_amount'] = $net;
|
||||
}
|
||||
$out[] = $row;
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user