Commit 87aa56ee by lizhilin

更新

parent 1fa3835e
......@@ -31,7 +31,9 @@ protected function grid()
for ($i = 1; $i <= $monthNum; $i++) {
$grid->column($i, $i . '月');
}
$grid->column('total', '合计');
$grid->column('total', '合计')->display(function ($val) {
return $val ? $val : '';
});
// $grid->disableViewButton();
// $grid->disableCreateButton();
......
......@@ -2,8 +2,9 @@
namespace App\Admin\Repositories;
use App\Models\Lawyer;
use App\Models\Lawyer as ModelLawyer;
use App\Models\LawyerCost as ModelLawyerCost;
use App\Models\CovenantReceivePayment as ModelCovenantReceivePayment;
//use Dcat\Admin\Repositories\EloquentRepository;
use Dcat\Admin\Repositories\Repository;
use Dcat\Admin\Grid;
......@@ -29,6 +30,12 @@ public function get(Grid\Model $model)
// 获取筛选条件
$year = $model->filter()->input('year') ?? date("Y");
$lnum = $model->filter()->input('no') ?? '';
$lawyer_id = $commission_rate = 0;
if ($lnum) {
$larwerObj = ModelLawyer::where('number', $lnum)->first();
$lawyer_id = $larwerObj->id;
$commission_rate = $larwerObj->commission_rate;
}
$data = [];
$nowyear = date('Y');
......@@ -48,6 +55,24 @@ public function get(Grid\Model $model)
$tmp[$i] = '0.00';
$condition = ['year' => $year, 'month' => $i, 'number' => $lnum];
//创收收款
$receiveMoeny = ModelCovenantReceivePayment::getReceivedMoney($lawyer_id, $year, $i);
if ($val['field'] == 'received_money') {
$tmp[$i] = ModelCovenantReceivePayment::getReceivedMoney($lawyer_id, $year, $i);
}
//提成比例
if ($val['field'] == 'commission_rate') {
$tmp[$i] = strval($commission_rate * 1) . '%';
}
//可提成金额
if ($val['field'] == 'royalty_amount') {
$tmp[$i] = sprintf('%.2f', $receiveMoeny * ($commission_rate / 100));
}
//已支付款项
if ($val['field'] == 'paid_amount') {
$paid_amount = ModelLawyerCost::getPaidAmount($lawyer_id, $year, $i);
$tmp[$i] = sprintf('%.2f', $paid_amount);
}
//基本工资
if ($val['field'] == 'basic_salary') {
$basic_salary = ModelLawyerCost::where($condition)->sum('basic_salary');
......@@ -131,7 +156,9 @@ public function get(Grid\Model $model)
}
//总计
$tmp['total'] += $tmp[$i];
if ($val['field'] != 'commission_rate') {
$tmp['total'] += $tmp[$i];
}
}
$data[$key] = $tmp;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment