|
|
|
@ -3,8 +3,10 @@ package com.jianshui.api.controller.webservice.income.v1.impl; |
|
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
|
import cn.hutool.core.util.ReUtil; |
|
|
|
|
import cn.hutool.core.util.XmlUtil; |
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
// 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.entity.Companyservice; |
|
|
|
|
import com.jianshui.common.utils.DateUtils; |
|
|
|
@ -113,10 +115,12 @@ public class InvoiceCheckWebServiceImpl { |
|
|
|
|
return buildResult(result, "1", "交互密码不能为空", null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 全电发票没有发票代码
|
|
|
|
|
String InvCode = InvCodeElementNode != null ? InvCodeElementNode.getNodeValue() : ""; |
|
|
|
|
/* |
|
|
|
|
if (StringUtils.isEmpty(InvCode)) { |
|
|
|
|
return buildResult(result, "1", "发票代码不能为空", null); |
|
|
|
|
} |
|
|
|
|
}*/ |
|
|
|
|
String InvNo = InvNoElementNode != null ? InvNoElementNode.getNodeValue() : ""; |
|
|
|
|
if (StringUtils.isEmpty(InvNo)) { |
|
|
|
|
return buildResult(result, "1", "发票号码不能为空", null); |
|
|
|
@ -307,7 +311,7 @@ public class InvoiceCheckWebServiceImpl { |
|
|
|
|
getInvoiceVO.setZfbz("Y"); |
|
|
|
|
} |
|
|
|
|
if (StringUtils.equals(zfbz, "H")) { |
|
|
|
|
getInvoiceVO.setZfbz("Y"); |
|
|
|
|
getInvoiceVO.setZfbz("N"); |
|
|
|
|
getInvoiceVO.setHcbz("Y"); |
|
|
|
|
} |
|
|
|
|
if (StringUtils.equals(zfbz, "N")) { |
|
|
|
@ -326,14 +330,21 @@ public class InvoiceCheckWebServiceImpl { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 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); |
|
|
|
|
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); |
|
|
|
|
getInvoiceDoc.appendChild(sphElement); |
|
|
|
|
} |
|
|
|
|
return buildResult(result, "0", "发票查询成功", getInvoiceDoc); |
|
|
|
|
return buildResult(result, "1", "查验成功", getInvoiceDoc); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Element json2Element(Document result, String elementName, JSONObject jsonObject) { |
|
|
|
@ -341,6 +352,8 @@ public class InvoiceCheckWebServiceImpl { |
|
|
|
|
Element parent = result.createElement(elementName); |
|
|
|
|
jsonObject.keySet().forEach(key -> { |
|
|
|
|
String value = jsonObject.getString(key); |
|
|
|
|
// 转为全小写
|
|
|
|
|
key = key.toLowerCase(); |
|
|
|
|
Element element = result.createElement(key); |
|
|
|
|
element.setTextContent(value); |
|
|
|
|
// result.appendChild(element);
|
|
|
|
|