Commit 78f7c207 by lizhilin

更新

parent 2f291d78
...@@ -25,46 +25,50 @@ class LawyerCollectController extends AdminController ...@@ -25,46 +25,50 @@ class LawyerCollectController extends AdminController
protected function grid() protected function grid()
{ {
return Grid::make(new LawyerCollect(), function (Grid $grid) { return Grid::make(new LawyerCollect(), function (Grid $grid) {
//筛选参数
$number = $grid->model()->filter()->input('number') ?? ''; //律师编号 $received_at = $invoiced_at = $params = [];
$year = $grid->model()->filter()->input('year') ?? date("Y"); //律师编号 $params['number'] = $_GET['number'] ?? ''; //律师编号
$received_at = $invoiced_at = []; $params['year'] = $_GET['number'] ?? date('Y'); //律师编号
$received_at['start'] = $_GET['received_at']['start'] ?? ''; $received_at['start'] = isset($_GET['received_at']['start']) && $_GET['received_at']['start'] ? $_GET['received_at']['start'] . "-01" : '';
$received_at['end'] = $_GET['received_at']['end'] ?? ''; $received_at['end'] = isset($_GET['received_at']['end']) && $_GET['received_at']['end'] ? $_GET['received_at']['end'] . "-31" : '';
$invoiced_at['start'] = $_GET['invoiced_at']['start'] ?? ''; $invoiced_at['start'] = isset($_GET['invoiced_at']['start']) && $_GET['invoiced_at']['start'] ? $_GET['invoiced_at']['start'] . '-01' : '';
$invoiced_at['end'] = $_GET['invoiced_at']['end'] ?? ''; $invoiced_at['end'] = isset($_GET['invoiced_at']['end']) && $_GET['invoiced_at']['end'] ? $_GET['invoiced_at']['end'] . '-31' : '';
$lawyer_id = 0; $lawyer_id = 0;
$number = $params['number'];
$year = $params['year'];
$lawyObj = ModelLawyer::where('number', $number)->first(); $lawyObj = ModelLawyer::where('number', $number)->first();
if ($lawyObj) { if ($lawyObj) {
$lawyer_id = $lawyObj->number; $lawyer_id = $lawyObj->number;
} }
$totalInfo = ModelLawyer::getTotalInfo($params, $received_at, $invoiced_at);
//创收已收款 //创收已收款
$received_amount = ModelsCovenantReceivePayment::getReceivedMoneyByNumber($number, $year, $received_at, $invoiced_at); $received_amount = $totalInfo['receipt_money']; //ModelsCovenantReceivePayment::getReceivedMoneyByNumber($number, $year, $received_at, $invoiced_at);
//已开票 //已开票
$invoiced_money = ModelsCovenantReceivePayment::getInvoicedMoneyByNumber($number, $year, $received_at, $invoiced_at); $invoiced_money = $totalInfo['invoiced_money']; //ModelsCovenantReceivePayment::getInvoicedMoneyByNumber($number, $year, $received_at, $invoiced_at);
//收款未开票 //收款未开票
$received_noinvoiced = ($received_amount - $invoiced_money) > 0 ? $received_amount - $invoiced_money : 0; $received_noinvoiced = ($received_amount - $invoiced_money) > 0 ? $received_amount - $invoiced_money : 0;
//开票未收款 //开票未收款
$invoiced_noreceived = ($invoiced_money - $received_amount) > 0 ? $invoiced_money - $received_amount : 0; $invoiced_noreceived = ($invoiced_money - $received_amount) > 0 ? $invoiced_money - $received_amount : 0;
//提成金额 //提成金额
$commissionAmount = ModelsCovenantReceivePayment::getCommissionAmount($number, $year, $received_at); $commissionAmount = $totalInfo['commission_amount']; //ModelsCovenantReceivePayment::getCommissionAmount($number, $year, $received_at);
//成本合计 //成本合计
$costTotal = ModelLawyerCost::getTotalCost($lawyer_id, $year); $costTotal = $totalInfo['cost'];
//基本工资 //基本工资
$basicSalary = ModelLawyerCost::getBasiSalary($lawyer_id, $year); $basicSalary = $totalInfo['salary'];
//专项附加 //专项附加
$special_additional = ModelLawyerCost::getSpecialAdditional($lawyer_id, $year); $special_additional = $totalInfo['special_additional'];
//社保 //社保
$social = ModelLawyerCost::getSocial($lawyer_id, $year); $social = $totalInfo['social'];
//公积金 //公积金
$accumulation_fund = ModelLawyerCost::getAccumulationFund($lawyer_id, $year); $accumulation_fund = $totalInfo['accumulation_fund'];
//贴票金额 //贴票金额
$posting_tickets = ModelLawyerCost::getAllPostingTicketsMoney($lawyer_id, $year); $posting_tickets = $totalInfo['tickets_money'];
//预支款 //预支款
$advance_fee = ModelLawyerCost::getAdvanceFee($lawyer_id, $year); $advance_fee = $totalInfo['advance_fee'];
//可结算提成 //可结算提成
$payable_amount = ModelLawyerCost::getAllPayableAmount($lawyer_id, $year); $payable_amount = $totalInfo['payable_commission'];
// 添加一行表头数据 // 添加一行表头数据
$grid->header(function () use ($received_amount, $commissionAmount, $received_noinvoiced, $invoiced_noreceived, $costTotal, $basicSalary, $special_additional, $social, $accumulation_fund, $posting_tickets, $advance_fee, $payable_amount) { $grid->header(function () use ($received_amount, $commissionAmount, $received_noinvoiced, $invoiced_noreceived, $costTotal, $basicSalary, $special_additional, $social, $accumulation_fund, $posting_tickets, $advance_fee, $payable_amount) {
return '<div class="table-responsive table-wrapper complex-container table-middle mt-1 table-collapse "> return '<div class="table-responsive table-wrapper complex-container table-middle mt-1 table-collapse ">
......
...@@ -38,14 +38,15 @@ public function get(Grid\Model $model) ...@@ -38,14 +38,15 @@ public function get(Grid\Model $model)
$lname = $model->filter()->input('name'); $lname = $model->filter()->input('name');
$year = $model->filter()->input('year') ?? date("Y"); $year = $model->filter()->input('year') ?? date("Y");
$received_at = $invoiced_at = []; $received_at = $invoiced_at = [];
$received_at['start'] = $_GET['received_at']['start'] ?? ''; $received_at['start'] = isset($_GET['received_at']['start']) && $_GET['received_at']['start'] ? $_GET['received_at']['start'] . "-01" : '';
$received_at['end'] = $_GET['received_at']['end'] ?? ''; $received_at['end'] = isset($_GET['received_at']['end']) && $_GET['received_at']['end'] ? $_GET['received_at']['end'] . "-31" : '';
$invoiced_at['start'] = $_GET['invoiced_at']['start'] ?? ''; $invoiced_at['start'] = isset($_GET['invoiced_at']['start']) && $_GET['invoiced_at']['start'] ? $_GET['invoiced_at']['start'] . '-01' : '';
$invoiced_at['end'] = $_GET['invoiced_at']['end'] ?? ''; $invoiced_at['end'] = isset($_GET['invoiced_at']['end']) && $_GET['invoiced_at']['end'] ? $_GET['invoiced_at']['end'] . '-31' : '';
$param = [ $param = [
'sort' => $sort, 'sort' => $sort,
'start' => $start, 'offsetstart' => $start,
'search' => [ 'search' => [
'number' => $number, 'number' => $number,
'lname' => $lname, 'lname' => $lname,
...@@ -67,13 +68,28 @@ public function get(Grid\Model $model) ...@@ -67,13 +68,28 @@ public function get(Grid\Model $model)
public function getList(array $param) public function getList(array $param)
{ {
$prePage = $param['per_page'] ?? 20; $prePage = $param['per_page'] ?? 20;
$start = $param['start'] ?? 0; $offsetstart = $param['offsetstart'] ?? 0;
$number = $param['search']['number'] ?? ''; $number = $param['search']['number'] ?? '';
$lname = $param['search']['lname'] ?? ''; $lname = $param['search']['lname'] ?? '';
$year = $param['search']['year'] ?? date("Y"); $year = $param['search']['year'] ?? date("Y");
$invoiced_at = $param['search']['invoiced_at'] ?? []; $invoiced_at = $param['search']['invoiced_at'] ?? [];
$received_at = $param['search']['received_at'] ?? []; $received_at = $param['search']['received_at'] ?? [];
$list = []; $list = [];
$note_monitor = DB::table('covenant_receive_payment AS rp')
->select(DB::raw('rp.lawyer_id,rp.year,l.number as lnumber,l.name as lname,l.commission_rate,sum(invoiced_money) as invoiced_money,sum(received_amount) as received_amount'))
//->select(['rp.*', 'l.name as lname', 'l.number as lnumber', 'l.commission_rate'])
->leftJoin('lawyer as l', 'rp.lawyer_id', '=', 'l.id');
if ($number) {
$note_monitor = $note_monitor->where("l.number", $number);
}
if ($lname) {
$note_monitor = $note_monitor->where("l.name", $lname);
}
if ($year) {
$note_monitor = $note_monitor->where("rp.year", $year);
}
if ($invoiced_at['start'] && $received_at['start']) { if ($invoiced_at['start'] && $received_at['start']) {
$in_start = $invoiced_at['start'] ?? ''; $in_start = $invoiced_at['start'] ?? '';
$in_end = $invoiced_at['end'] ?? ''; $in_end = $invoiced_at['end'] ?? '';
...@@ -81,65 +97,31 @@ public function getList(array $param) ...@@ -81,65 +97,31 @@ public function getList(array $param)
$re_end = $received_at['end'] ?? ''; $re_end = $received_at['end'] ?? '';
if ($in_start && $re_start) { if ($in_start && $re_start) {
if ($in_end && $re_end) { if ($in_end && $re_end) {
$note_monitor = DB::table('covenant_receive_payment AS rp') $note_monitor = $note_monitor->whereBetween('rp.received_at', [$re_start, $re_end])
->select(['rp.*', 'l.name as lname', 'l.number as lnumber', 'l.commission_rate']) ->whereBetween('rp.invoiced_at', [$in_start, $in_end]);
->leftJoin('lawyer as l', 'rp.lawyer_id', '=', 'l.id')
->whereBetween('rp.received_at', [$re_start, $re_end])
->whereBetween('rp.invoiced_at', [$in_start, $in_end])
->groupBy('rp.lawyer_id');
} else { } else {
if ($in_end) { if ($in_end) {
$note_monitor = DB::table('covenant_receive_payment AS rp') $note_monitor = $note_monitor->whereDate('rp.received_at', '>', $re_start)
->select(['rp.*', 'l.name as lname', 'l.number as lnumber', 'l.commission_rate']) ->whereBetween('rp.invoiced_at', [$in_start, $in_end]);
->leftJoin('lawyer as l', 'rp.lawyer_id', '=', 'l.id')
->whereDate('rp.received_at', '>', $re_start)
->whereBetween('rp.invoiced_at', [$in_start, $in_end])
->groupBy('rp.lawyer_id');
} elseif ($re_end) { } elseif ($re_end) {
$note_monitor = DB::table('covenant_receive_payment AS rp') $note_monitor = $note_monitor->whereDate('rp.invoiced_at', '>', $in_start)
->select(['rp.*', 'l.name as lname', 'l.number as lnumber', 'l.commission_rate']) ->whereBetween('rp.received_at', [$re_start, $re_end]);
->leftJoin('lawyer as l', 'rp.lawyer_id', '=', 'l.id')
->whereDate('rp.invoiced_at', '>', $in_start)
->whereBetween('rp.received_at', [$re_start, $re_end])
->groupBy('rp.lawyer_id');
} else { } else {
$note_monitor = DB::table('covenant_receive_payment AS rp') $note_monitor = $note_monitor->whereDate('rp.invoiced_at', '>', $in_start)
->select(['rp.*', 'l.name as lname', 'l.number as lnumber', 'l.commission_rate']) ->whereDate('rp.received_at', '>', $re_start);
->leftJoin('lawyer as l', 'rp.lawyer_id', '=', 'l.id')
->whereDate('rp.invoiced_at', '>', $in_start)
->whereDate('rp.received_at', '>', $re_start)
->groupBy('rp.lawyer_id');
} }
} }
} }
// 计算列表总数
$count = $note_monitor->count();
// 获取列表
$data = [];
$list = $note_monitor->limit($prePage)->offset($start)->orderBy('rp.cid', 'desc')->get()->toArray();
} elseif ($invoiced_at['start'] && !$received_at['start']) { //开票日期 } elseif ($invoiced_at['start'] && !$received_at['start']) { //开票日期
$start = $invoiced_at['start'] ?? ''; $start = $invoiced_at['start'] ?? '';
$end = $invoiced_at['end'] ?? ''; $end = $invoiced_at['end'] ?? '';
if ($start) { if ($start) {
if ($end) { if ($end) {
$note_monitor = DB::table('covenant_receive_payment AS rp') $note_monitor = $note_monitor->whereBetween('rp.received_at', [$start, $end]);
->select(['rp.*', 'l.name as lname', 'l.number as lnumber', 'l.commission_rate'])
->leftJoin('lawyer as l', 'rp.lawyer_id', '=', 'l.id')
->whereBetween('rp.received_at', [$start, $end])
->groupBy('rp.lawyer_id');
} else { } else {
$note_monitor = DB::table("covenant_receive_payment as rp") $note_monitor = $note_monitor->whereDate('rp.received_at', '>', $start);
->select(['rp.*', 'l.name as lname', 'l.number as lnumber', 'l.commission_rate'])
->leftJoin('lawyer as l', 'rp.lawyer_id', '=', 'l.id')
->whereDate('rp.received_at', '>', $start)
->groupBy('rp.lawyer_id');
} }
// 计算列表总数
$count = $note_monitor->count();
// 获取列表
$data = [];
$list = $note_monitor->limit($prePage)->offset($start)->orderBy('rp.cid', 'desc')->get()->toArray();
} }
// //
} elseif ($received_at['start'] && !$invoiced_at['start']) { //收款日期 } elseif ($received_at['start'] && !$invoiced_at['start']) { //收款日期
...@@ -148,47 +130,26 @@ public function getList(array $param) ...@@ -148,47 +130,26 @@ public function getList(array $param)
if ($start) { if ($start) {
if ($end) { if ($end) {
$note_monitor = DB::table('covenant_receive_payment AS rp') $note_monitor = $note_monitor->whereBetween('rp.received_at', [$start, $end]);
->select(['rp.*', 'l.name as lname', 'l.number as lnumber', 'l.commission_rate'])
->leftJoin('lawyer as l', 'rp.lawyer_id', '=', 'l.id')
->whereBetween('rp.received_at', [$start, $end])
->groupBy('rp.lawyer_id');
} else { } else {
$note_monitor = DB::table("covenant_receive_payment as rp") $note_monitor = $note_monitor->whereDate('rp.received_at', '>', $start);
->select(['rp.*', 'l.name as lname', 'l.number as lnumber', 'l.commission_rate'])
->leftJoin('lawyer as l', 'rp.lawyer_id', '=', 'l.id')
->whereDate('rp.received_at', '>', $start)
->groupBy('rp.lawyer_id');
} }
// 计算列表总数
$count = $note_monitor->count();
// 获取列表
$data = [];
$list = $note_monitor->limit($prePage)->offset($start)->orderBy('rp.cid', 'desc')->get()->toArray();
}
} else { //关键词搜索
$note_monitor = DB::table('lawyer as ly')->select(['id as lawyer_id', 'number as lnumber', 'name as lname', 'commission_rate']);
if ($number) {
$note_monitor = $note_monitor->where("number", $number);
}
if ($lname) {
$note_monitor = $note_monitor->where("name", $lname);
} }
// 计算列表总数
$count = $note_monitor->count();
// 获取列表
$data = [];
$list = $note_monitor->limit($prePage)->offset($start)->get()->toArray();
} }
// 计算列表总数
$count = $note_monitor->count();
// 获取列表
$data = [];
$list = $note_monitor->limit($prePage)->offset($offsetstart)->groupBy('rp.lawyer_id')->get()->toArray();
foreach ($list as $key => $item) { foreach ($list as $key => $item) {
$tmp = []; $tmp = [];
//$tmp['id'] = $item->id; //$tmp['id'] = $item->id;
//已收款 //已收款
$receipt_money = ModelCovenantReceivePayment::getReceivedMoney($item->lawyer_id, $year); $receipt_money = $item->received_amount; //ModelCovenantReceivePayment::getReceivedMoney($item->lawyer_id, $year);
//已开票 //已开票
$invoiced_money = ModelCovenantReceivePayment::getInvoicedMoney($item->lawyer_id, $year); $invoiced_money = $item->invoiced_money; //ModelCovenantReceivePayment::getInvoicedMoney($item->lawyer_id, $year);
//已收款未开票 //已收款未开票
$receipt_noinvoice = ($receipt_money - $invoiced_money) > 0 ? $receipt_money - $invoiced_money : 0; $receipt_noinvoice = ($receipt_money - $invoiced_money) > 0 ? $receipt_money - $invoiced_money : 0;
//已开票未收款 //已开票未收款
......
...@@ -5,9 +5,231 @@ ...@@ -5,9 +5,231 @@
use Dcat\Admin\Traits\HasDateTimeFormatter; use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class Lawyer extends Model class Lawyer extends Model
{ {
use HasDateTimeFormatter; use HasDateTimeFormatter;
protected $table = 'lawyer'; protected $table = 'lawyer';
//律师汇总表 总基本工资
public static function getTotalBasiSalary($params, $received_at, $invoiced_at)
{
// 获取筛选条件
$lnum = $params['lnum'] ?? '';
$lname = $params['lname'] ?? '';
$year = $params['year'] ?? date('Y');
DB::enableQueryLog();
$list = [];
$note_monitor = DB::table('covenant_receive_payment AS rp')
->select(['rp.*', 'l.name as lname', 'l.number as lnumber', 'l.commission_rate'])
->leftJoin('lawyer as l', 'rp.lawyer_id', '=', 'l.id');
if ($lnum) {
$note_monitor = $note_monitor->where("l.number", $lnum);
}
if ($lname) {
$note_monitor = $note_monitor->where("l.name", $lname);
}
if ($year) {
$note_monitor = $note_monitor->where("rp.year", $year);
}
if ($invoiced_at['start'] && $received_at['start']) {
$in_start = $invoiced_at['start'] ?? '';
$in_end = $invoiced_at['end'] ?? '';
$re_start = $received_at['start'] ?? '';
$re_end = $received_at['end'] ?? '';
if ($in_start && $re_start) {
if ($in_end && $re_end) {
$note_monitor = $note_monitor->whereBetween('rp.received_at', [$re_start, $re_end])
->whereBetween('rp.invoiced_at', [$in_start, $in_end]);
} else {
if ($in_end) {
$note_monitor = $note_monitor->whereDate('rp.received_at', '>', $re_start)
->whereBetween('rp.invoiced_at', [$in_start, $in_end]);
} elseif ($re_end) {
$note_monitor = $note_monitor->whereDate('rp.invoiced_at', '>', $in_start)
->whereBetween('rp.received_at', [$re_start, $re_end]);
} else {
$note_monitor = $note_monitor->whereDate('rp.invoiced_at', '>', $in_start)
->whereDate('rp.received_at', '>', $re_start);
}
}
}
} elseif ($invoiced_at['start'] && !$received_at['start']) { //开票日期
$start = $invoiced_at['start'] ?? '';
$end = $invoiced_at['end'] ?? '';
if ($start) {
if ($end) {
$note_monitor = $note_monitor->whereBetween('rp.received_at', [$start, $end]);
} else {
$note_monitor = $note_monitor->whereDate('rp.received_at', '>', $start);
}
}
//
} elseif ($received_at['start'] && !$invoiced_at['start']) { //收款日期
$start = $received_at['start'] ?? '';
$end = $received_at['end'] ?? '';
if ($start) {
if ($end) {
$note_monitor = $note_monitor->whereBetween('rp.received_at', [$start, $end]);
} else {
$note_monitor = $note_monitor->whereDate('rp.received_at', '>', $start);
}
}
}
// 获取列表
$total = 0;
$list = $note_monitor->limit(1000)->groupBy('rp.lawyer_id')->get()->toArray();
foreach ($list as $item) {
$salary = LawyerCost::getBasiSalary($item->lawyer_id, $year);
$total += $salary;
}
//$queries = DB::getQueryLog();
return $total;
}
//律师汇总表 律师基本信息统计
public static function getTotalInfo($params, $received_at, $invoiced_at)
{
// 获取筛选条件
$lnum = $params['lnum'] ?? '';
$lname = $params['lname'] ?? '';
$year = $params['year'] ?? date('Y');
DB::enableQueryLog();
$list = [];
$note_monitor = DB::table('covenant_receive_payment AS rp')
->select(DB::raw('rp.lawyer_id,rp.year,l.number as lnumber,l.name as lname,l.commission_rate,sum(invoiced_money) as invoiced_money,sum(received_amount) as received_amount'))
//->select(['rp.*', 'l.name as lname', 'l.number as lnumber', 'l.commission_rate'])
->leftJoin('lawyer as l', 'rp.lawyer_id', '=', 'l.id');
if ($lnum) {
$note_monitor = $note_monitor->where("l.number", $lnum);
}
if ($lname) {
$note_monitor = $note_monitor->where("l.name", $lname);
}
if ($year) {
$note_monitor = $note_monitor->where("rp.year", $year);
}
if ($invoiced_at['start'] && $received_at['start']) {
$in_start = $invoiced_at['start'] ?? '';
$in_end = $invoiced_at['end'] ?? '';
$re_start = $received_at['start'] ?? '';
$re_end = $received_at['end'] ?? '';
if ($in_start && $re_start) {
if ($in_end && $re_end) {
$note_monitor = $note_monitor->whereBetween('rp.received_at', [$re_start, $re_end])
->whereBetween('rp.invoiced_at', [$in_start, $in_end]);
} else {
if ($in_end) {
$note_monitor = $note_monitor->whereDate('rp.received_at', '>', $re_start)
->whereBetween('rp.invoiced_at', [$in_start, $in_end]);
} elseif ($re_end) {
$note_monitor = $note_monitor->whereDate('rp.invoiced_at', '>', $in_start)
->whereBetween('rp.received_at', [$re_start, $re_end]);
} else {
$note_monitor = $note_monitor->whereDate('rp.invoiced_at', '>', $in_start)
->whereDate('rp.received_at', '>', $re_start);
}
}
}
} elseif ($invoiced_at['start'] && !$received_at['start']) { //开票日期
$start = $invoiced_at['start'] ?? '';
$end = $invoiced_at['end'] ?? '';
if ($start) {
if ($end) {
$note_monitor = $note_monitor->whereBetween('rp.received_at', [$start, $end]);
} else {
$note_monitor = $note_monitor->whereDate('rp.received_at', '>', $start);
}
}
//
} elseif ($received_at['start'] && !$invoiced_at['start']) { //收款日期
$start = $received_at['start'] ?? '';
$end = $received_at['end'] ?? '';
if ($start) {
if ($end) {
$note_monitor = $note_monitor->whereBetween('rp.received_at', [$start, $end]);
} else {
$note_monitor = $note_monitor->whereDate('rp.received_at', '>', $start);
}
}
}
// 获取列表
$total = [
'receipt_money' => 0,
'invoiced_money' => 0,
'commission_amount' => 0,
'cost' => 0,
'salary' => 0,
'special_additional' => 0,
'social' => 0,
'accumulation_fund' => 0,
'advance_fee' => 0,
'tickets_money' => 0,
'payable_commission' => 0,
];
$list = $note_monitor->limit(1000)->groupBy('rp.lawyer_id')->get()->toArray();
foreach ($list as $item) {
$lawyerObj = Lawyer::find($item->lawyer_id);
//已收款
$receipt_money = $item->received_amount;
$total['receipt_money'] += $receipt_money;
//已开票
$invoiced_money = $item->invoiced_money;
$total['invoiced_money'] += $invoiced_money;
//提成金额
$commission_amount = self::getCommissionAmount($receipt_money, $lawyerObj->commission_rate);
$total['commission_amount'] += $commission_amount;
//成本合计
$cost = LawyerCost::getTotalCost($item->lawyer_id, $year);
$total['cost'] += $cost;
//基本工资
$salary = LawyerCost::getBasiSalary($item->lawyer_id, $year);
$total['salary'] += $salary;
//专项附加
$additional = LawyerCost::getSpecialAdditional($item->lawyer_id, $year);
$total['special_additional'] += $additional;
//社保
$social = LawyerCost::getSocial($item->lawyer_id, $year);
$total['social'] += $social;
//公积金
$accumulation_fund = LawyerCost::getAccumulationFund($item->lawyer_id, $year);
$total['accumulation_fund'] += $accumulation_fund;
//预支款
$advance_fee = LawyerCost::getAdvanceFee($item->lawyer_id, $year);
$total['advance_fee'] += $advance_fee;
//贴票金额
$lawyerObj = Lawyer::find($item->lawyer_id);
$tickets_money = LawyerCost::getPostingTicketsMoney($item->lawyer_id, $year, $lawyerObj->commission_rate, $lawyerObj->ticket_ratio);
$total['tickets_money'] += $tickets_money;
//可结算提成
$payable_commission = self::getPayableAmount($item->lawyer_id, $year, $lawyerObj->commission_rate, $receipt_money);
$total['payable_commission'] += $payable_commission;
}
return $total;
}
//提成金额
public static function getCommissionAmount($receipt_money, $commission_rate)
{
return $receipt_money * ($commission_rate / 100);
}
//可结算提成
public static function getPayableAmount($lawyer_id, $year, $commission_rate, $receipt_money)
{
$paid_amount = LawyerCost::getPaidAmount($lawyer_id, $year); //已支付款项
$result = $receipt_money * ($commission_rate / 100) - $paid_amount;
return $result;
}
} }
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