Customer.php
4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<?php
namespace app\admin\controller\facrm\analysis;
use app\common\controller\Backend;
use think\Db;
use think\Exception;
use think\exception\PDOException;
use think\exception\ValidateException;
/**
*客户分析
*/
class Customer extends Backend
{
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\facrm\Customer();
}
/**
*
* 地区分析
* @return \think\response\Json|void
*/
public function index()
{
$allmap=$dealmap=[];
$cache_key=md5("allmapdeal_map");
list($allmap,$dealmap)=cache($cache_key);
if (!$allmap&&!$dealmap) {
try {
//查询所有省份
$province_list=model('area')->where('level',1)->cache(true)->column('id','shortname');
foreach ($province_list as $key=>$val){
$r['name']=$key;
$r['value']= $this->model->where('province',$val)->where('deal_status',1)->count();
$dealmap[]=$r;
$f['name']=$key;
$f['value']= $this->model->where('province',$val)->count();;
$allmap[]=$f;
}
cache($cache_key,array($allmap,$dealmap),86400);
}catch (Exception $e){
$this->error(__("获取地区表和数据失败,查看解决方案:")."https://ask.fastadmin.net/question/17297.html");
}
}
if (!$allmap||!$dealmap){
$this->error(__("获取地区表和数据失败,查看解决方案:")."https://ask.fastadmin.net/question/17297.html");
}
$this->view->assign([
'allmap' =>$allmap,
'dealmap' =>$dealmap,
]);
return $this->view->fetch();
}
/**
* 行业分析
*/
public function industry(){
$config= get_addon_config('facrm');
$config['industry'][0]='未知';
$alldata=$dealdata=[];
$cache_key=md5("industrydealdataalldata");
list($allmap,$dealmap)=cache($cache_key);
if (!$alldata&&!$dealdata) {
foreach ($config['industry'] as $k=>$v){
$r['name']=$v;
$r['value']= $this->model->where('industry',$k)->count();
$alldata[]=$r;
$f['name']=$v;
$f['value']= $this->model->where('industry',$k)->where('deal_status',1)->count();;
$dealdata[]=$f;
}
cache($cache_key,array($alldata,$dealdata),86400);
}
$this->view->assign([
'industry' =>$config['industry'],
'alldata'=>$alldata,
'dealdata'=>$dealdata,
]);
return $this->view->fetch();
}
/**
* 级别分析
*/
public function level(){
$config= get_addon_config('facrm');
$config['level'][0]='未知';
$alldata=$dealdata=[];
$cache_key=md5("leveldealdataalldata");
list($alldata,$dealdata)=cache($cache_key);
if (!$alldata&&!$dealdata) {
foreach ($config['level'] as $k=>$v){
$r['name']=$v;
$r['value']= $this->model->where('level',$k)->count();
$alldata[]=$r;
$f['name']=$v;
$f['value']= $this->model->where('level',$k)->where('deal_status',1)->count();;
$dealdata[]=$f;
}
cache($cache_key,array($alldata,$dealdata),86400);
}
$this->view->assign([
'level' =>$config['level'],
'alldata'=>$alldata,
'dealdata'=>$dealdata,
]);
return $this->view->fetch();
}
/**
* 来源分析
*/
public function source(){
$config= get_addon_config('facrm');
$config['source'][0]='未知';
$alldata=$dealdata=[];
$cache_key=md5("sourcedealdataalldata");
list($alldata,$dealdata)=cache($cache_key);
if (!$alldata&&!$dealdata) {
foreach ($config['source'] as $k=>$v){
$r['name']=$v;
$r['value']= $this->model->where('source',$k)->count();
$alldata[]=$r;
$f['name']=$v;
$f['value']= $this->model->where('source',$k)->where('deal_status',1)->count();;
$dealdata[]=$f;
}
cache($cache_key,array($alldata,$dealdata),86400);
}
$this->view->assign([
'source' =>$config['source'],
'alldata'=>$alldata,
'dealdata'=>$dealdata,
]);
return $this->view->fetch();
}
}