|
|
@ -6812,19 +6812,14 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
$gift_sum = $query2 |
|
|
|
$gift_sum = $query2 |
|
|
|
->leftJoin(OrderGiftT::tableName(), "order_gift_t.order_id=caiwu_t.order_id") |
|
|
|
->leftJoin(OrderGiftT::tableName(), "order_gift_t.order_id=caiwu_t.order_id") |
|
|
|
->leftJoin(GiftT::tableName(), "gift_t.id=order_gift_t.gift_id") |
|
|
|
->leftJoin(GiftT::tableName(), "gift_t.id=order_gift_t.gift_id") |
|
|
|
->where('order_gift_t.gift_type=1 && order_gift_t.is_free=2') |
|
|
|
->andWhere('order_gift_t.gift_type=1 && order_gift_t.is_free=2') |
|
|
|
->select([ |
|
|
|
->sum('gift_t.price'); |
|
|
|
'sum_gift' => 'sum(gift_t.price)', |
|
|
|
|
|
|
|
])->asArray()->one(); |
|
|
|
|
|
|
|
$query2 = clone $query; |
|
|
|
$query2 = clone $query; |
|
|
|
$voucher_sum = $query2 |
|
|
|
$voucher_sum = $query2 |
|
|
|
->leftJoin(OrderGiftT::tableName(), "order_gift_t.order_id=caiwu_t.order_id") |
|
|
|
->leftJoin(OrderGiftT::tableName(), "order_gift_t.order_id=caiwu_t.order_id") |
|
|
|
->leftJoin(GiftT::tableName(), "gift_t.id=order_gift_t.gift_id") |
|
|
|
->leftJoin(GiftT::tableName(), "gift_t.id=order_gift_t.gift_id") |
|
|
|
->where('order_gift_t.gift_type=2 && order_gift_t.is_free=2') |
|
|
|
->andWhere('order_gift_t.gift_type=2 && order_gift_t.is_free=2') |
|
|
|
->select([ |
|
|
|
->sum('gift_t.price'); |
|
|
|
'sum_gift' => 'sum(gift_t.price)', |
|
|
|
|
|
|
|
])->asArray()->one(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$total = $query->count(); |
|
|
|
$total = $query->count(); |
|
|
|
$query=$query->offset($offset)->limit($limit); |
|
|
|
$query=$query->offset($offset)->limit($limit); |
|
|
|
$items = $query->orderBy('order_t.print_date DESC')->all(); |
|
|
|
$items = $query->orderBy('order_t.print_date DESC')->all(); |
|
|
@ -6873,8 +6868,8 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
['商业净保总额', number_format($sums['sum_total1_clear'],2)], |
|
|
|
['商业净保总额', number_format($sums['sum_total1_clear'],2)], |
|
|
|
['基本提成合计', number_format($sums['sum_yeji_ticheng'],2)], |
|
|
|
['基本提成合计', number_format($sums['sum_yeji_ticheng'],2)], |
|
|
|
['加点提成合计', number_format($sums['sum_ticheng_money'],2)], |
|
|
|
['加点提成合计', number_format($sums['sum_ticheng_money'],2)], |
|
|
|
['自费礼品合计', number_format($gift_sum['sum_gift'],2)], |
|
|
|
['自费礼品合计', number_format($gift_sum,2)], |
|
|
|
['自费礼券合计', number_format($voucher_sum['sum_gift'],2)], |
|
|
|
['自费礼券合计', number_format($voucher_sum,2)], |
|
|
|
['自费减免合计', number_format($sums['sum_yuangong_money'],2)], |
|
|
|
['自费减免合计', number_format($sums['sum_yuangong_money'],2)], |
|
|
|
['提成合计', number_format($sums['sum_yewu_ticheng'],2)] |
|
|
|
['提成合计', number_format($sums['sum_yewu_ticheng'],2)] |
|
|
|
); |
|
|
|
); |
|
|
@ -7817,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; |
|
|
|
} |
|
|
|
} |
|
|
@ -7833,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 . '%"'); |
|
|
|
} |
|
|
|
} |
|
|
@ -7926,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) { |
|
|
@ -7937,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'] = []; |
|
|
@ -7999,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() |
|
|
|