104 lines
2.9 KiB
PHP
104 lines
2.9 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_customers_model extends HD_Model
|
|
{
|
|
private $table_name = 'lc_receiver_customers';
|
|
|
|
private $status_arr = [-1 => '删除', 0 => '未见客户', 1 => '到店客户', 2 => '订单客户', 3 => '战败客户'];
|
|
private $level = ['H', 'A', 'B', 'C', 'D'];
|
|
private $cfrom_arr = ['自有资源', '平台分配', '素材推广', '私域活动'];
|
|
private $cfrom_clues_arr = ['自然进店', '外展', 'DM', '转介绍', '其它','网站','外展外拓','垂直媒体','自媒体'];
|
|
private $buy_time = [3, 7, 15, 30];
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct($this->table_name, 'default');
|
|
}
|
|
|
|
/**
|
|
* Notes:根据id获取数据
|
|
* @param $ids array() id 数组
|
|
* @param string $fileds
|
|
* @return array
|
|
*/
|
|
public function get_map_by_ids($ids, $fileds = '')
|
|
{
|
|
$rows = [];
|
|
$ids = array_filter($ids);
|
|
if ($ids) {
|
|
$cf_ids = implode(',', $ids);
|
|
$where = [
|
|
"id in ($cf_ids)" => null
|
|
];
|
|
$rows = $this->map('id', '', $where, '', '', '', $fileds);
|
|
}
|
|
return $rows;
|
|
}
|
|
|
|
public function get_status()
|
|
{
|
|
return $this->status_arr;
|
|
}
|
|
|
|
public function get_sdata($type = 'cfrom')
|
|
{
|
|
switch ($type) {
|
|
case 'cfrom':
|
|
$result = $this->cfrom_arr;
|
|
break;
|
|
case 'cfrom_clues':
|
|
$result = $this->cfrom_clues_arr;
|
|
break;
|
|
case 'btime':
|
|
$result = $this->buy_time;
|
|
break;
|
|
case 'level':
|
|
$result = $this->level;
|
|
break;
|
|
default:
|
|
$result = '';
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
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_customers.*';
|
|
$this->db->distinct()->select($fileds);
|
|
$this->db->from('lc_receiver_customers');
|
|
$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();
|
|
}
|
|
}
|