Car.php
8.5 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
<?php
namespace app\products\controller;
use app\products\validate\Car as CarValidate;
use app\web\controller\BaseController;
use think\Log;
use think\Request;
use util\MCurl;
header("Content-type: text/html; charset=utf-8");
/**
* 功能描述 华安车险
* Class Car
* @package app\products\controller
* Date: 2020/8/3
* Time: 17:00
* @author nyq
*/
class Car extends BaseController
{
//请求地址
//private $api_url = "https://api.sosyun.com//serviceapi/car/";
//private $api_url = "http://demo8.xiaochakeji.com/serviceapi/car/";
private $api_url = "www.aisigit.com/products/car/";
//回调查询接口
private $api_back_url = "http://demo8.xiaochakeji.com/notify/car/";
//private $api_back_url = "https://api.sosyun.com//notify/car/";
/**
* 函数功能描述 获取订单信息
* Date: 2020/8/07
* Time: 10:00
* @author nyq
*/
public function carOrder(Request $request)
{
$data = $request->param();
$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
$offset=($page-1)*$rows;
$data['id']=2;
$data['offset']=$offset;
$data['rows']=$rows;
$res = MCurl::instance($this->api_url."carOrder")->post($data);
$json=json_decode($res);
$result["total"] =count($json);
$result['rows']=$json;
echo json_encode($result);
//return $json;
}
/**
* 函数功能描述 获取订单详情
* Date: 2020/8/07
* Time: 10:00
* @author nyq
*/
public function carOrderDetail(Request $request)
{
$data = $request->param();
$id['id']=$data['id'];
$res = MCurl::instance($this->api_url."carOrderDetail")->post($id);
$res = json_decode($res, true);
$use_res = MCurl::instance($this->api_url."selMember")->post($id);
$use_res = json_decode($use_res, true);
$status_arr = ['转人工核保','','','打回修改','拒保','','','待支付','支付成功','支付失败'];
foreach($res as $k => $v){
if($v['riskCode']=='0302'){
$res[$k]['type']='商业险';
}elseif($v['riskCode']=='0301'){
$res[$k]['type']='交强险';
}
$res[$k]['appName']=$use_res['appName'];
$res[$k]['insuredName']=$use_res['insuredName'];
$res[$k]['status_arr'] = $status_arr[$v['status']];
$res[$k]['operDate'] =date("Y-m-d H:i:s",$v['operDate']);
}
return $res;
}
/**
* 函数功能描述 搜索
* Date: 2020/8/07
* Time: 10:00
* @author nyq
*/
public function select(Request $request)
{
$data = $request->param();
$page = isset($_POST['page']) ? intval($_POST['page']) : 1;
$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
$offset=($page-1)*$rows;
$data['id']=2;
$data['offset']=$offset;
$data['rows']=$rows;
$res = MCurl::instance($this->api_url."carOrder")->post($data);
$json=json_decode($res);
$result["total"] =count($json);
$result['rows']=$json;
echo json_encode($result);
}
/**
* 函数功能描述 支付申请
* Date: 2020/8/11
* Time: 10:00
* @author nyq
*/
public function pay(Request $request)
{
$data = $request->param();
//查询订单信息及金额
$order_res = MCurl::instance($this->api_url."pay")->post($data);
$use_res = MCurl::instance($this->api_url."selMember")->post($data);
$order_json=json_decode($order_res,true);
$use_json=json_decode($use_res,true);
$json['jqAppNo']=$order_json[0]['appNo'];
$json['jqAmount']=$order_json[0]['premium']+$order_json[0]['currentTax'];
$json['jqAppName']=$use_json['appName'];
$json['syAppNo']=$order_json[1]['appNo'];
$json['syAmount']=$order_json[1]['premium'];
$json['syAppName']=$use_json['appName'];
$arr['data']=json_encode($json);
$res = MCurl::instance($this->api_url."launchPayment")->post($arr);
$res=json_decode($res, true);
return $res;
}
/**
* 函数功能描述 获取车型
* Date: 2020/8/03
* Time: 17:10
* @author nyq
*/
public function carmodel(Request $request)
{
$data = $request->param();
$validtaor = new CarValidate();
$res = $validtaor->scene("carmodel")->check($data);
if ($res === false) {
return ['errcode' => 100, 'errmsg' => $validtaor->getError()];
}
if (in_array("undefined", $data)) {
return ["errcode" => 100, "errmsg" => "提交数据存在问题"];
}
$res = MCurl::instance($this->api_url."carmodel")->post($data);
$res = json_decode($res, true);
return $res;
}
/**
* 函数功能描述 车险保费计算
* Date: 2020/8/4
* Time: 09:12
* @author nyq
*/
public function premium(Request $request)
{
$json = $request->param(); // 报错 Array to string conversion
$data = $request->param('data');
//数据特殊符号转义
$data = htmlspecialchars_decode($data);
$data = json_decode($data, true);
//处理校验数据
$arr=$this->premiumArray($data);
$validtaor = new CarValidate();
$res = $validtaor->scene("premium")->check($arr);
if ($res === false) {
return ['errcode' => 100, 'errmsg' => $validtaor->getError()];
}
if (in_array("undefined", $arr)) {
return ["errcode" => 100, "errmsg" => "提交数据存在问题"];
}
$res = MCurl::instance($this->api_url."premium")->post($json);
$res = json_decode($res, true);
return $res;
}
/**
* 函数功能描述 车险提交核保
* Date: 2020/8/03
* Time: 15:10
* @author nyq
*/
public function underwrite()
{
$json = $this->request->post();
$base = $this->request->post('data');
$base = htmlspecialchars_decode($base);
$base = json_decode($base, true);
//进行数据校验
$validtaor = new CarValidate();
$res = $validtaor->scene("underwrite")->check($base);
if ($res === false) {
return ['errcode' => 100, 'errmsg' => $validtaor->getError()];
}
$res = MCurl::instance($this->api_url."underwrite")->post($json);
$res=json_decode($res, true);
return $res;
}
/**
* 函数功能描述 支付/核保回调接口
* Date: 2020/8/4
* Time: 17:00
* @author nyq
*/
public function get_status()
{
$base = $this->request->post();
$res = MCurl::instance($this->api_back_url."get_status")->post($base);
$res=json_decode($res, true);
return $res;
}
/**
* 函数功能描述 支付申请接口
* Date: 2020/8/4
* Time: 16:30
* @author nyq
*/
public function payment()
{
$json = $this->request->post();
$base = $this->request->post('data');
$base = htmlspecialchars_decode($base);
$base=json_decode($base, true);
//进行数据校验
$validator = new CarValidate();
$res = $validator->scene("pay")->check($base);
if ($res === false) {
return ['errcode' => 100, 'errmsg' => $validator->getError()];
}
$res = MCurl::instance($this->api_url."payment")->post($json);
$res=json_decode($res, true);
return $res;
}
/**
* 函数功能描述 整理车险检验信息
* Date: 2020/7/21
* Time: 11:12
* @author nyq
*/
public function premiumArray($arr){
//车主信息
$owner=$arr['owner'];
//投保人
$applacation=$arr['applacation'];
//被保人
$insured=$arr['insured'];
//车辆信息
$vhl=$arr['vhl'];
//base
//$base=$arr['base'];
$data=array_merge($owner,$applacation,$insured,$vhl);
//险种信息
if(count($arr['riskList'])>1){
if($arr['riskList'][0]['riskCode'] != '' && $arr['riskList'][1]['riskCode'] != ''){
$data['xz']='true';
}else{
$data['xz']='';
}
}else{
$data['xz']='';
}
$data['cityCode']=$arr['cityCode'];
$data['modelName']=$arr['modelName'];
$data['email']=$arr['email'];
return $data;
}
}