Commit e496463d by HTML5-侯张振

新接口更改

parent 07225ff4
......@@ -131,8 +131,12 @@ class Report extends CI_Controller
$this->data['count'] = $count;
$customers = $this->customer_building->get_report_list($where, $page_no, self::PAGE_SIZE);
// echo '<pre>';
// print_r($customers);die;
//$salewhere = $customers['cid'];
$salearray = array();
foreach($customers as $i=>$sale){
$customers[$i]['Strue_name'] = $this->customer_building->get_report_salelist($sale['id']);
}
//echo '<pre>';print_r($customers);die;
if ($customers) {
//查找楼盘的经理和销售员关系
......@@ -502,6 +506,7 @@ class Report extends CI_Controller
$this->load->model('recommend_trace_model', 'recommend');
$this->load->model('customer_building_log_model','customer_building_log');
$this->load->model('sales_model','sales');
$this->load->model('customer_sales_model','customer_sales');
$this->load->helper('eas');
$api=new easApi;
$customerId = $this->customer->search_rongchuang_id();
......@@ -515,18 +520,25 @@ class Report extends CI_Controller
$customerBuilding = $this->customer_building->get(array('id' => $entity_id['id']));
//获取返回的sale_id
$checksalesnum='';
$checksalesnum=array();
$checksales=$results[0]["saleManColl"];
foreach($checksales as $value){
$checksalesID=$this->sales->get(array('rongchuang_user_id'=> $value["id"]));
if(count($checksales,COUNT_NORMAL)>1){
$checksalesnum.=','.$checksalesID['user_id'];
$checksalesnum[]=$checksalesID['user_id'];
}else{
$checksalesnum=$checksalesID['user_id'];
}
};
if($customerBuilding['sale_id']!=$checksalesnum){
$this->customer_building->update_customer_building($value['id'],array('sale_id' => $checksalesnum));
$customer_sales_id = $this->customer_building->get_sale_id(array('customer_building_id'=>$customerBuilding['id']));
if(!($customer_sales_id==$checksalesnum)){
$this->customer_sales->delete_sale_id(array('customer_building_id'=>$customerBuilding['id']));
foreach($checksalesnum as $checksales){
$customer_sales['customer_building_id'] = $customerBuilding['id'];
$customer_sales['sale_id'] = $checksales['user_id'];
$customer_sales['create_time'] = timer();
$this->customer_sales->add($customer_sales);
}
$datasales['user_id'] = $customerBuilding['user_id'];
$datasales['customer_id'] = $customerBuilding['customer_id'];
$datasales['building_id'] = $customerBuilding['building_id'];
......
......@@ -143,7 +143,8 @@ class Customer_building_model extends MY_Model{
->join('tb_building B', 'B.id = CB.building_id ', 'left')
->join('tb_customer C', 'C.id = CB.customer_id ', 'left')
->join('tb_region R', 'R.region_code = CB.city_code ', 'left')
->join('tb_user UP', 'UP.id in ("CB.sale_id")', 'left')
// ->join('tb_customer_sales US', 'US.customer_building_id = CB.id', 'left')
->join('tb_user UP', 'UP.id = CB.sale_id', 'left')
->join('tb_user U', 'U.id = CB.user_id', 'left')
->join('tb_user TU', 'TU.id = CB.manager_id', 'left')
->join('tb_distributor D', 'D.id = CB.distributor_id', 'left')
......@@ -169,6 +170,47 @@ class Customer_building_model extends MY_Model{
}
return array();
}
public function get_report_salelist($where = '')
{
$this->db->distinct()
->select('UP.true_name Strue_name')
->from('tb_customer_building CB')
->join('tb_customer_sales US', 'US.customer_building_id = CB.id', 'left')
->join('tb_user UP', 'UP.id = US.sale_id', 'left');
if(!empty($where))
{
$this->db->where('CB.id =' . $where);
}
$this->db->order_by('CB.id','desc');
$query = $this->db->get();
if($query->num_rows() > 0)
{
$return = $query->result_array();
return $return;
}
return array();
}
//获取sale_id
public function get_sale_id($where){
$this->db->select('CS.sale_id')
->from('tb_customer_sales CS')
->where($where);
$query = $this->db->get();
if($query->num_rows() > 0)
{
$return = $query->result_array();
return $return;
}
return array();
}
//二次报备列表
public function get_reportagain_list($where = '', $page = 1, $page_size = 10, $order = NULL)
{
......
......@@ -280,7 +280,7 @@
<?php }else{?>
<td>已过期</td>
<?php }?>
<td><?php echo $customer['Strue_name'];?></td>
<td><?php foreach($customer['Strue_name'] as $i=>$sale):?><?php if($i==0||$customer['Strue_name'][$i]['Strue_name']==''){?><?php echo $customer['Strue_name'][$i]['Strue_name']?><?php }else{?><?php echo ",".$customer['Strue_name'][$i]['Strue_name']?><?php }?><?php endforeach?></td>
<td><?php echo $customer['Mtrue_name'];?></td>
<td><?php echo $customer['agent_name'];?></td>
<td><?php echo $customer['channel_name']; ?></td>
......
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