|
|
|
@ -26,7 +26,9 @@ import com.jianshui.invoice.domain.dto.api.jcsk.QueryTwoDTO; |
|
|
|
|
import com.jianshui.invoice.domain.dto.api.jcsk.add.InvoiceAllAddInfoTwoDTO; |
|
|
|
|
import com.jianshui.invoice.domain.dto.api.jcsk.add.InvoiceAllAddTwoDTO; |
|
|
|
|
import com.jianshui.invoice.domain.dto.api.jcsk.add.InvoiceAllAddmxListTwoDTO; |
|
|
|
|
import com.jianshui.invoice.domain.dto.api.jcsk.red.AddRedInvoiceTwoDTO; |
|
|
|
|
import com.jianshui.invoice.domain.vo.jcsk.AddInvoiceTWOVO; |
|
|
|
|
import com.jianshui.invoice.domain.vo.jcsk.AddRedInvoiceTWOVO; |
|
|
|
|
import com.jianshui.invoice.mapper.*; |
|
|
|
|
import com.jianshui.invoice.service.IInvoiceApiService; |
|
|
|
|
import com.jianshui.invoice.utils.aisino.console.AisinoConsoleUtil; |
|
|
|
@ -83,90 +85,157 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
// 请求billInfo
|
|
|
|
|
Long billInfoID = 0L; |
|
|
|
|
|
|
|
|
|
// 开票实体转换,校验
|
|
|
|
|
InvoiceAllAddTwoDTO invoiceAllAddTwoDTO = BeanUtil.copyProperties(billInfo, InvoiceAllAddTwoDTO.class); |
|
|
|
|
ValidateUtils.validate(invoiceAllAddTwoDTO); |
|
|
|
|
// kptype 1蓝票 2红票
|
|
|
|
|
String kpType = billInfo.getKptype(); |
|
|
|
|
|
|
|
|
|
InvoiceAllAddInfoTwoDTO invoiceAllAddInfoTwoDTO = BeanUtil.copyProperties(billInfo, InvoiceAllAddInfoTwoDTO.class); |
|
|
|
|
ValidateUtils.validate(invoiceAllAddInfoTwoDTO); |
|
|
|
|
if ("1".equals(kpType)) { |
|
|
|
|
// 开票实体转换,校验
|
|
|
|
|
InvoiceAllAddTwoDTO invoiceAllAddTwoDTO = BeanUtil.copyProperties(billInfo, InvoiceAllAddTwoDTO.class); |
|
|
|
|
ValidateUtils.validate(invoiceAllAddTwoDTO); |
|
|
|
|
|
|
|
|
|
InvoiceAllAddInfoTwoDTO invoiceAllAddInfoTwoDTO = BeanUtil.copyProperties(billInfo, InvoiceAllAddInfoTwoDTO.class); |
|
|
|
|
ValidateUtils.validate(invoiceAllAddInfoTwoDTO); |
|
|
|
|
|
|
|
|
|
// 明细集合
|
|
|
|
|
List<InvoiceAllAddmxListTwoDTO> mxList = BeanUtil.copyToList(billInfo.getBillDetailList(), InvoiceAllAddmxListTwoDTO.class); |
|
|
|
|
if (CollectionUtils.isEmpty(mxList)) { |
|
|
|
|
return new HXResponse("mxList明细集合不存在!"); |
|
|
|
|
} |
|
|
|
|
for (InvoiceAllAddmxListTwoDTO addmxListDTO : mxList) { |
|
|
|
|
ValidateUtils.validate(addmxListDTO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 报文转换存储
|
|
|
|
|
billInfo.setCompanyId(companyservice.getCompanyid()); |
|
|
|
|
billInfo.setServiceSupplierKey("JCSK"); |
|
|
|
|
try { |
|
|
|
|
int resBillInfo = billInfoMapper.insertBillInfo(billInfo); |
|
|
|
|
if (resBillInfo > 0) { |
|
|
|
|
billInfoID = billInfo.getId(); |
|
|
|
|
if (BeanUtil.isEmpty(billInfo.getId())) { |
|
|
|
|
log.error("【金四服务类】【金财数科】【蓝字发票开具】API请求异常,billInfoId返回存储错误。"); |
|
|
|
|
return new HXResponse(ErrorCode.INCOME_ERROR.toString()); |
|
|
|
|
// 明细集合
|
|
|
|
|
List<InvoiceAllAddmxListTwoDTO> mxList = BeanUtil.copyToList(billInfo.getBillDetailList(), InvoiceAllAddmxListTwoDTO.class); |
|
|
|
|
if (CollectionUtils.isEmpty(mxList)) { |
|
|
|
|
return new HXResponse("mxList明细集合不存在!"); |
|
|
|
|
} |
|
|
|
|
for (InvoiceAllAddmxListTwoDTO addmxListDTO : mxList) { |
|
|
|
|
ValidateUtils.validate(addmxListDTO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 报文转换存储
|
|
|
|
|
billInfo.setCompanyId(companyservice.getCompanyid()); |
|
|
|
|
billInfo.setServiceSupplierKey("JCSK"); |
|
|
|
|
try { |
|
|
|
|
int resBillInfo = billInfoMapper.insertBillInfo(billInfo); |
|
|
|
|
if (resBillInfo > 0) { |
|
|
|
|
billInfoID = billInfo.getId(); |
|
|
|
|
if (BeanUtil.isEmpty(billInfo.getId())) { |
|
|
|
|
log.error("【金四服务类】【金财数科】【蓝字发票开具】API请求异常,billInfoId返回存储错误。"); |
|
|
|
|
return new HXResponse("蓝字发票开具内部错误!"); |
|
|
|
|
} |
|
|
|
|
//数据库存储
|
|
|
|
|
List<BillDetail> billDetailList = billInfo.getBillDetailList(); |
|
|
|
|
int billDetailResult = billInfoMapper.batchBillDetail(billDetailList); |
|
|
|
|
} |
|
|
|
|
//数据库存储
|
|
|
|
|
List<BillDetail> billDetailList = billInfo.getBillDetailList(); |
|
|
|
|
int billDetailResult = billInfoMapper.batchBillDetail(billDetailList); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
log.error("【金四服务类】【金财数科】【蓝字发票开具】API请求异常,billInfo存储错误。错误信息:{}", e.getMessage()); |
|
|
|
|
return new HXResponse("蓝字发票开具内部错误!"); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
log.error("【金四服务类】【金财数科】【蓝字发票开具】API请求异常,billInfo存储错误。错误信息:{}", e.getMessage()); |
|
|
|
|
return new HXResponse(ErrorCode.INCOME_ERROR.toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cn.hutool.json.JSONObject result = null; |
|
|
|
|
try { |
|
|
|
|
cn.hutool.json.JSONObject result = null; |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
result = ApiHttp.request(WebServiceConstant.LZFPKJ, WebServiceConstant.URL, invoiceAllAddTwoDTO, companyservice); |
|
|
|
|
result = ApiHttp.request(WebServiceConstant.LZFPKJ, WebServiceConstant.URL, invoiceAllAddTwoDTO, companyservice); |
|
|
|
|
|
|
|
|
|
String code = result.get("code") != null ? result.get("code").toString() : ""; |
|
|
|
|
String msg = result.get("msg") != null ? result.get("msg").toString() : ""; |
|
|
|
|
String data = result.get("data") != null ? result.get("data").toString() : ""; |
|
|
|
|
String code = result.get("code") != null ? result.get("code").toString() : ""; |
|
|
|
|
String msg = result.get("msg") != null ? result.get("msg").toString() : ""; |
|
|
|
|
String data = result.get("data") != null ? result.get("data").toString() : ""; |
|
|
|
|
|
|
|
|
|
if ("0000".equals(code) && StrUtil.isNotEmpty(data)) { |
|
|
|
|
cn.hutool.json.JSONObject json = JSONUtil.parseObj(data); |
|
|
|
|
String requestId = json.getOrDefault("requestId", "").toString(); |
|
|
|
|
if (StrUtil.isEmpty(requestId)) { |
|
|
|
|
if ("0000".equals(code) && StrUtil.isNotEmpty(data)) { |
|
|
|
|
cn.hutool.json.JSONObject json = JSONUtil.parseObj(data); |
|
|
|
|
String requestId = json.getOrDefault("requestId", "").toString(); |
|
|
|
|
if (StrUtil.isEmpty(requestId)) { |
|
|
|
|
return new HXResponse(msg); |
|
|
|
|
} |
|
|
|
|
BillInfo billInfoRes = billInfoMapper.selectBillInfoById(billInfoID); |
|
|
|
|
billInfoRes.setOutTradeOrderno(requestId); |
|
|
|
|
billInfoMapper.updateBillInfo(billInfoRes); |
|
|
|
|
|
|
|
|
|
// 保存日志
|
|
|
|
|
InvoiceAllApiLog allApiLog = new InvoiceAllApiLog(); |
|
|
|
|
allApiLog.setUrl(WebServiceConstant.LZFPKJ); |
|
|
|
|
allApiLog.setSendMsg(""); |
|
|
|
|
allApiLog.setResultMsg(""); |
|
|
|
|
allApiLog.setCompany(companyservice.getSellertax()); |
|
|
|
|
allApiLog.setIdentityId(companyservice.getIdentity()); |
|
|
|
|
allApiLog.setRequestId(requestId); |
|
|
|
|
allApiLog.setCreateTime(new Date()); |
|
|
|
|
AsyncManager.me().execute( |
|
|
|
|
new TimerTask() { |
|
|
|
|
@Override |
|
|
|
|
public void run() { |
|
|
|
|
allApiLogMapper.insertInvoiceAllApiLog(allApiLog); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
HXResponse response = new HXResponse("0000", "同步成功"); |
|
|
|
|
response.put("fpqqlsh", billInfo.getSystemOrderno()); |
|
|
|
|
return response; |
|
|
|
|
} else { |
|
|
|
|
return new HXResponse(msg); |
|
|
|
|
} |
|
|
|
|
BillInfo billInfoRes = billInfoMapper.selectBillInfoById(billInfoID); |
|
|
|
|
billInfoRes.setOutTradeOrderno(requestId); |
|
|
|
|
billInfoMapper.updateBillInfo(billInfoRes); |
|
|
|
|
|
|
|
|
|
// 保存日志
|
|
|
|
|
InvoiceAllApiLog allApiLog = new InvoiceAllApiLog(); |
|
|
|
|
allApiLog.setUrl(WebServiceConstant.LZFPKJ); |
|
|
|
|
allApiLog.setSendMsg(""); |
|
|
|
|
allApiLog.setResultMsg(""); |
|
|
|
|
allApiLog.setCompany(companyservice.getSellertax()); |
|
|
|
|
allApiLog.setIdentityId(companyservice.getIdentity()); |
|
|
|
|
allApiLog.setRequestId(requestId); |
|
|
|
|
allApiLog.setCreateTime(new Date()); |
|
|
|
|
AsyncManager.me().execute( |
|
|
|
|
new TimerTask() { |
|
|
|
|
@Override |
|
|
|
|
public void run() { |
|
|
|
|
allApiLogMapper.insertInvoiceAllApiLog(allApiLog); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("【金四服务类】【金财数科】【蓝字发票开具】API请求异常,外部报文返回code非0000。错误信息:{}", e.getMessage()); |
|
|
|
|
return new HXResponse("蓝字发票开具异常"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HXResponse response = new HXResponse("0000", "同步成功"); |
|
|
|
|
response.put("fpqqlsh", billInfo.getSystemOrderno()); |
|
|
|
|
return response; |
|
|
|
|
} else { |
|
|
|
|
return new HXResponse(msg); |
|
|
|
|
} else if ("2".equals(kpType)) { |
|
|
|
|
|
|
|
|
|
//billinfo => 红字报文
|
|
|
|
|
|
|
|
|
|
AddRedInvoiceTwoDTO addRedInvoiceDTO = BeanUtil.copyProperties(billInfo, AddRedInvoiceTwoDTO.class); |
|
|
|
|
ValidateUtils.validate(addRedInvoiceDTO); |
|
|
|
|
|
|
|
|
|
// 查找原Invoice
|
|
|
|
|
QueryWrapper<Invoice> invoiceQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
invoiceQueryWrapper.eq("fphm", addRedInvoiceDTO.getYfphm()); |
|
|
|
|
invoiceQueryWrapper.eq("invoice_type", getInvoiceType(addRedInvoiceDTO.getYfplxdm(), false)); |
|
|
|
|
Invoice originInvoice = invoiceMapper.selectOne(invoiceQueryWrapper); |
|
|
|
|
if (originInvoice == null) { |
|
|
|
|
return new HXResponse(ErrorCode.INVOICE_NOT_EXISTS.toString()); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("【金四服务类】【金财数科】【蓝字发票开具】API请求异常,外部报文返回code非0000。错误信息:{}", e.getMessage()); |
|
|
|
|
return new HXResponse("蓝字发票开具异常"); |
|
|
|
|
|
|
|
|
|
BillInfo redBillInfo = billInfoMapper.selectById(originInvoice.getBillInfoId()); |
|
|
|
|
if (billInfo == null) { |
|
|
|
|
return new HXResponse(ErrorCode.INVOICE_NOT_EXISTS.toString()); |
|
|
|
|
} |
|
|
|
|
redBillInfo.setId(null); |
|
|
|
|
redBillInfo.setOriginFphm(addRedInvoiceDTO.getYfphm()); |
|
|
|
|
redBillInfo.setOutTradeOrderno(addRedInvoiceDTO.getFpqqlsh()); |
|
|
|
|
redBillInfo.setFpqqlsh(""); |
|
|
|
|
String systemOrderno = IdUtils.randomSystemOrderno(); |
|
|
|
|
redBillInfo.setSystemOrderno(systemOrderno); |
|
|
|
|
redBillInfo.setKptype("2"); |
|
|
|
|
if (billInfoMapper.insert(redBillInfo) == 0) { |
|
|
|
|
return new HXResponse(ErrorCode.INVOICE_NOT_EXISTS.toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cn.hutool.json.JSONObject result = null; |
|
|
|
|
try { |
|
|
|
|
result = ApiHttp.request(WebServiceConstant.ADD_RED_INVOICE, WebServiceConstant.URL, addRedInvoiceDTO, companyservice); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
log.error("【金四服务类】【金财数科】【获取二维码】API请求异常,外部报文返回code非0000。错误信息:{}", e.getMessage()); |
|
|
|
|
return new HXResponse(ErrorCode.INCOME_ERROR.toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 处理请求
|
|
|
|
|
if (!StringUtils.equals("0000", result.getStr("code"))) { |
|
|
|
|
log.error("【金四服务类】【金财数科】【获取二维码】API请求异常,外部报文返回code非0000。返回信息:{}", result); |
|
|
|
|
return new HXResponse(result.getStr("message")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cn.hutool.json.JSONObject data = result.getJSONObject("data"); |
|
|
|
|
if (data == null) { |
|
|
|
|
return new HXResponse(ErrorCode.INCOME_ERROR.toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String requestId = data.getStr("requestId"); |
|
|
|
|
redBillInfo.setFpqqlsh(requestId); |
|
|
|
|
redBillInfo.setOutTradeOrderno(requestId); |
|
|
|
|
billInfoMapper.updateById(redBillInfo); |
|
|
|
|
|
|
|
|
|
HXResponse response = new HXResponse("0000", "同步成功"); |
|
|
|
|
response.put("fpqqlsh", billInfo.getSystemOrderno()); |
|
|
|
|
return response; |
|
|
|
|
} else { |
|
|
|
|
return new HXResponse(ErrorCode.INCOME_ERROR + "未获取到开票类型!".toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -174,11 +243,12 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 发票打印 |
|
|
|
|
* @author dxk |
|
|
|
|
* @date 2022/6/29 13:48 |
|
|
|
|
* |
|
|
|
|
* @param invoice |
|
|
|
|
* @param companyservice |
|
|
|
|
* @return com.jianshui.common.core.domain.AjaxResult |
|
|
|
|
* @author dxk |
|
|
|
|
* @date 2022/6/29 13:48 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public AjaxResult printInvoice(Invoice invoice, Companyservice companyservice) { |
|
|
|
@ -188,11 +258,12 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 发票作废 |
|
|
|
|
* @author dxk |
|
|
|
|
* @date 2022/6/30 9:43 |
|
|
|
|
* |
|
|
|
|
* @param invoice |
|
|
|
|
* @param companyservice |
|
|
|
|
* @return com.jianshui.invoice.domain.dto.HXResponse |
|
|
|
|
* @author dxk |
|
|
|
|
* @date 2022/6/30 9:43 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public HXResponse deprecateInvoice(JSONObject invoice, Companyservice companyservice) { |
|
|
|
@ -207,6 +278,7 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 单个发票查询 |
|
|
|
|
* |
|
|
|
|
* @param billInfo |
|
|
|
|
* @param companyservice |
|
|
|
|
* @return |
|
|
|
@ -215,20 +287,20 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
public HXResponse queryInvoice(QueryBillInfoDTO billInfo, Companyservice companyservice) { |
|
|
|
|
|
|
|
|
|
String systemOrderNo = billInfo.getSystemOrderno(); |
|
|
|
|
BillInfo billInfoResult = billInfoMapper.selectBySystemOrderNo(companyservice.getCompanyid(),systemOrderNo); |
|
|
|
|
BillInfo billInfoResult = billInfoMapper.selectBySystemOrderNo(companyservice.getCompanyid(), systemOrderNo); |
|
|
|
|
|
|
|
|
|
// requestId=OutTradeOrderno
|
|
|
|
|
if(StrUtil.isEmpty(billInfoResult.getOutTradeOrderno())){ |
|
|
|
|
if (StrUtil.isEmpty(billInfoResult.getOutTradeOrderno())) { |
|
|
|
|
return new HXResponse("未获取到开票记录!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询用户登记参数
|
|
|
|
|
QueryWrapper<InvoiceAllYhdj> yhdjQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
yhdjQueryWrapper.eq("nsrsbh",companyservice.getSellertax()); |
|
|
|
|
yhdjQueryWrapper.eq("identity",companyservice.getIdentity()); |
|
|
|
|
yhdjQueryWrapper.eq("nsrsbh", companyservice.getSellertax()); |
|
|
|
|
yhdjQueryWrapper.eq("identity", companyservice.getIdentity()); |
|
|
|
|
InvoiceAllYhdj invoiceAllYhdj = yhdjMapper.selectOne(yhdjQueryWrapper); |
|
|
|
|
|
|
|
|
|
if(BeanUtil.isEmpty(invoiceAllYhdj)) { |
|
|
|
|
if (BeanUtil.isEmpty(invoiceAllYhdj)) { |
|
|
|
|
return new HXResponse("用户未登记!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -256,20 +328,21 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
if ("0000".equals(code) && StrUtil.isNotEmpty(data)) { |
|
|
|
|
|
|
|
|
|
QueryWrapper<InvoiceAllApiLog> apiLogQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
apiLogQueryWrapper.eq("request_id",requestId); |
|
|
|
|
apiLogQueryWrapper.eq("request_id", requestId); |
|
|
|
|
InvoiceAllApiLog allApiLog = allApiLogMapper.selectOne(apiLogQueryWrapper); |
|
|
|
|
if(BeanUtil.isNotEmpty(allApiLog) && StrUtil.isNotEmpty(allApiLog.getRequestId())){ |
|
|
|
|
if (BeanUtil.isNotEmpty(allApiLog) && StrUtil.isNotEmpty(allApiLog.getRequestId())) { |
|
|
|
|
serviceId = allApiLog.getRequestId(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HXResponse response = new HXResponse("0000", "查询成功"); |
|
|
|
|
|
|
|
|
|
String finalServiceId = serviceId; |
|
|
|
|
|
|
|
|
|
if (WebServiceConstant.LZFPKJ.equals(finalServiceId)) { |
|
|
|
|
// 蓝字发票开具
|
|
|
|
|
AddInvoiceTWOVO addInvoiceVO = BeanUtil.copyProperties(data, AddInvoiceTWOVO.class); |
|
|
|
|
|
|
|
|
|
if(BeanUtil.isNotEmpty(addInvoiceVO)){ |
|
|
|
|
if (BeanUtil.isNotEmpty(addInvoiceVO)) { |
|
|
|
|
QueryWrapper<BillInfo> billInfoQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
billInfoQueryWrapper.eq("out_trade_orderno", requestId); |
|
|
|
|
BillInfo billInfoR = billInfoMapper.selectOne(billInfoQueryWrapper); |
|
|
|
@ -318,10 +391,10 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
response.put("data", invoice); |
|
|
|
|
} else { |
|
|
|
|
log.error("【金四服务类】【金财数科】【通用查询接口】API请求异常,billInfo未查询到,requestId={}。", requestId); |
|
|
|
|
// return AjaxResult.error(ErrorCode.INCOME_ERROR);
|
|
|
|
|
return new HXResponse("查询错误!"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} /*else if (WebServiceConstant.FPEWMXZ.equals(finalServiceId)) { |
|
|
|
|
} else if (WebServiceConstant.FPEWMXZ.equals(finalServiceId)) { |
|
|
|
|
// 获取发票下载地址
|
|
|
|
|
cn.hutool.json.JSONObject json = JSONUtil.parseObj(data); |
|
|
|
|
String ewmUrl = json.getOrDefault("ewmUrl", "").toString(); |
|
|
|
@ -338,21 +411,18 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
invoiceMapper.updateInvoice(invoice); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
/*else if (WebServiceConstant.ADD_RED_INVOICE.equals(finalServiceId)) { |
|
|
|
|
// TODO: 2023/3/29 返回数据处理
|
|
|
|
|
} else if (WebServiceConstant.ADD_RED_INVOICE.equals(finalServiceId)) { |
|
|
|
|
// 查找原发票信息
|
|
|
|
|
AddRedInvoiceVO addRedInvoiceVO = BeanUtil.copyProperties(data, AddRedInvoiceVO.class); |
|
|
|
|
AddRedInvoiceTWOVO addRedInvoiceVO = BeanUtil.copyProperties(data, AddRedInvoiceTWOVO.class); |
|
|
|
|
QueryWrapper<BillInfo> billInfoQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
billInfoQueryWrapper.eq("fpqqlsh", requestId); |
|
|
|
|
BillInfo billInfo = billInfoMapper.selectOne(billInfoQueryWrapper); |
|
|
|
|
if (billInfo != null) { |
|
|
|
|
BillInfo billInfoR = billInfoMapper.selectOne(billInfoQueryWrapper); |
|
|
|
|
if (billInfoR != null) { |
|
|
|
|
// return AjaxResult.error("未查询到原发票信息");
|
|
|
|
|
// 根据billInfo获得原发票号码
|
|
|
|
|
QueryWrapper<BillInfo> originBillInfoWrapper = new QueryWrapper<>(); |
|
|
|
|
originBillInfoWrapper.eq("origin_fphm", billInfo.getOriginFphm()); |
|
|
|
|
originBillInfoWrapper.eq("origin_fphm", billInfoR.getOriginFphm()); |
|
|
|
|
BillInfo originBillInfo = billInfoMapper.selectOne(originBillInfoWrapper); |
|
|
|
|
if (originBillInfo != null) { |
|
|
|
|
// return AjaxResult.error("未查询到原发票信息");
|
|
|
|
@ -377,13 +447,13 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
invoice.setcOfdUrl(addRedInvoiceVO.getXmlUrl()); |
|
|
|
|
invoice.setState(2); |
|
|
|
|
invoiceMapper.insertInvoice(invoice); |
|
|
|
|
billInfo.setState(2); |
|
|
|
|
billInfoMapper.updateById(billInfo); |
|
|
|
|
billInfoR.setState(2); |
|
|
|
|
billInfoMapper.updateById(billInfoR); |
|
|
|
|
|
|
|
|
|
response.put("data", invoice); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
response.put("data", JSONUtil.parseObj(data)); |
|
|
|
|
|
|
|
|
|
}*/ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*else if (WebServiceConstant.KSHC.equals(finalServiceId)) { |
|
|
|
|
// 快速冲红
|
|
|
|
@ -419,6 +489,7 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 发票批量查询 |
|
|
|
|
* |
|
|
|
|
* @param billInfo |
|
|
|
|
* @param byWhat |
|
|
|
|
* @param companyservice |
|
|
|
@ -434,7 +505,9 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** 红字信息表上传*/ |
|
|
|
|
/** |
|
|
|
|
* 红字信息表上传 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public HXResponse uploadRedInfo(Redinfo redinfo, Companyservice companyservice) { |
|
|
|
|
|
|
|
|
@ -480,7 +553,7 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
|
|
|
|
|
// TODO: 2023/3/9 设备号是 jspbh 并非billNO? 申请方税号reqnsrsbh
|
|
|
|
|
//
|
|
|
|
|
redinfo.setJspbh("661024643068230218103524".substring(0,12)); |
|
|
|
|
redinfo.setJspbh("661024643068230218103524".substring(0, 12)); |
|
|
|
|
redinfo.setReqnsrsbh("9113093067851155XY"); |
|
|
|
|
redinfo.setFjh("123"); |
|
|
|
|
redinfo.setMultTaxRate("0"); |
|
|
|
@ -492,7 +565,7 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
redinfoMapper.batchRedinfodetail(redinfodetailList); |
|
|
|
|
|
|
|
|
|
// 参数校验及参数处理
|
|
|
|
|
AisinoConsoleInvoiceRedUploadDTO redUploadDTO = BeanUtil.copyProperties(redinfo,AisinoConsoleInvoiceRedUploadDTO.class); |
|
|
|
|
AisinoConsoleInvoiceRedUploadDTO redUploadDTO = BeanUtil.copyProperties(redinfo, AisinoConsoleInvoiceRedUploadDTO.class); |
|
|
|
|
// 填开日期
|
|
|
|
|
redUploadDTO.setDate(redinfo.getBillInputTime()); |
|
|
|
|
// 信息表类型
|
|
|
|
@ -507,18 +580,17 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
ValidateUtils.validate(redUploadDTO); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(redinfo.getRedinfodetailList() == null || redinfo.getRedinfodetailList().size() == 0){ |
|
|
|
|
if (redinfo.getRedinfodetailList() == null || redinfo.getRedinfodetailList().size() == 0) { |
|
|
|
|
return new HXResponse("格式校验失败,请上传明细信息!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String paramChild = ""; |
|
|
|
|
List<AisinoConsoleInvoiceRedUploadChildDTO> redUploadChildDTO = BeanUtil.copyToList(redinfo.getRedinfodetailList(),AisinoConsoleInvoiceRedUploadChildDTO.class); |
|
|
|
|
List<AisinoConsoleInvoiceRedUploadChildDTO> redUploadChildDTO = BeanUtil.copyToList(redinfo.getRedinfodetailList(), AisinoConsoleInvoiceRedUploadChildDTO.class); |
|
|
|
|
for (AisinoConsoleInvoiceRedUploadChildDTO childDTO : redUploadChildDTO) { |
|
|
|
|
|
|
|
|
|
// TODO-dxk: 2023/2/27 含税、不含税金额
|
|
|
|
|
childDTO.setHS_BZ(childDTO.getHS_BZ().equals("false")? "N":"Y"); |
|
|
|
|
childDTO.setHS_BZ(childDTO.getHS_BZ().equals("false") ? "N" : "Y"); |
|
|
|
|
|
|
|
|
|
paramChild = "<GoodsMx>" + JSONUtil.toXmlStr(JSONUtil.parse(childDTO)) + " </GoodsMx>"; |
|
|
|
|
|
|
|
|
@ -546,10 +618,10 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
|
|
|
|
|
//发起请求
|
|
|
|
|
AjaxResult ajaxResult = null; |
|
|
|
|
try{ |
|
|
|
|
try { |
|
|
|
|
ajaxResult = AisinoConsoleUtil.sendRequest(AisinoConsoleConstants.RED_UPLOAD, param, companyservice); |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
log.error("【销项发票】【总部控制台接口】【发票作废】发票请求异常,请求报文{},销方信息{}","", JSONObject.toJSONString(companyservice)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("【销项发票】【总部控制台接口】【发票作废】发票请求异常,请求报文{},销方信息{}", "", JSONObject.toJSONString(companyservice)); |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
throw new JianshuiServiceException("系统异常!"); |
|
|
|
|
} |
|
|
|
@ -585,7 +657,9 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** 红字信息表下载 */ |
|
|
|
|
/** |
|
|
|
|
* 红字信息表下载 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public HXResponse downloadRedInfo(DownloadRedInfoDTO downloadRedInfoDTO, Companyservice companyservice) { |
|
|
|
|
|
|
|
|
@ -624,7 +698,7 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 组装报文
|
|
|
|
|
AisinoConsoleInvoiceRedDownloadDTO downloadDTO = BeanUtil.copyProperties(redInfoResult,AisinoConsoleInvoiceRedDownloadDTO.class); |
|
|
|
|
AisinoConsoleInvoiceRedDownloadDTO downloadDTO = BeanUtil.copyProperties(redInfoResult, AisinoConsoleInvoiceRedDownloadDTO.class); |
|
|
|
|
downloadDTO.setYQZT("N"); |
|
|
|
|
downloadDTO.setXXBFW("0"); |
|
|
|
|
downloadDTO.setPAGENO("1"); |
|
|
|
@ -638,10 +712,10 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
|
|
|
|
|
//发起请求
|
|
|
|
|
AjaxResult ajaxResult = null; |
|
|
|
|
try{ |
|
|
|
|
try { |
|
|
|
|
ajaxResult = AisinoConsoleUtil.sendRequest(AisinoConsoleConstants.RED_DOWLOAD, param, companyservice); |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
log.error("【销项发票】【总部控制台接口】【发票作废】发票请求异常,请求报文{},销方信息{}","", JSONObject.toJSONString(companyservice)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("【销项发票】【总部控制台接口】【发票作废】发票请求异常,请求报文{},销方信息{}", "", JSONObject.toJSONString(companyservice)); |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
throw new JianshuiServiceException("系统异常!"); |
|
|
|
|
} |
|
|
|
@ -668,7 +742,6 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public HXResponse deprecateQueryInvoice(DeprecateQueryInvoiceDTO invoice, Companyservice companyservice) { |
|
|
|
|
return null; |
|
|
|
@ -677,6 +750,7 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 打印机查询 |
|
|
|
|
* |
|
|
|
|
* @param queryPrinterDTO |
|
|
|
|
* @param companyservice |
|
|
|
|
* @return |
|
|
|
@ -693,6 +767,7 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 发票打印 |
|
|
|
|
* |
|
|
|
|
* @param printDTO |
|
|
|
|
* @param companyservice |
|
|
|
|
* @return |
|
|
|
@ -762,16 +837,17 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 总部控制台转简税发票类型 |
|
|
|
|
* @author dxk |
|
|
|
|
* @date 2022/6/29 17:12 |
|
|
|
|
* |
|
|
|
|
* @param invoiceType |
|
|
|
|
* @return java.lang.String |
|
|
|
|
* @author dxk |
|
|
|
|
* @date 2022/6/29 17:12 |
|
|
|
|
*/ |
|
|
|
|
public static String CovertInvoiceTypeReverse(String invoiceType){ |
|
|
|
|
public static String CovertInvoiceTypeReverse(String invoiceType) { |
|
|
|
|
|
|
|
|
|
if(invoiceType.equals("2")){ |
|
|
|
|
if (invoiceType.equals("2")) { |
|
|
|
|
return "p"; |
|
|
|
|
}else if(invoiceType.equals("0")){ |
|
|
|
|
} else if (invoiceType.equals("0")) { |
|
|
|
|
return "s"; |
|
|
|
|
} |
|
|
|
|
return ""; |
|
|
|
@ -789,4 +865,36 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 简税和金财数科 发票类型互换 |
|
|
|
|
* |
|
|
|
|
* @param invoiceType 发票种类 |
|
|
|
|
* @param jcsk2js 是否通过金财数科转换为简税 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private static String getInvoiceType(String invoiceType, boolean jcsk2js) { |
|
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
|
|
map.put("10", "p"); //电子增值税普通发票 10
|
|
|
|
|
map.put("04", "c"); //增值税普通发票 04
|
|
|
|
|
map.put("01", "s"); //增值税专用发票 01
|
|
|
|
|
map.put("08", "b"); //增值税电子专用发票 08
|
|
|
|
|
map.put("87", "j"); //机动车发票 87
|
|
|
|
|
map.put("88", "u"); //二手车发票 88
|
|
|
|
|
map.put("82", "q"); //全电普票
|
|
|
|
|
map.put("81", "q"); //全电专票
|
|
|
|
|
if (jcsk2js) { |
|
|
|
|
String resp = map.get(invoiceType); |
|
|
|
|
return StringUtils.isNotEmpty(resp) ? resp : invoiceType; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (Map.Entry<String, String> entry : map.entrySet()) { |
|
|
|
|
if (entry.getValue().equals(invoiceType)) { |
|
|
|
|
return entry.getKey(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return invoiceType; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|