|
@@ -10,6 +10,7 @@ import com.bz.smart_city.entity.pay.PayInvoiceprinted;
|
|
|
import com.bz.smart_city.service.pay.PrintInvoicePrintService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -29,6 +30,8 @@ import java.util.Map;
|
|
|
public class PrintInvoiceQueryResultServiceImpl {
|
|
|
@Autowired
|
|
|
PrintInvoicePrintService printInvoicePrintService;
|
|
|
+ @Value("${invoice.query.url}")
|
|
|
+ private String queryUrl;
|
|
|
|
|
|
@Async
|
|
|
public void queryPrintInvoiceInfo(PayInvoiceprinted payInvoiceprinted) throws Exception {
|
|
@@ -41,61 +44,60 @@ public class PrintInvoiceQueryResultServiceImpl {
|
|
|
String resultString = DESDZFP.encrypt(JSON.toJSONString(payEleInvoiceRequestDto));
|
|
|
Map<String, String> invoiceResult = new HashMap<String, String>();
|
|
|
invoiceResult.put("order", resultString);
|
|
|
- String invoiceInfo = HttpClientUtils.doPost("http://nnfpbox.nuonuocs.cn/shop/buyer/allow/ecOd/queryElectricKp.action", invoiceResult);
|
|
|
+ String invoiceInfo = HttpClientUtils.doPost(queryUrl, invoiceResult);
|
|
|
PayInvoiceResultDto payInvoiceResultDto = JSON.parseObject(invoiceInfo, PayInvoiceResultDto.class);
|
|
|
if (payInvoiceResultDto != null && payInvoiceResultDto.getList().size() > 0) {
|
|
|
- for (InvoicePrintInfoResult item : payInvoiceResultDto.getList()) {
|
|
|
+ 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.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(2);//开票中
|
|
|
- break;
|
|
|
+ payInvoiceprinted.setState(0);//开票中 也标注为待生成
|
|
|
}
|
|
|
if (item.getC_status().equals("22") || item.getC_status().equals("24")) {
|
|
|
payInvoiceprinted.setState(4);//开票失败
|
|
|
- break;
|
|
|
}
|
|
|
if (item.getC_status().equals("3") || item.getC_status().equals("31")) {
|
|
|
payInvoiceprinted.setState(5);//已作废
|
|
|
- break;
|
|
|
}
|
|
|
- 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.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());
|
|
|
- printInvoicePrintService.update(payInvoiceprinted);
|
|
|
}
|
|
|
+ printInvoicePrintService.update(payInvoiceprinted);
|
|
|
}
|
|
|
}
|
|
|
+ //开票失败则恢复实收及蓝票的状态
|
|
|
if (payInvoiceprinted.getInvoiceType() == 1) {//开具蓝票
|
|
|
- if (payInvoiceprinted.getState() == 1 || payInvoiceprinted.getState() == 2) {
|
|
|
- printInvoicePrintService.updateReceivedIsPrint(true, payInvoiceprinted.getPayseriesno(), payInvoiceprinted.getCustomerId());
|
|
|
+ if (payInvoiceprinted.getState() == 4 || payInvoiceprinted.getState() == 5) {
|
|
|
+ printInvoicePrintService.updateReceivedIsPrint(false, payInvoiceprinted.getPayseriesno(), payInvoiceprinted.getCustomerId());
|
|
|
}
|
|
|
- } else {//蓝票冲红
|
|
|
- if (payInvoiceprinted.getState() == 1 || payInvoiceprinted.getState() == 2) {
|
|
|
+ } 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);
|
|
|
}
|
|
|
- //标记原始蓝票为已冲红 状态3
|
|
|
- PayInvoiceprinted oldPayInvoiceprinted = new PayInvoiceprinted();
|
|
|
- oldPayInvoiceprinted.setId(payInvoiceprinted.getCancelInvoiceId());
|
|
|
- oldPayInvoiceprinted.setState(3);//已冲红
|
|
|
- printInvoicePrintService.update(oldPayInvoiceprinted);
|
|
|
}
|
|
|
}
|
|
|
}
|