修改红字信息表申请

beta-prop-all^2
路明慧 2 years ago
parent 0fc454b62f
commit b0edb1ddfe
  1. 161
      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.date.DateUtil;
import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSON;
import cn.hutool.json.JSONConfig; import cn.hutool.json.JSONConfig;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -699,6 +699,7 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService {
* @param companyservice * @param companyservice
* @return * @return
*/ */
@Override
public HXResponse scopeQueryInvoices(JSONObject queryJson, Companyservice companyservice) { public HXResponse scopeQueryInvoices(JSONObject queryJson, Companyservice companyservice) {
// 获取基本参数 // 获取基本参数
QueryWrapper<Invoice> queryWrapper = new QueryWrapper<>(); QueryWrapper<Invoice> queryWrapper = new QueryWrapper<>();
@ -1247,6 +1248,7 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService {
InvoiceAllApiLog allApiLog = new InvoiceAllApiLog(); InvoiceAllApiLog allApiLog = new InvoiceAllApiLog();
allApiLog.setUrl(WebServiceConstant.SQHZFPXXQRD); allApiLog.setUrl(WebServiceConstant.SQHZFPXXQRD);
allApiLog.setSendMsg(""); allApiLog.setSendMsg("");
// 添加对应uuid
allApiLog.setResultMsg(""); allApiLog.setResultMsg("");
allApiLog.setCompany(companyservice.getSellertax()); allApiLog.setCompany(companyservice.getSellertax());
allApiLog.setIdentityId(companyservice.getIdentity()); allApiLog.setIdentityId(companyservice.getIdentity());
@ -1456,6 +1458,7 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService {
* @param companyservice * @param companyservice
* @return * @return
*/ */
@Override
public HXResponse deprecateQueryInvoice(DeprecateQueryInvoiceDTO deprecateQueryInvoiceDTO, Companyservice companyservice) { public HXResponse deprecateQueryInvoice(DeprecateQueryInvoiceDTO deprecateQueryInvoiceDTO, Companyservice companyservice) {
Invoice invoice = new Invoice(); Invoice invoice = new Invoice();
invoice.setSellerTaxnum(companyservice.getSellertax()); invoice.setSellerTaxnum(companyservice.getSellertax());
@ -1491,6 +1494,7 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService {
* @param companyservice * @param companyservice
* @return * @return
*/ */
@Override
public HXResponse queryPrinter(QueryPrinterDTO queryPrinterDTO, Companyservice companyservice) { public HXResponse queryPrinter(QueryPrinterDTO queryPrinterDTO, Companyservice companyservice) {
JSONObject query = new JSONObject(); JSONObject query = new JSONObject();
query.put("NSRSBH", companyservice.getSellertax()); query.put("NSRSBH", companyservice.getSellertax());
@ -1992,8 +1996,31 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService {
return response; return response;
}else if (WebServiceConstant.QRCODE.equals(finalServiceId)) { }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<String,Object> 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)) { }else if (WebServiceConstant.SQHZFPXXQRD.equals(finalServiceId)) {
// 申请红字信息表 // 申请红字信息表
@ -2002,7 +2029,7 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService {
LambdaQueryWrapper<Redinfo> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Redinfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Redinfo::getFpqqlsh,requestId); queryWrapper.eq(Redinfo::getFpqqlsh,requestId);
Redinfo redinfo = redinfoMapper.selectOne(queryWrapper); Redinfo redinfo = redinfoMapper.selectOne(queryWrapper);
HXResponse hxResponse = queryRedInfoByElepant(redinfo,companyservice); HXResponse hxResponse = queryRedInfoByElepant(redinfo,companyservice,allApiLog);
return hxResponse; return hxResponse;
@ -2054,8 +2081,8 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService {
} }
@Transactional(rollbackFor = Exception.class) // @Transactional(rollbackFor = Exception.class)
public HXResponse queryRedInfoByElepant(Redinfo redinfo, Companyservice companyservice) { public HXResponse queryRedInfoByElepant(Redinfo redinfo, Companyservice companyservice,InvoiceAllApiLog apiLog) {
//返回信息 //返回信息
if (ObjectUtils.isEmpty(redinfo)){ if (ObjectUtils.isEmpty(redinfo)){
@ -2068,8 +2095,7 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService {
//封装请求参数 //封装请求参数
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
param.put("NSRSBH",companyservice.getSellertax()); param.put("NSRSBH",companyservice.getSellertax());
//TODO 上传红字信息表需要存入uuid param.put("UUID",apiLog.getResultMsg());
param.put("UUID","");
param.put("XSFNSRSBH",companyservice.getSellertax()); param.put("XSFNSRSBH",companyservice.getSellertax());
debugLog("红字信息表申请查询断点1",uuid,System.currentTimeMillis()); debugLog("红字信息表申请查询断点1",uuid,System.currentTimeMillis());
@ -2097,6 +2123,24 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService {
debugLog("断点8", uuid, System.currentTimeMillis()); debugLog("断点8", uuid, System.currentTimeMillis());
ElephantRedInfo elephantRedInfo = queryResultDTO.getDATA(); ElephantRedInfo elephantRedInfo = queryResultDTO.getDATA();
//原发票处理
String originFphm = redinfo.getOriginFphm();
QueryWrapper<Invoice> 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.setRedInfoNo(elephantRedInfo.getHZFPXXQRDBH());
redinfo.setSqlb(elephantRedInfo.getLRFSF()); redinfo.setSqlb(elephantRedInfo.getLRFSF());
@ -2116,52 +2160,73 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService {
redinfo.setBillInputTime(elephantRedInfo.getHZKPRQ()); redinfo.setBillInputTime(elephantRedInfo.getHZKPRQ());
int i = redinfoMapper.updateRedinfo(redinfo); int i = redinfoMapper.updateRedinfo(redinfo);
debugLog("断点9", uuid, System.currentTimeMillis());
if (i<1){ if (i<1){
debugLog("红字订单更新主表信息失败",uuid,System.currentTimeMillis()); debugLog("红字订单更新主表信息失败",uuid,System.currentTimeMillis());
throw new JianshuiServiceException("红字订单更新主表信息失败"); throw new JianshuiServiceException("红字订单更新主表信息失败");
} }
List<Redinfodetail> redinfodetailList = new ArrayList<>(); //返回报文
AddRedInfoInvoiceTWOVO addRedInfoInvoiceTWO = new AddRedInfoInvoiceTWOVO();
List<Redinfodetail> redinfodetails = redinfoMapper.selectRedinfoDetailList(redinfo.getId());
addRedInfoInvoiceTWO.setHzfpxxqrdZtdm(elephantRedInfo.getHZFPXXQRDBH());
Map<Integer, Redinfodetail> redInfoMapByIndex = redinfodetails.stream().collect(Collectors.toMap(e -> e.getIndex(), e -> e)); addRedInfoInvoiceTWO.setHzfpxxqrdid(elephantRedInfo.getUUID());
addRedInfoInvoiceTWO.setHzfpxxqrdZtdm(queryResultDTO.getZTDM());
for (ElephantRedInfoDetail elephantRedInfoDetail : elephantRedInfo.getHZQRXXMXLIST()) {
AddRedInfoInvoiceJsonDataTWOVO addRedInfoInvoiceJsonDataTWOVO = new AddRedInfoInvoiceJsonDataTWOVO();
Redinfodetail redinfodetail = redInfoMapByIndex.get(elephantRedInfoDetail.getXH().longValue()); addRedInfoInvoiceJsonDataTWOVO.setFpqqlsh(redinfo.getFpqqlsh());
redinfodetail.setBillno(redinfo.getRedInfoNo()); addRedInfoInvoiceJsonDataTWOVO.setFphm(elephantRedInfo.getHZFPHM());
redinfodetail.setRedinfoId(redinfo.getId()); addRedInfoInvoiceJsonDataTWOVO.setGmfnsrsbh(elephantRedInfo.getGMFNSRSBH());
redinfodetail.setIndex(elephantRedInfoDetail.getXH()); addRedInfoInvoiceJsonDataTWOVO.setGmfmc(elephantRedInfo.getGMFMC());
redinfodetail.setGoodName(elephantRedInfoDetail.getXMMC()); addRedInfoInvoiceJsonDataTWOVO.setKprq(elephantRedInfo.getHZKPRQ());
redinfodetail.setSpec(elephantRedInfoDetail.getGGXH()); addRedInfoInvoiceJsonDataTWOVO.setXsfmc(elephantRedInfo.getXSFMC());
redinfodetail.setUnit(elephantRedInfoDetail.getDW()); addRedInfoInvoiceJsonDataTWOVO.setXsfnsrsbh(elephantRedInfo.getXSFNSRSBH());
redinfodetail.setPrice(new BigDecimal(elephantRedInfoDetail.getFPSPDJ()));
// TODO 不确定金额是否为含税金额 addRedInfoInvoiceTWO.setHzfpxx(addRedInfoInvoiceJsonDataTWOVO);
redinfodetail.setTaxamt(new BigDecimal(elephantRedInfoDetail.getJE()));
redinfodetail.setTax(new BigDecimal(elephantRedInfoDetail.getSE())); //金财没有处理明细
redinfodetail.setTaxfreeamt(redinfodetail.getTaxamt().subtract(redinfodetail.getTax()));
// List<Redinfodetail> redinfodetailList = new ArrayList<>();
redinfodetail.setTaxrate(new BigDecimal(elephantRedInfoDetail.getSLV())); //
redinfodetail.setCreateTime(new Date()); // List<Redinfodetail> redinfodetails = redinfoMapper.selectRedinfoDetailList(redinfo.getId());
redinfodetailList.add(redinfodetail); //
} // Map<Integer, Redinfodetail> redInfoMapByIndex = redinfodetails.stream().collect(Collectors.toMap(e -> e.getIndex(), e -> e));
//
//删除红字信息明细 // for (ElephantRedInfoDetail elephantRedInfoDetail : elephantRedInfo.getHZQRXXMXLIST()) {
redinfoMapper.deleteRedinfodetailByRedinfoId(redinfo.getId()); //
//批量插入 // Redinfodetail redinfodetail = redInfoMapByIndex.get(elephantRedInfoDetail.getXH().longValue());
int count = redinfoMapper.batchRedinfodetail(redinfodetailList); // redinfodetail.setBillno(redinfo.getRedInfoNo());
if(count <1){ // redinfodetail.setRedinfoId(redinfo.getId());
debugLog("红字订单更新明细信息失败",uuid,System.currentTimeMillis()); // redinfodetail.setIndex(elephantRedInfoDetail.getXH());
throw new JianshuiServiceException("红字订单更新明细信息失败"); // redinfodetail.setGoodName(elephantRedInfoDetail.getXMMC());
} // redinfodetail.setSpec(elephantRedInfoDetail.getGGXH());
// redinfodetail.setUnit(elephantRedInfoDetail.getDW());
//TODO 返回啥看看文档 // redinfodetail.setPrice(new BigDecimal(elephantRedInfoDetail.getFPSPDJ()));
// // TODO 不确定金额是否为含税金额
redinfo.setRedinfodetailList(redinfodetailList); // redinfodetail.setTaxamt(new BigDecimal(elephantRedInfoDetail.getJE()));
// redinfodetail.setTax(new BigDecimal(elephantRedInfoDetail.getSE()));
return new HXResponse("200","查询成功",redinfo); // 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);
} }
} }