|
|
|
@ -1,36 +1,33 @@ |
|
|
|
|
package com.jianshui.invoice.service.impl.api; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
|
import cn.hutool.core.convert.Convert; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.jianshui.common.constant.WebServiceConstant; |
|
|
|
|
import com.jianshui.common.core.domain.AjaxResult; |
|
|
|
|
import com.jianshui.common.core.domain.entity.Companyservice; |
|
|
|
|
import com.jianshui.common.enums.ErrorCode; |
|
|
|
|
import com.jianshui.common.exception.jianshui.JianshuiParamErrorException; |
|
|
|
|
import com.jianshui.common.exception.jianshui.JianshuiServiceException; |
|
|
|
|
import com.jianshui.common.utils.BeanToMapUtils; |
|
|
|
|
import com.jianshui.common.utils.StringUtils; |
|
|
|
|
import com.jianshui.common.utils.TimeUtil; |
|
|
|
|
import com.jianshui.common.utils.ValidateUtils; |
|
|
|
|
import com.jianshui.common.utils.jcsk.ApiHttp; |
|
|
|
|
import com.jianshui.common.utils.uuid.IdUtils; |
|
|
|
|
import com.jianshui.framework.manager.AsyncManager; |
|
|
|
|
import com.jianshui.invoice.constant.aisino.console.AisinoConsoleConstants; |
|
|
|
|
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.vo.api.aisino.console.AisinoConsoleInvoiceAddVO; |
|
|
|
|
import com.jianshui.invoice.mapper.BillInfoMapper; |
|
|
|
|
import com.jianshui.invoice.mapper.InvoiceMapper; |
|
|
|
|
import com.jianshui.invoice.mapper.RedinfoMapper; |
|
|
|
|
import com.jianshui.invoice.mapper.SkDyjMapper; |
|
|
|
|
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.mapper.*; |
|
|
|
|
import com.jianshui.invoice.service.IInvoiceApiService; |
|
|
|
|
import com.jianshui.invoice.utils.BillInfoUtils; |
|
|
|
|
import com.jianshui.invoice.utils.aisino.console.AisinoConsoleUtil; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
@ -58,6 +55,8 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
private RedinfoMapper redinfoMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 发票开具 |
|
|
|
|
* |
|
|
|
@ -70,234 +69,93 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
@Override |
|
|
|
|
public HXResponse addInvoice(BillInfo billInfo, Companyservice companyservice) throws IllegalAccessException, InstantiationException { |
|
|
|
|
|
|
|
|
|
// 预处理:处理billinfo,计算税额等
|
|
|
|
|
try { |
|
|
|
|
billInfo = BillInfoUtils.processBillInfo(billInfo, companyservice); |
|
|
|
|
} catch (JianshuiParamErrorException e) { |
|
|
|
|
return new HXResponse(e.getMessage()); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("【销项】【总部控制台发票】开票接口校验异常", e); |
|
|
|
|
return new HXResponse("格式校验失败,请检查报文!"); |
|
|
|
|
} |
|
|
|
|
// 请求billInfo
|
|
|
|
|
Long billInfoID = 0L; |
|
|
|
|
|
|
|
|
|
// 发票类型处理 必填
|
|
|
|
|
Integer invoceTypeTemp = CovertInvoiceType(billInfo.getInvoiceType()); |
|
|
|
|
if (invoceTypeTemp == -1) { |
|
|
|
|
return new HXResponse("发票类型不存在!"); |
|
|
|
|
} |
|
|
|
|
// 开票实体转换,校验
|
|
|
|
|
InvoiceAllAddTwoDTO invoiceAllAddTwoDTO = BeanUtil.copyProperties(billInfo, InvoiceAllAddTwoDTO.class); |
|
|
|
|
ValidateUtils.validate(invoiceAllAddTwoDTO); |
|
|
|
|
|
|
|
|
|
billInfo.setInvoiceType(String.valueOf(invoceTypeTemp)); |
|
|
|
|
InvoiceAllAddInfoTwoDTO invoiceAllAddInfoTwoDTO = BeanUtil.copyProperties(billInfo, InvoiceAllAddInfoTwoDTO.class); |
|
|
|
|
ValidateUtils.validate(invoiceAllAddInfoTwoDTO); |
|
|
|
|
|
|
|
|
|
// 转换报文为总部控制台请求报文
|
|
|
|
|
AisinoConsoleInvoiceAddDTO aisinoConsoleInvoiceAddDTO = BeanUtil.copyProperties(billInfo, AisinoConsoleInvoiceAddDTO.class); |
|
|
|
|
|
|
|
|
|
List<BillDetail> billDetailList = billInfo.getBillDetailList(); |
|
|
|
|
if (CollectionUtils.isEmpty(billDetailList)) { |
|
|
|
|
return new HXResponse("发票明细不存在,请检查报文!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
aisinoConsoleInvoiceAddDTO.setInvoiceType(invoceTypeTemp); |
|
|
|
|
|
|
|
|
|
//购方地址电话
|
|
|
|
|
String buyerAddress = billInfo.getBuyerAddress(); |
|
|
|
|
String buyerTelPhone = billInfo.getBuyerTelephone(); |
|
|
|
|
aisinoConsoleInvoiceAddDTO.setCustomerAddressTel(buyerAddress + buyerTelPhone); |
|
|
|
|
|
|
|
|
|
//购方银行账户
|
|
|
|
|
String buyerBank = billInfo.getBuyerBank(); |
|
|
|
|
String buyerAccount = billInfo.getBuyerAccount(); |
|
|
|
|
aisinoConsoleInvoiceAddDTO.setCustomerBankAccountNr(buyerBank + buyerAccount); |
|
|
|
|
|
|
|
|
|
//销方银行账户
|
|
|
|
|
String sellerBank = billInfo.getSellerBank(); |
|
|
|
|
String sellerAccount = billInfo.getSellerAccount(); |
|
|
|
|
if (StrUtil.isEmpty(sellerBank) || StrUtil.isEmpty(sellerAccount)) { |
|
|
|
|
return new HXResponse("销方银行账户不存在!"); |
|
|
|
|
} |
|
|
|
|
aisinoConsoleInvoiceAddDTO.setSellerBankAccountNr(sellerBank + sellerAccount); |
|
|
|
|
|
|
|
|
|
// 销方地址电话
|
|
|
|
|
// 2022/12/21 中举说浪潮的地址和电话都放到 sellerAddress字段里了
|
|
|
|
|
/*String sellerAddress = billInfo.getSellerAddress(); |
|
|
|
|
String sellerTelephone = billInfo.getSellerTelephone(); |
|
|
|
|
if (StrUtil.isEmpty(sellerAddress) || StrUtil.isEmpty(sellerTelephone)) { |
|
|
|
|
return new HXResponse("销方地址电话不存在!"); |
|
|
|
|
} |
|
|
|
|
aisinoConsoleInvoiceAddDTO.setSellerAddressTel(sellerAddress + sellerTelephone);*/ |
|
|
|
|
String sellerAddress = billInfo.getSellerAddress(); |
|
|
|
|
if (StrUtil.isEmpty(sellerAddress)) { |
|
|
|
|
return new HXResponse("销方地址电话不存在!"); |
|
|
|
|
// 明细集合
|
|
|
|
|
List<InvoiceAllAddmxListTwoDTO> mxList = BeanUtil.copyToList(billInfo.getBillDetailList(), InvoiceAllAddmxListTwoDTO.class); |
|
|
|
|
if (CollectionUtils.isEmpty(mxList)) { |
|
|
|
|
return new HXResponse("mxList明细集合不存在!"); |
|
|
|
|
} |
|
|
|
|
aisinoConsoleInvoiceAddDTO.setSellerAddressTel(sellerAddress); |
|
|
|
|
|
|
|
|
|
//清单标志
|
|
|
|
|
String qdbz = billInfo.getQdbz(); |
|
|
|
|
if (StrUtil.isEmpty(qdbz)) { |
|
|
|
|
return new HXResponse("清单标志不存在!"); |
|
|
|
|
for (InvoiceAllAddmxListTwoDTO addmxListDTO : mxList) { |
|
|
|
|
ValidateUtils.validate(addmxListDTO); |
|
|
|
|
} |
|
|
|
|
boolean qdbzTemp = qdbz.equals("1") ? true : false; |
|
|
|
|
aisinoConsoleInvoiceAddDTO.setListed(qdbzTemp); |
|
|
|
|
|
|
|
|
|
// 销售单号 非必填
|
|
|
|
|
//aisinoConsoleInvoiceAddDTO.setDocumentNr("");
|
|
|
|
|
// 开票校验标识 问了下主任这里默认塞 0 标识开票
|
|
|
|
|
aisinoConsoleInvoiceAddDTO.setCheckEWM(0); |
|
|
|
|
|
|
|
|
|
//税额
|
|
|
|
|
BigDecimal tax = billInfo.getTax(); |
|
|
|
|
aisinoConsoleInvoiceAddDTO.setTax(Convert.toDouble(tax)); |
|
|
|
|
|
|
|
|
|
//数量 非必填
|
|
|
|
|
//aisinoConsoleInvoiceAddDTO.setQuantity(0.0D);
|
|
|
|
|
|
|
|
|
|
//专票必填
|
|
|
|
|
if (invoceTypeTemp == 0) { |
|
|
|
|
if (StrUtil.isEmpty(aisinoConsoleInvoiceAddDTO.getCustomerTaxNr())) { |
|
|
|
|
return new HXResponse("购方税号不存在,专票!"); |
|
|
|
|
} |
|
|
|
|
if (StrUtil.isEmpty(aisinoConsoleInvoiceAddDTO.getCustomerAddressTel())) { |
|
|
|
|
return new HXResponse("购方地址电话不存在,专票!"); |
|
|
|
|
} |
|
|
|
|
if (StrUtil.isEmpty(aisinoConsoleInvoiceAddDTO.getCustomerBankAccountNr())) { |
|
|
|
|
return new HXResponse("购方银行账户不存在,专票!"); |
|
|
|
|
// 2022/12/12 现在只是倒下手,那么就是只存一下就行,返回的也是存。不用转回去。
|
|
|
|
|
// 报文转换存储
|
|
|
|
|
billInfo.setCompanyId(companyservice.getCompanyid()); |
|
|
|
|
billInfo.setServiceSupplierKey("JCSK"); |
|
|
|
|
try { |
|
|
|
|
int resBillInfo = billInfoMapper.insertBillInfo(billInfo); |
|
|
|
|
if (resBillInfo > 0) { |
|
|
|
|
billInfoID = billInfo.getId(); |
|
|
|
|
if (BeanUtil.isEmpty(billInfo.getId())) { |
|
|
|
|
log.error("【金四服务类】【金财数科】【蓝字发票开具】API请求异常,billInfoId返回存储错误。"); |
|
|
|
|
return new HXResponse(ErrorCode.INCOME_ERROR.toString()); |
|
|
|
|
} |
|
|
|
|
//数据库存储
|
|
|
|
|
List<BillDetail> billDetailList = billInfo.getBillDetailList(); |
|
|
|
|
int billDetailResult = billInfoMapper.batchBillDetail(billDetailList); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
log.error("【金四服务类】【金财数科】【蓝字发票开具】API请求异常,billInfo存储错误。错误信息:{}", e.getMessage()); |
|
|
|
|
return new HXResponse(ErrorCode.INCOME_ERROR.toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//处理备注
|
|
|
|
|
String kpType = billInfo.getKptype() == null ? "":billInfo.getKptype() ; |
|
|
|
|
String redInvoiceCode = billInfo.getRedInvoiceInfoCode() == null ? "":billInfo.getRedInvoiceInfoCode(); |
|
|
|
|
if("2".equals(kpType) && invoceTypeTemp == 0){ |
|
|
|
|
//专票:红字信息表编号 开具红字发票:备注中注明“开具红字增值税专用发票信息表编号 XXXXXXXXXXXXXXXX”
|
|
|
|
|
aisinoConsoleInvoiceAddDTO.setMemo("开具红字增值税专用发票信息表编号"+redInvoiceCode); |
|
|
|
|
}else if("2".equals(kpType) && invoceTypeTemp == 2){ |
|
|
|
|
//普票:开具负数发票(普通发票负数发票):备注中注明“对应正数发票代码 XXXXXXXXXX 号 码 YYYYYYYY”字样,其中“X”为发票左上角 10 或是 12 位代码数字,“Y”为发票右上角 8位号码数字
|
|
|
|
|
aisinoConsoleInvoiceAddDTO.setMemo("对应正数发票代码"+billInfo.getOriginFpdm()+"号码"+billInfo.getOriginFphm()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//明细处理前条件校验
|
|
|
|
|
ValidateUtils.validate(aisinoConsoleInvoiceAddDTO, companyservice, null); |
|
|
|
|
|
|
|
|
|
//发票明细处理
|
|
|
|
|
List<AisinoConsoleInvoiceAddDetailDTO> invoiceItems = new ArrayList<>(); |
|
|
|
|
List<Map<String,Object>> listMap = new ArrayList<>(); |
|
|
|
|
for (BillDetail billDetail : billDetailList) { |
|
|
|
|
AisinoConsoleInvoiceAddDetailDTO addDetailDTO = BeanUtil.copyProperties(billDetail, AisinoConsoleInvoiceAddDetailDTO.class); |
|
|
|
|
cn.hutool.json.JSONObject result = null; |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
//通过含税标志,区分含税单价不含税单价
|
|
|
|
|
Integer hsbz = billDetail.getHsbz(); |
|
|
|
|
if (hsbz == null) { |
|
|
|
|
return new HXResponse("含税标志不存在!"); |
|
|
|
|
} |
|
|
|
|
addDetailDTO.setIncludeTax(hsbz == 1 ? true : false); |
|
|
|
|
//税率
|
|
|
|
|
addDetailDTO.setTaxRate(Convert.toDouble(billDetail.getTaxrate())); |
|
|
|
|
//金额
|
|
|
|
|
Double je = 0D; |
|
|
|
|
if (hsbz == 1) { |
|
|
|
|
je = Convert.toDouble(billDetail.getTaxamt()); |
|
|
|
|
} else if (hsbz == 0) { |
|
|
|
|
je = Convert.toDouble(billDetail.getTaxfreeamt()); |
|
|
|
|
result = ApiHttp.request(WebServiceConstant.LZFPKJ, WebServiceConstant.URL, invoiceAllAddTwoDTO, companyservice); |
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
BillInfo billInfoRes = billInfoMapper.selectBillInfoById(billInfoID); |
|
|
|
|
billInfoRes.setOriginSystemOrderno(requestId); |
|
|
|
|
billInfoMapper.updateBillInfo(billInfoRes); |
|
|
|
|
|
|
|
|
|
// 保存日志
|
|
|
|
|
/*InvoiceAllApiLog allApiLog = new InvoiceAllApiLog(); |
|
|
|
|
allApiLog.setUrl(WebServiceConstant.LZFPKJ); |
|
|
|
|
allApiLog.setSendMsg(""); |
|
|
|
|
allApiLog.setResultMsg(""); |
|
|
|
|
allApiLog.setCompany(companyservice.getSellertax()); |
|
|
|
|
allApiLog.setIdentityId(companyservice.getIdentity()); |
|
|
|
|
allApiLog.setRequestId(requestId); |
|
|
|
|
allApiLog.setCreateTime(new Date()); |
|
|
|
|
AsyncManager.me().execute( |
|
|
|
|
new TimerTask() { |
|
|
|
|
@Override |
|
|
|
|
public void run() { |
|
|
|
|
allApiLogMapper.insertInvoiceAllApiLog(allApiLog); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
);*/ |
|
|
|
|
|
|
|
|
|
return new HXResponse("0000",json); |
|
|
|
|
} else { |
|
|
|
|
return new HXResponse("金额不存在!"); |
|
|
|
|
return new HXResponse(msg); |
|
|
|
|
} |
|
|
|
|
addDetailDTO.setValue(je); |
|
|
|
|
//单价
|
|
|
|
|
addDetailDTO.setPrice(Convert.toDouble(billDetail.getPrice())); |
|
|
|
|
|
|
|
|
|
//是否享受优惠政策
|
|
|
|
|
Integer yhzcbs = billDetail.getYhzcbs(); |
|
|
|
|
if (yhzcbs == null) { |
|
|
|
|
return new HXResponse("优惠政策标识不存在!"); |
|
|
|
|
} |
|
|
|
|
addDetailDTO.setTaxPre(String.valueOf(yhzcbs)); |
|
|
|
|
//享受优惠政策内容 非必填
|
|
|
|
|
//addDetailDTO.setTaxPreCon("");
|
|
|
|
|
//企业自编码 非必填
|
|
|
|
|
//addDetailDTO.setCropGoodsNo("");
|
|
|
|
|
|
|
|
|
|
ValidateUtils.validate(addDetailDTO, companyservice, null); |
|
|
|
|
invoiceItems.add(addDetailDTO); |
|
|
|
|
Map<String,Object> mapDetail = BeanToMapUtils.fastJsonBean2Map(addDetailDTO); |
|
|
|
|
listMap.add(mapDetail); |
|
|
|
|
} |
|
|
|
|
aisinoConsoleInvoiceAddDTO.setInvoiceItems(invoiceItems); |
|
|
|
|
|
|
|
|
|
// 发起请求
|
|
|
|
|
AjaxResult ajaxResult = null; |
|
|
|
|
try { |
|
|
|
|
//hutool的beancopy别名会与JSONUTIl冲突
|
|
|
|
|
Map<String,Object> map = BeanToMapUtils.fastJsonBean2Map(aisinoConsoleInvoiceAddDTO); |
|
|
|
|
map.put("invoiceItems",listMap); |
|
|
|
|
ajaxResult = AisinoConsoleUtil.sendRequest(AisinoConsoleConstants.INVOICE_ADD, JSONUtil.parse(map), companyservice); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("【销项发票】【总部控制台接口】【发票开具】发票请求异常,请求报文{},销方信息{}", JSONUtil.parse(aisinoConsoleInvoiceAddDTO).toString(), JSONObject.toJSONString(companyservice)); |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
throw new JianshuiServiceException("系统异常!"); |
|
|
|
|
} |
|
|
|
|
log.info("【销项发票】【总部控制台发票】发票开具请求拉取结果{}", ajaxResult.toString()); |
|
|
|
|
|
|
|
|
|
//返回报文解析
|
|
|
|
|
if (ajaxResult.isError()) { |
|
|
|
|
throw new JianshuiServiceException(ajaxResult.getMsg()); |
|
|
|
|
log.error("【金四服务类】【金财数科】【蓝字发票开具】API请求异常,外部报文返回code非0000。错误信息:{}", e.getMessage()); |
|
|
|
|
return new HXResponse(ErrorCode.INCOME_ERROR.toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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 ("4011".equals(retcode)) { |
|
|
|
|
//回写发票代码、发票号码信息
|
|
|
|
|
if(StrUtil.isEmpty(retmsg)){ |
|
|
|
|
return new HXResponse(retcode); |
|
|
|
|
} |
|
|
|
|
AisinoConsoleInvoiceAddVO aisinoConsoleInvoiceAddVO = BeanUtil.copyProperties(resultJSON, AisinoConsoleInvoiceAddVO.class); |
|
|
|
|
if(StrUtil.isEmpty(aisinoConsoleInvoiceAddVO.getInfoNumber())){ |
|
|
|
|
throw new JianshuiServiceException("开具的发票号码不存在!"); |
|
|
|
|
} |
|
|
|
|
//更新发票状态
|
|
|
|
|
billInfo.setState(2); |
|
|
|
|
billInfoMapper.updateBillInfo(billInfo); |
|
|
|
|
|
|
|
|
|
//插入invoice
|
|
|
|
|
Invoice invoice = BeanUtil.copyProperties(billInfo,Invoice.class); |
|
|
|
|
List<InvoiceDetail> invoiceDetailList = BeanUtil.copyToList(billInfo.getBillDetailList(),InvoiceDetail.class); |
|
|
|
|
invoice.setInvoiceDetailList(invoiceDetailList); |
|
|
|
|
|
|
|
|
|
//发票代码
|
|
|
|
|
invoice.setFpdm(aisinoConsoleInvoiceAddVO.getInfoTypeCode()); |
|
|
|
|
//发票号码
|
|
|
|
|
invoice.setFphm(aisinoConsoleInvoiceAddVO.getInfoNumber()); |
|
|
|
|
//上一张发票代码
|
|
|
|
|
invoice.setOriginFpdm(aisinoConsoleInvoiceAddVO.getHisInfoTypeCode()); |
|
|
|
|
//上一张发票号码
|
|
|
|
|
invoice.setOriginFphm(aisinoConsoleInvoiceAddVO.getHisInfoNumber()); |
|
|
|
|
//上一张发票种类
|
|
|
|
|
String hisInvoceTypeTemp = CovertInvoiceTypeReverse(aisinoConsoleInvoiceAddVO.getHisInfoKind()); |
|
|
|
|
invoice.setInvoiceType(hisInvoceTypeTemp); |
|
|
|
|
invoice.setBillInfoId(billInfo.getId()); |
|
|
|
|
|
|
|
|
|
long id = 0L; |
|
|
|
|
QueryWrapper<Invoice> invoiceQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
invoiceQueryWrapper.eq("fpdm",invoice.getFpdm()).eq("fphm",invoice.getFphm()); |
|
|
|
|
List<Invoice> invoices = invoiceMapper.selectList(invoiceQueryWrapper); |
|
|
|
|
if(CollectionUtils.isEmpty(invoices)){ |
|
|
|
|
invoiceMapper.insertInvoice(invoice); |
|
|
|
|
invoices = invoiceMapper.selectList(invoiceQueryWrapper); |
|
|
|
|
id = invoices.get(0).getId(); |
|
|
|
|
}else{ |
|
|
|
|
Invoice invoiceT = invoices.get(0); |
|
|
|
|
invoiceT = BeanUtil.copyProperties(invoice,Invoice.class); |
|
|
|
|
invoiceMapper.updateInvoice(invoiceT); |
|
|
|
|
id = invoiceT.getId(); |
|
|
|
|
} |
|
|
|
|
invoiceDetailList.forEach(i -> i.setInvoiceId(invoice.getId())); |
|
|
|
|
invoiceMapper.batchInvoiceDetail(invoiceDetailList); |
|
|
|
|
|
|
|
|
|
HXResponse response = new HXResponse("0000", "同步成功"); |
|
|
|
|
response.put("fpqqlsh", billInfo.getSystemOrderno()); |
|
|
|
|
return response; |
|
|
|
|
} else { |
|
|
|
|
return new HXResponse(retmsg); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -713,4 +571,6 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
public Object decryptCallback(HttpServletRequest request) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|