|
|
|
@ -214,14 +214,21 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
|
foreach($items as $item) { |
|
|
|
|
$row = $item->toArray(); |
|
|
|
|
$row['group'] = $item->user && $item->user->group ? $item->user->group->name : ''; |
|
|
|
|
$row['company_name'] = $item->order->company2->name; |
|
|
|
|
$row['username'] = $item->user ? $item->user->showName : ''; |
|
|
|
|
$row['submit_date'] = $item->order->submit_date; |
|
|
|
|
$row['print_date'] = $item->order->print_date; |
|
|
|
|
$row['company_name'] = $item->order && $item->order->company2 ? $item->order->company2->name : 0; |
|
|
|
|
$row['username'] = $item->user ? $item->user->getShowName() : 0; |
|
|
|
|
$row['submit_date'] = $item->order ? $item->order->submit_date : ''; |
|
|
|
|
$row['print_date'] = $item->order ? $item->order->print_date : ''; |
|
|
|
|
$row['total_real'] = round($item->total_clear_real + $item->total_tax_real,2); |
|
|
|
|
$data['rows'][] = $row; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$data['rows'][] = array( |
|
|
|
|
['商业保总额', $sum_total], |
|
|
|
|
['商业净保总额', $sum_total_clear], |
|
|
|
|
['回款总额', $sum_r_total], |
|
|
|
|
['回款差额', $sum_total_dis] |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
return $data; |
|
|
|
|
} |
|
|
|
|
public function actionReceiptImport() { |
|
|
|
@ -5147,12 +5154,20 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
|
$row['is_leave'] = $item->is_leave ? '已离职':''; |
|
|
|
|
$pay_info = $item->getPay($pay_date); |
|
|
|
|
$row['status_name'] = $pay_info ? $pay_info->getStatus($pay_info->status_id) : ''; |
|
|
|
|
$row['real_pay'] = $pay_info->base_real_pay; |
|
|
|
|
$row['should_pay'] = $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['real_pay'] = $pay_info ? $pay_info->base_real_pay : ''; |
|
|
|
|
$row['should_pay'] = $pay_info ? $pay_info->ticheng_real_pay : ''; |
|
|
|
|
$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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$pay_chexian = PayT::find() |
|
|
|
|
->where("pay_date='{$pay_date}'") |
|
|
|
|
->sum('ticheng_real_pay'); |
|
|
|
|
|
|
|
|
|
$data['rows'][] = array( |
|
|
|
|
['提成工资总额', number_format($pay_chexian,2)], |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
return $data; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -6543,6 +6558,7 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
|
$query->andWhere('order_t.print_date<="' . $end_date . '"'); |
|
|
|
|
} |
|
|
|
|
$total = $query->count(); |
|
|
|
|
$sum_total1_clear = $query->sum('total1_clear'); |
|
|
|
|
|
|
|
|
|
$query->offset($offset)->limit($limit); |
|
|
|
|
$items = $query->all(); |
|
|
|
@ -6561,6 +6577,10 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
|
$data['rows'][] = $row; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$data['rows'][] = array( |
|
|
|
|
['商业净保总额', number_format($sum_total1_clear,2)], |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
return $data; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -6718,18 +6738,14 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
|
$group_ids = []; |
|
|
|
|
if($group_id > 0) { |
|
|
|
|
$items = GroupT::getTree($group_id); |
|
|
|
|
|
|
|
|
|
$group_ids[] = $group_id; |
|
|
|
|
foreach($items as $group_info) { |
|
|
|
|
$group_ids[] = $group_info->id; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$query = CaiwuT::find() |
|
|
|
|
->leftJoin(OrderT::tableName(), "order_t.id=caiwu_t.order_id") |
|
|
|
|
->where('order_t.status_id>1') |
|
|
|
|
->orderBy('order_t.print_date DESC'); |
|
|
|
|
|
|
|
|
|
->where('order_t.status_id>1'); |
|
|
|
|
if($user_names != '' && $user_names != 'null'){ |
|
|
|
|
$user_arr = explode(',',$user_names); |
|
|
|
|
$user_ids = []; |
|
|
|
@ -6738,40 +6754,33 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
|
if($user) |
|
|
|
|
$user_ids[] = $user->id; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$query->andWhere(['in','caiwu_t.user_id',$user_ids]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if( $company_id > 0) { |
|
|
|
|
$query->andWhere('order_t.company2_id='.$company_id); |
|
|
|
|
} |
|
|
|
|
if( $car_no != '') { |
|
|
|
|
$query->andWhere('order_t.car_no="'.$car_no.'"'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if($car_no_type == 1){ |
|
|
|
|
$query->andWhere('caiwu_t.car_no like "' . '京' . '%"'); |
|
|
|
|
}elseif($car_no_type == 2){ |
|
|
|
|
$query->andWhere('caiwu_t.car_no not like "' . '京' . '%"'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if($begin_totalclear != ''){ |
|
|
|
|
$query->andWhere('caiwu_t.total_clear >=' . $begin_totalclear); |
|
|
|
|
} |
|
|
|
|
if($end_totalclear != ''){ |
|
|
|
|
$query->andWhere('caiwu_t.total_clear <=' . $end_totalclear); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($begin_date != "") { |
|
|
|
|
$query->andWhere('order_t.print_date>="' . $begin_date . '"'); |
|
|
|
|
} |
|
|
|
|
if ($end_date != "") { |
|
|
|
|
$query->andWhere('order_t.print_date<="' . $end_date . '"'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$user_items = $this->my->getChildren(''); |
|
|
|
|
$user_items[] = $this->my; |
|
|
|
|
|
|
|
|
|
$row = array(); |
|
|
|
|
foreach($user_items as $user_info) { |
|
|
|
|
if ($group_id > 0) { |
|
|
|
@ -6781,58 +6790,46 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
|
} |
|
|
|
|
$row[] = $user_info->id; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//加上级别筛选 |
|
|
|
|
if($group_id > 0){ |
|
|
|
|
$query->andWhere(['in','caiwu_t.user_id',$row]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$query1 = clone $query; |
|
|
|
|
if($insurer_type ==1){ |
|
|
|
|
$query->andWhere('caiwu_t.insurer_type=1'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$items = $query->all(); |
|
|
|
|
|
|
|
|
|
$total2_clear_all = $query1->andWhere('caiwu_t.insurer_type=2')->sum('total_clear'); |
|
|
|
|
|
|
|
|
|
$yewu_ticheng_all = 0; |
|
|
|
|
$total1_clear_all = 0; |
|
|
|
|
$yeji_ticheng_all = 0; |
|
|
|
|
$ticheng_money_all = 0; |
|
|
|
|
$lipin_all = 0; |
|
|
|
|
$liquan_all = 0; |
|
|
|
|
$yuangong_money_all = 0; |
|
|
|
|
foreach($items as $index => $item) { |
|
|
|
|
$order_caiwu_info = $item->orderCaiwu; |
|
|
|
|
$order_info = $item->order; |
|
|
|
|
|
|
|
|
|
$total1_clear_all += $item->total_clear; |
|
|
|
|
$yewu_ticheng_all += $order_caiwu_info ? $order_caiwu_info->yewu_ticheng : 0; |
|
|
|
|
$yeji_ticheng_all += $order_caiwu_info ? $order_caiwu_info->yeji_ticheng : 0; |
|
|
|
|
$ticheng_money_all += $order_info ? $order_info->ticheng_money : 0; |
|
|
|
|
$lipin_all += $order_info ? $order_info->getGiftPrice(1,1) : 0; |
|
|
|
|
$liquan_all += $order_info ? $order_info->getGiftPrice(1,2) : 0; |
|
|
|
|
$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; |
|
|
|
|
$query1 = clone $query; |
|
|
|
|
$sums = $query1 |
|
|
|
|
->leftJoin(OrderCaiwuT::tableName(), "order_t.id=order_caiwu_t.order_id") |
|
|
|
|
->select([ |
|
|
|
|
'sum_total1_clear' => 'sum(order_t.total1_clear)', |
|
|
|
|
'sum_total2_clear' => 'sum(order_t.total2_clear)', |
|
|
|
|
'sum_yeji_ticheng' => 'sum(order_caiwu_t.yeji_ticheng)', |
|
|
|
|
'sum_ticheng_money' => 'sum(order_caiwu_t.ticheng_money)', |
|
|
|
|
'sum_yuangong_money' => 'sum(order_caiwu_t.yuangong_money)', |
|
|
|
|
'sum_yewu_ticheng' => 'sum(order_caiwu_t.yewu_ticheng)', |
|
|
|
|
])->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('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('order_gift_t.gift_type=2 && order_gift_t.is_free=2') |
|
|
|
|
->sum('gift_t.price'); |
|
|
|
|
$total = $query->count(); |
|
|
|
|
|
|
|
|
|
$query->offset($offset)->limit($limit); |
|
|
|
|
$items = $query->all(); |
|
|
|
|
$query=$query->offset($offset)->limit($limit); |
|
|
|
|
$items = $query->orderBy('order_t.print_date DESC')->all(); |
|
|
|
|
|
|
|
|
|
$data = []; |
|
|
|
|
$data['total'] = $total; |
|
|
|
|
$data['rows'] = []; |
|
|
|
|
foreach($items as $item) { |
|
|
|
|
$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['yeji_rate'] = $item->orderCaiwu->yeji_rate; |
|
|
|
|
$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['yewu_ticheng'] = $item->orderCaiwu->yewu_ticheng; |
|
|
|
|
if($item->order->car->op2_id > 0) { |
|
|
|
|
$row['op_user'] = $item->order->car->op2->showName; |
|
|
|
|
$row['op_user1'] = $item->order->car->op1->showName; |
|
|
|
|
$row['op_user'] = $item->order->car->op2?$item->order->car->op2->showName:''; |
|
|
|
|
$row['op_user1'] = $item->order->car->op1?$item->order->car->op1->showName:''; |
|
|
|
|
} 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['first_xinbao_ticheng'] = $item->orderCaiwu->first_xinbao_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['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_names1'] = $item->orderCaiwu->dz_names1; |
|
|
|
|
$row['dz_ticheng2'] = $item->orderCaiwu->dz_ticheng2; |
|
|
|
@ -6866,6 +6863,16 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
|
$row['dz_names5'] = $item->orderCaiwu->dz_names5; |
|
|
|
|
$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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -7379,6 +7386,9 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
|
|
|
|
|
|
$query = $query->offset($offset)->limit($limit); |
|
|
|
|
$items = $query->all(); |
|
|
|
|
$pay_chexian = PayOrderUserT::find() |
|
|
|
|
->where("pay_date='{$pay_date}'") |
|
|
|
|
->sum('real_pay'); |
|
|
|
|
|
|
|
|
|
$data = []; |
|
|
|
|
$data['total'] = $total; |
|
|
|
@ -7394,6 +7404,10 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
|
$data['rows'][] = $row; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$data['rows'][] = array( |
|
|
|
|
['提成工资总额', number_format($pay_chexian,2)], |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
return $data; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
@ -7585,7 +7599,6 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
|
$limit = $request->get('limit', 10); |
|
|
|
|
|
|
|
|
|
$user_id = $this->my->id; |
|
|
|
|
// var_dump($user_id); |
|
|
|
|
$query = UserT::find() |
|
|
|
|
->leftJoin('pay_t','pay_t.user_id=user_t.id') |
|
|
|
|
->where('group_id>0 and is_delete=0'); |
|
|
|
@ -7626,8 +7639,17 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
|
$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 string |
|
|
|
@ -7790,14 +7812,9 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
|
$zbname = $request->get('zbname'); |
|
|
|
|
//级别 |
|
|
|
|
$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; |
|
|
|
|
|
|
|
|
|
if($group_id > 0) { |
|
|
|
|
$items = GroupT::getTree($group_id); |
|
|
|
|
|
|
|
|
|
foreach($items as $group_info) { |
|
|
|
|
$group_ids[] = $group_info->id; |
|
|
|
|
} |
|
|
|
@ -7806,70 +7823,33 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
|
$query = CaiwuT::find() |
|
|
|
|
->leftJoin(OrderT::tableName(), "order_t.id=caiwu_t.order_id") |
|
|
|
|
->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) { |
|
|
|
|
$query->andWhere('caiwu_t.insurer_type='.$insurer_type); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if( $company_id > 0) { |
|
|
|
|
$query->andWhere('order_t.company2_id='.$company_id); |
|
|
|
|
} |
|
|
|
|
if ($username != "") { |
|
|
|
|
// $userdata = UserT::findOne(['username'=>$username]); |
|
|
|
|
$userdata = UserT::find()->where('username="'.$username.'"')->andwhere('is_leave=0')->one(); |
|
|
|
|
if($userdata){ |
|
|
|
|
$query->andWhere('caiwu_t.user_id = ' . $userdata->id . ''); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($hebaoname != "") { |
|
|
|
|
// $userdata = UserT::findOne(['username'=>$username]); |
|
|
|
|
$userdata = UserT::find()->where('username="'.$hebaoname.'"')->andwhere('is_leave=0')->one(); |
|
|
|
|
if($userdata){ |
|
|
|
|
$query->andWhere('order_t.op1_id = ' . $userdata->id . ''); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($zbname != "") { |
|
|
|
|
// $userdata = UserT::findOne(['username'=>$username]); |
|
|
|
|
$userdata = UserT::find()->where('username="'.$zbname.'"')->andwhere('is_leave=0')->one(); |
|
|
|
|
if($userdata){ |
|
|
|
|
$query->andWhere('order_t.op2_id = ' . $userdata->id . ''); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($car_no != "") { |
|
|
|
|
$query->andWhere('caiwu_t.car_no like "%' . $car_no . '%"'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($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 |
|
|
|
|
// 现在的搜索条件 |
|
|
|
|
$userSql = ''; |
|
|
|
|
|
|
|
|
|
$user_items = $this->my->getChildren($userSql); |
|
|
|
|
$user_items[] = $this->my; |
|
|
|
|
|
|
|
|
|
$row = array(); |
|
|
|
|
foreach($user_items as $user_info) { |
|
|
|
|
if ($group_id > 0) { |
|
|
|
@ -7910,36 +7888,71 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$row[] = $user_info->id; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//加上级别筛选 |
|
|
|
|
if($group_id > 0){ |
|
|
|
|
$query->andWhere(['in','caiwu_t.user_id',$row]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$query1 = clone $query; |
|
|
|
|
|
|
|
|
|
$item1s = $query1->all(); |
|
|
|
|
|
|
|
|
|
// echo $query->createCommand()->rawSql; |
|
|
|
|
$total = $query->count(); |
|
|
|
|
|
|
|
|
|
$sum_r_total = $query->sum('r_total'); |
|
|
|
|
//商业净保费综合 |
|
|
|
|
$sum_total_clear = $query->sum('total_clear'); //是错误的 |
|
|
|
|
|
|
|
|
|
//商业总保费 |
|
|
|
|
$sum_total = $query->sum('total'); |
|
|
|
|
$query1 = clone $query; |
|
|
|
|
$sums = $query1->select([ |
|
|
|
|
'sum_total1' => 'sum(order_t.total1)', |
|
|
|
|
'sum_r_total' => 'sum(caiwu_t.r_total)', |
|
|
|
|
'sum_total1_clear' => 'sum(order_t.total1_clear)', |
|
|
|
|
'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(); |
|
|
|
|
|
|
|
|
|
// var_dump($items); |
|
|
|
|
$data = []; |
|
|
|
|
$data['total'] = $total; |
|
|
|
|
$data['rows'] = []; |
|
|
|
@ -7972,8 +7985,19 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
|
$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() |
|
|
|
|