|
|
|
@ -98,7 +98,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
return post; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String pushInvoiceToRecordInvoice(SNRequestObject snRequestObject, String taxNo, String company) throws Exception { |
|
|
|
|
public String pushInvoiceToRecordInvoice(SNInvoice snInvoice, String taxNo, String company) throws Exception { |
|
|
|
|
|
|
|
|
|
QueryWrapper<BaseTDxTaxCurrent> currentWrapper = new QueryWrapper<>(); |
|
|
|
|
currentWrapper.eq("taxno", taxNo); |
|
|
|
@ -106,12 +106,6 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
BaseTDxTaxCurrent current = baseTDxTaxCurrentDao.selectOne(currentWrapper); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<SNInvoice> invoiceInfoList = snRequestObject.getInvoiceInfoList(); |
|
|
|
|
|
|
|
|
|
if (invoiceInfoList != null && invoiceInfoList.size() > 0) { |
|
|
|
|
|
|
|
|
|
for (SNInvoice snInvoice : invoiceInfoList) { |
|
|
|
|
|
|
|
|
|
String fpdm = snInvoice.getInvoiceCode(); |
|
|
|
|
String fphm = snInvoice.getInvoiceNumber(); |
|
|
|
|
|
|
|
|
@ -138,15 +132,18 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
BaseTDxRecordInvoice recordInvoice = new BaseTDxRecordInvoice(); |
|
|
|
|
recordInvoice.setUuid(fpdm + fphm); |
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
|
if(kprq != null) { |
|
|
|
|
if (kprq != null) { |
|
|
|
|
recordInvoice.setInvoiceDate(sdf.parse(kprq)); |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
recordInvoice.setInvoiceDate(new Date()); |
|
|
|
|
log.error("开票日期为空.请检查发票"); |
|
|
|
|
} |
|
|
|
|
recordInvoice.setInvoiceCode(fpdm); |
|
|
|
|
recordInvoice.setInvoiceNo(fphm); |
|
|
|
|
|
|
|
|
|
if (je != null) { |
|
|
|
|
recordInvoice.setInvoiceAmount(new BigDecimal(je)); |
|
|
|
|
} |
|
|
|
|
if (se != null) { |
|
|
|
|
recordInvoice.setTaxAmount(new BigDecimal(se)); |
|
|
|
|
} |
|
|
|
@ -169,40 +166,39 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
} else { |
|
|
|
|
baseTDxRecordInvoiceDao.insert(recordInvoice); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Integer pushInvoiceToRecordInvoice2(SNRequestObject snRequestObject) { |
|
|
|
|
public Integer pushInvoiceToRecordInvoice2(SNInvoice snInvoice,String imageId,String compCode) { |
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
|
|
|
|
|
int update = 0; |
|
|
|
|
List<SNInvoice> invoiceInfoList = snRequestObject.getInvoiceInfoList(); |
|
|
|
|
|
|
|
|
|
if (invoiceInfoList != null && invoiceInfoList.size() > 0) { |
|
|
|
|
for (SNInvoice snInvoice : invoiceInfoList) { |
|
|
|
|
String fpdm = snInvoice.getInvoiceCode(); |
|
|
|
|
String fphm = snInvoice.getInvoiceNumber(); |
|
|
|
|
QueryWrapper<BaseTDxRecordInvoice> recordWrapper = new QueryWrapper<>(); |
|
|
|
|
recordWrapper.eq("uuid", fpdm + fphm); |
|
|
|
|
BaseTDxRecordInvoice recordInvoice = new BaseTDxRecordInvoice(); |
|
|
|
|
recordInvoice.setImageId(snRequestObject.getImageId()); |
|
|
|
|
recordInvoice.setCompCode(snRequestObject.getCompCode()); |
|
|
|
|
recordInvoice.setImageId(imageId); |
|
|
|
|
recordInvoice.setCompCode(compCode); |
|
|
|
|
|
|
|
|
|
update = baseTDxRecordInvoiceDao.update(recordInvoice, recordWrapper); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
String imageId = snRequestObject.getImageId(); |
|
|
|
|
QueryWrapper<BaseTDxRecordInvoice> recordWrapper = new QueryWrapper<>(); |
|
|
|
|
recordWrapper.eq("image_id", imageId); |
|
|
|
|
BaseTDxRecordInvoice recordInvoice = new BaseTDxRecordInvoice(); |
|
|
|
|
recordInvoice.setImageId(""); |
|
|
|
|
recordInvoice.setCompCode(""); |
|
|
|
|
|
|
|
|
|
update = baseTDxRecordInvoiceDao.update(recordInvoice, recordWrapper); |
|
|
|
|
} |
|
|
|
|
// if (invoiceInfoList != null && invoiceInfoList.size() > 0) {
|
|
|
|
|
// for (SNInvoice snInvoice : invoiceInfoList) {
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// String imageId = snRequestObject.getImageId();
|
|
|
|
|
// QueryWrapper<BaseTDxRecordInvoice> recordWrapper = new QueryWrapper<>();
|
|
|
|
|
// recordWrapper.eq("image_id", imageId);
|
|
|
|
|
// BaseTDxRecordInvoice recordInvoice = new BaseTDxRecordInvoice();
|
|
|
|
|
// recordInvoice.setImageId("");
|
|
|
|
|
// recordInvoice.setCompCode("");
|
|
|
|
|
//
|
|
|
|
|
// update = baseTDxRecordInvoiceDao.update(recordInvoice, recordWrapper);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
return update; |
|
|
|
|
} |
|
|
|
@ -501,7 +497,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
if (num > 9) { |
|
|
|
|
taxRateDetail = "0." + taxRateDetail; |
|
|
|
|
} else { |
|
|
|
|
if(!taxRateDetail.startsWith("0")){ |
|
|
|
|
if (!taxRateDetail.startsWith("0")) { |
|
|
|
|
taxRateDetail = "0.0" + taxRateDetail; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -544,7 +540,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
return jsonObject; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String updateInvoicePoll(@RequestBody SNRequestObject snRequestObject, String company, String taxNo, TDxInvoiceReimburse reimburse, SNInvoice invoice, String fplxdm, String invoiceCode, String invoiceNo) throws Exception { |
|
|
|
|
public String updateInvoicePoll(String company, String taxNo, TDxInvoiceReimburse reimburse, SNInvoice invoice, String fplxdm,String imageId,String compCode) throws Exception { |
|
|
|
|
String result = "0000"; |
|
|
|
|
|
|
|
|
|
//判断发票类型
|
|
|
|
@ -562,16 +558,16 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
if (data != null) { |
|
|
|
|
invoice.setIsDeductible(data.getIsDeductible()); |
|
|
|
|
invoice.setTaxRate(data.getTaxRate()); |
|
|
|
|
if(data.getInvoiceAmount() != null) { |
|
|
|
|
if (data.getInvoiceAmount() != null) { |
|
|
|
|
invoice.setTotalAmount(data.getInvoiceAmount().toString()); |
|
|
|
|
} |
|
|
|
|
if(data.getTaxAmount() != null) { |
|
|
|
|
if (data.getTaxAmount() != null) { |
|
|
|
|
invoice.setTotalTax(data.getTaxAmount().toString()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!"ok".equals(invoiceResult.getMsg()) && !"0000".equals(invoiceResult.getMsg())) { |
|
|
|
|
log.info("价税分离失败:{}",invoiceResult.getMsg()); |
|
|
|
|
log.info("价税分离失败:{}", invoiceResult.getMsg()); |
|
|
|
|
return invoiceResult.getMsg(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -597,11 +593,11 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
|| "08".equals(fplxdm) || "10".equals(fplxdm) || "11".equals(fplxdm) || "14".equals(fplxdm) |
|
|
|
|
|| "15".equals(fplxdm) || "31".equals(fplxdm) || "32".equals(fplxdm)) { |
|
|
|
|
//可查验发票,已入库,更新票池
|
|
|
|
|
Integer integer = this.pushInvoiceToRecordInvoice2(snRequestObject); |
|
|
|
|
Integer integer = this.pushInvoiceToRecordInvoice2(invoice,imageId,compCode); |
|
|
|
|
log.info("可查验发票,更新底账库完成"); |
|
|
|
|
} else { |
|
|
|
|
//不可查验发票,未入库,插入票池
|
|
|
|
|
this.pushInvoiceToRecordInvoice(snRequestObject, taxNo, company); |
|
|
|
|
this.pushInvoiceToRecordInvoice(invoice, taxNo, company); |
|
|
|
|
log.info("不可查验发票,插入底账库成功"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -610,7 +606,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private TDxInvoiceReimburse convertToReimburse(SNInvoice invoice, TDxInvoiceReimburse reimburse, String fplxdm, String company) { |
|
|
|
|
|
|
|
|
|
reimburse.setId(IdUtils.nextId()); |
|
|
|
|
reimburse.setInvoiceType(fplxdm); |
|
|
|
|
reimburse.setInvoiceCode(invoice.getInvoiceCode()); |
|
|
|
|
reimburse.setInvoiceNo(invoice.getInvoiceNumber()); |
|
|
|
|