| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.by4cloud.platformx.business.entity.BillingInfo; |
| | | import com.by4cloud.platformx.business.entity.ContractOutBound; |
| | | import com.by4cloud.platformx.business.entity.SaleCredit; |
| | | import com.by4cloud.platformx.business.entity.invoice.*; |
| | |
| | | import com.by4cloud.platformx.business.invoice.service.BipInvoiceService; |
| | | import com.by4cloud.platformx.business.invoice.service.FileUploadService; |
| | | import com.by4cloud.platformx.business.invoice.service.FpInvoiceResultService; |
| | | import com.by4cloud.platformx.business.service.BillingInfoService; |
| | | import com.by4cloud.platformx.business.service.InvoiceService; |
| | | import com.by4cloud.platformx.business.service.SaleCreditService; |
| | | import com.by4cloud.platformx.business.vo.ContractOutBoundVo; |
| | |
| | | private SaleCreditService saleCreditService; |
| | | |
| | | @Autowired |
| | | private BillingInfoService billingInfoService; |
| | | |
| | | @Autowired |
| | | private FpInvoiceResultService invoiceResultService; |
| | | |
| | | @Autowired |
| | |
| | | |
| | | @Autowired |
| | | private FileUploadService fileUploadService; |
| | | |
| | | |
| | | |
| | | @Value("${BWInvoice.ip}") |
| | | private String invoiceIp; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> toRedTicket1(BillingInfo billingInfo) { |
| | | return redTicket1(billingInfo); |
| | | } |
| | | |
| | | @Override |
| | | public InvoicingVo toGetByCompare(SaleCredit saleCredit, List<ContractOutBound> contractOutBoundList) { |
| | | return getByCompare(saleCredit,contractOutBoundList); |
| | | } |
| | |
| | | @Override |
| | | public InvoicingVo toGetByCompareByVo(SaleCredit saleCredit, List<ContractOutBoundVo> contractOutBoundList) { |
| | | return getByCompareVo(saleCredit,contractOutBoundList); |
| | | } |
| | | |
| | | @Override |
| | | public InvoicingVo toGetByCompareByVo1(BillingInfo saleCredit, List<ContractOutBoundVo> contractOutBoundList) { |
| | | return getByCompareVo1(saleCredit,contractOutBoundList); |
| | | } |
| | | |
| | | /** |
| | |
| | | return invoicingVo; |
| | | } |
| | | |
| | | private InvoicingVo getByCompareVo1(BillingInfo saleCredit, List<ContractOutBoundVo> contractOutBoundList){ |
| | | InvoicingVo invoicingVo = new InvoicingVo(); |
| | | invoicingVo.setSaleCreditId(saleCredit.getId()); |
| | | invoicingVo.setEntrustCode(saleCredit.getEntrustCode()); |
| | | //销方 |
| | | invoicingVo.setTaxNo(saleCredit.getCreditCodeB()); |
| | | invoicingVo.setLedgerName(saleCredit.getPartyB()); |
| | | invoicingVo.setOrgCode(saleCredit.getCreditCodeB()); |
| | | invoicingVo.setFormatGenerate(false); |
| | | invoicingVo.setIsSplit(false); |
| | | invoicingVo.setFormatPushType(false); |
| | | invoicingVo.setTaxUserName(saleCredit.getContactPhoneB()); |
| | | InvoicingVo.InvoicingVoInfo invoicingVoInfo = new InvoicingVo.InvoicingVoInfo(); |
| | | |
| | | |
| | | invoicingVoInfo.setInvoiceTypeCode("01"); |
| | | invoicingVoInfo.setSerialNo("MX_ZPP_" + System.currentTimeMillis()); |
| | | invoicingVoInfo.setDrawer(saleCredit.getContactPhoneB()); |
| | | |
| | | Map<String, Object> ext = new HashMap<>(); |
| | | ext.put("htbh",saleCredit.getContractNo()); |
| | | invoicingVoInfo.setExt(ext); |
| | | |
| | | invoicingVoInfo.setSystemName("xx销售管理信息系统"); |
| | | |
| | | List<InvoicingVo.InvoiceDetail> details = new ArrayList<>(); |
| | | |
| | | int i = 0; |
| | | for (ContractOutBound outBoundVo : contractOutBoundList){ |
| | | i++; |
| | | InvoicingVo.InvoiceDetail invoiceDetail = new InvoicingVo.InvoiceDetail(); |
| | | invoiceDetail.setGoodsLineNo(i); |
| | | invoiceDetail.setGoodsTaxRate(outBoundVo.getTaxRate()); |
| | | invoiceDetail.setGoodsType(outBoundVo.getSubjectMatterName()); |
| | | invoiceDetail.setGoodsUnit(outBoundVo.getUnit()); |
| | | invoiceDetail.setGoodsQuantity(outBoundVo.getOutBoundNum()); |
| | | invoiceDetail.setGoodsPrice(outBoundVo.getUnitPrice()); |
| | | invoiceDetail.setGoodsTotalPrice(outBoundVo.getTotalPrice()); |
| | | invoiceDetail.setGoodsTotalTax(outBoundVo.getTotalTax()); |
| | | details.add(invoiceDetail); |
| | | } |
| | | //购方 |
| | | invoicingVoInfo.setBuyerTaxNo(saleCredit.getCreditCodeA()); |
| | | invoicingVoInfo.setBuyerName(saleCredit.getPartyA()); |
| | | invoicingVoInfo.setInvoiceTotalPrice(saleCredit.getTotalAmount()); |
| | | //invoicingVoInfo.setInvoiceTotalTax(new BigDecimal(allTax).setScale(2,BigDecimal.ROUND_HALF_UP)); |
| | | invoicingVoInfo.setInvoiceTotalPriceTax(saleCredit.getTotalTax()); |
| | | invoicingVoInfo.setBuyerBankName(saleCredit.getBankNameB()); |
| | | invoicingVoInfo.setBuyerBankNumber(saleCredit.getBankAccountB()); |
| | | //invoicingVoInfo.setBuyerAddress(.getBuyerAddress()); |
| | | invoicingVoInfo.setBuyerTelphone(saleCredit.getContactPhoneA()); |
| | | invoicingVoInfo.setInvoiceDetailsList(details); |
| | | invoicingVo.setData(invoicingVoInfo); |
| | | return invoicingVo; |
| | | } |
| | | |
| | | private InvoicingVo getByCompareVo(SaleCredit saleCredit, List<ContractOutBoundVo> contractOutBoundList){ |
| | | InvoicingVo invoicingVo = new InvoicingVo(); |
| | | invoicingVo.setSaleCreditId(saleCredit.getId()); |
| | |
| | | saleCredit.setRedInvoiceResultId(invoiceObj.getId()); |
| | | saleCredit.setStatus(7); |
| | | saleCreditService.updateById(saleCredit); |
| | | return stringObjectMap; |
| | | }else { |
| | | |
| | | InvoicingVo invoicingVo = redKaiPiaoVo(invoiceObj); |
| | | invoicingVo.setSaleCreditId(saleCredit.getId()); |
| | | if(invoicingVo !=null){ |
| | | Map<String, Object> stringObjectMap1 = redTicketKaiPiao(invoicingVo); |
| | | Boolean confimSuccess1 = (Boolean) stringObjectMap1.get("success"); |
| | | String message1 = (String) stringObjectMap1.get("message"); |
| | | if(confimSuccess1){ |
| | | System.out.println(saleCredit.getEntrustCode()+"的railwayEntrust红字开票结果为:"+confimSuccess1+"------"+message1); |
| | | return stringObjectMap1; |
| | | } |
| | | } |
| | | } |
| | | }else { |
| | | System.out.println(saleCredit.getEntrustCode()+"的红字确认单确认接口异常"); |
| | | return stringObjectMap; |
| | | } |
| | | }else { |
| | | System.out.println(saleCredit.getEntrustCode()+"的红字确认单新增接口异常"); |
| | | return objectMap; |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | System.out.println("异步方法执行完成"); |
| | | Map<String, Object> result = new HashMap<>(); |
| | | result.put("success",false); |
| | | result.put("message","开票异常"); |
| | | return result; |
| | | } |
| | | |
| | | public Map<String, Object> redTicket1(BillingInfo saleCredit) { |
| | | System.out.println("进入异步方法"); |
| | | System.out.println("当前线程名称:" + Thread.currentThread().getName()); |
| | | |
| | | try { |
| | | //红字确认单 |
| | | InvoiceResult result = invoiceResultService.getById(saleCredit.getBlueInvoiceResultId()); |
| | | Map<String, Object> objectMap = redTicketConfirm1(result,saleCredit); |
| | | Boolean success = (Boolean) objectMap.get("success"); |
| | | if(success){ |
| | | InvoiceResult obj = (InvoiceResult) objectMap.get("obj"); |
| | | //红字确认单确认接口 |
| | | Map<String, Object> stringObjectMap = redTicketConfirmSearch1(obj,saleCredit); |
| | | Boolean confimSuccess = (Boolean) stringObjectMap.get("success"); |
| | | if(confimSuccess){ |
| | | //开票接口 |
| | | InvoiceResult invoiceObj = (InvoiceResult) stringObjectMap.get("obj"); |
| | | if(invoiceObj.getConfirmBillingMark().equals("Y")){ |
| | | //无需开票 |
| | | System.out.println(saleCredit.getEntrustCode()+"的railwayEntrust已开红字开票"); |
| | | |
| | | QueryWrapper<InvoiceResult> invoiceResultQueryWrapper = new QueryWrapper<>(); |
| | | invoiceResultQueryWrapper.lambda() |
| | | .eq(InvoiceResult::getEntrustCode,saleCredit.getEntrustCode()) |
| | | .eq(InvoiceResult::getMethodName,"蓝字开票接口") |
| | | .like(InvoiceResult::getMessage,"%发票开具成功%"); |
| | | List<InvoiceResult> list = invoiceResultService.list(invoiceResultQueryWrapper); |
| | | if(list !=null && list.size()>0){ |
| | | invoiceResultService.removeByIds(list); |
| | | } |
| | | |
| | | /*UpdateWrapper<RailwayEntrust> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.lambda().set(RailwayEntrust::getInvoiceResult,null) |
| | | .set(RailwayEntrust::getInvoiceResultId,null) |
| | | .set(RailwayEntrust::getInvoiceRemark,"红字开票成功") |
| | | .set(RailwayEntrust::getInvoiceRedResultId,invoiceObj.getId()) |
| | | .eq(RailwayEntrust::getEntrustCode,saleCredit.getEntrustCode()); |
| | | railwayEntrustMapper.update(null,updateWrapper);*/ |
| | | saleCredit.setInvoiceRemark("红字开票成功"); |
| | | saleCredit.setRedInvoiceResultId(invoiceObj.getId()); |
| | | saleCredit.setRedResultStatus(1); |
| | | billingInfoService.updateById(saleCredit); |
| | | return stringObjectMap; |
| | | }else { |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 数电红字确认单新增接口 |
| | | */ |
| | | Map<String,Object> redTicketConfirm1(InvoiceResult invoiceResult,BillingInfo saleCredit){ |
| | | String format = strToFormat(invoiceResult.getInvoiceDate()); |
| | | List<InvoiceResultItem> resultItems = itemMapper.selectList(new LambdaQueryWrapper<InvoiceResultItem>() |
| | | .eq(InvoiceResultItem::getResultId,invoiceResult.getId()) |
| | | ); |
| | | |
| | | if(saleCredit!=null) { |
| | | RedConfirmVo confirmVo = new RedConfirmVo(); |
| | | confirmVo.setTaxNo(saleCredit.getCreditCodeB()); |
| | | confirmVo.setOrgCode(saleCredit.getCreditCodeB()); |
| | | confirmVo.setTaxUserName(saleCredit.getContactPhoneB()); |
| | | confirmVo.setRedConfirmSerialNo("MX_RPP_"+System.currentTimeMillis()); |
| | | confirmVo.setEntryIdentity("01"); |
| | | confirmVo.setSellerTaxNo(saleCredit.getCreditCodeB()); |
| | | confirmVo.setSellerTaxName(saleCredit.getPartyB()); |
| | | confirmVo.setBuyerTaxName(saleCredit.getPartyA()); |
| | | confirmVo.setBuyerTaxNo(saleCredit.getCreditCodeA()); |
| | | confirmVo.setOriginInvoiceIsPaper("N"); |
| | | confirmVo.setInvoiceSource("2"); |
| | | confirmVo.setOriginalInvoiceNo(invoiceResult.getInvoiceNo()); |
| | | confirmVo.setOriginInvoiceDate(format); |
| | | confirmVo.setOriginInvoiceTotalPrice(invoiceResult.getInvoiceTotalPrice()); |
| | | confirmVo.setOriginInvoiceTotalTax(invoiceResult.getInvoiceTotalTax()); |
| | | confirmVo.setOriginInvoiceType("01"); |
| | | confirmVo.setInvoiceTotalPrice(invoiceResult.getInvoiceTotalPrice()*-1); |
| | | confirmVo.setInvoiceTotalTax(invoiceResult.getInvoiceTotalTax()*-1); |
| | | confirmVo.setRedInvoiceLabel("02"); |
| | | confirmVo.setAutoIssueSwitch("N"); |
| | | |
| | | List<RedConfirmVo.RedConfirmDetail> detailList = new ArrayList<>(); |
| | | for (InvoiceResultItem resultItem : resultItems) { |
| | | RedConfirmVo.RedConfirmDetail detail = new RedConfirmVo.RedConfirmDetail(); |
| | | detail.setOriginalInvoiceDetailNo(resultItem.getGoodsLineNo()); |
| | | detail.setGoodsLineNo(resultItem.getGoodsLineNo()); |
| | | detail.setGoodsCode(resultItem.getGoodsCode()); |
| | | detail.setGoodsTaxRate(resultItem.getGoodsTaxRate()); |
| | | detail.setGoodsName(resultItem.getCoalName()); |
| | | detail.setProjectName(resultItem.getCoalName()); |
| | | detail.setGoodsPrice(resultItem.getGoodsPrice()+""); |
| | | detail.setGoodsSpecification(resultItem.getGoodsSpecification()); |
| | | detail.setGoodsUnit(resultItem.getGoodsUnit()); |
| | | detail.setGoodsQuantity(resultItem.getGoodsQuantity()*-1+""); |
| | | detail.setGoodsTotalPrice(resultItem.getGoodsTotalPrice()*-1); |
| | | detail.setGoodsTotalTax(resultItem.getGoodsTotalTax()*-1); |
| | | detail.setCoalType(resultItem.getCoalType()); |
| | | detail.setAgreementTerm(resultItem.getAgreementTerm()); |
| | | detailList.add(detail); |
| | | } |
| | | confirmVo.setRedConfirmDetailReqEntityList(detailList); |
| | | Gson gson =new Gson(); |
| | | String str = gson.toJson(confirmVo); |
| | | System.out.println(str); |
| | | String responseBody = ""; |
| | | responseBody = HttpRequest.post(invoiceIp+redConfirmUrl+ UuidUtils.generateUuid()) |
| | | .timeout(400000) |
| | | .body(str) |
| | | .execute() |
| | | .body(); |
| | | System.out.println(responseBody); |
| | | JSONObject jsonObj = JSON.parseObject(responseBody); |
| | | if(jsonObj!=null) { |
| | | boolean flag = (Boolean) jsonObj.get("success"); |
| | | JSONObject message = jsonObj.getJSONObject("message"); |
| | | String requestId = (String) jsonObj.get("requestId"); |
| | | if (!flag) { |
| | | Map<String,Object> res = new HashMap<>(); |
| | | res.put("success",flag); |
| | | res.put("message",message.get("errorMessage")); |
| | | InvoiceResult result = new InvoiceResult(); |
| | | result.setRequestId(requestId); |
| | | result.setSuccess(flag); |
| | | result.setMessage((String) message.get("errorMessage")); |
| | | result.setMethodName("红字确认单新增接口"); |
| | | result.setEntrustCode(saleCredit.getEntrustCode()); |
| | | invoiceResultService.save(result); |
| | | |
| | | saleCredit.setInvoiceRemark((String) message.get("errorMessage")); |
| | | billingInfoService.updateById(saleCredit); |
| | | return res; |
| | | } else { |
| | | String successMessage = (String) message.get("successMessage"); |
| | | JSONArray modelarr = jsonObj.getJSONArray("model"); |
| | | JSONObject model = modelarr.getJSONObject(0); |
| | | |
| | | String redConfirmSerialNo = (String)model.get("redConfirmSerialNo"); |
| | | String redConfirmNo = (String)model.get("redConfirmNo"); |
| | | String redConfirmUuid = (String)model.get("redConfirmUuid"); |
| | | String confirmState = (String)model.get("confirmState"); |
| | | String confirmBillingMark = (String)model.get("confirmBillingMark"); |
| | | |
| | | InvoiceResult result = new InvoiceResult(); |
| | | result.setXTaxNo(invoiceResult.getXTaxNo()); |
| | | result.setRequestId(requestId); |
| | | result.setSuccess(flag); |
| | | result.setMessage(successMessage); |
| | | result.setSerialNo(redConfirmSerialNo); |
| | | result.setInvoiceNo(redConfirmNo); |
| | | result.setRedConfirmUuid(redConfirmUuid); |
| | | result.setConfirmState(confirmState); |
| | | result.setConfirmBillingMark(confirmBillingMark); |
| | | result.setMethodName("红字确认单新增接口"); |
| | | result.setOriginalInvoiceNo(invoiceResult.getInvoiceNo()); |
| | | result.setEntrustCode(invoiceResult.getEntrustCode()); |
| | | invoiceResultService.save(result); |
| | | Map<String,Object> res = new HashMap<>(); |
| | | res.put("success",flag); |
| | | res.put("message",successMessage); |
| | | res.put("obj",result); |
| | | return res; |
| | | } |
| | | }else { |
| | | Map<String,Object> res = new HashMap<>(); |
| | | res.put("success",false); |
| | | res.put("message","开票接口异常"); |
| | | |
| | | InvoiceResult result = new InvoiceResult(); |
| | | result.setSuccess(false); |
| | | result.setMessage("红字确认单新增接口异常"); |
| | | result.setMethodName("红字确认单新增接口"); |
| | | result.setEntrustCode(saleCredit.getEntrustCode()); |
| | | invoiceResultService.save(result); |
| | | |
| | | saleCredit.setInvoiceRemark("红字确认单新增接口异常"); |
| | | billingInfoService.updateById(saleCredit); |
| | | return res; |
| | | } |
| | | }else { |
| | | Map<String,Object> res = new HashMap<>(); |
| | | res.put("success",false); |
| | | res.put("message","红字确认单新增接口异常"); |
| | | InvoiceResult result = new InvoiceResult(); |
| | | result.setSuccess(false); |
| | | result.setMessage("红字确认单新增接口异常"); |
| | | result.setMethodName("红字确认单新增接口"); |
| | | result.setEntrustCode(saleCredit.getEntrustCode()); |
| | | invoiceResultService.save(result); |
| | | |
| | | saleCredit.setInvoiceRemark("红字确认单新增接口异常"); |
| | | billingInfoService.updateById(saleCredit); |
| | | return res; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 数电红字确认单查询接口 |
| | | */ |
| | | Map<String,Object> redTicketConfirmSearch(InvoiceResult invoiceResult,SaleCredit saleCredit){ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 数电红字确认单查询接口 |
| | | */ |
| | | Map<String,Object> redTicketConfirmSearch1(InvoiceResult invoiceResult,BillingInfo saleCredit){ |
| | | /* QueryWrapper<RailwayEntrust> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda().eq(RailwayEntrust::getEntrustCode,invoiceResult.getEntrustCode()); |
| | | RailwayEntrust railwayEntrust = railwayEntrustMapper.selectList(wrapper).get(0);*/ |
| | | |
| | | |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("taxNo",invoiceResult.getXTaxNo()); |
| | | //map.put("taxUserName",dwuser); |
| | | map.put("sellerTaxNo",invoiceResult.getXTaxNo()); |
| | | map.put("redConfirmUuid",invoiceResult.getRedConfirmUuid()); |
| | | Gson gson =new Gson(); |
| | | String str = gson.toJson(map); |
| | | System.out.println(str); |
| | | String responseBody = ""; |
| | | responseBody = HttpRequest.post(invoiceIp+redConfirmSearchUrl+UuidUtils.generateUuid()) |
| | | .timeout(400000) |
| | | .body(str) |
| | | .execute() |
| | | .body(); |
| | | System.out.println(responseBody); |
| | | |
| | | JSONObject jsonObj = JSON.parseObject(responseBody); |
| | | if(jsonObj!=null) { |
| | | boolean flag = (Boolean) jsonObj.get("success"); |
| | | JSONObject message = jsonObj.getJSONObject("message"); |
| | | String requestId = (String) jsonObj.get("requestId"); |
| | | if (!flag) { |
| | | Map<String,Object> res = new HashMap<>(); |
| | | res.put("success",false); |
| | | res.put("message","红字确认单确认接口异常"); |
| | | InvoiceResult result = new InvoiceResult(); |
| | | result.setSuccess(false); |
| | | result.setRequestId(requestId); |
| | | result.setMessage("红字确认单确认接口异常"); |
| | | result.setMethodName("红字确认单确认接口"); |
| | | result.setEntrustCode(invoiceResult.getEntrustCode()); |
| | | invoiceResultService.save(result); |
| | | |
| | | saleCredit.setInvoiceRemark("红字确认单确认接口异常"); |
| | | billingInfoService.updateById(saleCredit); |
| | | return res; |
| | | } else { |
| | | |
| | | |
| | | String successMessage = (String) message.get("successMessage"); |
| | | JSONArray modelarr = jsonObj.getJSONArray("model"); |
| | | JSONObject model = modelarr.getJSONObject(0); |
| | | |
| | | String redConfirmSerialNo = (String)model.get("redConfirmSerialNo"); |
| | | String redConfirmNo = (String)model.get("redConfirmNo"); |
| | | String redConfirmUuid = (String)model.get("redConfirmUuid"); |
| | | String confirmState = (String)model.get("confirmState"); |
| | | String confirmBillingMark = (String)model.get("confirmBillingMark"); |
| | | String entryIdentity = (String)model.get("entryIdentity"); |
| | | String sellerTaxNo = (String)model.get("sellerTaxNo"); |
| | | String sellerName = (String)model.get("sellerName"); |
| | | String buyerTaxNo = (String)model.get("buyerTaxNo"); |
| | | String buyerName = (String)model.get("buyerName"); |
| | | String originalInvoiceNo = (String)model.get("originalInvoiceNo"); |
| | | String originInvoiceIsPaper = (String)model.get("originInvoiceIsPaper"); |
| | | String originInvoiceDate = (String)model.get("originInvoiceDate"); |
| | | String originInvoiceType = (String)model.get("originInvoiceType"); |
| | | String redInvoiceLabel = (String)model.get("redInvoiceLabel"); |
| | | String alreadyRedInvoiceFlag = (String)model.get("alreadyRedInvoiceFlag"); |
| | | String redInvoiceNo = (String)model.get("redInvoiceNo"); |
| | | String redInvoiceDate = (String)model.get("redInvoiceDate"); |
| | | String entryDate = (String)model.get("entryDate"); |
| | | String validFlag = (String)model.get("validFlag"); |
| | | String invoiceSource = (String)model.get("invoiceSource"); |
| | | String tenantCode = (String)model.get("tenantCode"); |
| | | String orgCode = (String)model.get("orgCode"); |
| | | String buySelSelector = (String)model.get("buySelSelector"); |
| | | String autoIssueSwitch = (String)model.get("autoIssueSwitch"); |
| | | String priceTaxMark = (String)model.get("priceTaxMark"); |
| | | BigDecimal originInvoiceTotalPriceValue = (BigDecimal) model.get("originInvoiceTotalPrice"); |
| | | Double originInvoiceTotalPrice = Double.valueOf(originInvoiceTotalPriceValue.doubleValue()); |
| | | BigDecimal originInvoiceTotalTaxValue = (BigDecimal) model.get("originInvoiceTotalTax"); |
| | | Double originInvoiceTotalTax = Double.valueOf(originInvoiceTotalTaxValue.doubleValue()); |
| | | BigDecimal invoiceTotalPriceValue = (BigDecimal) model.get("invoiceTotalPrice"); |
| | | Double invoiceTotalPrice = Double.valueOf(invoiceTotalPriceValue.doubleValue()); |
| | | BigDecimal invoiceTotalTaxValue = (BigDecimal) model.get("invoiceTotalTax"); |
| | | Double invoiceTotalTax = Double.valueOf(invoiceTotalTaxValue.doubleValue()); |
| | | |
| | | InvoiceResult result = new InvoiceResult(); |
| | | result.setRequestId(requestId); |
| | | result.setMessage(successMessage); |
| | | result.setSerialNo(redConfirmSerialNo); |
| | | result.setInvoiceNo(redConfirmNo); |
| | | result.setSuccess(flag); |
| | | result.setInvoiceNo(invoiceResult.getInvoiceNo()); |
| | | result.setEntrustCode(invoiceResult.getEntrustCode()); |
| | | result.setXTaxNo(sellerTaxNo); |
| | | result.setXOrgCode(orgCode); |
| | | result.setXName(sellerName); |
| | | result.setGName(buyerName); |
| | | result.setGTaxNo(buyerTaxNo); |
| | | result.setEntryDate(entryDate); |
| | | result.setEntryIdentity(entryIdentity); |
| | | result.setAlreadyRedInvoiceFlag(alreadyRedInvoiceFlag); |
| | | result.setOriginInvoiceType(originInvoiceType); |
| | | result.setOriginalInvoiceDate(originInvoiceDate); |
| | | result.setOriginInvoiceIsPaper(originInvoiceIsPaper); |
| | | result.setOriginalInvoiceNo(originalInvoiceNo); |
| | | result.setRedInvoiceNo(redInvoiceNo); |
| | | result.setRedInvoiceDate(redInvoiceDate); |
| | | result.setValidFlag(validFlag); |
| | | result.setRedInvoiceLabel(redInvoiceLabel); |
| | | result.setRedConfirmUuid(redConfirmUuid); |
| | | result.setConfirmState(confirmState); |
| | | result.setConfirmBillingMark(confirmBillingMark); |
| | | result.setMethodName("红字确认单确认接口"); |
| | | result.setInvoiceTotalPrice(invoiceTotalPrice); |
| | | result.setInvoiceTotalTax(invoiceTotalTax); |
| | | result.setOriginInvoiceTotalPrice(originInvoiceTotalPrice); |
| | | result.setOriginInvoiceTotalTax(originInvoiceTotalTax); |
| | | invoiceResultService.save(result); |
| | | |
| | | |
| | | JSONArray invoiceDetailList1 = model.getJSONArray("electricInvoiceDetails"); |
| | | for (int i = 0; i < invoiceDetailList1.size(); i++) { |
| | | JSONObject jsonObject = invoiceDetailList1.getJSONObject(i); |
| | | int goodsLineNo = (int) jsonObject.get("goodsLineNo"); |
| | | int originalInvoiceDetailNo = (int) jsonObject.get("originalInvoiceDetailNo"); |
| | | String goodsName = (String) jsonObject.get("goodsName"); |
| | | String goodsCode = (String) jsonObject.get("goodsCode"); |
| | | BigDecimal goodsPriceValue = (BigDecimal)jsonObject.get("goodsPrice"); |
| | | Double goodsPrice = Double.valueOf(goodsPriceValue.doubleValue()); |
| | | double goodsQuantity=0.0; |
| | | try { |
| | | BigDecimal goodsQuantityValue = (BigDecimal)jsonObject.get("goodsQuantity"); |
| | | goodsQuantity = Double.valueOf(goodsQuantityValue.doubleValue()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | int goodsQuantity1 = (int) jsonObject.get("goodsQuantity"); |
| | | goodsQuantity = goodsQuantity1; |
| | | } |
| | | |
| | | BigDecimal goodsTotalPriceValue = (BigDecimal)jsonObject.get("goodsTotalPrice"); |
| | | Double goodsTotalPrice = Double.valueOf(goodsTotalPriceValue.doubleValue()); |
| | | BigDecimal goodsTotalTaxValue = (BigDecimal)jsonObject.get("goodsTotalTax"); |
| | | Double goodsTotalTax = Double.valueOf(goodsTotalTaxValue.doubleValue()); |
| | | BigDecimal goodsTaxRateValue = (BigDecimal)jsonObject.get("goodsTaxRate"); |
| | | Double goodsTaxRate = Double.valueOf(goodsTaxRateValue.doubleValue()); |
| | | String invoiceLineNature = (String) jsonObject.get("invoiceLineNature"); |
| | | String goodsUnit = (String) jsonObject.get("goodsUnit"); |
| | | String goodsSpecification = (String) jsonObject.get("goodsSpecification"); |
| | | String coalType = (String)jsonObject.get("coalType"); |
| | | String agreementTerm = (String)jsonObject.get("agreementTerm"); |
| | | String name = ""; |
| | | if(goodsLineNo==1){ |
| | | name = "煤款"; |
| | | } |
| | | if(goodsLineNo==2){ |
| | | name = "取送车费"; |
| | | } |
| | | if(goodsLineNo==3){ |
| | | name = "专线费"; |
| | | } |
| | | |
| | | InvoiceResultItem item = new InvoiceResultItem(); |
| | | item.setGoodsLineNature(invoiceLineNature); |
| | | item.setOriginalInvoiceDetailNo(originalInvoiceDetailNo); |
| | | item.setGoodsCode(goodsCode); |
| | | item.setGoodsPrice(goodsPrice); |
| | | item.setGoodsType(name); |
| | | if(goodsSpecification !=null){ |
| | | item.setGoodsSpecification(goodsSpecification); |
| | | } |
| | | item.setGoodsLineNo(goodsLineNo); |
| | | item.setGoodsQuantity(goodsQuantity); |
| | | item.setGoodsTaxRate(goodsTaxRate); |
| | | item.setGoodsName(goodsName); |
| | | item.setGoodsTotalPrice(goodsTotalPrice); |
| | | item.setGoodsTotalTax(goodsTotalTax); |
| | | item.setGoodsUnit(goodsUnit); |
| | | item.setResultId(result.getId()); |
| | | item.setEntrustCode(result.getEntrustCode()); |
| | | if(coalType !=null){ |
| | | item.setCoalType(coalType); |
| | | } |
| | | if(agreementTerm !=null){ |
| | | item.setAgreementTerm(agreementTerm); |
| | | } |
| | | String[] split = goodsName.split("\\*"); |
| | | int length = split.length; |
| | | String coalName = split[length - 1]; |
| | | item.setCoalName(coalName); |
| | | itemMapper.insert(item); |
| | | } |
| | | Map<String,Object> res = new HashMap<>(); |
| | | res.put("success",flag); |
| | | res.put("message",successMessage); |
| | | res.put("obj",result); |
| | | saleCredit.setInvoiceRemark("红字确认单确认接口成功"); |
| | | saleCredit.setRedInvoiceResultId(result.getId()); |
| | | billingInfoService.updateById(saleCredit); |
| | | return res; |
| | | } |
| | | }else { |
| | | Map<String,Object> res = new HashMap<>(); |
| | | res.put("success",false); |
| | | res.put("message","红字确认单确认接口异常"); |
| | | InvoiceResult result = new InvoiceResult(); |
| | | result.setSuccess(false); |
| | | result.setMessage("红字确认单确认接口异常"); |
| | | result.setMethodName("红字确认单确认接口"); |
| | | result.setEntrustCode(invoiceResult.getEntrustCode()); |
| | | invoiceResultService.save(result); |
| | | |
| | | saleCredit.setInvoiceRemark("红字确认单确认接口异常"); |
| | | billingInfoService.updateById(saleCredit); |
| | | return res; |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 红字确认单form |
| | | * @param result |
| | | * @return |