|
|
@ -4,6 +4,7 @@ import cn.hutool.core.convert.Convert; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
|
|
|
|
import cn.hutool.http.HttpUtil; |
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
@ -14,6 +15,7 @@ import com.jianshui.common.enums.ErrorCode; |
|
|
|
import com.jianshui.common.exception.jianshui.JianshuiParamErrorException; |
|
|
|
import com.jianshui.common.exception.jianshui.JianshuiParamErrorException; |
|
|
|
import com.jianshui.common.exception.jianshui.JianshuiServiceException; |
|
|
|
import com.jianshui.common.exception.jianshui.JianshuiServiceException; |
|
|
|
import com.jianshui.common.utils.*; |
|
|
|
import com.jianshui.common.utils.*; |
|
|
|
|
|
|
|
import com.jianshui.common.utils.spring.SpringUtils; |
|
|
|
import com.jianshui.common.utils.uuid.IdUtils; |
|
|
|
import com.jianshui.common.utils.uuid.IdUtils; |
|
|
|
import com.jianshui.invoice.constant.aisino.console.AisinoConsoleConstants; |
|
|
|
import com.jianshui.invoice.constant.aisino.console.AisinoConsoleConstants; |
|
|
|
import com.jianshui.invoice.domain.*; |
|
|
|
import com.jianshui.invoice.domain.*; |
|
|
@ -29,6 +31,8 @@ import com.jianshui.invoice.mapper.SkDyjMapper; |
|
|
|
import com.jianshui.invoice.service.IInvoiceApiService; |
|
|
|
import com.jianshui.invoice.service.IInvoiceApiService; |
|
|
|
import com.jianshui.invoice.utils.BillInfoUtils; |
|
|
|
import com.jianshui.invoice.utils.BillInfoUtils; |
|
|
|
import com.jianshui.invoice.utils.aisino.console.AisinoConsoleUtil; |
|
|
|
import com.jianshui.invoice.utils.aisino.console.AisinoConsoleUtil; |
|
|
|
|
|
|
|
import com.jianshui.system.domain.CompanyserviceProp; |
|
|
|
|
|
|
|
import com.jianshui.system.service.ICompanyservicePropService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -72,6 +76,17 @@ public class AisinoConsoleInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public HXResponse addInvoice(BillInfo billInfo, Companyservice companyservice) throws IllegalAccessException, InstantiationException { |
|
|
|
public HXResponse addInvoice(BillInfo billInfo, Companyservice companyservice) throws IllegalAccessException, InstantiationException { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String outNO = billInfo.getOutTradeOrderno() != null ? billInfo.getOutTradeOrderno():""; |
|
|
|
|
|
|
|
if(StrUtil.isEmpty(outNO)){ |
|
|
|
|
|
|
|
return new HXResponse("订单号为空,请检查报文!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// TODO: 2023/9/26 订单号唯一校验
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 预处理:处理billinfo,计算税额等
|
|
|
|
// 预处理:处理billinfo,计算税额等
|
|
|
|
try { |
|
|
|
try { |
|
|
|
billInfo = BillInfoUtils.processBillInfo(billInfo, companyservice); |
|
|
|
billInfo = BillInfoUtils.processBillInfo(billInfo, companyservice); |
|
|
@ -302,6 +317,15 @@ public class AisinoConsoleInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
invoiceDetailList.forEach(i -> i.setInvoiceId(invoice.getId())); |
|
|
|
invoiceDetailList.forEach(i -> i.setInvoiceId(invoice.getId())); |
|
|
|
invoiceMapper.batchInvoiceDetail(invoiceDetailList); |
|
|
|
invoiceMapper.batchInvoiceDetail(invoiceDetailList); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: 2023/9/26 增加主动回调方式,可配置
|
|
|
|
|
|
|
|
ICompanyservicePropService companyserviceProp = SpringUtils.getBean(ICompanyservicePropService.class); |
|
|
|
|
|
|
|
CompanyserviceProp secretIdProp = companyserviceProp.selectPropByKey(companyservice.getCompanyid(), "aisino_callback_url"); |
|
|
|
|
|
|
|
if(BeanUtil.isNotEmpty(secretIdProp) && secretIdProp.getValue() != null && !"".equals(secretIdProp.getValue())){ |
|
|
|
|
|
|
|
String callBackUrl = secretIdProp.getValue(); |
|
|
|
|
|
|
|
callBackAisino(callBackUrl,invoice.getId()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
HXResponse response = new HXResponse("0000", "同步成功"); |
|
|
|
HXResponse response = new HXResponse("0000", "同步成功"); |
|
|
|
response.put("fpqqlsh", billInfo.getSystemOrderno()); |
|
|
|
response.put("fpqqlsh", billInfo.getSystemOrderno()); |
|
|
|
return response; |
|
|
|
return response; |
|
|
@ -310,6 +334,36 @@ public class AisinoConsoleInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 开票接口回调-重汽 |
|
|
|
|
|
|
|
* 2023-09-26 |
|
|
|
|
|
|
|
* @param callBackUrl |
|
|
|
|
|
|
|
* @param id |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void callBackAisino(String callBackUrl, Long id) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(id == null){ |
|
|
|
|
|
|
|
log.info("【控制台】发票回调,id为空"); |
|
|
|
|
|
|
|
return ; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Invoice invoice = invoiceMapper.selectInvoiceById(id); |
|
|
|
|
|
|
|
if (invoice == null) { |
|
|
|
|
|
|
|
log.info("【控制台】发票信息未查询到,id={}",id); |
|
|
|
|
|
|
|
return ; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
log.info("【控制台】发票回调接口,发送数据开始,id={}",id); |
|
|
|
|
|
|
|
String result = HttpUtil.post(callBackUrl,JSONUtil.toJsonStr(invoice)); |
|
|
|
|
|
|
|
log.info("【控制台】发票回调接口,发送数据结束,id={},接口返回信息={}",id,JSONUtil.toJsonStr(invoice)); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.info("【控制台】发票回调接口,发送数据异常,id={}",id); |
|
|
|
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 发票打印 |
|
|
|
* 发票打印 |
|
|
|