| | |
| | | package com.by4cloud.platformx.business.controller; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.by4cloud.platformx.business.entity.ContractOutBound; |
| | | import com.by4cloud.platformx.business.entity.SaleCredit; |
| | | import com.by4cloud.platformx.business.entity.invoice.InvoiceResult; |
| | | import com.by4cloud.platformx.business.entity.invoice.InvoiceResultItem; |
| | | import com.by4cloud.platformx.business.entity.invoice.InvoicingVo; |
| | | import com.by4cloud.platformx.business.entity.invoice.vo.BipResVo; |
| | | import com.by4cloud.platformx.business.entity.invoice.vo.InvoicingVo; |
| | | import com.by4cloud.platformx.business.invoice.service.BIPYsService; |
| | | import com.by4cloud.platformx.business.invoice.service.FpInvoiceResultItemService; |
| | | import com.by4cloud.platformx.business.service.ContractOutBoundService; |
| | | import com.by4cloud.platformx.business.service.InvoiceService; |
| | |
| | | private final InvoiceService invoiceService; |
| | | private final SaleCreditService saleCreditService; |
| | | private final ContractOutBoundService contractOutBoundService; |
| | | private final BIPYsService bipYsService; |
| | | |
| | | @Operation(summary = "推送应付蓝票" , description = "推送应付蓝票" ) |
| | | @GetMapping("/pushYfBlue" ) |
| | |
| | | Map<String, Object> objectMap = invoiceService.toKaipiao(invoicingVo); |
| | | Boolean success = (Boolean) objectMap.get("success"); |
| | | String message = (String) objectMap.get("message"); |
| | | System.out.println(saleCredit.getEntrustCode() + "的railwayEntrust蓝字开票结果为:" + success + "------" + message); |
| | | //System.out.println(saleCredit.getEntrustCode() + "的railwayEntrust蓝字开票结果为:" + success + "------" + message); |
| | | if(success){ |
| | | saleCredit.setBlueResultStatus(1); |
| | | saleCreditService.updateById(saleCredit); |
| | | //StringBuffer errMsg = new StringBuffer(); |
| | | BipResVo bipResVo = bipYsService.sendBIPYs(saleCredit); |
| | | if (!bipResVo.getCode().equals("200")) { |
| | | /*if (StrUtil.isNotEmpty(errMsg)) { |
| | | errMsg.append(","); |
| | | } |
| | | errMsg.append(saleCredit.getCreditCodeB()+ "应收发票推送失败:" + bipResVo.getMessage());*/ |
| | | return R.failed("开票成功,推送bip失败,err:" + bipResVo.getMessage()); |
| | | }else{ |
| | | return R.ok("开票成功,推送big成功!"); |
| | | } |
| | | |
| | | }else{ |
| | | saleCredit.setStatus(2); |
| | | saleCreditService.updateById(saleCredit); |
| | | return R.ok("开票成功!"); |
| | | }else{ |
| | | saleCredit.setStatus(3); |
| | | saleCreditService.updateById(saleCredit); |
| | | return R.failed("开票失败!"); |
| | | return R.failed("开票失败!原因:" + message); |
| | | } |
| | | |
| | | }catch (Exception e){ |
| | |
| | | @Operation(summary = "发票查看" , description = "发票查看" ) |
| | | @GetMapping("/downInvoice" ) |
| | | public R downInvoice(String code) { |
| | | SaleCredit saleCredit = saleCreditService.getOne(new LambdaQueryWrapper<SaleCredit>() |
| | | .eq(SaleCredit::getEntrustCode, code) |
| | | .last("limit 1") |
| | | ); |
| | | QueryWrapper<InvoiceResult> invoiceResultQueryWrapper = new QueryWrapper<>(); |
| | | invoiceResultQueryWrapper.lambda() |
| | | .eq(InvoiceResult::getEntrustCode,code) |
| | | .eq(InvoiceResult::getMethodName,"蓝字开票接口") |
| | | .eq(InvoiceResult::getSuccess,1) |
| | | .eq(InvoiceResult::getEntrustCode, code) |
| | | .eq(InvoiceResult::getMethodName, "蓝字开票接口") |
| | | .eq(InvoiceResult::getSuccess, 1) |
| | | .orderByDesc(InvoiceResult::getCreateTime); |
| | | List<InvoiceResult> list = invoiceService.list(invoiceResultQueryWrapper); |
| | | if(list !=null && list.size()>0){ |
| | | if (list != null && list.size() > 0) { |
| | | InvoiceResult result = list.get(0); |
| | | Map<String, Object> objectMap = invoiceService.downInvoiceMethod(result); |
| | | Boolean success = (Boolean) objectMap.get("success"); |
| | | String message = (String) objectMap.get("message"); |
| | | if(success){ |
| | | // if(result.getPushBip()==null||result.getPushBip()!=1){ |
| | | // QueryWrapper<RailwayEntrust> wrapper = new QueryWrapper<>(); |
| | | // wrapper.lambda() |
| | | // .eq(RailwayEntrust::getEntrustCode,code); |
| | | // List<RailwayEntrust> railwayEntrusts = railwayEntrustService.list(wrapper); |
| | | // if(railwayEntrusts !=null && railwayEntrusts.size()>0){ |
| | | // RailwayEntrust railwayEntrust = railwayEntrusts.get(0); |
| | | // System.out.println(railwayEntrust.getEntrustCode()+"开始推送bip蓝票"); |
| | | // try { |
| | | // pushBip(railwayEntrust.getId(),railwayEntrust.getInvoicUrl()); |
| | | // System.out.println(railwayEntrust.getEntrustCode()+"推送bip蓝票成功"); |
| | | // result.setPushBip(1); |
| | | // result.setPushBipyf(1); |
| | | // invoiceResultService.updateById(result); |
| | | // }catch (Exception e){ |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | // } |
| | | return R.ok(objectMap); |
| | | }else { |
| | | return R.failed(message); |
| | | if (success) { |
| | | if (result.getPushBip() == null || result.getPushBip() != 1) { |
| | | try { |
| | | boolean b = invoiceService.pushBlue(saleCredit.getId(), 1); |
| | | if (b) { |
| | | //System.out.println(railwayEntrust.getEntrustCode() + "推送bip蓝票成功"); |
| | | result.setPushBip(1); |
| | | result.setPushBipyf(1); |
| | | invoiceService.updateById(result); |
| | | return R.ok("查看蓝票成功,推送bip蓝票成功!"); |
| | | }else{ |
| | | return R.failed("查看蓝票成功,推送bip蓝票失败!"); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return R.failed("查看蓝票成功,推送bip蓝票失败!"); |
| | | } |
| | | } |
| | | return R.ok("查看蓝票成功!"); |
| | | |
| | | } else{ |
| | | return R.failed("查看蓝票失败!err:" + message); |
| | | } |
| | | }else { |
| | | return R.failed("未查询到开票记录"); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 去开红票 |
| | |
| | | } |
| | | } |
| | | |
| | | /* @Operation(summary = "红冲确认单" , description = "红冲确认单" ) |
| | | @Operation(summary = "红冲确认单" , description = "红冲确认单" ) |
| | | @PostMapping("/redConfirm" ) |
| | | public R redConfirm(@RequestBody InvoicingVo vo) { |
| | | |
| | |
| | | Boolean success = (Boolean) objectMap.get("success"); |
| | | String message = (String) objectMap.get("message"); |
| | | if(success){ |
| | | return R.ok(null,message); |
| | | BipResVo bipResVo = bipYsService.removeBipInvoice(saleCredit.getBlueInvoiceResultId().toString(),saleCredit.getEntrustCode(),6); |
| | | if(bipResVo.getCode().equals("200")){ |
| | | return R.ok("开红票成功,bip删除成功!"); |
| | | }else{ |
| | | return R.ok("开红票成功,bip删除失败,err:" + bipResVo.getMessage()); |
| | | } |
| | | }else { |
| | | return R.failed(null,message); |
| | | return R.failed(null,"开票失败,err:" + message); |
| | | } |
| | | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return R.failed("开红票失败"); |
| | | } |
| | | }*/ |
| | | } |
| | | |
| | | //发红冲之前,先进行红票确认。 |
| | | @Operation(summary = "红冲发票form" , description = "红冲发票form" ) |