|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.dxhy.erp.controller; |
|
|
|
package com.dxhy.erp.controller; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.dxhy.common.aspect.SysLog; |
|
|
|
import com.dxhy.common.aspect.SysLog; |
|
|
|
import com.dxhy.common.constant.CommonConstants; |
|
|
|
import com.dxhy.common.constant.CommonConstants; |
|
|
@ -70,7 +71,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
@PostMapping("/sn/singleInvoiceCheck") |
|
|
|
@PostMapping("/sn/singleInvoiceCheck") |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
@SysLog("发票查验") |
|
|
|
@SysLog("发票查验") |
|
|
|
public ResponseEntity<String> singleInvoiceCheck(@RequestBody Map<String, String> pramsMap) { |
|
|
|
public ResponseEntity<String> singleInvoiceCheck(@RequestBody Map<String, String> pramsMap) throws ParseException { |
|
|
|
log.info("传入的参数为:{}", pramsMap); |
|
|
|
log.info("传入的参数为:{}", pramsMap); |
|
|
|
String userid = "101833"; |
|
|
|
String userid = "101833"; |
|
|
|
String dbName = "business"; |
|
|
|
String dbName = "business"; |
|
|
@ -128,6 +129,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
log.info("发票类型为:{}", pramsMap.get("invoiceType")); |
|
|
|
log.info("发票类型为:{}", pramsMap.get("invoiceType")); |
|
|
|
|
|
|
|
|
|
|
|
String uuid = (StringUtils.isBlank(pramsMap.get("invoiceCode")) ? "" : pramsMap.get("invoiceCode")) + pramsMap.get("invoiceNo"); |
|
|
|
String uuid = (StringUtils.isBlank(pramsMap.get("invoiceCode")) ? "" : pramsMap.get("invoiceCode")) + pramsMap.get("invoiceNo"); |
|
|
|
|
|
|
|
log.info("uuid={}", uuid); |
|
|
|
String notes = invoiceQueryService.checkingInvoiceInfo("business", uuid, getUserInfo()); |
|
|
|
String notes = invoiceQueryService.checkingInvoiceInfo("business", uuid, getUserInfo()); |
|
|
|
if (notes != null) { |
|
|
|
if (notes != null) { |
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(notes))); |
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error(notes))); |
|
|
@ -136,18 +138,25 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
//查询底账库是否有对应发票,有则直接返回
|
|
|
|
//查询底账库是否有对应发票,有则直接返回
|
|
|
|
TdxCheckRecordInvoice checkInvoiceByUuid = signCheckRecordService.getCheckInvoiceByUuid(uuid); |
|
|
|
TdxCheckRecordInvoice checkInvoiceByUuid = signCheckRecordService.getCheckInvoiceByUuid(uuid); |
|
|
|
if (checkInvoiceByUuid != null) { |
|
|
|
if (checkInvoiceByUuid != null) { |
|
|
|
|
|
|
|
log.info("进项票池已存在发票.直接返回票池信息"); |
|
|
|
R data = new R(1000, "default success"); |
|
|
|
R data = new R(1000, "default success"); |
|
|
|
|
|
|
|
|
|
|
|
String checkInvoice = JSONObject.toJSONString(checkInvoiceByUuid); |
|
|
|
JSONObject checkInvoice = (JSONObject) JSONObject.toJSON(checkInvoiceByUuid); |
|
|
|
|
|
|
|
convertToResult(checkInvoice); |
|
|
|
|
|
|
|
|
|
|
|
data.put("data", checkInvoice); |
|
|
|
data.put("data", checkInvoice); |
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
TdxSaleRecordInvoice tdxSaleRecordInvoice = tdxSaleRecordInvoiceDao.selectByUuid(uuid); |
|
|
|
TdxSaleRecordInvoice tdxSaleRecordInvoice = tdxSaleRecordInvoiceDao.selectByUuid(uuid); |
|
|
|
|
|
|
|
log.info("tdxSaleRecordInvoice={}", tdxSaleRecordInvoice); |
|
|
|
if (tdxSaleRecordInvoice != null) { |
|
|
|
if (tdxSaleRecordInvoice != null) { |
|
|
|
|
|
|
|
log.info("销项票池已存在发票.直接返回票池信息"); |
|
|
|
R data = new R(1000, "default success"); |
|
|
|
R data = new R(1000, "default success"); |
|
|
|
|
|
|
|
|
|
|
|
String checkInvoice = JSONObject.toJSONString(tdxSaleRecordInvoice); |
|
|
|
JSONObject checkInvoice = (JSONObject) JSONObject.toJSON(tdxSaleRecordInvoice); |
|
|
|
|
|
|
|
convertToResult(checkInvoice); |
|
|
|
|
|
|
|
|
|
|
|
data.put("data", checkInvoice); |
|
|
|
data.put("data", checkInvoice); |
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
@ -199,6 +208,136 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error().put("data", checkInvoiceResult))); |
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error().put("data", checkInvoiceResult))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void convertToResult(JSONObject checkInvoice) throws ParseException { |
|
|
|
|
|
|
|
checkInvoice.put("totalTax", checkInvoice.getString("taxAmount")); |
|
|
|
|
|
|
|
checkInvoice.put("amountTax", checkInvoice.getString("totalAmount")); |
|
|
|
|
|
|
|
checkInvoice.put("totalAmount", checkInvoice.getString("invoiceAmount")); |
|
|
|
|
|
|
|
String invoiceCode = checkInvoice.get("invoiceCode").toString(); |
|
|
|
|
|
|
|
String invoiceType = checkInvoice.get("invoiceType").toString(); |
|
|
|
|
|
|
|
if ("22".equals(invoiceType)) { |
|
|
|
|
|
|
|
invoiceType = "33"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if ("21".equals(invoiceType)) { |
|
|
|
|
|
|
|
invoiceType = "31"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checkInvoice.put("invoiceType", invoiceType); |
|
|
|
|
|
|
|
checkInvoice.put("administrativeDivisionNo", ""); |
|
|
|
|
|
|
|
checkInvoice.put("administrativeDivisionName", ""); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checkInvoice.put("invoiceCode", invoiceCode); |
|
|
|
|
|
|
|
checkInvoice.put("invoiceNumber", checkInvoice.get("invoiceNo").toString()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String kprq = checkInvoice.get("invoiceDate").toString(); |
|
|
|
|
|
|
|
Date formatDat = new SimpleDateFormat("yyyyMMdd").parse(kprq); |
|
|
|
|
|
|
|
String str = new SimpleDateFormat("yyyy-MM-dd").format(formatDat); |
|
|
|
|
|
|
|
log.info("开票日期为:{} ", str); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checkInvoice.put("billingDate", str); |
|
|
|
|
|
|
|
checkInvoice.put("purchaserName", checkInvoice.get("gfName")); |
|
|
|
|
|
|
|
checkInvoice.put("purchaserTaxNo", checkInvoice.get("gfTaxNo")); |
|
|
|
|
|
|
|
checkInvoice.put("purchaserBank", checkInvoice.get("gfBankAndNo")); |
|
|
|
|
|
|
|
checkInvoice.put("purchaserAddressPhone", checkInvoice.get("gfAddressAndPhone")); |
|
|
|
|
|
|
|
checkInvoice.put("salesName", checkInvoice.get("xfName")); |
|
|
|
|
|
|
|
checkInvoice.put("salesTaxNo", checkInvoice.get("xfTaxNo")); |
|
|
|
|
|
|
|
checkInvoice.put("salesAddressPhone", checkInvoice.get("gfAddressAndPhone")); |
|
|
|
|
|
|
|
checkInvoice.put("salesBank", checkInvoice.get("gfBankAndNo")); |
|
|
|
|
|
|
|
checkInvoice.put("checkCode", checkInvoice.get("checkCode")); |
|
|
|
|
|
|
|
String taxRate = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Map<String, String>> returnDetailList = new ArrayList<>(); |
|
|
|
|
|
|
|
// JSONArray detailList = (JSONArray) invoiceData.get("detailList");
|
|
|
|
|
|
|
|
JSONArray detailList = new JSONArray(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < detailList.size(); i++) { |
|
|
|
|
|
|
|
String taxRateDetail = ""; |
|
|
|
|
|
|
|
JSONObject detail = (JSONObject) detailList.get(i); |
|
|
|
|
|
|
|
Map<String, String> snDetailMap = new HashMap<String, String>(); |
|
|
|
|
|
|
|
snDetailMap.put("rowNo", i + 1 + ""); |
|
|
|
|
|
|
|
snDetailMap.put("commodityCode", detail.getString("ssflbm")); |
|
|
|
|
|
|
|
snDetailMap.put("commodityName", detail.getString("hwmc")); |
|
|
|
|
|
|
|
snDetailMap.put("specificationModel", detail.getString("ggxh")); |
|
|
|
|
|
|
|
snDetailMap.put("unit", detail.getString("jldw")); |
|
|
|
|
|
|
|
String quantity = detail.getString("spsl"); |
|
|
|
|
|
|
|
if (quantity.length() > 3) { |
|
|
|
|
|
|
|
int index = quantity.indexOf("."); |
|
|
|
|
|
|
|
quantity = quantity.substring(0, index + 2); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
snDetailMap.put("quantity", quantity); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String unitPrice = detail.getString("bhsdj"); |
|
|
|
|
|
|
|
if (unitPrice.length() > 3) { |
|
|
|
|
|
|
|
int index = unitPrice.indexOf("."); |
|
|
|
|
|
|
|
unitPrice = unitPrice.substring(0, index + 3); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
snDetailMap.put("unitPrice", unitPrice); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ("11".equals(invoiceType)) { |
|
|
|
|
|
|
|
snDetailMap.put("tax", "0"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果是卷票计算合计金额
|
|
|
|
|
|
|
|
Float hjje = null; |
|
|
|
|
|
|
|
if (detail.getString("se") != null && detail.getString("je") != null) { |
|
|
|
|
|
|
|
Float je = Float.parseFloat(detail.getString("je")); |
|
|
|
|
|
|
|
Float se = Float.parseFloat(detail.getString("se")); |
|
|
|
|
|
|
|
hjje = je + se; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (hjje != null) |
|
|
|
|
|
|
|
snDetailMap.put("amount", hjje.toString()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
snDetailMap.put("tax", "***".equals(detail.getString("se")) ? "0.00" : detail.getString("se")); |
|
|
|
|
|
|
|
snDetailMap.put("amount", detail.getString("je")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ("免税".equals(detail.getString("sl"))) { |
|
|
|
|
|
|
|
taxRateDetail = "0"; |
|
|
|
|
|
|
|
snDetailMap.put("taxRate", taxRateDetail); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (detail.get("sl") != null && StringUtils.isNoneBlank(detail.get("sl").toString())) { |
|
|
|
|
|
|
|
taxRateDetail = detail.get("sl").toString(); |
|
|
|
|
|
|
|
if (!"0".equals(taxRateDetail)) { |
|
|
|
|
|
|
|
if (StringUtils.isNoneBlank(taxRateDetail)) { |
|
|
|
|
|
|
|
int index = taxRateDetail.indexOf("%"); |
|
|
|
|
|
|
|
if (index > 0) { |
|
|
|
|
|
|
|
taxRateDetail = taxRateDetail.substring(0, taxRateDetail.length() - 1); |
|
|
|
|
|
|
|
Float num = Float.parseFloat(taxRateDetail); |
|
|
|
|
|
|
|
if (num > 9) { |
|
|
|
|
|
|
|
taxRateDetail = "0." + taxRateDetail; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (!taxRateDetail.startsWith("0")) { |
|
|
|
|
|
|
|
taxRateDetail = "0.0" + taxRateDetail; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ("11".equals(invoiceType)) { |
|
|
|
|
|
|
|
taxRateDetail = "0.000"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
log.info("明细-发票税率为:{}", taxRateDetail); |
|
|
|
|
|
|
|
snDetailMap.put("taxRate", taxRateDetail); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("明细-tax={}", detail.get("se")); |
|
|
|
|
|
|
|
log.info("明细-commodityCode={}", detail.get("ssflbm")); |
|
|
|
|
|
|
|
snDetailMap.put("currentDateEnd", detail.getString("txrqz")); |
|
|
|
|
|
|
|
snDetailMap.put("currentDateStart", detail.getString("txrqq")); |
|
|
|
|
|
|
|
snDetailMap.put("licensePlateNum", detail.getString("cph")); |
|
|
|
|
|
|
|
snDetailMap.put("type", detail.getString("lx")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
returnDetailList.add(snDetailMap); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checkInvoice.put("invoiceLineList", returnDetailList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 查验发票 |
|
|
|
* 查验发票 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|