|
@@ -50,9 +50,9 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
|
|
|
@Autowired
|
|
|
private UserService userService;
|
|
|
@Value("${invoice.print.url}")
|
|
|
- private String printUrl;
|
|
|
+ private String printUrl;
|
|
|
@Autowired
|
|
|
- private BaseClosingAccountInfoService baseClosingAccountInfoService;
|
|
|
+ private BaseClosingAccountInfoService baseClosingAccountInfoService;
|
|
|
|
|
|
private Map<String, String> getPrintParam(Integer siteId, Integer customerId) {
|
|
|
Map<String, String> map = new HashMap<>();
|
|
@@ -90,8 +90,9 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
|
|
|
Map<Integer, PayInvoiceParam> map = new HashMap<>();
|
|
|
List<PayInvoiceParam> payInvoiceParams = payInvoiceParamService.findList(null, siteId, customerId);
|
|
|
for (PayInvoiceParam item : payInvoiceParams) {
|
|
|
- if(item.getTaxrate()!=null) {
|
|
|
- BigDecimal taxRate = BigDecimal.valueOf(Long.parseLong(item.getTaxrate())).setScale(2, BigDecimal.ROUND_HALF_UP);;
|
|
|
+ if (item.getTaxrate() != null) {
|
|
|
+ BigDecimal taxRate = BigDecimal.valueOf(Long.parseLong(item.getTaxrate())).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ ;
|
|
|
taxRate = taxRate.divide(BigDecimal.valueOf(100));
|
|
|
item.setTaxrate(String.valueOf(taxRate));
|
|
|
}
|
|
@@ -114,30 +115,27 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
|
|
|
* @Author:
|
|
|
* @Date: 2020/7/28
|
|
|
*/
|
|
|
- public ReturnPrintResultDto requestPrint(String siteId, String customerId, String kpType, String userCode, String payseriesno, String invoicePrintId,String email) {
|
|
|
+ public ReturnPrintResultDto requestPrint(String siteId, String customerId, String kpType, String userCode, String payseriesno, String invoicePrintId, String email) {
|
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
ReturnPrintResultDto returnPrintResultDto = new ReturnPrintResultDto();//开票返回结果信息
|
|
|
|
|
|
- if(loginUser==null) {
|
|
|
- User user = userService.findUserByName("系统操作", BigInteger.valueOf(Long.parseLong(siteId)));
|
|
|
- loginUser = new LoginUser();
|
|
|
- if(user!=null)
|
|
|
- {
|
|
|
- loginUser.setName("系统操作");
|
|
|
- loginUser.setId(user.getId());
|
|
|
- }else
|
|
|
- {
|
|
|
- returnPrintResultDto.setResult("1");//开票失败
|
|
|
- returnPrintResultDto.setMsg("开票失败,失败原因:系统未配置操作员");
|
|
|
- return returnPrintResultDto;
|
|
|
- }
|
|
|
+ if (loginUser == null) {
|
|
|
+ User user = userService.findUserByName("系统操作", BigInteger.valueOf(Long.parseLong(siteId)));
|
|
|
+ loginUser = new LoginUser();
|
|
|
+ if (user != null) {
|
|
|
+ loginUser.setName("系统操作");
|
|
|
+ loginUser.setId(user.getId());
|
|
|
+ } else {
|
|
|
+ returnPrintResultDto.setResult("1");//开票失败
|
|
|
+ returnPrintResultDto.setMsg("开票失败,失败原因:系统未配置操作员");
|
|
|
+ return returnPrintResultDto;
|
|
|
+ }
|
|
|
loginUser.setCustomerId(Integer.valueOf(customerId));
|
|
|
loginUser.setSiteId(Integer.valueOf(siteId));
|
|
|
}
|
|
|
String name = loginUser.getName();//操作员姓名
|
|
|
- BaseClosingAccountInfo baseClosingAccountInfo = baseClosingAccountInfoService.getCurrentCloseInfo(loginUser.getSiteId(),loginUser.getCustomerId());
|
|
|
- if(baseClosingAccountInfo==null)
|
|
|
- {
|
|
|
+ BaseClosingAccountInfo baseClosingAccountInfo = baseClosingAccountInfoService.getCurrentCloseInfo(loginUser.getSiteId(), loginUser.getCustomerId());
|
|
|
+ if (baseClosingAccountInfo == null) {
|
|
|
returnPrintResultDto.setResult("1");//开票失败
|
|
|
returnPrintResultDto.setMsg("开票失败,失败原因:账期信息查询失败");
|
|
|
return returnPrintResultDto;
|
|
@@ -150,8 +148,7 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
|
|
|
Map<String, String> invoiceParam = getPrintParam(loginUser.getSiteId(), loginUser.getCustomerId());//销方开票信息
|
|
|
Map<Integer, PayInvoiceParam> invoiceMap = getInvoiceParam(loginUser.getSiteId(), loginUser.getCustomerId());//税率相关参数
|
|
|
payEleInvoiceDto.setIdentity(invoiceParam.get("saleIdentity"));//认证信息
|
|
|
- if(invoiceParam.get("saleIdentity")==null)
|
|
|
- {
|
|
|
+ if (invoiceParam.get("saleIdentity") == null) {
|
|
|
returnPrintResultDto.setResult("1");//开票失败
|
|
|
returnPrintResultDto.setMsg("开票失败,失败原因:认证信息缺失");
|
|
|
return returnPrintResultDto;
|
|
@@ -266,7 +263,7 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
|
|
|
return returnPrintResultDto;
|
|
|
}
|
|
|
payInvoiceOrderDto.setDetail(orderDetailDtos);
|
|
|
- if(email!=null&& email.length()>0)
|
|
|
+ if (email != null && email.length() > 0)
|
|
|
payInvoiceOrderDto.setEmail(email);
|
|
|
else {
|
|
|
if (payBaseAccount.getEmail() != null)
|
|
@@ -279,8 +276,18 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
|
|
|
String jsonsString = DESDZFP.encrypt(JSON.toJSONString(payEleInvoiceDto));
|
|
|
Map<String, String> map = new HashMap<String, String>();
|
|
|
map.put("order", jsonsString);
|
|
|
+ //查询开票地址
|
|
|
+ List<PayBaseConfigDto> payBaseConfigDtos = payBaseConfigService.getPrintInfo("PRINT_INVOICE_URL", loginUser.getSiteId(), loginUser.getCustomerId());
|
|
|
+ String invoiceUrl = "";
|
|
|
+ if (payBaseConfigDtos.size() == 0) {
|
|
|
+ returnPrintResultDto.setResult("1");//开票失败
|
|
|
+ returnPrintResultDto.setMsg("开票失败,失败原因:发票开票地址缺失");
|
|
|
+ return returnPrintResultDto;
|
|
|
+ } else {
|
|
|
+ invoiceUrl = payBaseConfigDtos.get(0).getValue();
|
|
|
+ }
|
|
|
try {
|
|
|
- String returnString = HttpClientUtils.doPost(printUrl, map);
|
|
|
+ String returnString = HttpClientUtils.doPost(invoiceUrl, map);
|
|
|
JSONObject jsonObject = (JSONObject) JSON.parse(returnString);
|
|
|
PayInvoiceprinted payInvoiceprinted = new PayInvoiceprinted();//发票信息
|
|
|
payInvoiceprinted.setTaxnum(payInvoiceOrderDto.getTaxnum());
|