|
@@ -881,4 +881,153 @@ public class NoCarServiceImpl implements NoCarService{
|
|
|
mounthAccMapper.insert(mounthAcc);
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取发票和运单状态 true 实时 false 走本地 自用,不对外
|
|
|
+ * @param noCarWayBill
|
|
|
+ * @param isInterface
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(isolation= Isolation.READ_COMMITTED)
|
|
|
+ public RespR getInvoiceByWayBillOwnerNumReal(NoCarWayBill noCarWayBill, boolean isInterface) {
|
|
|
+ byte isKf = 1;
|
|
|
+ /**
|
|
|
+ * 迁移数据
|
|
|
+ */
|
|
|
+ if(noCarWayBill.getInterType() == 3){
|
|
|
+ isKf = 3;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 特殊处理数据
|
|
|
+ */
|
|
|
+ if(noCarWayBill.getInterType() == 5){
|
|
|
+ isKf = 5;
|
|
|
+ }
|
|
|
+ log.info("取票啦:NoCarServiceImpl.getInvoiceByWayBillOwnerNumReal{},isCurr{}",noCarWayBill,isInterface);
|
|
|
+ if(isInterface && (noCarWayBill.getBillwayStatus()!=-5 || noCarWayBill.getInterType() == 4)){
|
|
|
+ if(noCarWayBill.getBillwayStatus() == 1 || noCarWayBill.getBillwayStatus() == 2 || noCarWayBill.getBillwayStatus() == 3 || noCarWayBill.getBillwayStatus() == 4){
|
|
|
+ //直接返回发票信息
|
|
|
+ List<BillInvoice> billInvoices = billInvoiceMapper.selectByBillNum(noCarWayBill.getBillNum());
|
|
|
+ WaybillNumFindInvoiceResponse waybillNumFindInvoiceResponse = buildInterFaceVoiceData(noCarWayBill,billInvoices);
|
|
|
+ return new RespR(waybillNumFindInvoiceResponse);
|
|
|
+ }else{
|
|
|
+ return new RespR(false,noCarWayBill.getFailReason()==null?"运单未知异常":noCarWayBill.getFailReason());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(noCarWayBill.getBillwayStatus()!=2 && noCarWayBill.getBillwayStatus()!=-5){
|
|
|
+ return new RespR(false,"不是开票中的状态,别取票啦");
|
|
|
+ }
|
|
|
+ // RespR respR = checkCarWayBillAndSetInfo(noCarWayBill);
|
|
|
+ // if(respR.getCode() == 1){
|
|
|
+ // log.info("取票失败啦:NoCarServiceImpl.getInvoiceByWayBillOwnerNumReal{},isCurr{},msg{}",noCarWayBill,isInterface,respR.getMsg());
|
|
|
+ // return respR;
|
|
|
+ // }
|
|
|
+
|
|
|
+ //进行取票操作
|
|
|
+ WaybillNumFindInvoiceRequest waybillNumFindInvoiceRequest = new WaybillNumFindInvoiceRequest();
|
|
|
+ String companyNum = paramService.getParamsByParamName("REQUEST_COMPANY_NUM").getParamValue();
|
|
|
+ waybillNumFindInvoiceRequest.setCompanyNum(companyNum);
|
|
|
+ waybillNumFindInvoiceRequest.setWaybillNum(noCarWayBill.getBillNum());
|
|
|
+ RespR<WaybillNumFindInvoiceResponse> responseRespR = noCarInterface.waybillNumFindInvoice(waybillNumFindInvoiceRequest);
|
|
|
+ if(responseRespR.getCode() == 1){
|
|
|
+ log.info("取票失败啦:NoCarServiceImpl.getInvoiceByWayBillOwnerNumReal{},isCurr{},msg{}",noCarWayBill,isInterface,responseRespR.getMsg());
|
|
|
+ return new RespR(false,responseRespR.getMsg());
|
|
|
+ }else{
|
|
|
+ int tempStatus = responseRespR.getData().getWaybillStatus().intValue();
|
|
|
+ if(noCarWayBill.getBillwayStatus()==-5){
|
|
|
+ if(isKf != 3){
|
|
|
+ noCarWayBill.setInterType(0);
|
|
|
+ }else{
|
|
|
+ if(tempStatus == 3){
|
|
|
+ noCarWayBill.setInterType(4);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ noCarWayBill.setPlateNum(responseRespR.getData().getPlateNum());
|
|
|
+ noCarWayBill.setStartTime(DateUtil.tTimeToDate(responseRespR.getData().getWaybillStartTime()));
|
|
|
+ noCarWayBill.setPredictEndTime(DateUtil.tTimeToDate(responseRespR.getData().getWaybillEndTime()));
|
|
|
+ //更改票状态
|
|
|
+ noCarWayBill.setBillwayStatus(tempStatus);
|
|
|
+ insertOrUpdateBill(noCarWayBill);
|
|
|
+
|
|
|
+ }else {
|
|
|
+ //更改票状态
|
|
|
+ noCarWayBill.setPlateNum(responseRespR.getData().getPlateNum());
|
|
|
+ noCarWayBill.setStartTime(DateUtil.tTimeToDate(responseRespR.getData().getWaybillStartTime()));
|
|
|
+ noCarWayBill.setPredictEndTime(DateUtil.tTimeToDate(responseRespR.getData().getWaybillEndTime()));
|
|
|
+ noCarWayBill.setBillwayStatus(tempStatus);
|
|
|
+ noCarWayBill.setUpdateTime(DateUtil.getCurrentDateStr());
|
|
|
+ noCarWaybillMapper.updateByBillNum(noCarWayBill);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(tempStatus == 2 || tempStatus==3){
|
|
|
+ //删除已有发票
|
|
|
+ billInvoiceMapper.deleteByBillNum(noCarWayBill.getBillNum());
|
|
|
+ //发票入库
|
|
|
+ List<InvoiceProcessingListModel> invoiceProcessingListModels = responseRespR.getData().getResult();
|
|
|
+ //用set来去重计费信息
|
|
|
+ Set<NoCarCalculateInfor> carCalculateInfors = new HashSet<>();
|
|
|
+ invoiceProcessingListModels.stream().forEach(invoiceProcessingListModel -> {
|
|
|
+ log.info("44444getInvoiceByWayBillOwnerNumReal{}",invoiceProcessingListModel.getTransactionId());
|
|
|
+ BillInvoice billInvoice = buildFromInvoiceProcessingListModel(invoiceProcessingListModel);
|
|
|
+ billInvoice.setCompanyName(noCarWayBill.getCompanyName());
|
|
|
+ billInvoice.setCompanyNum(noCarWayBill.getCompanyNum());
|
|
|
+ billInvoice.setCustomerName(noCarWayBill.getCustomerName());
|
|
|
+ //扣费明细入账
|
|
|
+ NoCarCalculateInfor calculateInfor = new NoCarCalculateInfor();
|
|
|
+ if(noCarWayBill.getInterType()!=4 && noCarWayBill.getInterType()!=3){
|
|
|
+ calculateInfor.setCalculateTime(DateUtil.getCurrentDateStr());
|
|
|
+ }else{
|
|
|
+ calculateInfor.setCalculateTime("2021-01-11 00:00:00");
|
|
|
+ }
|
|
|
+
|
|
|
+ calculateInfor.setCompanyNum(noCarWayBill.getCompanyNum());
|
|
|
+ calculateInfor.setCtype(1);
|
|
|
+ calculateInfor.setCustomId(noCarWayBill.getCustomerName());
|
|
|
+ calculateInfor.setBuyerName(invoiceProcessingListModel.getBuyerName());
|
|
|
+ calculateInfor.setBuyerTaxpayerCode(invoiceProcessingListModel.getBuyerTaxpayerCode());
|
|
|
+ calculateInfor.setInvoiceMakeTime(billInvoice.getInvoiceMakeTime());
|
|
|
+ calculateInfor.setTradeId(billInvoice.getTransactionId());
|
|
|
+ NoCarCalculateInfor noCarCalculateInfor = calculateInforMapper.selectByTradeId(billInvoice.getTransactionId());
|
|
|
+ if(noCarCalculateInfor!=null){
|
|
|
+ billInvoice.setCalculateTime(noCarCalculateInfor.getCalculateTime());
|
|
|
+ }else{
|
|
|
+ carCalculateInfors.add(calculateInfor);
|
|
|
+ billInvoice.setCalculateTime(calculateInfor.getCalculateTime());
|
|
|
+ }
|
|
|
+ billInvoiceMapper.insert(billInvoice);
|
|
|
+ });
|
|
|
+ log.info("6666666getInvoiceByWayBillOwnerNumReal{}",noCarWayBill.getBillNum());
|
|
|
+ if(isKf == 3)
|
|
|
+ return new RespR(responseRespR.getData());
|
|
|
+ //统一插入交易id 和 和计费信息
|
|
|
+ Param param = paramService.getParamsByParamName("CUST_NOCAR_FEE");
|
|
|
+ Double fee = Double.parseDouble(param.getParamValue());
|
|
|
+ Customer customer = customerMapper.selectByCustomerNameForLock(noCarWayBill.getCustomerName());
|
|
|
+ customer.setInvoiceTime(DateUtil.getCurrentDateStr());
|
|
|
+ carCalculateInfors.stream().forEach(calculateInfor -> {
|
|
|
+ try {
|
|
|
+ calculateInfor.setCompanyLongName(customer.getCompany());
|
|
|
+ calculateInfor.setFee(fee);
|
|
|
+ calculateInforMapper.insert(calculateInfor);
|
|
|
+ customer.setAccountBalance(MathUtil.sub(customer.getAccountBalance(),calculateInfor.getFee()));
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("重复数据来啦getInvoiceByWayBillOwnerNumReal"+calculateInfor.getTradeId());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+ if(isKf==1)
|
|
|
+ customerMapper.updateByPrimaryKeySelective(customer);
|
|
|
+
|
|
|
+ }
|
|
|
+ if(true){
|
|
|
+ log.info("10000000000getInvoiceByWayBillOwnerNumReal{}",noCarWayBill.getBillNum());
|
|
|
+ return new RespR(responseRespR.getData());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info("99999999getInvoiceByWayBillOwnerNumReal{}",noCarWayBill.getBillNum());
|
|
|
+ return new RespR("success");
|
|
|
+ }
|
|
|
}
|