|
|
|
@ -46,7 +46,7 @@ import java.util.Map; |
|
|
|
|
@Slf4j |
|
|
|
|
|
|
|
|
|
public class InvoiceDetailServiceImpl extends MpBaseServiceImpl<TDxRecordInvoiceDao, TDxRecordInvoice> |
|
|
|
|
implements InvoiceDetailService { |
|
|
|
|
implements InvoiceDetailService { |
|
|
|
|
@Resource |
|
|
|
|
private InvoiceDetailDao invoiceDetailDao; |
|
|
|
|
|
|
|
|
@ -95,7 +95,7 @@ public class InvoiceDetailServiceImpl extends MpBaseServiceImpl<TDxRecordInvoice |
|
|
|
|
JSONObject checkInfo = null; |
|
|
|
|
String invoiceCode = pramsMap.get("invoiceCode"); |
|
|
|
|
String invoiceNo = pramsMap.get("invoiceNo"); |
|
|
|
|
String uuid = (StringUtils.isEmpty(invoiceCode)?"":invoiceCode) + invoiceNo; |
|
|
|
|
String uuid = (StringUtils.isEmpty(invoiceCode) ? "" : invoiceCode) + invoiceNo; |
|
|
|
|
|
|
|
|
|
DynamicContextHolder.push(pramsMap.get("dbName") + DbConstant.BUSINESS_READ); |
|
|
|
|
QueryWrapper<TDxRecordInvoice> queryWrapper = new QueryWrapper<>(); |
|
|
|
@ -144,22 +144,17 @@ public class InvoiceDetailServiceImpl extends MpBaseServiceImpl<TDxRecordInvoice |
|
|
|
|
/** |
|
|
|
|
* 根据数据拼接需要返回的报文 |
|
|
|
|
* |
|
|
|
|
* @param invoiceRecord |
|
|
|
|
* 底账表信息 |
|
|
|
|
* @param vehicleSaleInfo |
|
|
|
|
* 机动车表信息 |
|
|
|
|
* @param invoiceDetailList |
|
|
|
|
* 底账明细表信息 |
|
|
|
|
* @param img |
|
|
|
|
* 图片信息 |
|
|
|
|
* @param invoiceRecord 底账表信息 |
|
|
|
|
* @param vehicleSaleInfo 机动车表信息 |
|
|
|
|
* @param invoiceDetailList 底账明细表信息 |
|
|
|
|
* @param img 图片信息 |
|
|
|
|
* @return 返回 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
private JSONObject createCheckInfo(TDxRecordInvoice invoiceRecord, TDxVehicleSaleInvoice vehicleSaleInfo, |
|
|
|
|
List<TDxRecordInvoiceDetail> invoiceDetailList, TDxInvoiceImg img) { |
|
|
|
|
List<TDxRecordInvoiceDetail> invoiceDetailList, TDxInvoiceImg img) { |
|
|
|
|
|
|
|
|
|
JSONObject checkInfo = new JSONObject(); |
|
|
|
|
InvoiceSubjectVO checkRecordVo = this.convertToCheckRecordVo(invoiceRecord, img,invoiceDetailList); |
|
|
|
|
InvoiceSubjectVO checkRecordVo = this.convertToCheckRecordVo(invoiceRecord, img, invoiceDetailList); |
|
|
|
|
|
|
|
|
|
// 取发票上的价税合计
|
|
|
|
|
String totalAmount = checkRecordVo.getTotalAmount(); |
|
|
|
@ -172,7 +167,7 @@ public class InvoiceDetailServiceImpl extends MpBaseServiceImpl<TDxRecordInvoice |
|
|
|
|
// 机动车部分信息
|
|
|
|
|
if (vehicleSaleInfo != null) { |
|
|
|
|
CheckVehicleSaleVO checkVehicleSaleVo = this.convertToVehicleSaleVo(vehicleSaleInfo, |
|
|
|
|
invoiceRecord.getInvoiceType(), invoiceRecord.getInvoicer()); |
|
|
|
|
invoiceRecord.getInvoiceType(), invoiceRecord.getInvoicer()); |
|
|
|
|
checkInfo.put("vehicle", JSON.toJSON(checkVehicleSaleVo)); |
|
|
|
|
} else { |
|
|
|
|
checkInfo.put("vehicle", new JSONObject()); |
|
|
|
@ -194,10 +189,10 @@ public class InvoiceDetailServiceImpl extends MpBaseServiceImpl<TDxRecordInvoice |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
checkInfo.put("invoiceDetails", detail); |
|
|
|
|
if("11".equals(invoiceRecord.getInvoiceType())){ |
|
|
|
|
if ("11".equals(invoiceRecord.getInvoiceType())) { |
|
|
|
|
checkInfo.put("detailAmountSum", totalAmount); |
|
|
|
|
checkInfo.put("taxAmountSum", checkRecordVo.getTaxAmount()); |
|
|
|
|
}else { |
|
|
|
|
} else { |
|
|
|
|
checkInfo.put("detailAmountSum", MathUtil.round(invoiceRecord.getInvoiceAmount().toPlainString())); |
|
|
|
|
if (StringUtils.isNotBlank(se) && invoiceRecord.getTaxAmount().compareTo(new BigDecimal(0)) == 0) { |
|
|
|
|
checkInfo.put("taxAmountSum", se); |
|
|
|
@ -215,7 +210,7 @@ public class InvoiceDetailServiceImpl extends MpBaseServiceImpl<TDxRecordInvoice |
|
|
|
|
return checkInfo; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private InvoiceSubjectVO convertToCheckRecordVo(TDxRecordInvoice invoiceRecord, TDxInvoiceImg img,List<TDxRecordInvoiceDetail> invoiceDetailList) { |
|
|
|
|
private InvoiceSubjectVO convertToCheckRecordVo(TDxRecordInvoice invoiceRecord, TDxInvoiceImg img, List<TDxRecordInvoiceDetail> invoiceDetailList) { |
|
|
|
|
InvoiceSubjectVO checkRecordVo = new InvoiceSubjectVO(); |
|
|
|
|
// 字典值转换
|
|
|
|
|
String fpzt = dictdetaServcice.queryDictName(DictConstant.INVOICE_STATUS, invoiceRecord.getInvoiceStatus()); |
|
|
|
@ -230,22 +225,22 @@ public class InvoiceDetailServiceImpl extends MpBaseServiceImpl<TDxRecordInvoice |
|
|
|
|
String dqskssq = invoiceRecord.getRzhBelongDate(); |
|
|
|
|
|
|
|
|
|
checkRecordVo.setConfirmDate( |
|
|
|
|
(invoiceRecord.getConfirmDate() == null) ? "" : DateUtils.dateToStrLong(invoiceRecord.getConfirmDate())); |
|
|
|
|
(invoiceRecord.getConfirmDate() == null) ? "" : DateUtils.dateToStrLong(invoiceRecord.getConfirmDate())); |
|
|
|
|
|
|
|
|
|
checkRecordVo |
|
|
|
|
.setGxDate((invoiceRecord.getGxDate() == null) ? "" : DateUtils.dateToStrLong(invoiceRecord.getGxDate())); |
|
|
|
|
.setGxDate((invoiceRecord.getGxDate() == null) ? "" : DateUtils.dateToStrLong(invoiceRecord.getGxDate())); |
|
|
|
|
|
|
|
|
|
checkRecordVo.setInvoiceStatus(fpzt); |
|
|
|
|
checkRecordVo.setSourceSystem( |
|
|
|
|
(StringUtils.isNotBlank(invoiceRecord.getSourceSystem()) && "1".equals(invoiceRecord.getSourceSystem())) |
|
|
|
|
? "查验" : "采集"); |
|
|
|
|
(StringUtils.isNotBlank(invoiceRecord.getSourceSystem()) && "1".equals(invoiceRecord.getSourceSystem())) |
|
|
|
|
? "查验" : "采集"); |
|
|
|
|
if (invoiceRecord.getCreateDate() != null) { |
|
|
|
|
checkRecordVo.setCreateDate(DateUtils.dateToStrLong(invoiceRecord.getCreateDate())); |
|
|
|
|
} else { |
|
|
|
|
checkRecordVo.setCreateDate(""); |
|
|
|
|
} |
|
|
|
|
if ("01".equals(invoiceRecord.getInvoiceType()) || "03".equals(invoiceRecord.getInvoiceType()) |
|
|
|
|
|| "14".equals(invoiceRecord.getInvoiceType())) { |
|
|
|
|
|| "14".equals(invoiceRecord.getInvoiceType())) { |
|
|
|
|
if ("0".equals(invoiceRecord.getInvoiceStatus())) { |
|
|
|
|
if (StringUtils.isNotBlank(invoiceRecord.getGxUserAccount())) { |
|
|
|
|
checkRecordVo.setGxState("是"); |
|
|
|
@ -267,20 +262,20 @@ public class InvoiceDetailServiceImpl extends MpBaseServiceImpl<TDxRecordInvoice |
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日"); |
|
|
|
|
checkRecordVo.setInvoiceDate(sdf.format(invoiceRecord.getInvoiceDate())); |
|
|
|
|
checkRecordVo.setInvoiceAmount(invoiceRecord.getInvoiceAmount() == null ? "" |
|
|
|
|
: MathUtil.round(invoiceRecord.getInvoiceAmount().toPlainString())); |
|
|
|
|
: MathUtil.round(invoiceRecord.getInvoiceAmount().toPlainString())); |
|
|
|
|
checkRecordVo.setTaxAmount( |
|
|
|
|
invoiceRecord.getTaxAmount() == null ? "" : MathUtil.round(invoiceRecord.getTaxAmount().toPlainString())); |
|
|
|
|
if("11".equals(invoiceRecord.getInvoiceType())){ |
|
|
|
|
invoiceRecord.getTaxAmount() == null ? "" : MathUtil.round(invoiceRecord.getTaxAmount().toPlainString())); |
|
|
|
|
if ("11".equals(invoiceRecord.getInvoiceType())) { |
|
|
|
|
BigDecimal detailAmount = new BigDecimal(0); |
|
|
|
|
if(CollectionUtils.isNotEmpty(invoiceDetailList)){ |
|
|
|
|
for (TDxRecordInvoiceDetail tdxRecordInvoiceDetail:invoiceDetailList){ |
|
|
|
|
if(tdxRecordInvoiceDetail.getDetailAmount()!=null){ |
|
|
|
|
if (CollectionUtils.isNotEmpty(invoiceDetailList)) { |
|
|
|
|
for (TDxRecordInvoiceDetail tdxRecordInvoiceDetail : invoiceDetailList) { |
|
|
|
|
if (tdxRecordInvoiceDetail.getDetailAmount() != null) { |
|
|
|
|
detailAmount = detailAmount.add(new BigDecimal(tdxRecordInvoiceDetail.getDetailAmount())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
checkRecordVo.setTotalAmount(MathUtil.round(detailAmount.toPlainString())); |
|
|
|
|
}else { |
|
|
|
|
} else { |
|
|
|
|
if (invoiceRecord.getTotalAmount() == null) { |
|
|
|
|
BigDecimal add = invoiceRecord.getInvoiceAmount().add(invoiceRecord.getTaxAmount()); |
|
|
|
|
checkRecordVo.setTotalAmount(MathUtil.round(add.toPlainString())); |
|
|
|
@ -301,12 +296,12 @@ public class InvoiceDetailServiceImpl extends MpBaseServiceImpl<TDxRecordInvoice |
|
|
|
|
checkRecordVo.setId(String.valueOf(invoiceRecord.getId())); |
|
|
|
|
checkRecordVo.setUuid(invoiceRecord.getUuid()); |
|
|
|
|
checkRecordVo |
|
|
|
|
.setQsDate((invoiceRecord.getQsDate() == null) ? "" : DateUtils.dateToStrLong(invoiceRecord.getQsDate())); |
|
|
|
|
.setQsDate((invoiceRecord.getQsDate() == null) ? "" : DateUtils.dateToStrLong(invoiceRecord.getQsDate())); |
|
|
|
|
checkRecordVo.setQsName(StringHelper.trimEnter(invoiceRecord.getQsName())); |
|
|
|
|
checkRecordVo.setQsStatus(qsStatus); |
|
|
|
|
checkRecordVo.setQsType(qsType); |
|
|
|
|
checkRecordVo.setRzhDate( |
|
|
|
|
(invoiceRecord.getRzhDate() == null) ? "" : DateUtils.dateToStrLong(invoiceRecord.getRzhDate())); |
|
|
|
|
(invoiceRecord.getRzhDate() == null) ? "" : DateUtils.dateToStrLong(invoiceRecord.getRzhDate())); |
|
|
|
|
checkRecordVo.setRzlx(rzlx); |
|
|
|
|
checkRecordVo.setRemark(invoiceRecord.getRemark()); |
|
|
|
|
checkRecordVo.setRzhYesorno(rzhYesorno); |
|
|
|
@ -345,10 +340,8 @@ public class InvoiceDetailServiceImpl extends MpBaseServiceImpl<TDxRecordInvoice |
|
|
|
|
/** |
|
|
|
|
* 转义认证类型 |
|
|
|
|
* |
|
|
|
|
* @param rzlx |
|
|
|
|
* 认证类型 |
|
|
|
|
* @param rzlx 认证类型 |
|
|
|
|
* @return 返回 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
private String getRzlx(String rzlx) { |
|
|
|
|
String rzlxmc = ""; |
|
|
|
@ -365,10 +358,8 @@ public class InvoiceDetailServiceImpl extends MpBaseServiceImpl<TDxRecordInvoice |
|
|
|
|
/** |
|
|
|
|
* 转义签收方式 |
|
|
|
|
* |
|
|
|
|
* @param qsType |
|
|
|
|
* 前首富昂视 |
|
|
|
|
* @param qsType 前首富昂视 |
|
|
|
|
* @return 类型 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
private String getQsType(String qsType) { |
|
|
|
|
String qsfs = ""; |
|
|
|
@ -391,10 +382,8 @@ public class InvoiceDetailServiceImpl extends MpBaseServiceImpl<TDxRecordInvoice |
|
|
|
|
/** |
|
|
|
|
* 转义签收状态 |
|
|
|
|
* |
|
|
|
|
* @param qsStatus |
|
|
|
|
* 签收状态 |
|
|
|
|
* @param qsStatus 签收状态 |
|
|
|
|
* @return 返回 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
private String getQsStatus(String qsStatus) { |
|
|
|
|
String qszt = ""; |
|
|
|
@ -409,10 +398,8 @@ public class InvoiceDetailServiceImpl extends MpBaseServiceImpl<TDxRecordInvoice |
|
|
|
|
/** |
|
|
|
|
* 转义认证方式 |
|
|
|
|
* |
|
|
|
|
* @param rzhType |
|
|
|
|
* 认证方式 |
|
|
|
|
* @param rzhType 认证方式 |
|
|
|
|
* @return 返回 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
private String getRztype(String rzhType) { |
|
|
|
|
String rzType = ""; |
|
|
|
@ -481,7 +468,7 @@ public class InvoiceDetailServiceImpl extends MpBaseServiceImpl<TDxRecordInvoice |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private CheckVehicleSaleVO convertToVehicleSaleVo(TDxVehicleSaleInvoice vehicleSaleInfo, String invoiceType, |
|
|
|
|
String invoicer) { |
|
|
|
|
String invoicer) { |
|
|
|
|
String taxRate = StringHelper.trimEnter(vehicleSaleInfo.getTaxRate()); |
|
|
|
|
CheckVehicleSaleVO checkVehicleSaleVo = new CheckVehicleSaleVO(); |
|
|
|
|
checkVehicleSaleVo.setBuyerBank(StringHelper.trimEnter(vehicleSaleInfo.getBuyerBank())); |
|
|
|
@ -520,12 +507,12 @@ public class InvoiceDetailServiceImpl extends MpBaseServiceImpl<TDxRecordInvoice |
|
|
|
|
checkVehicleSaleVo.setBuyerUnitOrIndividual(StringHelper.trimEnter(vehicleSaleInfo.getBuyerUnit())); |
|
|
|
|
checkVehicleSaleVo.setBuyerUnitCodeOrIdNo(StringHelper.trimEnter(vehicleSaleInfo.getBuyerUnitCode())); |
|
|
|
|
checkVehicleSaleVo |
|
|
|
|
.setBuyerUnitOrIndividualAddress(StringHelper.trimEnter(vehicleSaleInfo.getBuyerUnitAddress())); |
|
|
|
|
.setBuyerUnitOrIndividualAddress(StringHelper.trimEnter(vehicleSaleInfo.getBuyerUnitAddress())); |
|
|
|
|
checkVehicleSaleVo.setBuyerPhone(StringHelper.trimEnter(vehicleSaleInfo.getBuyerPhone())); |
|
|
|
|
checkVehicleSaleVo.setSellerUnitOrIndividual(StringHelper.trimEnter(vehicleSaleInfo.getSellerUnit())); |
|
|
|
|
checkVehicleSaleVo.setSellerUnitCodeOrIdNo(StringHelper.trimEnter(vehicleSaleInfo.getSellerUnitCode())); |
|
|
|
|
checkVehicleSaleVo |
|
|
|
|
.setSellerUnitOrIndividualAddress(StringHelper.trimEnter(vehicleSaleInfo.getSellerUnitAddress())); |
|
|
|
|
.setSellerUnitOrIndividualAddress(StringHelper.trimEnter(vehicleSaleInfo.getSellerUnitAddress())); |
|
|
|
|
checkVehicleSaleVo.setSellerPhone(StringHelper.trimEnter(vehicleSaleInfo.getSellerPhone())); |
|
|
|
|
if (StringUtils.isNotBlank(invoicer)) { |
|
|
|
|
checkVehicleSaleVo.setInvoicer(StringHelper.trimEnter(invoicer)); |
|
|
|
@ -538,15 +525,19 @@ public class InvoiceDetailServiceImpl extends MpBaseServiceImpl<TDxRecordInvoice |
|
|
|
|
CheckRecordInvoiceDetailVO checkRecordDetailVo = new CheckRecordInvoiceDetailVO(); |
|
|
|
|
if (StringHelper.trimEnter(tDxRecordInvoiceDetail.getTaxRate()).matches("[0-9]+")) { |
|
|
|
|
checkRecordDetailVo.setTaxRate(StringHelper.trimEnter(tDxRecordInvoiceDetail.getTaxRate()) + "%"); |
|
|
|
|
} else if(tDxRecordInvoiceDetail.getTaxRate().contains(".")){ |
|
|
|
|
} else if (tDxRecordInvoiceDetail.getTaxRate().contains(".")) { |
|
|
|
|
String taxRate = StringHelper.trimEnter(tDxRecordInvoiceDetail.getTaxRate()); |
|
|
|
|
if(taxRate.contains(".")){ |
|
|
|
|
if (taxRate.contains(".")) { |
|
|
|
|
taxRate = taxRate.replace(".", "").replace("0", ""); |
|
|
|
|
} |
|
|
|
|
checkRecordDetailVo.setTaxRate(taxRate + "%"); |
|
|
|
|
}else { |
|
|
|
|
} else { |
|
|
|
|
checkRecordDetailVo.setTaxRate(StringHelper.trimEnter(tDxRecordInvoiceDetail.getTaxRate())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (checkRecordDetailVo.getTaxRate() != null) |
|
|
|
|
checkRecordDetailVo.setTaxCode(getZSM(checkRecordDetailVo.getTaxRate())); |
|
|
|
|
|
|
|
|
|
checkRecordDetailVo.setCph(StringHelper.trimEnter(tDxRecordInvoiceDetail.getCph())); |
|
|
|
|
checkRecordDetailVo.setDetailAmount(StringHelper.trimEnter(tDxRecordInvoiceDetail.getDetailAmount())); |
|
|
|
|
checkRecordDetailVo.setDetailNo(StringHelper.trimEnter(tDxRecordInvoiceDetail.getDetailNo())); |
|
|
|
@ -569,7 +560,7 @@ public class InvoiceDetailServiceImpl extends MpBaseServiceImpl<TDxRecordInvoice |
|
|
|
|
JSONObject checkInfo = null; |
|
|
|
|
String invoiceCode = pramsMap.get("invoiceCode"); |
|
|
|
|
String invoiceNo = pramsMap.get("invoiceNo"); |
|
|
|
|
String uuid = (StringUtils.isEmpty(invoiceCode)?"":invoiceCode) + invoiceNo; |
|
|
|
|
String uuid = (StringUtils.isEmpty(invoiceCode) ? "" : invoiceCode) + invoiceNo; |
|
|
|
|
|
|
|
|
|
DynamicContextHolder.push(pramsMap.get("dbName") + DbConstant.BUSINESS_READ); |
|
|
|
|
|
|
|
|
@ -606,4 +597,55 @@ public class InvoiceDetailServiceImpl extends MpBaseServiceImpl<TDxRecordInvoice |
|
|
|
|
} |
|
|
|
|
return this.createCheckInfo(invoiceRecord, vehicleSaleInfo, invoiceDetailList, img); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String getZSM(String taxRate) { |
|
|
|
|
|
|
|
|
|
String sm = ""; |
|
|
|
|
|
|
|
|
|
switch (taxRate) { |
|
|
|
|
// 发票采集
|
|
|
|
|
case "0.00": |
|
|
|
|
sm = "J0"; |
|
|
|
|
break; |
|
|
|
|
case "免税": |
|
|
|
|
sm = "J0"; |
|
|
|
|
break; |
|
|
|
|
case "16%": |
|
|
|
|
sm = "J1"; |
|
|
|
|
break; |
|
|
|
|
case "13%": |
|
|
|
|
sm = "J2"; |
|
|
|
|
break; |
|
|
|
|
case "10%": |
|
|
|
|
sm = "J3"; |
|
|
|
|
break; |
|
|
|
|
case "9%": |
|
|
|
|
sm = "J4"; |
|
|
|
|
break; |
|
|
|
|
case "6%": |
|
|
|
|
sm = "J5"; |
|
|
|
|
break; |
|
|
|
|
case "5%": |
|
|
|
|
sm = "J6"; |
|
|
|
|
break; |
|
|
|
|
case "3%": |
|
|
|
|
sm = "J7"; |
|
|
|
|
break; |
|
|
|
|
case "2%": |
|
|
|
|
sm = "J8"; |
|
|
|
|
break; |
|
|
|
|
case "1%": |
|
|
|
|
sm = "J9"; |
|
|
|
|
break; |
|
|
|
|
case "17%": |
|
|
|
|
sm = "JC"; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
sm = ""; |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return sm; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|