简税升级

beta-prop-all^2
dongxiaoke 2 years ago
parent 1586a03c5e
commit cbde72665c
  1. 2
      jianshui-admin/src/main/java/com/jianshui/api/config/WebserviceResponseHandler.java
  2. 23
      jianshui-admin/src/main/java/com/jianshui/api/controller/webservice/income/v1/impl/InvoiceCheckWebServiceImpl.java

@ -38,7 +38,7 @@ public class WebserviceResponseHandler implements SOAPHandler<SOAPMessageContext
SOAPBody body = message.getSOAPBody(); SOAPBody body = message.getSOAPBody();
Node returnNode = body.getFirstChild().getFirstChild(); Node returnNode = body.getFirstChild().getFirstChild();
Node dataNode = returnNode.getFirstChild(); Node dataNode = returnNode.getFirstChild();
CDATASection cdata = dataNode.getOwnerDocument().createCDATASection(XmlUtil.toStr(dataNode)); CDATASection cdata = dataNode.getOwnerDocument().createCDATASection(XmlUtil.toStr(dataNode,"GBK",false,false));
returnNode.removeChild(dataNode); returnNode.removeChild(dataNode);
returnNode.appendChild(cdata); returnNode.appendChild(cdata);
// body.getFirstChild().removeChild(body.getFirstChild().getFirstChild()); // body.getFirstChild().removeChild(body.getFirstChild().getFirstChild());

@ -3,8 +3,10 @@ package com.jianshui.api.controller.webservice.income.v1.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ReUtil; import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.XmlUtil; import cn.hutool.core.util.XmlUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
// import com.jianshui.api.controller.webservice.income.v1.InvoiceCheckWebService; // import com.jianshui.api.controller.webservice.income.v1.InvoiceCheckWebService;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.jianshui.common.core.domain.AjaxResult; import com.jianshui.common.core.domain.AjaxResult;
import com.jianshui.common.core.domain.entity.Companyservice; import com.jianshui.common.core.domain.entity.Companyservice;
import com.jianshui.common.utils.DateUtils; import com.jianshui.common.utils.DateUtils;
@ -113,10 +115,12 @@ public class InvoiceCheckWebServiceImpl {
return buildResult(result, "1", "交互密码不能为空", null); return buildResult(result, "1", "交互密码不能为空", null);
} }
// 全电发票没有发票代码
String InvCode = InvCodeElementNode != null ? InvCodeElementNode.getNodeValue() : ""; String InvCode = InvCodeElementNode != null ? InvCodeElementNode.getNodeValue() : "";
/*
if (StringUtils.isEmpty(InvCode)) { if (StringUtils.isEmpty(InvCode)) {
return buildResult(result, "1", "发票代码不能为空", null); return buildResult(result, "1", "发票代码不能为空", null);
} }*/
String InvNo = InvNoElementNode != null ? InvNoElementNode.getNodeValue() : ""; String InvNo = InvNoElementNode != null ? InvNoElementNode.getNodeValue() : "";
if (StringUtils.isEmpty(InvNo)) { if (StringUtils.isEmpty(InvNo)) {
return buildResult(result, "1", "发票号码不能为空", null); return buildResult(result, "1", "发票号码不能为空", null);
@ -307,7 +311,7 @@ public class InvoiceCheckWebServiceImpl {
getInvoiceVO.setZfbz("Y"); getInvoiceVO.setZfbz("Y");
} }
if (StringUtils.equals(zfbz, "H")) { if (StringUtils.equals(zfbz, "H")) {
getInvoiceVO.setZfbz("Y"); getInvoiceVO.setZfbz("N");
getInvoiceVO.setHcbz("Y"); getInvoiceVO.setHcbz("Y");
} }
if (StringUtils.equals(zfbz, "N")) { if (StringUtils.equals(zfbz, "N")) {
@ -326,14 +330,21 @@ public class InvoiceCheckWebServiceImpl {
} }
// getInvoiceVO转成JSONObject // getInvoiceVO转成JSONObject
JSONObject getInvoiceVOJson = (JSONObject) JSONObject.toJSON(getInvoiceVO); // JSONObject getInvoiceVOJson = (JSONObject) JSONObject.toJSON(getInvoiceVO);
String getInvoiceVOJsonStr = JSON.toJSONString(getInvoiceVO,SerializerFeature.WriteSlashAsSpecial);
JSONObject getInvoiceVOJson = JSONObject.parseObject(getInvoiceVOJsonStr);
Element getInvoiceDoc = json2Element(result, "Fp", getInvoiceVOJson); Element getInvoiceDoc = json2Element(result, "Fp", getInvoiceVOJson);
for (GetInvoiceSphVO getInvoiceSphVO : getInvoiceSphVOList) { for (GetInvoiceSphVO getInvoiceSphVO : getInvoiceSphVOList) {
JSONObject getInvoiceSphVOJson = (JSONObject) JSONObject.toJSON(getInvoiceSphVO); // JSONObject getInvoiceSphVOJson = (JSONObject) JSONObject.toJSON(getInvoiceSphVO);
// 防止转义
String getInvoiceSphVOJsonStr = JSON.toJSONString(getInvoiceSphVO, SerializerFeature.WriteSlashAsSpecial);
getInvoiceSphVOJsonStr.replace("免税","0.0%").replace("***","0.00");
JSONObject getInvoiceSphVOJson = JSONObject.parseObject(getInvoiceSphVOJsonStr);
Element sphElement = json2Element(result, "Sph", getInvoiceSphVOJson); Element sphElement = json2Element(result, "Sph", getInvoiceSphVOJson);
getInvoiceDoc.appendChild(sphElement); getInvoiceDoc.appendChild(sphElement);
} }
return buildResult(result, "0", "发票查询成功", getInvoiceDoc); return buildResult(result, "1", "查验成功", getInvoiceDoc);
} }
private Element json2Element(Document result, String elementName, JSONObject jsonObject) { private Element json2Element(Document result, String elementName, JSONObject jsonObject) {
@ -341,6 +352,8 @@ public class InvoiceCheckWebServiceImpl {
Element parent = result.createElement(elementName); Element parent = result.createElement(elementName);
jsonObject.keySet().forEach(key -> { jsonObject.keySet().forEach(key -> {
String value = jsonObject.getString(key); String value = jsonObject.getString(key);
// 转为全小写
key = key.toLowerCase();
Element element = result.createElement(key); Element element = result.createElement(key);
element.setTextContent(value); element.setTextContent(value);
// result.appendChild(element); // result.appendChild(element);