Commit f80c8f82 authored by zhuwei's avatar zhuwei

计算业绩总计 即应分佣金 根据分佣ID去重

parent 52a9bbed
...@@ -175,14 +175,42 @@ class ImageDepot extends Basic ...@@ -175,14 +175,42 @@ class ImageDepot extends Basic
public function ceshi(){ public function ceshi(){
//查询客户是否在保护期内
//判断客户是否超过24小时保护期间 0:保护器内 1:超过保护期 $records = array(
$vip_services = new VipService(); array(
//是否可以查看vip客户 0:可查看 1:不可查看 'bargain_id' => 2135,
$agent_id = 51; 'scale_fee' => 12,
$group_id = '2,3,4,5'; ),
$res = $vip_services->getGroup($agent_id, $group_id); array(
dump($res); 'bargain_id' => 2135,
'scale_fee' => 12,
),
array(
'bargain_id' => 2135,
'scale_fee' => 12,
),
array(
'bargain_id' => 5623,
'scale_fee' => 12,
)
);
$first_names = $this->arr_unset($records,'bargain_id');
dump($first_names);
}
//对一个二维数组的某个键进行去重
private function arr_unset($arr,$key){
$res = array();
foreach ($arr as $value) {
if(isset($res[$value[$key]])){//查看有没有重复项
unset($value[$key]); //有:销毁
}
else{
$res[$value[$key]] = $value;
}
}
return $res;
} }
} }
......
...@@ -121,9 +121,24 @@ class PerformanceInfo extends Basic ...@@ -121,9 +121,24 @@ class PerformanceInfo extends Basic
} }
$return_total = $this->oBargainModel->performancelInfoTotal($where,$field); $return_total = $this->oBargainModel->performancelInfoTotal($where,$field);
$field = 'sum(Obargain.scale_fee) as scale_fee_sum';
$return_sum = $this->oBargainModel->performancelInfo($where,$field,$pageSize,$pageNo); /*计算业绩总计 即应分佣金 根据分佣ID去重*/
return $this->response(200, '', ['scale_fee_sum'=>$return_sum[0]['scale_fee_sum'],'data'=>$return,'total'=>$return_total]); $field = 'Obargain.scale_fee,Obargain.id,Obargain.father_id';
$return_sum = $this->oBargainModel->performancelInfoScaleFee($where,$field);
foreach ($return_sum as $key1 => $val1) {
//成交报告ID
$return_sum[$key1]['bargain_id'] = $val1["father_id"] == 0 ? $val1["id"] : $val1["father_id"];
//分佣ID
$return_sum[$key1]['commission_id'] = $val1["id"] ;
}
$return_sum_unique = $this->arr_unset($return_sum,'commission_id');
$return_sum = 0;
foreach ($return_sum_unique as $key12 => $val2) {
$return_sum += $val2["scale_fee"];
}
/*计算业绩总计 即应分佣金 根据分佣ID去重*/
return $this->response(200, '', ['scale_fee_sum'=>$return_sum,'data'=>$return,'total'=>$return_total]);
} else { } else {
return view('performanceInfo'); return view('performanceInfo');
} }
...@@ -253,6 +268,28 @@ class PerformanceInfo extends Basic ...@@ -253,6 +268,28 @@ class PerformanceInfo extends Basic
} }
//对一个二维数组的某个键进行去重
private function arr_unset($arr,$key){
$res = array();
foreach ($arr as $value) {
if(isset($res[$value[$key]])){//查看有没有重复项
unset($value[$key]); //有:销毁
}
else{
$res[$value[$key]] = $value;
}
}
return $res;
}
} }
\ No newline at end of file
...@@ -1413,6 +1413,25 @@ class OBargainModel extends Model ...@@ -1413,6 +1413,25 @@ class OBargainModel extends Model
return $result; return $result;
} }
public function performancelInfoScaleFee($where, $filed)
{
$result = $this->db_
->field($filed)
->alias("Obargain")
->join("o_report Oreport", "Obargain.report_id = Oreport.id", "left")
->join("o_order Oorder", "Obargain.order_id = Oorder.id", "left")
->join("g_houses Houses", "Oorder.house_id = Houses.id", "left")
->join("a_agents Agent", "Obargain.agent_id = Agent.id", "left")
->join('a_store Store', 'Agent.store_id = Store.id', 'left')
->join('a_district District', 'Agent.district_id = District.id', 'left')
->join('o_partial_commission PartialCommission', 'PartialCommission.bargain_id = Obargain.id', 'left')
->where($where)
->order("Obargain.create_time desc")
->select();
//echo $this->db_->getLastSql();
return $result;
}
public function performancelInfoExcel($where, $filed) public function performancelInfoExcel($where, $filed)
{ {
$result = $this->db_ $result = $this->db_
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment