Procházet zdrojové kódy

发票打印相关

609324174@qq.com před 4 roky
rodič
revize
b62b8e0b7c

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/quartz/job/InvoicePrintResultJob.java

@@ -28,7 +28,7 @@ public class InvoicePrintResultJob {
     private PrintInvoiceQueryResultServiceImpl printInvoiceQueryResultService;
 
     @Scheduled(cron = "0 0 0/1 * * ?")
-    //@Scheduled(cron = "0 33 15 ? * *")   //定时执行,秒分时日月年
+    //@Scheduled(cron = "0 58 09 ? * *")   //定时执行,秒分时日月年
     private void queryResult() {
         List<PayInvoiceprinted> payInvoiceprinteds = printInvoicePrintService.findListByState();
         for (PayInvoiceprinted item : payInvoiceprinteds) {

+ 32 - 25
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/IssueElectronicInvoiceServiceImpl.java

@@ -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());

+ 21 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayInvoiceParamServiceImpl.java

@@ -123,6 +123,17 @@ public class PayInvoiceParamServiceImpl implements PayInvoiceParamService {
             payBaseConfig.setName("PRINT_EMAIL");
             payBaseConfig.setType("0");
             payBaseConfigService.add(payBaseConfig);
+
+            payBaseConfig.setCnname("发票开票URL");
+            payBaseConfig.setName("PRINT_INVOICE_URL");
+            payBaseConfig.setType("0");
+            payBaseConfigService.add(payBaseConfig);
+
+            payBaseConfig.setCnname("发票开票查询URL");
+            payBaseConfig.setName("PRINT_INVOICE_QUERYURL");
+            payBaseConfig.setType("0");
+            payBaseConfigService.add(payBaseConfig);
+
         } catch (Exception ex) {
             //异常不处理,可手动添加
         }
@@ -184,6 +195,16 @@ public class PayInvoiceParamServiceImpl implements PayInvoiceParamService {
             payBaseConfig.setName("PRINT_EMAIL");
             payBaseConfig.setType("0");
             payBaseConfigService.add(payBaseConfig);
+
+            payBaseConfig.setCnname("发票开票URL");
+            payBaseConfig.setName("PRINT_INVOICE_URL");
+            payBaseConfig.setType("0");
+            payBaseConfigService.add(payBaseConfig);
+
+            payBaseConfig.setCnname("发票开票查询URL");
+            payBaseConfig.setName("PRINT_INVOICE_QUERYURL");
+            payBaseConfig.setType("0");
+            payBaseConfigService.add(payBaseConfig);
         } catch (Exception ex) {
             //异常不处理,可手动添加
         }

+ 15 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PrintInvoiceQueryResultServiceImpl.java

@@ -4,9 +4,11 @@ import com.alibaba.fastjson.JSON;
 import com.bz.smart_city.commom.util.DESDZFP;
 import com.bz.smart_city.commom.util.HttpClientUtils;
 import com.bz.smart_city.dto.pay.InvoicePrintInfoResult;
+import com.bz.smart_city.dto.pay.PayBaseConfigDto;
 import com.bz.smart_city.dto.pay.PayEleInvoiceRequestDto;
 import com.bz.smart_city.dto.pay.PayInvoiceResultDto;
 import com.bz.smart_city.entity.pay.PayInvoiceprinted;
+import com.bz.smart_city.service.pay.PayBaseConfigService;
 import com.bz.smart_city.service.pay.PrintInvoicePrintService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -17,6 +19,7 @@ import org.springframework.stereotype.Service;
 import java.math.BigInteger;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -32,6 +35,8 @@ public class PrintInvoiceQueryResultServiceImpl {
     PrintInvoicePrintService printInvoicePrintService;
     @Value("${invoice.query.url}")
     private  String queryUrl;
+    @Autowired
+    PayBaseConfigService payBaseConfigService;
 
     @Async
     public void queryPrintInvoiceInfo(PayInvoiceprinted payInvoiceprinted) throws Exception {
@@ -44,7 +49,16 @@ public class PrintInvoiceQueryResultServiceImpl {
             String resultString = DESDZFP.encrypt(JSON.toJSONString(payEleInvoiceRequestDto));
             Map<String, String> invoiceResult = new HashMap<String, String>();
             invoiceResult.put("order", resultString);
-            String invoiceInfo = HttpClientUtils.doPost(queryUrl, invoiceResult);
+            //查询开票地址
+
+            List<PayBaseConfigDto> payBaseConfigDtos = payBaseConfigService.getPrintInfo("PRINT_INVOICE_QUERYURL",Integer.valueOf(payInvoiceprinted.getSiteId().toString()),Integer.valueOf(payInvoiceprinted.getCustomerId().toString()));
+            String invoiceUrl = "";
+            if (payBaseConfigDtos.size() == 0) {
+               return;
+            } else {
+                invoiceUrl = payBaseConfigDtos.get(0).getValue();
+            }
+            String invoiceInfo = HttpClientUtils.doPost(invoiceUrl, invoiceResult);
             PayInvoiceResultDto payInvoiceResultDto = JSON.parseObject(invoiceInfo, PayInvoiceResultDto.class);
             if (payInvoiceResultDto != null && payInvoiceResultDto.getList().size() > 0) {
                 InvoicePrintInfoResult item = payInvoiceResultDto.getList().get(0);

+ 1 - 1
smart-city-platform/src/main/resources/mapper/pay/PayInvoicePrintMapper.xml

@@ -116,7 +116,7 @@
 	<select id="findListByState" resultType="com.bz.smart_city.entity.pay.PayInvoiceprinted">
 	SELECT a.invoice_code as invoiceCode,a.invoice_no as invoiceNo,a.id as id,a.usercode as userCode,
 		   a.cancelinvoice_id as cancelInvoiceId,a.fpqqlsh as fpqqlsh,a.saleidentity as saleIdentity,
-		   a.invoice_type as invoiceType,customer_id as customerId
+		   a.invoice_type as invoiceType,a.customer_id as customerId,a.site_id as siteId
 	from pay_invoice_printed a
 	where a.state=0 or a.state=2
 	</select>