109 lines
3.4 KiB
PHP
109 lines
3.4 KiB
PHP
<?php
|
|
/**
|
|
* Created by Vim
|
|
* User: lcc
|
|
* Date: 2021/06/29
|
|
* Time: 13:47
|
|
*/
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class Receiver_clues_model extends HD_Model
|
|
{
|
|
private $table_name = 'lc_receiver_clues';
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct($this->table_name, 'default');
|
|
}
|
|
|
|
/**
|
|
* Notes:线索状态
|
|
* Created on: 2021/9/15 10:25
|
|
* Created by: dengbw
|
|
* @param $status
|
|
* @return array
|
|
*/
|
|
public function statusAry($status = '')
|
|
{
|
|
$status_ary[0] = array('name' => '待处理', 'list' => array());
|
|
$status_ary[1] = array('name' => '已分配', 'list' => array(1 => '强意向', 2 => '中意向', 3 => '弱意向'));
|
|
$status_ary[2] = array('name' => '跟进中', 'list' => array(4 => '未接通', 5 => '未完整触碰', 6 => '近期没时间'));
|
|
$status_ary[3] = array('name' => '无效线索', 'list' => array(7 => '明确拒绝', 8 => '误报', 9 => '战败'));
|
|
if (strlen($status)) {
|
|
$return_status = $status_ary[$status];
|
|
} else {
|
|
$return_status = $status_ary;
|
|
}
|
|
return $return_status;
|
|
}
|
|
|
|
//关联订单
|
|
public function count_order($where)
|
|
{
|
|
return $this->select_order($where, '', '', '', '', 1);
|
|
}
|
|
|
|
public function select_order($where = array(), $order = '', $page = 0, $page_size = 20, $fileds = '', $count = 0)
|
|
{
|
|
!$fileds && $fileds = 'lc_receiver_clues.*';
|
|
$this->db->select($fileds);
|
|
$this->db->from('lc_receiver_clues');
|
|
$this->db->join('lc_receiver_customers', 'lc_receiver_customers.rid = lc_receiver_clues.id', 'left');
|
|
$this->db->join('lc_receiver_orders', 'lc_receiver_orders.rid = lc_receiver_customers.id', 'left');
|
|
|
|
if ($where) {
|
|
$this->db->where($where);
|
|
}
|
|
if ($count) {
|
|
return $this->db->count_all_results();
|
|
}
|
|
if ($order) {
|
|
$this->db->order_by($order);
|
|
}
|
|
if ($page) {
|
|
$offset = ($page - 1) * $page_size;
|
|
$limit = $page_size;
|
|
} else {
|
|
$offset = null;
|
|
$limit = null;
|
|
}
|
|
$this->db->limit($limit, $offset);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
|
|
public function selectClues($where = array(), $order = '', $page = 0, $page_size = 20, $count = 0 ,$fileds = ''){
|
|
$this->db->from('lc_receiver_clues');
|
|
$this->db->join('lc_receiver_orders', 'lc_receiver_orders.clue_id = lc_receiver_clues.id and lc_receiver_orders.status>=0', 'left');
|
|
|
|
if ($where) {
|
|
$this->db->where($where);
|
|
}
|
|
|
|
if ($count) {
|
|
$this->db->distinct()->select('lc_receiver_clues.*');
|
|
return $this->db->count_all_results();
|
|
}else{
|
|
if($fileds){
|
|
$this->db->select($fileds);
|
|
}else{
|
|
$this->db->select('lc_receiver_clues.*,lc_receiver_orders.id as o_id');
|
|
}
|
|
$this->db->group_by('lc_receiver_clues.id');
|
|
}
|
|
|
|
if ($order) {
|
|
$this->db->order_by($order);
|
|
}
|
|
if ($page) {
|
|
$offset = ($page - 1) * $page_size;
|
|
$limit = $page_size;
|
|
} else {
|
|
$offset = null;
|
|
$limit = null;
|
|
}
|
|
$this->db->limit($limit, $offset);
|
|
return $this->db->get()->result_array();
|
|
}
|
|
}
|