数电开票

beta-enc
dongxiaoke 2 years ago
parent 1e454d9567
commit c918d8ed1c
  1. 3
      jianshui-admin/src/main/java/com/jianshui/web/controller/platform/InvoiceAddController.java
  2. 5
      jianshui-income/src/main/java/com/jianshui/income/service/impl/EleCheckInvoiceImpl.java
  3. 29
      jianshui-invoice/src/main/java/com/jianshui/invoice/enums/ChannelSource.java
  4. 4
      jianshui-platform/src/main/java/com/jianshui/platform/service/InvoiceAddService.java
  5. 77
      jianshui-platform/src/main/java/com/jianshui/platform/service/impl/InvoiceAddServiceImpl.java

@ -2,6 +2,7 @@ package com.jianshui.web.controller.platform;
import com.jianshui.common.core.controller.BaseController;
import com.jianshui.common.core.domain.AjaxResult;
import com.jianshui.invoice.domain.dto.HXResponse;
import com.jianshui.platform.dto.InvoiceAdd.BillInfoPDTO;
import com.jianshui.platform.service.InvoiceAddService;
import io.swagger.annotations.*;
@ -29,7 +30,7 @@ public class InvoiceAddController extends BaseController {
@ApiOperation(value = "发票开具",notes = "发票直接开具请求(支持数电普票、数电专票)")
@PostMapping( "invoiceIssuance")
public AjaxResult invoiceIssuance(@RequestBody BillInfoPDTO billInfoPDTO) throws Exception {
public HXResponse invoiceIssuance(@RequestBody BillInfoPDTO billInfoPDTO) throws Exception {
return addService.invoiceIssuance(billInfoPDTO);
}

@ -182,15 +182,16 @@ public class EleCheckInvoiceImpl implements ICheckInvoice {
return new AjaxResult(Integer.parseInt(invoiceCheck.getCyjg()),invoiceCheck.getCyjgxx());
}
// TODO: 2023/6/7 测试关闭
// :校验是否查询本企业发票
String xhfsbh = StrUtil.blankToDefault(invoiceCheck.getXhfsbh(), "");
/*String xhfsbh = StrUtil.blankToDefault(invoiceCheck.getXhfsbh(), "");
String xhfmc = StrUtil.blankToDefault(invoiceCheck.getXhfmc(), "");
String sellerTax = companyservice.getSellertax();
String sellerName = companyservice.getSellername();
if (!sellerTax.equals(xhfsbh) || !StrUtil.equalsIgnoreCase(sellerName, xhfmc)) {
log.info("单个发票校验非本企业发票:companyId=" + companyId + ",errorCode=" + invoiceCheck.getCyjg() + ",returnMessage=" + invoiceCheck.getCyjgxx());
return new AjaxResult(34,"授权企业与所查询发票的购方不一致,请进行核实");
}
}*/
// 更新成功处理返回数据
return AjaxResult.success(result);

@ -0,0 +1,29 @@
package com.jianshui.invoice.enums;
/**
* @Author: kk
* @Description: 上游通道选择枚举
* @DateTime: 2023/6/8 9:39
* @Params:
* @Return
*/
public enum ChannelSource {
PLATFORM("2", "简税产品平台");
private final String code;
private final String desc;
ChannelSource(String code, String desc) {
this.code = code;
this.desc = desc;
}
public String getCode() {
return code;
}
public String getDesc() {
return desc;
}
}

@ -1,7 +1,7 @@
package com.jianshui.platform.service;
import com.jianshui.common.core.domain.AjaxResult;
import com.jianshui.invoice.domain.dto.HXResponse;
import com.jianshui.platform.dto.InvoiceAdd.BillInfoPDTO;
/**
@ -29,7 +29,7 @@ public interface InvoiceAddService {
* @Params:
* @Return
*/
AjaxResult invoiceIssuance(BillInfoPDTO billInfoPDTO);
HXResponse invoiceIssuance(BillInfoPDTO billInfoPDTO);

@ -1,34 +1,49 @@
package com.jianshui.platform.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSONObject;
import com.jianshui.common.core.domain.AjaxResult;
import com.jianshui.common.core.domain.entity.Companyservice;
import com.jianshui.common.enums.ErrorCode;
import com.jianshui.common.exception.jianshui.JianshuiParamErrorException;
import com.jianshui.common.exception.jianshui.JianshuiServiceException;
import com.jianshui.common.utils.SecurityUtils;
import com.jianshui.common.utils.ValidateUtils;
import com.jianshui.invoice.domain.BillInfo;
import com.jianshui.invoice.domain.dto.HXResponse;
import com.jianshui.invoice.enums.ChannelSource;
import com.jianshui.invoice.factory.IInvoiceServiceFactory;
import com.jianshui.invoice.mapper.BillInfoMapper;
import com.jianshui.invoice.service.IInvoiceApiService;
import com.jianshui.invoice.service.IInvoiceRequestService;
import com.jianshui.invoice.service.IInvoiceResponseService;
import com.jianshui.platform.dto.InvoiceAdd.BillInfoPDTO;
import com.jianshui.platform.service.InvoiceAddService;
import com.jianshui.platform.utils.InvoiceAllYhdjUtils;
import com.jianshui.system.domain.InvoiceAllYhdj;
import com.jianshui.system.mapper.CompanyserviceMapper;
import com.jianshui.system.service.IServiceManageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Optional;
/**
* 发票录入
*
*/
@Service
@Slf4j
public class InvoiceAddServiceImpl implements InvoiceAddService {
@Autowired
private static BillInfoMapper billInfoMapper;
@Autowired
private IServiceManageService serviceManageService;
@Autowired
private IInvoiceServiceFactory invoiceServiceFactory;
@Autowired
private CompanyserviceMapper companyServiceMapper;
@Override
public int invoiceSave(BillInfoPDTO billInfoPDTO) {
ValidateUtils.validate(billInfoPDTO);
@ -41,16 +56,48 @@ public class InvoiceAddServiceImpl implements InvoiceAddService {
}
@Override
public AjaxResult invoiceIssuance(BillInfoPDTO billInfoPDTO) {
public HXResponse invoiceIssuance(BillInfoPDTO billInfoPDTO) {
BillInfo billInfo = BeanUtil.copyProperties(billInfoPDTO, BillInfo.class);
billInfo.setSource(ChannelSource.PLATFORM.getCode());
// 获取用户信息
Long companyId = Optional.ofNullable(SecurityUtils.getLoginUser())
.map(loginUser -> loginUser.getCompanyId())
.orElse(0L);
if (companyId == 0L) {
return new HXResponse("未获取到用户服务信息,请联系管理员配置!");
}
Companyservice companyservice = companyServiceMapper.selectCompanyserviceByCompanyid(companyId);
if (BeanUtil.isEmpty(companyservice)) {
return new HXResponse(("未获取到用户服务信息,请联系管理员配置!"));
}
// TODO: 2023/6/8 这里看看多通道的时候怎么处理
InvoiceAllYhdjUtils invoiceAllYhdjUtils = new InvoiceAllYhdjUtils();
InvoiceAllYhdj userInfo = invoiceAllYhdjUtils.getUserInfo(companyservice);
if (BeanUtil.isEmpty(userInfo)) {
return new HXResponse(("未查询到登记信息!"));
}
// 获得请求实例,并且进行扣费
String serviceKey = null;
try {
serviceKey = serviceManageService.getCompanyServiceSupplier("invoice", companyservice.getCompanyid());
serviceManageService.companyConsume("invoice", companyId);
billInfo.setServiceSupplierKey(serviceKey);
IInvoiceApiService invoiceService = invoiceServiceFactory.getService(serviceKey);
return invoiceService.addInvoice(billInfo, companyservice);
} catch (Exception e) {
log.error("简税产品端,发票开具失败,请求报文={},企业税号={},servicekey={}",billInfoPDTO.toString(),companyservice.toString(),serviceKey);
throw new JianshuiServiceException("发票开具系统异常!");
}
return null;
}
@ -61,8 +108,4 @@ public class InvoiceAddServiceImpl implements InvoiceAddService {
}

Loading…
Cancel
Save