AgentController.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
138
139
140
141
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2019/1/4
* Time: 11:01
*/
namespace app\index\controller;
use app\index\model\CollocationModel;
use app\index\model\OrderInfoModel;
use app\index\model\SubjoinInsuranceModel;
use app\index\model\UserModel;
use cmf\controller\WeChatBaseController;
use EasyWeChat\Foundation\Application;
class AgentController extends WeChatBaseController
{
//授权
function _initialize()
{
//判断用户是否微信浏览器打开
$this->isWechat();
//判断是否手机端
$this->isMobile();
//微信授权
parent::_initialize();
$this->checkWeChatUserLogin();
//阻止拉黑用户
$this->ban();
}
public function index(){
$user = $this->isAgent();
$collocationModel = new CollocationModel();
//共有多少保单
$no_collocation_count = $collocationModel->collocationCount(array('agent_phone'=>$user['mobile2']));
//查询所有保险人
$data = $collocationModel->insurerData(array('agent_phone'=>$user['mobile2']),'application');
$this->assign(
array(
'user'=>$user,
'no_collocation_count'=>$no_collocation_count,
'data'=>$data,
)
);
return $this->fetch();
}
//搜索
public function search(){
$keyword = $this->request->param('keyword',0);
$user = $this->isAgent();
$collocationModel = new CollocationModel();
$where['agent_phone'] = ['eq',$user['mobile2']];
$where['insurance_num|application|insurer'] = ['like',"%$keyword%"];
$data = $collocationModel->insurerData($where,'application');
$arr['code'] = 20000;
$arr['msg'] = '获取成功!';
$arr['data'] = $data;
return json_encode($arr);
}
public function more(){
$application = $this->request->param('application',0);
$user = $this->isAgent();
$collocationModel = new CollocationModel();
$no_collocation_count = $collocationModel->collocationCount(array('application'=>$application,'agent_phone'=>$user['mobile2']));//保单总数
$no_people_count = $collocationModel->peopleCount(array('application'=>$application,'agent_phone'=>$user['mobile2']));//被保人数
$no_main_total_sum = $collocationModel->totalSum(array('application'=>$application,'agent_phone'=>$user['mobile2']));//本年保险支出(主险)
$subjoinInsuranceModel = new SubjoinInsuranceModel();
$no_vice_total_sum = $subjoinInsuranceModel->subjoinSum(array('c.application'=>$application,'c.agent_phone'=>$user['mobile2']));//本年保险支出(附加险)
$insurer = $collocationModel->insurerData(array('application'=>$application,'agent_phone'=>$user['mobile2']),'insurer');
$orderInfoModel = new OrderInfoModel();
$collocation_data = $orderInfoModel->selectData1(array('c.application'=>$application,'c.insurer'=>$insurer[0]['insurer'],'c.agent_phone'=>$user['mobile2']));
$this->assign(
array(
'no_collocation_count' => $no_collocation_count,
'no_people_count' => $no_people_count,
'no_total_sum' => $no_main_total_sum+$no_vice_total_sum,
'application'=>$application,
'insurer'=>$insurer,
'collocation_data' => $collocation_data,
'agent_phone'=>$user['mobile2'],
)
);
return $this->fetch();
}
//进入保单信息页面
public function application_information(){
$param = $this->request->param();
$user_id = cmf_get_current_user_id();
$this->isAgent();
$collocationModel = new CollocationModel();
//获取全部的被保人
$insurer = $collocationModel->insurerData(array('application'=>$param['application']),"insurer");
//获取保单总数
$collocation_count = $collocationModel->collocationCount(array('application'=>$param['application']));
//获取本年保险支出
$no_main_total_sum = $collocationModel->totalSum(array('application'=>$param['application']));//本年保险支出(主险)
$subjoinInsuranceModel = new SubjoinInsuranceModel();
$no_vice_total_sum = $subjoinInsuranceModel->subjoinSum(array('application'=>$param['application']));//本年保险支出(附加险)
$total_sum = $no_main_total_sum+$no_vice_total_sum;
//获取默认显示保单信息
$orderInfoModel = new OrderInfoModel();
$collocation = $orderInfoModel->selectData(array('c.application'=>$param['application']));
dump($insurer);
dump($collocation_count);
dump($total_sum);
dump($collocation);
}
public function guarantee_info(){
$options = [
'app_id' => config('wechat_config.app_id'),
'secret' => config('wechat_config.secret'),
'payment' => config('wechat_config.payment'),
];
$app = new Application($options);
$js = $app->js;
$jssdk = $js->config(['chooseImage', 'uploadImage', 'previewImage'], $debug = false, $beta = false, $json = true);
$id = $this->request->param('id');
$orderInfoModel = new OrderInfoModel();
$data = $orderInfoModel->findData(array('o.id'=>$id));
$subjoinInsuranceModel = new SubjoinInsuranceModel();
$subjoin = $subjoinInsuranceModel->findData(array('collocation_id'=>$data['id']));
$this->assign(
array(
'data'=>$data,
'subjoin'=>$subjoin,
'jssdk'=>$jssdk,
)
);
return $this->fetch();
}
//获取当前代理人的手机号
public function get_agent_mobile(){
$user_id = cmf_get_current_user_id();
$userModel = new UserModel();
$user = $userModel->findUserData(array('id'=>$user_id));
return $user['mobile2'];
}
}