|
|
@ -2,6 +2,8 @@ package com.jianshui.invoice.service.impl.api; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.Date; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.copier.CopyOptions; |
|
|
|
import cn.hutool.core.bean.copier.CopyOptions; |
|
|
|
|
|
|
|
import cn.hutool.core.map.MapUtil; |
|
|
|
|
|
|
|
import com.jianshui.common.utils.BeanToMapUtils; |
|
|
|
import com.jianshui.invoice.domain.dto.api.*; |
|
|
|
import com.jianshui.invoice.domain.dto.api.*; |
|
|
|
import com.jianshui.invoice.domain.dto.api.jcsk.*; |
|
|
|
import com.jianshui.invoice.domain.dto.api.jcsk.*; |
|
|
|
|
|
|
|
|
|
|
@ -121,7 +123,7 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
// 忽略明细属性
|
|
|
|
// 忽略明细属性
|
|
|
|
InvoiceAllAddInfoTwoDTO invoiceAllAddInfoTwoDTO = BeanUtil.copyProperties(billInfo, InvoiceAllAddInfoTwoDTO.class |
|
|
|
InvoiceAllAddInfoTwoDTO invoiceAllAddInfoTwoDTO = BeanUtil.copyProperties(billInfo, InvoiceAllAddInfoTwoDTO.class |
|
|
|
,"fjxxList","mxList","tdywxx","ext"); |
|
|
|
,"fjxxList","mxList","tdywxx","ext"); |
|
|
|
// TODO: 2023/4/24 明细处理 必填非必填对应
|
|
|
|
// 发票类型处理
|
|
|
|
|
|
|
|
|
|
|
|
ValidateUtils.validate(invoiceAllAddInfoTwoDTO); |
|
|
|
ValidateUtils.validate(invoiceAllAddInfoTwoDTO); |
|
|
|
|
|
|
|
|
|
|
@ -141,6 +143,17 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
// 报文转换存储
|
|
|
|
// 报文转换存储
|
|
|
|
billInfo.setCompanyId(companyservice.getCompanyid()); |
|
|
|
billInfo.setCompanyId(companyservice.getCompanyid()); |
|
|
|
billInfo.setServiceSupplierKey("JCSK"); |
|
|
|
billInfo.setServiceSupplierKey("JCSK"); |
|
|
|
|
|
|
|
String invoiceType = getInvoiceType(billInfo.getInvoiceType(),true); |
|
|
|
|
|
|
|
if(StrUtil.isEmpty(invoiceType)){ |
|
|
|
|
|
|
|
return new HXResponse("发票类型代码不存在!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
billInfo.setInvoiceType(invoiceType); |
|
|
|
|
|
|
|
String systemOrderno = IdUtils.randomSystemOrderno(); |
|
|
|
|
|
|
|
billInfo.setSystemOrderno(systemOrderno); |
|
|
|
|
|
|
|
billInfo.setOutTradeOrderno(systemOrderno); |
|
|
|
|
|
|
|
if(BeanUtil.isEmpty(billInfo.getClerk())){ |
|
|
|
|
|
|
|
billInfo.setClerk(""); |
|
|
|
|
|
|
|
} |
|
|
|
try { |
|
|
|
try { |
|
|
|
int resBillInfo = billInfoMapper.insertBillInfo(billInfo); |
|
|
|
int resBillInfo = billInfoMapper.insertBillInfo(billInfo); |
|
|
|
if (resBillInfo > 0) { |
|
|
|
if (resBillInfo > 0) { |
|
|
@ -151,6 +164,11 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
} |
|
|
|
} |
|
|
|
//数据库存储
|
|
|
|
//数据库存储
|
|
|
|
List<BillDetail> billDetailList = billInfo.getBillDetailList(); |
|
|
|
List<BillDetail> billDetailList = billInfo.getBillDetailList(); |
|
|
|
|
|
|
|
Long index = 0L; |
|
|
|
|
|
|
|
for (BillDetail billDetail : billDetailList) { |
|
|
|
|
|
|
|
billDetail.setBillInfoId(billInfoID); |
|
|
|
|
|
|
|
billDetail.setIndex(++index); |
|
|
|
|
|
|
|
} |
|
|
|
int billDetailResult = billInfoMapper.batchBillDetail(billDetailList); |
|
|
|
int billDetailResult = billInfoMapper.batchBillDetail(billDetailList); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
@ -162,11 +180,10 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
cn.hutool.json.JSONObject result = null; |
|
|
|
cn.hutool.json.JSONObject result = null; |
|
|
|
|
|
|
|
|
|
|
|
// TODO: 2023/4/23 调试
|
|
|
|
// TODO: 2023/4/23 调试
|
|
|
|
log.info("金财数科蓝字请求报文打印=",JSONUtil.parse(invoiceAllAddTwoDTO)); |
|
|
|
|
|
|
|
return null; |
|
|
|
try { |
|
|
|
|
|
|
|
Map<String,Object> map = BeanToMapUtils.fastJsonBean2Map(invoiceAllAddTwoDTO); |
|
|
|
/*try { |
|
|
|
result = ApiHttp.request(WebServiceConstant.LZFPKJ, WebServiceConstant.URL, JSONUtil.parse(map), companyservice); |
|
|
|
result = ApiHttp.request(WebServiceConstant.LZFPKJ, WebServiceConstant.URL, invoiceAllAddTwoDTO, companyservice); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String code = result.get("code") != null ? result.get("code").toString() : ""; |
|
|
|
String code = result.get("code") != null ? result.get("code").toString() : ""; |
|
|
|
String msg = result.get("msg") != null ? result.get("msg").toString() : ""; |
|
|
|
String msg = result.get("msg") != null ? result.get("msg").toString() : ""; |
|
|
@ -209,7 +226,7 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("【金四服务类】【金财数科】【蓝字发票开具】API请求异常,外部报文返回code非0000。错误信息:{}", e.getMessage()); |
|
|
|
log.error("【金四服务类】【金财数科】【蓝字发票开具】API请求异常,外部报文返回code非0000。错误信息:{}", e.getMessage()); |
|
|
|
return new HXResponse("蓝字发票开具异常"); |
|
|
|
return new HXResponse("蓝字发票开具异常"); |
|
|
|
}*/ |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else if ("2".equals(kpType)) { |
|
|
|
} else if ("2".equals(kpType)) { |
|
|
|
|
|
|
|
|
|
|
@ -1309,6 +1326,31 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private static String getInvoiceType(String invoiceType, boolean jcsk2js) { |
|
|
|
private static String getInvoiceType(String invoiceType, boolean jcsk2js) { |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 全电发票(铁路电子客票):51 |
|
|
|
|
|
|
|
* 全电发票(航空运输电子客票行程单) 61 |
|
|
|
|
|
|
|
* 机动车销售电子统一发票 83 |
|
|
|
|
|
|
|
* 二手车销售电子统一发票 84 |
|
|
|
|
|
|
|
* 纸质专票(全电开具) 85 |
|
|
|
|
|
|
|
* 纸质普票(全电开具) 86 |
|
|
|
|
|
|
|
* 货物运输业增值税专用发票 02 |
|
|
|
|
|
|
|
* 机动车销售统一发票 03 |
|
|
|
|
|
|
|
* 二手车销售统一发票 15 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* 纸质发票(机动车销售统一发票) 87 |
|
|
|
|
|
|
|
* 纸质发票(二手车销售统一发票) 88 |
|
|
|
|
|
|
|
* 增值税专票 01 |
|
|
|
|
|
|
|
* 增值税普票 04 |
|
|
|
|
|
|
|
* 增值税电专 08 |
|
|
|
|
|
|
|
* 增值税电普 10 |
|
|
|
|
|
|
|
* 全电专票 81 |
|
|
|
|
|
|
|
* 全电普票 82 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
// TODO: 2023/4/26 整理所有发票代码统一管理
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// a、d、e、f、g、h、i、k、l、m、n、o、q、t、v、w、x、y、z。z
|
|
|
|
|
|
|
|
// p/c/s/b/j/u/q/r
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
|
map.put("10", "p"); //电子增值税普通发票 10
|
|
|
|
map.put("10", "p"); //电子增值税普通发票 10
|
|
|
|
map.put("04", "c"); //增值税普通发票 04
|
|
|
|
map.put("04", "c"); //增值税普通发票 04
|
|
|
@ -1316,8 +1358,9 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
map.put("08", "b"); //增值税电子专用发票 08
|
|
|
|
map.put("08", "b"); //增值税电子专用发票 08
|
|
|
|
map.put("87", "j"); //机动车发票 87
|
|
|
|
map.put("87", "j"); //机动车发票 87
|
|
|
|
map.put("88", "u"); //二手车发票 88
|
|
|
|
map.put("88", "u"); //二手车发票 88
|
|
|
|
|
|
|
|
|
|
|
|
map.put("82", "q"); //全电普票
|
|
|
|
map.put("82", "q"); //全电普票
|
|
|
|
map.put("81", "q"); //全电专票
|
|
|
|
map.put("81", "r"); //全电专票
|
|
|
|
if (jcsk2js) { |
|
|
|
if (jcsk2js) { |
|
|
|
String resp = map.get(invoiceType); |
|
|
|
String resp = map.get(invoiceType); |
|
|
|
return StringUtils.isNotEmpty(resp) ? resp : invoiceType; |
|
|
|
return StringUtils.isNotEmpty(resp) ? resp : invoiceType; |
|
|
@ -1333,4 +1376,7 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|