From b0edb1ddfe8bae0b78813b08fa489dbe676662ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B7=AF=E6=98=8E=E6=85=A7?= <1191093413@qq.com> Date: Thu, 2 Nov 2023 16:29:50 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BA=A2=E5=AD=97?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E8=A1=A8=E7=94=B3=E8=AF=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/ElephantInvoiceApiV6ServiceImpl.java | 161 ++++++++++++------ 1 file changed, 113 insertions(+), 48 deletions(-) diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java index 118ab1b..c6b8f88 100644 --- a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java +++ b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java @@ -5,9 +5,9 @@ import cn.hutool.core.codec.Base64; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.StrUtil; -import cn.hutool.json.JSON; import cn.hutool.json.JSONConfig; import cn.hutool.json.JSONUtil; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -699,6 +699,7 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { * @param companyservice * @return */ + @Override public HXResponse scopeQueryInvoices(JSONObject queryJson, Companyservice companyservice) { // 获取基本参数 QueryWrapper queryWrapper = new QueryWrapper<>(); @@ -1247,6 +1248,7 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { InvoiceAllApiLog allApiLog = new InvoiceAllApiLog(); allApiLog.setUrl(WebServiceConstant.SQHZFPXXQRD); allApiLog.setSendMsg(""); + // 添加对应uuid allApiLog.setResultMsg(""); allApiLog.setCompany(companyservice.getSellertax()); allApiLog.setIdentityId(companyservice.getIdentity()); @@ -1456,6 +1458,7 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { * @param companyservice * @return */ + @Override public HXResponse deprecateQueryInvoice(DeprecateQueryInvoiceDTO deprecateQueryInvoiceDTO, Companyservice companyservice) { Invoice invoice = new Invoice(); invoice.setSellerTaxnum(companyservice.getSellertax()); @@ -1491,6 +1494,7 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { * @param companyservice * @return */ + @Override public HXResponse queryPrinter(QueryPrinterDTO queryPrinterDTO, Companyservice companyservice) { JSONObject query = new JSONObject(); query.put("NSRSBH", companyservice.getSellertax()); @@ -1992,8 +1996,31 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { return response; }else if (WebServiceConstant.QRCODE.equals(finalServiceId)) { // 获取人脸二维码 - //查询状态还是返回二维码数据 - //用不用入库 + + //获取税局用户名称 + JSONObject param = new JSONObject(); + param.put("NSRSBH",companyservice.getSellertax()); + HXResponse hxResponse = queryRpaTaxAccount(param, companyservice); + if (!StringUtils.equals("000000",hxResponse.getCode())){ + return hxResponse; + } + JSONObject resp = JSONObject.parseObject(JSON.toJSONString(hxResponse.getData())); + + Map reqParam = new HashMap<>(); + reqParam.put("NSRSBH",companyservice.getSellertax()); + reqParam.put("YHM",resp.getString("YHM")); + reqParam.put("RZID",allApiLog.getResultMsg()); + + HXResponse rpaAuthStatus = getRpaAuthStatus(new JSONObject(reqParam), companyservice); + + if (StringUtils.equals("000000",rpaAuthStatus.getCode())){ + rpaAuthStatus.setCode("200"); + rpaAuthStatus.setMessage("处理成功"); + JSONObject data = JSONObject.parseObject(JSON.toJSONString(rpaAuthStatus.getData())); + String ewm = data.getString("EWM"); + rpaAuthStatus.setData(new HashMap<>().put("ewm",ewm)); + } + return rpaAuthStatus; }else if (WebServiceConstant.SQHZFPXXQRD.equals(finalServiceId)) { // 申请红字信息表 @@ -2002,7 +2029,7 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Redinfo::getFpqqlsh,requestId); Redinfo redinfo = redinfoMapper.selectOne(queryWrapper); - HXResponse hxResponse = queryRedInfoByElepant(redinfo,companyservice); + HXResponse hxResponse = queryRedInfoByElepant(redinfo,companyservice,allApiLog); return hxResponse; @@ -2054,8 +2081,8 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { } - @Transactional(rollbackFor = Exception.class) - public HXResponse queryRedInfoByElepant(Redinfo redinfo, Companyservice companyservice) { +// @Transactional(rollbackFor = Exception.class) + public HXResponse queryRedInfoByElepant(Redinfo redinfo, Companyservice companyservice,InvoiceAllApiLog apiLog) { //返回信息 if (ObjectUtils.isEmpty(redinfo)){ @@ -2068,8 +2095,7 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { //封装请求参数 JSONObject param = new JSONObject(); param.put("NSRSBH",companyservice.getSellertax()); - //TODO 上传红字信息表需要存入uuid - param.put("UUID",""); + param.put("UUID",apiLog.getResultMsg()); param.put("XSFNSRSBH",companyservice.getSellertax()); debugLog("红字信息表申请查询断点1",uuid,System.currentTimeMillis()); @@ -2097,6 +2123,24 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { debugLog("断点8", uuid, System.currentTimeMillis()); ElephantRedInfo elephantRedInfo = queryResultDTO.getDATA(); + //原发票处理 + String originFphm = redinfo.getOriginFphm(); + QueryWrapper invoiceQueryWrapper = new QueryWrapper<>(); + invoiceQueryWrapper.eq("fphm", originFphm); + Invoice invoice = invoiceMapper.selectOne(invoiceQueryWrapper); + //更新蓝字发票状态为冲红 99 + invoice.setState(99); + invoiceMapper.updateInvoice(invoice); + invoice.setId(null); + invoice.setOriginFphm(invoice.getFphm()); + invoice.setFphm(elephantRedInfo.getHZFPHM()); + invoice.setBillInfoId(redinfo.getId()); + invoice.setSystemOrderno(redinfo.getSystemOrderno()); + invoice.setOutTradeOrderno(apiLog.getRequestId()); + invoice.setFpqqlsh(redinfo.getFpqqlsh()); + invoice.setKprq(DateUtil.parse(elephantRedInfo.getHZKPRQ())); + invoice.setState(2); + invoiceMapper.insertInvoice(invoice); //红字信息表主信息封装 redinfo.setRedInfoNo(elephantRedInfo.getHZFPXXQRDBH()); redinfo.setSqlb(elephantRedInfo.getLRFSF()); @@ -2116,52 +2160,73 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { redinfo.setBillInputTime(elephantRedInfo.getHZKPRQ()); int i = redinfoMapper.updateRedinfo(redinfo); + debugLog("断点9", uuid, System.currentTimeMillis()); if (i<1){ debugLog("红字订单更新主表信息失败",uuid,System.currentTimeMillis()); throw new JianshuiServiceException("红字订单更新主表信息失败"); } - List redinfodetailList = new ArrayList<>(); - - List redinfodetails = redinfoMapper.selectRedinfoDetailList(redinfo.getId()); - - Map redInfoMapByIndex = redinfodetails.stream().collect(Collectors.toMap(e -> e.getIndex(), e -> e)); - - for (ElephantRedInfoDetail elephantRedInfoDetail : elephantRedInfo.getHZQRXXMXLIST()) { - - Redinfodetail redinfodetail = redInfoMapByIndex.get(elephantRedInfoDetail.getXH().longValue()); - redinfodetail.setBillno(redinfo.getRedInfoNo()); - redinfodetail.setRedinfoId(redinfo.getId()); - redinfodetail.setIndex(elephantRedInfoDetail.getXH()); - redinfodetail.setGoodName(elephantRedInfoDetail.getXMMC()); - redinfodetail.setSpec(elephantRedInfoDetail.getGGXH()); - redinfodetail.setUnit(elephantRedInfoDetail.getDW()); - redinfodetail.setPrice(new BigDecimal(elephantRedInfoDetail.getFPSPDJ())); - // TODO 不确定金额是否为含税金额 - redinfodetail.setTaxamt(new BigDecimal(elephantRedInfoDetail.getJE())); - redinfodetail.setTax(new BigDecimal(elephantRedInfoDetail.getSE())); - redinfodetail.setTaxfreeamt(redinfodetail.getTaxamt().subtract(redinfodetail.getTax())); - - redinfodetail.setTaxrate(new BigDecimal(elephantRedInfoDetail.getSLV())); - redinfodetail.setCreateTime(new Date()); - redinfodetailList.add(redinfodetail); - } - - //删除红字信息明细 - redinfoMapper.deleteRedinfodetailByRedinfoId(redinfo.getId()); - //批量插入 - int count = redinfoMapper.batchRedinfodetail(redinfodetailList); - if(count <1){ - debugLog("红字订单更新明细信息失败",uuid,System.currentTimeMillis()); - throw new JianshuiServiceException("红字订单更新明细信息失败"); - } - - //TODO 返回啥看看文档 - - redinfo.setRedinfodetailList(redinfodetailList); - - return new HXResponse("200","查询成功",redinfo); + //返回报文 + AddRedInfoInvoiceTWOVO addRedInfoInvoiceTWO = new AddRedInfoInvoiceTWOVO(); + + addRedInfoInvoiceTWO.setHzfpxxqrdZtdm(elephantRedInfo.getHZFPXXQRDBH()); + addRedInfoInvoiceTWO.setHzfpxxqrdid(elephantRedInfo.getUUID()); + addRedInfoInvoiceTWO.setHzfpxxqrdZtdm(queryResultDTO.getZTDM()); + + AddRedInfoInvoiceJsonDataTWOVO addRedInfoInvoiceJsonDataTWOVO = new AddRedInfoInvoiceJsonDataTWOVO(); + addRedInfoInvoiceJsonDataTWOVO.setFpqqlsh(redinfo.getFpqqlsh()); + addRedInfoInvoiceJsonDataTWOVO.setFphm(elephantRedInfo.getHZFPHM()); + addRedInfoInvoiceJsonDataTWOVO.setGmfnsrsbh(elephantRedInfo.getGMFNSRSBH()); + addRedInfoInvoiceJsonDataTWOVO.setGmfmc(elephantRedInfo.getGMFMC()); + addRedInfoInvoiceJsonDataTWOVO.setKprq(elephantRedInfo.getHZKPRQ()); + addRedInfoInvoiceJsonDataTWOVO.setXsfmc(elephantRedInfo.getXSFMC()); + addRedInfoInvoiceJsonDataTWOVO.setXsfnsrsbh(elephantRedInfo.getXSFNSRSBH()); + + addRedInfoInvoiceTWO.setHzfpxx(addRedInfoInvoiceJsonDataTWOVO); + + //金财没有处理明细 + +// List redinfodetailList = new ArrayList<>(); +// +// List redinfodetails = redinfoMapper.selectRedinfoDetailList(redinfo.getId()); +// +// Map redInfoMapByIndex = redinfodetails.stream().collect(Collectors.toMap(e -> e.getIndex(), e -> e)); +// +// for (ElephantRedInfoDetail elephantRedInfoDetail : elephantRedInfo.getHZQRXXMXLIST()) { +// +// Redinfodetail redinfodetail = redInfoMapByIndex.get(elephantRedInfoDetail.getXH().longValue()); +// redinfodetail.setBillno(redinfo.getRedInfoNo()); +// redinfodetail.setRedinfoId(redinfo.getId()); +// redinfodetail.setIndex(elephantRedInfoDetail.getXH()); +// redinfodetail.setGoodName(elephantRedInfoDetail.getXMMC()); +// redinfodetail.setSpec(elephantRedInfoDetail.getGGXH()); +// redinfodetail.setUnit(elephantRedInfoDetail.getDW()); +// redinfodetail.setPrice(new BigDecimal(elephantRedInfoDetail.getFPSPDJ())); +// // TODO 不确定金额是否为含税金额 +// redinfodetail.setTaxamt(new BigDecimal(elephantRedInfoDetail.getJE())); +// redinfodetail.setTax(new BigDecimal(elephantRedInfoDetail.getSE())); +// redinfodetail.setTaxfreeamt(redinfodetail.getTaxamt().subtract(redinfodetail.getTax())); +// +// redinfodetail.setTaxrate(new BigDecimal(elephantRedInfoDetail.getSLV())); +// redinfodetail.setCreateTime(new Date()); +// redinfodetailList.add(redinfodetail); +// } +// +// //删除红字信息明细 +// redinfoMapper.deleteRedinfodetailByRedinfoId(redinfo.getId()); +// debugLog("断点10", uuid, System.currentTimeMillis()); +// //批量插入 +// int count = redinfoMapper.batchRedinfodetail(redinfodetailList); +// debugLog("断点11", uuid, System.currentTimeMillis()); +// if(count <1){ +// debugLog("红字订单更新明细信息失败",uuid,System.currentTimeMillis()); +// throw new JianshuiServiceException("红字订单更新明细信息失败"); +// } + + + return new HXResponse("0000","查询成功",addRedInfoInvoiceTWO); } + } From 3641fe120a5836cac957696ce16486acdb2edd3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B7=AF=E6=98=8E=E6=85=A7?= <1191093413@qq.com> Date: Fri, 3 Nov 2023 10:56:29 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E7=BA=A2=E5=AD=97=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E8=A1=A8=E6=9F=A5=E8=AF=A2=E5=AF=B9=E6=8E=A5=E5=A4=A7=E8=B1=A1?= =?UTF-8?q?=E7=BA=A2=E5=AD=97=E4=BF=A1=E6=81=AF=E8=A1=A8=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../constant/elephant/ElephantConstants.java | 55 +++++++ .../invoice/domain/ele/HZQRXXLIST.java | 13 ++ .../jianshui/invoice/domain/ele/HZXXDATA.java | 32 ++++ .../jianshui/invoice/domain/ele/HZXXLIST.java | 8 + .../api/ElephantInvoiceApiV6ServiceImpl.java | 142 ++++++++++++++++-- 5 files changed, 235 insertions(+), 15 deletions(-) create mode 100644 jianshui-invoice/src/main/java/com/jianshui/invoice/domain/ele/HZQRXXLIST.java create mode 100644 jianshui-invoice/src/main/java/com/jianshui/invoice/domain/ele/HZXXDATA.java create mode 100644 jianshui-invoice/src/main/java/com/jianshui/invoice/domain/ele/HZXXLIST.java diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/constant/elephant/ElephantConstants.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/constant/elephant/ElephantConstants.java index 761dce9..1475989 100644 --- a/jianshui-invoice/src/main/java/com/jianshui/invoice/constant/elephant/ElephantConstants.java +++ b/jianshui-invoice/src/main/java/com/jianshui/invoice/constant/elephant/ElephantConstants.java @@ -99,4 +99,59 @@ public class ElephantConstants { */ public static String SIGN = "eseal/v1/sign"; + //纳税人识别号 + public static final String NSRSBH ="NSRSBH"; + + //UUID + public static final String UUID = "UUID"; + + //红字确认单编号 + public static final String HZQRDBH = "HZQRDBH"; + + //确认类型 + public static final String QRLX = "QRLX"; + + //Y + public static final String QRLX_Y = "Y"; + //N + public static final String QRLX_N = "N"; + //C + public static final String QRLX_C = "C"; + + + //用户名 + public static final String YHM = "YHM"; + + //二维码 + public static final String EWM = "EWM"; + + //用户角色类型 + public static final String YHJSLX = "YHJSLX"; + + //(销售方)名称 + public static final String XSFMC = "XSFMC"; + + //(销售方)统一社会信用代码/纳税人识别号/身份证件号码 + public static final String XSFNSRSBH = "XSFNSRSBH"; + + //(购买方)统一社会信用代码/纳税人识别号/身份证件号码 + public static final String GMFNSRSBH = "GMFNSRSBH"; + + //购买方名称 + public static final String GMFMC = "GMFMC"; + + //录入方身份 + public static final String LRFSF = "LRFSF"; + + //录入日期始 + public static final String LRRQQ = "LRRQQ"; + + //录入日期止 + public static final String LRRQZ = "LRRQZ"; + + //红字确认单编号 + public static final String HZFPXXQRDBH = "HZFPXXQRDBH"; + + public static final String STRING_0 = "0"; + } diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/domain/ele/HZQRXXLIST.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/domain/ele/HZQRXXLIST.java new file mode 100644 index 0000000..aa58b13 --- /dev/null +++ b/jianshui-invoice/src/main/java/com/jianshui/invoice/domain/ele/HZQRXXLIST.java @@ -0,0 +1,13 @@ +package com.jianshui.invoice.domain.ele; + +import lombok.Data; + +import java.util.List; + +@Data +public class HZQRXXLIST { + private int PAGENUMBER; + private int PAGESIZE; + private int TOTAL; + private List LIST; +} diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/domain/ele/HZXXDATA.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/domain/ele/HZXXDATA.java new file mode 100644 index 0000000..49944c9 --- /dev/null +++ b/jianshui-invoice/src/main/java/com/jianshui/invoice/domain/ele/HZXXDATA.java @@ -0,0 +1,32 @@ +package com.jianshui.invoice.domain.ele; + +import lombok.Data; + +@Data +public class HZXXDATA { + private String UUID; + private String HZFPXXQRDBH; + private String LRFSF; + private String XSFNSRSBH; + private String XSFMC; + private String GMFNSRSBH; + private String GMFMC; + private String LZFPDM; + private String LZFPHM; + private String SFZZFPBZ; + private String LZKPRQ; + private String LZHJJE; + private String LZHJSE; + private String LZFPPZDM; + private String LZFPTDYSLXDM; + private String HZCXJE; + private String HZCXSE; + private String HZQRDMXSL; + private String CHYYDM; + private String HZQRXXZTDM; + private String QRRQ; + private String YKJHZFPBZ; + private String HZFPHM; + private String HZKPRQ; + private String YXBZ; +} diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/domain/ele/HZXXLIST.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/domain/ele/HZXXLIST.java new file mode 100644 index 0000000..f113cf5 --- /dev/null +++ b/jianshui-invoice/src/main/java/com/jianshui/invoice/domain/ele/HZXXLIST.java @@ -0,0 +1,8 @@ +package com.jianshui.invoice.domain.ele; + +import lombok.Data; + +@Data +public class HZXXLIST { + private HZQRXXLIST HZQRXXLIST; +} diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java index c6b8f88..2834c8d 100644 --- a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java +++ b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java @@ -1,5 +1,6 @@ package com.jianshui.invoice.service.impl.api; +import ch.qos.logback.core.joran.spi.ElementPath; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.codec.Base64; import cn.hutool.core.date.DateUtil; @@ -7,6 +8,7 @@ import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONConfig; import cn.hutool.json.JSONUtil; +import com.alibaba.druid.support.json.JSONUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -29,6 +31,7 @@ import com.jianshui.common.utils.TimeUtil; import com.jianshui.common.utils.http.HttpHelper; import com.jianshui.common.utils.uuid.IdUtils; import com.jianshui.framework.manager.AsyncManager; +import com.jianshui.invoice.constant.elephant.ElephantConstants; import com.jianshui.invoice.constant.elephant.ElephantConstantsV6; import com.jianshui.invoice.domain.*; import com.jianshui.invoice.domain.dto.*; @@ -38,9 +41,7 @@ import com.jianshui.invoice.domain.dto.api.elephant.sd.GetRpaAuthStatusDTO; import com.jianshui.invoice.domain.dto.api.elephant.sd.HZQRDMXLIST; import com.jianshui.invoice.domain.dto.api.elephant.sd.RedDownload; import com.jianshui.invoice.domain.dto.api.elephant.sd.RedUpload; -import com.jianshui.invoice.domain.ele.EleNewMessage; -import com.jianshui.invoice.domain.ele.EleOuterMessage; -import com.jianshui.invoice.domain.ele.HZSQDMessage; +import com.jianshui.invoice.domain.ele.*; import com.jianshui.invoice.domain.vo.InvoiceAllQycodeResultElEVO; import com.jianshui.invoice.domain.vo.jcsk.*; import com.jianshui.invoice.mapper.BillInfoMapper; @@ -64,8 +65,10 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.ibatis.annotations.Lang; +import org.joda.time.format.DateTimeFormat; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -75,6 +78,8 @@ import java.math.BigDecimal; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; @@ -1999,26 +2004,23 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { //获取税局用户名称 JSONObject param = new JSONObject(); - param.put("NSRSBH",companyservice.getSellertax()); + param.put(ElephantConstants.NSRSBH,companyservice.getSellertax()); HXResponse hxResponse = queryRpaTaxAccount(param, companyservice); if (!StringUtils.equals("000000",hxResponse.getCode())){ return hxResponse; } JSONObject resp = JSONObject.parseObject(JSON.toJSONString(hxResponse.getData())); - Map reqParam = new HashMap<>(); - reqParam.put("NSRSBH",companyservice.getSellertax()); - reqParam.put("YHM",resp.getString("YHM")); - reqParam.put("RZID",allApiLog.getResultMsg()); + param.put(ElephantConstants.YHM,resp.getString(ElephantConstants.YHM)); - HXResponse rpaAuthStatus = getRpaAuthStatus(new JSONObject(reqParam), companyservice); + HXResponse rpaAuthStatus = qrcode(param, companyservice); if (StringUtils.equals("000000",rpaAuthStatus.getCode())){ rpaAuthStatus.setCode("200"); rpaAuthStatus.setMessage("处理成功"); JSONObject data = JSONObject.parseObject(JSON.toJSONString(rpaAuthStatus.getData())); - String ewm = data.getString("EWM"); - rpaAuthStatus.setData(new HashMap<>().put("ewm",ewm)); + String ewm = data.getString(ElephantConstants.EWM); + rpaAuthStatus.setData(new HashMap<>().put(ElephantConstants.EWM.toLowerCase(),ewm)); } return rpaAuthStatus; @@ -2058,9 +2060,27 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { }else if (WebServiceConstant.CXHZFPXXQRD.equals(finalServiceId)) { // 查询红字信息表 + JSONObject param = new JSONObject(); + param.put(ElephantConstants.YHJSLX,ElephantConstants.STRING_0); + param.put(ElephantConstants.XSFNSRSBH,companyservice.getSellertax()); + param.put(ElephantConstants.XSFMC,companyservice.getSellername()); + param.put(ElephantConstants.LRFSF,ElephantConstants.STRING_0); + //录入日期起始值 + HXResponse hxResponse = queryRedConfirmationList(param, companyservice); + + HZXXLIST hzxxlist = JSONObject.parseObject(JSONObject.toJSONString(hxResponse.getData()), HZXXLIST.class); + + return convertToJcData(hzxxlist); } else if (WebServiceConstant.SHHZFPXXQRD.equals(finalServiceId)) { // 审核红字信息表 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Redinfo::getFpqqlsh,requestId); + queryWrapper.orderByDesc(Redinfo::getId).last("limit 1"); + + Redinfo redinfo = redinfoMapper.selectOne(queryWrapper); + + return auditRedInfoResult(allApiLog.getResultMsg(),redinfo,companyservice); } else if (WebServiceConstant.FPEWMXZ.equals(finalServiceId)) { // 获取发票下载地址 @@ -2081,7 +2101,99 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { } -// @Transactional(rollbackFor = Exception.class) + private HXResponse convertToJcData(HZXXLIST hzxxlist) { + HZQRXXLIST hzqrxxlist = hzxxlist.getHZQRXXLIST(); + List redinfos = new ArrayList<>(hzqrxxlist.getTOTAL()); + + List list = hzqrxxlist.getLIST(); + + for (HZXXDATA hzxxdata : list) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Redinfo::getRedInfoNo,hzxxdata.getHZFPXXQRDBH()); + queryWrapper.orderByDesc(Redinfo::getId).last("limit 1"); + //根据红字信息表编号查询红字信息 + Redinfo redinfo = redinfoMapper.selectOne(queryWrapper); + //不存在就创建对象 + if (ObjectUtils.isEmpty(redinfo)){ + redinfo = new Redinfo(); + } + redinfo.setRedInfoNo(hzxxdata.getHZFPXXQRDBH()); + redinfo.setSellerTaxnum(hzxxdata.getXSFNSRSBH()); + redinfo.setSellerName(hzxxdata.getXSFMC()); + redinfo.setBuyerName(hzxxdata.getGMFMC()); + redinfo.setBuyerTaxnum(hzxxdata.getGMFNSRSBH()); + redinfo.setOriginFpdm(hzxxdata.getLZFPDM()); + redinfo.setOriginFphm(hzxxdata.getLZFPHM()); + redinfo.setOriginKprq(hzxxdata.getLZKPRQ()); + redinfo.setReqnsrsbh(hzxxdata.getXSFNSRSBH()); + redinfos.add(redinfo); + //判断是否存在红字信息,存在执行更新 + if (ObjectUtils.isEmpty(redinfo.getId())){ + //处理发票表和红字信息表 + redInfoAndInvoiceUpdate(hzxxdata, redinfo); + } + } + + return new HXResponse("200","查询成功",redinfos); + } + + @Async + public void redInfoAndInvoiceUpdate(HZXXDATA hzxxdata, Redinfo redinfo) { + redinfoMapper.updateRedinfo(redinfo); + QueryWrapper invoiceQueryWrapper = new QueryWrapper<>(); + invoiceQueryWrapper.eq("fphm", redinfo.getOriginFphm()); + Invoice invoice = invoiceMapper.selectOne(invoiceQueryWrapper); + //更新蓝字发票状态为冲红 99 + invoice.setState(99); + invoiceMapper.updateInvoice(invoice); + invoice.setId(null); + invoice.setOriginFphm(invoice.getFphm()); + invoice.setFphm(hzxxdata.getHZFPHM()); + invoice.setBillInfoId(redinfo.getId()); + invoice.setSystemOrderno(redinfo.getSystemOrderno()); + invoice.setOutTradeOrderno(redinfo.getOutTradeOrderno()); + invoice.setFpqqlsh(redinfo.getFpqqlsh()); + invoice.setKprq(DateUtil.parse(hzxxdata.getHZKPRQ())); + invoice.setState(2); + invoiceMapper.insertInvoice(invoice); + } + + private HXResponse auditRedInfoResult(String uuid,Redinfo redinfo, Companyservice companyservice) { + if (ObjectUtils.isEmpty(companyservice)){ + log.info("请求日志为空或者企业服务为空"); + return new HXResponse("9998","请求日志为空或者企业服务为空"); + } + if (ObjectUtils.isEmpty(redinfo)){ + log.info("不存在该红字信息"); + return new HXResponse("9998","不存在该红字信息"); + } + + if (StringUtils.isBlank(uuid)){ + log.info("红字确认单UUID不能为空"); + return new HXResponse("9998","红字确认单UUID不能为空"); + } + + JSONObject param = new JSONObject(); + param.put(ElephantConstants.NSRSBH,companyservice.getSellertax()); + param.put(ElephantConstants.UUID,uuid); + param.put(ElephantConstants.HZQRDBH,redinfo.getRedInfoNo()); + param.put(ElephantConstants.QRLX,ElephantConstants.QRLX_Y); + + //调用大象接口获取确认日期 + + AjaxResult queryResult = null; + try { + queryResult = ElephantUtils.sendRequestWithoutTokenV6New(ElephantConstantsV6.QUERY_INVOICE_LOCALHOST, ElephantConstantsV6.QUERY_INVOICE_METHOD, JSONUtil.parse(param), companyservice); + } catch (UnsupportedEncodingException | InvalidKeyException | NoSuchAlgorithmException e) { + log.error("【销项发票】【大象接口】【发票开具】发票请求异常,请求报文{},销方信息{}", param.toJSONString(), JSONObject.toJSONString(companyservice)); + e.printStackTrace(); + throw new JianshuiServiceException("系统异常!"); + } + + return new HXResponse(String.valueOf(queryResult.getCode()),queryResult.getMsg(),queryResult.getData()); + } + + // @Transactional(rollbackFor = Exception.class) public HXResponse queryRedInfoByElepant(Redinfo redinfo, Companyservice companyservice,InvoiceAllApiLog apiLog) { //返回信息 @@ -2094,9 +2206,9 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { //封装请求参数 JSONObject param = new JSONObject(); - param.put("NSRSBH",companyservice.getSellertax()); - param.put("UUID",apiLog.getResultMsg()); - param.put("XSFNSRSBH",companyservice.getSellertax()); + param.put(ElephantConstants.NSRSBH,companyservice.getSellertax()); + param.put(ElephantConstants.UUID,apiLog.getResultMsg()); + param.put(ElephantConstants.XSFNSRSBH,companyservice.getSellertax()); debugLog("红字信息表申请查询断点1",uuid,System.currentTimeMillis()); //调用大象接口查询红字信息表明细 From 731962cc137d3204c52c132ed6280bef25d6dff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B7=AF=E6=98=8E=E6=85=A7?= <1191093413@qq.com> Date: Fri, 3 Nov 2023 16:28:50 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B5=B7=E5=A7=8B?= =?UTF-8?q?=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/api/ElephantInvoiceApiV6ServiceImpl.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java index 1949c80..8832042 100644 --- a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java +++ b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java @@ -41,6 +41,8 @@ import com.jianshui.invoice.domain.dto.api.elephant.sd.GetRpaAuthStatusDTO; import com.jianshui.invoice.domain.dto.api.elephant.sd.HZQRDMXLIST; import com.jianshui.invoice.domain.dto.api.elephant.sd.RedDownload; import com.jianshui.invoice.domain.dto.api.elephant.sd.RedUpload; +import com.jianshui.invoice.domain.dto.api.jcsk.CxhzJsonDataTwoDTO; +import com.jianshui.invoice.domain.dto.api.jcsk.CxhzTwoDTO; import com.jianshui.invoice.domain.ele.*; import com.jianshui.invoice.domain.vo.InvoiceAllQycodeResultElEVO; import com.jianshui.invoice.domain.vo.jcsk.*; @@ -2060,12 +2062,23 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { }else if (WebServiceConstant.CXHZFPXXQRD.equals(finalServiceId)) { // 查询红字信息表 + CxhzJsonDataTwoDTO cxhzJsonDataTwoDTO = null; + try { + String sendMsg = allApiLog.getSendMsg(); + cxhzJsonDataTwoDTO= JSONObject.parseObject(sendMsg, CxhzTwoDTO.class).getJsonData(); + + }catch (Exception e){ + log.error("反序列化失败异常",e); + } JSONObject param = new JSONObject(); param.put(ElephantConstants.YHJSLX,ElephantConstants.STRING_0); param.put(ElephantConstants.XSFNSRSBH,companyservice.getSellertax()); param.put(ElephantConstants.XSFMC,companyservice.getSellername()); param.put(ElephantConstants.LRFSF,ElephantConstants.STRING_0); - //录入日期起始值 + param.put(ElephantConstants.LRRQQ,cxhzJsonDataTwoDTO.getKprqq()); + param.put(ElephantConstants.LRRQZ,cxhzJsonDataTwoDTO.getKprqz()); + + HXResponse hxResponse = queryRedConfirmationList(param, companyservice); HZXXLIST hzxxlist = JSONObject.parseObject(JSONObject.toJSONString(hxResponse.getData()), HZXXLIST.class); From 792eb9a516e4eaeb1f581e577e71a33dcd590319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B7=AF=E6=98=8E=E6=85=A7?= <1191093413@qq.com> Date: Fri, 3 Nov 2023 16:30:07 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B5=B7=E5=A7=8B?= =?UTF-8?q?=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/api/ElephantInvoiceApiV6ServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java index 8832042..7e48b2e 100644 --- a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java +++ b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java @@ -2069,6 +2069,7 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { }catch (Exception e){ log.error("反序列化失败异常",e); + throw new JianshuiServiceException("起始日期反序列化失败"); } JSONObject param = new JSONObject(); param.put(ElephantConstants.YHJSLX,ElephantConstants.STRING_0);