From 63857fd37af02f0d01fcea13355aceaad19aa59c Mon Sep 17 00:00:00 2001 From: dongxiaoke <1910333201@qq.com> Date: Mon, 24 Apr 2023 09:08:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AD=E4=BA=A4=E5=BB=BA-=E9=94=80=E9=A1=B9?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E6=B5=8B=E8=AF=95:=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=99=BB=E8=AE=B0=E6=8E=A5=E5=8F=A3=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../http/invoice/v1/InvoiceController.java | 16 +- .../jianshui/common/utils/HutoolUtilsPro.java | 37 +++ .../service/impl/InvoiceAllImpl.java | 11 +- .../AisinoInvoiceRequestAdapterImpl.java | 3 +- .../JcskInvoiceRequestAdapterImpl.java | 228 ---------------- .../JcskInvoiceResponseAdapterImpl.java | 246 ------------------ .../impl/api/JcskInvoiceApiServiceImpl.java | 33 ++- .../com/jianshui/invoice/utils/JcskTest.java | 2 +- 8 files changed, 94 insertions(+), 482 deletions(-) create mode 100644 jianshui-common/src/main/java/com/jianshui/common/utils/HutoolUtilsPro.java delete mode 100644 jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/JcskInvoiceRequestAdapterImpl.java delete mode 100644 jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/response/JcskInvoiceResponseAdapterImpl.java diff --git a/jianshui-admin/src/main/java/com/jianshui/api/controller/http/invoice/v1/InvoiceController.java b/jianshui-admin/src/main/java/com/jianshui/api/controller/http/invoice/v1/InvoiceController.java index cd07148..440c85c 100644 --- a/jianshui-admin/src/main/java/com/jianshui/api/controller/http/invoice/v1/InvoiceController.java +++ b/jianshui-admin/src/main/java/com/jianshui/api/controller/http/invoice/v1/InvoiceController.java @@ -167,7 +167,21 @@ public class InvoiceController { IInvoiceRequestService invoiceRequestService = invoiceRequestFactory.getService(requestAdapterKey); JSONObject decryptResult = invoiceRequestService.decrypt(request, companyservice, "add"); - HXResponse result = preHandleDecryptResult(decryptResult, "add", companyservice); + // 报文处理 + BillInfo billInfo = decryptResult.toJavaObject(BillInfo.class); + if (billInfo == null) { + throw new JianshuiParamErrorException(ErrorCode.ERROR_PARAMS, companyservice, "invoice"); + } + + billInfo.setSource("2"); + // 获得请求实例,并且进行扣费 + String serviceKey = serviceManageService.getCompanyServiceSupplier("invoice", companyservice.getCompanyid()); + serviceManageService.companyConsume("invoice", companyservice.getCompanyid()); + billInfo.setServiceSupplierKey(serviceKey); + IInvoiceApiService invoiceService = invoiceServiceFactory.getService(serviceKey); + HXResponse result = invoiceService.addInvoice(billInfo, companyservice); + +// HXResponse result = preHandleDecryptResult(decryptResult, "add", companyservice); String responseAdapterKey = serviceManageService.getResponseAdapterKey("invoice", companyservice.getCompanyid()); IInvoiceResponseService invoiceResponseService = invoiceResponseFactory.getService(responseAdapterKey); diff --git a/jianshui-common/src/main/java/com/jianshui/common/utils/HutoolUtilsPro.java b/jianshui-common/src/main/java/com/jianshui/common/utils/HutoolUtilsPro.java new file mode 100644 index 0000000..ce1e391 --- /dev/null +++ b/jianshui-common/src/main/java/com/jianshui/common/utils/HutoolUtilsPro.java @@ -0,0 +1,37 @@ +package com.jianshui.common.utils; + +import org.springframework.beans.BeanWrapper; +import org.springframework.beans.BeanWrapperImpl; + +import java.util.HashSet; +import java.util.Set; + + +/** + * hutool工具类处理 + * kk + */ +public class HutoolUtilsPro { + + + /** + * 修改BeanUtils.copy null属性覆盖的问题,判断null属性加入忽略列表 + * @param source + * @return + */ + public static String[] getNullPropertyNames (Object source) { + final BeanWrapper src = new BeanWrapperImpl(source); + java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors(); + + Set emptyNames = new HashSet(); + for(java.beans.PropertyDescriptor pd : pds) { + Object srcValue = src.getPropertyValue(pd.getName()); + if (srcValue == null) emptyNames.add(pd.getName()); + } + String[] result = new String[emptyNames.size()]; + return emptyNames.toArray(result); + } + + + +} diff --git a/jianshui-invoice-all/src/main/java/com/jianshui/invoiceall/service/impl/InvoiceAllImpl.java b/jianshui-invoice-all/src/main/java/com/jianshui/invoiceall/service/impl/InvoiceAllImpl.java index dd4179e..c0b8890 100644 --- a/jianshui-invoice-all/src/main/java/com/jianshui/invoiceall/service/impl/InvoiceAllImpl.java +++ b/jianshui-invoice-all/src/main/java/com/jianshui/invoiceall/service/impl/InvoiceAllImpl.java @@ -1,6 +1,7 @@ package com.jianshui.invoiceall.service.impl; import java.util.Date; +import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.date.DateUtil; import java.math.BigDecimal; @@ -17,6 +18,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.jianshui.common.core.domain.AjaxResult; import com.jianshui.common.core.domain.entity.Companyservice; import com.jianshui.common.enums.ErrorCode; +import com.jianshui.common.utils.HutoolUtilsPro; import com.jianshui.common.utils.StringUtils; import com.jianshui.common.utils.ValidateUtils; import com.jianshui.common.utils.uuid.IdUtils; @@ -89,7 +91,9 @@ public class InvoiceAllImpl implements IInvoiceAll { ValidateUtils.validate(yhdjDetailDTOList); yhdjDTO.setJsonData(yhdjDetailDTOList); - JSONObject result = null; +// JSONObject result = null; + JSONObject result = new JSONObject(); + try { result = ApiHttp.request(WebServiceConstant.YHDJ, WebServiceConstant.URL, yhdjDTO, companyservice); @@ -98,14 +102,15 @@ public class InvoiceAllImpl implements IInvoiceAll { String data = result.get("data") != null ? result.get("data").toString() : ""; if ("0000".equals(code)) { - InvoiceAllYhdj yhdj = BeanUtil.copyProperties(yhdjDTO.getJsonData(), InvoiceAllYhdj.class); + InvoiceAllYhdj yhdj = BeanUtil.copyProperties(yhdjDTO, InvoiceAllYhdj.class); QueryWrapper yhdjQueryWrapper = new QueryWrapper<>(); yhdjQueryWrapper.eq("nsrsbh", yhdj.getNsrsbh()); yhdjQueryWrapper.eq("identity", companyservice.getIdentity()); InvoiceAllYhdj yhdjTemp = yhdjMapper.selectOne(yhdjQueryWrapper); + if (BeanUtil.isNotEmpty(yhdjTemp)) { - yhdjTemp = BeanUtil.copyProperties(yhdj, InvoiceAllYhdj.class); + BeanUtil.copyProperties(yhdj,yhdjTemp,CopyOptions.create().setIgnoreNullValue(true)) ; yhdjTemp.setUpdateTime(new Date()); yhdjMapper.updateInvoiceAllYhdj(yhdjTemp); } else { diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/AisinoInvoiceRequestAdapterImpl.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/AisinoInvoiceRequestAdapterImpl.java index fc5a559..52cbbdf 100644 --- a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/AisinoInvoiceRequestAdapterImpl.java +++ b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/AisinoInvoiceRequestAdapterImpl.java @@ -101,7 +101,8 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService { // 平台解密 try { - order = AisinoInvoiceDecryptUtil.decrypt(order, JKey); + // TODO: 2023/4/23 调试屏蔽 +// order = AisinoInvoiceDecryptUtil.decrypt(order, JKey); } catch (Exception e) { e.printStackTrace(); throw new JianshuiParamErrorException(ErrorCode.DECRYPT_ERROR, companyservice, "invoice"); diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/JcskInvoiceRequestAdapterImpl.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/JcskInvoiceRequestAdapterImpl.java deleted file mode 100644 index 34474d4..0000000 --- a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/JcskInvoiceRequestAdapterImpl.java +++ /dev/null @@ -1,228 +0,0 @@ -package com.jianshui.invoice.service.impl.adapter.request; - -import com.alibaba.fastjson.JSONObject; -import com.jianshui.common.core.domain.entity.Companyservice; -import com.jianshui.common.enums.ErrorCode; -import com.jianshui.common.exception.jianshui.JianshuiParamErrorException; -import com.jianshui.common.utils.IdcardUtils; -import com.jianshui.common.utils.StringUtils; -import com.jianshui.common.utils.encrypt.AisinoInvoiceDecryptUtil; -import com.jianshui.invoice.domain.BillDetail; -import com.jianshui.invoice.domain.BillInfo; -import com.jianshui.invoice.domain.Redinfo; -import com.jianshui.invoice.domain.Redinfodetail; -import com.jianshui.invoice.domain.dto.DownloadRedInfoDTO; -import com.jianshui.invoice.domain.dto.adapter.request.aisino_jn.HxBillDetailDTO; -import com.jianshui.invoice.domain.dto.adapter.request.aisino_jn.HxBillInfoDTO; -import com.jianshui.invoice.domain.dto.adapter.request.aisino_jn.HxRedInfoDTO; -import com.jianshui.invoice.domain.dto.adapter.request.aisino_jn.HxRedInfoDetailsDTO; -import com.jianshui.invoice.service.IInvoiceRequestService; -import com.jianshui.system.service.ICompanyserviceService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.servlet.http.HttpServletRequest; -import java.util.*; - -/** - * @Description 航信入口报文适配器 - * @Author 巩权林 - * @Date 2022/3/19 21:28 - **/ -@Slf4j -@Component("jn_jcsk_invoice_request_adapter") -public class JcskInvoiceRequestAdapterImpl implements IInvoiceRequestService { - - @Autowired - private ICompanyserviceService companyserviceService; - - /** - * 解密函数 - * - * @param request - * @param companyservice - * @return - */ - @Override - public JSONObject decrypt(HttpServletRequest request, Companyservice companyservice, String serviceKey) { - // 根据servletRequest获取原始请求报文 - // String rawInput = HttpHelper.getBodyString(request); - // if (StringUtils.isEmpty(rawInput)) { - // throw new JianshuiParamErrorException(ErrorCode.EMPTY_PARAMS,"invoice); - // } - // JSONObject rawJson = JSONObject.parseObject(rawInput); - // 因为航信的报文都是Form,所以这里要按form的来 - //方式一:getParameterMap(),获得请求参数map - Map map = request.getParameterMap(); - //参数名称 - Set key = map.keySet(); - //参数迭代器 - Iterator iterator = key.iterator(); - // JSONObject rawJson = JSONObject.parseObject(JSONObject.toJSONString(params)); - JSONObject rawJson = new JSONObject(); - while (iterator.hasNext()) { - String k = iterator.next(); - rawJson.put(k, map.get(k)[0]); - } - - - if (StringUtils.isEmpty(rawJson)) { - throw new JianshuiParamErrorException(ErrorCode.ERROR_PARAMS, companyservice, "invoice"); - } - - String order = rawJson.getString("order"); - String identity = rawJson.getString("identity"); - - log.info("【航信转invoice请求适配器】客户请求报文原始数据:{},销方id:{},serviceKey:{}", rawJson, companyservice.getCompanyid(), serviceKey); - - // 开始解析报文 - if (order == null || "".equals(order.trim())) { - throw new JianshuiParamErrorException(ErrorCode.ERROR_PARAMS, companyservice, "invoice"); - } - - String JKey = companyservice.getSecret(); // 解密用的secret - if (StringUtils.isEmpty(JKey)) { - throw new JianshuiParamErrorException(ErrorCode.IDENTITY_NOT_SET, companyservice, "jcsk"); - } - - // 平台解密 - try { - order = AisinoInvoiceDecryptUtil.decrypt(order, JKey); - } catch (Exception e) { - e.printStackTrace(); - throw new JianshuiParamErrorException(ErrorCode.DECRYPT_ERROR, companyservice, "jcsk"); - } - - - log.info("销项报文:identity=" + identity + ",order=" + order); - - // 报文内容体 - JSONObject json = new JSONObject(); - try { - // 根据用户封装参数进行区别处理 - JSONObject orderJson = JSONObject.parseObject(order); - String myIdentity = orderJson.getString("identity"); - if (myIdentity != null) { - // order里面有identity的情况,取出来order - JSONObject tempJson = new JSONObject(); - tempJson = orderJson.getJSONObject("order"); - if (tempJson != null) { - orderJson = tempJson; - } - } - - json = orderJson; - - // 如果是开票或者查询 - if (StringUtils.equals(serviceKey, "add") || StringUtils.equals(serviceKey, "query")) { - // 开始把航信报文转成billInfo - HxBillInfoDTO hxBillInfo = json.toJavaObject(HxBillInfoDTO.class); - BillInfo billInfo = new BillInfo(); - BeanUtils.copyProperties(hxBillInfo, billInfo); - if(StringUtils.isNotEmpty(hxBillInfo.getEmail())){ - billInfo.setBuyerEmail(hxBillInfo.getEmail()); - } - if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) { - String bankNo = IdcardUtils.getBankNo(billInfo.getBuyerAccount()); - if (StringUtils.isNotEmpty(bankNo)) { - String raw = billInfo.getBuyerAccount(); - billInfo.setBuyerAccount(bankNo); - billInfo.setBuyerBank(raw.replace(bankNo, "")); - } - } - // 处理detail - List hxBillDetailList = hxBillInfo.getDetail(); - List detailList = new ArrayList<>(); - if (hxBillDetailList != null && hxBillDetailList.size() > 0) { - for (HxBillDetailDTO detial : hxBillDetailList) { - BillDetail temp = new BillDetail(); - BeanUtils.copyProperties(detial, temp); - detailList.add(temp); - } - billInfo.setBillDetailList(detailList); - } - - if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) { - String bankNo = IdcardUtils.getBankNo(billInfo.getBuyerAccount()); - if (StringUtils.isNotEmpty(bankNo)) { - String raw = billInfo.getBuyerAccount(); - billInfo.setBuyerAccount(bankNo); - billInfo.setBuyerBank(raw.replace(bankNo, "")); - } - } - // 处理销方信息 - if (StringUtils.isEmpty(billInfo.getSellerBank()) && StringUtils.isNotEmpty(billInfo.getSellerAccount())) { - String bankNo = IdcardUtils.getBankNo(billInfo.getSellerAccount()); - if (StringUtils.isNotEmpty(bankNo)) { - String raw = billInfo.getSellerAccount(); - billInfo.setSellerAccount(bankNo); - billInfo.setSellerBank(raw.replace(bankNo, "")); - } - } - - json = (JSONObject) JSONObject.toJSON(billInfo); - } - - // 如果是redinfo - if (StringUtils.equals(serviceKey, "add_redinfo")) { - // 开始把航信报文转成billInfo - HxRedInfoDTO hxBillInfo = json.toJavaObject(HxRedInfoDTO.class); - Redinfo billInfo = new Redinfo(); - BeanUtils.copyProperties(hxBillInfo, billInfo); - - - // 处理detail - List hxBillDetailList = hxBillInfo.getRedinfodetailList(); - List detailList = new ArrayList<>(); - for (int i = 0; i < hxBillDetailList.size(); i++) { - HxRedInfoDetailsDTO detial = hxBillDetailList.get(i); - Redinfodetail temp = new Redinfodetail(); - BeanUtils.copyProperties(detial, temp); - temp.setIndex(i); - detailList.add(temp); - } - billInfo.setRedinfodetailList(detailList); - json = (JSONObject) JSONObject.toJSON(billInfo); - } - - // 如果是发票作废 - if (StringUtils.equals(serviceKey, "deprecate")) { - return json; - } - - // 如果是红字信息表下载 - if (StringUtils.equals(serviceKey, "download_redinfo")) { - DownloadRedInfoDTO downloadRedInfoDTO = json.toJavaObject(DownloadRedInfoDTO.class); - json = (JSONObject) JSONObject.toJSON(downloadRedInfoDTO); - return json; - } - - // 如果是发票打印 - if (StringUtils.equals(serviceKey, "batch_print")) { - // JSONArray detail = json.getJSONArray("dyfpxx"); - // for (int i = 0; i < detail.size(); i++) { - // JSONObject temp = (JSONObject) detail.get(i); - // String fplxdm = ElephantUtils.transElephantType(temp.getString("fpzldm"), 1); - // temp.put("fpzldm", fplxdm); - // detail.set(i, temp); - // } - return json; - } - - } catch (JianshuiParamErrorException e) { - throw e; - } catch (Exception e) { - e.printStackTrace(); - throw new JianshuiParamErrorException(ErrorCode.DECRYPT_ERROR, companyservice, "invoice"); - } - - return json; - } - - @Override - public String covertMethodName(String method) { - return null; - } -} diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/response/JcskInvoiceResponseAdapterImpl.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/response/JcskInvoiceResponseAdapterImpl.java deleted file mode 100644 index ed832d7..0000000 --- a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/response/JcskInvoiceResponseAdapterImpl.java +++ /dev/null @@ -1,246 +0,0 @@ -package com.jianshui.invoice.service.impl.adapter.response; - -import com.alibaba.fastjson.JSONObject; -import com.jianshui.common.core.domain.AjaxResult; -import com.jianshui.common.core.domain.entity.Companyservice; -import com.jianshui.common.exception.jianshui.JianshuiParamErrorException; -import com.jianshui.common.utils.DictUtils; -import com.jianshui.common.utils.StringUtils; -import com.jianshui.common.utils.bean.BeanUtils; -import com.jianshui.invoice.domain.BillInfo; -import com.jianshui.invoice.domain.Invoice; -import com.jianshui.invoice.domain.InvoiceDetail; -import com.jianshui.invoice.domain.Redinfo; -import com.jianshui.invoice.domain.dto.HXResponse; -import com.jianshui.invoice.domain.dto.adapter.response.aisino_jn.AisinoJnInvoiceDetailResponse; -import com.jianshui.invoice.domain.dto.adapter.response.aisino_jn.AisinoJnInvoiceResponse; -import com.jianshui.invoice.service.IInvoiceResponseService; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.List; - -/** - * @Description 航信出口报文适配器 - * @Author 巩权林 - * @Date 2022/3/19 21:28 - **/ -@Component("jn_jcsk_invoice_response_adapter") -public class JcskInvoiceResponseAdapterImpl implements IInvoiceResponseService { - - @Override - public JSONObject response(HXResponse result, Companyservice companyservice, String query) { - - // 如果是开具 - if (StringUtils.equals("add", query)) { - return result; - } - - // 如果是发票查询 - if (StringUtils.equals("query", query)) { - // 判断有无data - Object datas = result.getData(); - - // 如果datas不为Null - if (datas != null) { - // 如果返回将诶过为invioce - List responses = new ArrayList<>(); - if (datas instanceof List) { - for (int ij = 0; ij < ((List) datas).size(); ij++) { - Object data = ((List) datas).get(ij); - // 转为HxInvoice - Invoice invoice = (Invoice) data; - if (invoice == null) { - continue; - } - AisinoJnInvoiceResponse invoiceResponse = new AisinoJnInvoiceResponse(); - BeanUtils.copyProperties(invoice, invoiceResponse); - String invoiceType = DictUtils.getDictLabel("invoice_type", invoice.getInvoiceType()); - if (invoiceType != null) { - invoiceResponse.setInvoiceType(invoiceType); - } - - // 处理发票状态 - - // 处理Detail - List detailList = invoice.getInvoiceDetailList(); - if (detailList != null) { - List invoiceDetailResponses = new ArrayList<>(); - for (int i = 0; i < detailList.size(); i++) { - AisinoJnInvoiceDetailResponse response = new AisinoJnInvoiceDetailResponse(); - InvoiceDetail tempDetail = detailList.get(i); - BeanUtils.copyProperties(tempDetail, response); - Integer hsbz = tempDetail.getHsbz(); - if (hsbz == 0) { - response.setHsbz("false"); - response.setTaxamt(null); - // 如果不含税 - } else { - // 如果含税 - response.setHsbz("true"); - response.setTaxfreeamt(response.getTaxamt()); - } - invoiceDetailResponses.add(response); - } - invoiceResponse.setInvoiceDetailList(invoiceDetailResponses); - } - responses.add(invoiceResponse); - } - - JSONObject queryResult = new JSONObject(); - queryResult.put("result", result.getMessage()); - queryResult.put("list", responses); - return queryResult; - } - - } - JSONObject queryResult = new JSONObject(); - queryResult.put("result", result.getMessage()); - queryResult.put("list", new ArrayList<>()); - } - - // 如果是开具红票 - if (StringUtils.equals("add_redinfo", query)) { - return result; - } - - // 如果是下载红票 - if (StringUtils.equals("download_redinfo", query)) { - - Object datas = result.getData(); - - // 如果datas不为Null - if (datas != null) { - // 如果返回将诶过为invioce - // List responses = new ArrayList<>(); - // if (datas instanceof List) { - // } - } - - return result; - } - - // 如果是打印 - if (StringUtils.equals("printer", query)) { - - Object datas = result.getData(); - - // 如果datas不为Null - if (datas != null) { - // 如果返回将诶过为invioce - // List responses = new ArrayList<>(); - // if (datas instanceof List) { - // } - } - - return result; - } - - // 作废查询 - if (StringUtils.equals("deprecate_query", query)) { - Object datas = result.getData(); - if (datas != null) { - JSONObject dataJson = (JSONObject) datas; - // String status = dataJson.getString("status"); - JSONObject result2 = new JSONObject(); - result2.put("message", "操作完成"); - result2.put("status", "0000"); - result2.put("data", dataJson); - // if (StringUtils.equals(status, "3")) { - // result2.put("code", "0000"); - // result2.put("msg", "作废成功"); - // } else if (StringUtils.equals(status, "1")) { - // result2.put("code", "9998"); - // result2.put("msg", "作废中"); - // } else { - // result2.put("code", "9998"); - // result2.put("msg", "作废失败"); - // } - return result2; - } - } - - if (StringUtils.equals("sign_e_seal", query)) { - AjaxResult resp = AjaxResult.success(); - Object data = result.getData(); - if (!StringUtils.equals("0000", result.getStatus())) { - resp = AjaxResult.error(result.getMessage()); - return JSONObject.parseObject(JSONObject.toJSONString(resp)); - } - JSONObject dataJson = (JSONObject) data; - if (StringUtils.equals("0000", dataJson.getString("CODE"))) { - // result.put("code", "200"); - // result.put("data", dataJson.getJSONObject("data")); - resp.put("data", dataJson.getJSONObject("DATA")); - return JSONObject.parseObject(JSONObject.toJSONString(resp)); - }else{ - // result.put("code", dataJson.getString("CODE")); - // result.put("message", dataJson.getJSONObject("MESSAGE")); - resp.put("code", dataJson.getString("CODE")); - resp.put("message", dataJson.getString("MESSAGE")); - return JSONObject.parseObject(JSONObject.toJSONString(resp)); - } - } - if (StringUtils.equals("register_e_seal", query)) { - AjaxResult resp = AjaxResult.success(); - Object data = result.getData(); - if (!StringUtils.equals("0000", result.getStatus())) { - resp = AjaxResult.error(result.getMessage()); - return JSONObject.parseObject(JSONObject.toJSONString(resp)); - } - JSONObject dataJson = (JSONObject) data; - if (StringUtils.equals("0000", dataJson.getString("CODE"))) { - // result.put("code", "200"); - // result.put("data", dataJson.getJSONObject("data")); - resp.put("data", dataJson.getJSONObject("DATA")); - return JSONObject.parseObject(JSONObject.toJSONString(resp)); - }else{ - // result.put("code", dataJson.getString("CODE")); - // result.put("message", dataJson.getJSONObject("MESSAGE")); - resp.put("code", dataJson.getString("CODE")); - resp.put("message", dataJson.getString("MESSAGE")); - return JSONObject.parseObject(JSONObject.toJSONString(resp)); - } - } - if (StringUtils.equals("create_e_seal", query)) { - AjaxResult resp = AjaxResult.success(); - Object data = result.getData(); - if (!StringUtils.equals("0000", result.getStatus())) { - resp = AjaxResult.error(result.getMessage()); - return JSONObject.parseObject(JSONObject.toJSONString(resp)); - } - JSONObject dataJson = (JSONObject) data; - if (StringUtils.equals("0000", dataJson.getString("CODE"))) { - // result.put("code", "200"); - // result.put("data", dataJson.getJSONObject("data")); - resp.put("data", dataJson.getJSONObject("DATA")); - return JSONObject.parseObject(JSONObject.toJSONString(resp)); - }else{ - // result.put("code", dataJson.getString("CODE")); - // result.put("message", dataJson.getJSONObject("MESSAGE")); - resp.put("code", dataJson.getString("CODE")); - resp.put("message", dataJson.getString("MESSAGE")); - return JSONObject.parseObject(JSONObject.toJSONString(resp)); - } - } - - - return result; - } - - @Override - public Object response(JianshuiParamErrorException result, Companyservice companyservice) { - // JSONObject myResult = new JSONObject(); - // myResult.put("status", result.getErrorCode()); - // myResult.put("message", result.getMsg()); - // return myResult; - AjaxResult resp = AjaxResult.error(result.getErrorCode(), null); - resp.put("msg", result.getMsg()); - return resp; - } - - @Override - public AjaxResult callback(BillInfo billInfo, Invoice invoice, Redinfo redinfo, Companyservice companyservice, String src) { - return null; - } -} diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/JcskInvoiceApiServiceImpl.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/JcskInvoiceApiServiceImpl.java index d15fc79..482cc6d 100644 --- a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/JcskInvoiceApiServiceImpl.java +++ b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/JcskInvoiceApiServiceImpl.java @@ -91,8 +91,33 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { String kpType = billInfo.getKptype(); if ("1".equals(kpType)) { + + // 查询用户登记参数 + QueryWrapper yhdjQueryWrapper = new QueryWrapper<>(); + yhdjQueryWrapper.eq("nsrsbh", companyservice.getSellertax()); + yhdjQueryWrapper.eq("identity", companyservice.getIdentity()); + InvoiceAllYhdj invoiceAllYhdj = yhdjMapper.selectOne(yhdjQueryWrapper); + + if (BeanUtil.isEmpty(invoiceAllYhdj)) { + return new HXResponse("用户未登记!"); + } + + QueryTwoDTO queryDTO = new QueryTwoDTO(); + queryDTO.setDqbm(invoiceAllYhdj.getDqbm()); + queryDTO.setAsync("false"); + queryDTO.setBsrysfzjhm(invoiceAllYhdj.getBsrysfzjhm()); + queryDTO.setNsrsbh(invoiceAllYhdj.getNsrsbh()); + queryDTO.setRequestId("tycxjk"); + + ValidateUtils.validate(queryDTO); + + + // 开票实体转换,校验 InvoiceAllAddTwoDTO invoiceAllAddTwoDTO = BeanUtil.copyProperties(billInfo, InvoiceAllAddTwoDTO.class); + invoiceAllAddTwoDTO.setDqbm(queryDTO.getDqbm()); + invoiceAllAddTwoDTO.setBsrysfzjhm(queryDTO.getBsrysfzjhm()); + invoiceAllAddTwoDTO.setNsrsbh(queryDTO.getNsrsbh()); ValidateUtils.validate(invoiceAllAddTwoDTO); InvoiceAllAddInfoTwoDTO invoiceAllAddInfoTwoDTO = BeanUtil.copyProperties(billInfo, InvoiceAllAddInfoTwoDTO.class); @@ -130,8 +155,12 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { } cn.hutool.json.JSONObject result = null; - try { + // TODO: 2023/4/23 调试 + log.info("金财数科蓝字请求报文打印=",JSONUtil.parse(invoiceAllAddTwoDTO)); + return null; + + /*try { result = ApiHttp.request(WebServiceConstant.LZFPKJ, WebServiceConstant.URL, invoiceAllAddTwoDTO, companyservice); String code = result.get("code") != null ? result.get("code").toString() : ""; @@ -175,7 +204,7 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { } catch (Exception e) { log.error("【金四服务类】【金财数科】【蓝字发票开具】API请求异常,外部报文返回code非0000。错误信息:{}", e.getMessage()); return new HXResponse("蓝字发票开具异常"); - } + }*/ } else if ("2".equals(kpType)) { diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/utils/JcskTest.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/utils/JcskTest.java index 92bbc97..3e7f855 100644 --- a/jianshui-invoice/src/main/java/com/jianshui/invoice/utils/JcskTest.java +++ b/jianshui-invoice/src/main/java/com/jianshui/invoice/utils/JcskTest.java @@ -74,7 +74,7 @@ public class JcskTest { " \"async\": false,\n" + " \"bsrysfzjhm\":\"37028519930620441X\",\n" + " \"serviceId\": \"yhdj\",\n" + - " \"dqbm\": \"guangdong\",\n" + + " \"dqbm\": \"qingdao\",\n" + " \"nsrsbh\": \"92370214MACAAEK16E\",\n" + " \"jsonData\": {\n" + " \"bsryxm\": \"贾宁\",\n" +