|
|
|
@ -6812,19 +6812,14 @@ class FinanceController extends \frontend\controllers\UserBaseController |
|
|
|
|
$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") |
|
|
|
|
->where('order_gift_t.gift_type=1 && order_gift_t.is_free=2') |
|
|
|
|
->select([ |
|
|
|
|
'sum_gift' => 'sum(gift_t.price)', |
|
|
|
|
])->asArray()->one(); |
|
|
|
|
->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") |
|
|
|
|
->where('order_gift_t.gift_type=2 && order_gift_t.is_free=2') |
|
|
|
|
->select([ |
|
|
|
|
'sum_gift' => 'sum(gift_t.price)', |
|
|
|
|
])->asArray()->one(); |
|
|
|
|
|
|
|
|
|
->andWhere('order_gift_t.gift_type=2 && order_gift_t.is_free=2') |
|
|
|
|
->sum('gift_t.price'); |
|
|
|
|
$total = $query->count(); |
|
|
|
|
$query=$query->offset($offset)->limit($limit); |
|
|
|
|
$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_yeji_ticheng'],2)], |
|
|
|
|
['加点提成合计', number_format($sums['sum_ticheng_money'],2)], |
|
|
|
|
['自费礼品合计', number_format($gift_sum['sum_gift'],2)], |
|
|
|
|
['自费礼券合计', number_format($voucher_sum['sum_gift'],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)] |
|
|
|
|
); |
|
|
|
@ -7817,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; |
|
|
|
|
} |
|
|
|
@ -7833,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 . '%"'); |
|
|
|
|
} |
|
|
|
@ -7926,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) { |
|
|
|
@ -7937,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'] = []; |
|
|
|
@ -7999,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() |
|
|
|
|