|
@@ -38,80 +38,85 @@ public class PrintInvoiceQueryResultServiceImpl {
|
|
|
PayBaseConfigService payBaseConfigService;
|
|
|
|
|
|
@Async
|
|
|
- public void queryPrintInvoiceInfo(PayInvoiceprinted payInvoiceprinted) throws Exception {
|
|
|
+ public void queryPrintInvoiceInfo(PayInvoiceprinted payInvoiceprinted) {
|
|
|
//创建票据打印记录信息
|
|
|
- if (payInvoiceprinted.getFpqqlsh() != null && payInvoiceprinted.getFpqqlsh().length() > 0) {
|
|
|
- Thread.sleep(30 * 1000);
|
|
|
- PayEleInvoiceRequestDto payEleInvoiceRequestDto = new PayEleInvoiceRequestDto();
|
|
|
- payEleInvoiceRequestDto.setIdentity(payInvoiceprinted.getSaleIdentity());
|
|
|
- payEleInvoiceRequestDto.setFpqqlsh(new String[]{payInvoiceprinted.getFpqqlsh()});
|
|
|
- String resultString = DESDZFP.encrypt(JSON.toJSONString(payEleInvoiceRequestDto));
|
|
|
- Map<String, String> invoiceResult = new HashMap<String, String>();
|
|
|
- invoiceResult.put("order", resultString);
|
|
|
- //查询开票地址
|
|
|
+ try {
|
|
|
+ if (payInvoiceprinted.getFpqqlsh() != null && payInvoiceprinted.getFpqqlsh().length() > 0) {
|
|
|
+ //Thread.sleep(30 * 1000);
|
|
|
+ PayEleInvoiceRequestDto payEleInvoiceRequestDto = new PayEleInvoiceRequestDto();
|
|
|
+ payEleInvoiceRequestDto.setIdentity(payInvoiceprinted.getSaleIdentity());
|
|
|
+ payEleInvoiceRequestDto.setFpqqlsh(new String[]{payInvoiceprinted.getFpqqlsh()});
|
|
|
+ String resultString = DESDZFP.encrypt(JSON.toJSONString(payEleInvoiceRequestDto));
|
|
|
+ Map<String, String> invoiceResult = new HashMap<String, String>();
|
|
|
+ invoiceResult.put("order", resultString);
|
|
|
+ //查询开票地址
|
|
|
|
|
|
- List<PayBaseConfigDto> payBaseConfigDtos = payBaseConfigService.getPrintInfo("PRINT_INVOICE_QUERYURL",payInvoiceprinted.getTenantId());
|
|
|
- String invoiceUrl = "";
|
|
|
- if (payBaseConfigDtos.size() == 0) {
|
|
|
- return;
|
|
|
- } else {
|
|
|
- invoiceUrl = payBaseConfigDtos.get(0).getValue();
|
|
|
- }
|
|
|
- String invoiceInfo = HttpClientUtils.doPost(invoiceUrl, invoiceResult);
|
|
|
- PayInvoiceResultDto payInvoiceResultDto = JSON.parseObject(invoiceInfo, PayInvoiceResultDto.class);
|
|
|
- if (payInvoiceResultDto != null && payInvoiceResultDto.getList().size() > 0) {
|
|
|
- InvoicePrintInfoResult item = payInvoiceResultDto.getList().get(0);
|
|
|
- {
|
|
|
- if (item.getC_status().equals("2")) {
|
|
|
- payInvoiceprinted.setState(1);//已生成
|
|
|
- payInvoiceprinted.setOrderNo(item.getC_orderno());
|
|
|
- if (StringUtils.isNotBlank(item.getC_kprq()))
|
|
|
- payInvoiceprinted.setPrintDate(new Date(new Long(item.getC_kprq())));
|
|
|
- payInvoiceprinted.setInvoiceCode(item.getC_fpdm());
|
|
|
- payInvoiceprinted.setInvoiceNo(item.getC_fphm());
|
|
|
- payInvoiceprinted.setMessage(item.getC_msg());
|
|
|
- payInvoiceprinted.setTotalAmount(Double.valueOf(item.getC_bhsje()));
|
|
|
- payInvoiceprinted.setInvoiceAmount(Double.valueOf(item.getC_hjse()));
|
|
|
- if (StringUtils.isNotBlank(item.getC_bhsje()) && StringUtils.isNotBlank(item.getC_hjse())) {
|
|
|
- Double totalPrintAmount = Double.valueOf(item.getC_bhsje()) + Double.valueOf(item.getC_hjse());
|
|
|
- payInvoiceprinted.setTotalPrintAmount(totalPrintAmount);
|
|
|
+ List<PayBaseConfigDto> payBaseConfigDtos = payBaseConfigService.getPrintInfo("PRINT_INVOICE_QUERYURL",payInvoiceprinted.getTenantId());
|
|
|
+ String invoiceUrl = "";
|
|
|
+ if (payBaseConfigDtos.size() == 0) {
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ invoiceUrl = payBaseConfigDtos.get(0).getValue();
|
|
|
+ }
|
|
|
+ String invoiceInfo = HttpClientUtils.doPost(invoiceUrl, invoiceResult);
|
|
|
+ PayInvoiceResultDto payInvoiceResultDto = JSON.parseObject(invoiceInfo, PayInvoiceResultDto.class);
|
|
|
+ if (payInvoiceResultDto != null && payInvoiceResultDto.getList().size() > 0) {
|
|
|
+ InvoicePrintInfoResult item = payInvoiceResultDto.getList().get(0);
|
|
|
+ {
|
|
|
+ if (item.getC_status().equals("2")) {
|
|
|
+ payInvoiceprinted.setState(1);//已生成
|
|
|
+ payInvoiceprinted.setOrderNo(item.getC_orderno());
|
|
|
+ if (StringUtils.isNotBlank(item.getC_kprq()))
|
|
|
+ payInvoiceprinted.setPrintDate(new Date(new Long(item.getC_kprq())));
|
|
|
+ payInvoiceprinted.setInvoiceCode(item.getC_fpdm());
|
|
|
+ payInvoiceprinted.setInvoiceNo(item.getC_fphm());
|
|
|
+ payInvoiceprinted.setMessage(item.getC_msg());
|
|
|
+ payInvoiceprinted.setTotalAmount(Double.valueOf(item.getC_bhsje()));
|
|
|
+ payInvoiceprinted.setInvoiceAmount(Double.valueOf(item.getC_hjse()));
|
|
|
+ if (StringUtils.isNotBlank(item.getC_bhsje()) && StringUtils.isNotBlank(item.getC_hjse())) {
|
|
|
+ Double totalPrintAmount = Double.valueOf(item.getC_bhsje()) + Double.valueOf(item.getC_hjse());
|
|
|
+ payInvoiceprinted.setTotalPrintAmount(totalPrintAmount);
|
|
|
+ }
|
|
|
+ payInvoiceprinted.setCheckCode(item.getC_jym());
|
|
|
+ payInvoiceprinted.setImgUrl(item.getC_imgUrls());
|
|
|
+ payInvoiceprinted.setPdfUrl(item.getC_url());
|
|
|
+ payInvoiceprinted.setJpgUrl(item.getC_jpg_url());
|
|
|
+ payInvoiceprinted.setRemarks(item.getC_resultmsg());
|
|
|
+ payInvoiceprinted.setBuyername(item.getC_buyername());
|
|
|
+ payInvoiceprinted.setTaxnum(item.getC_taxnum());
|
|
|
+ payInvoiceprinted.setQrCode(item.getQrCode());
|
|
|
+ }
|
|
|
+ if (item.getC_status().equals("20") || item.getC_status().equals("21")) {
|
|
|
+ payInvoiceprinted.setState(0);//开票中 也标注为待生成
|
|
|
+ }
|
|
|
+ if (item.getC_status().equals("22") || item.getC_status().equals("24")) {
|
|
|
+ payInvoiceprinted.setState(4);//开票失败
|
|
|
+ }
|
|
|
+ if (item.getC_status().equals("3") || item.getC_status().equals("31")) {
|
|
|
+ payInvoiceprinted.setState(5);//已作废
|
|
|
}
|
|
|
- payInvoiceprinted.setCheckCode(item.getC_jym());
|
|
|
- payInvoiceprinted.setImgUrl(item.getC_imgUrls());
|
|
|
- payInvoiceprinted.setPdfUrl(item.getC_url());
|
|
|
- payInvoiceprinted.setJpgUrl(item.getC_jpg_url());
|
|
|
- payInvoiceprinted.setRemarks(item.getC_resultmsg());
|
|
|
- payInvoiceprinted.setBuyername(item.getC_buyername());
|
|
|
- payInvoiceprinted.setTaxnum(item.getC_taxnum());
|
|
|
- payInvoiceprinted.setQrCode(item.getQrCode());
|
|
|
- }
|
|
|
- if (item.getC_status().equals("20") || item.getC_status().equals("21")) {
|
|
|
- payInvoiceprinted.setState(0);//开票中 也标注为待生成
|
|
|
- }
|
|
|
- if (item.getC_status().equals("22") || item.getC_status().equals("24")) {
|
|
|
- payInvoiceprinted.setState(4);//开票失败
|
|
|
- }
|
|
|
- if (item.getC_status().equals("3") || item.getC_status().equals("31")) {
|
|
|
- payInvoiceprinted.setState(5);//已作废
|
|
|
}
|
|
|
+ printInvoicePrintService.update(payInvoiceprinted);
|
|
|
}
|
|
|
- printInvoicePrintService.update(payInvoiceprinted);
|
|
|
- }
|
|
|
- }
|
|
|
- //开票失败则恢复实收及蓝票的状态
|
|
|
- if (payInvoiceprinted.getInvoiceType() == 1) {//开具蓝票
|
|
|
- if (payInvoiceprinted.getState() == 4 || payInvoiceprinted.getState() == 5) {
|
|
|
- printInvoicePrintService.updateReceivedIsPrint(false, payInvoiceprinted.getPayseriesno(), payInvoiceprinted.getCustomerId());
|
|
|
}
|
|
|
- } else {//蓝票冲红 需明确状态后才更新
|
|
|
- if (payInvoiceprinted.getState() == 1) {
|
|
|
- printInvoicePrintService.updateReceivedIsPrint(false, payInvoiceprinted.getPayseriesno(), payInvoiceprinted.getCustomerId());
|
|
|
- //标记原始蓝票为已冲红 状态3
|
|
|
- PayInvoiceprinted oldPayInvoiceprinted = new PayInvoiceprinted();
|
|
|
- oldPayInvoiceprinted.setId(payInvoiceprinted.getCancelInvoiceId());
|
|
|
- oldPayInvoiceprinted.setState(3);//正常
|
|
|
- printInvoicePrintService.update(oldPayInvoiceprinted);
|
|
|
+ //开票失败则恢复实收及蓝票的状态
|
|
|
+ if (payInvoiceprinted.getInvoiceType() == 1) {//开具蓝票
|
|
|
+ if (payInvoiceprinted.getState() == 4 || payInvoiceprinted.getState() == 5) {
|
|
|
+ printInvoicePrintService.updateReceivedIsPrint(false, payInvoiceprinted.getPayseriesno(), payInvoiceprinted.getCustomerId());
|
|
|
+ }
|
|
|
+ } else {//蓝票冲红 需明确状态后才更新
|
|
|
+ if (payInvoiceprinted.getState() == 1) {
|
|
|
+ printInvoicePrintService.updateReceivedIsPrint(false, payInvoiceprinted.getPayseriesno(), payInvoiceprinted.getCustomerId());
|
|
|
+ //标记原始蓝票为已冲红 状态3
|
|
|
+ PayInvoiceprinted oldPayInvoiceprinted = new PayInvoiceprinted();
|
|
|
+ oldPayInvoiceprinted.setId(payInvoiceprinted.getCancelInvoiceId());
|
|
|
+ oldPayInvoiceprinted.setState(3);//正常
|
|
|
+ printInvoicePrintService.update(oldPayInvoiceprinted);
|
|
|
+ }
|
|
|
}
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|