|
|
|
@ -100,9 +100,8 @@ public class AisinoConsoleInvoiceApiZhongQiServiceImpl implements IInvoiceApiSer |
|
|
|
|
@Override |
|
|
|
|
public HXResponse addInvoice(BillInfo billInfo, Companyservice companyservice) throws IllegalAccessException, InstantiationException { |
|
|
|
|
|
|
|
|
|
return new HXResponse("单票接口已关闭!请调用批量接口!"); |
|
|
|
|
|
|
|
|
|
/* // 1.订单唯一校验。新增历史订单部分(删除)。
|
|
|
|
|
// 1.订单唯一校验。新增历史订单部分(删除)。
|
|
|
|
|
// 订单号唯一校验 start
|
|
|
|
|
String outNO = billInfo.getOutTradeOrderno() != null ? billInfo.getOutTradeOrderno() : ""; |
|
|
|
|
if (StrUtil.isEmpty(outNO)) { |
|
|
|
@ -111,22 +110,47 @@ public class AisinoConsoleInvoiceApiZhongQiServiceImpl implements IInvoiceApiSer |
|
|
|
|
// update_by 0未删除 1已删除
|
|
|
|
|
Invoice invoiceValidateTemp = new Invoice(); |
|
|
|
|
List<Invoice> invoicesValidate = invoiceMapper.selectByOutTradeOrdernoList(companyservice.getCompanyid(), outNO, "0"); |
|
|
|
|
// 这里去直接跳出,更新推送关系表去重新推送一下看看。
|
|
|
|
|
if (CollectionUtils.isEmpty(invoicesValidate)) { |
|
|
|
|
|
|
|
|
|
// 开票回调失败防重复处理 start
|
|
|
|
|
if (!CollectionUtils.isEmpty(invoicesValidate)) { |
|
|
|
|
for (Invoice invoice : invoicesValidate) { |
|
|
|
|
QueryWrapper<InvoiceBack> invoiceBackQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
invoiceBackQueryWrapper.eq("system_orderno", invoice.getOutTradeOrderno()); |
|
|
|
|
List<InvoiceBack> invoiceBackList = invoiceBackMapper.selectList(invoiceBackQueryWrapper); |
|
|
|
|
|
|
|
|
|
for (InvoiceBack invoiceBack : invoiceBackList) { |
|
|
|
|
if ("0000".equals(invoiceBack.getResultCode())) { |
|
|
|
|
invoiceBack.setStatus("0"); |
|
|
|
|
invoiceBackMapper.updateInvoiceBack(invoiceBack); |
|
|
|
|
log.error("【销项】【总部控制台发票】开票接口,重复订单启动推送,订单号={}", invoice.getOutTradeOrderno()); |
|
|
|
|
return new HXResponse("0000", "重复订单已推送!"); |
|
|
|
|
} |
|
|
|
|
InvoiceBack invoiceBackVali = invoiceBackMapper.selectOne(invoiceBackQueryWrapper); |
|
|
|
|
|
|
|
|
|
if(BeanUtil.isEmpty(invoiceBackVali)){ |
|
|
|
|
invoiceBackVali = new InvoiceBack(); |
|
|
|
|
invoiceBackVali.setSystemOrderno(invoice.getOutTradeOrderno()); |
|
|
|
|
invoiceBackVali.setCreateTime(new Date()); |
|
|
|
|
|
|
|
|
|
invoiceBackVali.setId(IdUtils.randomUUID()); |
|
|
|
|
invoiceBackVali.setIdentity(companyservice.getIdentity()); |
|
|
|
|
invoiceBackVali.setBackUrl(""); |
|
|
|
|
invoiceBackVali.setStatus("0"); |
|
|
|
|
invoiceBackVali.setCreateTime(new Date()); |
|
|
|
|
invoiceBackVali.setSystemOrderno(invoice.getOutTradeOrderno()); |
|
|
|
|
invoiceBackVali.setBackMsg(""); |
|
|
|
|
invoiceBackVali.setResultCode("0000"); |
|
|
|
|
invoiceBackVali.setResultMsg("开票成功!"); |
|
|
|
|
invoiceBackVali.setUpdateTime(new Date()); |
|
|
|
|
invoiceBackMapper.insertInvoiceBack(invoiceBackVali); |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
invoiceBackVali.setResultCode("0000"); |
|
|
|
|
invoiceBackVali.setResultMsg("开票成功!"); |
|
|
|
|
invoiceBackVali.setStatus("0"); |
|
|
|
|
invoiceBackVali.setUpdateTime(new Date()); |
|
|
|
|
invoiceBackMapper.updateInvoiceBack(invoiceBackVali); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 再次推送
|
|
|
|
|
try { |
|
|
|
|
callBackAisino(invoiceBackVali, "", companyservice.getIdentity(),invoice.getId()); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.info("【重汽批量开票】发票回调失败!invoiceId={}", invoice.getId()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return new HXResponse("0000", "重复订单已推送!"); |
|
|
|
|
} |
|
|
|
|
// end
|
|
|
|
|
|
|
|
|
@ -178,12 +202,12 @@ public class AisinoConsoleInvoiceApiZhongQiServiceImpl implements IInvoiceApiSer |
|
|
|
|
|
|
|
|
|
// 销方地址电话
|
|
|
|
|
// 2022/12/21 中举说浪潮的地址和电话都放到 sellerAddress字段里了
|
|
|
|
|
*//*String sellerAddress = billInfo.getSellerAddress();
|
|
|
|
|
/*String sellerAddress = billInfo.getSellerAddress(); |
|
|
|
|
String sellerTelephone = billInfo.getSellerTelephone(); |
|
|
|
|
if (StrUtil.isEmpty(sellerAddress) || StrUtil.isEmpty(sellerTelephone)) { |
|
|
|
|
return new HXResponse("销方地址电话不存在!"); |
|
|
|
|
} |
|
|
|
|
aisinoConsoleInvoiceAddDTO.setSellerAddressTel(sellerAddress + sellerTelephone);*//*
|
|
|
|
|
aisinoConsoleInvoiceAddDTO.setSellerAddressTel(sellerAddress + sellerTelephone);*/ |
|
|
|
|
String sellerAddress = billInfo.getSellerAddress(); |
|
|
|
|
if (StrUtil.isEmpty(sellerAddress)) { |
|
|
|
|
return new HXResponse("销方地址电话不存在!"); |
|
|
|
@ -381,7 +405,7 @@ public class AisinoConsoleInvoiceApiZhongQiServiceImpl implements IInvoiceApiSer |
|
|
|
|
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())) { |
|
|
|
@ -399,24 +423,30 @@ public class AisinoConsoleInvoiceApiZhongQiServiceImpl implements IInvoiceApiSer |
|
|
|
|
queryInvoiceBack.setCreateTime(new Date()); |
|
|
|
|
queryInvoiceBack.setSystemOrderno(billInfo.getOutTradeOrderno()); |
|
|
|
|
queryInvoiceBack.setBackMsg(""); |
|
|
|
|
queryInvoiceBack.setResultCode("0000"); |
|
|
|
|
queryInvoiceBack.setResultMsg("开票成功!"); |
|
|
|
|
queryInvoiceBack.setUpdateTime(new Date()); |
|
|
|
|
invoiceBackMapper.insertInvoiceBack(queryInvoiceBack); |
|
|
|
|
} else { |
|
|
|
|
queryInvoiceBack = invoiceBackList.get(0); |
|
|
|
|
queryInvoiceBack.setResultCode("0000"); |
|
|
|
|
queryInvoiceBack.setResultMsg("开票成功!"); |
|
|
|
|
queryInvoiceBack.setUpdateTime(new Date()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 回调,失败的交给定时任务
|
|
|
|
|
InvoiceBack finalQueryInvoiceBack = queryInvoiceBack; |
|
|
|
|
try { |
|
|
|
|
callBackAisino(finalQueryInvoiceBack, callBackUrl, invoice.getId()); |
|
|
|
|
callBackAisino(finalQueryInvoiceBack, callBackUrl, "",invoice.getId()); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.info("【重汽批量开票】发票回调失败!invoiceId={}", invoice.getId()); |
|
|
|
|
} |
|
|
|
|
*//*AsyncManager.me().execute(new TimerTask() {
|
|
|
|
|
/*AsyncManager.me().execute(new TimerTask() { |
|
|
|
|
@Override |
|
|
|
|
public void run() { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
});*//*
|
|
|
|
|
});*/ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HXResponse response = new HXResponse("0000", "同步成功"); |
|
|
|
@ -424,7 +454,7 @@ public class AisinoConsoleInvoiceApiZhongQiServiceImpl implements IInvoiceApiSer |
|
|
|
|
return response; |
|
|
|
|
} else { |
|
|
|
|
return new HXResponse(retmsg); |
|
|
|
|
}*/ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -435,7 +465,7 @@ public class AisinoConsoleInvoiceApiZhongQiServiceImpl implements IInvoiceApiSer |
|
|
|
|
* @param id |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void callBackAisino(InvoiceBack invoiceBack, String callBackUrl, Long id) { |
|
|
|
|
public void callBackAisino(InvoiceBack invoiceBack, String callBackUrl, String identity,Long id) { |
|
|
|
|
|
|
|
|
|
// TODO: 2023/10/27 回调处理
|
|
|
|
|
|
|
|
|
@ -447,7 +477,7 @@ public class AisinoConsoleInvoiceApiZhongQiServiceImpl implements IInvoiceApiSer |
|
|
|
|
// 回调地址获取
|
|
|
|
|
if (StrUtil.isEmpty(callBackUrl)) { |
|
|
|
|
ICompanyservicePropService companyserviceProp = SpringUtils.getBean(ICompanyservicePropService.class); |
|
|
|
|
CompanyserviceProp secretIdProp = companyserviceProp.selectPropByKey(id, "aisino_callback_url"); |
|
|
|
|
CompanyserviceProp secretIdProp = companyserviceProp.selectPropByKey(Long.valueOf(identity), "aisino_callback_url"); |
|
|
|
|
if (BeanUtil.isNotEmpty(secretIdProp) && secretIdProp.getValue() != null && !"".equals(secretIdProp.getValue())) { |
|
|
|
|
callBackUrl = secretIdProp.getValue(); |
|
|
|
|
} |
|
|
|
@ -480,13 +510,16 @@ public class AisinoConsoleInvoiceApiZhongQiServiceImpl implements IInvoiceApiSer |
|
|
|
|
if ("0000".equals(status)) { |
|
|
|
|
invoiceBack.setStatus("1"); |
|
|
|
|
invoiceBack.setBackMsg(message); |
|
|
|
|
invoiceBack.setUpdateTime(new Date()); |
|
|
|
|
invoiceBackMapper.updateInvoiceBack(invoiceBack); |
|
|
|
|
} else if ("9999".equals(status)) { |
|
|
|
|
invoiceBack.setStatus("3"); |
|
|
|
|
invoiceBack.setBackMsg(message); |
|
|
|
|
invoiceBack.setUpdateTime(new Date()); |
|
|
|
|
invoiceBackMapper.updateInvoiceBack(invoiceBack); |
|
|
|
|
} else { |
|
|
|
|
invoiceBack.setStatus("2"); |
|
|
|
|
invoiceBack.setUpdateTime(new Date()); |
|
|
|
|
invoiceBack.setBackMsg(status + message); |
|
|
|
|
invoiceBackMapper.updateInvoiceBack(invoiceBack); |
|
|
|
|
} |
|
|
|
|