|
|
@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.dxhy.common.constant.DbConstant; |
|
|
|
import com.dxhy.common.constant.DbConstant; |
|
|
|
import com.dxhy.common.datasource.config.DynamicContextHolder; |
|
|
|
import com.dxhy.common.datasource.config.DynamicContextHolder; |
|
|
|
|
|
|
|
import com.dxhy.common.enums.SNFplxEnum; |
|
|
|
import com.dxhy.common.util.InvoiceUtil; |
|
|
|
import com.dxhy.common.util.InvoiceUtil; |
|
|
|
import com.dxhy.common.vo.UserInfo; |
|
|
|
import com.dxhy.common.vo.UserInfo; |
|
|
|
import com.dxhy.erp.dao.AreaDao; |
|
|
|
import com.dxhy.erp.dao.AreaDao; |
|
|
@ -16,6 +17,7 @@ import com.dxhy.erp.dao.BaseTDxTaxCurrentDao; |
|
|
|
import com.dxhy.erp.dao.OrgUserInfoDao; |
|
|
|
import com.dxhy.erp.dao.OrgUserInfoDao; |
|
|
|
import com.dxhy.erp.entity.BaseTDxRecordInvoice; |
|
|
|
import com.dxhy.erp.entity.BaseTDxRecordInvoice; |
|
|
|
import com.dxhy.erp.entity.BaseTDxTaxCurrent; |
|
|
|
import com.dxhy.erp.entity.BaseTDxTaxCurrent; |
|
|
|
|
|
|
|
import com.dxhy.erp.entity.TDxInvoiceReimburse; |
|
|
|
import com.dxhy.erp.entity.TdxCheckRecordInvoice; |
|
|
|
import com.dxhy.erp.entity.TdxCheckRecordInvoice; |
|
|
|
import com.dxhy.erp.entity.kfpt.ApiCheckInvoiceSingleRequest; |
|
|
|
import com.dxhy.erp.entity.kfpt.ApiCheckInvoiceSingleRequest; |
|
|
|
import com.dxhy.erp.entity.kfpt.ApiRequest; |
|
|
|
import com.dxhy.erp.entity.kfpt.ApiRequest; |
|
|
@ -35,6 +37,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
@ -95,6 +98,9 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private BaseTDxRecordInvoiceDao baseTDxRecordInvoiceDao; |
|
|
|
private BaseTDxRecordInvoiceDao baseTDxRecordInvoiceDao; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private TDxInvoiceReimburseService tDxInvoiceReimburseService; |
|
|
|
|
|
|
|
|
|
|
|
public String pushCheckResultToSAP(String requestParam) throws Exception { |
|
|
|
public String pushCheckResultToSAP(String requestParam) throws Exception { |
|
|
|
log.info("获取请求参数:{} , 请求地址:{}", requestParam, snYxUrl); |
|
|
|
log.info("获取请求参数:{} , 请求地址:{}", requestParam, snYxUrl); |
|
|
|
String post = HttpUtils.sendPo(snYxUrl, requestParam, userName, password); |
|
|
|
String post = HttpUtils.sendPo(snYxUrl, requestParam, userName, password); |
|
|
@ -121,7 +127,13 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
String fphm = snInvoice.getInvoiceNumber(); |
|
|
|
String fphm = snInvoice.getInvoiceNumber(); |
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper<BaseTDxRecordInvoice> recordWrapper = new QueryWrapper<>(); |
|
|
|
QueryWrapper<BaseTDxRecordInvoice> recordWrapper = new QueryWrapper<>(); |
|
|
|
recordWrapper.eq("uuid", fpdm + fphm); |
|
|
|
String uuid = ""; |
|
|
|
|
|
|
|
if(StringUtils.isNoneBlank(fpdm)){ |
|
|
|
|
|
|
|
uuid = fpdm + fphm; |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
uuid = fpdm; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
recordWrapper.eq("uuid", uuid); |
|
|
|
|
|
|
|
|
|
|
|
BaseTDxRecordInvoice baseTDxRecordInvoice = baseTDxRecordInvoiceDao.selectOne(recordWrapper); |
|
|
|
BaseTDxRecordInvoice baseTDxRecordInvoice = baseTDxRecordInvoiceDao.selectOne(recordWrapper); |
|
|
|
|
|
|
|
|
|
|
@ -537,6 +549,200 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
return jsonObject; |
|
|
|
return jsonObject; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TDxInvoiceReimburse updateInvoicePoll(@RequestBody SNRequestObject snRequestObject, String company, String taxNo, TDxInvoiceReimburse reimburse, SNInvoice invoice, String fplxdm, String invoiceCode, String invoiceNo) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断发票类型
|
|
|
|
|
|
|
|
fplxdm = getFplx(invoice, fplxdm); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果是可价税分离的票种,直接入报销库
|
|
|
|
|
|
|
|
if(SNFplxEnum.HCP.getFplxDm().equals(fplxdm) || SNFplxEnum.KYQCP.getFplxDm().equals(fplxdm) |
|
|
|
|
|
|
|
|| SNFplxEnum.JPXCD.getFplxDm().equals(fplxdm) || SNFplxEnum.CP.getFplxDm().equals(fplxdm) |
|
|
|
|
|
|
|
|| SNFplxEnum.KYQCP.getFplxDm().equals(fplxdm)){ |
|
|
|
|
|
|
|
InvoiceInfo invoiceInfo = convertToInvoiceInfo(invoice); |
|
|
|
|
|
|
|
ServiceResult<InvoiceInfo> invoiceResult = this.valoremTaxCount(invoiceInfo, "Y"); |
|
|
|
|
|
|
|
InvoiceInfo data = invoiceResult.getData(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
invoice.setIsDeductible(data.getIsDeductible()); |
|
|
|
|
|
|
|
invoice.setTaxRate(data.getTaxRate()); |
|
|
|
|
|
|
|
invoice.setTotalAmount(data.getInvoiceAmount().toString()); |
|
|
|
|
|
|
|
invoice.setTotalTax(data.getTaxAmount().toString()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reimburse = convertToReimburse(invoice,reimburse,fplxdm,company); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
|
|
|
int insert = 0; |
|
|
|
|
|
|
|
QueryWrapper wrapper = new QueryWrapper(); |
|
|
|
|
|
|
|
wrapper.eq("uuid",reimburse.getUuid()); |
|
|
|
|
|
|
|
TDxInvoiceReimburse reimburse1 = tDxInvoiceReimburseService.getBaseMapper().selectOne(wrapper); |
|
|
|
|
|
|
|
if(reimburse1 != null){ |
|
|
|
|
|
|
|
insert = tDxInvoiceReimburseService.getBaseMapper().updateById(reimburse1); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
insert = tDxInvoiceReimburseService.getBaseMapper().insert(reimburse); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(insert > 0){ |
|
|
|
|
|
|
|
log.info("实名客票插入报销库成功"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
//如果是可查验类型,直接更新数据库
|
|
|
|
|
|
|
|
InvoiceUtil iu = new InvoiceUtil(invoiceCode,invoiceNo); |
|
|
|
|
|
|
|
fplxdm = iu.getFplxdm(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(fplxdm != null) { |
|
|
|
|
|
|
|
//可查验发票,已入库,更新票池
|
|
|
|
|
|
|
|
Integer integer = this.pushInvoiceToRecordInvoice2(snRequestObject); |
|
|
|
|
|
|
|
log.info("可查验发票,更新票池完成"); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
//不可查验发票,未入库,插入票池
|
|
|
|
|
|
|
|
this.pushInvoiceToRecordInvoice(snRequestObject,taxNo,company); |
|
|
|
|
|
|
|
log.info("不可查验发票,更新票池完成"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return reimburse; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private TDxInvoiceReimburse convertToReimburse(SNInvoice invoice, TDxInvoiceReimburse reimburse,String fplxdm,String company) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reimburse.setInvoiceType(fplxdm); |
|
|
|
|
|
|
|
reimburse.setInvoiceCode(invoice.getInvoiceCode()); |
|
|
|
|
|
|
|
reimburse.setInvoiceNo(invoice.getInvoiceNumber()); |
|
|
|
|
|
|
|
reimburse.setInvoiceDate(invoice.getBillingDate()); |
|
|
|
|
|
|
|
reimburse.setPassenger(invoice.getRiderName()); |
|
|
|
|
|
|
|
if(invoice.getTotalAmount() != null) { |
|
|
|
|
|
|
|
reimburse.setInvoiceAmount(new BigDecimal(invoice.getTotalAmount())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(invoice.getAmountTax() != null) { |
|
|
|
|
|
|
|
reimburse.setTotalAmount(new BigDecimal(invoice.getAmountTax())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(invoice.getTotalTax() != null) { |
|
|
|
|
|
|
|
reimburse.setTaxAmount(new BigDecimal(invoice.getTotalTax())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reimburse.setInvoiceStatus(invoice.getState()); |
|
|
|
|
|
|
|
reimburse.setDepartureCity(invoice.getStationGetOn()); |
|
|
|
|
|
|
|
reimburse.setReachingCity(invoice.getStationGetOff()); |
|
|
|
|
|
|
|
reimburse.setTrainNumber(invoice.getTrainNumber()); |
|
|
|
|
|
|
|
reimburse.setPassengerSFZH(invoice.getIdcardNo()); |
|
|
|
|
|
|
|
reimburse.setXfName(invoice.getSalesName()); |
|
|
|
|
|
|
|
reimburse.setXfTaxNo(invoice.getSalesTaxNo()); |
|
|
|
|
|
|
|
reimburse.setXfAddressAndPhone(invoice.getSalesAddressPhone()); |
|
|
|
|
|
|
|
reimburse.setXfBankAndNo(invoice.getSalesBank()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reimburse.setGfTaxNo(invoice.getPurchaserTaxNo()); |
|
|
|
|
|
|
|
reimburse.setGfName(invoice.getPurchaserName()); |
|
|
|
|
|
|
|
reimburse.setGfAddressAndPhone(invoice.getPurchaserAddressPhone()); |
|
|
|
|
|
|
|
reimburse.setGfBankAndNo(invoice.getPurchaserBank()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reimburse.setTaxRate(invoice.getTaxRate()); |
|
|
|
|
|
|
|
reimburse.setIsDeduction(invoice.getIsDeductible()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(StringUtils.isNoneBlank(reimburse.getInvoiceCode())){ |
|
|
|
|
|
|
|
reimburse.setUuid(reimburse.getInvoiceCode() + reimburse.getInvoiceNo()); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
reimburse.setUuid(reimburse.getInvoiceNo()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Date date = new Date(); |
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
|
|
|
|
String format = sdf.format(date); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reimburse.setCreateDate(format); |
|
|
|
|
|
|
|
reimburse.setUpdateDate(date); |
|
|
|
|
|
|
|
reimburse.setCheckCode(invoice.getCheckCode()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reimburse.setFare(invoice.getNoTaxAmount()); |
|
|
|
|
|
|
|
reimburse.setFuelSurcharge(invoice.getFuelSurcharge()); |
|
|
|
|
|
|
|
reimburse.setCompany(company); |
|
|
|
|
|
|
|
reimburse.setPostingTime(format); |
|
|
|
|
|
|
|
reimburse.setAccountPeriod(""); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return reimburse; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private InvoiceInfo convertToInvoiceInfo(SNInvoice snInvoice) { |
|
|
|
|
|
|
|
InvoiceInfo invoice = new InvoiceInfo(); |
|
|
|
|
|
|
|
invoice.setInvoiceTypeCode(snInvoice.getInvoiceType()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date date = new Date(); |
|
|
|
|
|
|
|
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
date = ft.parse(snInvoice.getBillingDate()); |
|
|
|
|
|
|
|
} catch (ParseException e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
invoice.setInvoiceDate(date); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
invoice.setIdentityNumber(snInvoice.getIdcardNo()); |
|
|
|
|
|
|
|
invoice.setPassenger(snInvoice.getRiderName()); |
|
|
|
|
|
|
|
invoice.setDepartCity(snInvoice.getStationGetOn()); |
|
|
|
|
|
|
|
invoice.setArriveCity(snInvoice.getStationGetOff()); |
|
|
|
|
|
|
|
if("92".equals(invoice.getInvoiceTypeCode())){ |
|
|
|
|
|
|
|
if(snInvoice.getAmountTax() != null) |
|
|
|
|
|
|
|
invoice.setInvoiceAmount(new BigDecimal(snInvoice.getAmountTax())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if("90".equals(invoice.getInvoiceTypeCode())) { |
|
|
|
|
|
|
|
invoice.setFare(snInvoice.getNoTaxAmount()); |
|
|
|
|
|
|
|
invoice.setFuelSurcharge(snInvoice.getFuelSurcharge()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(snInvoice.getNoTaxAmount() != null){ |
|
|
|
|
|
|
|
BigDecimal amount = new BigDecimal(snInvoice.getNoTaxAmount()); |
|
|
|
|
|
|
|
invoice.setInvoiceAmount(amount); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return invoice; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getFplx(SNInvoice invoice, String fplxdm) { |
|
|
|
|
|
|
|
String snFplx = invoice.getInvoiceType(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(SNFplxEnum.HCP.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
|
|
|
fplxdm = "92"; |
|
|
|
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(SNFplxEnum.KYQCP.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
|
|
|
fplxdm = "94"; |
|
|
|
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(SNFplxEnum.JPXCD.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
|
|
|
fplxdm = "90"; |
|
|
|
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(SNFplxEnum.DEFP.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
|
|
|
fplxdm = "95"; |
|
|
|
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(SNFplxEnum.JDFP.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
|
|
|
fplxdm = "97"; |
|
|
|
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(SNFplxEnum.CZCFP.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
|
|
|
fplxdm = "91"; |
|
|
|
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(SNFplxEnum.KYQCP.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
|
|
|
fplxdm = "89"; |
|
|
|
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(SNFplxEnum.GLF.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
|
|
|
fplxdm = "101"; |
|
|
|
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(SNFplxEnum.CP.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
|
|
|
fplxdm = "88"; |
|
|
|
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(SNFplxEnum.GJXP.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
|
|
|
fplxdm = "99"; |
|
|
|
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(SNFplxEnum.QTFP.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
|
|
|
fplxdm = "00"; |
|
|
|
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return fplxdm; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 客票价税计算 |
|
|
|
* 客票价税计算 |
|
|
|