InvoiceHelperServiceImpl.java
100 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
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
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
//package com.zteits.pay.biz;
//
//import cn.hutool.core.date.DateUtil;
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import com.clouds.common.cache.pay.AppOrgCacheUtil;
//import com.clouds.common.constants.InvoiceServiceTypeEnum;
//import com.clouds.common.utils.*;
//import com.clouds.common.web.SpringContextUtil;
//import com.ejinshui.service.ZKInvoiceService;
//import com.github.pagehelper.PageInfo;
//import com.xiaoleilu.hutool.util.CollectionUtil;
//import com.zteits.clouds.api.apibase.bean.BizResult;
//import com.zteits.clouds.api.apibase.bean.PageBean;
//import com.zteits.clouds.api.apibase.constants.*;
//import com.zteits.clouds.api.apibase.exception.AppException;
//import com.zteits.clouds.api.apibase.exception.BizException;
//import com.zteits.clouds.api.dto.order.backorder.dto.OrderBackDTO;
//import com.zteits.clouds.api.dto.order.backorder.param.BackOrderPageQueryByContidionReq;
//import com.zteits.clouds.api.dto.order.backorder.param.UpdateOrderBackByOrderIdRequest;
//import com.zteits.clouds.api.dto.order.parkorder.dto.OrderParkQueryDTO;
//import com.zteits.clouds.api.dto.order.parkorder.param.OrderParkQueryReq;
//import com.zteits.clouds.api.dto.order.parkorder.param.UpdateOrderParkByOrderIdRequest;
//import com.zteits.clouds.api.dto.order.payorder.dto.PayOrderForInvoiceDTO;
//import com.zteits.clouds.api.dto.order.payorder.param.QueryPayOrderListsReq;
//import com.zteits.clouds.api.dto.order.rechargeorder.dto.OrderRechargeDTO;
//import com.zteits.clouds.api.dto.order.rechargeorder.param.OrderRechargeQueryReq;
//import com.zteits.clouds.api.dto.order.rechargeorder.param.OrderRechargeUpdateRequest;
//import com.zteits.clouds.api.dto.order.vipcardorder.dto.OrderVipcardDetailDTO;
//import com.zteits.clouds.api.dto.order.vipcardorder.param.QueryInvoiceStateByDetailOrderIdReqest;
//import com.zteits.clouds.api.dto.order.vipcardorder.param.QueryVipcardDetailsReq;
//import com.zteits.clouds.api.dto.order.vipcardorder.param.UpdateVipcardDetailReq;
//import com.zteits.clouds.api.dto.pay.*;
//import com.zteits.clouds.api.dto.pay.dto.TdCCustInvoiceMailDTO;
//import com.zteits.clouds.api.dto.pay.dto.TdCCustInvoiceSaleDTO;
//import com.zteits.clouds.api.dto.pay.param.*;
//import com.zteits.clouds.api.dto.pay.param.einvoice.DownloadReturnMsg;
//import com.zteits.clouds.api.dto.pay.param.einvoice.InvoInfo;
//import com.zteits.clouds.api.dto.pay.param.einvoice.InvoInfo.Items;
//import com.zteits.clouds.api.dto.pay.param.einvoice.InvoInfo.Order;
//import com.zteits.clouds.api.dto.pay.param.einvoice.InvoInfo.Orders;
//import com.zteits.clouds.api.dto.pay.param.einvoice.InvoInfo.item;
//import com.zteits.clouds.api.dto.pay.param.einvoice.ReturnMsg;
//import com.zteits.clouds.api.dto.pay.param.einvoice.SYFPReturnMsg;
//import com.zteits.clouds.api.service.order.backorder.oper.BackParkOrderOperService;
//import com.zteits.clouds.api.service.order.backorder.query.BackOrderQueryService;
//import com.zteits.clouds.api.service.order.parkorder.oper.RNTParkOrderOperService;
//import com.zteits.clouds.api.service.order.parkorder.query.PubParkOrderQueryService;
//import com.zteits.clouds.api.service.order.payorder.query.PayOrderQueryService;
//import com.zteits.clouds.api.service.order.rechargeorder.oper.RechargeOrderOperService;
//import com.zteits.clouds.api.service.order.rechargeorder.query.RechargeOrderQueryService;
//import com.zteits.clouds.api.service.order.vipcardorder.oper.VipCardOrderOperService;
//import com.zteits.clouds.api.service.order.vipcardorder.query.VipCardOrderQueryService;
//import com.zteits.clouds.api.service.pay.AppOrgService;
//import com.zteits.clouds.api.service.pay.InvoiceHelperService;
//import com.zteits.pay.biz.invoice.handler.InvoiceOpenHandler;
//import com.zteits.pay.configuration.mail.MailService;
//import com.zteits.pay.dao.*;
//import com.zteits.pay.domain.*;
//import com.zteits.pay.domain.TdCCustInvoiceHisExample.Criteria;
//import com.zteits.pay.pagepager.PageBeanUtil;
//import com.zteits.pay.service.query.TdCCustInvoiceHisQueryInnerService;
//import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.BeanUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.transaction.annotation.Transactional;
//import org.springframework.util.CollectionUtils;
//import org.springframework.util.StringUtils;
//
//import javax.xml.bind.JAXBException;
//import java.io.UnsupportedEncodingException;
//import java.math.BigDecimal;
//import java.math.RoundingMode;
//import java.rmi.RemoteException;
//import java.util.*;
//import java.util.stream.Collectors;
//
///**
// * 发票申领
// * @author hxz
// *
// */
//public class InvoiceHelperServiceImpl implements InvoiceHelperService {
//
// private static final Logger logger = LoggerFactory.getLogger(InvoiceHelperServiceImpl.class);
// @Autowired
// private TdCCustInvoiceSaleParkRelDao tdCCustInvoiceSaleParkRelDao;
//
// @Autowired
// private TdCCustInvoiceinfoDao custInvoiceinfoDao;
//
// @Autowired
// private TdCCustMailingAddressDao custMailingAddressDao;
//
// @Autowired
// private TdCCustInvoiceHisDao custInvoiceHisDao;
//
// @Autowired
// private TdCCustInvoiceHisDetailDao custInvoiceHisDetailDao;
//
// @Autowired
// private TdCCustInvoiceHisItemDao tdCCustInvoiceHisItemDao;
//
// @Autowired
// private VipCardOrderQueryService vipCardOrderQueryService;
//
// @Autowired
// private VipCardOrderOperService vipCardOrderOperService;
//
// @Autowired
// private RNTParkOrderOperService rntParkOrderOperService;
//
// @Autowired
// private BackParkOrderOperService backParkOrderOperService;
//
// @Autowired
// private BackOrderQueryService backOrderQueryService;
//
// @Autowired
// private PubParkOrderQueryService pubParkOrderQueryService;
// @Autowired
// private PayOrderQueryService payOrderQueryService;
//
// @Autowired
// private RechargeOrderOperService rechargeOrderOperService;
//
// @Autowired
// private RechargeOrderQueryService rechargeOrderQueryService;
//
// @Autowired
// private TdCCustInvoiceSaleDao tdCCustInvoiceSaleDao;
//
// @Autowired
// private MailService mailService;
//
// @Autowired
// private AppOrgService appOrgService;
// @Autowired
// private TdCCustInvoiceMailDao tdCCustInvoiceMailDao;
//
//// @Value("${jinshui.wsdl.url}")
//// private String jinshuiWsdl;
//
// @Autowired
// private TdCCustInvoiceHisQueryInnerService tdCCustInvoiceHisQueryInnerService;
//
//
//
// /**
// * 新增一条客户发票抬头信息
// */
// @Override
// public BizResult <Long> insertCustomerInvoiceInfo(TdCCustInvoiceinfoRequest requestObject) {
// if (null == requestObject) {
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
// /**检查当前用户绑定抬头是否超过五个*/
// Long count = custInvoiceinfoDao.checkBindInfoNum(requestObject);
// logger.info("checkBindInfoNum:当前用户已绑定了"+count+"个抬头信息。");
// if (count >=5 ) {
// throw new AppException(AppErrorEnum.APP_INFOOUTLIMIT_ERROR);
// }
// TdCCustInvoiceinfo record = new TdCCustInvoiceinfo();
// BeanUtils.copyProperties(requestObject, record);
// logger.info("insertCustomerInvoiceInfo TdCCustInvoiceinfo--->: {} ", JSONObject.toJSON(record));
//
// Long resultId = custInvoiceinfoDao.insertCustomerInvoiceInfo(record);
// if(requestObject.getReturnId() !=null && requestObject.getReturnId()){
// resultId = record.getId();
// }
// return new BizResult <Long> (resultId);
// }
//
// /**
// * 新增一条客户邮寄地址信息
// */
// @Override
// public BizResult <Long> insertCustomerMailingAddressInfo(TdCCustMailingAddressRequest requestObject) {
// if (null == requestObject) {
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
//
// TdCCustMailingAddress record = new TdCCustMailingAddress();
// BeanUtils.copyProperties(requestObject, record);
//
// return new BizResult <Long> (custMailingAddressDao.insertCustomerMailingAddressInfo(record));
// }
//
// /**
// * 删除一条客户发票抬头信息
// */
// @Override
// public BizResult <Boolean> deleteCustomerInvoiceInfoByID(DeleteCustInvoiceinfoRequest requestObject) {
// if (null == requestObject) {
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
// logger.info("deleteCustomerInvoiceInfoByID->id={}", requestObject.getId().toString());
// return new BizResult <Boolean> (custInvoiceinfoDao.deleteCustomerInvoiceInfoByID(requestObject.getId()));
// }
//
// /**
// * 删除一条客户邮寄地址信息
// */
// @Override
// public BizResult <Boolean> deleteCustomerMailingAddressInfoByID(DeleteCustMailingAddressRequest requestObject) {
// if (null == requestObject) {
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
//
// return new BizResult<Boolean> (custMailingAddressDao.deleteCustomerMailingAddressByID(requestObject.getId()));
// }
//
// /**
// * 更新一条客户发票抬头信息
// */
// @Override
// public BizResult <Boolean> updateCustomerInvoiceInfo(TdCCustInvoiceinfoRequest requestObject) {
// if (null == requestObject) {
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
//
// TdCCustInvoiceinfo record = new TdCCustInvoiceinfo();
// BeanUtils.copyProperties(requestObject, record);
//
// return new BizResult <Boolean> (custInvoiceinfoDao.updateByPrimaryKeySelective(record));
// }
//
// /**
// * 更新一条客户邮寄地址信息
// */
// @Override
// public BizResult<Boolean> updateCustomerMailingAddressInfo(TdCCustMailingAddressRequest requestObject) {
// if (null == requestObject) {
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
// TdCCustMailingAddress record = new TdCCustMailingAddress();
// BeanUtils.copyProperties(requestObject, record);
//
// return new BizResult<Boolean> (custMailingAddressDao.updateByPrimaryKeySelective(record));
// }
//
// /**
// * 查询一条客户发票抬头信息
// */
// @Override
// public BizResult <TdCCustInvoiceinfoDTO> queryCustomerInvoiceInfoById(QueryCustInvoiceinfoRequest requestObject) {
// if (null == requestObject) {
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
//
// TdCCustInvoiceinfo tdCCustInvoiceinfo = custInvoiceinfoDao.queryCustomerInvoiceInfoById(requestObject.getId());
// TdCCustInvoiceinfoDTO tdCCustInvoiceinfoDTO = new TdCCustInvoiceinfoDTO();
// if (null != tdCCustInvoiceinfo) {
// BeanUtils.copyProperties(tdCCustInvoiceinfo, tdCCustInvoiceinfoDTO);
// }
//
// return new BizResult <TdCCustInvoiceinfoDTO> (tdCCustInvoiceinfoDTO);
// }
//
// /**
// * 查询客户所有发票抬头信息
// */
// @Override
// public BizResult<List<TdCCustInvoiceinfoDTO>> queryCustInvoiceInfoList(
// QueryCustInvoiceInfoListRequest requestObject) {
// if (null == requestObject) {
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
//
// TdCCustInvoiceinfoExample example = new TdCCustInvoiceinfoExample();
// example.createCriteria().andCustIdEqualTo(requestObject.getCustId());
//
// List <TdCCustInvoiceinfo> tdCCustInvoiceinfoList = custInvoiceinfoDao.queryCustInvoiceInfoList(example);
// List <TdCCustInvoiceinfoDTO> tdCCustInvoiceinfoDTOList = null;
// if (null != tdCCustInvoiceinfoList) {
// tdCCustInvoiceinfoDTOList = JSON.parseArray(JSON.toJSONString(tdCCustInvoiceinfoList, false), TdCCustInvoiceinfoDTO.class);
// }
//
// return new BizResult <List<TdCCustInvoiceinfoDTO>> (tdCCustInvoiceinfoDTOList);
// }
//
// /**
// * 查询一条客户邮寄地址信息
// */
// @Override
// public BizResult <TdCCustMailingAddressDTO> queryCustomerMailingAddressInfoById(
// QueryCustMailingAddressRequest requestObject) {
// if (null == requestObject) {
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
//
// TdCCustMailingAddressDTO tdCCustMailingAddressDTO = new TdCCustMailingAddressDTO();
// TdCCustMailingAddress tdCCustMailingAddress = custMailingAddressDao.queryCustomerMailingAddressById(requestObject.getId());
// if (null != tdCCustMailingAddress) {
// BeanUtils.copyProperties(tdCCustMailingAddress, tdCCustMailingAddressDTO);
// }
//
// return new BizResult <TdCCustMailingAddressDTO> (tdCCustMailingAddressDTO);
// }
//
// /**
// * 查询客户所有邮寄地址信息
// */
// @Override
// public BizResult<List<TdCCustMailingAddressDTO>> queryCustMailingAddressInfoList(
// QueryCustMailingAddressInfoListRequest requestObject) {
// if (null == requestObject) {
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
//
// TdCCustMailingAddressExample example = new TdCCustMailingAddressExample();
// example.createCriteria().andCustIdEqualTo(requestObject.getCustId());
//
// List<TdCCustMailingAddress> tdCCustMailingAddressList = custMailingAddressDao.queryCustMailingAddressInfoList(example);
// List<TdCCustMailingAddressDTO> tdCCustMailingAddressDTOList = null;
// if (null != tdCCustMailingAddressList) {
// tdCCustMailingAddressDTOList = JSON.parseArray(JSON.toJSONString(tdCCustMailingAddressList, false), TdCCustMailingAddressDTO.class);
// }
//
// return new BizResult <List<TdCCustMailingAddressDTO>> (tdCCustMailingAddressDTOList);
// }
//
// /**
// * 会员卡开票列表
// */
// @Override
// public BizResult <List<VipCardTicketInfoDTO>> queryVipCardTicketList(QueryVipcardDetailsReq requestObject) {
// List <VipCardTicketInfoDTO> queryResult = new ArrayList<>();
// //首先查询未开票的会员卡
// BizResult<List<OrderVipcardDetailDTO>> bizResult = vipCardOrderQueryService.queryVipCardDetails(requestObject);
// logger.info("---queryVipCardTicketList 返回={}", JSONObject.toJSON(bizResult));
// if(bizResult.isSuccess()&&!CollectionUtils.isEmpty(bizResult.getData())){
// for(OrderVipcardDetailDTO dto : bizResult.getData()){
// VipCardTicketInfoDTO item = new VipCardTicketInfoDTO();
// item.setOrderId(dto.getOrderId());
// item.setCardType(dto.getCardType());
// item.setCardTypeName(VipCardTypeEnum.getDesc(item.getCardType().intValue()));
// item.setBuyNum(dto.getBuyNum());
// item.setCardAmount(new BigDecimal(dto.getPrice()));
// item.setCarNumber(dto.getCarNumber());
// item.setCreateDate(dto.getCreateDate());
// item.setDiscount(dto.getPrice() == 0 ? "0.00" : String.valueOf(10-(new BigDecimal((float)dto.getOrderDicountFee()/(dto.getPrice()*dto.getBuyNum())*10).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue())));
// item.setDiscountAmount(new BigDecimal(dto.getOrderDicountFee()));
// item.setCardTotalAmount(new BigDecimal(dto.getCardActAmount()));
// queryResult.add(item);
// }
// }
// logger.info("---queryVipCardTicketList queryResult 返回={}", JSONObject.toJSON(queryResult));
// return new BizResult <List<VipCardTicketInfoDTO>> (queryResult);
// }
//
// /**
// * 记录客户开发票历史信息
// */
// @Override
// @Transactional
// public BizResult <TdCCustInvoiceHisDTO> insertCustInvoiceHistoryInfo(TdCCustInvoiceHisRequest requestObject) {
// if (null == requestObject) {
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
// TdCCustInvoiceHisDTO tdCCustInvoiceHisDTO = new TdCCustInvoiceHisDTO();
//
// // 历史开票详情插入
// List<OrderVipcardDetailDTO> orderList = null;
// if (null != requestObject.getOrderIds() && requestObject.getOrderIds().size()>0) {
// QueryVipcardDetailsReq requestQ = new QueryVipcardDetailsReq();
// requestQ.setOrderIds(requestObject.getOrderIds());
// requestQ.setSysCode(BasicEnum.SYS_CODE.getValue());
// BizResult<List<OrderVipcardDetailDTO>> bizResult = vipCardOrderQueryService.queryVipCardDetails(requestQ);
// if(bizResult.isSuccess()&&!CollectionUtils.isEmpty(bizResult.getData())) {
// orderList = bizResult.getData();
//
// // 校验发票金额
// BigDecimal checkTotalInvoiceFee = new BigDecimal(0);
// // 校验是否已进行开票申请
// QueryInvoiceStateByDetailOrderIdReqest req = new QueryInvoiceStateByDetailOrderIdReqest ();
// req.setSysCode(BasicEnum.SYS_CODE.getValue());
// for (OrderVipcardDetailDTO orderItem: orderList) {
// //重复开票校验
// req.setDetailOrderId(orderItem.getDetailOrderId());
// BizResult<Integer> bizresInvoiceState = vipCardOrderQueryService.queryInvoiceStateByDetailOrderId(req);
// if (bizresInvoiceState.isSuccess() && (null != bizresInvoiceState.getData())) {
// if (0 < bizresInvoiceState.getData()) {
// logger.info("insertCustInvoiceHistoryDetailInfo--不能重复开票 ");
// throw new BizException(ErrorType.APP_ERROR, "不能重复开票");
// }
// }
//
// // sum实付金额
// checkTotalInvoiceFee = checkTotalInvoiceFee.add(new BigDecimal(orderItem.getCardActAmount()));
// }
// if (0 != checkTotalInvoiceFee.compareTo(requestObject.getInvoiceTotalFee())) {
// logger.info("insertCustInvoiceHistoryDetailInfo--手机端开票金额计算有误 ");
// throw new BizException(ErrorType.APP_ERROR, "开票金额计算有误");
// }
// }
// } else {
// logger.info("insertCustInvoiceHistoryDetailInfo--requestObject.getOrderIds 传入参数订单id列表为空 ");
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
//
// List<TdCCustInvoiceHisDetailDTO> hisDetailList = new ArrayList<TdCCustInvoiceHisDetailDTO>();
// if (null != orderList) {
// for (OrderVipcardDetailDTO orderItem: orderList) {
//
// // 更新是否已开发票状态
// UpdateVipcardDetailReq updateVipcardDetailReq = new UpdateVipcardDetailReq();
// updateVipcardDetailReq.setDetailOrderId(orderItem.getDetailOrderId());
// updateVipcardDetailReq.setId(orderItem.getId());
// updateVipcardDetailReq.setInvoiceState(InvoiceStateEnum.YES.getValue());
// updateVipcardDetailReq.setSysCode(BasicEnum.SYS_CODE.getValue());
// vipCardOrderOperService.updateVipCardDetail(updateVipcardDetailReq);
//
// // 新增已开发票详情
// TdCCustInvoiceHisDetail record = new TdCCustInvoiceHisDetail();
// record.setOrderId(orderItem.getOrderId());
// record.setInvoiceId(requestObject.getInvoiceId());
// record.setOrderType(orderItem.getOrderType());
// record.setOrderActFee(new BigDecimal(orderItem.getCardActAmount()));
// record.setOrderPayedFee(new BigDecimal(orderItem.getCardActAmount()));
// record.setOrderTotalFee(new BigDecimal(orderItem.getPrice()*orderItem.getBuyNum()));
// record.setOrderDate(orderItem.getCreateDate());
// record.setDataState(1);
// record.setCreateDate(new Date());
// record.setId(custInvoiceHisDetailDao.insertCustInvoiceHistoryDetailInfo(record));
//
// TdCCustInvoiceHisDetailDTO tdCCustInvoiceHisDetailDTO = new TdCCustInvoiceHisDetailDTO();
// BeanUtils.copyProperties(record, tdCCustInvoiceHisDetailDTO);
//
// hisDetailList.add(tdCCustInvoiceHisDetailDTO);
// }
// }
//
// tdCCustInvoiceHisDTO.setCustInvoiceHisDetailDTOList(hisDetailList);
//
//
// // 历史开票插入
// TdCCustInvoiceHis recordo = new TdCCustInvoiceHis();
// BeanUtils.copyProperties(requestObject, recordo);
// logger.info("---begin--serviceinsertCustInvoiceHistoryInforecordo记录客户开发票历史信息,入参={}", JSONObject.toJSON(recordo));
// recordo.setId(custInvoiceHisDao.insertCustInvoiceHistoryInfo(recordo));
// BeanUtils.copyProperties(recordo, tdCCustInvoiceHisDTO);
//
//// //新增开票条目
//// List<TdCCustInvoiceHisItem> items = new ArrayList<>();
//// TdCCustInvoiceHisItem item = new TdCCustInvoiceHisItem();
//// BeanUtils.copyProperties(requestObject, item);
//// item.setInvoiceId(requestObject.getInvoiceId());
//// item.setItemName(saleInfo.getItemName());
//// item.setItemCode(saleInfo.getItemCode());
//// item.setLineType(InvoiceItemEnum.LINETYPE);//0:正常行1:折扣行2:被折扣行
//// item.setTaxRate(saleInfo.getItemTaxRate());
//// item.setQuantity(1D);
//// item.setTaxPrice(requestObject.getInvoiceTotalFee() == null?0:requestObject.getInvoiceTotalFee().doubleValue());
//// item.setTotalAmount(requestObject.getInvoiceTotalFee() == null?0:requestObject.getInvoiceTotalFee().doubleValue());
//// item.setYhzcbs("0");//税收优惠政策标志0:不使用 1:使用
//// items.add(item);
//// custInvoiceHisDao.insertCustInvoiceHistorItems(items );
// return new BizResult<TdCCustInvoiceHisDTO> (tdCCustInvoiceHisDTO);
// }
//
// /**
// * 记录客户开发票历史详情信息(由几张vip订单组成一起开发票)
// */
// @Transactional
// @Override
// public BizResult <List<TdCCustInvoiceHisDetailDTO>> insertCustInvoiceHistoryDetailInfo(TdCCustInvoiceHisDetailRequest requestObject) {
// if (null == requestObject) {
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
//
// // 历史开票详情插入
// List<OrderVipcardDetailDTO> orderList = null;
// if (null != requestObject.getOrderIds() && requestObject.getOrderIds().size()>0) {
// QueryVipcardDetailsReq requestQ = new QueryVipcardDetailsReq();
// requestQ.setOrderIds(requestObject.getOrderIds());
// requestQ.setSysCode(BasicEnum.SYS_CODE.getValue());
// BizResult<List<OrderVipcardDetailDTO>> bizResult = vipCardOrderQueryService.queryVipCardDetails(requestQ);
// if(bizResult.isSuccess()&&!CollectionUtils.isEmpty(bizResult.getData())){
// orderList = bizResult.getData();
// }
// } else {
// logger.info("insertCustInvoiceHistoryDetailInfo--requestObject.getOrderIds 传入参数订单id列表为空 ");
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
//
// List<TdCCustInvoiceHisDetailDTO> hisDetailList = new ArrayList<TdCCustInvoiceHisDetailDTO>();
// if (null != orderList) {
// for (OrderVipcardDetailDTO orderItem: orderList) {
//
// // 更新是否已开发票状态
// UpdateVipcardDetailReq updateVipcardDetailReq = new UpdateVipcardDetailReq();
// updateVipcardDetailReq.setDetailOrderId(orderItem.getDetailOrderId());
// updateVipcardDetailReq.setId(orderItem.getId());
// updateVipcardDetailReq.setInvoiceState(InvoiceStateEnum.YES.getValue());
// vipCardOrderOperService.updateVipCardDetail(updateVipcardDetailReq);
//
// // 新增已开发票详情
// TdCCustInvoiceHisDetail record = new TdCCustInvoiceHisDetail();
// record.setOrderId(orderItem.getOrderId());
// record.setInvoiceId(requestObject.getInvoiceId());
// record.setOrderType(orderItem.getOrderType());
// record.setOrderActFee(new BigDecimal(orderItem.getCardActAmount()));
// record.setOrderPayedFee(new BigDecimal(orderItem.getCardActAmount()));
// record.setOrderTotalFee(new BigDecimal(orderItem.getPrice()*orderItem.getBuyNum()));
// record.setOrderDate(orderItem.getCreateDate());
// record.setDataState(1);
// record.setCreateDate(new Date());
// record.setId(custInvoiceHisDetailDao.insertCustInvoiceHistoryDetailInfo(record));
//
// TdCCustInvoiceHisDetailDTO tdCCustInvoiceHisDetailDTO = new TdCCustInvoiceHisDetailDTO();
// BeanUtils.copyProperties(record, tdCCustInvoiceHisDetailDTO);
//
// hisDetailList.add(tdCCustInvoiceHisDetailDTO);
// }
// }
//
// return new BizResult<List<TdCCustInvoiceHisDetailDTO>> (hisDetailList);
// }
//
// /**
// * 通过客户id(custId)查询开票历史列表
// */
// @Override
// public BizResult<List<TdCCustInvoiceHisDTO>> queryCustInvoiceHistoryList(
// QueryCustInvoiceHistoryListRequest requestObject) {
// if (null == requestObject) {
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
//
// TdCCustInvoiceHisExample example = new TdCCustInvoiceHisExample ();
// example.createCriteria().andCustIdEqualTo(requestObject.getCustId())
// .andInvoiceStateIn(requestObject.getInvoiceStateList());
//
// List<TdCCustInvoiceHis> tdCCustInvoiceHisList = custInvoiceHisDao.queryCustInvoiceHistoryList(example);
// List<TdCCustInvoiceHisDTO> tdCCustInvoiceHisDTOList = new ArrayList<TdCCustInvoiceHisDTO> ();
// if (null != tdCCustInvoiceHisList) {
// for (TdCCustInvoiceHis item: tdCCustInvoiceHisList) {
// TdCCustInvoiceHisDTO tdCCustInvoiceHisDTO = new TdCCustInvoiceHisDTO ();
// BeanUtils.copyProperties(item, tdCCustInvoiceHisDTO);
// //获取客服电话
// String servicePhone = getServicePhone(tdCCustInvoiceHisDTO.getOrgId());
// tdCCustInvoiceHisDTO.setServicePhone(servicePhone);
// // 获取历史详情列表
// TdCCustInvoiceHisDetailExample detailExample = new TdCCustInvoiceHisDetailExample();
// detailExample.createCriteria().andInvoiceIdEqualTo(item.getInvoiceId());
// List<TdCCustInvoiceHisDetail> tdCCustInvoiceHisDetailList = custInvoiceHisDetailDao.
// queryCustInvoiceHisDetailList(detailExample);
// List<TdCCustInvoiceHisDetailDTO> tdCCustInvoiceHisDetailDTOList = null;
// if (null != tdCCustInvoiceHisDetailList) {
// tdCCustInvoiceHisDetailDTOList = JSON.parseArray(JSON.toJSONString(tdCCustInvoiceHisDetailList, false), TdCCustInvoiceHisDetailDTO.class);
// tdCCustInvoiceHisDTO.setCustInvoiceHisDetailDTOList(tdCCustInvoiceHisDetailDTOList);
// }
//
// // 赋值给开票历史列表项
// tdCCustInvoiceHisDTOList.add(tdCCustInvoiceHisDTO);
// }
// //tdCCustInvoiceHisDTOList = JSON.parseArray(JSON.toJSONString(tdCCustInvoiceHisList, false), TdCCustInvoiceHisDTO.class);
// }
//
// return new BizResult <List<TdCCustInvoiceHisDTO>> (tdCCustInvoiceHisDTOList);
// }
//
// /**
// * 通过Id查询客户开票历史信息
// */
// @Override
// public BizResult<TdCCustInvoiceHisDTO> queryCustInvoiceHistoryInfoById (QueryCustInvoiceHisRequest requestObject) {
// if (null == requestObject) {
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
//
// TdCCustInvoiceHisDTO tdCCustInvoiceHisDTO = new TdCCustInvoiceHisDTO();
// TdCCustInvoiceHis record = custInvoiceHisDao.queryCustInvoiceHistoryInfo(requestObject.getId());
// List<TdCCustInvoiceHisDetailDTO> tdCCustInvoiceHisDetailDTOList = null;
// if (null != record) {
// BeanUtils.copyProperties(record, tdCCustInvoiceHisDTO);
//
// TdCCustInvoiceHisDetailExample example = new TdCCustInvoiceHisDetailExample();
// example.createCriteria().andInvoiceIdEqualTo(record.getInvoiceId());
// List<TdCCustInvoiceHisDetail> tdCCustInvoiceHisDetailList = custInvoiceHisDetailDao.queryCustInvoiceHisDetailList(example);
// if (null != tdCCustInvoiceHisDetailList) {
// tdCCustInvoiceHisDetailDTOList = JSON.parseArray(JSON.toJSONString(tdCCustInvoiceHisDetailList, false), TdCCustInvoiceHisDetailDTO.class);
// tdCCustInvoiceHisDTO.setCustInvoiceHisDetailDTOList(tdCCustInvoiceHisDetailDTOList);
// }
// }
//
// return new BizResult<TdCCustInvoiceHisDTO> (tdCCustInvoiceHisDTO);
// }
//
// /**
// * 通过Id查询客户开票历史详情
// */
// @Override
// public BizResult<TdCCustInvoiceHisDetailDTO> queryCustInvoiceHistoryDetailInfoById (
// QueryCustInvoiceHisDetailRequest requestObject) {
// if (null == requestObject) {
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
//
// TdCCustInvoiceHisDetailDTO tdCCustInvoiceHisDetailDTO = new TdCCustInvoiceHisDetailDTO();
// TdCCustInvoiceHisDetail record = custInvoiceHisDetailDao.queryCustInvoiceHistoryDetailInfo(requestObject.getId());
// if (null != record) {
// BeanUtils.copyProperties(record, tdCCustInvoiceHisDetailDTO);
// }
// return new BizResult<TdCCustInvoiceHisDetailDTO> (tdCCustInvoiceHisDetailDTO);
// }
//
// @Override
// public BizResult<List<TdCCustInvoiceHisDetailDTO>> queryCustInvoiceHisDetailList (QueryCustInvoiceHisDetailRequest requestObject) {
// if (null == requestObject) {
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
// TdCCustInvoiceHisDetailExample detailExample = new TdCCustInvoiceHisDetailExample();
// detailExample.createCriteria().andInvoiceIdEqualTo(requestObject.getInvoiceId());
// List<TdCCustInvoiceHisDetail> tdCCustInvoiceHisDetails = custInvoiceHisDetailDao.queryCustInvoiceHisDetailList(detailExample);
// List<TdCCustInvoiceHisDetailDTO> dtoList = new ArrayList<>();
// if(!CollectionUtils.isEmpty(tdCCustInvoiceHisDetails)){
// for(TdCCustInvoiceHisDetail detail:tdCCustInvoiceHisDetails){
// TdCCustInvoiceHisDetailDTO tdCCustInvoiceHisDetailDTO = new TdCCustInvoiceHisDetailDTO();
// BeanUtils.copyProperties(detail,tdCCustInvoiceHisDetailDTO);
// dtoList.add(tdCCustInvoiceHisDetailDTO);
// }
//
// }
// return new BizResult<List<TdCCustInvoiceHisDetailDTO>> (dtoList);
// }
//
// @Override
// public BizResult<List<TdCCustInvoiceHisDTO>> selectListByOrderId(TdCCustInvoiceHisRequest record) {
// List<TdCCustInvoiceHisDTO> tdCCustInvoiceHisDTOS = custInvoiceHisDao.selectListByOrderId(record);
// return new BizResult<>(tdCCustInvoiceHisDTOS);
// }
//
// @Override
// public BizResult<TdCCustInvoiceHisDTO> CloudOpenTicketForCustInvoiceHisInfo(TdCCustInvoiceHisRequest request) {
// if (null == request) {
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
//
// List<TdCCustInvoiceHisDetailDTO> hisDetailList = new ArrayList<TdCCustInvoiceHisDetailDTO>();
// TdCCustInvoiceHisDTO tdCCustInvoiceHisDTO = new TdCCustInvoiceHisDTO();
// /**对订单进行开票(包括临停,补缴和会员卡)*/
// List<TdCCustInvoiceByOrdersRequest> orders = request.getOrders();
//
// TdCCustInvoiceHis recordo = new TdCCustInvoiceHis();
// BeanUtils.copyProperties(request, recordo);
// Long invoiceTotalFee = 0L;
// if(CollectionUtil.isNotEmpty(orders)){
// //对订单根据类型进行分类
// Map<Integer, List<TdCCustInvoiceByOrdersRequest>> aMap = new HashMap<>();
// aMap = orders.stream().collect(Collectors.groupingBy(TdCCustInvoiceByOrdersRequest::getPayOrderType));
// /**1.校验是否开票***/
// for(Integer payOrderType :aMap.keySet()) {
// //校验是否已经开过电子发票
// checkInvoiced(aMap, payOrderType);
// }
// /**2.进行开票***/
// for(Integer payOrderType :aMap.keySet()){
// logger.info("开票更改开票状态: "+JSONObject.toJSONString(aMap.get(payOrderType)));
// /**临停费用*/
// if(PayOrderTypeEnum.PARK_PAY.value().equals(payOrderType)||
// PayOrderTypeEnum.SHAREBERTH_PAY.value().equals(payOrderType)||
// PayOrderTypeEnum.PARKPRE_PAY.value().equals(payOrderType)){
// for(TdCCustInvoiceByOrdersRequest ordersRequest :aMap.get(payOrderType)) {
// /**临停*/
// invoiceTotalFee = invoiceTotalFee+ordersRequest.getOrderActFee();
// hisDetailList = this.createCustInvoiceHisDetail(request,ordersRequest,hisDetailList);
// }
// recordo.setInvoiceBigType(OrderBigTypeEnum.PARK_ORDER.value());
// }else if(PayOrderTypeEnum.PARKBACK_PAY.value().equals(payOrderType)){
// /**欠费补交*/
// for(TdCCustInvoiceByOrdersRequest ordersRequest :aMap.get(payOrderType)) {
// /**欠费补交*/
// invoiceTotalFee = invoiceTotalFee+ordersRequest.getOrderActFee();
// hisDetailList = this.createCustInvoiceHisDetail(request,ordersRequest,hisDetailList);
// }
// recordo.setInvoiceBigType(OrderBigTypeEnum.PARK_ORDER.value());
//
// }else if(PayOrderTypeEnum.VIP_CARD_ADDED.value().equals(payOrderType)||
// PayOrderTypeEnum.VIP_CARD_RENEW.value().equals(payOrderType) ||
// PayOrderTypeEnum.AREA_VIP_CARD_ADDED.value().equals(payOrderType) ||
// PayOrderTypeEnum.AREA_VIP_CARD_CHANGE_CARNUM.value().equals(payOrderType) ||
// PayOrderTypeEnum.TIME_VIP_CARD_ADDED.value().equals(payOrderType) ||
// PayOrderTypeEnum.TIME_VIP_CARD_CHANGE_CARNUM.value().equals(payOrderType))
// {
// for(TdCCustInvoiceByOrdersRequest ordersRequest :aMap.get(payOrderType)) {
// /**会员卡*/
// invoiceTotalFee = invoiceTotalFee+ordersRequest.getOrderActFee();
// hisDetailList = this.createCustInvoiceHisDetail(request,ordersRequest,hisDetailList);
// }
// recordo.setInvoiceBigType(OrderBigTypeEnum.VIP_ORDER.value());
//
// }else if(PayOrderTypeEnum.BALANCE_PAY.value().equals(payOrderType)) {
// for(TdCCustInvoiceByOrdersRequest ordersRequest :aMap.get(payOrderType)) {
// /**账户充值*/
// invoiceTotalFee = invoiceTotalFee+ordersRequest.getOrderActFee();
// hisDetailList = this.createCustInvoiceHisDetail(request,ordersRequest,hisDetailList);
// }
// recordo.setInvoiceBigType(OrderBigTypeEnum.RECHARGE_ORDER.value());
//
// }
// }
// } else {
// logger.info("openTicketForCustInvoiceHisInfo--requestObject.getOrders 传入参数订单列表为空 ");
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
// //查询销方信息
// TdCCustInvoiceSaleQueryRequest saleRequest = new TdCCustInvoiceSaleQueryRequest();
// saleRequest.setSysCode(BasicEnum.SYS_CODE.getValue());
// saleRequest.setOrgId(recordo.getOrgId());
// // 根据税号去查询销方信息
// saleRequest.setSaleTaxids(Collections.singletonList(request.getSaleTaxid()));
// if (null == recordo.getOrgId()) {
// throw new BizException(ErrorType.PARAMM_NULL, "获取销方信息,组织id为空!");
// }
// List<TdCCustInvoiceSale> saleList = tdCCustInvoiceSaleDao.queryTdCCustInvoiceSale(saleRequest);
// if(CollectionUtils.isEmpty(saleList)){
// throw new BizException(ErrorType.BIZ_ERROR, "根据当前组织编码["+recordo.getOrgId()+"],未查询到相应的销方信息!");
// }
//
// tdCCustInvoiceHisDTO.setCustInvoiceHisDetailDTOList(hisDetailList);
// TdCCustInvoiceSale saleInfo = saleList.get(0);
// // 历史开票插入
// recordo.setInvoiceTaxRate(new BigDecimal(saleInfo.getItemTaxRate()));
// //总价除以(1+9%)乘9%
// recordo.setInvoiceTaxFee(invoiceTotalFee == null ? new BigDecimal("0") :
// (new BigDecimal(invoiceTotalFee).multiply(recordo.getInvoiceTaxRate()))
// );
// BigDecimal a = recordo.getInvoiceTaxRate().add(new BigDecimal(1));
// recordo.setInvoiceTaxFee(recordo.getInvoiceTaxFee().divide(a,2, RoundingMode.HALF_UP)
// );
// recordo.setInvoiceTotalFee(new BigDecimal(invoiceTotalFee));
// recordo.setInvoiceFee(new BigDecimal(invoiceTotalFee) == null ? new BigDecimal("0") :
// (new BigDecimal(invoiceTotalFee)).subtract(recordo.getInvoiceTaxFee()));
// //放入销方信息
// recordo.setSaleAddress(saleInfo.getAddress());
// recordo.setSaleBankName(saleInfo.getSaleBankName());
// recordo.setSaleCardNo(saleInfo.getSaleBankNo());
// recordo.setSaleName(saleInfo.getSaleName());
// recordo.setSaleTaxid(saleInfo.getSaleTaxid());
// //放入开票人、复核人、收款人
// recordo.setChecker(saleInfo.getChecker());
// recordo.setPryee(saleInfo.getPryee());
// recordo.setDrawer(saleInfo.getDrawer());
// recordo.setTerminalSource(request.getTerminalSource());
// if(StringUtils.isEmpty(recordo.getTicketContent())){
// recordo.setTicketContent(saleInfo.getItemName());
// }
// if(request.getOptState()==1){
// recordo.setId(custInvoiceHisDao.insertCustInvoiceHistoryInfo(recordo));
// }
// BeanUtils.copyProperties(recordo, tdCCustInvoiceHisDTO);
//
// //新增开票条目
// List<TdCCustInvoiceHisItem> items = new ArrayList<>();
// TdCCustInvoiceHisItem item = new TdCCustInvoiceHisItem();
// BeanUtils.copyProperties(recordo, item);
// item.setInvoiceId(recordo.getInvoiceId());
// item.setItemName(saleInfo.getItemName());
// item.setItemCode(saleInfo.getItemCode());
// item.setLineType(InvoiceItemEnum.LINETYPE);//0:正常行1:折扣行2:被折扣行
// item.setTaxRate(saleInfo.getItemTaxRate());
// item.setUnit(InvoiceItemEnum.UNIT);
// item.setSpec(InvoiceItemEnum.SPEC);
// item.setQuantity(1D);
// item.setTaxPrice(new BigDecimal(invoiceTotalFee) == null?0:(new BigDecimal(invoiceTotalFee).doubleValue())/100);
// item.setTotalAmount(new BigDecimal(invoiceTotalFee) == null?0:(new BigDecimal(invoiceTotalFee).doubleValue())/100);
// item.setYhzcbs("0");//税收优惠政策标志0:不使用 1:使用
// items.add(item);
// if(request.getOptState()==1){
// custInvoiceHisDao.insertCustInvoiceHistorItems(items );
// }
// if(!CollectionUtils.isEmpty(items)){
// List<TdCCustInvoiceHisItemDTO> custInvoiceHisItemDTOs = new ArrayList<>();
// ListCopyUtil.listCopyProperties(items,custInvoiceHisItemDTOs,TdCCustInvoiceHisItemDTO.class);
// tdCCustInvoiceHisDTO.setCustInvoiceHisItemDTOs(custInvoiceHisItemDTOs);
// }
// tdCCustInvoiceHisDTO.setInvoiceTotalYuanCase(AmountUtils.moneyUpperCase(new BigDecimal(AmountUtils.changeF2Y(invoiceTotalFee)).doubleValue()));
//
// logger.info("CliudopenTicketForCustInvoiceHisInfo--返回 :"+JSONObject.toJSON(tdCCustInvoiceHisDTO));
//
// return new BizResult<TdCCustInvoiceHisDTO> (tdCCustInvoiceHisDTO);
// }
//
// @Override
// public BizResult<TdCCustInvoiceHisDTO> CloudOpenTicketForUpdateInvoiceStatus(TdCCustInvoiceHisRequest requestObject) {
// if (null == requestObject) {
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
//
// TdCCustInvoiceHisDTO tdCCustInvoiceHisDTO = new TdCCustInvoiceHisDTO();
// List<TdCCustInvoiceByOrdersRequest> orders = requestObject.getOrders();
// if(CollectionUtil.isNotEmpty(orders)){
// //对订单根据类型进行分类
// Map<Integer, List<TdCCustInvoiceByOrdersRequest>> aMap = new HashMap<>();
// aMap = orders.stream().collect(Collectors.groupingBy(TdCCustInvoiceByOrdersRequest::getPayOrderType));
//
// /**修改开状态***/
// for(Integer payOrderType :aMap.keySet()){
// logger.info("开票更改开票状态: "+JSONObject.toJSONString(aMap.get(payOrderType)));
// /**临停费用*/
// if(PayOrderTypeEnum.PARK_PAY.value().equals(payOrderType)||
// PayOrderTypeEnum.SHAREBERTH_PAY.value().equals(payOrderType)||
// PayOrderTypeEnum.PARKPRE_PAY.value().equals(payOrderType)){
// for(TdCCustInvoiceByOrdersRequest ordersRequest :aMap.get(payOrderType)) {
// /**临停*/
// // 更新已开发票状态
// logger.info("临停车,开票更改开票状态: "+JSONObject.toJSONString(ordersRequest));
// UpdateOrderParkByOrderIdRequest orderIdRequest = new UpdateOrderParkByOrderIdRequest();
// orderIdRequest.setOrderId(ordersRequest.getRltOrderId());
// orderIdRequest.setInvoiceState(InvoiceStateEnum.YES.getValue());
// orderIdRequest.setSysCode(BasicEnum.SYS_CODE.getValue());
// rntParkOrderOperService.updateOrderParkByOrderId(orderIdRequest);
// }
// }else if(PayOrderTypeEnum.PARKBACK_PAY.value().equals(payOrderType)){
// /**欠费补交*/
// for(TdCCustInvoiceByOrdersRequest ordersRequest :aMap.get(payOrderType)) {
// /**欠费补交*/
// // 更新已开发票状态
// UpdateOrderBackByOrderIdRequest orderIdRequest = new UpdateOrderBackByOrderIdRequest();
// orderIdRequest.setOrderId(ordersRequest.getRltOrderId());
// orderIdRequest.setInvoiceState(InvoiceStateEnum.YES.getValue());
// orderIdRequest.setSysCode(BasicEnum.SYS_CODE.getValue());
// backParkOrderOperService.updateBackOrderByOrderId(orderIdRequest);
// }
// }else if(PayOrderTypeEnum.VIP_CARD_ADDED.value().equals(payOrderType)||
// PayOrderTypeEnum.VIP_CARD_RENEW.value().equals(payOrderType) ||
// PayOrderTypeEnum.AREA_VIP_CARD_ADDED.value().equals(payOrderType) ||
// PayOrderTypeEnum.AREA_VIP_CARD_CHANGE_CARNUM.value().equals(payOrderType) ||
// PayOrderTypeEnum.TIME_VIP_CARD_ADDED.value().equals(payOrderType) ||
// PayOrderTypeEnum.TIME_VIP_CARD_CHANGE_CARNUM.value().equals(payOrderType))
// {
// for(TdCCustInvoiceByOrdersRequest ordersRequest :aMap.get(payOrderType)) {
// /**会员卡*/
// // 更新是否已开发票状态
// UpdateVipcardDetailReq updateVipcardDetailReq = new UpdateVipcardDetailReq();
// updateVipcardDetailReq.setOrderId(ordersRequest.getRltOrderId());
// updateVipcardDetailReq.setInvoiceState(InvoiceStateEnum.YES.getValue());
// updateVipcardDetailReq.setSysCode(BasicEnum.SYS_CODE.getValue());
// vipCardOrderOperService.updateVipCardDetailByOrderId(updateVipcardDetailReq);
// }
//
// }else if(PayOrderTypeEnum.BALANCE_PAY.value().equals(payOrderType)) {
// for(TdCCustInvoiceByOrdersRequest ordersRequest :aMap.get(payOrderType)) {
// /**账户充值*/
// // 更新是否已开发票状态
// OrderRechargeUpdateRequest orderRechargeUpdateRequest = new OrderRechargeUpdateRequest();
// orderRechargeUpdateRequest.setOrderId(ordersRequest.getRltOrderId());
// orderRechargeUpdateRequest.setInvoiceState(InvoiceStateEnum.YES.getValue());
// orderRechargeUpdateRequest.setSysCode(BasicEnum.SYS_CODE.getValue());
// rechargeOrderOperService.updateOrderRechargeByOrderIdOrId(orderRechargeUpdateRequest);
// }
// }
// }
// } else {
// logger.info("CloudOpenTicketForUpdateInvoiceStatus--requestObject.getOrders 传入参数订单列表为空 ");
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
// return new BizResult<TdCCustInvoiceHisDTO> (tdCCustInvoiceHisDTO);
// }
//
// /**
// * 校验是否已经开票
// * @param aMap
// * @param payOrderType
// */
// private void checkInvoiced(Map<Integer, List<TdCCustInvoiceByOrdersRequest>> aMap, Integer payOrderType) {
// /**临停费用*/
// if (PayOrderTypeEnum.PARK_PAY.value().equals(payOrderType) || PayOrderTypeEnum.SHAREBERTH_PAY.value().equals(payOrderType) || PayOrderTypeEnum.PARKPRE_PAY.value().equals(payOrderType)) {
// List<String> orderIds = aMap.get(payOrderType).stream().map(item -> item.getRltOrderId()).collect(Collectors.toList());
// if (CollectionUtil.isNotEmpty(orderIds)) {
// OrderParkQueryReq requestQ = new OrderParkQueryReq();
// requestQ.setOrderIds(orderIds);
// requestQ.setSysCode(BasicEnum.SYS_CODE.getValue());
// BizResult<List<OrderParkQueryDTO>> bizResult = pubParkOrderQueryService.queryParkOrderByCondition(requestQ);
// if (bizResult.isSuccess() && CollectionUtil.isNotEmpty(bizResult.getData())) {
// for (OrderParkQueryDTO dto : bizResult.getData()) {
// if (0 < dto.getInvoiceState()) {
// logger.info("insertCustInvoiceHistoryDetailInfo--不能重复开票 ");
// throw new BizException(ErrorType.APP_ERROR, "不能重复开票");
// }
// }
// }
// }
// } else if (PayOrderTypeEnum.PARKBACK_PAY.value().equals(payOrderType)) {
// /**欠费补交*/
// List<String> orderIds = aMap.get(payOrderType).stream().map(item -> item.getRltOrderId()).collect(Collectors.toList());
// BackOrderPageQueryByContidionReq requestQ = new BackOrderPageQueryByContidionReq();
// requestQ.setOrderIds(orderIds);
// requestQ.setSysCode(BasicEnum.SYS_CODE.getValue());
// requestQ.getBaseRequest().setPageNum(1);
// requestQ.getBaseRequest().setPageSize(999);
// BizResult<PageBean<OrderBackDTO>> bizResult = backOrderQueryService.pageQueryBackOrderByCondition(requestQ);
// if (bizResult.isSuccess() && bizResult.getData() != null && CollectionUtil.isNotEmpty(bizResult.getData().getDataList())) {
// for (OrderBackDTO dto : bizResult.getData().getDataList()) {
// if (0 < dto.getInvoiceState()) {
// logger.info("insertCustInvoiceHistoryDetailInfo--不能重复开票 ");
// throw new BizException(ErrorType.APP_ERROR, "不能重复开票");
// }
// }
// }
//
// } else if (PayOrderTypeEnum.VIP_CARD_ADDED.value().equals(payOrderType) ||
// PayOrderTypeEnum.VIP_CARD_RENEW.value().equals(payOrderType)) {
// /**查询会员卡是否已经开票*/
// List<String> orderIds = aMap.get(payOrderType).stream().map(item -> item.getRltOrderId()).collect(Collectors.toList());
// QueryVipcardDetailsReq requestQ = new QueryVipcardDetailsReq();
// requestQ.setOrderIds(orderIds);
// requestQ.setSysCode(BasicEnum.SYS_CODE.getValue());
// BizResult<List<OrderVipcardDetailDTO>> bizResult = vipCardOrderQueryService.queryVipCardDetails(requestQ);
// if (bizResult.isSuccess() && CollectionUtil.isNotEmpty(bizResult.getData())) {
// for (OrderVipcardDetailDTO dto : bizResult.getData()) {
// if (0 < dto.getInvoiceState()) {
// logger.info("insertCustInvoiceHistoryDetailInfo--不能重复开票 ");
// throw new BizException(ErrorType.APP_ERROR, "不能重复开票");
// }
// }
// }
// } else if (PayOrderTypeEnum.BALANCE_PAY.value().equals(payOrderType)) {
// /**查询账户充值是否已经开票*/
// List<String> orderIds = aMap.get(payOrderType).stream().map(item -> item.getRltOrderId()).collect(Collectors.toList());
// OrderRechargeQueryReq requestQ = new OrderRechargeQueryReq();
// requestQ.setOrderIds(orderIds);
// requestQ.setSysCode(BasicEnum.SYS_CODE.getValue());
// BizResult<List<OrderRechargeDTO>> bizResult = rechargeOrderQueryService.queryOrderRechargeByCondition(requestQ);
// if (bizResult.isSuccess() && CollectionUtil.isNotEmpty(bizResult.getData())) {
// for (OrderRechargeDTO dto : bizResult.getData()) {
// if (0 < dto.getInvoiceState()) {
// logger.info("insertCustInvoiceHistoryDetailInfo--不能重复开票 ");
// throw new BizException(ErrorType.APP_ERROR, "不能重复开票");
// }
// }
// }
// }
// }
//
//
// @Override
// public BizResult<PageBean<TdCCustInvoiceHisDTO>> queryCustInvoiceHisList(TdCCustInvoiceHisRequest requestObject) {
// if (null == requestObject) {
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
// TdCCustInvoiceHis record = new TdCCustInvoiceHis();
// BeanUtils.copyProperties(requestObject, record);
//
// PageBean<TdCCustInvoiceHisDTO> pageBean = new PageBean<>();
// PageInfo<TdCCustInvoiceHisDTO> pageInfo = custInvoiceHisDao.queryListByVO(requestObject);
// if(pageInfo!=null){
// PageBeanUtil.copyProperties(pageInfo, pageBean, TdCCustInvoiceHisDTO.class);
// for (TdCCustInvoiceHisDTO dto : pageBean.getDataList()) {
// String invoiceBigTypeDesc = "";
// //发票大类名称:100:停车,200-充值,300-会员卡
// if(dto.getInvoiceBigType()==null){
// dto.setInvoiceBigType(300);
// }
// switch (dto.getInvoiceBigType()) {
// case 100:
// invoiceBigTypeDesc = "临停开票";
// break;
// case 200:
// invoiceBigTypeDesc = "充值开票";
// case 300:
// invoiceBigTypeDesc = "会员卡开票";
// default:
// break;
// }
// dto.setInvoiceBigTypeDesc(invoiceBigTypeDesc);
// }
// }
// return new BizResult<>(pageBean);
// }
//
// @Override
// public BizResult<Integer> updateInvioceById(TdCCustInvoiceHisRequest requestObject) {
// if (null == requestObject) {
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
// TdCCustInvoiceHis record = new TdCCustInvoiceHis();
// BeanUtils.copyProperties(requestObject, record);
//
// return new BizResult <Integer> (custInvoiceHisDao.updateInvioceById(record));
// }
//
// @Override
// @Transactional
// public BizResult<TdCCustInvoiceHisDTO> openTicketForCustInvoiceHisInfo(TdCCustInvoiceHisRequest requestObject) {
// if (null == requestObject) {
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
//
// List<TdCCustInvoiceHisDetailDTO> hisDetailList = new ArrayList<TdCCustInvoiceHisDetailDTO>();
// TdCCustInvoiceHisDTO tdCCustInvoiceHisDTO = new TdCCustInvoiceHisDTO();
// /**对订单进行开票(包括临停,补缴和会员卡)*/
// List<TdCCustInvoiceByOrdersRequest> orders = requestObject.getOrders();
//
// TdCCustInvoiceHis recordo = new TdCCustInvoiceHis();
// BeanUtils.copyProperties(requestObject, recordo);
//
// if(CollectionUtil.isNotEmpty(orders)){
// //对订单根据类型进行分类
// Map<Integer, List<TdCCustInvoiceByOrdersRequest>> aMap = new HashMap<>();
// aMap = orders.stream().collect(Collectors.groupingBy(TdCCustInvoiceByOrdersRequest::getPayOrderType));
// /**1.校验是否开票***/
// Long invoiceTotalFee = 0L;
// for(Integer payOrderType :aMap.keySet()){
// //校验是否已经开票
// checkInvoiced(aMap, payOrderType);
// }
// /**2.比较开票金额*/
// QueryPayOrderListsReq requestQP = new QueryPayOrderListsReq();
// requestQP.setCustId(requestObject.getCustId());
// List<String> orderIds = orders.stream().map(item->item.getRltOrderId()).collect(Collectors.toList());
// requestQP.setOrderIds(orderIds);
// requestQP.setSysCode(BasicEnum.SYS_CODE.getValue());
// logger.info("queryRntPayOrderForInvoice 入参对象requestQP:{}", requestQP);
// BizResult<List<PayOrderForInvoiceDTO>> responseResult = payOrderQueryService.queryRntPayOrderForInvoice(requestQP);
// if(responseResult.isSuccess()&&CollectionUtil.isNotEmpty(responseResult.getData())){
// recordo.setOrgId(Long.valueOf(responseResult.getData().get(0).getOrgId()));//放入组织id
// for(PayOrderForInvoiceDTO dto : responseResult.getData()){
// invoiceTotalFee += dto.getOrderActFee();
// }
// }
// if (0 != new BigDecimal(invoiceTotalFee).compareTo(requestObject.getInvoiceTotalFee())) {
// logger.info("insertCustInvoiceHistoryDetailInfo--手机端开票金额计算有误 ");
// throw new BizException(ErrorType.APP_ERROR, "开票金额计算有误");
// }
// /**3.进行开票***/
// for(Integer payOrderType :aMap.keySet()){
// logger.info("开票更改开票状态: "+JSONObject.toJSONString(aMap.get(payOrderType)));
// /**临停费用*/
// if(PayOrderTypeEnum.PARK_PAY.value().equals(payOrderType)||
// PayOrderTypeEnum.SHAREBERTH_PAY.value().equals(payOrderType)||
// PayOrderTypeEnum.PARKPRE_PAY.value().equals(payOrderType)){
// for(TdCCustInvoiceByOrdersRequest ordersRequest :aMap.get(payOrderType)) {
// /**临停*/
// // 更新已开发票状态
// logger.info("临停车,开票更改开票状态: "+JSONObject.toJSONString(ordersRequest));
// UpdateOrderParkByOrderIdRequest orderIdRequest = new UpdateOrderParkByOrderIdRequest();
// orderIdRequest.setOrderId(ordersRequest.getRltOrderId());
// orderIdRequest.setInvoiceState(InvoiceStateEnum.YES.getValue());
// orderIdRequest.setSysCode(BasicEnum.SYS_CODE.getValue());
// rntParkOrderOperService.updateOrderParkByOrderId(orderIdRequest);
// hisDetailList = this.getCustInvoiceHisDetail(requestObject,ordersRequest,hisDetailList);
// }
// recordo.setInvoiceBigType(OrderBigTypeEnum.PARK_ORDER.value());
// }else if(PayOrderTypeEnum.PARKBACK_PAY.value().equals(payOrderType)){
// /**欠费补交*/
// for(TdCCustInvoiceByOrdersRequest ordersRequest :aMap.get(payOrderType)) {
// /**欠费补交*/
// // 更新已开发票状态
// UpdateOrderBackByOrderIdRequest orderIdRequest = new UpdateOrderBackByOrderIdRequest();
// orderIdRequest.setOrderId(ordersRequest.getRltOrderId());
// orderIdRequest.setInvoiceState(InvoiceStateEnum.YES.getValue());
// orderIdRequest.setSysCode(BasicEnum.SYS_CODE.getValue());
// backParkOrderOperService.updateBackOrderByOrderId(orderIdRequest);
// hisDetailList = this.getCustInvoiceHisDetail(requestObject,ordersRequest,hisDetailList);
// }
// recordo.setInvoiceBigType(OrderBigTypeEnum.PARK_ORDER.value());
//
// }else if(PayOrderTypeEnum.VIP_CARD_ADDED.value().equals(payOrderType)||
// PayOrderTypeEnum.VIP_CARD_RENEW.value().equals(payOrderType) ||
// PayOrderTypeEnum.AREA_VIP_CARD_ADDED.value().equals(payOrderType) ||
// PayOrderTypeEnum.AREA_VIP_CARD_CHANGE_CARNUM.value().equals(payOrderType) ||
// PayOrderTypeEnum.TIME_VIP_CARD_ADDED.value().equals(payOrderType) ||
// PayOrderTypeEnum.TIME_VIP_CARD_CHANGE_CARNUM.value().equals(payOrderType))
// {
// for(TdCCustInvoiceByOrdersRequest ordersRequest :aMap.get(payOrderType)) {
// /**会员卡*/
// // 更新是否已开发票状态
// UpdateVipcardDetailReq updateVipcardDetailReq = new UpdateVipcardDetailReq();
// updateVipcardDetailReq.setOrderId(ordersRequest.getRltOrderId());
// updateVipcardDetailReq.setInvoiceState(InvoiceStateEnum.YES.getValue());
// updateVipcardDetailReq.setSysCode(BasicEnum.SYS_CODE.getValue());
// vipCardOrderOperService.updateVipCardDetailByOrderId(updateVipcardDetailReq);
// hisDetailList = this.getCustInvoiceHisDetail(requestObject,ordersRequest,hisDetailList);
// }
// recordo.setInvoiceBigType(OrderBigTypeEnum.VIP_ORDER.value());
//
// }else if(PayOrderTypeEnum.BALANCE_PAY.value().equals(payOrderType)) {
// for(TdCCustInvoiceByOrdersRequest ordersRequest :aMap.get(payOrderType)) {
// /**账户充值*/
// // 更新是否已开发票状态
// OrderRechargeUpdateRequest orderRechargeUpdateRequest = new OrderRechargeUpdateRequest();
// orderRechargeUpdateRequest.setOrderId(ordersRequest.getRltOrderId());
// orderRechargeUpdateRequest.setInvoiceState(InvoiceStateEnum.YES.getValue());
// orderRechargeUpdateRequest.setSysCode(BasicEnum.SYS_CODE.getValue());
// rechargeOrderOperService.updateOrderRechargeByOrderIdOrId(orderRechargeUpdateRequest);
// hisDetailList = this.getCustInvoiceHisDetail(requestObject,ordersRequest,hisDetailList);
// }
// recordo.setInvoiceBigType(OrderBigTypeEnum.RECHARGE_ORDER.value());
//
// }
// }
// } else {
// logger.info("openTicketForCustInvoiceHisInfo--requestObject.getOrders 传入参数订单列表为空 ");
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
// //查询销方信息
// TdCCustInvoiceSaleQueryRequest saleRequest = new TdCCustInvoiceSaleQueryRequest();
// saleRequest.setSysCode(BasicEnum.SYS_CODE.getValue());
// saleRequest.setOrgId(recordo.getOrgId());
// // 新增了税号,根据税号获取对应的销方信息 by zegnqc
// saleRequest.setSaleTaxids(Collections.singletonList(requestObject.getSaleTaxid()));
// if (null == recordo.getOrgId()) {
// throw new BizException(ErrorType.PARAMM_NULL, "获取销方信息,组织id为空!");
// }
// List<TdCCustInvoiceSale> saleList = tdCCustInvoiceSaleDao.queryTdCCustInvoiceSale(saleRequest);
// if(CollectionUtils.isEmpty(saleList)){
// throw new BizException(ErrorType.BIZ_ERROR, "根据当前组织编码["+recordo.getOrgId()+"],未查询到相应的销方信息!");
// }
//
// tdCCustInvoiceHisDTO.setCustInvoiceHisDetailDTOList(hisDetailList);
// TdCCustInvoiceSale saleInfo = saleList.get(0);
// // 历史开票插入
// recordo.setInvoiceTaxRate(new BigDecimal(saleInfo.getItemTaxRate()));
// //总价除以(1+9%)乘9%
// recordo.setInvoiceTaxFee(recordo.getInvoiceTotalFee() == null ? new BigDecimal("0") :
// ((recordo.getInvoiceTotalFee()).multiply(recordo.getInvoiceTaxRate()))
// );
// BigDecimal a = recordo.getInvoiceTaxRate().add(new BigDecimal(1));
// recordo.setInvoiceTaxFee(recordo.getInvoiceTaxFee().divide(a,2, RoundingMode.HALF_UP)
// );
// recordo.setInvoiceTotalFee(recordo.getInvoiceTotalFee());
// recordo.setInvoiceFee(recordo.getInvoiceTotalFee() == null ? new BigDecimal("0") :
// (recordo.getInvoiceTotalFee()).subtract(recordo.getInvoiceTaxFee()));
// //放入销方信息
// recordo.setSaleAddress(saleInfo.getAddress());
// recordo.setSaleBankName(saleInfo.getSaleBankName());
// recordo.setSaleCardNo(saleInfo.getSaleBankNo());
// recordo.setSaleName(saleInfo.getSaleName());
// recordo.setSaleTaxid(saleInfo.getSaleTaxid());
// //放入开票人、复核人、收款人
// recordo.setChecker(saleInfo.getChecker());
// recordo.setPryee(saleInfo.getPryee());
// recordo.setDrawer(saleInfo.getDrawer());
// if(StringUtils.isEmpty(recordo.getTicketContent())){
// recordo.setTicketContent(saleInfo.getItemName());
// }
// recordo.setTerminalSource(requestObject.getTerminalSource());
// logger.info("---begin--openTicketForCustInvoiceHisInfo记录客户开发票历史信息,入参={}", JSONObject.toJSON(recordo));
// recordo.setId(custInvoiceHisDao.insertCustInvoiceHistoryInfo(recordo));
// BeanUtils.copyProperties(recordo, tdCCustInvoiceHisDTO);
//
// //新增开票条目
// List<TdCCustInvoiceHisItem> items = new ArrayList<>();
// TdCCustInvoiceHisItem item = new TdCCustInvoiceHisItem();
// BeanUtils.copyProperties(recordo, item);
// item.setInvoiceId(recordo.getInvoiceId());
// item.setItemName(saleInfo.getItemName());
// item.setItemCode(saleInfo.getItemCode());
// item.setLineType(InvoiceItemEnum.LINETYPE);//0:正常行1:折扣行2:被折扣行
// item.setTaxRate(saleInfo.getItemTaxRate());
// item.setUnit(InvoiceItemEnum.UNIT);
// item.setSpec(InvoiceItemEnum.SPEC);
// item.setQuantity(1D);
// item.setTaxPrice(recordo.getInvoiceTotalFee() == null?0:(recordo.getInvoiceTotalFee().doubleValue())/100);
// item.setTotalAmount(recordo.getInvoiceTotalFee() == null?0:(recordo.getInvoiceTotalFee().doubleValue())/100);
// item.setYhzcbs("0");//税收优惠政策标志0:不使用 1:使用
// items.add(item);
// custInvoiceHisDao.insertCustInvoiceHistorItems(items );
// return new BizResult<TdCCustInvoiceHisDTO> (tdCCustInvoiceHisDTO);
// }
//
// private List<TdCCustInvoiceHisDetailDTO> getCustInvoiceHisDetail(TdCCustInvoiceHisRequest requestObject,
// TdCCustInvoiceByOrdersRequest ordersRequest,List<TdCCustInvoiceHisDetailDTO> hisDetailList){
// // 新增已开发票详情
// TdCCustInvoiceHisDetail record = new TdCCustInvoiceHisDetail();
// record.setOrderId(ordersRequest.getRltOrderId());
// record.setInvoiceId(requestObject.getInvoiceId());
// record.setOrderType(ordersRequest.getPayOrderType());
// record.setOrderActFee(new BigDecimal(ordersRequest.getOrderActFee()));
// record.setOrderPayedFee(new BigDecimal(ordersRequest.getOrderActFee()));
// record.setOrderTotalFee(new BigDecimal(ordersRequest.getOrderTotalFee()));
// record.setOrderDate(ordersRequest.getCreateDate());
// record.setDataState(1);
// record.setCreateDate(new Date());
// record.setCarNumber(ordersRequest.getCarNumber());
// record.setPlNo(ordersRequest.getPlNo());
// record.setPlName(ordersRequest.getPlName());
// record.setId(custInvoiceHisDetailDao.insertCustInvoiceHistoryDetailInfo(record));
//
// TdCCustInvoiceHisDetailDTO tdCCustInvoiceHisDetailDTO = new TdCCustInvoiceHisDetailDTO();
// BeanUtils.copyProperties(record, tdCCustInvoiceHisDetailDTO);
//
// hisDetailList.add(tdCCustInvoiceHisDetailDTO);
//
// return hisDetailList;
// }
//
// private List<TdCCustInvoiceHisDetailDTO> createCustInvoiceHisDetail(TdCCustInvoiceHisRequest requestObject,TdCCustInvoiceByOrdersRequest ordersRequest,List<TdCCustInvoiceHisDetailDTO> hisDetailList){
// // 新增已开发票详情
// TdCCustInvoiceHisDetail record = new TdCCustInvoiceHisDetail();
// record.setOrderId(ordersRequest.getRltOrderId());
// record.setInvoiceId(requestObject.getInvoiceId());
// record.setOrderType(ordersRequest.getPayOrderType());
// record.setOrderActFee(new BigDecimal(ordersRequest.getOrderActFee()));
// record.setOrderPayedFee(new BigDecimal(ordersRequest.getOrderActFee()));
// record.setOrderTotalFee(new BigDecimal(ordersRequest.getOrderTotalFee()));
// record.setOrderDate(ordersRequest.getCreateDate());
// record.setDataState(1);
// record.setCreateDate(new Date());
// record.setCarNumber(ordersRequest.getCarNumber());
// record.setPlNo(ordersRequest.getPlNo());
// record.setPlName(ordersRequest.getPlName());
// if(requestObject.getOptState()==1){
// record.setId(custInvoiceHisDetailDao.insertCustInvoiceHistoryDetailInfo(record));
// }
// TdCCustInvoiceHisDetailDTO tdCCustInvoiceHisDetailDTO = new TdCCustInvoiceHisDetailDTO();
// BeanUtils.copyProperties(record, tdCCustInvoiceHisDetailDTO);
//
// hisDetailList.add(tdCCustInvoiceHisDetailDTO);
//
// return hisDetailList;
// }
//
// @Override
// public BizResult<PageBean<TdCCustInvoiceHisDTO>> queryCustInvoiceHisForPage(TdCCustInvoiceHisQueryRequest request) {
// PageBean<TdCCustInvoiceHisDTO> pageBean = new PageBean<>();
// PageInfo<TdCCustInvoiceHis> pageInfo = custInvoiceHisDao.queryCustInvoiceHisForPage(request);
// if(pageInfo!=null){
// PageBeanUtil.copyProperties(pageInfo, pageBean, TdCCustInvoiceHisDTO.class);
//
// }
// return new BizResult<>(pageBean);
// }
//
// @Override
// public BizResult<TdCCustInvoiceHisDTO> queryCustInvoiceHisById(TdCCustInvoiceHisQueryRequest request) {
// TdCCustInvoiceHisDTO dto = custInvoiceHisDao.queryCustInvoiceHisById(request);
// return new BizResult<>(dto);
// }
//
// @Override
// public BizResult<Boolean> openInvoiceRecordTest(TdCCustInvoiceHisRequest request) throws RemoteException, JAXBException {
// InvoInfo invoInfo = new InvoInfo();
// invoInfo.setSwno("911390449563895037952");
// invoInfo.setSaleTax("110101999999446");
// invoInfo.setCustName("中兴-测试");
// Orders orderList = new Orders();
// List<Order> orders = new ArrayList<Order>();
// Order order = new Order();
// order.setBillNo("B10001");
// Items itemList = new Items();
// List<item> items = new ArrayList<>();
// item item = new item();
// item.setKce(124.3D);
// items.add(item);
// items.add(item);
// itemList.setItem(items);
// order.setItems(itemList);
//
// orders.add(order);
// orders.add(order);
//
// orderList.setOrder(orders);
// invoInfo.setOrders(orderList);
// String xml = XMLHelper.converTomXml(invoInfo);
// logger.info("调用电子发票接口开票入参:{}",invoInfo);
// ZKInvoiceService zkInvoiceService = this.getEInvoiceServiceBean("http://218.249.166.20:8113","eisp-zk/ws/zkiService?wsdl");
// String result = zkInvoiceService.submitEInvoiceInfo(xml);
// ReturnMsg returnMsg = XMLHelper.converyToJavaBean(result,ReturnMsg.class );
// logger.info("调用电子发票接口开票返回:{}",JSONObject.toJSON(returnMsg));
// return new BizResult<>(true);
// }
//
// @Override
// @Transactional
// public BizResult<Boolean> openInvoiceRecord(TdCCustInvoiceHisRequest request) {
// TdCCustInvoiceHis record = new TdCCustInvoiceHis();
// List<TdCCustInvoiceHisItem> items = new ArrayList<>();
// BeanUtils.copyProperties(request, record);
// record.setInvoiceId(SequenceUtil.getNextId(SequenceTypeEnum.INVOICE_ID));
// record.setDataState(DataStatusEnum.DATA_STATUS_VALID.value());
// record.setCustId("CLOUD1001");
// record.setCreateDate(new Date());
// List<TdCCustInvoiceHisItemDTO> itemDTOs = request.getCustInvoiceHisItemDTOs();
// ListCopyUtil.listCopyProperties(itemDTOs, items, TdCCustInvoiceHisItem.class);
// Long result = custInvoiceHisDao.insertCustInvoiceHistoryInfo(record);
// if(result <= 0){
// throw new BizException(ErrorType.BIZ_ERROR,"新增电子发票失败!");
// }
// for (TdCCustInvoiceHisItem item : items) {
// item.setCreateDate(record.getCreateDate());
// item.setCreateEmpid(record.getCreateEmpid());
// item.setDataState(DataStatusEnum.DATA_STATUS_VALID.value());
// item.setInvoiceId(record.getInvoiceId());
// item.setOrgId(record.getOrgId());
// Boolean i = custInvoiceHisDao.insertCustInvoiceHistorItems(items);
// if(!i){
// throw new BizException(ErrorType.BIZ_ERROR,"新增电子发票条目失败!");
// }
// }
// return new BizResult<>(result>0);
// }
//
// /**
// * 获取金税发票接口bean
// * @return
// * 2019年8月12日 wangfei
// */
// private ZKInvoiceService getEInvoiceServiceBean(String jinshuiWsdl,String serviceUrl){
// // 接口地址
// //http://218.249.166.20:8113/eisp-zk/ws/zkiService?wsdl
// String address = "http://" + jinshuiWsdl + "/"+serviceUrl;
// // 代理工厂
// JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
// // 设置代理地址
// jaxWsProxyFactoryBean.setAddress(address);
// // 设置接口类型
// jaxWsProxyFactoryBean.setServiceClass(ZKInvoiceService.class);
// // 创建一个代理接口实现
// ZKInvoiceService zkInvoiceService = (ZKInvoiceService) jaxWsProxyFactoryBean.create();
// return zkInvoiceService;
// }
//
// @Override
// public BizResult<Boolean> openInvoiceListByOrderIds(TdCCustInvoiceHisRequest request) throws RemoteException, JAXBException {
// TdCCustInvoiceSaleQueryRequest saleRequest = new TdCCustInvoiceSaleQueryRequest();
// saleRequest.setSysCode(BasicEnum.SYS_CODE.getValue());
// saleRequest.setOrgId(request.getOrgId());
// // 增加税号,后面根据税号查询对应的销方信息;by zengqc 2022-03-29
// if(!StringUtils.isEmpty(request.getSaleTaxid())){
// saleRequest.setSaleTaxids(Collections.singletonList(request.getSaleTaxid()));
// }
//
// if(CollectionUtils.isEmpty(request.getOrderIds())){
// throw new BizException(ErrorType.PARAMM_NULL,"订单编号");
// }
// if(StringUtils.isEmpty(request.getOrgId())){
// throw new BizException(ErrorType.PARAMM_NULL,"组织编号");
// }
// List<TdCCustInvoiceHisDTO> invoices = this.queryCustInvoiceHisListByInvoiceIds(request.getOrderIds());
// if(CollectionUtils.isEmpty(invoices)){
// throw new BizException(ErrorType.BIZ_ERROR,"未查询到待开票订单信息!");
// }
// //根据组织查询销方信息
// //查询销方信息
// if(invoices.get(0).getOrgId() != null){
// saleRequest.setOrgId(invoices.get(0).getOrgId());
// }
//
// List<TdCCustInvoiceSale> saleList = tdCCustInvoiceSaleDao.queryTdCCustInvoiceSale(saleRequest);
// if(CollectionUtils.isEmpty(saleList)){
// throw new BizException(ErrorType.BIZ_ERROR, "根据当前组织编码["+request.getOrgId()+"],未查询到相应的销方信息!");
// }
// TdCCustInvoiceSale saleInfo = saleList.get(0);
// String jinshuiWsdl = saleInfo.getServerIp()+":"+saleInfo.getServerPort();
// String serviceUrl = saleInfo.getWsdlUrl();
// if(org.apache.commons.lang3.StringUtils.isBlank(serviceUrl)){
// serviceUrl = "eisp-zx/ws/zkiService?wsdl";
// }
// for (TdCCustInvoiceHisDTO i : invoices) {
//
// if(i.getTerminalSource()==4){
// TdCCustInvoiceHis record = new TdCCustInvoiceHis();
// record.setCustName(request.getCustName());
// record.setInvoiceType(request.getInvoiceType());
// record.setCustTaxid(request.getCustTaxid());
// record.setCustEmail(request.getCustEmail());
// record.setCustBankName(request.getCustBankName());
// record.setCustPhone(request.getCustPhone());
// record.setCustCardNo(request.getCustCardNo());
// record.setCustAddress(request.getCustAddress());
// record.setRemark(request.getRemark());
// record.setInvoiceId(i.getInvoiceId());
// custInvoiceHisDao.updateInvioceByInvoiceId(record);
// }
// //开始调用接口循环开票
// // this.invoiceOpenHandle(request, i,jinshuiWsdl,serviceUrl);
// InvoiceOpenHandler invoiceOpenHandler = (InvoiceOpenHandler) SpringContextUtil.getBean(InvoiceServiceTypeEnum.InvoiceServiceTypeNameEnum.getValue(saleInfo.getServerType()).getDesc());
// BizResult<Boolean> booleanBizResult = invoiceOpenHandler.downTheInvoice(request, saleInfo);
// }
//
// //更新发票余量
// //this.updateInvoiceSaleSurplus(request.getSaleTaxid(),jinshuiWsdl,serviceUrl);
//
// return new BizResult<>(true);
// }
//
// /**
// * 更新发票余量
// * @param taxId
// * 2019年9月2日 wangfei
// * @throws RemoteException
// * @throws JAXBException
// */
// private void updateInvoiceSaleSurplus(String taxId,String jinshuiWsdl,String serviceUrl) {
//
// if(StringUtils.isEmpty(taxId)){
// return;
// }
// try{
// InvoInfo invoInfo = new InvoInfo();
// invoInfo.setSaleTax(taxId);
// String xml = XMLHelper.converTomXml(invoInfo );
// logger.info("调用电子发票余量查询接口入参:{}",xml);
// ZKInvoiceService zkInvoiceService = this.getEInvoiceServiceBean(jinshuiWsdl,serviceUrl);
// String result = zkInvoiceService.getKPYL(xml);
// logger.info("调用电子发票余量查询接口返回:{}",result);
// SYFPReturnMsg returnMsg = XMLHelper.converyToJavaBean(result,SYFPReturnMsg.class);
// if("0000".equals(returnMsg.getRETURNCODE())){
// TdCCustInvoiceSale record = new TdCCustInvoiceSale();
// record.setSaleTaxid(taxId);
// record.setInvoiceSurplusNum(returnMsg.getSYFPFS());
// tdCCustInvoiceSaleDao.updateInvoiceSaleByTaxId(record );
// }else{
// logger.error("调用电子发票余量查询接口报错:{}",result);
// }
// }catch (Exception e){
// logger.error("调用电子发票余量查询接口报错Exception:{}",e);
// }
//
// }
//
// /**
// * 开始处理开票
// * @param request
// * @param i
// * @throws RemoteException
// * @throws JAXBException
// * 2019年9月2日 wangfei
// */
// //@Transactional
//// private void invoiceOpenHandle(TdCCustInvoiceHisRequest request, TdCCustInvoiceHisDTO i,String jinshuiWsdl,String serviceUrl)
//// throws RemoteException, JAXBException {
////
//// ZKInvoiceService zkInvoiceService = this.getEInvoiceServiceBean(jinshuiWsdl,serviceUrl);
//// // 开始转换参数
//// InvoInfo invoInfo = new InvoInfo();
//// invoInfo.setSwno(i.getInvoiceId());
//// invoInfo.setSaleTax(i.getSaleTaxid());
////// invoInfo.setCustName(i.getSaleName());
//// if(("0").equals(i.getInvoiceType())){//个人
//// invoInfo.setCustName(i.getCustName());
//// invoInfo.setCustType("03");
//// }else if(("1").equals(i.getInvoiceType())){//企业
//// invoInfo.setCustTaxNo(i.getCustTaxid());
//// invoInfo.setCustName(i.getCustName());
//// invoInfo.setCustType("01");
//// }else if(("2").equals(i.getInvoiceType())){//表示非企业性质单位
//// invoInfo.setCustTaxNo(i.getCustTaxid());
//// invoInfo.setCustName(i.getCustName());
//// invoInfo.setCustType("02");
//// }
//// invoInfo.setCustAddr(i.getCustAddress());
////// invoInfo.setCustTelephone(i.getCustPhone());
//// invoInfo.setCustPhone(i.getCustPhone());
//// invoInfo.setCustEmail(i.getCustEmail());
//// invoInfo.setCustBankAccount(i.getCustBankName() == null ? "" : i.getCustBankName()
//// + (i.getCustCardNo() == null ? "" : i.getCustCardNo()));
////
//// invoInfo.setInvType(3);
//// invoInfo.setBillDate(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
//// invoInfo.setBillType(1);
//// invoInfo.setSpecialRedFlag("0");
//// invoInfo.setOperationCode("10");
//// //设置收款人、复核人、开票人
//// if(org.apache.commons.lang3.StringUtils.isBlank(i.getDrawer())){
//// invoInfo.setKpy(request.getCreateEmpid());
//// }else{
//// invoInfo.setKpy(i.getDrawer());
//// }
//// invoInfo.setFhr(i.getChecker());
//// invoInfo.setSky(i.getPryee());
//// invoInfo.setInvoMemo(i.getRemark());
////
//// Orders orderList = new Orders();
//// List<Order> orders = new ArrayList<Order>();
//// Order order = new Order();
//// order.setBillNo("B"+i.getInvoiceId());
//// Items itemList = new Items();
//// List<item> items = new ArrayList<>();
//// for (TdCCustInvoiceHisItemDTO m : i.getCustInvoiceHisItemDTOs()) {
//// item item = new item();
//// item.setName(m.getItemName());
//// item.setCode(m.getItemCode());
//// item.setLineType(m.getLineType());
//// item.setSpec(m.getSpec());
//// item.setUnit(m.getUnit());
//// item.setTaxRate(m.getTaxRate());
//// item.setQuantity(m.getQuantity());
//// item.setTaxPrice(m.getTaxPrice());
//// item.setTotalAmount(m.getTotalAmount());
//// item.setYhzcbs(m.getYhzcbs());
//// item.setYhzcnr(m.getYhzcnr());
//// items.add(item);
//// }
//// itemList.setItem(items);
//// order.setItems(itemList);
//// orders.add(order);
//// orderList.setOrder(orders);
//// invoInfo.setOrders(orderList);
//// String xml = XMLHelper.converTomXml(invoInfo);
//// logger.info("调用电子发票接口开票入参:{}",xml);
//// String result = zkInvoiceService.submitEInvoiceInfo(xml);
//// logger.info("调用电子发票接口开票返回:{}",result);
//// ReturnMsg returnMsg = XMLHelper.converyToJavaBean(result,ReturnMsg.class);
//// if("0000".equals(returnMsg.getMsgCode())){
//// //开票成功 调用修改接口
//// TdCCustInvoiceHis record = new TdCCustInvoiceHis();
//// record.setInvoiceId(i.getInvoiceId());
//// record.setModfiyEmpid(request.getModfiyEmpid());
//// record.setInvoiceState(InvoiceStateEnum.ALREADY_OPEN_INVOICE.getValue()+"");
//// record.setMsg(returnMsg.getMsg());
////// record.setDrawerId(Long.valueOf(request.getModfiyEmpid()));
////// record.setDrawer(request.getCreateEmpid());
//// record.setInvoiceDate(new Date());
//// custInvoiceHisDao.updateInvioceByInvoiceId(record);
////// //开始查询开票后的信息,下载电子发票
////// Boolean down = this.downTheInvoice(i);
////// if(!down){
////// throw new BizException(ErrorType.BIZ_ERROR,"开票下载失败!");
////// }
////
//// }else if("9106".equals(returnMsg.getMsgCode())){
//// //重复开票
//// TdCCustInvoiceHis record = new TdCCustInvoiceHis();
//// record.setInvoiceId(i.getInvoiceId());
//// record.setModfiyEmpid(request.getModfiyEmpid());
//// record.setInvoiceState(InvoiceStateEnum.REPEATED_INVOICING.getValue()+"");
//// record.setMsg(returnMsg.getMsg());
////// record.setDrawerId(Long.valueOf(request.getModfiyEmpid()));
////// record.setDrawer(request.getCreateEmpid());
//// custInvoiceHisDao.updateInvioceByInvoiceId(record);
//// }else {
//// //开票错误
//// TdCCustInvoiceHis record = new TdCCustInvoiceHis();
//// record.setInvoiceId(i.getInvoiceId());
//// record.setModfiyEmpid(request.getModfiyEmpid());
//// record.setInvoiceState(InvoiceStateEnum.INVOICE_PARAM_NOT_VALID.getValue()+"");
//// record.setMsg(returnMsg.getMsg());
////// record.setDrawerId(Long.valueOf(request.getModfiyEmpid()));
////// record.setDrawer(request.getCreateEmpid());
//// custInvoiceHisDao.updateInvioceByInvoiceId(record);
////
//// }
//// logger.info("调用电子发票接口开票返回:{}",JSONObject.toJSON(returnMsg));
//// }
//
// /**
// * 下载电子发票(单个的)
// * @param
// * @throws RemoteException
// * @throws JAXBException
// * 2019年9月2日 wangfei
// */
// public BizResult<Boolean> downTheInvoice(TdCCustInvoiceHisRequest request) throws RemoteException, JAXBException {
// //获取销方信息
// TdCCustInvoiceSaleQueryRequest saleRequest = new TdCCustInvoiceSaleQueryRequest();
// saleRequest.setSysCode(BasicEnum.SYS_CODE.getValue());
// saleRequest.setOrgId(request.getOrgId());
// // 补充根据税号查询销方信息
// saleRequest.setSaleTaxids(Collections.singletonList(request.getSaleTaxid()));
// List<TdCCustInvoiceSale> saleList = tdCCustInvoiceSaleDao.queryTdCCustInvoiceSale(saleRequest);
// if(CollectionUtils.isEmpty(saleList)){
// throw new BizException(ErrorType.BIZ_ERROR, "根据当前组织编码["+request.getOrgId()+"],未查询到相应的销方信息!");
// }
// TdCCustInvoiceSale saleInfo = saleList.get(0);
// String jinshuiWsdl = saleInfo.getServerIp()+":"+saleInfo.getServerPort();
// String serviceUrl = saleInfo.getWsdlUrl();
// if(org.apache.commons.lang3.StringUtils.isBlank(serviceUrl)){
// serviceUrl = "eisp-zx/ws/zkiService?wsdl";
// }
// ZKInvoiceService zkInvoiceService = this.getEInvoiceServiceBean(jinshuiWsdl,serviceUrl);
// for (String orderId : request.getOrderIds()) {
// InvoInfo info = new InvoInfo();
// info.setSwno(orderId);
// info.setSaleTax(request.getSaleTaxid());
// String xml = XMLHelper.converTomXml(info);
// logger.info("调用电子发票下载接口入参:{}",xml);
// String result = zkInvoiceService.splitDownloadEInvoiceInfo(xml);
// logger.info("调用电子发票下载接口返回:{}",result);
// DownloadReturnMsg returnMsg = XMLHelper.converyToJavaBean(result,DownloadReturnMsg.class);
// logger.info("调用电子发票下载接口返回:{}",JSONObject.toJSON(returnMsg));
// if("0000".equals(returnMsg.getReturnMsg().getMsgCode())){
// TdCCustInvoiceHis record = new TdCCustInvoiceHis();
// record.setInvoiceId(orderId);
// record.setInvoiceState(InvoiceStateEnum.ALREADY_DOWNLOAD.getValue()+"");
// record.setMsg(returnMsg.getReturnMsg().getMsg());
// record.setInvoiceCode(returnMsg.getFpMsgs().getFpMsg().get(0).getFpdm());
// record.setInvoiceNumber(returnMsg.getFpMsgs().getFpMsg().get(0).getFphm());
// record.setHjbhsje(returnMsg.getFpMsgs().getFpMsg().get(0).getHjbhsje());
// record.setKphjse(returnMsg.getFpMsgs().getFpMsg().get(0).getKphjse());
// record.setPdfMd5(returnMsg.getFpMsgs().getFpMsg().get(0).getPdfMd5());
// record.setInvoiceUrl(returnMsg.getFpMsgs().getFpMsg().get(0).getPdf_url());
// record.setModfiyDate(new Date());
// custInvoiceHisDao.updateInvioceByInvoiceId(record);
// }else{
// //下载错误
// TdCCustInvoiceHis record = new TdCCustInvoiceHis();
// record.setInvoiceId(orderId);
// record.setInvoiceState(InvoiceStateEnum.DOWN_FAILD.getValue()+"");
// record.setMsg(returnMsg.getReturnMsg().getMsg());
// custInvoiceHisDao.updateInvioceByInvoiceId(record);
// return new BizResult<>(ErrorType.BIZ_ERROR,returnMsg.getReturnMsg().getMsg(),false);
// }
// }
// return new BizResult<>(true);
//
// }
//
// @Override
// public BizResult<TdCCustInvoiceHisStatisticsDTO> queryElectronicInvoiceBillingStatistics(InvoiceStatisticsRequest request) {
// TdCCustInvoiceHisStatisticsDTO tdCCustInvoiceHisStatisticsDTO = new TdCCustInvoiceHisStatisticsDTO();
// tdCCustInvoiceHisStatisticsDTO.setCustName(request.getCustName());
// tdCCustInvoiceHisStatisticsDTO.setSaleName(request.getSaleName());
// tdCCustInvoiceHisStatisticsDTO.setReportDate(new Date());
// tdCCustInvoiceHisStatisticsDTO.setExportDate(tdCCustInvoiceHisStatisticsDTO.getReportDate());
// List<RateDataDTO> rateDataDTOS = tdCCustInvoiceHisQueryInnerService.queryRateData(request);
// if (!CollectionUtils.isEmpty(rateDataDTOS)) {
// tdCCustInvoiceHisStatisticsDTO.setRateData(rateDataDTOS);
// }
// List<StatisticsDataDTO> statisticsDataDTOS = tdCCustInvoiceHisQueryInnerService.queryStatisticsData(request);
// if (!CollectionUtils.isEmpty(statisticsDataDTOS)) {
// tdCCustInvoiceHisStatisticsDTO.setCustTaxid(statisticsDataDTOS.get(0).getCustTaxID());
// statisticsDataDTOS.stream().forEach(statisticsDataDTO ->
// tdCCustInvoiceHisStatisticsDTO.setTotaldata(
// tdCCustInvoiceHisStatisticsDTO.getTotaldata() == null ? 0 : tdCCustInvoiceHisStatisticsDTO.getTotaldata()
// + statisticsDataDTO.getAmount()));
// tdCCustInvoiceHisStatisticsDTO.setStatisticsData(statisticsDataDTOS);
// }
// return new BizResult<>(tdCCustInvoiceHisStatisticsDTO);
// }
//
// @Override
// public BizResult<Boolean> resendInvoiceMail(TdCCustInvoiceHisRequest request, String mailTemplet) throws UnsupportedEncodingException {
// TdCCustInvoiceHisDTO invoice = custInvoiceHisDao.queryCustInvoiceHisByInvoiceId(request.getInvoiceId());
// if(!StringUtils.isEmpty(request.getCustEmail())){
// invoice.setCustEmail(request.getCustEmail());
// }
// //查询开票服务器信息
// if(invoice == null || StringUtils.isEmpty(invoice.getInvoiceUrl())){
// logger.error("开票信息错误");
// throw new AppException(AppErrorEnum.APP_INVOICEURLNOTNULL_ERROR);
// }
// TdCCustInvoiceSaleQueryRequest saleRequest = new TdCCustInvoiceSaleQueryRequest();
// saleRequest.setOrgId(request.getOrgId());
// saleRequest.setSysCode(BasicEnum.SYS_CODE.getValue());
//
// // 补充根据税号查询销方信息 by zengqc 2022-03-29
// if(!StringUtils.isEmpty(request.getSaleTaxid())){
// saleRequest.setSaleTaxids(Collections.singletonList(request.getSaleTaxid()));
// }
// List<TdCCustInvoiceSale> sales = tdCCustInvoiceSaleDao.queryTdCCustInvoiceSale(saleRequest);
// if(CollectionUtils.isEmpty(sales)){
// logger.error("根据当前orgId["+request.getOrgId()+"]没有查询到相应的开票服务器信息,请及时添加!saleRequest={}", JSONObject.toJSON(saleRequest));
// throw new AppException(AppErrorEnum.APP_UNGETSERVER_ERROR);
// }
// TdCCustInvoiceSaleDTO saleDTO = new TdCCustInvoiceSaleDTO();
// BeanUtils.copyProperties(sales.get(0), saleDTO);
// //发邮件
// if(saleDTO.getMessagePushSwitch() == null || 0 == (saleDTO.getMessagePushSwitch())){
// logger.error("销方邮箱推送开关未开启,请联系工作人员!");
// throw new AppException(AppErrorEnum.APP_MAILPUSHCLOSE_ERROR);
// }
// //查询开发件箱
// TdCCustInvoiceMail mail = tdCCustInvoiceMailDao.queryTheLessMailByOrgId(request.getOrgId());
// if(mail == null || mail.getId() == null){
// logger.error("销方邮箱信息未查询到,请联系工作人员!");
// logger.info("销方邮箱信息未查询到,请联系工作人员!");
// }
// TdCCustInvoiceMailDTO mailDTO = new TdCCustInvoiceMailDTO();
// BeanUtils.copyProperties(mail,mailDTO);
// invoice.setInvoiceTotalYuan(invoice.getInvoiceTotalFee() == null ? "0" :
// "" + ((invoice.getInvoiceTotalFee()).divide(new BigDecimal(100))));
// String[] str = mailTemplet.split("&&");
// String subject = str[0];
// String content = MsgTemplateUtil.render(str[1], invoice);
// logger.info("开始发送电子邮件!:"+invoice.getCustEmail()+subject+ content);
// mailService.sendHtmlMail(invoice.getCustEmail(), subject, content,mailDTO);
// return new BizResult<>(true);
// }
//
// /**
// * 根据发票id获取发票详情以及条目
// *
// * @param invoiceIds
// * @return 2019年8月26日 wangfei
// */
// private List<TdCCustInvoiceHisDTO> queryCustInvoiceHisListByInvoiceIds(List<String> invoiceIds) {
// List<TdCCustInvoiceHisDTO> result = new ArrayList<>();
// TdCCustInvoiceHisExample example = new TdCCustInvoiceHisExample();
// Criteria sql = example.createCriteria();
//
// sql.andInvoiceIdIn(invoiceIds);
// sql.andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
//
// List<TdCCustInvoiceHis> list = custInvoiceHisDao.queryCustInvoiceHistoryList(example);
// if (CollectionUtil.isNotEmpty(list)) {
// //查询明细
// for (TdCCustInvoiceHis i : list) {
// TdCCustInvoiceHisDTO dto = new TdCCustInvoiceHisDTO();
// BeanUtils.copyProperties(i, dto);
// TdCCustInvoiceHisItemExample example2 = new TdCCustInvoiceHisItemExample();
// example2.createCriteria().andInvoiceIdEqualTo(i.getInvoiceId()).andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
// List<TdCCustInvoiceHisItemDTO> itemDTOs = new ArrayList<>();
// List<TdCCustInvoiceHisItem> items = tdCCustInvoiceHisItemDao.queryCustInvoiceHistoryList(example2);
// if (!CollectionUtils.isEmpty(items)) {
// ListCopyUtil.listCopyProperties(items, itemDTOs, TdCCustInvoiceHisItemDTO.class);
// dto.setCustInvoiceHisItemDTOs(itemDTOs);
// }
// result.add(dto);
//
// }
// }
// return result;
// }
//
// /**
// * 获取客服电话
// * @param
// * @return
// * @Author: niueb
// * @Date: 2019/12/11
// *
// */
// private String getServicePhone(Long orgId){
// //查询缓存
// AppOrgDTO appOrgDTO = AppOrgCacheUtil.getAppOrgInfoByOrgId(orgId + "");
// if (appOrgDTO == null) {
// appOrgDTO = new AppOrgDTO();
// appOrgDTO.setIsOpenActivity(0);
// AppOrgRequest apporgRequest = new AppOrgRequest();
// apporgRequest.setOrgId(orgId + "");
// apporgRequest.setSysCode(BasicEnum.SYS_CODE.getValue());
// BizResult<AppOrgDTO> appOrgDTOBizResult = appOrgService.queryAppOrgByOrgId(apporgRequest);
// logger.info("查询APP组织:" + JSONObject.toJSON(appOrgDTOBizResult));
// if (appOrgDTOBizResult.isSuccess() && appOrgDTOBizResult.getData() != null) {
// appOrgDTO = appOrgDTOBizResult.getData();
// }
// }
// String servicePhone = appOrgDTO == null ? "" : appOrgDTO.getPhone();
// return servicePhone;
// }
//
//
// /**
// * 查询客户所有发票抬头信息
// */
// @Override
// public BizResult<List<TdCCustInvoiceinfoDTO>> queryCustInvoiceInfoListByName(QueryCustInvoiceInfoListRequest requestObject) {
// if (null == requestObject) {
// throw new BizException(ErrorType.PARAMM_NULL, "请求对象为空");
// }
//
// TdCCustInvoiceinfoExample example = new TdCCustInvoiceinfoExample();
// example.createCriteria().andInvoiceTypeEqualTo("1").andNameLike(requestObject.getName()+"%");
//
// List <TdCCustInvoiceinfo> tdCCustInvoiceinfoList = custInvoiceinfoDao.queryCustInvoiceInfoList(example);
// List <TdCCustInvoiceinfoDTO> tdCCustInvoiceinfoDTOList = null;
// if (null != tdCCustInvoiceinfoList) {
// tdCCustInvoiceinfoDTOList = JSON.parseArray(JSON.toJSONString(tdCCustInvoiceinfoList, false), TdCCustInvoiceinfoDTO.class);
// }
//
// return new BizResult <List<TdCCustInvoiceinfoDTO>> (tdCCustInvoiceinfoDTOList);
// }
//
// /**
// * APP 传过来的开票请求,一次可以包含多个停车场的记录。 如果不同的停车场绑定不同的销方,
// * 则需要根据销方,将订单分开开票, 将一开始的一个请求,分解未多个请求的list
// */
// @Override
// public BizResult<List<TdCCustInvoiceHisRequest>> splitOneToList(InvoiceHisSplitOrderRequest invoiceHisSplitOrderRequest) {
// List<TdCCustInvoiceHisRequest> invoiceHisRequestList = new ArrayList<>();
// TdCCustInvoiceHisRequest baseRequest = invoiceHisSplitOrderRequest.getRequestObject();
// // APP穿过来的待开票的所有订单记录
// List<TdCCustInvoiceByOrdersRequest> orders = invoiceHisSplitOrderRequest.getOrders();
// // 获取停车场编号去重列表
// List<String> plNos = orders.stream()
// .map(TdCCustInvoiceByOrdersRequest::getPlNo)
// .distinct()
// .collect(Collectors.toList());
//
// // 根据停车场编号获取对应的税号
// TdCCustInvoiceSaleQueryRequest request = new TdCCustInvoiceSaleQueryRequest();
// request.setOrgId(baseRequest.getOrgId());
// // 该组织下默认的销方
// TdCCustInvoiceSale defaultInvoiceSale = tdCCustInvoiceSaleDao.queryDefaultInvoiceSale(request);
// // 默认的销方税号, 找不到默认的话,设置为 “-1”
// String defaultSaleTaxId = Optional.ofNullable(defaultInvoiceSale).map(TdCCustInvoiceSale::getSaleTaxid).orElse("-1");
//
// // 根据停车场编号获取 停车场编号-税号 关联关系列表
// List<TdCCustInvoiceSaleParkRel> saleParkRelList = tdCCustInvoiceSaleParkRelDao.queryInvoiceSaleParkRelByPlNos(plNos);
//
// // 如果没有默认的销方,并且没有关联的普通销方,则直接返回空
// if (CollectionUtil.isEmpty(saleParkRelList)
// && defaultInvoiceSale == null) {
// logger.warn("没有默认的销方,并且没有关联的普通销方!!!");
// return new BizResult<>(invoiceHisRequestList);
// }
// // 停车场编号-销方税号的map
// Map<String, String> plNoTaxIdMap = saleParkRelList.stream()
// .collect(Collectors.toMap(TdCCustInvoiceSaleParkRel::getPlNo, TdCCustInvoiceSaleParkRel::getSaleTaxid, (k1, k2) -> k2));
//
// // 订单根据停车场编号填充对应的税号,方便后面的处理
// orders.forEach(order -> {
// order.setSaleTaxId(Optional.ofNullable(plNoTaxIdMap.get(order.getPlNo())).orElse(defaultSaleTaxId));
// if(order.getSaleTaxId().equals("-1")){
// logger.warn("订单未找到关联的销方数据orderId=[{}]-carNumber=[{}]-plNo=[{}]", order.getRltOrderId(), order.getCarNumber(), order.getPlNo());
// }
// });
//
//
// // KEY:销方税号 -- VALUE:关联的订单列表 MAP
// Map<String, List<TdCCustInvoiceByOrdersRequest>> saleIdOrdersMap = orders.stream()
// // 如果一个订单没有找到关联税号,也没有默认的税号,则不去开发票
// .filter(order -> !order.getSaleTaxId().equals("-1"))
// .collect(
// Collectors.toMap(
// TdCCustInvoiceByOrdersRequest::getSaleTaxId,
// order -> {
// List<TdCCustInvoiceByOrdersRequest> requestList = new ArrayList<>();
// requestList.add(order);
// return requestList;
// },
// (List<TdCCustInvoiceByOrdersRequest> v1, List<TdCCustInvoiceByOrdersRequest> v2) -> {
// v1.addAll(v2);
// return v1;
// }
// )
// );
//
//
// /*
// 每个销方下,单独拼接出来自己的订单开票请求。【invoiceTotalFee】重新根据订单计算了一遍
// APP 穿过来的开票请求,一次可以包含多个停车场的记录。 如果不同的停车场绑定不同的销方,
// 则需要根据销方,将订单分开开票。
// 所以前端传递过来的 invoiceTotalFee 总费用,查拆开以后,需要重新计算下
// */
// for(String key : saleIdOrdersMap.keySet()){
// List<TdCCustInvoiceByOrdersRequest> requestList = saleIdOrdersMap.get(key);
// if(CollectionUtil.isEmpty(requestList)){
// continue;
// }
// // 销方以及关联的订单list
// TdCCustInvoiceHisRequest temRequest = new TdCCustInvoiceHisRequest();
// BeanUtils.copyProperties(baseRequest, temRequest);
//
//
// // 重新计算 invoiceTotalFee, 拆分以后,对应的开票订单列表可能变化了,所以重新计算 invoiceTotalFee
// long invoiceTotalFee = 0L;
// for(TdCCustInvoiceByOrdersRequest order : requestList){
// invoiceTotalFee += order.getOrderActFee();
// }
//
// temRequest.setOrders(requestList);
// temRequest.setSaleTaxid(key);
// temRequest.setInvoiceTotalFee(new BigDecimal(invoiceTotalFee));
// temRequest.setInvoiceId(SequenceUtil.getNextId(SequenceTypeEnum.INVOICE_ID));
// invoiceHisRequestList.add(temRequest);
// }
//
// return new BizResult<>(invoiceHisRequestList);
// }
//}