package com.by4cloud.platformx.business.service.impl;
|
|
import cn.hutool.http.HttpRequest;
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.nacos.common.utils.StringUtils;
|
import com.alibaba.nacos.common.utils.UuidUtils;
|
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.entity.invoice.vo.InvoicingVo;
|
import com.by4cloud.platformx.business.entity.invoice.vo.RedConfirmVo;
|
import com.by4cloud.platformx.business.invoice.mapper.FpInvoiceResultItemMapper;
|
import com.by4cloud.platformx.business.invoice.mapper.FpInvoiceResultMapper;
|
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;
|
import com.google.gson.Gson;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.stereotype.Service;
|
|
import java.math.BigDecimal;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.stream.Collectors;
|
|
/**
|
* 销售挂账
|
*
|
* @author wjli
|
* @date 2026-05-21 16:16:31
|
*/
|
@Service
|
public class InvoiceServiceImpl extends ServiceImpl<FpInvoiceResultMapper, InvoiceResult> implements InvoiceService {
|
|
@Autowired
|
private StringRedisTemplate redisTemplate;
|
|
@Autowired
|
private FpInvoiceResultItemMapper itemMapper;
|
|
@Autowired
|
private SaleCreditService saleCreditService;
|
|
@Autowired
|
private BillingInfoService billingInfoService;
|
|
@Autowired
|
private FpInvoiceResultService invoiceResultService;
|
|
@Autowired
|
private BipInvoiceService bipInvoiceService;
|
|
@Autowired
|
private FileUploadService fileUploadService;
|
|
|
|
@Value("${BWInvoice.ip}")
|
private String invoiceIp;
|
@Value("${BWInvoice.kaipiao}")
|
private String kpUrl;
|
@Value("${BWInvoice.chaxun}")
|
private String cxUrl;
|
@Value("${BWInvoice.redConfirmAdd}")
|
private String redConfirmUrl;
|
|
@Value("${BWInvoice.redConfirmSearch}")
|
private String redConfirmSearchUrl;
|
|
@Override
|
public Map<String, Object> toKaipiao(InvoicingVo invoicingVo) {
|
Map<String, Object> stringObjectMap = zizhuKaiPiao(invoicingVo);
|
return stringObjectMap;
|
}
|
|
@Override
|
public Map<String, Object> toRedTicket(SaleCredit saleCredit) {
|
return redTicket(saleCredit);
|
}
|
|
@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);
|
}
|
|
/**
|
* 自主结算开票
|
*/
|
Map<String, Object> zizhuKaiPiao(InvoicingVo vo){
|
String s1 = redisTemplate.opsForValue().get("ZZKP_BLUE:" + vo.getEntrustCode());
|
if(StringUtils.isNotBlank(s1)){
|
System.out.println("结算单号:"+vo.getEntrustCode()+"正在开票,请勿重复点击");
|
Map<String,Object> res = new HashMap<>();
|
res.put("success",false);
|
res.put("message","结算单号:"+vo.getEntrustCode()+"正在开票,请勿重复点击");
|
return res;
|
}
|
redisTemplate.opsForValue().set("ZZKP_BLUE:" + vo.getEntrustCode(),"true");
|
try {
|
Gson gson =new Gson();
|
String str = gson.toJson(vo);
|
System.out.println(str);
|
String responseBody = "";
|
responseBody = HttpRequest.post(invoiceIp+kpUrl+ 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 invoiceResult = new InvoiceResult();
|
invoiceResult.setSaleCreditId(vo.getSaleCreditId());
|
invoiceResult.setRequestId(requestId);
|
invoiceResult.setSuccess(flag);
|
invoiceResult.setMessage((String) message.get("errorMessage"));
|
invoiceResult.setMethodName("蓝字开票接口");
|
invoiceResult.setEntrustCode(vo.getEntrustCode());
|
invoiceResultService.save(invoiceResult);
|
|
SaleCredit saleCredit = saleCreditService.getById(invoiceResult.getSaleCreditId());
|
saleCredit.setInvoiceRemark((String) message.get("errorMessage"));
|
saleCreditService.updateById(saleCredit);
|
|
/* UpdateWrapper<RailwayEntrust> updateWrapper = new UpdateWrapper<>();
|
updateWrapper.lambda().set(RailwayEntrust::getInvoiceResult,null)
|
.set(RailwayEntrust::getInvoiceResultId,null)
|
.set(RailwayEntrust::getTaskId,null)
|
.set(RailwayEntrust::getInvoiceProcInstId,null)
|
.set(RailwayEntrust::getInvoiceRemark,(String) message.get("errorMessage"))
|
.eq(RailwayEntrust::getEntrustCode,vo.getEntrustCode());
|
railwayEntrustMapper.update(null,updateWrapper);*/
|
|
redisTemplate.delete("ZZKP_BLUE:" + vo.getEntrustCode());
|
return res;
|
}else {
|
String successMessage = (String)message.get("successMessage");
|
JSONObject model = jsonObj.getJSONObject("model");
|
JSONArray success = model.getJSONArray("success");
|
JSONObject modelObject = success.getJSONObject(0);
|
String invoiceTypeCode = (String)modelObject.get("invoiceTypeCode");
|
String invoiceNo = (String)modelObject.get("invoiceNo");
|
String invoiceDate = (String)modelObject.get("invoiceDate");
|
String invoiceQrCode = (String)modelObject.get("invoiceQrCode");
|
String serialNo = (String)modelObject.get("serialNo");
|
BigDecimal invoiceTotalPriceValue = (BigDecimal)modelObject.get("invoiceTotalPrice");
|
Double invoiceTotalPrice = Double.valueOf(invoiceTotalPriceValue.doubleValue());
|
BigDecimal invoiceTotalTaxValue = (BigDecimal)modelObject.get("invoiceTotalTax");
|
Double invoiceTotalTax = Double.valueOf(invoiceTotalTaxValue.doubleValue());
|
BigDecimal invoiceTotalPriceTaxValue = (BigDecimal)modelObject.get("invoiceTotalPriceTax");
|
Double invoiceTotalPriceTax = Double.valueOf(invoiceTotalPriceTaxValue.doubleValue());
|
String mulPurchaserMark = (String)modelObject.get("mulPurchaserMark");
|
String sellerTaxNo = (String)modelObject.get("sellerTaxNo");
|
String coalCalorificValue = (String)modelObject.get("coalCalorificValue");
|
String totalSulfurOnDryBasis = (String)modelObject.get("totalSulfurOnDryBasis");
|
String dryAshFreeVolatileMatter = (String)modelObject.get("dryAshFreeVolatileMatter");
|
|
InvoiceResult invoiceResult = new InvoiceResult();
|
invoiceResult.setSaleCreditId(vo.getSaleCreditId());
|
invoiceResult.setRequestId(requestId);
|
invoiceResult.setSuccess(flag);
|
invoiceResult.setMessage(successMessage);
|
invoiceResult.setInvoiceNo(invoiceNo);
|
invoiceResult.setInvoiceTyCode(invoiceTypeCode);
|
invoiceResult.setInvoiceDate(invoiceDate);
|
invoiceResult.setInvoiceQrCode(invoiceQrCode);
|
invoiceResult.setSerialNo(serialNo);
|
invoiceResult.setMethodName("蓝字开票接口");
|
invoiceResult.setEntrustCode(vo.getEntrustCode());
|
invoiceResult.setInvoiceTotalPrice(invoiceTotalPrice);
|
invoiceResult.setInvoiceTotalTax(invoiceTotalTax);
|
invoiceResult.setInvoiceTotalPriceTax(invoiceTotalPriceTax);
|
invoiceResult.setMulPurchaserMark(mulPurchaserMark);
|
invoiceResult.setXTaxNo(sellerTaxNo);
|
/*if(StringUtils.isNotBlank(coalCalorificValue)){
|
invoiceResult.setCoalCalorificValue(coalCalorificValue);
|
}
|
if(StringUtils.isNotBlank(totalSulfurOnDryBasis)){
|
invoiceResult.setTotalSulfurOnDryBasis(totalSulfurOnDryBasis);
|
}
|
if(StringUtils.isNotBlank(dryAshFreeVolatileMatter)){
|
invoiceResult.setDryAshFreeVolatileMatter(dryAshFreeVolatileMatter);
|
}*/
|
invoiceResultService.save(invoiceResult);
|
|
JSONArray invoiceDetailList1 = modelObject.getJSONArray("invoiceDetailsList");
|
for (int i = 0; i < invoiceDetailList1.size(); i++) {
|
JSONObject jsonObject = invoiceDetailList1.getJSONObject(i);
|
int goodsLineNo = (int) jsonObject.get("goodsLineNo");
|
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 {
|
int goodsQuantity1 = (int) jsonObject.get("goodsQuantity");
|
goodsQuantity = goodsQuantity1;
|
}catch (Exception e){
|
e.printStackTrace();
|
BigDecimal goodsQuantityValue = (BigDecimal)jsonObject.get("goodsQuantity");
|
goodsQuantity = Double.valueOf(goodsQuantityValue.doubleValue());
|
}
|
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 && goodsTaxRate==0.13){
|
name = "取送车费";
|
}
|
if(goodsTaxRate==0.6){
|
name = "专线费";
|
}*/
|
InvoiceResultItem item = new InvoiceResultItem();
|
item.setGoodsLineNature(invoiceLineNature);
|
item.setGoodsCode(goodsCode);
|
item.setGoodsPrice(goodsPrice);
|
item.setGoodsLineNo(goodsLineNo);
|
item.setGoodsQuantity(goodsQuantity);
|
item.setGoodsTaxRate(goodsTaxRate);
|
item.setGoodsType(name);
|
item.setGoodsName(goodsName);
|
item.setGoodsTotalPrice(goodsTotalPrice);
|
item.setGoodsTotalTax(goodsTotalTax);
|
item.setGoodsUnit(goodsUnit);
|
item.setCoalType(coalType);
|
if(StringUtils.isNotBlank(agreementTerm)){
|
item.setAgreementTerm(agreementTerm);
|
}
|
if(goodsSpecification !=null){
|
item.setGoodsSpecification(goodsSpecification);
|
}
|
item.setResultId(invoiceResult.getId());
|
item.setEntrustCode(invoiceResult.getEntrustCode());
|
String[] split = goodsName.split("\\*");
|
int length = split.length;
|
String coalName = split[length - 1];
|
item.setCoalName(coalName);
|
itemMapper.insert(item);
|
}
|
|
/*QueryWrapper<RailwayEntrust> wrapper = new QueryWrapper<>();
|
wrapper.lambda().eq(RailwayEntrust::getEntrustCode,invoiceResult.getEntrustCode());
|
RailwayEntrust railwayEntrust = railwayEntrustMapper.selectList(wrapper).get(0);
|
railwayEntrust.setInvoiceResultId(invoiceResult.getId());
|
railwayEntrust.setInvoiceResult(2);
|
railwayEntrust.setInvoiceRemark("蓝字开票成功");
|
railwayEntrustMapper.updateById(railwayEntrust);*/
|
|
SaleCredit saleCredit = saleCreditService.getById(invoiceResult.getSaleCreditId());
|
saleCredit.setInvoiceRemark("蓝字开票成功");
|
saleCredit.setStatus(2);
|
saleCredit.setBlueInvoiceResultId(invoiceResult.getId());
|
saleCreditService.updateById(saleCredit);
|
|
Map<String,Object> res = new HashMap<>();
|
res.put("success",flag);
|
res.put("message",successMessage);
|
String s = redisTemplate.opsForValue().get("railwayEntrust_invoice_id:" + saleCredit.getId());
|
if(StringUtils.isNotBlank(s)){
|
redisTemplate.delete("railwayEntrust_invoice_id:" + saleCredit.getId());
|
}
|
redisTemplate.delete("ZZKP_BLUE:" + vo.getEntrustCode());
|
return res;
|
}
|
|
}else {
|
InvoiceResult invoiceResult = new InvoiceResult();
|
invoiceResult.setSuccess(false);
|
invoiceResult.setMessage("蓝字开票接口无返回值");
|
invoiceResult.setMethodName("蓝字开票接口");
|
invoiceResult.setEntrustCode(vo.getEntrustCode());
|
invoiceResultService.save(invoiceResult);
|
Map<String,Object> res = new HashMap<>();
|
res.put("success",false);
|
res.put("message","蓝字开票接口无返回值");
|
|
/*UpdateWrapper<RailwayEntrust> updateWrapper = new UpdateWrapper<>();
|
updateWrapper.lambda().set(RailwayEntrust::getInvoiceResult,null)
|
.set(RailwayEntrust::getInvoiceResultId,null)
|
.set(RailwayEntrust::getTaskId,null)
|
.set(RailwayEntrust::getInvoiceProcInstId,null)
|
.set(RailwayEntrust::getInvoiceRemark,"蓝字开票接口无返回值")
|
.eq(RailwayEntrust::getEntrustCode,vo.getEntrustCode());
|
railwayEntrustMapper.update(null,updateWrapper);*/
|
|
SaleCredit saleCredit = saleCreditService.getById(invoiceResult.getSaleCreditId());
|
saleCredit.setInvoiceRemark("蓝字开票接口无返回值");
|
saleCredit.setStatus(3);
|
saleCredit.setBlueInvoiceResultId(null);
|
saleCredit.setEntrustCode(vo.getEntrustCode());
|
saleCreditService.updateById(saleCredit);
|
|
redisTemplate.delete("ZZKP_BLUE:" + vo.getEntrustCode());
|
return res;
|
}
|
}catch (Exception e){
|
e.printStackTrace();
|
Map<String,Object> res = new HashMap<>();
|
res.put("success",false);
|
res.put("message","开票接口异常");
|
InvoiceResult invoiceResult = new InvoiceResult();
|
invoiceResult.setSuccess(false);
|
invoiceResult.setMessage("蓝字开票接口异常");
|
invoiceResult.setMethodName("蓝字开票接口");
|
invoiceResult.setEntrustCode(vo.getEntrustCode());
|
invoiceResultService.save(invoiceResult);
|
|
/*UpdateWrapper<RailwayEntrust> updateWrapper = new UpdateWrapper<>();
|
updateWrapper.lambda().set(RailwayEntrust::getInvoiceResult,null)
|
.set(RailwayEntrust::getInvoiceResultId,null)
|
.set(RailwayEntrust::getTaskId,null)
|
.set(RailwayEntrust::getInvoiceProcInstId,null)
|
.set(RailwayEntrust::getInvoiceRemark,"蓝字开票接口异常")
|
.eq(RailwayEntrust::getEntrustCode,vo.getEntrustCode());
|
railwayEntrustMapper.update(null,updateWrapper);*/
|
|
SaleCredit saleCredit = saleCreditService.getById(invoiceResult.getSaleCreditId());
|
saleCredit.setInvoiceRemark("蓝字开票接口异常");
|
saleCredit.setStatus(3);
|
saleCredit.setBlueInvoiceResultId(null);
|
saleCredit.setEntrustCode(vo.getEntrustCode());
|
saleCreditService.updateById(saleCredit);
|
|
redisTemplate.delete("ZZKP_BLUE:" + vo.getEntrustCode());
|
return res;
|
}
|
}
|
|
|
|
|
private InvoicingVo getByCompare(SaleCredit saleCredit, List<ContractOutBound> 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 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());
|
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;
|
}
|
|
//@Async("myExecutor")
|
public Map<String, Object> redTicket(SaleCredit saleCredit) {
|
System.out.println("进入异步方法");
|
System.out.println("当前线程名称:" + Thread.currentThread().getName());
|
|
try {
|
//红字确认单
|
InvoiceResult result = invoiceResultService.getById(saleCredit.getBlueInvoiceResultId());
|
Map<String, Object> objectMap = redTicketConfirm(result,saleCredit);
|
Boolean success = (Boolean) objectMap.get("success");
|
if(success){
|
InvoiceResult obj = (InvoiceResult) objectMap.get("obj");
|
//红字确认单确认接口
|
Map<String, Object> stringObjectMap = redTicketConfirmSearch(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.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 {
|
|
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;
|
}
|
|
/**
|
* 版式文件查询
|
* @param invoiceResult
|
* @return
|
*/
|
@Override
|
public Map<String, Object> downInvoiceMethod(InvoiceResult invoiceResult) {
|
SaleCredit saleCredit = saleCreditService.getById(invoiceResult.getSaleCreditId());
|
Map<String,Object> map = new HashMap<>();
|
Map<String,Object> map1 = new HashMap<>();
|
map.put("taxNo",invoiceResult.getXTaxNo());
|
map1.put("serialNo",invoiceResult.getSerialNo());
|
if(invoiceResult.getMethodName().equals("红字确认单确认接口")){
|
map1.put("einvoiceNo",invoiceResult.getRedInvoiceNo());
|
}else {
|
map1.put("einvoiceNo",invoiceResult.getInvoiceNo());
|
}
|
map1.put("returnType","1");
|
map1.put("invoiceIssueMode","1");
|
map.put("data",map1);
|
Gson gson =new Gson();
|
String str = gson.toJson(map);
|
System.out.println(str);
|
String responseBody = "";
|
responseBody = HttpRequest.post(invoiceIp+cxUrl+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");
|
if(!flag){
|
String successMessage = (String) message.get("errorMessage");
|
Map<String,Object> res = new HashMap<>();
|
res.put("success",flag);
|
res.put("message",successMessage);
|
return res;
|
}else {
|
String requestId = (String) jsonObj.get("requestId");
|
String successMessage = (String) message.get("successMessage");
|
JSONObject model = jsonObj.getJSONObject("model");
|
String modelRequestId = (String)model.get("requestId");
|
String invoiceNo = (String)model.get("invoiceNo");
|
String serialNo = (String)model.get("serialNo");
|
String sellerTaxNo = (String)model.get("sellerTaxNo");
|
String eInvoiceUrlOld = (String)model.get("eInvoiceUrl");
|
String returnType = (String)model.get("returnType");
|
|
String eInvoiceUrl = eInvoiceUrlOld.replace("http://","https://");
|
|
InvoiceResult result = new InvoiceResult();
|
result.setXTaxNo(sellerTaxNo);
|
result.setRequestId(requestId);
|
result.setFpRequestId(modelRequestId);
|
result.setSuccess(flag);
|
result.setMessage(successMessage);
|
result.setSerialNo(serialNo);
|
result.setInvoiceNo(invoiceNo);
|
result.setEInvoiceUrl(eInvoiceUrl);
|
result.setMethodName("版式文件查询接口");
|
result.setEntrustCode(invoiceResult.getEntrustCode());
|
invoiceResultService.save(result);
|
|
/*QueryWrapper<RailwayEntrust> wrapper = new QueryWrapper<>();
|
wrapper.lambda().eq(RailwayEntrust::getEntrustCode,invoiceResult.getEntrustCode());
|
RailwayEntrust railwayEntrust = railwayEntrustMapper.selectList(wrapper).get(0);*/
|
if(invoiceResult.getMethodName().contains("蓝字")){
|
/* railwayEntrust.setInvoiceRemark("蓝字发票已查询");
|
railwayEntrust.setInvoicUrl(result.getEInvoiceUrl());
|
if(railwayEntrust.getInvoiceResultId()==null){
|
railwayEntrust.setInvoiceResultId(result.getId());
|
}*/
|
saleCredit.setInvoiceRemark("蓝字发票已查询");
|
saleCredit.setInvoicUrl(result.getEInvoiceUrl());
|
saleCredit.setBlueInvoiceResultId(result.getId());
|
saleCreditService.updateById(saleCredit);
|
|
|
}else {
|
/*railwayEntrust.setInvoiceRemark("红字发票已查询");
|
railwayEntrust.setInvoicRedUrl(result.getEInvoiceUrl());
|
if(railwayEntrust.getInvoiceRedResultId()==null){
|
railwayEntrust.setInvoiceRedResultId(result.getId());
|
}*/
|
saleCredit.setInvoiceRemark("红字发票已查询");
|
saleCredit.setInvoicUrl(result.getEInvoiceUrl());
|
saleCredit.setBlueInvoiceResultId(result.getId());
|
saleCreditService.updateById(saleCredit);
|
}
|
|
//railwayEntrustMapper.updateById(railwayEntrust);
|
|
Map<String,Object> res = new HashMap<>();
|
res.put("success",flag);
|
res.put("message",successMessage);
|
res.put("url",eInvoiceUrl);
|
res.put("name",invoiceNo);
|
return res;
|
}
|
}else {
|
Map<String,Object> res = new HashMap<>();
|
res.put("success",false);
|
res.put("message","开票接口异常");
|
return res;
|
}
|
}
|
|
@Override
|
public boolean pushBlue(Long railwayId, Integer type) {
|
SaleCredit saleCredit = saleCreditService.getById(railwayId);
|
|
if (saleCredit.getBipStatus() == null || !saleCredit.getBipStatus().equals("200")) {
|
return false;
|
} else {
|
InvoiceResult result = null;
|
QueryWrapper<InvoiceResult> invoiceResultQueryWrapper = new QueryWrapper<>();
|
invoiceResultQueryWrapper.lambda()
|
.eq(InvoiceResult::getEntrustCode, saleCredit.getEntrustCode())
|
.eq(InvoiceResult::getMethodName,"蓝字开票接口")
|
.eq(InvoiceResult::getSuccess,1)
|
.like(InvoiceResult::getMessage,"%发票开具成功%")
|
.orderByAsc(InvoiceResult::getCreateTime)
|
.last( " limit 4 ");
|
if(type==0){
|
invoiceResultQueryWrapper.lambda().eq(InvoiceResult::getPushBip,1);
|
}else {
|
invoiceResultQueryWrapper.lambda().eq(InvoiceResult::getPushBipyf,1);
|
}
|
List<InvoiceResult> list = invoiceResultService.list(invoiceResultQueryWrapper);
|
if(list !=null && list.size()>0){
|
return false;
|
}
|
|
QueryWrapper<InvoiceResult> invoiceResultQueryWrapper1 = new QueryWrapper<>();
|
invoiceResultQueryWrapper1.lambda()
|
.eq(InvoiceResult::getEntrustCode, saleCredit.getEntrustCode())
|
.eq(InvoiceResult::getMethodName,"蓝字开票接口")
|
.eq(InvoiceResult::getSuccess,1)
|
.like(InvoiceResult::getMessage,"%发票开具成功%")
|
.orderByAsc(InvoiceResult::getCreateTime)
|
.last( " limit 4 ");
|
if(type==0){
|
invoiceResultQueryWrapper1.lambda().isNull(InvoiceResult::getPushBip);
|
}else {
|
invoiceResultQueryWrapper1.lambda().isNull(InvoiceResult::getPushBipyf);
|
}
|
List<InvoiceResult> list1 = invoiceResultService.list(invoiceResultQueryWrapper1);
|
if(list1 !=null && list1.size()>0){
|
result = list1.get(0);
|
}else {
|
System.out.println(saleCredit.getEntrustCode()+"未查询到开票记录");
|
return false;
|
}
|
|
if(com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(saleCredit.getInvoicUrl())){
|
if(type==0){
|
if(result.getPushBip()==null||result.getPushBip()==0) {
|
System.out.println(saleCredit.getEntrustCode() + "开始推送bip应收蓝票");
|
try {
|
boolean b = pushBipYS(saleCredit.getId(), saleCredit.getInvoicUrl());
|
if(b){
|
System.out.println(saleCredit.getEntrustCode() + "推送bip应收蓝票成功");
|
result.setPushBip(1);
|
invoiceResultService.updateById(result);
|
return true;
|
}else {
|
System.out.println(saleCredit.getEntrustCode() + "推送bip应收蓝票失败");
|
return false;
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
}else if (type==1){
|
if(result.getPushBipyf()==null||result.getPushBipyf()==0) {
|
System.out.println(saleCredit.getEntrustCode() + "开始推送bip应付蓝票");
|
try {
|
boolean b = pushBipYF(saleCredit.getId(), saleCredit.getInvoicUrl());
|
if(b){
|
System.out.println(saleCredit.getEntrustCode() + "推送bip应付蓝票成功");
|
result.setPushBipyf(1);
|
invoiceResultService.updateById(result);
|
return true;
|
}else {
|
System.out.println(saleCredit.getEntrustCode() + "推送bip应付蓝票失败");
|
return false;
|
}
|
}catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
}
|
}else {
|
Map<String, Object> objectMap = downInvoiceMethod(result);
|
Boolean success = (Boolean) objectMap.get("success");
|
String message = (String) objectMap.get("message");
|
String url = (String) objectMap.get("url");
|
if(success){
|
try {
|
if(type==0){
|
boolean b = pushBipYS(saleCredit.getId(),url);
|
if(b){
|
System.out.println(saleCredit.getEntrustCode()+"推送bip应收蓝票成功");
|
result.setPushBip(1);
|
invoiceResultService.updateById(result);
|
return true;
|
}else {
|
System.out.println(saleCredit.getEntrustCode()+"推送bip应收蓝票失败");
|
return false;
|
}
|
|
}else if (type==1){
|
boolean b = pushBipYF(saleCredit.getId(),url);
|
if(b){
|
System.out.println(saleCredit.getEntrustCode()+"推送bip应付蓝票成功");
|
result.setPushBipyf(1);
|
invoiceResultService.updateById(result);
|
return true;
|
}else {
|
System.out.println(saleCredit.getEntrustCode()+"推送bip应付蓝票失败");
|
return false;
|
}
|
}
|
}catch (Exception e){
|
e.printStackTrace();
|
}
|
}
|
}
|
}
|
return false;
|
}
|
|
/**
|
* 推送bip应收蓝票
|
* @param id
|
* @param file
|
*/
|
public boolean pushBipYS(Long id,String file){
|
//应收
|
QueryWrapper<BipInvoice> bipInvoiceQueryWrapper = new QueryWrapper<>();
|
bipInvoiceQueryWrapper.lambda()
|
.eq(BipInvoice::getRailwayEntrustId, id)
|
.eq(BipInvoice::getInvoiceType, 0)
|
.in(BipInvoice::getResStatus, 200, 910)
|
.orderByDesc(BipInvoice::getCreateTime);
|
List<BipInvoice> list1 = bipInvoiceService.list(bipInvoiceQueryWrapper);
|
if(list1!=null && list1.size()>0){
|
BipInvoice bipInvoice = list1.get(0);
|
String bipNumber = bipInvoice.getBipNumber();
|
fileUploadService.uploadUrlToBip(id,bipNumber,file);
|
return true;
|
}else {
|
return false;
|
}
|
}
|
|
/**
|
* 推送bip应付蓝票
|
* @param id
|
* @param file
|
*/
|
public boolean pushBipYF(Long id,String file){
|
//应付
|
QueryWrapper<BipInvoice> bipInvoiceQueryWrapper1 = new QueryWrapper<>();
|
bipInvoiceQueryWrapper1.lambda()
|
.eq(BipInvoice::getRailwayEntrustId, id)
|
.eq(BipInvoice::getInvoiceType, 1)
|
.in(BipInvoice::getResStatus, 200, 910)
|
.orderByDesc(BipInvoice::getCreateTime);
|
List<BipInvoice> list2 = bipInvoiceService.list(bipInvoiceQueryWrapper1);
|
if(list2!=null && list2.size()>0){
|
BipInvoice bipInvoice = list2.get(0);
|
String bipNumber = bipInvoice.getBipNumber();
|
fileUploadService.uploadUrlToBip(id,bipNumber,file);
|
return true;
|
}else {
|
return false;
|
}
|
}
|
|
/**
|
* 红冲开票接口
|
*/
|
Map<String,Object> redTicketKaiPiao(InvoicingVo vo){
|
SaleCredit saleCredit = saleCreditService.getById(vo.getSaleCreditId());
|
Gson gson =new Gson();
|
String str = gson.toJson(vo);
|
System.out.println(str);
|
String responseBody = "";
|
responseBody = HttpRequest.post(invoiceIp+kpUrl+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 invoiceResult = new InvoiceResult();
|
invoiceResult.setRequestId(requestId);
|
invoiceResult.setSuccess(flag);
|
invoiceResult.setMessage((String) message.get("errorMessage"));
|
invoiceResult.setMethodName("红字开票接口");
|
invoiceResult.setEntrustCode(vo.getEntrustCode());
|
invoiceResultService.save(invoiceResult);
|
|
/*UpdateWrapper<RailwayEntrust> updateWrapper = new UpdateWrapper<>();
|
updateWrapper.lambda()
|
.set(RailwayEntrust::getInvoiceRemark,(String) message.get("errorMessage"))
|
.eq(RailwayEntrust::getEntrustCode,invoiceResult.getEntrustCode());
|
railwayEntrustMapper.update(null,updateWrapper);*/
|
|
saleCredit.setInvoiceRemark((String) message.get("errorMessage"));
|
saleCreditService.updateById(saleCredit);
|
|
return res;
|
}else {
|
String successMessage = (String)message.get("successMessage");
|
JSONObject model = jsonObj.getJSONObject("model");
|
JSONArray success = model.getJSONArray("success");
|
JSONObject modelObject = success.getJSONObject(0);
|
String invoiceTypeCode = (String) modelObject.get("invoiceTypeCode");
|
String invoiceNo = (String) modelObject.get("invoiceNo");
|
String invoiceDate = (String) modelObject.get("invoiceDate");
|
String invoiceQrCode = (String) modelObject.get("invoiceQrCode");
|
String serialNo = (String) modelObject.get("serialNo");
|
BigDecimal invoiceTotalPriceValue = (BigDecimal) modelObject.get("invoiceTotalPrice");
|
Double invoiceTotalPrice = Double.valueOf(invoiceTotalPriceValue.doubleValue());
|
BigDecimal invoiceTotalTaxValue = (BigDecimal) modelObject.get("invoiceTotalTax");
|
Double invoiceTotalTax = Double.valueOf(invoiceTotalTaxValue.doubleValue());
|
BigDecimal invoiceTotalPriceTaxValue = (BigDecimal) modelObject.get("invoiceTotalPriceTax");
|
Double invoiceTotalPriceTax = Double.valueOf(invoiceTotalPriceTaxValue.doubleValue());
|
String mulPurchaserMark = (String) modelObject.get("mulPurchaserMark");
|
String sellerTaxNo = (String) modelObject.get("sellerTaxNo");
|
|
InvoiceResult issueRedResult = new InvoiceResult();
|
issueRedResult.setRequestId(requestId);
|
issueRedResult.setSuccess(flag);
|
issueRedResult.setMessage(successMessage);
|
issueRedResult.setInvoiceNo(invoiceNo);
|
issueRedResult.setInvoiceTyCode(invoiceTypeCode);
|
issueRedResult.setInvoiceDate(invoiceDate);
|
issueRedResult.setInvoiceQrCode(invoiceQrCode);
|
issueRedResult.setSerialNo(serialNo);
|
issueRedResult.setMethodName("红字开票接口");
|
issueRedResult.setEntrustCode(vo.getEntrustCode());
|
issueRedResult.setInvoiceTotalPrice(invoiceTotalPrice);
|
issueRedResult.setInvoiceTotalTax(invoiceTotalTax);
|
issueRedResult.setInvoiceTotalPriceTax(invoiceTotalPriceTax);
|
issueRedResult.setMulPurchaserMark(mulPurchaserMark);
|
issueRedResult.setXTaxNo(sellerTaxNo);
|
invoiceResultService.save(issueRedResult);
|
|
|
JSONArray invoiceDetailList1 = modelObject.getJSONArray("invoiceDetailsList");
|
for (int i = 0; i < invoiceDetailList1.size(); i++) {
|
JSONObject jsonObject = invoiceDetailList1.getJSONObject(i);
|
int goodsLineNo = (int) jsonObject.get("goodsLineNo");
|
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 && goodsTaxRate==0.13){
|
name = "取送车费";
|
}
|
if(goodsTaxRate==0.6){
|
name = "专线费";
|
}
|
|
InvoiceResultItem item = new InvoiceResultItem();
|
item.setGoodsLineNature(invoiceLineNature);
|
item.setGoodsCode(goodsCode);
|
item.setGoodsPrice(goodsPrice);
|
item.setGoodsType(name);
|
if(goodsSpecification != null){
|
item.setGoodsSpecification(goodsSpecification);
|
}
|
if(coalType !=null){
|
item.setCoalType(coalType);
|
}
|
if(agreementTerm !=null){
|
item.setAgreementTerm(agreementTerm);
|
}
|
item.setGoodsLineNo(goodsLineNo);
|
item.setGoodsQuantity(goodsQuantity);
|
item.setGoodsTaxRate(goodsTaxRate);
|
item.setGoodsName(goodsName);
|
item.setGoodsTotalPrice(goodsTotalPrice);
|
item.setGoodsTotalTax(goodsTotalTax);
|
item.setGoodsUnit(goodsUnit);
|
item.setResultId(issueRedResult.getId());
|
item.setEntrustCode(issueRedResult.getEntrustCode());
|
String[] split = goodsName.split("\\*");
|
int length = split.length;
|
String coalName = split[length - 1];
|
item.setCoalName(coalName);
|
itemMapper.insert(item);
|
}
|
|
QueryWrapper<InvoiceResult> invoiceResultQueryWrapper = new QueryWrapper<>();
|
invoiceResultQueryWrapper.lambda()
|
.eq(InvoiceResult::getEntrustCode,issueRedResult.getEntrustCode())
|
.eq(InvoiceResult::getMethodName,"蓝字开票接口");
|
List<InvoiceResult> list = invoiceResultService.list(invoiceResultQueryWrapper);
|
List<Long> collect = list.stream().map(item -> item.getId()).collect(Collectors.toList());
|
removeByIds(collect);
|
|
/*UpdateWrapper<RailwayEntrust> updateWrapper = new UpdateWrapper<>();
|
updateWrapper.lambda().set(RailwayEntrust::getInvoiceResult,null)
|
.set(RailwayEntrust::getInvoiceResultId,null)
|
.set(RailwayEntrust::getInvoiceRemark,"红字开票成功")
|
.set(RailwayEntrust::getInvoiceRedResult,2)
|
.set(RailwayEntrust::getInvoicUrl,null)
|
.set(RailwayEntrust::getInvoiceRedResultId,issueRedResult.getId())
|
.eq(RailwayEntrust::getEntrustCode,issueRedResult.getEntrustCode());
|
railwayEntrustMapper.update(null,updateWrapper);*/
|
|
saleCredit.setInvoiceRemark("红字开票成功");
|
saleCredit.setRedInvoiceResultId(issueRedResult.getId());
|
saleCredit.setStatus(7);
|
saleCreditService.updateById(saleCredit);
|
|
Map<String,Object> res = new HashMap<>();
|
res.put("success",flag);
|
res.put("message",successMessage);
|
return res;
|
}
|
}else {
|
Map<String,Object> res = new HashMap<>();
|
res.put("success",false);
|
res.put("message","红字开票接口异常");
|
InvoiceResult invoiceResult = new InvoiceResult();
|
invoiceResult.setSuccess(false);
|
invoiceResult.setMessage("红字开票接口异常");
|
invoiceResult.setMethodName("红字开票接口");
|
invoiceResult.setEntrustCode(vo.getEntrustCode());
|
invoiceResultService.save(invoiceResult);
|
|
/* QueryWrapper<RailwayEntrust> wrapper = new QueryWrapper<>();
|
wrapper.lambda().eq(RailwayEntrust::getEntrustCode,invoiceResult.getEntrustCode());
|
RailwayEntrust railwayEntrust = railwayEntrustMapper.selectList(wrapper).get(0);
|
railwayEntrust.setInvoiceRemark("红字开票接口异常");
|
railwayEntrustMapper.updateById(railwayEntrust);*/
|
|
saleCredit.setInvoiceRemark("红字开票接口异常");
|
saleCredit.setStatus(6);
|
saleCreditService.updateById(saleCredit);
|
|
|
return res;
|
}
|
|
}
|
|
/**
|
* 数电红字确认单新增接口
|
*/
|
Map<String,Object> redTicketConfirm(InvoiceResult invoiceResult,SaleCredit 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"));
|
saleCreditService.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("红字确认单新增接口异常");
|
saleCreditService.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("红字确认单新增接口异常");
|
saleCreditService.updateById(saleCredit);
|
return res;
|
}
|
}
|
|
/**
|
* 数电红字确认单新增接口
|
*/
|
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){
|
/* 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("红字确认单确认接口异常");
|
saleCreditService.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());
|
saleCreditService.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("红字确认单确认接口异常");
|
saleCreditService.updateById(saleCredit);
|
return res;
|
}
|
|
}
|
|
/**
|
* 数电红字确认单查询接口
|
*/
|
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
|
*/
|
InvoicingVo redKaiPiaoVo(InvoiceResult result){
|
SaleCredit saleCredit = saleCreditService.getById(result.getSaleCreditId());
|
InvoiceResult blueResult = null;
|
InvoiceResult redResult = null;
|
QueryWrapper<InvoiceResult> invoiceResultQueryWrapper = new QueryWrapper<>();
|
invoiceResultQueryWrapper.lambda()
|
.eq(InvoiceResult::getEntrustCode,result.getEntrustCode())
|
.eq(InvoiceResult::getMethodName,"蓝字开票接口")
|
.eq(InvoiceResult::getSuccess,1)
|
.orderByDesc(InvoiceResult::getCreateTime);
|
List<InvoiceResult> InvoiceResultList = invoiceResultService.list(invoiceResultQueryWrapper);
|
if(InvoiceResultList!=null&&InvoiceResultList.size()>0){
|
blueResult = InvoiceResultList.get(0);
|
redResult = result;
|
}else {
|
return null;
|
}
|
|
|
InvoicingVo invoicingVo = new InvoicingVo();
|
|
QueryWrapper<InvoiceResultItem> itemQueryWrapper = new QueryWrapper<>();
|
itemQueryWrapper.lambda()
|
.eq(InvoiceResultItem::getResultId,blueResult.getId());
|
List<InvoiceResultItem> resultItems = itemMapper.selectList(itemQueryWrapper);
|
|
if(saleCredit!=null) {
|
|
invoicingVo.setTaxNo(saleCredit.getCreditCodeB());
|
invoicingVo.setEntrustCode(blueResult.getEntrustCode());
|
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.setInvoiceType("1");
|
invoicingVoInfo.setSerialNo("MX_REDPP_" + System.currentTimeMillis());
|
invoicingVoInfo.setRedInfoNo(redResult.getInvoiceNo());
|
invoicingVoInfo.setRedIssueReason("1");
|
invoicingVoInfo.setRedConfirmUuid(redResult.getRedConfirmUuid());
|
invoicingVoInfo.setDrawer(saleCredit.getContactPhoneB());
|
|
Map<String, Object> ext1 = new HashMap<>();
|
ext1.put("htbh",saleCredit.getContractNo());
|
invoicingVoInfo.setExt(ext1);
|
|
invoicingVoInfo.setSystemName("**销售管理信息系统");
|
|
List<InvoicingVo.InvoiceDetail> details = new ArrayList<>();
|
for (InvoiceResultItem resultItem : resultItems) {
|
InvoicingVo.InvoiceDetail invoiceDetail = new InvoicingVo.InvoiceDetail();
|
invoiceDetail.setGoodsLineNo(resultItem.getGoodsLineNo());
|
invoiceDetail.setCoalType(resultItem.getCoalType());
|
invoiceDetail.setAgreementTerm(resultItem.getAgreementTerm());
|
invoiceDetail.setOriginalInvoiceDetailNo(resultItem.getGoodsLineNo()+"");
|
invoiceDetail.setGoodsTaxRate(resultItem.getGoodsTaxRate());
|
invoiceDetail.setGoodsUnit(resultItem.getGoodsUnit());
|
invoiceDetail.setGoodsName(resultItem.getCoalName());
|
invoiceDetail.setGoodsCode(resultItem.getGoodsCode());
|
invoiceDetail.setGoodsType(resultItem.getGoodsType());
|
invoiceDetail.setGoodsSpecification(resultItem.getGoodsSpecification());
|
invoiceDetail.setGoodsQuantity(new BigDecimal(resultItem.getGoodsQuantity()*-1).setScale(3,BigDecimal.ROUND_HALF_UP));
|
invoiceDetail.setGoodsPrice(new BigDecimal(resultItem.getGoodsPrice()).setScale(8,BigDecimal.ROUND_HALF_UP));
|
invoiceDetail.setGoodsTotalPrice(new BigDecimal(resultItem.getGoodsTotalPrice()*-1).setScale(2,BigDecimal.ROUND_HALF_UP));
|
invoiceDetail.setGoodsTotalTax(new BigDecimal(resultItem.getGoodsTotalTax()*-1).setScale(2,BigDecimal.ROUND_HALF_UP));
|
details.add(invoiceDetail);
|
}
|
|
invoicingVoInfo.setBuyerTaxNo(saleCredit.getCreditCodeA());
|
invoicingVoInfo.setBuyerName(saleCredit.getPartyA());
|
invoicingVoInfo.setInvoiceTotalPrice(new BigDecimal(blueResult.getInvoiceTotalPrice()*-1).setScale(2,BigDecimal.ROUND_HALF_UP));
|
invoicingVoInfo.setInvoiceTotalTax(new BigDecimal(blueResult.getInvoiceTotalTax()*-1).setScale(2,BigDecimal.ROUND_HALF_UP));
|
invoicingVoInfo.setInvoiceTotalPriceTax(new BigDecimal(blueResult.getInvoiceTotalPriceTax()*-1).setScale(2,BigDecimal.ROUND_HALF_UP));
|
invoicingVoInfo.setBuyerBankName(saleCredit.getBankNameA());
|
invoicingVoInfo.setBuyerBankNumber(saleCredit.getBankAccountA());
|
//invoicingVoInfo.setBuyerAddress(invoiceCustomer.getBuyerAddress());
|
invoicingVoInfo.setBuyerTelphone(saleCredit.getContactPhoneA());
|
invoicingVoInfo.setInvoiceDetailsList(details);
|
/*if(invoicingVoInfo.getInvoiceTotalPriceTax().compareTo(new BigDecimal(10000000))>=0){
|
invoicingVoInfo.setCoalCalorificValue(blueResult.getCoalCalorificValue());
|
invoicingVoInfo.setDryAshFreeVolatileMatter(blueResult.getDryAshFreeVolatileMatter());
|
invoicingVoInfo.setTotalSulfurOnDryBasis(blueResult.getTotalSulfurOnDryBasis());
|
}*/
|
invoicingVo.setData(invoicingVoInfo);
|
return invoicingVo;
|
}else {
|
return null;
|
}
|
}
|
|
/**
|
* 时间格式化工具
|
* @param s
|
* @return
|
*/
|
String strToFormat(String s){
|
String year = s.substring(0, 4);
|
String month = s.substring(4, 6);
|
String day = s.substring(6, 8);
|
String hour = s.substring(8, 10);
|
String minute = s.substring(10, 12);
|
String second = s.substring(12);
|
String date = year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second;
|
System.out.println(date);
|
return date;
|
}
|
}
|