Browse Source

发票打印相关

609324174@qq.com 4 years ago
parent
commit
2cf9b74ff3

+ 12 - 4
smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayPrintInvoiceController.java

@@ -29,15 +29,23 @@ public class PayPrintInvoiceController {
 
     @ApiOperation(value = "发票打印")
     @GetMapping(value = "/InvoicePrintRequest")
-    public AjaxMessage<ReturnPrintResultDto> InvoicePrintRequest(@ApiParam(value = "用户编号", required = true) @RequestParam(required = true) String userCode, @ApiParam(value = "缴费流水号", required = true) @RequestParam(required = true) String payseriesno) {
-        ReturnPrintResultDto returnPrintResultDto = issueElectronicInvoiceService.requestPrint("1", userCode, payseriesno, null);
+    public AjaxMessage<ReturnPrintResultDto> InvoicePrintRequest(
+            @ApiParam(value = "站点ID", required = false) @RequestParam(required = false) String siteId,
+            @ApiParam(value = "水司ID", required = false) @RequestParam(required = false) String customerId,
+            @ApiParam(value = "用户编号", required = true) @RequestParam(required = true) String userCode,
+            @ApiParam(value = "缴费流水号", required = true) @RequestParam(required = true) String payseriesno) {
+        ReturnPrintResultDto returnPrintResultDto = issueElectronicInvoiceService.requestPrint(siteId,customerId,"1", userCode, payseriesno, null);
         return new AjaxMessage<>(ResultStatus.OK, returnPrintResultDto);
     }
 
     @ApiOperation(value = "发票冲红")
     @GetMapping(value = "/cancelInvoicePrint")
-    public AjaxMessage<ReturnPrintResultDto> cancelInvoicePrint(@ApiParam(value = "用户编号", required = true) @RequestParam(required = true) String userCode, @ApiParam(value = "票据ID", required = true) @RequestParam(required = true) String invoicePrintId) {
-        ReturnPrintResultDto returnPrintResultDto = issueElectronicInvoiceService.requestPrint("2", null, null, invoicePrintId);
+    public AjaxMessage<ReturnPrintResultDto> cancelInvoicePrint(
+            @ApiParam(value = "站点ID", required = false) @RequestParam(required = false) String siteId,
+            @ApiParam(value = "水司ID", required = false) @RequestParam(required = false) String customerId,
+            @ApiParam(value = "用户编号", required = true) @RequestParam(required = true) String userCode,
+            @ApiParam(value = "票据ID", required = true) @RequestParam(required = true) String invoicePrintId) {
+        ReturnPrintResultDto returnPrintResultDto = issueElectronicInvoiceService.requestPrint(siteId,customerId,"2", null, null, invoicePrintId);
         return new AjaxMessage<>(ResultStatus.OK, returnPrintResultDto);
     }
 

+ 4 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/UserMapper.java

@@ -8,6 +8,8 @@ import com.bz.smart_city.entity.User;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.math.BigDecimal;
+import java.math.BigInteger;
 import java.util.List;
 
 @Mapper
@@ -69,5 +71,7 @@ public interface UserMapper {
 
     List<UserTypeDto> getAllUser();
 
+    User findUserByName(@Param("name") String  name,@Param("sitId") BigInteger sitId);
+
 }
 

+ 1 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/BaseClosingAccountInfoMapper.java

@@ -35,4 +35,5 @@ public interface BaseClosingAccountInfoMapper {
 
     public BaseClosingAccountInfoDto getLastClosingAccount( @Param("siteId")Integer siteId,@Param("customerId") Integer customerId);
 
+    BaseClosingAccountInfoDto getCurrentCloseInfo(@Param("siteId")Integer siteId,@Param("customerId") Integer customerId);
 }

+ 4 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/PayInvoiceprinted.java

@@ -85,6 +85,10 @@ public class PayInvoiceprinted extends PayBaseInfo {
 	private String saleIdentity;
 	@ApiModelProperty(value = "二维码")
 	private  String qrCode;
+	@ApiModelProperty(value = "二维码")
+	private  Integer year;
+	@ApiModelProperty(value = "二维码")
+	private  Integer month;
 }
 
 

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/UserService.java

@@ -1,5 +1,6 @@
 package com.bz.smart_city.service;
 
+import java.math.BigInteger;
 import java.util.List;
 
 import com.bz.smart_city.commom.model.Pagination;
@@ -114,4 +115,6 @@ public interface UserService {
     String miniProgramLogin(String username, String password, String openId);
 
     void bindOpenId(String openId);
+
+    User findUserByName(String name, BigInteger customerId);
 }

+ 6 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/UserServiceImpl.java

@@ -20,6 +20,7 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.math.BigInteger;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
@@ -612,4 +613,9 @@ public class UserServiceImpl implements UserService {
             this.update(userUpdate);
         }
     }
+
+    @Override
+    public User findUserByName(String name, BigInteger customerId) {
+        return userMapper.findUserByName(name,customerId);
+    }
 }

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

@@ -18,6 +18,7 @@ import com.bz.smart_city.entity.pay.PayTransactionSurvey;
 import com.bz.smart_city.service.pay.BaseClosingAccountInfoService;
 import com.github.pagehelper.PageHelper;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -550,6 +551,10 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
         return list;
     }
 
+    @Override
+    public BaseClosingAccountInfoDto getCurrentCloseInfo(Integer siteId,Integer customerId) {
+        return baseClosingAccountInfoMapper.getCurrentCloseInfo(siteId, customerId);
+    }
 
 
 }

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

@@ -2,13 +2,15 @@ package com.bz.smart_city.service.impl.pay;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.bz.smart_city.commom.model.Pagination;
 import com.bz.smart_city.commom.util.*;
 import com.bz.smart_city.dto.LoginUser;
 import com.bz.smart_city.dto.pay.*;
+import com.bz.smart_city.entity.User;
+import com.bz.smart_city.entity.pay.BaseClosingAccountInfo;
 import com.bz.smart_city.entity.pay.PayInvoiceParam;
 import com.bz.smart_city.entity.pay.PayInvoiceprinted;
 import com.bz.smart_city.entity.pay.archives.PayBaseCustomerandmeterrela;
+import com.bz.smart_city.service.UserService;
 import com.bz.smart_city.service.pay.*;
 import com.bz.smart_city.service.pay.archives.PayBaseCustomerandmeterrelaService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -45,8 +47,12 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
     PrintInvoiceQueryResultServiceImpl printInvoiceQueryResultService;
     @Autowired
     private SnowflakeIdWorker idWorker;
+    @Autowired
+    private UserService userService;
     @Value("${invoice.print.url}")
     private  String printUrl;
+    @Autowired
+    private  BaseClosingAccountInfoService baseClosingAccountInfoService;
 
     private Map<String, String> getPrintParam(Integer siteId, Integer customerId) {
         Map<String, String> map = new HashMap<>();
@@ -103,11 +109,24 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
      * @Author:
      * @Date: 2020/7/28
      */
-    public ReturnPrintResultDto requestPrint(String kpType, String userCode, String payseriesno, String invoicePrintId) {
+    public ReturnPrintResultDto requestPrint(String siteId, String customerId, String kpType, String userCode, String payseriesno, String invoicePrintId) {
         LoginUser loginUser = UserUtil.getCurrentUser();
+        ReturnPrintResultDto returnPrintResultDto = new ReturnPrintResultDto();//开票返回结果信息
         String name = loginUser.getName();//操作员姓名
+        if(loginUser==null) {
+            // User user = userService.findUserByName("系统操作", BigInteger.valueOf(Long.parseLong(siteId)));
+            //loginUser = new LoginUser();
+            loginUser.setCustomerId(Integer.valueOf(customerId));
+            loginUser.setSiteId(Integer.valueOf(siteId));
+        }
+        BaseClosingAccountInfo baseClosingAccountInfo = baseClosingAccountInfoService.getCurrentCloseInfo(loginUser.getSiteId(),loginUser.getCustomerId());
+        if(baseClosingAccountInfo==null)
+        {
+            returnPrintResultDto.setResult("1");//开票失败
+            returnPrintResultDto.setMsg("开票失败,失败原因:账期信息查询失败");
+            return returnPrintResultDto;
+        }
 
-        ReturnPrintResultDto returnPrintResultDto = new ReturnPrintResultDto();//开票返回结果信息
         PayInvoiceOrderDto payInvoiceOrderDto = new PayInvoiceOrderDto();//开票订单信息
         PayEleInvoiceDto payEleInvoiceDto = new PayEleInvoiceDto();//电子发票请求主体信息
         PayInvoiceprinted oldInvoiceprinted = new PayInvoiceprinted();//原始蓝票信息(红票时处理)
@@ -244,6 +263,8 @@ public class IssueElectronicInvoiceServiceImpl implements IssueElectronicInvoice
             payInvoiceprinted.setTaxnum(payInvoiceOrderDto.getTaxnum());
             payInvoiceprinted.setSendtype(2);
             payInvoiceprinted.setInvoiceType(1);
+            payInvoiceprinted.setYear(baseClosingAccountInfo.getYear());
+            payInvoiceprinted.setMonth(baseClosingAccountInfo.getMonth());
             payInvoiceprinted.setPrintNo(payInvoiceOrderDto.getOrderno());
             payInvoiceprinted.setOrderNo(payInvoiceOrderDto.getOrderno());
             payInvoiceprinted.setPayseriesno(payseriesno);

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/BaseClosingAccountInfoService.java

@@ -13,4 +13,6 @@ public interface BaseClosingAccountInfoService {
     public List<BaseClosingAccountInfoDto> getList(Integer year,Integer month);
     public Pagination<BaseClosingAccountInfoDto> getList(Integer year, Integer month, Integer pageNum, Integer pageSize);
     public List<BaseClosingAccountInfoDto> getAll();
+
+    BaseClosingAccountInfoDto getCurrentCloseInfo(Integer siteId,Integer customerId);
 }

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

@@ -10,5 +10,5 @@ import com.bz.smart_city.dto.pay.ReturnPrintResultDto;
  * @Version V1.0
  **/
 public interface IssueElectronicInvoiceService {
-    ReturnPrintResultDto requestPrint(String kpType, String userCode, String payseriesno, String invoicePrintId);
+    ReturnPrintResultDto requestPrint(String siteId, String customerId,String kpType, String userCode, String payseriesno, String invoicePrintId);
 }

+ 6 - 1
smart-city-platform/src/main/resources/mapper/UserMapper.xml

@@ -517,7 +517,12 @@
         LEFT JOIN sc_site_user ssu on(ssu.user_id = su.id and ssu.`status`=1)
         WHERE su.`status`=1 ORDER BY id ASC
     </select>
-
+    <select id="findUserByName" resultType="com.bz.smart_city.entity.User">
+    select scuser.id,scuser.username,scuser.name
+    from sc_site_user scsuser
+    inner join sc_user scuser on scsuser.user_id= scuser.id
+    where scsuser.site_id=#{sitId} and scuser.name=#{name} limit 1
+  </select>
 
 
 </mapper>

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

@@ -39,7 +39,9 @@
             customer_id,
             usercode,
             cancelinvoice_id,
-            saleidentity
+            saleidentity,
+            year,
+            month
 		) VALUES (
 			#{printNo},
 			#{oldInvoiceCode},
@@ -77,7 +79,9 @@
             #{customerId},
             #{userCode},
             #{cancelInvoiceId},
-            #{saleIdentity}
+            #{saleIdentity},
+            #{year},
+            #{month}
 		)
     </insert>
     <select id="findInvoiceByPayseriesno" resultType="com.bz.smart_city.entity.pay.PayInvoiceprinted">

+ 16 - 0
smart-city-platform/src/main/resources/mapper/pay/baseClosingAccountInfoMapper.xml

@@ -199,7 +199,23 @@
 		</if>
 		order by year desc,month desc LIMIT 1
 	</select>
+	<select id="getCurrentCloseInfo" resultType="com.bz.smart_city.dto.pay.BaseClosingAccountInfoDto">
+		SELECT
+		<include refid="baseClosingaccountinfoColumns"/>
+		FROM pay_base_closingaccountinfo a
+		<include refid="baseClosingaccountinfoJoins"/>
+		<where>
+			  a.state=0
+			<if test="siteId != null">
+				and a.site_id=#{siteId}
+			</if>
+			<if test="customerId != null">
+				and a.customer_id=#{customerId}
+			</if>
 
+		</where>
+		limit 1
+	</select>
 
 
 </mapper>