MeTrusteeshipController.php
17.3 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/12/27
* Time: 16:21
*/
namespace app\index\controller;
use app\index\model\CodeModel;
use app\index\model\CollocationModel;
use app\index\model\OrderInfoModel;
use app\index\model\OrderModel;
use app\index\model\PageHtmlModel;
use app\index\model\QuestionModel;
use app\index\model\SubjoinInsuranceModel;
use app\index\model\UserModel;
use app\index\server\IndexServer;
use cmf\controller\WeChatBaseController;
class MeTrusteeshipController extends WeChatBaseController
{
//授权
function _initialize()
{
//判断用户是否微信浏览器打开
$this->isWechat();
//判断是否手机端
$this->isMobile();
//微信授权
parent::_initialize();
$this->checkWeChatUserLogin();
//阻止拉黑用户
$this->ban();
}
//进入我的托管页面
public function index(){
$result1 = $this->isRegister();
if(empty($result1)){
//重定向到注册页面
$this->redirect('user_register_mobile/index');
}
$result2 = $this->isQuestion();
if(empty($result2)){
//重定向到问卷调查
$this->redirect('question/index');
}
$user_id = cmf_get_current_user_id();
$userModel = new UserModel();
$user = $userModel->findUserData(array('id'=>$user_id));
$collocationModel = new CollocationModel();
$no_collocation_count = $collocationModel->collocationCount(array('user_id'=>$user_id));//保单总数
$no_people_count = $collocationModel->peopleCount(array('user_id'=>$user_id));//被保人数
$no_main_total_sum = $collocationModel->totalSum(array('user_id'=>$user_id));//本年保险支出(主险)
$subjoinInsuranceModel = new SubjoinInsuranceModel();
$no_vice_total_sum = $subjoinInsuranceModel->subjoinSum(array('s.user_id'=>$user_id));//本年保险支出(附加险)
//已托管的保单信息
$orderInfoModel = new OrderInfoModel();
$yes_collocation_count = $orderInfoModel->collocationCount(array('c.user_id'=>$user_id));//托管中状态的保单份数
$yes_people_count = $orderInfoModel->peopleCount(array('c.user_id'=>$user_id));//托管中状态的被保人数
$yes_main_total_sum = $orderInfoModel->totalSum(array('c.user_id'=>$user_id));//托管中状态的本年保险支出(主险)
$yes_vice_total_sum = $orderInfoModel->subjoinSum(array('c.user_id'=>$user_id));//托管中状态的本年保险支出(附加险)
$insurer = $collocationModel->insurerData(array('user_id'=>$user_id),"insurer");//获取全部保险人
$collocation = $orderInfoModel->selectData1(array('c.user_id'=>$user_id));//获取到在托管中状态的保单
//获取第一个保险人的默认信息
$insurer_one = !empty($insurer[0]['insurer']) ? $insurer[0]['insurer'] : '';
$time = time();
// $whereor1 = "o.status = 1 and c.expire_time > $time and c.user_id = $user_id and o.delete_time = 0 and c.insurer = '$insurer_one' and c.insurance_type_id = 1";
// $whereor2 = "o.status = 1 and c.expire_time > $time and c.user_id = $user_id and o.delete_time = 0 and c.insurer = '$insurer_one' and c.insurance_type_id = 2";
// $whereor3 = "o.status = 1 and c.expire_time > $time and c.user_id = $user_id and o.delete_time = 0 and c.insurer = '$insurer_one' and c.insurance_type_id = 3";
// $whereor4 = "o.status = 1 and c.expire_time > $time and c.user_id = $user_id and o.delete_time = 0 and c.insurer = '$insurer_one' and c.insurance_type_id = 4";
// $whereor5 = "o.status = 1 and c.expire_time > $time and c.user_id = $user_id and o.delete_time = 0 and c.insurer = '$insurer_one' and c.insurance_type_id = 5";
// $whereor6 = "o.status = 1 and c.expire_time > $time and c.user_id = $user_id and o.delete_time = 0 and c.insurer = '$insurer_one' and c.insurance_type_id = 6";
$one_collocation_data_one = $orderInfoModel->selectData(
array(
'c.user_id'=>$user_id,
'c.insurer'=>$insurer_one,
'c.insurance_type_id'=>1
)
// $whereor1
);//获取第一个人的主保单类型信息$where1['o.order_expire_time'] = ['>',time()];
$one_collocation_data_two = $orderInfoModel->selectData(
array(
'c.user_id'=>$user_id,
'c.insurer'=>$insurer_one,
'c.insurance_type_id'=>2
)
// $whereor2
);
$one_collocation_data_three = $orderInfoModel->selectData(
array(
'c.user_id'=>$user_id,
'c.insurer'=>$insurer_one,
'c.insurance_type_id'=>3
)
// $whereor3
);
$one_collocation_data_four = $orderInfoModel->selectData(
array(
'c.user_id'=>$user_id,
'c.insurer'=>$insurer_one,
'c.insurance_type_id'=>4
)
// $whereor4
);
$one_collocation_data_five = $orderInfoModel->selectData(
array(
'c.user_id'=>$user_id,
'c.insurer'=>$insurer_one,
'c.insurance_type_id'=>5
)
// $whereor5
);
$one_collocation_data_six = $orderInfoModel->selectData(
array(
'c.user_id'=>$user_id,
'c.insurer'=>$insurer_one,
'c.insurance_type_id'=>6
)
// $whereor6
);
// $subjoin_whereor1 = "o.status = 1 and c.expire_time > $time and s_i.user_id = $user_id and o.delete_time = 0 and c.insurer = '$insurer_one' and s_i.insurance_type_id = 1";
// $subjoin_whereor2 = "o.status = 1 and c.expire_time > $time and s_i.user_id = $user_id and o.delete_time = 0 and c.insurer = '$insurer_one' and s_i.insurance_type_id = 2";
// $subjoin_whereor3 = "o.status = 1 and c.expire_time > $time and s_i.user_id = $user_id and o.delete_time = 0 and c.insurer = '$insurer_one' and s_i.insurance_type_id = 3";
// $subjoin_whereor4 = "o.status = 1 and c.expire_time > $time and s_i.user_id = $user_id and o.delete_time = 0 and c.insurer = '$insurer_one' and s_i.insurance_type_id = 4";
// $subjoin_whereor5 = "o.status = 1 and c.expire_time > $time and s_i.user_id = $user_id and o.delete_time = 0 and c.insurer = '$insurer_one' and s_i.insurance_type_id = 5";
// $subjoin_whereor6 = "o.status = 1 and c.expire_time > $time and s_i.user_id = $user_id and o.delete_time = 0 and c.insurer = '$insurer_one' and s_i.insurance_type_id = 6";
$one_subjoin_data_one = $subjoinInsuranceModel->selectData(
array(
's_i.user_id'=>$user_id,
'c.insurer'=>$insurer_one,
's_i.insurance_type_id'=>1,
)
// $subjoin_whereor1
);//获取第一个人的附加保单类型信息
$one_subjoin_data_two = $subjoinInsuranceModel->selectData(
array(
's_i.user_id'=>$user_id,
'c.insurer'=>$insurer_one,
's_i.insurance_type_id'=>2
)
// $subjoin_whereor2
);
$one_subjoin_data_three = $subjoinInsuranceModel->selectData(
array(
's_i.user_id'=>$user_id,
'c.insurer'=>$insurer_one,
's_i.insurance_type_id'=>3
)
// $subjoin_whereor3
);
$one_subjoin_data_four = $subjoinInsuranceModel->selectData(
array(
's_i.user_id'=>$user_id,
'c.insurer'=>$insurer_one,
's_i.insurance_type_id'=>4
)
// $subjoin_whereor4
);
$one_subjoin_data_five = $subjoinInsuranceModel->selectData(
array(
's_i.user_id'=>$user_id,
'c.insurer'=>$insurer_one,
's_i.insurance_type_id'=>5
)
// $subjoin_whereor5
);
$one_subjoin_data_six = $subjoinInsuranceModel->selectData(
array(
's_i.user_id'=>$user_id,
'c.insurer'=>$insurer_one,
's_i.insurance_type_id'=>6
)
// $subjoin_whereor6
);
$data_one = array_merge($one_collocation_data_one,$one_subjoin_data_one);
$data_one = $this->regroup($data_one,1);
$data_two = array_merge($one_collocation_data_two,$one_subjoin_data_two);
$data_two = $this->regroup($data_two,2);
$data_three = array_merge($one_collocation_data_three,$one_subjoin_data_three);
$data_three = $this->regroup($data_three,3);
$data_four = array_merge($one_collocation_data_four,$one_subjoin_data_four);
$data_four = $this->regroup($data_four,4);
$data_five = array_merge($one_collocation_data_five,$one_subjoin_data_five);
$data_five = $this->regroup($data_five,5);
$data_six = array_merge($one_collocation_data_six,$one_subjoin_data_six);
$data_six = $this->regroup($data_six,6);
$pageHtmlModel = new PageHtmlModel();
$page_html = $pageHtmlModel->findData(array('id'=>4));
$this->assign(
array(
'title'=>"我的托管",
'user' => $user,
'no_collocation_count' => $no_collocation_count,
'no_people_count' => $no_people_count,
'no_total_sum' => $no_main_total_sum+$no_vice_total_sum,
'yes_collocation_count' => $yes_collocation_count,
'yes_people_count' => $yes_people_count,
'yes_total_sum' => $yes_main_total_sum+$yes_vice_total_sum,
'insurer' => $insurer,
'data_one' => $data_one,
'data_two' => $data_two,
'data_three' => $data_three,
'data_four' => $data_four,
'data_five' => $data_five,
'data_six' => $data_six,
'one_collocation_data_six' => $one_collocation_data_six,
'one_subjoin_data_one' => $one_subjoin_data_one,
'one_subjoin_data_two' => $one_subjoin_data_two,
'one_subjoin_data_three' => $one_subjoin_data_three,
'one_subjoin_data_four' => $one_subjoin_data_four,
'one_subjoin_data_five' => $one_subjoin_data_five,
'one_subjoin_data_six' => $one_subjoin_data_six,
'page_html' => $page_html,
)
);
return $this->fetch();
// dump($no_collocation_count);
// dump($no_people_count);
// dump($no_main_total_sum+$no_vice_total_sum);
// dump($yes_collocation_count);
// dump($yes_people_count);
// dump($yes_main_total_sum+$yes_vice_total_sum);
// dump($insurer);
// dump($collocation);
// dump($one_collocation_data);
}
//箭头
public function arrows(){
$user_id = cmf_get_current_user_id();
$param = $this->request->param();
//获取当前用户的问卷调查
$questionModel = new QuestionModel();
$question = $questionModel->findData(array('user_id'=>$user_id));
if(empty($question)){
$arr['code'] = 40001;
$arr['msg'] = "问卷调查未填写!";
return json_encode($arr);
}
//获取填写验证码时输入的姓名
$userModel = new UserModel();
$user = $userModel->findUserData(array('id'=>$user_id));
if(empty($user)){
$arr['code'] = 40002;
$arr['msg'] = "未注册手机号!";
return json_encode($arr);
}
$subjoinInsuranceModel = new SubjoinInsuranceModel();
$orderInfoModel = new OrderInfoModel();
$collocation_data = $orderInfoModel->selectData(
array(
'c.user_id'=>$user_id,
'c.insurer'=>$param['insurer'],
'c.insurance_type_id'=>$param['insurance_type_id']
)
);
$subjoin_data_one = $subjoinInsuranceModel->selectData(array('s_i.insurance_type_id'=>$param['insurance_type_id'],'s_i.user_id'=>$user_id,'c.insurer'=>$param['insurer']));
$data = array_merge($collocation_data,$subjoin_data_one);
$data = $this->regroup($data,$param['insurance_type_id'],$question,$user);
$arr['code'] = 20000;
$arr['msg'] = '获取成功!';
$arr['data'] = $data;
return json_encode($arr);
}
//切换被保人
public function select_insurer(){
$user_id = cmf_get_current_user_id();
$insurer = $this->request->param('insurer');
//获取当前用户的问卷调查
$questionModel = new QuestionModel();
$question = $questionModel->findData(array('user_id'=>$user_id));
if(empty($question)){
$arr['code'] = 40001;
$arr['msg'] = "问卷调查未填写!";
return json_encode($arr);
}
//获取填写验证码时输入的姓名
$userModel = new UserModel();
$user = $userModel->findUserData(array('id'=>$user_id));
if(empty($user)){
$arr['code'] = 40002;
$arr['msg'] = "未注册手机号!";
return json_encode($arr);
}
// $orderInfoModel = new OrderInfoModel();
// $insurance = $orderInfoModel->selectData(array('c.user_id'=>$user_id,'c.insurer'=>$insurer));
// $subjoinInsuranceModel = new SubjoinInsuranceModel();
// $subjoin = $subjoinInsuranceModel->selectData(array('s_i.user_id'=>$user_id,'c.insurer'=>$insurer));
// $indexServer = new IndexServer();
// $data = $indexServer->main_arrows($insurance,$subjoin,$question,$user);
$subjoinInsuranceModel = new SubjoinInsuranceModel();
$orderInfoModel = new OrderInfoModel();
$collocation_data_one = $orderInfoModel->selectData(array('c.user_id'=>$user_id,'c.insurer'=>$insurer,'c.insurance_type_id'=>1));
$collocation_data_two = $orderInfoModel->selectData(array('c.user_id'=>$user_id,'c.insurer'=>$insurer,'c.insurance_type_id'=>2));
$collocation_data_three = $orderInfoModel->selectData(array('c.user_id'=>$user_id,'c.insurer'=>$insurer,'c.insurance_type_id'=>3));
$collocation_data_four = $orderInfoModel->selectData(array('c.user_id'=>$user_id,'c.insurer'=>$insurer,'c.insurance_type_id'=>4));
$collocation_data_five = $orderInfoModel->selectData(array('c.user_id'=>$user_id,'c.insurer'=>$insurer,'c.insurance_type_id'=>5));
$collocation_data_six = $orderInfoModel->selectData(array('c.user_id'=>$user_id,'c.insurer'=>$insurer,'c.insurance_type_id'=>6));
$subjoin_data_one = $subjoinInsuranceModel->selectData(array('s_i.user_id'=>$user_id,'c.insurer'=>$insurer,'s_i.insurance_type_id'=>1));
$subjoin_data_two = $subjoinInsuranceModel->selectData(array('s_i.user_id'=>$user_id,'c.insurer'=>$insurer,'s_i.insurance_type_id'=>2));
$subjoin_data_three = $subjoinInsuranceModel->selectData(array('s_i.user_id'=>$user_id,'c.insurer'=>$insurer,'s_i.insurance_type_id'=>3));
$subjoin_data_four = $subjoinInsuranceModel->selectData(array('s_i.user_id'=>$user_id,'c.insurer'=>$insurer,'s_i.insurance_type_id'=>4));
$subjoin_data_five = $subjoinInsuranceModel->selectData(array('s_i.user_id'=>$user_id,'c.insurer'=>$insurer,'s_i.insurance_type_id'=>5));
$subjoin_data_six = $subjoinInsuranceModel->selectData(array('s_i.user_id'=>$user_id,'c.insurer'=>$insurer,'s_i.insurance_type_id'=>6));
$data_one = array_merge($collocation_data_one,$subjoin_data_one);
$data_one = $this->regroup($data_one,1);
$data_two = array_merge($collocation_data_two,$subjoin_data_two);
$data_two = $this->regroup($data_two,2);
$data_three = array_merge($collocation_data_three,$subjoin_data_three);
$data_three = $this->regroup($data_three,3);
$data_four = array_merge($collocation_data_four,$subjoin_data_four);
$data_four = $this->regroup($data_four,4);
$data_five = array_merge($collocation_data_five,$subjoin_data_five);
$data_five = $this->regroup($data_five,5);
$data_six = array_merge($collocation_data_six,$subjoin_data_six);
$data_six = $this->regroup($data_six,6);
$data['data_one'] = $data_one;
$data['data_two'] = $data_two;
$data['data_three'] = $data_three;
$data['data_four'] = $data_four;
$data['data_five'] = $data_five;
$data['data_six'] = $data_six;
$arr['code'] = 20000;
$arr['msg'] = '获取成功!';
$arr['data'] = $data;
return json_encode($arr);
}
public function regroup2($data){
$arr = [];
$result = [];
foreach($data as $key => $vo){
$result1 = [];
$result2 = [];
foreach($vo as $k=>$v){
$result1[] = $v['subjoin_price'];
if($v['order_expire_time'] > time()){
$result2[] = $v['subjoin_price'];
}
}
$arr['name'] = $key;
$arr['sum'] = array_sum($result2);
if(empty($result1)){//未有保单
$arr['type'] = 1;
}else if(empty($result2)){//保障缺失
$arr['type'] = 2;
}else{
$arr['type'] = 3;
}
$result[] = $arr;
}
return $result;
}
}