|
@@ -3,12 +3,11 @@ package com.zcxk.rmcp.pay.service.impl.pay;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.zcxk.rmcp.pay.commom.util.*;
|
|
import com.zcxk.rmcp.pay.commom.util.*;
|
|
|
|
+import com.zcxk.rmcp.pay.dao.pay.MeasurementInstanceMapper;
|
|
import com.zcxk.rmcp.pay.dto.LoginUser;
|
|
import com.zcxk.rmcp.pay.dto.LoginUser;
|
|
import com.zcxk.rmcp.pay.dto.pay.*;
|
|
import com.zcxk.rmcp.pay.dto.pay.*;
|
|
import com.zcxk.rmcp.pay.entity.User;
|
|
import com.zcxk.rmcp.pay.entity.User;
|
|
-import com.zcxk.rmcp.pay.entity.pay.BaseClosingAccountInfo;
|
|
|
|
-import com.zcxk.rmcp.pay.entity.pay.PayInvoiceParam;
|
|
|
|
-import com.zcxk.rmcp.pay.entity.pay.PayInvoiceprinted;
|
|
|
|
|
|
+import com.zcxk.rmcp.pay.entity.pay.*;
|
|
import com.zcxk.rmcp.pay.entity.pay.archives.PayBaseCustomerandmeterrela;
|
|
import com.zcxk.rmcp.pay.entity.pay.archives.PayBaseCustomerandmeterrela;
|
|
import com.zcxk.rmcp.pay.service.UserService;
|
|
import com.zcxk.rmcp.pay.service.UserService;
|
|
import com.zcxk.rmcp.pay.service.pay.*;
|
|
import com.zcxk.rmcp.pay.service.pay.*;
|
|
@@ -16,7 +15,9 @@ import com.zcxk.rmcp.pay.service.pay.archives.PayBaseCustomerandmeterrelaService
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigInteger;
|
|
import java.math.BigInteger;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
@@ -56,6 +57,8 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
|
|
private String printUrl;
|
|
private String printUrl;
|
|
@Autowired
|
|
@Autowired
|
|
private BaseClosingAccountInfoService baseClosingAccountInfoService;
|
|
private BaseClosingAccountInfoService baseClosingAccountInfoService;
|
|
|
|
+ @Resource
|
|
|
|
+ private MeasurementSettlementService measurementSettlementService;
|
|
|
|
|
|
private Map<String, String> getPrintParam(String tenantId) {
|
|
private Map<String, String> getPrintParam(String tenantId) {
|
|
Map<String, String> map = new HashMap<>();
|
|
Map<String, String> map = new HashMap<>();
|
|
@@ -131,9 +134,9 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
|
|
loginUser.setCustomerId(Integer.valueOf(customerId));
|
|
loginUser.setCustomerId(Integer.valueOf(customerId));
|
|
loginUser.setSiteId(Integer.valueOf(siteId));
|
|
loginUser.setSiteId(Integer.valueOf(siteId));
|
|
}
|
|
}
|
|
- String name = loginUser.getName();//操作员姓名
|
|
|
|
- BaseClosingAccountInfo baseClosingAccountInfo = baseClosingAccountInfoService.getCurrentCloseInfo(loginUser.getSiteId(), loginUser.getCustomerId());
|
|
|
|
- if (baseClosingAccountInfo == null) {
|
|
|
|
|
|
+ String name = loginUser.getUsername();//操作员姓名
|
|
|
|
+ BaseClosingAccountInfo baseClosingAccountInfo=measurementSettlementService.findHistory();
|
|
|
|
+ if (baseClosingAccountInfo==null) {
|
|
returnPrintResultDto.setResult("1");//开票失败
|
|
returnPrintResultDto.setResult("1");//开票失败
|
|
returnPrintResultDto.setMsg("开票失败,失败原因:账期信息查询失败");
|
|
returnPrintResultDto.setMsg("开票失败,失败原因:账期信息查询失败");
|
|
return returnPrintResultDto;
|
|
return returnPrintResultDto;
|
|
@@ -169,7 +172,7 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
|
|
}
|
|
}
|
|
|
|
|
|
if (kpType.equals("2")) {//红票按蓝票票ID查询
|
|
if (kpType.equals("2")) {//红票按蓝票票ID查询
|
|
- oldInvoiceprinted = printInvoicePrintService.findInvoiceByPayseriesno(invoicePrintId, BigInteger.valueOf(loginUser.getSiteId()), BigInteger.valueOf(loginUser.getCustomerId()));
|
|
|
|
|
|
+ oldInvoiceprinted = printInvoicePrintService.findInvoiceByPayseriesno(invoicePrintId, null, null);
|
|
if (oldInvoiceprinted != null && oldInvoiceprinted.getInvoiceCode() != null) {
|
|
if (oldInvoiceprinted != null && oldInvoiceprinted.getInvoiceCode() != null) {
|
|
payInvoiceOrderDto.setFpdm(oldInvoiceprinted.getInvoiceCode());
|
|
payInvoiceOrderDto.setFpdm(oldInvoiceprinted.getInvoiceCode());
|
|
payInvoiceOrderDto.setFphm(oldInvoiceprinted.getInvoiceNo());
|
|
payInvoiceOrderDto.setFphm(oldInvoiceprinted.getInvoiceNo());
|
|
@@ -197,7 +200,7 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
|
|
payInvoiceOrderDto.setTaxnum(payBaseAccount.getVatno());//购方税号
|
|
payInvoiceOrderDto.setTaxnum(payBaseAccount.getVatno());//购方税号
|
|
|
|
|
|
//循环加入明细
|
|
//循环加入明细
|
|
- List<PayReceivedInvoiceDto> payReceivedInvoiceDtos = payPayReceivedService.findInvoiceReceivedByPayseriesno(payseriesno, loginUser.getSiteId(), loginUser.getCustomerId());
|
|
|
|
|
|
+ List<PayReceivedInvoiceDto> payReceivedInvoiceDtos = payPayReceivedService.findInvoiceReceivedByPayseriesno(payseriesno, loginUser.getTenantId());
|
|
for (PayReceivedInvoiceDto item : payReceivedInvoiceDtos) {
|
|
for (PayReceivedInvoiceDto item : payReceivedInvoiceDtos) {
|
|
PayInvoiceOrderDetailDto orderDetailDto = new PayInvoiceOrderDetailDto();
|
|
PayInvoiceOrderDetailDto orderDetailDto = new PayInvoiceOrderDetailDto();
|
|
PayInvoiceParam payInvoiceParam = invoiceMap.get(item.getFeetype());
|
|
PayInvoiceParam payInvoiceParam = invoiceMap.get(item.getFeetype());
|
|
@@ -228,7 +231,7 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
|
|
orderDetailDto.setTaxfreeamt(String.valueOf(saveTwoDecimal(receAmount.add(taxAmount).multiply(BigDecimal.valueOf(-1)))));//不含税金额
|
|
orderDetailDto.setTaxfreeamt(String.valueOf(saveTwoDecimal(receAmount.add(taxAmount).multiply(BigDecimal.valueOf(-1)))));//不含税金额
|
|
} else {
|
|
} else {
|
|
orderDetailDto.setTax(String.valueOf(saveTwoDecimal(taxAmount)));//税额
|
|
orderDetailDto.setTax(String.valueOf(saveTwoDecimal(taxAmount)));//税额
|
|
- orderDetailDto.setTaxfreeamt(String.valueOf(saveTwoDecimal(receAmount.add(taxAmount).multiply(BigDecimal.valueOf(-1)))));//不含税金额
|
|
|
|
|
|
+ orderDetailDto.setTaxfreeamt(String.valueOf(saveTwoDecimal(receAmount.add(taxAmount))));//不含税金额
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (item.getPrice() != null) {
|
|
if (item.getPrice() != null) {
|
|
@@ -303,8 +306,7 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
|
|
payInvoiceprinted.setCreateDate(LocalDateTime.now());
|
|
payInvoiceprinted.setCreateDate(LocalDateTime.now());
|
|
payInvoiceprinted.setUpdateBy(BigInteger.valueOf(loginUser.getId()));
|
|
payInvoiceprinted.setUpdateBy(BigInteger.valueOf(loginUser.getId()));
|
|
payInvoiceprinted.setUpdateDate(LocalDateTime.now());
|
|
payInvoiceprinted.setUpdateDate(LocalDateTime.now());
|
|
- payInvoiceprinted.setSiteId(BigInteger.valueOf(loginUser.getSiteId()));
|
|
|
|
- payInvoiceprinted.setCustomerId(BigInteger.valueOf(loginUser.getCustomerId()));
|
|
|
|
|
|
+
|
|
payInvoiceprinted.setDelFlag("0");
|
|
payInvoiceprinted.setDelFlag("0");
|
|
payInvoiceprinted.setRemarks(jsonObject.getString("message"));
|
|
payInvoiceprinted.setRemarks(jsonObject.getString("message"));
|
|
payInvoiceprinted.setType(1); //发票
|
|
payInvoiceprinted.setType(1); //发票
|
|
@@ -314,6 +316,8 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
|
|
payInvoiceprinted.setEmail(payInvoiceOrderDto.getEmail());
|
|
payInvoiceprinted.setEmail(payInvoiceOrderDto.getEmail());
|
|
payInvoiceprinted.setSaleIdentity(invoiceParam.get("saleIdentity"));
|
|
payInvoiceprinted.setSaleIdentity(invoiceParam.get("saleIdentity"));
|
|
payInvoiceprinted.setTenantId(loginUser.getTenantId());
|
|
payInvoiceprinted.setTenantId(loginUser.getTenantId());
|
|
|
|
+ payInvoiceprinted.setCompanyOrgId(loginUser.getCompanyId());
|
|
|
|
+ payInvoiceprinted.setDeptOrgId(loginUser.getDepartmentId());
|
|
if (kpType.equals("2")) {
|
|
if (kpType.equals("2")) {
|
|
payInvoiceprinted.setInvoiceType(2);//红票
|
|
payInvoiceprinted.setInvoiceType(2);//红票
|
|
payInvoiceprinted.setCancelInvoiceId(BigInteger.valueOf(Long.parseLong(invoicePrintId)));
|
|
payInvoiceprinted.setCancelInvoiceId(BigInteger.valueOf(Long.parseLong(invoicePrintId)));
|