|
|
|
@ -1,4 +1,6 @@ |
|
|
|
|
package com.jianshui.invoice.service.impl.api; |
|
|
|
|
import com.jianshui.invoice.domain.dto.api.jcsk.SqhzJsonDataDetailTwoDTO; |
|
|
|
|
import com.jianshui.invoice.domain.dto.api.jcsk.SqhzJsonDataTwoDTO; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
@ -23,6 +25,7 @@ import com.jianshui.invoice.domain.*; |
|
|
|
|
import com.jianshui.invoice.domain.dto.*; |
|
|
|
|
import com.jianshui.invoice.domain.dto.api.aisino.console.*; |
|
|
|
|
import com.jianshui.invoice.domain.dto.api.jcsk.QueryTwoDTO; |
|
|
|
|
import com.jianshui.invoice.domain.dto.api.jcsk.SqhzTwoDTO; |
|
|
|
|
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; |
|
|
|
@ -511,8 +514,7 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
@Override |
|
|
|
|
public HXResponse uploadRedInfo(Redinfo redinfo, Companyservice companyservice) { |
|
|
|
|
|
|
|
|
|
// 前置处理
|
|
|
|
|
redinfo.setCompanyId(companyservice.getCompanyid()); |
|
|
|
|
// 前置处理 redinfo.setCompanyId(companyservice.getCompanyid());
|
|
|
|
|
redinfo.setSystemOrderno(IdUtils.randomSystemOrderno()); |
|
|
|
|
if (StringUtils.isEmpty(redinfo.getOutTradeOrderno())) { |
|
|
|
|
// 把 outTradeOrderno作为用户的申请单号
|
|
|
|
@ -538,7 +540,6 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
int index = 0; |
|
|
|
|
|
|
|
|
|
String spbm = ""; |
|
|
|
|
|
|
|
|
|
for (Redinfodetail detail : redinfodetailList) { |
|
|
|
|
detail.setBillno(redinfo.getRedInfoNo()); |
|
|
|
|
detail.setRedinfoId(redinfo.getId()); |
|
|
|
@ -551,105 +552,87 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
spbm = detail.getSpbm(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO: 2023/3/9 设备号是 jspbh 并非billNO? 申请方税号reqnsrsbh
|
|
|
|
|
//
|
|
|
|
|
redinfo.setJspbh("661024643068230218103524".substring(0, 12)); |
|
|
|
|
redinfo.setReqnsrsbh("9113093067851155XY"); |
|
|
|
|
redinfo.setFjh("123"); |
|
|
|
|
redinfo.setMultTaxRate("0"); |
|
|
|
|
redinfo.setBillInputTime("2022-11-11"); |
|
|
|
|
redinfo.setBmbbh("2323232"); |
|
|
|
|
redinfo.setTaxrate(new BigDecimal("0.03")); |
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
redinfoMapper.batchRedinfodetail(redinfodetailList); |
|
|
|
|
|
|
|
|
|
// 参数校验及参数处理
|
|
|
|
|
AisinoConsoleInvoiceRedUploadDTO redUploadDTO = BeanUtil.copyProperties(redinfo, AisinoConsoleInvoiceRedUploadDTO.class); |
|
|
|
|
// 填开日期
|
|
|
|
|
redUploadDTO.setDate(redinfo.getBillInputTime()); |
|
|
|
|
// 信息表类型
|
|
|
|
|
redUploadDTO.setBillType("0"); |
|
|
|
|
// TODO-dxk: 2023/2/27 含税、不含税金额 含税标志,这里需要确定
|
|
|
|
|
// 合计金额计算
|
|
|
|
|
redUploadDTO.setAmount(String.valueOf(taxfreeamt)); |
|
|
|
|
// 含税税率标识
|
|
|
|
|
redUploadDTO.setSLBZ("0"); |
|
|
|
|
// 税种类别
|
|
|
|
|
redUploadDTO.setSzlb("1"); |
|
|
|
|
ValidateUtils.validate(redUploadDTO); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (redinfo.getRedinfodetailList() == null || redinfo.getRedinfodetailList().size() == 0) { |
|
|
|
|
return new HXResponse("格式校验失败,请上传明细信息!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String paramChild = ""; |
|
|
|
|
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"); |
|
|
|
|
|
|
|
|
|
paramChild = "<GoodsMx>" + JSONUtil.toXmlStr(JSONUtil.parse(childDTO)) + " </GoodsMx>"; |
|
|
|
|
// 金财数科数据处理 start
|
|
|
|
|
// 查询用户登记参数
|
|
|
|
|
QueryWrapper<InvoiceAllYhdj> yhdjQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
yhdjQueryWrapper.eq("nsrsbh", companyservice.getSellertax()); |
|
|
|
|
yhdjQueryWrapper.eq("identity", companyservice.getIdentity()); |
|
|
|
|
InvoiceAllYhdj invoiceAllYhdj = yhdjMapper.selectOne(yhdjQueryWrapper); |
|
|
|
|
|
|
|
|
|
ValidateUtils.validate(childDTO); |
|
|
|
|
if (BeanUtil.isEmpty(invoiceAllYhdj)) { |
|
|
|
|
return new HXResponse("用户未登记!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 组装xml报文
|
|
|
|
|
String param = JSONUtil.toXmlStr(JSONUtil.parse(redUploadDTO)); |
|
|
|
|
SqhzTwoDTO sqhzDTO = BeanUtil.copyProperties(redinfo,SqhzTwoDTO.class); |
|
|
|
|
sqhzDTO.setAsync("true"); |
|
|
|
|
sqhzDTO.setBsrysfzjhm(invoiceAllYhdj.getBsrysfzjhm()); |
|
|
|
|
sqhzDTO.setDqbm(invoiceAllYhdj.getDqbm()); |
|
|
|
|
sqhzDTO.setNsrsbh(invoiceAllYhdj.getNsrsbh()); |
|
|
|
|
ValidateUtils.validate(sqhzDTO); |
|
|
|
|
|
|
|
|
|
// param = "<?xml version=\"1.0\" encoding=\"GBK\"?>\n" +
|
|
|
|
|
param = "" + |
|
|
|
|
"<FPXT>\n" + |
|
|
|
|
" <INPUT>\n" + |
|
|
|
|
" <RedInvReqBill>" + param; |
|
|
|
|
SqhzJsonDataTwoDTO sqhzJsonDataTwoDTO = BeanUtil.copyProperties(redinfo,SqhzJsonDataTwoDTO.class); |
|
|
|
|
ValidateUtils.validate(sqhzJsonDataTwoDTO); |
|
|
|
|
|
|
|
|
|
param = param + "<RedInvReqBillMx>"; |
|
|
|
|
List<SqhzJsonDataDetailTwoDTO> sqhzJsonDataDetailTwoDTOS = BeanUtil.copyToList(redinfo.getRedinfodetailList(),SqhzJsonDataDetailTwoDTO.class); |
|
|
|
|
for (SqhzJsonDataDetailTwoDTO sqhzJsonDataDetailTwoDTO : sqhzJsonDataDetailTwoDTOS) { |
|
|
|
|
ValidateUtils.validate(sqhzJsonDataDetailTwoDTO); |
|
|
|
|
} |
|
|
|
|
sqhzJsonDataTwoDTO.setHzqrxxmxlist(sqhzJsonDataDetailTwoDTOS); |
|
|
|
|
sqhzDTO.setJsonData(sqhzJsonDataTwoDTO); |
|
|
|
|
|
|
|
|
|
param = param + paramChild; |
|
|
|
|
cn.hutool.json.JSONObject result = null; |
|
|
|
|
try { |
|
|
|
|
result = ApiHttp.request(WebServiceConstant.SQHZFPXXQRD, WebServiceConstant.URL, sqhzDTO, companyservice); |
|
|
|
|
|
|
|
|
|
param = param + " </RedInvReqBillMx>\n" + |
|
|
|
|
" </RedInvReqBill>\n" + |
|
|
|
|
" </INPUT>\n" + |
|
|
|
|
"</FPXT>"; |
|
|
|
|
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)) { |
|
|
|
|
return new HXResponse(msg); |
|
|
|
|
} |
|
|
|
|
InvoiceAllApiLog allApiLog = new InvoiceAllApiLog(); |
|
|
|
|
allApiLog.setUrl(WebServiceConstant.SQHZFPXXQRD); |
|
|
|
|
allApiLog.setSendMsg(sqhzDTO.toString()); |
|
|
|
|
allApiLog.setResultMsg(JSONUtil.toJsonStr(result)); |
|
|
|
|
allApiLog.setCompany(companyservice.getSellertax()); |
|
|
|
|
allApiLog.setIdentityId(companyservice.getIdentity()); |
|
|
|
|
allApiLog.setRequestId(requestId); |
|
|
|
|
allApiLog.setCreateTime(new Date()); |
|
|
|
|
allApiLogMapper.insertInvoiceAllApiLog(allApiLog); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HXResponse response = new HXResponse("0000", "申请成功"); |
|
|
|
|
response.put("data",requestId); |
|
|
|
|
return response; |
|
|
|
|
|
|
|
|
|
//发起请求
|
|
|
|
|
AjaxResult ajaxResult = null; |
|
|
|
|
try { |
|
|
|
|
ajaxResult = AisinoConsoleUtil.sendRequest(AisinoConsoleConstants.RED_UPLOAD, param, companyservice); |
|
|
|
|
} else { |
|
|
|
|
return new HXResponse(msg); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("【销项发票】【总部控制台接口】【发票作废】发票请求异常,请求报文{},销方信息{}", "", JSONObject.toJSONString(companyservice)); |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
throw new JianshuiServiceException("系统异常!"); |
|
|
|
|
} |
|
|
|
|
log.error("【金四服务类】【金财数科】【申请红字信息表】API请求异常,外部报文返回code非0000。错误信息:{}", e.getMessage()); |
|
|
|
|
return new HXResponse("通用查询接口异常"); |
|
|
|
|
|
|
|
|
|
//返回报文解析
|
|
|
|
|
if (ajaxResult.isError()) { |
|
|
|
|
throw new JianshuiServiceException(ajaxResult.getMsg()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// todo-k: 返回报文解析这里还带看下具体的返回形式
|
|
|
|
|
|
|
|
|
|
cn.hutool.json.JSONObject resultJSON = JSONUtil.parseObj(ajaxResult.get("data")); |
|
|
|
|
String retcode = resultJSON.get("retcode") != null ? resultJSON.get("retcode").toString() : ""; |
|
|
|
|
String retmsg = resultJSON.get("retmsg") != null ? resultJSON.get("retmsg").toString() : ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.equals("0000", retcode)) { |
|
|
|
|
/*if (!StringUtils.equals("0000", retcode)) { |
|
|
|
|
redinfo.setRedInfoStatus("2"); |
|
|
|
|
redinfo.setRedInfoMessage(retmsg); |
|
|
|
|
redinfoMapper.updateRedinfo(redinfo); |
|
|
|
|
return new HXResponse(retmsg); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO-dxk: 2023/2/27 看下 RedInfoStatus 0 1 2代表什么
|
|
|
|
|
redinfo.setRedInfoStatus("1"); |
|
|
|
|
redinfo.setRedInfoMessage(retmsg); |
|
|
|
|
redinfoMapper.updateRedinfo(redinfo); |
|
|
|
|
return new HXResponse(retmsg); |
|
|
|
|
return new HXResponse(retmsg);*/ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|