|
|
|
@ -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,6 +85,10 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
// 请求billInfo
|
|
|
|
|
Long billInfoID = 0L; |
|
|
|
|
|
|
|
|
|
// kptype 1蓝票 2红票
|
|
|
|
|
String kpType = billInfo.getKptype(); |
|
|
|
|
|
|
|
|
|
if ("1".equals(kpType)) { |
|
|
|
|
// 开票实体转换,校验
|
|
|
|
|
InvoiceAllAddTwoDTO invoiceAllAddTwoDTO = BeanUtil.copyProperties(billInfo, InvoiceAllAddTwoDTO.class); |
|
|
|
|
ValidateUtils.validate(invoiceAllAddTwoDTO); |
|
|
|
@ -109,7 +115,7 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
billInfoID = billInfo.getId(); |
|
|
|
|
if (BeanUtil.isEmpty(billInfo.getId())) { |
|
|
|
|
log.error("【金四服务类】【金财数科】【蓝字发票开具】API请求异常,billInfoId返回存储错误。"); |
|
|
|
|
return new HXResponse(ErrorCode.INCOME_ERROR.toString()); |
|
|
|
|
return new HXResponse("蓝字发票开具内部错误!"); |
|
|
|
|
} |
|
|
|
|
//数据库存储
|
|
|
|
|
List<BillDetail> billDetailList = billInfo.getBillDetailList(); |
|
|
|
@ -118,7 +124,7 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
log.error("【金四服务类】【金财数科】【蓝字发票开具】API请求异常,billInfo存储错误。错误信息:{}", e.getMessage()); |
|
|
|
|
return new HXResponse(ErrorCode.INCOME_ERROR.toString()); |
|
|
|
|
return new HXResponse("蓝字发票开具内部错误!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cn.hutool.json.JSONObject result = null; |
|
|
|
@ -169,16 +175,80 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
return new HXResponse("蓝字发票开具异常"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} 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()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 发票打印 |
|
|
|
|
* @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 |
|
|
|
@ -265,6 +337,7 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
HXResponse response = new HXResponse("0000", "查询成功"); |
|
|
|
|
|
|
|
|
|
String finalServiceId = serviceId; |
|
|
|
|
|
|
|
|
|
if (WebServiceConstant.LZFPKJ.equals(finalServiceId)) { |
|
|
|
|
// 蓝字发票开具
|
|
|
|
|
AddInvoiceTWOVO addInvoiceVO = BeanUtil.copyProperties(data, AddInvoiceTWOVO.class); |
|
|
|
@ -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) { |
|
|
|
|
|
|
|
|
@ -507,7 +580,6 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
ValidateUtils.validate(redUploadDTO); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (redinfo.getRedinfodetailList() == null || redinfo.getRedinfodetailList().size() == 0) { |
|
|
|
|
return new HXResponse("格式校验失败,请上传明细信息!"); |
|
|
|
|
} |
|
|
|
@ -585,7 +657,9 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** 红字信息表下载 */ |
|
|
|
|
/** |
|
|
|
|
* 红字信息表下载 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public HXResponse downloadRedInfo(DownloadRedInfoDTO downloadRedInfoDTO, Companyservice companyservice) { |
|
|
|
|
|
|
|
|
@ -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,10 +837,11 @@ 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) { |
|
|
|
|
|
|
|
|
@ -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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|