Files
liche/common/models/receiver/Receiver_customers_model.php
2022-05-10 11:41:50 +08:00

144 lines
4.4 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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 => '3天(H级)', 7 => '7天(A级)', 15 => '15天(B级)', 30 => '30天 C级)'];
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;
}
/**
* Notes:线下来源
* Created on: 2022/3/4 16:54
* Created by: dengbw
* @param int $id
* @return mixed
*/
public function offlineSources($id = 0)
{
$arr[1] = ['name' => '自然到店', 'list' => []];
$arr[2] = ['name' => '转介绍', 'list' => [20 => '其他4S店', 21 => '其他二网', 22 => '汽车美容', 23 => '二手车',
24 => '修车厂', 25 => '驾校', 26 => '老车主', 27 => '亲朋好友']];
$arr[3] = ['name' => '网络推广', 'list' => [30 => '抖音', 31 => '区域媒体', 32 => '懂车帝', 33 => '易车',
34 => '汽车之家', 35 => '网红', 36 => '厂商分配', 37 => '狸车分配']];
$arr[4] = ['name' => '外展外拓', 'list' => [40 => '巡展', 41 => '车展', 42 => '静展', 43 => '大客户']];
$arr[5] = ['name' => '自媒体', 'list' => [50 => '小红书号', 51 => '咸鱼号', 52 => '抖音号', 53 => '狸车素材', 54 => '知乎号']];
if ($id) {
return $arr[$id];
} else {
return $arr;
}
}
/**
* Notes:企微好友状态
* Created on: 2022/5/10 10:00
* Created by: dengbw
* @param int $id
* @return array|mixed
*/
public function wxqyAry($id = '')
{
$arr = [0 => '未添加', 1 => '已添加', -1 => '删除'];
if (strlen($id)) {
return $arr[$id];
} else {
return $arr;
}
}
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();
}
}