车险提成统计

dev
zhaocheng 5 years ago
parent 20bd9ce864
commit c405c40505
  1. 2
      common/libs/MyLib.php
  2. 92
      frontend/controllers/FinanceController.php
  3. 3
      frontend/controllers/FixCarController.php
  4. 32
      frontend/controllers/InsurerController.php
  5. 2
      frontend/views/car/info-track.php
  6. 15
      frontend/views/finance/budian-list.php
  7. 13
      frontend/views/insurer/finance-mng.php

@ -214,7 +214,7 @@ class MyLib {
} }
} }
static public function zhifufs($cx){ static public function zhifufs($cx){
$cn = '未知';
if($cx==1) { if($cx==1) {
$cn='上门收费'; $cn='上门收费';
}elseif($cx==2){ }elseif($cx==2){

@ -213,11 +213,11 @@ class FinanceController extends \frontend\controllers\UserBaseController
$data['rows'] = []; $data['rows'] = [];
foreach($items as $item) { foreach($items as $item) {
$row = $item->toArray(); $row = $item->toArray();
$row['group'] = $item->user->group ? $item->user->group->name : ''; $row['group'] = $item->user && $item->user->group ? $item->user->group->name : '';
$row['company_name'] = $item->order->company2 ? $item->order->company2->name : 0; $row['company_name'] = $item->order && $item->order->company2 ? $item->order->company2->name : 0;
$row['username'] = $item->user->getShowName(); $row['username'] = $item->user ? $item->user->getShowName() : 0;
$row['submit_date'] = $item->order->submit_date; $row['submit_date'] = $item->order ? $item->order->submit_date : '';
$row['print_date'] = $item->order->print_date; $row['print_date'] = $item->order ? $item->order->print_date : '';
$row['total_real'] = round($item->total_clear_real + $item->total_tax_real,2); $row['total_real'] = round($item->total_clear_real + $item->total_tax_real,2);
$data['rows'][] = $row; $data['rows'][] = $row;
} }
@ -6550,6 +6550,7 @@ class FinanceController extends \frontend\controllers\UserBaseController
$query->andWhere('order_t.print_date<="' . $end_date . '"'); $query->andWhere('order_t.print_date<="' . $end_date . '"');
} }
$total = $query->count(); $total = $query->count();
$sum_total1_clear = $query->sum('total1_clear');
$query->offset($offset)->limit($limit); $query->offset($offset)->limit($limit);
$items = $query->all(); $items = $query->all();
@ -6568,6 +6569,10 @@ class FinanceController extends \frontend\controllers\UserBaseController
$data['rows'][] = $row; $data['rows'][] = $row;
} }
$data['rows'][] = array(
['商业净保总额', number_format($sum_total1_clear,2)],
);
return $data; return $data;
} }
@ -6725,19 +6730,14 @@ class FinanceController extends \frontend\controllers\UserBaseController
$group_ids = []; $group_ids = [];
if($group_id > 0) { if($group_id > 0) {
$items = GroupT::getTree($group_id); $items = GroupT::getTree($group_id);
$group_ids[] = $group_id; $group_ids[] = $group_id;
foreach($items as $group_info) { foreach($items as $group_info) {
$group_ids[] = $group_info->id; $group_ids[] = $group_info->id;
} }
} }
$query = CaiwuT::find() $query = CaiwuT::find()
->leftJoin(OrderT::tableName(), "order_t.id=caiwu_t.order_id") ->leftJoin(OrderT::tableName(), "order_t.id=caiwu_t.order_id")
->where('order_t.status_id>1') ->where('order_t.status_id>1');
->orderBy('order_t.print_date DESC');
if($user_names != '' && $user_names != 'null'){ if($user_names != '' && $user_names != 'null'){
$user_arr = explode(',',$user_names); $user_arr = explode(',',$user_names);
$user_ids = []; $user_ids = [];
@ -6746,40 +6746,33 @@ class FinanceController extends \frontend\controllers\UserBaseController
if($user) if($user)
$user_ids[] = $user->id; $user_ids[] = $user->id;
} }
$query->andWhere(['in','caiwu_t.user_id',$user_ids]); $query->andWhere(['in','caiwu_t.user_id',$user_ids]);
} }
if( $company_id > 0) { if( $company_id > 0) {
$query->andWhere('order_t.company2_id='.$company_id); $query->andWhere('order_t.company2_id='.$company_id);
} }
if( $car_no != '') { if( $car_no != '') {
$query->andWhere('order_t.car_no="'.$car_no.'"'); $query->andWhere('order_t.car_no="'.$car_no.'"');
} }
if($car_no_type == 1){ if($car_no_type == 1){
$query->andWhere('caiwu_t.car_no like "' . '京' . '%"'); $query->andWhere('caiwu_t.car_no like "' . '京' . '%"');
}elseif($car_no_type == 2){ }elseif($car_no_type == 2){
$query->andWhere('caiwu_t.car_no not like "' . '京' . '%"'); $query->andWhere('caiwu_t.car_no not like "' . '京' . '%"');
} }
if($begin_totalclear != ''){ if($begin_totalclear != ''){
$query->andWhere('caiwu_t.total_clear >=' . $begin_totalclear); $query->andWhere('caiwu_t.total_clear >=' . $begin_totalclear);
} }
if($end_totalclear != ''){ if($end_totalclear != ''){
$query->andWhere('caiwu_t.total_clear <=' . $end_totalclear); $query->andWhere('caiwu_t.total_clear <=' . $end_totalclear);
} }
if ($begin_date != "") { if ($begin_date != "") {
$query->andWhere('order_t.print_date>="' . $begin_date . '"'); $query->andWhere('order_t.print_date>="' . $begin_date . '"');
} }
if ($end_date != "") { if ($end_date != "") {
$query->andWhere('order_t.print_date<="' . $end_date . '"'); $query->andWhere('order_t.print_date<="' . $end_date . '"');
} }
$user_items = $this->my->getChildren(''); $user_items = $this->my->getChildren('');
$user_items[] = $this->my; $user_items[] = $this->my;
$row = array(); $row = array();
foreach($user_items as $user_info) { foreach($user_items as $user_info) {
if ($group_id > 0) { if ($group_id > 0) {
@ -6789,22 +6782,14 @@ class FinanceController extends \frontend\controllers\UserBaseController
} }
$row[] = $user_info->id; $row[] = $user_info->id;
} }
//加上级别筛选 //加上级别筛选
if($group_id > 0){ if($group_id > 0){
$query->andWhere(['in','caiwu_t.user_id',$row]); $query->andWhere(['in','caiwu_t.user_id',$row]);
} }
$query1 = clone $query;
if($insurer_type ==1){ if($insurer_type ==1){
$query->andWhere('caiwu_t.insurer_type=1'); $query->andWhere('caiwu_t.insurer_type=1');
} }
$items = $query->all(); $items = $query->all();
$total2_clear_all = $query1->andWhere('caiwu_t.insurer_type=2')->sum('total_clear');
$yewu_ticheng_all = 0; $yewu_ticheng_all = 0;
$total1_clear_all = 0; $total1_clear_all = 0;
$yeji_ticheng_all = 0; $yeji_ticheng_all = 0;
@ -6815,7 +6800,6 @@ class FinanceController extends \frontend\controllers\UserBaseController
foreach($items as $index => $item) { foreach($items as $index => $item) {
$order_caiwu_info = $item->orderCaiwu; $order_caiwu_info = $item->orderCaiwu;
$order_info = $item->order; $order_info = $item->order;
$total1_clear_all += $item->total_clear; $total1_clear_all += $item->total_clear;
$yewu_ticheng_all += $order_caiwu_info ? $order_caiwu_info->yewu_ticheng : 0; $yewu_ticheng_all += $order_caiwu_info ? $order_caiwu_info->yewu_ticheng : 0;
$yeji_ticheng_all += $order_caiwu_info ? $order_caiwu_info->yeji_ticheng : 0; $yeji_ticheng_all += $order_caiwu_info ? $order_caiwu_info->yeji_ticheng : 0;
@ -6827,20 +6811,42 @@ class FinanceController extends \frontend\controllers\UserBaseController
$yuangong_money = $order_info->yuangong_money>0?$order_info->yuangong_money:0; $yuangong_money = $order_info->yuangong_money>0?$order_info->yuangong_money:0;
} }
$yuangong_money_all += $yuangong_money; $yuangong_money_all += $yuangong_money;
} }
// echo $query->createCommand()->rawSql;exit;
$total = $query->count();
$query->offset($offset)->limit($limit); $yewu_ticheng_all = 0;
$items = $query->all(); $total1_clear_all = 0;
$yeji_ticheng_all = 0;
$ticheng_money_all = 0;
$lipin_all = 0;
$liquan_all = 0;
$yuangong_money_all = 0;
$query1 = clone $query;
$sums = $query1->select([
'sum_total1_clear' => 'sum(order_caiwi_t.total1_clear)',
'sum_yewu_ticheng' => 'sum(order_caiwi_t.yewu_ticheng)',
'sum_yeji_ticheng' => 'sum(order_caiwi_t.yeji_ticheng)',
'sum_ticheng_money' => 'sum(order_caiwi_t.ticheng_money)',
'sum_yuangong_money' => 'sum(order_caiwi_t.yuangong_money)',
])->asArray()->one();
$query2 = clone $query;
// $gift_sums = $query2
// ->leftJoin(OrderGiftT::tableName(), "order_gift_t.order_id=caiwu_t.order_id")
// ->leftJoin(GiftT::tableName(), "gift_t.id=order_t.gift_id")
// ->groupBy('caiwu_t.id')
// ->select([
// 'sum_no_free_gift' => 'sum(order_caiwi_t.total1_clear)',
// ])->asArray()->one();
$total = $query->count();
$query=$query->offset($offset)->limit($limit);
$items = $query->orderBy('order_t.print_date DESC')->all();
$data = []; $data = [];
$data['total'] = $total; $data['total'] = $total;
$data['rows'] = []; $data['rows'] = [];
foreach($items as $item) { foreach($items as $item) {
$row = $item->toArray(); $row = $item->toArray();
$row['company_name'] = $item->order->company2->name; $row['company_name'] = $item->order->company2?$item->order->company2->name:'';
$row['print_date'] = $item->order->print_date; $row['print_date'] = $item->order->print_date;
$row['yeji_rate'] = $item->orderCaiwu->yeji_rate; $row['yeji_rate'] = $item->orderCaiwu->yeji_rate;
$row['yeji_ticheng'] = $item->orderCaiwu->yeji_ticheng; $row['yeji_ticheng'] = $item->orderCaiwu->yeji_ticheng;
@ -6851,17 +6857,17 @@ class FinanceController extends \frontend\controllers\UserBaseController
$row['yuangong_money'] = $item->order->yuangong_money; $row['yuangong_money'] = $item->order->yuangong_money;
$row['yewu_ticheng'] = $item->orderCaiwu->yewu_ticheng; $row['yewu_ticheng'] = $item->orderCaiwu->yewu_ticheng;
if($item->order->car->op2_id > 0) { if($item->order->car->op2_id > 0) {
$row['op_user'] = $item->order->car->op2->showName; $row['op_user'] = $item->order->car->op2?$item->order->car->op2->showName:'';
$row['op_user1'] = $item->order->car->op1->showName; $row['op_user1'] = $item->order->car->op1?$item->order->car->op1->showName:'';
} else { } else {
$row['op_user'] = $item->order->car->op1->showName; $row['op_user'] = $item->order->car->op1?$item->order->car->op1->showName:'';
$row['op_user1'] = ''; $row['op_user1'] = '';
} }
$row['first_xinbao_ticheng'] = $item->orderCaiwu->first_xinbao_ticheng; $row['first_xinbao_ticheng'] = $item->orderCaiwu->first_xinbao_ticheng;
$row['hebao_ticheng'] = $item->orderCaiwu->hebao_ticheng; $row['hebao_ticheng'] = $item->orderCaiwu->hebao_ticheng;
$row['op1_user'] = $item->order->op1->showName; $row['op1_user'] = $item->order->op1?$item->order->op1->showName:'';
$row['zhengben_ticheng'] = $item->orderCaiwu->zhengben_ticheng; $row['zhengben_ticheng'] = $item->orderCaiwu->zhengben_ticheng;
$row['op2_user'] = $item->order->op2->showName; $row['op2_user'] = $item->order->op2?$item->order->op2->showName:'';
$row['dz_ticheng1'] = $item->orderCaiwu->dz_ticheng1; $row['dz_ticheng1'] = $item->orderCaiwu->dz_ticheng1;
$row['dz_names1'] = $item->orderCaiwu->dz_names1; $row['dz_names1'] = $item->orderCaiwu->dz_names1;
$row['dz_ticheng2'] = $item->orderCaiwu->dz_ticheng2; $row['dz_ticheng2'] = $item->orderCaiwu->dz_ticheng2;
@ -6874,6 +6880,16 @@ class FinanceController extends \frontend\controllers\UserBaseController
$row['dz_names5'] = $item->orderCaiwu->dz_names5; $row['dz_names5'] = $item->orderCaiwu->dz_names5;
$data['rows'][] = $row; $data['rows'][] = $row;
} }
$data['rows'][] = array(
['保费总额', number_format($sums['sum_total1'],2)],
['商业净保总额', number_format($sums['sum_total1_clear'],2)],
['基本提成合计', number_format($sums['sum_yuangong_money'],2)],
['加点提成合计', number_format($sums['sum_non_total1_dis'],2)],
['自费礼品合计', number_format($sums['sum_total1_dis'],2)],
['自费礼券合计', number_format($sums['sum_yuangong_money'] + $sums['sum_total1_dis'],2)],
['自费减免合计', number_format($sums['sum_yuangong_money'] + $sums['sum_total1_dis'],2)],
['提成合计', number_format($sums['sum_yuangong_money'] + $sums['sum_total1_dis'],2)]
);
return $data; return $data;
} }

@ -207,9 +207,6 @@ class FixCarController extends BaseController
$info->displacement_id = $car_info->displacement_id; $info->displacement_id = $car_info->displacement_id;
$info->car_year = $car_info->car_year; $info->car_year = $car_info->car_year;
$info->status = $status; $info->status = $status;
// var_dump($car_info->car_year);
// var_dump($info->car_year);
// die;
} }
if($car_id == 0) { if($car_id == 0) {
$car_id = $info->car_id; $car_id = $info->car_id;

@ -1122,17 +1122,14 @@ class InsurerController extends BaseController
if($group_id > 0) { if($group_id > 0) {
$items = GroupT::getTree($group_id); $items = GroupT::getTree($group_id);
foreach($items as $group_info) { foreach($items as $group_info) {
$group_ids[] = $group_info->id; $group_ids[] = $group_info->id;
} }
} }
$query = OrderT::find() $query = OrderT::find()
->leftJoin('order_caiwu_t','order_caiwu_t.order_id=order_t.id') ->leftJoin('order_caiwu_t','order_caiwu_t.order_id=order_t.id')
->where('order_caiwu_t.status_id>0') ->where('order_caiwu_t.status_id>0');
->orderBy('order_t.print_date asc');
if($car_man != '') { if($car_man != '') {
$query->andWhere('id_man="'.$car_man.'"'); $query->andWhere('id_man="'.$car_man.'"');
} }
@ -1195,9 +1192,7 @@ class InsurerController extends BaseController
continue; continue;
} }
} }
$row[] = $user_info->id; $row[] = $user_info->id;
} }
//加上级别筛选 //加上级别筛选
@ -1205,8 +1200,15 @@ class InsurerController extends BaseController
$query = $query->andWhere(['in','order_t.user_id',$row]); $query = $query->andWhere(['in','order_t.user_id',$row]);
} }
$total = $query->count(); $total = $query->count();
$query1 = clone $query;
$query = $query->offset($offset)->limit($limit); $sums = $query1->select([
'sum_total1' => 'sum(order_t.total1)',
'sum_total1_clear' => 'sum(order_t.total1_clear)',
'sum_yuangong_money' => 'sum(order_t.yuangong_money)',
'sum_non_total1_dis' => 'sum(order_t.non_total1_dis)',
'sum_total1_dis' => 'sum(order_t.total1_dis)',
])->asArray()->one();
$query = $query->orderBy('order_t.print_date asc')->offset($offset)->limit($limit);
$items = $query->all(); $items = $query->all();
$data = []; $data = [];
@ -1214,18 +1216,26 @@ class InsurerController extends BaseController
$data['rows'] = []; $data['rows'] = [];
foreach($items as $item) { foreach($items as $item) {
$row = $item->toArray(); $row = $item->toArray();
$row['company_name'] = $item->company2->name; $row['company_name'] = $item->company2 ? $item->company2->name : '';
$row['path'] = ($item->user && $item->user->group) ? $item->user->group->getPath() : ''; $row['path'] = ($item->user && $item->user->group) ? $item->user->group->getPath() : '';
$row['user_name'] = $item->user ? $item->user->getShowName() : ''; $row['user_name'] = $item->user ? $item->user->getShowName() : '';
$row['total_user_real'] = number_format($item->total1_dis + $item->yuangong_money, 2); $row['total_user_real'] = number_format($item->total1_dis + $item->yuangong_money, 2);
$row['transfer_date'] = $item->caiwu->transfer_date; $row['transfer_date'] = $item->caiwu->transfer_date;
$row['caiwu_status_name'] = $item->caiwu->caiwuStatus->name; $row['caiwu_status_name'] = $item->caiwu && $item->caiwu->caiwuStatus ? $item->caiwu->caiwuStatus->name : '';
$row['shoufei_name'] = MyLib::zhifufs($item->shoufei_id); $row['shoufei_name'] = MyLib::zhifufs($item->shoufei_id);
$row['status_name'] = $item->caiwu->status->name; $row['status_name'] = $item->caiwu && $item->caiwu->status ? $item->caiwu->status->name : '';
$row['lock_man'] = $item->caiwu->lock?$item->caiwu->lock->getShowName():''; $row['lock_man'] = $item->caiwu->lock?$item->caiwu->lock->getShowName():'';
$data['rows'][] = $row; $data['rows'][] = $row;
} }
$data['rows'][] = array(
['商业保总额', number_format($sums['sum_total1'],2)],
['商业净保总额', number_format($sums['sum_total1_clear'],2)],
['业务自付', number_format($sums['sum_yuangong_money'],2)],
['公司代付非车险', number_format($sums['sum_non_total1_dis'],2)],
['公司返金额', number_format($sums['sum_total1_dis'],2)],
['实返现金额', number_format($sums['sum_yuangong_money'] + $sums['sum_total1_dis'],2)]
);
return $data; return $data;
} }

@ -39,7 +39,7 @@ use \common\libs\MyLib;
<th class="bg-warning" nowrap>车架号</th> <th class="bg-warning" nowrap>车架号</th>
<td><?=$car_info->car_frame_no?></td> <td><?=$car_info->car_frame_no?></td>
<th class="bg-warning" nowrap>车辆使用性质</th> <th class="bg-warning" nowrap>车辆使用性质</th>
<td><?=$car_info->carUse->name?></td> <td><?=$car_info->carUse?$car_info->carUse->name:''?></td>
</tr> </tr>
<tr> <tr>
<th class="bg-warning">车主</th> <th class="bg-warning">车主</th>

@ -40,8 +40,6 @@ use \common\libs\MyLib;
<?php <?php
foreach($company_items as $item) { foreach($company_items as $item) {
echo '<option value="'.$item->id.'"'; echo '<option value="'.$item->id.'"';
if($item->id == $company_id)
echo ' selected ';
echo '>'.$item->name.'</option>'; echo '>'.$item->name.'</option>';
} }
?> ?>
@ -126,6 +124,19 @@ use \common\libs\MyLib;
o['offset'] = params['offset']; o['offset'] = params['offset'];
o['limit'] = params['limit']; o['limit'] = params['limit'];
return o; return o;
},
responseHandler: function (res) {
var totals = res.rows.pop();
var html = '<tfoot><tr><td colspan="18" class="text-left">';
$.each(totals,function (i,d) {
html += '<div class="layui-show-md-inline-block m-r-lg m-l-lg">' +
'<span>'+ d[0] +':</span>' +
'<span class="font-bold">'+ d[1] +'</span>' +
'</div>'
});
html += '</td></tr></tfoot>';
$('#listTable').append(html);
return res;
} }
}); });
return false; return false;

@ -112,6 +112,19 @@ use \common\libs\MyLib;
o['limit'] = params['limit']; o['limit'] = params['limit'];
o['offset'] = params['offset']; o['offset'] = params['offset'];
return o; return o;
},
responseHandler: function (res) {
var totals = res.rows.pop();
var html = '<tfoot><tr><td colspan="18" class="text-center">';
$.each(totals,function (i,d) {
html += '<div class="layui-show-md-inline-block m-r-lg m-l-lg">' +
'<span>'+ d[0] +':</span>' +
'<span class="font-bold">'+ d[1] +'</span>' +
'</div>'
});
html += '</td></tr></tfoot>';
$('#listTable').append(html);
return res;
} }
}); });
return false; return false;

Loading…
Cancel
Save