MeTrusteeshipController.php
5.9 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
<?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\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();
//微信授权
parent::_initialize();
$this->checkWeChatUserLogin();
//阻止拉黑用户
$this->ban();
}
//进入我的托管页面
public function index(){
$result1 = $this->isRegister();
if($result1['code'] == 40030){
//重定向到注册页面
$this->redirect('user_register_mobile/index');
}
$result2 = $this->isQuestion();
if($result2['code'] == 40031){
//重定向到问卷调查
$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->selectData(array('c.user_id'=>$user_id));//获取到在托管中状态的保单
//获取第一个保险人的默认信息
$one_collocation_data = $orderInfoModel->selectData(array('c.user_id'=>$user_id,'c.insurer'=>$collocation[0]['insurer']));//获取第一个人的保单类型信息
$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,
'one_collocation_data' => $one_collocation_data,
)
);
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);
}
$orderInfoModel = new OrderInfoModel();
// $where1 = array('c.user_id'=>$user_id,'c.insurance_type_id'=>$param['insurance_type_id'],'c.insurer'=>$param['insurer']);
$where2 = array('insurance_type_id'=>$param['insurance_type_id'],'user_id'=>$user_id,'insurer'=>$param['insurer']);
$subjoin = $orderInfoModel->selectData1($where2);//获取到当前类型的附加保单
$orderModel = new OrderModel();
$insurance = $orderModel->selectData($where2);//获取到当前类型的主保单
$indexServer = new IndexServer();
$data = $indexServer->main_arrows($insurance,$subjoin,$question,$user);
dump($data);
exit();
$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');
$orderInfoModel = new OrderInfoModel();
$data = $orderInfoModel->selectData(array('c.user_id'=>$user_id,'c.insurer'=>$insurer));
$arr['code'] = 20000;
$arr['msg'] = '获取成功!';
$arr['data'] = $data;
return json_encode($arr);
}
}