|
|
@ -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; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|