kongdeqiang
2023-06-08 d0c8bb3267a8a666b9a7ad1ae406c88b2fceff58
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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
package com.boying.controller.phone;
 
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.boying.common.BaseController;
import com.boying.common.R;
import com.boying.common.ReturnData;
import com.boying.common.SystemConfigProperties;
import com.boying.entity.*;
import com.boying.service.*;
import com.boying.util.HTTPEntityUtil;
import com.google.gson.Gson;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.util.DigestUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
 
 
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.UnsupportedEncodingException;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
 
import static com.boying.util.MyX509TrustManager.httpsRequest;
 
/**
 * @author kdq
 * @version 1.0.0
 * @ClassName PayController.java
 * @Description TODO
 * @createTime 2022年11月22日 15:19:00
 */
@RestController
@RequestMapping("ffzf/ffPay")
@RequiredArgsConstructor
public class PayController extends BaseController {
 
    private final OrderRecordService orderRecordService;
    private final TicketService ticketService;
    private final TicketBlackService ticketBlackService;
    private final OutParkService outParkService;
    private final SystemConfigProperties systemConfigProperties;
    private final ParkService parkService;
    private final WhiteListService whiteListService;
 
    static String payKey = "df937eda27cb4a59a12347966678e232";
    static String paySecret = "9e3b2f387b5b4232a9c782affc9c36ed";
    static String payerTypeCode = "1304062100000001";
    static String payerTypeCode2 = "1304062100000002";
    static String ip = "https://pay.hebcz.cn";
    static String ip2 = "http://nontax.hebcz.cn";
 
 
    //生成电子缴款码
    @PostMapping("zhiFa")
    public Object zhiFa(Long id){
        Ticket ticket = ticketService.getById(id);
        if(ticket.getPayStatus()==1){
            return error("此罚单已支付");
        }
        if(ticket.getStatus()==3){
            return error("此罚单已撤销");
        }
        StringBuffer sbf = new StringBuffer();
        StringBuffer s = new StringBuffer();
        if(ticket.getMoney()==0){
            s.append("amt=0.01");
        }else{
            DecimalFormat df = new DecimalFormat("#0.00");
            s.append("amt="+df.format(ticket.getMoney()).toString());
        }
        s.append("&notifyUrl="+systemConfigProperties.getIp()+"ffPay/result");
        s.append("&payKey=df937eda27cb4a59a12347966678e232");
        s.append("&payerName="+ticket.getCarNo());
        s.append("&payerNum="+ticket.getCode());
        s.append("&payerTypeCode=1304062100000001");
        s.append("&reserve1=");
        s.append("&reserve2=");
        s.append("&reserve3=");
        s.append("&returnUrl=");
        sbf.append(s.toString());
        s.append("&paySecret=9e3b2f387b5b4232a9c782affc9c36ed");
 
        String encode = null;
        try {
            encode = DigestUtils.md5DigestAsHex(s.toString().getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        sbf.append("&sign="+encode);
        sbf.append("&signType=MD5");
        System.out.println(sbf.toString());
        String s1 = httpsRequest(ip + "/pay/inpay", "POST", sbf.toString());
        System.out.println(s1);
        if(s1.equals("error")){
            return error("生成电子缴款码失败,请联系管理员");
        }
        JSONObject jsonObject = JSON.parseObject(s1);
        String payCode = "";
        if(jsonObject.get("payCode")==null){
            String eInfo = jsonObject.get("errorInfo").toString();
            if(eInfo.equals("此订单已过期")){
                ticket.setCode(System.currentTimeMillis()+"");
                String payCode2 = zhiFa2(ticket);
                ticket.setPayCode(payCode2);
                ticketService.save(ticket);
                addOrderRecord2(ticket);
                return success("生成执法电子缴款码","https://hbfs.govpay.ccb.com/online/fssm?fee=130000000001&PyfScnCgycd=01&pyfTpcd=3&BNo="+payCode);
            }
            return error(jsonObject.get("errorInfo").toString());
        }
        payCode = jsonObject.get("payCode").toString();
        ticket.setPayCode(payCode);
        ticketService.save(ticket);
 
        addOrderRecord2(ticket);
        return success("生成执法电子缴款码","https://hbfs.govpay.ccb.com/online/fssm?fee=130000000001&PyfScnCgycd=01&pyfTpcd=3&BNo="+payCode);
    }
 
    public String zhiFa2(Ticket ticket){
        StringBuffer sbf = new StringBuffer();
        StringBuffer s = new StringBuffer();
        if(ticket.getMoney()==0){
            s.append("amt=0.01");
        }else{
            DecimalFormat df = new DecimalFormat("#0.00");
            s.append("amt="+df.format(ticket.getMoney()).toString());
        }
        s.append("&notifyUrl="+systemConfigProperties.getIp()+"ffPay/result");
        s.append("&payKey=df937eda27cb4a59a12347966678e232");
        s.append("&payerName="+ticket.getCarNo());
        s.append("&payerNum="+ticket.getCode());
        s.append("&payerTypeCode=1304062100000001");
        s.append("&reserve1=");
        s.append("&reserve2=");
        s.append("&reserve3=");
        s.append("&returnUrl=");
        sbf.append(s.toString());
        s.append("&paySecret=9e3b2f387b5b4232a9c782affc9c36ed");
 
        String encode = null;
        try {
            encode = DigestUtils.md5DigestAsHex(s.toString().getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        sbf.append("&sign="+encode);
        sbf.append("&signType=MD5");
        String s1 = httpsRequest(ip + "/pay/inpay", "POST", sbf.toString());
        JSONObject jsonObject = JSON.parseObject(s1);
        String payCode = jsonObject.get("payCode").toString();
        return payCode;
    }
 
    //支付接口通知
    @PostMapping("result")
    public String result(HttpServletRequest request, String payKey, String payerTypeCode, String payerNum, String payCode, Double amt, String status, String errorInfo, String sign, String signType) throws Exception{
        try {
           // updateOrderRecord(payCode,status);
        }catch (Exception e){
         e.printStackTrace();
        }
        return "success";
    }
 
    //生成电子缴款码
    @PostMapping("park2")
    public Object park2(Long id){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
        String logs = sdf.format(new Date())+"开始扫码缴费------》\n";
        logs += "出场表id为:"+id+",\n";
        OutPark outPark =  outParkService.getById(id);
        if(outPark.getPrice()==0){
            updateOutPark(outPark.getId(),"03");
            logs += "支付金额为0,\n";
            writeTxt(logs);
            return error("本次停车无需支付费用");
        }
 
        //判断是否在白名单
        QueryWrapper<WhiteList> wrapper = new QueryWrapper<>();
        wrapper.lambda()
                .eq(WhiteList::getCarNo,outPark.getCarNo());
        List<WhiteList> all = whiteListService.list(wrapper);
        for(WhiteList w : all){
            if(w.getType()==0){
                logs+=outPark.getCarNo()+"在白名单,\n";
                updateOutPark(outPark.getId(),"03");
                writeTxt(logs);
                return error("本次停车无需支付费用!");
            }else{
                if(w.getParkId()!=null){
                    if(w.getEndTime()!=null){
                        if(w.getParkId().equals(outPark.getParkId())&&System.currentTimeMillis()<w.getEndTime().getTime()){
                            logs+=outPark.getCarNo()+"在特殊规则白名单,\n";
                            updateOutPark(outPark.getId(),"03");
                            writeTxt(logs);
                            return error("本次停车无需支付费用!");
                        }
                    }
                }
            }
        }
 
        StringBuffer sbf = new StringBuffer();
        StringBuffer s = new StringBuffer();
        DecimalFormat df = new DecimalFormat("#0.00");
        s.append("amt="+df.format(outPark.getPrice()).toString());
        s.append("&notifyUrl="+systemConfigProperties.getIp()+"ffPay/result");//回调的url
        s.append("&payKey=df937eda27cb4a59a12347966678e232");//财政给的
        s.append("&payerName="+outPark.getCarNo());
        s.append("&payerNum="+ outPark.getCode());//订单号
        //s.append("&payerTypeCode=1304062100000001");////财政给的
        s.append("&payerTypeCode=072101");////财政给的
        s.append("&reserve1=");
        s.append("&reserve2=");
        s.append("&reserve3=");
        s.append("&returnUrl=");
        sbf.append(s.toString());
        s.append("&paySecret=9e3b2f387b5b4232a9c782affc9c36ed");////财政给的
 
        String encode = null;
        try {
            encode = DigestUtils.md5DigestAsHex(s.toString().getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        sbf.append("&sign="+encode);
        sbf.append("&signType=MD5");
        String s1 = httpsRequest(ip+"/pay/inpay","POST",sbf.toString());
        if(s1.equals("error")){
            logs += "生成执法电子缴款码失败,请联系管理员,\n";
            writeTxt(logs);
            return error("生成执法电子缴款码失败,请联系管理员");
        }
        JSONObject jsonObject = JSON.parseObject(s1);
        if(jsonObject.get("payCode")==null){
            String eInfo = jsonObject.get("errorInfo").toString();
            if(eInfo.equals("此订单已过期")){
                outPark.setCode(System.currentTimeMillis()+"");
                outParkService.save(outPark);
                logs += "此订单已过期,\n";
                writeTxt(logs);
                return park(id);
            }else{
                logs += "此订单有异常错误,\n";
                writeTxt(logs);
                return error(eInfo);
            }
        }else{
            String payCode = jsonObject.get("payCode").toString();
            logs += "payCode: "+payCode+",\n";
            outPark.setPayCode(payCode);
            outParkService.save(outPark);
            writeTxt(logs);
            addOrderRecord(outPark);
            return success("生成停车电子缴款码","https://hbfs.govpay.ccb.com/online/fssm?fee=130000000001&PyfScnCgycd=01&pyfTpcd=3&BNo="+payCode);
        }
    }
 
 
    /**
     * 缴款书
     */
    @PostMapping("park")
    public Object park(Long id){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
        String logs = sdf.format(new Date())+"开始扫码缴费------》\n";
        logs += "出场表id为:"+id+",\n";
        OutPark outPark =  outParkService.getById(id);
        if(outPark.getPrice()==0){
            updateOutPark(outPark.getId(),"03");
            logs += "支付金额为0,\n";
            writeTxt(logs);
            return R.failed("本次停车无需支付费用");
        }
 
        //判断是否在白名单
        QueryWrapper<WhiteList> wrapper = new QueryWrapper<>();
        wrapper.lambda()
                .eq(WhiteList::getCarNo,outPark.getCarNo());
        List<WhiteList> all = whiteListService.list(wrapper);
        for(WhiteList w : all){
            if(w.getType()==0){
                logs+=outPark.getCarNo()+"在白名单,\n";
                updateOutPark(outPark.getId(),"03");
                writeTxt(logs);
                return R.failed("本次停车无需支付费用!");
            }else{
                if(w.getParkId()!=null){
                    if(w.getEndTime()!=null){
                        if(w.getParkId().equals(outPark.getParkId())&&System.currentTimeMillis()<w.getEndTime().getTime()){
                            logs+=outPark.getCarNo()+"在特殊规则白名单,\n";
                            updateOutPark(outPark.getId(),"03");
                            writeTxt(logs);
                            return R.failed("本次停车无需支付费用!");
                        }
                    }
                }
            }
        }
        if(StringUtils.isNotBlank(outPark.getPayCode()) && outPark.getStatus() == 0){
            return R.ok("生成停车电子缴款码", "https://hbfs.govpay.ccb.com/online/fssm?fee=130000000001&PyfScnCgycd=01&pyfTpcd=3&BNo="+outPark.getPayCode());
        }else if(StringUtils.isNotBlank(outPark.getPayCode()) && outPark.getStatus() == 1){
            return R.failed("已缴费");
        }
        if(StringUtils.isBlank(outPark.getPayCode())){
            return R.ok("生成停车电子缴款码", getPayUrl(outPark));
        }else {
            return R.failed("出错");
        }
 
    }
 
    /**
     * 获取缴款码
     * @param outPark
     * @return
     */
    public String getPayUrl(OutPark outPark){
        String urlIP = systemConfigProperties.getIp4();
        String applyetcketnum = systemConfigProperties.getAPPLYETCKETNUM();
        //申请缴款书,唯一码为出场id+时间戳
        String idStr = outPark.getId()+"";
        String dateStr = DateUtil.currentSeconds()+"";
        String l = idStr + dateStr;
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
        String format = sdf2.format(new Date());
        List< ApplyTicket.detail> details = new ArrayList<>();
        ApplyTicket.detail detail = new ApplyTicket.detail();
        detail.setItemstandardtype("");
        detail.setAmount(1);
        detail.setAmt(outPark.getPrice());
        detail.setIncitemcode("072101");
        detail.setMeasureunit("");
        details.add(detail);
 
        ApplyTicket applyTicket = new ApplyTicket();
        applyTicket.setBusinum(l);
        applyTicket.setFilldate(format);
        applyTicket.setPayer(outPark.getCarNo());
        applyTicket.setPayeraccount("");
        applyTicket.setPayerbank("");
        applyTicket.setPayerphonenumber("18888888888");
        applyTicket.setPayee("河北省财政厅");
        applyTicket.setAmt(outPark.getPrice());
        applyTicket.setMemo("");
        applyTicket.setOverdate("");
        applyTicket.setState(1);
        applyTicket.setDetails(details);
        String jsonStr = JSON.toJSONString(applyTicket, SerializerFeature.WriteDateUseDateFormat);
        Map<String, Object> map = JSON.parseObject(jsonStr, new TypeReference<Map<String, Object>>() {});
        RestTemplate restTemplate = new RestTemplate();
        ResponseEntity<ReturnData> entity = restTemplate.postForEntity(urlIP+applyetcketnum, HTTPEntityUtil.setEntity(map), ReturnData.class);
        if(entity.getBody().getCode() == 1){
            System.out.println("支付申请缴款码返回为:"+entity.getBody());
            Object o = entity.getBody().getData().get(0);
            String s = JSON.toJSONString(o);
            Map<String,Object> map1 = (Map)JSON.parse(s);
            String payurl = (String)map1.get("payurl");
            String eticketnum = (String)map1.get("eticketnum");
            outPark.setPayCode(eticketnum);
            outPark.setCode2(l);
            outParkService.saveOrUpdate(outPark);
            addOrderRecord(outPark);
            return payurl+eticketnum;
        }else {
            return null;
        }
    }
 
 
    /**
     * 缴款书
     */
    @PostMapping("zhifa")
    public Object zhifa(Long id){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
        String logs = sdf.format(new Date())+"开始扫码缴费------》\n";
        logs += "罚单表id为:"+id+",\n";
        Ticket ticket =  ticketService.getById(id);
        if(ticket.getMoney()==0){
            updateTicket(ticket.getId(),"03");
            logs += "支付金额为0,\n";
            writeTxt(logs);
            return R.failed("本罚单无需支付费用");
        }
        if(StringUtils.isNotBlank(ticket.getPayCode()) && ticket.getStatus() == 0){
            return R.ok("生成电子罚单缴款码", "https://hbfs.govpay.ccb.com/online/fssm?fee=130000000001&PyfScnCgycd=01&pyfTpcd=3&BNo="+ticket.getPayCode());
        }else if(StringUtils.isNotBlank(ticket.getPayCode()) && ticket.getStatus() == 1){
            return R.failed("已缴费");
        }
        if(StringUtils.isBlank(ticket.getPayCode())){
            return R.ok("生成电子罚单缴款码", getPayUrl2(ticket));
        }else {
            return R.failed("出错");
        }
 
    }
 
    /**
     * 获取缴款码
     * @param ticket
     * @return
     */
    public String getPayUrl2(Ticket ticket){
        String urlIP = systemConfigProperties.getIp4();
        String applyetcketnum = systemConfigProperties.getAPPLYETCKETNUM();
        //申请缴款书,唯一码为出场id+时间戳
        String idStr = ticket.getId()+"";
        String dateStr = DateUtil.currentSeconds()+"";
        String l = idStr + dateStr;
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
        String format = sdf2.format(new Date());
        List< ApplyTicket.detail> details = new ArrayList<>();
        ApplyTicket.detail detail = new ApplyTicket.detail();
        detail.setItemstandardtype("");
        detail.setAmount(1);
        detail.setAmt(ticket.getMoney());
        detail.setIncitemcode("050114");
        detail.setMeasureunit("");
        details.add(detail);
 
        ApplyTicket applyTicket = new ApplyTicket();
        applyTicket.setBusinum(l);
        applyTicket.setFilldate(format);
        applyTicket.setPayer(ticket.getCarNo());
        applyTicket.setPayeraccount("");
        applyTicket.setPayerbank("");
        applyTicket.setPayerphonenumber("18888888888");
        applyTicket.setPayee("河北省财政厅");
        applyTicket.setAmt(ticket.getMoney());
        applyTicket.setMemo("");
        applyTicket.setOverdate("");
        applyTicket.setState(1);
        applyTicket.setDetails(details);
        String jsonStr = JSON.toJSONString(applyTicket, SerializerFeature.WriteDateUseDateFormat);
        Map<String, Object> map = JSON.parseObject(jsonStr, new TypeReference<Map<String, Object>>() {});
        RestTemplate restTemplate = new RestTemplate();
        ResponseEntity<ReturnData> entity = restTemplate.postForEntity(urlIP+applyetcketnum, HTTPEntityUtil.setEntity(map), ReturnData.class);
        if(entity.getBody().getCode() == 1){
            System.out.println("支付申请缴款码返回为:"+entity.getBody());
            Object o = entity.getBody().getData().get(0);
            String s = JSON.toJSONString(o);
            Map<String,Object> map1 = (Map)JSON.parse(s);
            String payurl = (String)map1.get("payurl");
            String eticketnum = (String)map1.get("eticketnum");
            ticket.setPayCode(eticketnum);
            ticket.setCode2(l);
            ticketService.saveOrUpdate(ticket);
            addOrderRecord2(ticket);
            return payurl+eticketnum;
        }else {
            return null;
        }
    }
 
 
 
 
 
 
    /**
         * 1.停车缴费流程:获取缴款码->生成订单->支付接口返回通知->更新订单->更新出场表
         * 2.罚单流程:    获取缴款码->生成罚单->生成订单->支付接口返回通知->更新订单->更新罚单->更新车辆
         *
         */
 
 
 
    //更新订单记录
    public void updateOrderRecord(Integer queryId,String status){
        QueryWrapper<OrderRecord> wrapper = new QueryWrapper<>();
        wrapper.lambda()
                .eq(OrderRecord::getQueryId,queryId)
                .orderByDesc(OrderRecord::getCreateTime);
        List<OrderRecord> all = orderRecordService.list(wrapper);
        if(all.size()>=1){
            OrderRecord orderRecord = all.get(0);
            if(status.equals("01")){
                orderRecord.setStatus(0);
            }
            if(status.equals("03")){
                orderRecord.setStatus(1);
                //测试环境,暂时把开票设置为2
                orderRecord.setTicketStatus(2);
            }
            if(status.equals("04")||status.equals("05")||status.equals("06")){
                orderRecord.setStatus(2);
            }
            orderRecordService.saveOrUpdate(orderRecord);
            if(orderRecord.getType()==0){
                updateTicket(orderRecord.getQueryId(),status);
            }else{
                updateOutPark(orderRecord.getQueryId(),status);
            }
        }
    }
 
    //更新罚单的状态
    public void updateTicket(Integer ticketId,String status){
        Ticket ticket = ticketService.getById(ticketId);
        if(ticket!=null){
            if(status.equals("01")){
                ticket.setPayStatus(0);
            }
            if(status.equals("03")){
                ticket.setPayStatus(1);
                dealCar(ticket.getCarNo());
            }
            if(status.equals("04")||status.equals("05")||status.equals("06")){
                ticket.setPayStatus(2);
            }
            ticketService.saveOrUpdate(ticket);
        }
    }
 
    //更新缴费状态
    private void dealCar(String carNo){
        QueryWrapper<Ticket> wrapper = new QueryWrapper<>();
        wrapper.lambda()
                .eq(Ticket::getCarNo,carNo)
                .eq(Ticket::getPayStatus,1);
        List<Ticket> tickets = ticketService.list(wrapper);
        if(tickets.size()==0){
            //更新缴费状态
            QueryWrapper<TicketBlack> wrapper1 = new QueryWrapper<>();
            wrapper1.lambda()
                    .eq(TicketBlack::getCarNo,carNo);
            List<TicketBlack> all = ticketBlackService.list(wrapper1);
            for(TicketBlack ticketBlack:all){
                ticketBlack.setStatus(1);
                ticketBlack.setBlackType(0);
                ticketBlackService.saveOrUpdate(ticketBlack);
            }
        }
    }
 
 
    public void updateOutPark(Integer outParkId, String status){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH_mm_ss");
        String s = sdf.format(new Date())+"开始修改出场表-----》\n";
        s+= "outparkId==="+outParkId+",status==="+status+",\n";
        OutPark outPark = outParkService.getById(outParkId);
        if(outPark!=null){
            s += "找到出场数据:"+outPark.getId()+",\n";
            writeTxt(s);
            if(status.equals("03")){
                s += "出场数据修改----》";
                writeTxt(s);
                outPark.setStatus(1);
                outParkService.saveOrUpdate(outPark);
            }
        }else {
            s += "未找到出场数据-----》";
            writeTxt(s);
        }
 
    }
 
 
    //插入停车订单记录
    public void addOrderRecord(OutPark outPark){
        Park park = parkService.getById(outPark.getParkId());
        OrderRecord orderRecord = new OrderRecord();
        orderRecord.setAddress(park.getName());
        orderRecord.setCarNo(outPark.getCarNo());
        orderRecord.setCode(outPark.getCode());
        orderRecord.setCode2(outPark.getCode2());
        orderRecord.setMoney(outPark.getPrice());
        orderRecord.setQueryId(outPark.getId());
        orderRecord.setType(1);
        orderRecord.setTicketStatus(0);
        orderRecord.setPayCode(outPark.getPayCode());
        orderRecordService.saveOrUpdate(orderRecord);
    }
 
    //插入执法订单记录
    public void addOrderRecord2(Ticket ticket){
        OrderRecord orderRecord = new OrderRecord();
        orderRecord.setAddress(ticket.getAddress());
        orderRecord.setCarNo(ticket.getCarNo());
        orderRecord.setCode(ticket.getCode());
        orderRecord.setCode2(ticket.getCode2());
        orderRecord.setMoney(ticket.getMoney());
        orderRecord.setQueryId(ticket.getId());
        orderRecord.setType(0);
        orderRecord.setTicketStatus(2);
        orderRecord.setPayCode(ticket.getPayCode());
        orderRecordService.saveOrUpdate(orderRecord);
    }
 
    //确认开票接口
    public void ticketIsOk(OrderRecord orderRecord){
        orderRecord.setTicketStatus(1);
        orderRecordService.saveOrUpdate(orderRecord);
    }
 
 
    private void writeTxt( String txt)
    {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        try
        {
            FileWriter f = new FileWriter(systemConfigProperties.getLogPath()+"支付日志"+sdf.format(new Date())+".txt",true);
            BufferedWriter bw=new BufferedWriter(f);
            bw.write(txt);
            bw.newLine();
            bw.close();
        }
        catch(Exception e)
        {
            System.out.println("打印错误");
        }
    }
 
 
}