|
|
@ -3,6 +3,10 @@ package com.jianshui.api.controller.http.invoice.v1; |
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
|
|
|
import com.dxhy.order.protocol.invoke.DxhyInterfaceResponse; |
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException; |
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
|
|
|
|
|
import com.google.gson.Gson; |
|
|
|
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.enums.ErrorCode; |
|
|
|
import com.jianshui.common.enums.ErrorCode; |
|
|
@ -13,6 +17,10 @@ import com.jianshui.common.utils.http.HttpHelper; |
|
|
|
import com.jianshui.invoice.constant.elephant.ElephantConstants; |
|
|
|
import com.jianshui.invoice.constant.elephant.ElephantConstants; |
|
|
|
import com.jianshui.invoice.domain.BillInfo; |
|
|
|
import com.jianshui.invoice.domain.BillInfo; |
|
|
|
import com.jianshui.invoice.domain.FindRedInfo; |
|
|
|
import com.jianshui.invoice.domain.FindRedInfo; |
|
|
|
|
|
|
|
import com.jianshui.invoice.domain.ele.EleNewMessage; |
|
|
|
|
|
|
|
import com.jianshui.invoice.domain.ele.EleOuterMessage; |
|
|
|
|
|
|
|
import com.jianshui.invoice.domain.ele.FindRedInfoDTO; |
|
|
|
|
|
|
|
import com.jianshui.invoice.domain.ele.HZSQDMessage; |
|
|
|
import com.jianshui.invoice.utils.elephant.ElephantUtils; |
|
|
|
import com.jianshui.invoice.utils.elephant.ElephantUtils; |
|
|
|
import com.jianshui.platform.dto.InvoiceAdd.BillInfoPDTO; |
|
|
|
import com.jianshui.platform.dto.InvoiceAdd.BillInfoPDTO; |
|
|
|
import com.jianshui.invoice.domain.Redinfo; |
|
|
|
import com.jianshui.invoice.domain.Redinfo; |
|
|
@ -38,6 +46,7 @@ import javax.servlet.http.HttpServletRequest; |
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
import java.security.InvalidKeyException; |
|
|
|
import java.security.InvalidKeyException; |
|
|
|
import java.security.NoSuchAlgorithmException; |
|
|
|
import java.security.NoSuchAlgorithmException; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @Description |
|
|
|
* @Description |
|
|
@ -69,53 +78,91 @@ public class InvoiceController { |
|
|
|
private InvoiceAddPService addService; |
|
|
|
private InvoiceAddPService addService; |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/api/v1/test") |
|
|
|
@GetMapping("/api/v1/test") |
|
|
|
public Object test(){ |
|
|
|
public EleNewMessage test() { |
|
|
|
Companyservice companyservice = new Companyservice(); |
|
|
|
Companyservice companyservice = new Companyservice(); |
|
|
|
FindRedInfo findRedInfo = new FindRedInfo(); |
|
|
|
FindRedInfo findRedInfo = new FindRedInfo(); |
|
|
|
findRedInfo.setSQBQQPCH("127021937706230911155203"); |
|
|
|
findRedInfo.setSQBQQPCH("127021937706230911155203"); |
|
|
|
findRedInfo.setNSRSBH("91370921MACWQ1520M"); |
|
|
|
findRedInfo.setNSRSBH("91370921MACWQ1520M"); |
|
|
|
AjaxResult queryResult = null; |
|
|
|
DxhyInterfaceResponse dxhyInterfaceResponse = null; |
|
|
|
try { |
|
|
|
try { |
|
|
|
queryResult = ElephantUtils.sendRequestWithoutTokenV6(ElephantConstants.REDINFO_FIND_LOCALHOST, ElephantConstants.REDINFO_FIND_METHOD, JSONUtil.parse(findRedInfo), companyservice); |
|
|
|
dxhyInterfaceResponse = ElephantUtils.sendRequestWithoutTokenV6(ElephantConstants.REDINFO_FIND_LOCALHOST, |
|
|
|
|
|
|
|
ElephantConstants.REDINFO_FIND_METHOD, JSONUtil.parse(findRedInfo), companyservice); |
|
|
|
} catch (UnsupportedEncodingException | InvalidKeyException | NoSuchAlgorithmException e) { |
|
|
|
} catch (UnsupportedEncodingException | InvalidKeyException | NoSuchAlgorithmException e) { |
|
|
|
log.error("【销项发票】【大象接口】【红字信息表查询】发票请求异常,请求报文{},销方信息{}", JSONUtil.parse(findRedInfo).toString(), JSONObject.toJSONString(companyservice)); |
|
|
|
log.error("【销项发票】【大象接口】【红字信息表查询】发票请求异常,请求报文{},销方信息{}", |
|
|
|
|
|
|
|
JSONUtil.parse(findRedInfo).toString(), JSONObject.toJSONString(companyservice)); |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
throw new JianshuiServiceException("系统异常!"); |
|
|
|
throw new JianshuiServiceException("系统异常!"); |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
String data = dxhyInterfaceResponse.getData(); |
|
|
|
|
|
|
|
cn.hutool.json.JSONObject dataStr = new cn.hutool.json.JSONObject(data); |
|
|
|
|
|
|
|
if ("000000".equals(dataStr.getStr("ZTDM"))) { |
|
|
|
|
|
|
|
Gson gson = new Gson(); |
|
|
|
|
|
|
|
EleOuterMessage eleOuterMessage = gson.fromJson(data, EleOuterMessage.class); |
|
|
|
|
|
|
|
String inMsg = ""; |
|
|
|
|
|
|
|
String inMsgInfo = ""; |
|
|
|
|
|
|
|
List<HZSQDMessage> hzsqdxzzxx = eleOuterMessage.getHZSQDXZZXX(); |
|
|
|
|
|
|
|
for (HZSQDMessage hzsqdMessage : hzsqdxzzxx) { |
|
|
|
|
|
|
|
inMsg = hzsqdMessage.getHZSQDXZTXX().getZTDM(); |
|
|
|
|
|
|
|
inMsgInfo = hzsqdMessage.getHZSQDXZTXX().getZTXX(); |
|
|
|
|
|
|
|
hzsqdMessage.getHZSQDXZTXX().setBillNo(findRedInfo.getSQBQQPCH()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
EleNewMessage eleNewMessage = new EleNewMessage(); |
|
|
|
|
|
|
|
BeanUtil.copyProperties(eleOuterMessage, eleNewMessage); |
|
|
|
|
|
|
|
eleNewMessage.setStatus(eleOuterMessage.getZTDM().substring(eleOuterMessage.getZTDM().length() - 4)); |
|
|
|
|
|
|
|
if ("060000".equals(inMsg)) { |
|
|
|
|
|
|
|
eleNewMessage.setMessage(inMsgInfo); |
|
|
|
|
|
|
|
eleNewMessage.setData(eleOuterMessage.getHZSQDXZZXX()); |
|
|
|
|
|
|
|
return eleNewMessage; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
eleNewMessage.setMessage(inMsgInfo); |
|
|
|
|
|
|
|
eleNewMessage.setData(eleOuterMessage.getHZSQDXZZXX()); |
|
|
|
|
|
|
|
return eleNewMessage; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
EleNewMessage eleNewMessage = new EleNewMessage(); |
|
|
|
|
|
|
|
eleNewMessage.setStatus("9999"); |
|
|
|
|
|
|
|
eleNewMessage.setMessage("接口请求失败"); |
|
|
|
|
|
|
|
return eleNewMessage; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 功能描述: 红字查询接口 |
|
|
|
* 功能描述: 红字查询接口 |
|
|
|
|
|
|
|
* |
|
|
|
* @param identity |
|
|
|
* @param identity |
|
|
|
* @return : com.jianshui.invoice.domain.dto.HXResponse |
|
|
|
* @return : com.jianshui.invoice.domain.dto.HXResponse |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@PostMapping({"/api/invoice/v1/findRedInfo", "/api/invoice/v1/findRedInfo/{identity}", "/invoice/findRedInfo"}) |
|
|
|
@PostMapping({"/api/invoice/v1/findRedInfo", "/api/invoice/v1/findRedInfo/{identity}", "/invoice/findRedInfo"}) |
|
|
|
public Object findRedInfo(HttpServletRequest request,String identity) throws Exception { |
|
|
|
public EleNewMessage findRedInfo(HttpServletRequest request, String identity) throws Exception { |
|
|
|
log.info("开始执行"); |
|
|
|
log.info("开始执行"); |
|
|
|
if (StringUtils.isEmpty(identity)) { |
|
|
|
if (StringUtils.isEmpty(identity)) { |
|
|
|
return AjaxResult.error(ErrorCode.EMPTY_IDENTITY); |
|
|
|
EleNewMessage eleNewMessage = new EleNewMessage(); |
|
|
|
|
|
|
|
eleNewMessage.setStatus("9999"); |
|
|
|
|
|
|
|
eleNewMessage.setMessage("身份认证参数为空"); |
|
|
|
|
|
|
|
return eleNewMessage; |
|
|
|
} |
|
|
|
} |
|
|
|
Companyservice companyservice = iCompanyserviceService.selectCompanyserviceByIdentity(identity); |
|
|
|
Companyservice companyservice = iCompanyserviceService.selectCompanyserviceByIdentity(identity); |
|
|
|
if (companyservice == null) { |
|
|
|
if (companyservice == null) { |
|
|
|
return AjaxResult.error(ErrorCode.COMPANY_NOT_FOUND); |
|
|
|
EleNewMessage eleNewMessage = new EleNewMessage(); |
|
|
|
|
|
|
|
eleNewMessage.setStatus("9999"); |
|
|
|
|
|
|
|
eleNewMessage.setMessage("企业信息不存在"); |
|
|
|
|
|
|
|
return eleNewMessage; |
|
|
|
} |
|
|
|
} |
|
|
|
String requestAdapterKey = serviceManageService.getRequestAdapterKey("invoice", companyservice.getCompanyid()); |
|
|
|
String requestAdapterKey = serviceManageService.getRequestAdapterKey("invoice", companyservice.getCompanyid()); |
|
|
|
IInvoiceRequestService invoiceRequestService = invoiceRequestFactory.getService(requestAdapterKey); |
|
|
|
IInvoiceRequestService invoiceRequestService = invoiceRequestFactory.getService(requestAdapterKey); |
|
|
|
JSONObject decryptResult = invoiceRequestService.decrypt(request, companyservice, "find_redinfo"); |
|
|
|
JSONObject decryptResult = invoiceRequestService.decrypt(request, companyservice, "find_redinfo"); |
|
|
|
// 获得请求实例,并且进行扣费
|
|
|
|
// 获得请求实例,并且进行扣费
|
|
|
|
log.info("解密数据{}", decryptResult); |
|
|
|
log.info("解密数据{}", decryptResult); |
|
|
|
FindRedInfo findRedInfo = decryptResult.toJavaObject(FindRedInfo.class); |
|
|
|
FindRedInfoDTO findRedInfoDTO = decryptResult.toJavaObject(FindRedInfoDTO.class); |
|
|
|
|
|
|
|
FindRedInfo findRedInfo = new FindRedInfo(); |
|
|
|
|
|
|
|
findRedInfo.setSQBQQPCH(findRedInfoDTO.getBillNo()); |
|
|
|
|
|
|
|
findRedInfo.setNSRSBH(findRedInfoDTO.getNSRSBH()); |
|
|
|
log.info("转换数据{}", JSONUtil.toJsonStr(findRedInfo)); |
|
|
|
log.info("转换数据{}", JSONUtil.toJsonStr(findRedInfo)); |
|
|
|
String serviceKey = serviceManageService.getCompanyServiceSupplier("invoice", companyservice.getCompanyid()); |
|
|
|
String serviceKey = serviceManageService.getCompanyServiceSupplier("invoice", companyservice.getCompanyid()); |
|
|
|
serviceManageService.companyConsume("invoice", companyservice.getCompanyid()); |
|
|
|
serviceManageService.companyConsume("invoice", companyservice.getCompanyid()); |
|
|
|
IInvoiceApiService invoiceService = invoiceServiceFactory.getService(serviceKey); |
|
|
|
IInvoiceApiService invoiceService = invoiceServiceFactory.getService(serviceKey); |
|
|
|
HXResponse result = invoiceService.findRedInfo(findRedInfo, companyservice); |
|
|
|
EleNewMessage result = invoiceService.findRedInfo(findRedInfo, companyservice); |
|
|
|
|
|
|
|
return result; |
|
|
|
String responseAdapterKey = serviceManageService.getResponseAdapterKey("invoice", companyservice.getCompanyid()); |
|
|
|
|
|
|
|
IInvoiceResponseService invoiceResponseService = invoiceResponseFactory.getService(responseAdapterKey); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return invoiceResponseService.response(result, companyservice, "find_redinfo"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -404,7 +451,9 @@ public class InvoiceController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 红字信息表上传*/ |
|
|
|
/** |
|
|
|
|
|
|
|
* 红字信息表上传 |
|
|
|
|
|
|
|
*/ |
|
|
|
@Validated |
|
|
|
@Validated |
|
|
|
// @ApiOperation("红字信息表上传")
|
|
|
|
// @ApiOperation("红字信息表上传")
|
|
|
|
@ApiImplicitParams({ |
|
|
|
@ApiImplicitParams({ |
|
|
@ -1366,6 +1415,4 @@ public class InvoiceController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|