|
|
@ -214,14 +214,21 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
foreach($items as $item) { |
|
|
|
foreach($items as $item) { |
|
|
|
$row = $item->toArray(); |
|
|
|
$row = $item->toArray(); |
|
|
|
$row['group'] = $item->user && $item->user->group ? $item->user->group->name : ''; |
|
|
|
$row['group'] = $item->user && $item->user->group ? $item->user->group->name : ''; |
|
|
|
$row['company_name'] = $item->order->company2->name; |
|
|
|
$row['company_name'] = $item->order && $item->order->company2 ? $item->order->company2->name : 0; |
|
|
|
$row['username'] = $item->user ? $item->user->showName : ''; |
|
|
|
$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; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data['rows'][] = array( |
|
|
|
|
|
|
|
['商业保总额', $sum_total], |
|
|
|
|
|
|
|
['商业净保总额', $sum_total_clear], |
|
|
|
|
|
|
|
['回款总额', $sum_r_total], |
|
|
|
|
|
|
|
['回款差额', $sum_total_dis] |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
return $data; |
|
|
|
return $data; |
|
|
|
} |
|
|
|
} |
|
|
|
public function actionReceiptImport() { |
|
|
|
public function actionReceiptImport() { |
|
|
@ -5147,12 +5154,20 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
$row['is_leave'] = $item->is_leave ? '已离职':''; |
|
|
|
$row['is_leave'] = $item->is_leave ? '已离职':''; |
|
|
|
$pay_info = $item->getPay($pay_date); |
|
|
|
$pay_info = $item->getPay($pay_date); |
|
|
|
$row['status_name'] = $pay_info ? $pay_info->getStatus($pay_info->status_id) : ''; |
|
|
|
$row['status_name'] = $pay_info ? $pay_info->getStatus($pay_info->status_id) : ''; |
|
|
|
$row['real_pay'] = $pay_info->base_real_pay; |
|
|
|
$row['real_pay'] = $pay_info ? $pay_info->base_real_pay : ''; |
|
|
|
$row['should_pay'] = $pay_info->ticheng_real_pay; |
|
|
|
$row['should_pay'] = $pay_info ? $pay_info->ticheng_real_pay : ''; |
|
|
|
$row['is_show'] = ($pay_info->renshi_status_id > 0 && $pay_info->chuna_status_id > 0 && $pay_info->status_id != 7 && $pay_info->status_id != 8) ? 1 : 0; |
|
|
|
$row['is_show'] = $pay_info && ($pay_info->renshi_status_id > 0 && $pay_info->chuna_status_id > 0 && $pay_info->status_id != 7 && $pay_info->status_id != 8) ? 1 : 0; |
|
|
|
$data['rows'][] = $row; |
|
|
|
$data['rows'][] = $row; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$pay_chexian = PayT::find() |
|
|
|
|
|
|
|
->where("pay_date='{$pay_date}'") |
|
|
|
|
|
|
|
->sum('ticheng_real_pay'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data['rows'][] = array( |
|
|
|
|
|
|
|
['提成工资总额', number_format($pay_chexian,2)], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
return $data; |
|
|
|
return $data; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -6543,6 +6558,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(); |
|
|
@ -6561,6 +6577,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; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -6718,18 +6738,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 = []; |
|
|
@ -6738,40 +6754,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) { |
|
|
@ -6781,58 +6790,46 @@ 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'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$query1 = clone $query; |
|
|
|
|
|
|
|
$sums = $query1 |
|
|
|
$items = $query->all(); |
|
|
|
->leftJoin(OrderCaiwuT::tableName(), "order_t.id=order_caiwu_t.order_id") |
|
|
|
|
|
|
|
->select([ |
|
|
|
$total2_clear_all = $query1->andWhere('caiwu_t.insurer_type=2')->sum('total_clear'); |
|
|
|
'sum_total1_clear' => 'sum(order_t.total1_clear)', |
|
|
|
|
|
|
|
'sum_total2_clear' => 'sum(order_t.total2_clear)', |
|
|
|
$yewu_ticheng_all = 0; |
|
|
|
'sum_yeji_ticheng' => 'sum(order_caiwu_t.yeji_ticheng)', |
|
|
|
$total1_clear_all = 0; |
|
|
|
'sum_ticheng_money' => 'sum(order_caiwu_t.ticheng_money)', |
|
|
|
$yeji_ticheng_all = 0; |
|
|
|
'sum_yuangong_money' => 'sum(order_caiwu_t.yuangong_money)', |
|
|
|
$ticheng_money_all = 0; |
|
|
|
'sum_yewu_ticheng' => 'sum(order_caiwu_t.yewu_ticheng)', |
|
|
|
$lipin_all = 0; |
|
|
|
])->asArray()->one(); |
|
|
|
$liquan_all = 0; |
|
|
|
$query2 = clone $query; |
|
|
|
$yuangong_money_all = 0; |
|
|
|
$gift_sum = $query2 |
|
|
|
foreach($items as $index => $item) { |
|
|
|
->leftJoin(OrderGiftT::tableName(), "order_gift_t.order_id=caiwu_t.order_id") |
|
|
|
$order_caiwu_info = $item->orderCaiwu; |
|
|
|
->leftJoin(GiftT::tableName(), "gift_t.id=order_gift_t.gift_id") |
|
|
|
$order_info = $item->order; |
|
|
|
->andWhere('order_gift_t.gift_type=1 && order_gift_t.is_free=2') |
|
|
|
|
|
|
|
->sum('gift_t.price'); |
|
|
|
$total1_clear_all += $item->total_clear; |
|
|
|
$query2 = clone $query; |
|
|
|
$yewu_ticheng_all += $order_caiwu_info ? $order_caiwu_info->yewu_ticheng : 0; |
|
|
|
$voucher_sum = $query2 |
|
|
|
$yeji_ticheng_all += $order_caiwu_info ? $order_caiwu_info->yeji_ticheng : 0; |
|
|
|
->leftJoin(OrderGiftT::tableName(), "order_gift_t.order_id=caiwu_t.order_id") |
|
|
|
$ticheng_money_all += $order_info ? $order_info->ticheng_money : 0; |
|
|
|
->leftJoin(GiftT::tableName(), "gift_t.id=order_gift_t.gift_id") |
|
|
|
$lipin_all += $order_info ? $order_info->getGiftPrice(1,1) : 0; |
|
|
|
->andWhere('order_gift_t.gift_type=2 && order_gift_t.is_free=2') |
|
|
|
$liquan_all += $order_info ? $order_info->getGiftPrice(1,2) : 0; |
|
|
|
->sum('gift_t.price'); |
|
|
|
$yuangong_money = 0; |
|
|
|
|
|
|
|
if($order_info){ |
|
|
|
|
|
|
|
$yuangong_money = $order_info->yuangong_money>0?$order_info->yuangong_money:0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$yuangong_money_all += $yuangong_money; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// echo $query->createCommand()->rawSql;exit; |
|
|
|
|
|
|
|
$total = $query->count(); |
|
|
|
$total = $query->count(); |
|
|
|
|
|
|
|
$query=$query->offset($offset)->limit($limit); |
|
|
|
$query->offset($offset)->limit($limit); |
|
|
|
$items = $query->orderBy('order_t.print_date DESC')->all(); |
|
|
|
$items = $query->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; |
|
|
@ -6843,17 +6840,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; |
|
|
@ -6866,6 +6863,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_clear'] + $sums['sum_total2_clear'],2)], |
|
|
|
|
|
|
|
['商业净保总额', number_format($sums['sum_total1_clear'],2)], |
|
|
|
|
|
|
|
['基本提成合计', number_format($sums['sum_yeji_ticheng'],2)], |
|
|
|
|
|
|
|
['加点提成合计', number_format($sums['sum_ticheng_money'],2)], |
|
|
|
|
|
|
|
['自费礼品合计', number_format($gift_sum,2)], |
|
|
|
|
|
|
|
['自费礼券合计', number_format($voucher_sum,2)], |
|
|
|
|
|
|
|
['自费减免合计', number_format($sums['sum_yuangong_money'],2)], |
|
|
|
|
|
|
|
['提成合计', number_format($sums['sum_yewu_ticheng'],2)] |
|
|
|
|
|
|
|
); |
|
|
|
return $data; |
|
|
|
return $data; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -7379,6 +7386,9 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
|
|
|
|
|
|
|
|
$query = $query->offset($offset)->limit($limit); |
|
|
|
$query = $query->offset($offset)->limit($limit); |
|
|
|
$items = $query->all(); |
|
|
|
$items = $query->all(); |
|
|
|
|
|
|
|
$pay_chexian = PayOrderUserT::find() |
|
|
|
|
|
|
|
->where("pay_date='{$pay_date}'") |
|
|
|
|
|
|
|
->sum('real_pay'); |
|
|
|
|
|
|
|
|
|
|
|
$data = []; |
|
|
|
$data = []; |
|
|
|
$data['total'] = $total; |
|
|
|
$data['total'] = $total; |
|
|
@ -7394,6 +7404,10 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
$data['rows'][] = $row; |
|
|
|
$data['rows'][] = $row; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data['rows'][] = array( |
|
|
|
|
|
|
|
['提成工资总额', number_format($pay_chexian,2)], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
return $data; |
|
|
|
return $data; |
|
|
|
} |
|
|
|
} |
|
|
|
/** |
|
|
|
/** |
|
|
@ -7585,7 +7599,6 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
$limit = $request->get('limit', 10); |
|
|
|
$limit = $request->get('limit', 10); |
|
|
|
|
|
|
|
|
|
|
|
$user_id = $this->my->id; |
|
|
|
$user_id = $this->my->id; |
|
|
|
// var_dump($user_id); |
|
|
|
|
|
|
|
$query = UserT::find() |
|
|
|
$query = UserT::find() |
|
|
|
->leftJoin('pay_t','pay_t.user_id=user_t.id') |
|
|
|
->leftJoin('pay_t','pay_t.user_id=user_t.id') |
|
|
|
->where('group_id>0 and is_delete=0'); |
|
|
|
->where('group_id>0 and is_delete=0'); |
|
|
@ -7626,8 +7639,17 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
$data['rows'][] = $row; |
|
|
|
$data['rows'][] = $row; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$pay_chexian = PayT::find() |
|
|
|
|
|
|
|
->where("pay_date='{$pay_date}'") |
|
|
|
|
|
|
|
->sum('ticheng_real_pay'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data['rows'][] = array( |
|
|
|
|
|
|
|
['提成工资总额', number_format($pay_chexian,2)], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
return $data; |
|
|
|
return $data; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 出纳工资-详情 |
|
|
|
* 出纳工资-详情 |
|
|
|
* @return string |
|
|
|
* @return string |
|
|
@ -7790,14 +7812,9 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
$zbname = $request->get('zbname'); |
|
|
|
$zbname = $request->get('zbname'); |
|
|
|
//级别 |
|
|
|
//级别 |
|
|
|
$group_id = $request->get('group_id'); |
|
|
|
$group_id = $request->get('group_id'); |
|
|
|
$group_items = GroupT::getTree((int)$this->my->group_id); |
|
|
|
|
|
|
|
if($this->my->id == 1) |
|
|
|
|
|
|
|
$group_items = GroupT::getTree(); |
|
|
|
|
|
|
|
$group_ids[] = $group_id; |
|
|
|
$group_ids[] = $group_id; |
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
} |
|
|
|
} |
|
|
@ -7806,70 +7823,33 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
$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'); |
|
|
|
|
|
|
|
|
|
|
|
switch ($sort_key) { |
|
|
|
|
|
|
|
case 'total': |
|
|
|
|
|
|
|
$sort = 'caiwu_t.total '; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'total_clear': |
|
|
|
|
|
|
|
$sort = 'caiwu_t.total_clear '; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'total_rate': |
|
|
|
|
|
|
|
$sort = 'caiwu_t.total_rate '; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'print_date'://默认按照print_date排序 |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
$sort = 'order_t.print_date '; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch ($sort_value) { |
|
|
|
|
|
|
|
case 'ASC': |
|
|
|
|
|
|
|
$sort .= 'ASC'; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'DESC': |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
$sort .= 'DESC'; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$query->orderBy($sort); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( $insurer_type != 0) { |
|
|
|
if( $insurer_type != 0) { |
|
|
|
$query->andWhere('caiwu_t.insurer_type='.$insurer_type); |
|
|
|
$query->andWhere('caiwu_t.insurer_type='.$insurer_type); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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 ($username != "") { |
|
|
|
if ($username != "") { |
|
|
|
// $userdata = UserT::findOne(['username'=>$username]); |
|
|
|
|
|
|
|
$userdata = UserT::find()->where('username="'.$username.'"')->andwhere('is_leave=0')->one(); |
|
|
|
$userdata = UserT::find()->where('username="'.$username.'"')->andwhere('is_leave=0')->one(); |
|
|
|
if($userdata){ |
|
|
|
if($userdata){ |
|
|
|
$query->andWhere('caiwu_t.user_id = ' . $userdata->id . ''); |
|
|
|
$query->andWhere('caiwu_t.user_id = ' . $userdata->id . ''); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($hebaoname != "") { |
|
|
|
if ($hebaoname != "") { |
|
|
|
// $userdata = UserT::findOne(['username'=>$username]); |
|
|
|
|
|
|
|
$userdata = UserT::find()->where('username="'.$hebaoname.'"')->andwhere('is_leave=0')->one(); |
|
|
|
$userdata = UserT::find()->where('username="'.$hebaoname.'"')->andwhere('is_leave=0')->one(); |
|
|
|
if($userdata){ |
|
|
|
if($userdata){ |
|
|
|
$query->andWhere('order_t.op1_id = ' . $userdata->id . ''); |
|
|
|
$query->andWhere('order_t.op1_id = ' . $userdata->id . ''); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($zbname != "") { |
|
|
|
if ($zbname != "") { |
|
|
|
// $userdata = UserT::findOne(['username'=>$username]); |
|
|
|
|
|
|
|
$userdata = UserT::find()->where('username="'.$zbname.'"')->andwhere('is_leave=0')->one(); |
|
|
|
$userdata = UserT::find()->where('username="'.$zbname.'"')->andwhere('is_leave=0')->one(); |
|
|
|
if($userdata){ |
|
|
|
if($userdata){ |
|
|
|
$query->andWhere('order_t.op2_id = ' . $userdata->id . ''); |
|
|
|
$query->andWhere('order_t.op2_id = ' . $userdata->id . ''); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($car_no != "") { |
|
|
|
if ($car_no != "") { |
|
|
|
$query->andWhere('caiwu_t.car_no like "%' . $car_no . '%"'); |
|
|
|
$query->andWhere('caiwu_t.car_no like "%' . $car_no . '%"'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($insurer_no != "") { |
|
|
|
if ($insurer_no != "") { |
|
|
|
$query->andWhere('caiwu_t.insurer_no like "' . $insurer_no . '%"'); |
|
|
|
$query->andWhere('caiwu_t.insurer_no like "' . $insurer_no . '%"'); |
|
|
|
} |
|
|
|
} |
|
|
@ -7899,10 +7879,8 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
//找出$group_id 有多少在职的user_ids |
|
|
|
//找出$group_id 有多少在职的user_ids |
|
|
|
// 现在的搜索条件 |
|
|
|
// 现在的搜索条件 |
|
|
|
$userSql = ''; |
|
|
|
$userSql = ''; |
|
|
|
|
|
|
|
|
|
|
|
$user_items = $this->my->getChildren($userSql); |
|
|
|
$user_items = $this->my->getChildren($userSql); |
|
|
|
$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) { |
|
|
@ -7910,36 +7888,71 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$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; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$item1s = $query1->all(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// echo $query->createCommand()->rawSql; |
|
|
|
|
|
|
|
$total = $query->count(); |
|
|
|
$total = $query->count(); |
|
|
|
|
|
|
|
|
|
|
|
$sum_r_total = $query->sum('r_total'); |
|
|
|
$query1 = clone $query; |
|
|
|
//商业净保费综合 |
|
|
|
$sums = $query1->select([ |
|
|
|
$sum_total_clear = $query->sum('total_clear'); //是错误的 |
|
|
|
'sum_total1' => 'sum(order_t.total1)', |
|
|
|
|
|
|
|
'sum_r_total' => 'sum(caiwu_t.r_total)', |
|
|
|
//商业总保费 |
|
|
|
'sum_total1_clear' => 'sum(order_t.total1_clear)', |
|
|
|
$sum_total = $query->sum('total'); |
|
|
|
'sum_budian' => 'sum(order_t.yuangong_money)', |
|
|
|
|
|
|
|
'sum_r_budian' => 'sum(ifnull(caiwu_t.budian_rate,0)*total_clear/100)', |
|
|
|
|
|
|
|
'sum_total1_dis' => 'sum(order_t.total1_dis)', |
|
|
|
|
|
|
|
])->asArray()->one(); |
|
|
|
|
|
|
|
$query2 = clone $query; |
|
|
|
|
|
|
|
$gift_sum = $query2 |
|
|
|
|
|
|
|
->leftJoin(OrderGiftT::tableName(), "order_gift_t.order_id=caiwu_t.order_id") |
|
|
|
|
|
|
|
->leftJoin(GiftT::tableName(), "gift_t.id=order_gift_t.gift_id") |
|
|
|
|
|
|
|
->andWhere('caiwu_t.insurer_type=1') |
|
|
|
|
|
|
|
->andWhere('order_gift_t.gift_type=1 && order_gift_t.is_free=2') |
|
|
|
|
|
|
|
->sum('gift_t.price'); |
|
|
|
|
|
|
|
$query2 = clone $query; |
|
|
|
|
|
|
|
$voucher_sum = $query2 |
|
|
|
|
|
|
|
->leftJoin(OrderGiftT::tableName(), "order_gift_t.order_id=caiwu_t.order_id") |
|
|
|
|
|
|
|
->leftJoin(GiftT::tableName(), "gift_t.id=order_gift_t.gift_id") |
|
|
|
|
|
|
|
->andWhere('caiwu_t.insurer_type=1') |
|
|
|
|
|
|
|
->andWhere('order_gift_t.gift_type=2 && order_gift_t.is_free=2') |
|
|
|
|
|
|
|
->sum('gift_t.price'); |
|
|
|
|
|
|
|
$query2 = clone $query; |
|
|
|
|
|
|
|
$gongzi_sum = $query2 |
|
|
|
|
|
|
|
->leftJoin(PayOrderUserT::tableName(), "pay_order_user_t.order_id=caiwu_t.order_id") |
|
|
|
|
|
|
|
->andWhere('caiwu_t.insurer_type=1') |
|
|
|
|
|
|
|
->sum('pay_order_user_t.real_pay'); |
|
|
|
|
|
|
|
|
|
|
|
$sum_total_dis = $query->sum('total_dis'); |
|
|
|
switch ($sort_key) { |
|
|
|
|
|
|
|
case 'total': |
|
|
|
|
|
|
|
$sort = 'caiwu_t.total '; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'total_clear': |
|
|
|
|
|
|
|
$sort = 'caiwu_t.total_clear '; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'total_rate': |
|
|
|
|
|
|
|
$sort = 'caiwu_t.total_rate '; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'print_date'://默认按照print_date排序 |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
$sort = 'order_t.print_date '; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
switch ($sort_value) { |
|
|
|
|
|
|
|
case 'ASC': |
|
|
|
|
|
|
|
$sort .= 'ASC'; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'DESC': |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
$sort .= 'DESC'; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$query = $query->offset($offset)->limit($limit); |
|
|
|
$query = $query->orderBy($sort)->offset($offset)->limit($limit); |
|
|
|
$items = $query->all(); |
|
|
|
$items = $query->all(); |
|
|
|
|
|
|
|
|
|
|
|
// var_dump($items); |
|
|
|
|
|
|
|
$data = []; |
|
|
|
$data = []; |
|
|
|
$data['total'] = $total; |
|
|
|
$data['total'] = $total; |
|
|
|
$data['rows'] = []; |
|
|
|
$data['rows'] = []; |
|
|
@ -7972,8 +7985,19 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
$data['rows'][] = $row; |
|
|
|
$data['rows'][] = $row; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $data; |
|
|
|
$data['rows'][] = array( |
|
|
|
|
|
|
|
['商业保总额', number_format($sums['sum_total1'],2)], |
|
|
|
|
|
|
|
['商业净保总额', number_format($sums['sum_total1_clear'],2)], |
|
|
|
|
|
|
|
['回款总额', number_format($sums['sum_r_total'],2)], |
|
|
|
|
|
|
|
['补点总额', number_format($sums['sum_budian'],2)], |
|
|
|
|
|
|
|
['回款补点总额', number_format($sums['sum_r_budian'],2)], |
|
|
|
|
|
|
|
['减免总额', number_format($sums['sum_total1_dis'],2)], |
|
|
|
|
|
|
|
['礼品礼券自费总额', number_format($gift_sum + $voucher_sum,2)], |
|
|
|
|
|
|
|
['工资总额', number_format($gongzi_sum,2)], |
|
|
|
|
|
|
|
['利润总额', number_format($sums['sum_total1_clear'] + $sums['sum_budian'] - $sums['sum_total1_dis'] - $gongzi_sum - $gift_sum - $voucher_sum,2)], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $data; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function actionGongziAllReturnSave() |
|
|
|
public function actionGongziAllReturnSave() |
|
|
|