wangli 4 سال پیش
والد
کامیت
166693085e
15فایلهای تغییر یافته به همراه463 افزوده شده و 73 حذف شده
  1. 1 2
      smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayFeeController.java
  2. 59 2
      smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayInvoiceController.java
  3. 2 1
      smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayFeeMapper.java
  4. 21 2
      smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayInvoiceMapper.java
  5. 6 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayInvoiceDto.java
  6. 4 1
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/PayfeeReceivableInfo.java
  7. 31 22
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/PrintInvoiceData.java
  8. 35 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/PrintReceivedInfo.java
  9. 2 0
      smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/PayInvoice.java
  10. 3 2
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayFeeServiceImp.java
  11. 104 21
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayInvoiceServiceImpl.java
  12. 1 2
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PayFeeService.java
  13. 18 2
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PayinvoiceService.java
  14. 166 5
      smart-city-platform/src/main/resources/mapper/pay/PayInvoiceMapper.xml
  15. 10 11
      smart-city-platform/src/main/resources/mapper/pay/payFeeMapper.xml

+ 1 - 2
smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayFeeController.java

@@ -92,10 +92,9 @@ public class PayFeeController {
     @ApiOperation(value="收费界面查询客户信息,客户id是在查询出多用户时,选择某个用户")
     public AjaxMessage<List<PayfeeAccountInfoDto>> findPayfeeAccountInfo(
             @ApiParam(value = "开户id,查询多用户时,再次查询用id查询") @RequestParam(required = false)BigInteger id,
-            @ApiParam(value = "查询类型,1客户名称,2客户编码,3电话,4地址") @RequestParam(required = false)Integer queryType ,
             @ApiParam(value = "查询内容") @RequestParam(required = false)String condition ){
 
-        return new AjaxMessage<List<PayfeeAccountInfoDto>>(ResultStatus.OK, payFeeService.findPayfeeAccountInfo(id, queryType , condition ));
+        return new AjaxMessage<List<PayfeeAccountInfoDto>>(ResultStatus.OK, payFeeService.findPayfeeAccountInfo(id , condition ));
     }
 
     @GetMapping("/getPayfeeDetaileBill")

+ 59 - 2
smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayInvoiceController.java

@@ -6,15 +6,20 @@ import com.bz.smart_city.commom.model.ResultStatus;
 import com.bz.smart_city.dto.pay.PayInvoiceDto;
 import com.bz.smart_city.dto.pay.PayMessageTemplateDto;
 import com.bz.smart_city.dto.pay.PayTransactiondetails;
+import com.bz.smart_city.dto.pay.payfee.PrintInvoiceData;
 import com.bz.smart_city.entity.pay.PayInvoice;
 import com.bz.smart_city.service.pay.PayinvoiceService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
+import java.math.BigInteger;
+import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 
 /**
@@ -30,9 +35,9 @@ public class PayInvoiceController {
     @Autowired
     private PayinvoiceService payinvoiceService;
 
-    @GetMapping("/getMessageTemplate")
+    @GetMapping("/getPrintInfoListPage")
     @ApiOperation("查询收据")
-    public AjaxMessage<Pagination<PayInvoiceDto>> getMessageTemplate(
+    public AjaxMessage<Pagination<PayInvoiceDto>> getPrintInfoListPage(
             @ApiParam(value = "查询条件", required = false) @RequestParam(required = false) String condition,
             @ApiParam(value = "收据状态", required = false) @RequestParam(required = false) Integer state,
             @ApiParam(value = "开票时间开始", required = false) @RequestParam(required = false) String startTime,
@@ -55,4 +60,56 @@ public class PayInvoiceController {
         return new AjaxMessage<>(ResultStatus.OK);
     }
 
+    @GetMapping("/getPrintData")
+    @ApiOperation("获取打印数据")
+    public AjaxMessage< PrintInvoiceData> getPrintData(
+            @ApiParam(value = "缴费批次号", required = true) @RequestParam(required = true) String payseriesno,
+            @ApiParam(value = "交易类型,实收打印时为空", required = false) @RequestParam(required = false) Integer transType,
+            @ApiParam(value = "支付方式", required = true) @RequestParam(required = true) Integer payway ) {
+        if(transType !=null && transType==1 && payway == 4){	//单纯充值
+            return  new AjaxMessage<>(ResultStatus.OK,payinvoiceService.getPrintDataOfTrans(payseriesno));
+
+
+        }else{	//缴费
+            return  new AjaxMessage<>(ResultStatus.OK,payinvoiceService.getPrintDataOfReceived(payseriesno));
+        }
+    }
+
+    @GetMapping("/getPrintDataAgain")
+    @ApiOperation("补打票据")
+    public AjaxMessage<PrintInvoiceData> getPrintDataAgain(
+            @ApiParam(value = "票据id", required = true) @RequestParam(required = true) BigInteger id
+           ){
+
+        PayInvoiceDto payInvoiceDto = payinvoiceService.get(id);
+        String payseriesno = payinvoiceService.findPayseriesnoByPrint(id, 1);
+        if (StringUtils.isNotBlank(payseriesno)) {
+            PrintInvoiceData printInvoiceData= payinvoiceService.getPrintDataOfReceived(payseriesno);
+            printInvoiceData.setInvoiceNo(payInvoiceDto.getInvoiceno());
+            return new AjaxMessage<>(ResultStatus.OK,printInvoiceData);
+
+        } else {
+            payseriesno = payinvoiceService.findPayseriesnoByPrint(id, 2);
+            if (StringUtils.isNotBlank(payseriesno)) {
+                PrintInvoiceData printInvoiceData= payinvoiceService.getPrintDataOfTrans(payseriesno);
+                printInvoiceData.setInvoiceNo(payInvoiceDto.getInvoiceno());
+                return new AjaxMessage<>(ResultStatus.OK,printInvoiceData);
+            } else {
+                return new AjaxMessage<>(ResultStatus.OPERATE_RECORD_NOT_EXIT);
+            }
+        }
+    }
+
+    @PostMapping("/cancelPrintinfo")
+    @ApiOperation("作废票据")
+    public AjaxMessage<String> cancelPrintinfo(
+            @ApiParam(value = "票据id", required = true) @RequestParam(required = true) BigInteger id
+    ){
+        payinvoiceService.cancelPrintInfo(id);
+        return new AjaxMessage<>(ResultStatus.OK);
+    }
+
+    public static void main(String[] args) {
+        System.out.println(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS").format(LocalDateTime.now())+""+(int)(Math.random()*1000));
+    }
 }

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

@@ -3,6 +3,7 @@ package com.bz.smart_city.dao.pay;
 import com.bz.smart_city.dto.pay.PayCustomRechargeDto;
 import com.bz.smart_city.dto.pay.PayInvoiceDto;
 import com.bz.smart_city.dto.pay.payfee.*;
+import com.bz.smart_city.entity.ProgramItem;
 import com.bz.smart_city.entity.pay.BaseClosingAccountInfo;
 import com.bz.smart_city.entity.pay.PayReceivable;
 import org.apache.ibatis.annotations.Mapper;
@@ -33,7 +34,7 @@ public interface PayFeeMapper {
 
     void updateAccountState(@Param("accountId") BigInteger accountId);
 
-    List<PayfeeAccountInfoDto> findPayfeeAccountInfo(@Param("id")BigInteger id,@Param("queryType")Integer queryType ,@Param("condition")String condition,@Param("siteId") Integer siteId, @Param("customerId") Integer customerId);
+    List<PayfeeAccountInfoDto> findPayfeeAccountInfo(@Param("id")BigInteger id, @Param("condition")String condition, @Param("siteId") Integer siteId, @Param("customerId") Integer customerId,@Param("programItems") List<ProgramItem> programItems);
 
     PayfeeDetaileBill getPayfeeDetaileBill(@Param("accountId") BigInteger accountId);
 

+ 21 - 2
smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayInvoiceMapper.java

@@ -1,17 +1,21 @@
 package com.bz.smart_city.dao.pay;
 
 import com.bz.smart_city.dto.pay.PayInvoiceDto;
+import com.bz.smart_city.dto.pay.PayTransactiondetails;
 import com.bz.smart_city.dto.pay.PayTransactiondetailsDto;
+import com.bz.smart_city.dto.pay.payfee.PrintInvoiceData;
+import com.bz.smart_city.dto.pay.payfee.PrintReceivedInfo;
 import com.bz.smart_city.entity.pay.PayInvoice;
 import com.bz.smart_city.entity.pay.PayPayReceived;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.math.BigInteger;
+import java.time.LocalDateTime;
 import java.util.List;
 
 /**
- * @description
+ * @description 收据打印
  * @auto wangli
  * @data 2020-07-30 8:39
  */
@@ -19,8 +23,23 @@ import java.util.List;
 public interface PayInvoiceMapper {
     void insert(PayInvoice payInvoice);
     List<PayInvoiceDto> findList(PayInvoiceDto payInvoiceDto);
+    PayInvoiceDto get(BigInteger id);
 
-    List<PayTransactiondetailsDto> findTransByPayseriesno(@Param("payseriesno") String payseriesno, @Param("siteId") Integer siteId, @Param("customerId") Integer customerId);
+    List<PayTransactiondetails> findTransByPayseriesno(@Param("payseriesno") String payseriesno, @Param("siteId") Integer siteId, @Param("customerId") Integer customerId);
     List<PayPayReceived> findReceivedByPayseriesno(@Param("payseriesno") String payseriesno , @Param("siteId") Integer siteId, @Param("customerId") Integer customerId);
     void updatePrintInvoiceRecord(@Param("type") Integer type, @Param("payseriesno") String payseriesno, @Param("invoiceId") BigInteger invoiceId,@Param("siteId") Integer siteId, @Param("customerId") Integer customerId);
+    PrintInvoiceData getPrintDataOfTran(@Param("payseriesno")String payseriesno,@Param("siteId")Integer siteId,@Param("customerId")Integer customerId);
+    PrintInvoiceData getLastWaterUsedRecord(@Param("accountid")BigInteger accountId,@Param("date") LocalDateTime date, @Param("siteId")Integer siteId, @Param("customerId")Integer customerId);
+
+
+    PrintInvoiceData getDateRangeInfoPrint(@Param("payseriesno")String payseriesno,@Param("siteId")Integer siteId,@Param("customerId")Integer customerId);
+    PrintInvoiceData getAccountInfoPrint(@Param("accountId") BigInteger accountId);
+    List<PrintReceivedInfo>  getPayfeeInfoPrint(@Param("minPeriod")Integer minPeriod,@Param("maxPeriod")Integer maxPeriod,@Param("accountId")BigInteger accountId);
+    PrintInvoiceData getPayfeeRemainingPrint(@Param("accountId")BigInteger accountId,@Param("maxPeriod")Integer maxPeriod,@Param("payseriesno")String payseriesno);
+
+    String findPayseriesnoByPrint(@Param("id")BigInteger id, @Param("type")Integer type);
+
+    void deleteTransPrint(@Param("id")BigInteger id);
+    void deleteReceivedPrint(@Param("id")BigInteger id);
+    void cancelPayInvoice(@Param("id")BigInteger id,@Param("canceltime")LocalDateTime canceltime,@Param("cancelperson")BigInteger cancelperson);
 }

+ 6 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayInvoiceDto.java

@@ -1,7 +1,9 @@
 package com.bz.smart_city.dto.pay;
 
 import com.bz.smart_city.entity.ProgramItem;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -16,6 +18,7 @@ import java.util.List;
  * @data 2020-07-30 8:18
  */
 @Data
+@ApiModel("收据管理")
 public class PayInvoiceDto {
 
     @ApiModelProperty(value = "收据id")
@@ -36,6 +39,7 @@ public class PayInvoiceDto {
     private LocalDateTime createDate;
     @ApiModelProperty(value = "开票人")
     private String createByName;
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
     @ApiModelProperty(value = "作废时间")
     private LocalDateTime canceltime;
     @ApiModelProperty(value = "作废人")
@@ -48,8 +52,10 @@ public class PayInvoiceDto {
     private Integer siteId;
     @ApiModelProperty(value = "客户id",  hidden = true)
     private Integer customerId;
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
     @ApiModelProperty(value = "开票时间",  hidden = true)
     private LocalDateTime startTime;
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
     @ApiModelProperty(value = "开票时间",  hidden = true)
     private LocalDateTime endTime;
 

+ 4 - 1
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/PayfeeReceivableInfo.java

@@ -1,5 +1,6 @@
 package com.bz.smart_city.dto.pay.payfee;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -7,6 +8,7 @@ import lombok.Data;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.time.LocalDateTime;
 import java.util.Date;
 
 /**
@@ -36,6 +38,7 @@ public class PayfeeReceivableInfo {
     private BigDecimal payamount;
     @ApiModelProperty(value = "应收金额")
     private BigDecimal receivablefee;
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
     @ApiModelProperty(value = "创建时间")
-    private Date createDate;
+    private LocalDateTime createDate;
 }

+ 31 - 22
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/PrintInvoiceData.java

@@ -1,8 +1,13 @@
 package com.bz.smart_city.dto.pay.payfee;
 
 import com.bz.smart_city.entity.pay.PayPayReceived;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
 
+import java.math.BigDecimal;
+import java.math.BigInteger;
 import java.time.LocalDateTime;
 import java.util.List;
 
@@ -11,18 +16,23 @@ import java.util.List;
  * @auto wangli
  * @data 2020-07-30 16:18
  */
+@Data
+@ApiModel("打印信息")
 public class PrintInvoiceData {
 
-    @ApiModelProperty(value = "充值日期")
+    @ApiModelProperty(value = "票据号码")
+    private String invoiceNo ;
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+    @ApiModelProperty(value = "充值日期" ,hidden = true)
     private LocalDateTime createDate;	//充值日期
     @ApiModelProperty(value = "本期余额")
-    private Double remaining;	//本期余额
-    @ApiModelProperty(value = "交易金额\t·实收金额")
-    private Double transamount;	//交易金额	·实收金额
+    private BigDecimal remaining;	//本期余额
+    @ApiModelProperty(value = "交易金额·实收金额")
+    private BigDecimal transamount;	//交易金额	·实收金额
     @ApiModelProperty(value = "上期金额")
-    private Double lastRemaining;	//上期金额
+    private BigDecimal lastRemaining;	//上期金额
     @ApiModelProperty(value = "客户ID")
-    private String accountId;	//客户ID
+    private BigInteger accountId;	//客户ID
     @ApiModelProperty(value = "客户名称")
     private String accountname;	//客户名称
     @ApiModelProperty(value = "客户编码")
@@ -30,29 +40,28 @@ public class PrintInvoiceData {
     @ApiModelProperty(value = "客户地址")
     private String address;	//客户地址
     @ApiModelProperty(value = "抄表止度")
-    private Double reading;	//抄表止度
+    private BigDecimal reading;	//抄表止度
     @ApiModelProperty(value = "收费日期")
     private String paydate;	//收费日期
-    @ApiModelProperty(value = "抄表日期")
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+    @ApiModelProperty(value = "抄表日期" ,hidden = true)
     private LocalDateTime recorddate;	//抄表日期
     @ApiModelProperty(value = "应收金额")
-    private Double receivablefee;	//应收金额
+    private BigDecimal receivablefee;	//应收金额
     @ApiModelProperty(value = "上期止度")
-    private Double lastreading;	//上期止度
+    private BigDecimal lastreading;	//上期止度
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+    @ApiModelProperty(value = "上期抄表日期", hidden = true)
+    private LocalDateTime lastrecorddate;	//上期抄表日期
     @ApiModelProperty(value = "收费账期区间")
     private String dateRange;	//收费账期区间
     @ApiModelProperty(value = "收费员")
-    private String createUser;	//收费员
-    @ApiModelProperty(value = "水量")
-    private Integer amount;	//水量
-    @ApiModelProperty(value = "单价")
-    private Double price;	//单价
-    @ApiModelProperty(value = "单价1")
-    private Double price1;	//单价1
-    @ApiModelProperty(value = "单价3")
-    private Double price3;	//单价3
-    @ApiModelProperty(value = "单价4")
-    private Double price4;	//单价4
+    private String createBy;	//收费员
     @ApiModelProperty(value = "实收信息")
-    private List<PayPayReceived> payReceiveds;
+    private List<PrintReceivedInfo> printReceivedInfo;
+
+    @ApiModelProperty(value = "最大账期(year*12+month)" ,hidden = true)
+    private Integer maxPeriod;
+    @ApiModelProperty(value = "最小账期(year*12+month)" ,hidden = true)
+    private Integer minPeriod;
 }

+ 35 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/PrintReceivedInfo.java

@@ -0,0 +1,35 @@
+package com.bz.smart_city.dto.pay.payfee;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+/**
+ * @description
+ * @auto wangli
+ * @data 2020-07-31 19:25
+ */
+@Data
+@ApiModel("收据打印详情")
+public class PrintReceivedInfo {
+
+    @ApiModelProperty(value = "客户id")
+    private BigInteger accountId;
+    @ApiModelProperty(value = "收费类型")
+    private String feetypename;
+    @ApiModelProperty(value = "阶梯")
+    private String ladderlevel;
+    @ApiModelProperty(value = "阶梯标签")
+    private String ladderlevelname;
+    @ApiModelProperty(value = "水量")
+    private BigDecimal payamount;
+    @ApiModelProperty(value = "单价")
+    private BigDecimal waterbasicprice;
+    @ApiModelProperty(value = "实收金额(应收金额)")
+    private BigDecimal receivedamount;
+    @ApiModelProperty(value = "划扣金额")
+    private BigDecimal autoReceivedamount;
+}

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

@@ -1,6 +1,7 @@
 package com.bz.smart_city.entity.pay;
 
 import com.bz.smart_city.dto.pay.BaseDto;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -35,6 +36,7 @@ public class PayInvoice extends PayBaseInfo{
     private BigInteger officeId;
     @ApiModelProperty(value = "作废人")
     private BigInteger cancelperson;
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
     @ApiModelProperty(value = "作废时间")
     private LocalDateTime canceltime;
     @ApiModelProperty(value = "账期年")

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

@@ -730,9 +730,10 @@ public class PayFeeServiceImp implements PayFeeService {
         return payReceived;
     }
 
-    public List<PayfeeAccountInfoDto> findPayfeeAccountInfo(BigInteger id, Integer queryType , String condition ){
+    public List<PayfeeAccountInfoDto> findPayfeeAccountInfo(BigInteger id, String condition ){
         LoginUser loginUser = UserUtil.getCurrentUser();
-        return payFeeMapper.findPayfeeAccountInfo(id, queryType , condition ,loginUser.getSiteId(),loginUser.getCustomerId());
+        //数据权限
+        return payFeeMapper.findPayfeeAccountInfo(id, condition ,loginUser.getSiteId(),loginUser.getCustomerId(),UserUtil.getCurrentSiteProgramItems(loginUser));
     }
 
     public PayfeeDetaileBill getPayfeeDetaileBill(BigInteger id){

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

@@ -9,6 +9,7 @@ import com.bz.smart_city.dto.pay.PayMessagesendrecordDto;
 import com.bz.smart_city.dto.pay.PayTransactiondetails;
 import com.bz.smart_city.dto.pay.PayTransactiondetailsDto;
 import com.bz.smart_city.dto.pay.payfee.PrintInvoiceData;
+import com.bz.smart_city.dto.pay.payfee.PrintReceivedInfo;
 import com.bz.smart_city.entity.pay.PayInvoice;
 import com.bz.smart_city.entity.pay.PayPayReceived;
 import com.bz.smart_city.service.pay.PayinvoiceService;
@@ -38,6 +39,9 @@ public class PayInvoiceServiceImpl implements PayinvoiceService {
     public void insert(PayInvoice payInvoice) {
         payInvoiceMapper.insert(payInvoice);
     }
+    public PayInvoiceDto get(BigInteger id) {
+        return payInvoiceMapper.get(id);
+    }
 
     public List<PayInvoiceDto> findList(String condition, Integer state, String startTime, String endTime) {
         LoginUser loginUser= UserUtil.getCurrentUser();
@@ -107,16 +111,19 @@ public class PayInvoiceServiceImpl implements PayinvoiceService {
         invoice.setRemarks("");
 
         //获取同批次号的交易明细
-        List<PayTransactiondetailsDto> payTransactiondetailsList=payInvoiceMapper.findTransByPayseriesno(payseriesno,loginUser.getSiteId(),loginUser.getCustomerId());
+        List<PayTransactiondetails> payTransactiondetailsList=payInvoiceMapper.findTransByPayseriesno(payseriesno,loginUser.getSiteId(),loginUser.getCustomerId());
 
-        for(PayTransactiondetailsDto payTransactiondetailsDto:payTransactiondetailsList){
+        for(PayTransactiondetails payTransactiondetails:payTransactiondetailsList){
             //转预存或充值金额
-            if(payTransactiondetailsDto.getPayway()!=4&&(payTransactiondetailsDto.getTranstype()==1||payTransactiondetailsDto.getTranstype()==4)){
-                countReceivedamount = countReceivedamount.add(payTransactiondetailsDto.getTransamount()!=null?payTransactiondetailsDto.getTransamount():BigDecimal.ZERO);
+            if(payTransactiondetails.getPayway()!=4&&(payTransactiondetails.getTranstype()==1||payTransactiondetails.getTranstype()==4)){
+                countReceivedamount = countReceivedamount.add(payTransactiondetails.getTransamount()!=null?payTransactiondetails.getTransamount():BigDecimal.ZERO);
 
-                invoice.setAccountId(payTransactiondetailsDto.getAccountId());
-                invoice.setAccountname(payTransactiondetailsDto.getAccountname());
-                invoice.setAccountnumber(payTransactiondetailsDto.getAccountnumber());
+                invoice.setAccountId(payTransactiondetails.getAccountId());
+                invoice.setAccountname(payTransactiondetails.getAccountname());
+                invoice.setAccountnumber(payTransactiondetails.getAccountnumber());
+                invoice.setOfficeId(payTransactiondetails.getOfficeId());
+                invoice.setYear(payTransactiondetails.getYear());
+                invoice.setMonth(payTransactiondetails.getMonth());
             }
         }
         //获取同批次号的实收信息
@@ -130,6 +137,9 @@ public class PayInvoiceServiceImpl implements PayinvoiceService {
                 invoice.setAccountId(received.getAccountId());
                 invoice.setAccountname(received.getAccountname());
                 invoice.setAccountnumber(received.getAccountnumber());
+                invoice.setOfficeId(received.getOfficeId());
+                invoice.setYear(received.getYear());
+                invoice.setMonth(received.getMonth());
             }
 
         }
@@ -147,28 +157,101 @@ public class PayInvoiceServiceImpl implements PayinvoiceService {
     }
 
     /**
-     * 仅充值
+     * 打印收据——仅充值
      * @param payseriesno
      * @return
      */
     public PrintInvoiceData getPrintDataOfTrans(String payseriesno){
-//        PrintInvoiceData printInvoiceData=printNoticeDao.getPrintDataOfTran(payseriesno);
-//        if(printInvoiceData!=null){
-//            PrintInvoiceData  wateruserdData=printNoticeDao.getLastWaterUsedRecord(printInvoiceData.getAccountId(), printInvoiceData.getCreateDate());
-//            if(wateruserdData!=null){
-//                printInvoiceData.setReading(wateruserdData.getReading());
-//                printInvoiceData.setRecorddate(wateruserdData.getRecorddate());
-//            }
-//            printInvoiceData.setPaydate(printInvoiceData.getCreateDate());
-//        }
-//        return printInvoiceData;
-        return null;
+        LoginUser loginUser=UserUtil.getCurrentUser();
+        PrintInvoiceData printInvoiceData=payInvoiceMapper.getPrintDataOfTran(payseriesno,loginUser.getSiteId(),loginUser.getCustomerId());
+        if(printInvoiceData!=null){
+            PrintInvoiceData  wateruserdData=payInvoiceMapper.getLastWaterUsedRecord(printInvoiceData.getAccountId(), printInvoiceData.getCreateDate(),loginUser.getSiteId(),loginUser.getCustomerId());
+            if(wateruserdData!=null){
+                printInvoiceData.setReading(wateruserdData.getReading());
+                printInvoiceData.setRecorddate(wateruserdData.getRecorddate());
+            }
+            DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+            if(printInvoiceData.getCreateDate()!=null){
+                printInvoiceData.setPaydate(df.format(printInvoiceData.getCreateDate()));
+            }else{
+                printInvoiceData.setPaydate(df.format(LocalDateTime.now()));
+            }
+        }
+        printInvoiceData.setInvoiceNo(
+                DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS").format(LocalDateTime.now())+""+(int)(Math.random()*1000));
+        return printInvoiceData;
     }
+    /**
+     * 打印收据——缴纳欠费(transtype == null || (transtype ==2 ||transtype ==4))
+     * @param payseriesno
+     * @return
+     */
     public PrintInvoiceData getPrintDataOfReceived(String payseriesno){
-        return null;
-    }
+        LoginUser loginUser=UserUtil.getCurrentUser();
+        //收费区间信息和抄表信息
+        PrintInvoiceData printInvoiceData=payInvoiceMapper.getDateRangeInfoPrint(payseriesno,loginUser.getSiteId(),loginUser.getCustomerId());
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        if(printInvoiceData.getCreateDate()!=null){
+            printInvoiceData.setPaydate(df.format(printInvoiceData.getCreateDate()));
+        }else{
+            printInvoiceData.setPaydate(df.format(LocalDateTime.now()));
+        }
+        printInvoiceData.setDateRange(
+            printInvoiceData.getMaxPeriod()/12+""+String.format("%02d",printInvoiceData.getMaxPeriod()%12)+"————"+
+            printInvoiceData.getMinPeriod()/12+""+String.format("%02d",printInvoiceData.getMinPeriod()%12)   );
 
 
+        //缴费用户信息
+        PrintInvoiceData accountInfoPrint =payInvoiceMapper.getAccountInfoPrint(printInvoiceData.getAccountId());
+        printInvoiceData.setAccountname(accountInfoPrint.getAccountname());
+        printInvoiceData.setAccountnumber(accountInfoPrint.getAccountnumber());
+        printInvoiceData.setAddress(accountInfoPrint.getAddress());
+        printInvoiceData.setRemaining(accountInfoPrint.getRemaining());
 
+        //余额信息(/*--交易前后余额(先按批次号查询,没有再查询交易后第一条记录,还有没有就取预存账户余额)*/)
+        PrintInvoiceData payfeeRemainingPrint= payInvoiceMapper.getPayfeeRemainingPrint(printInvoiceData.getAccountId(),null,payseriesno);
+        if(payfeeRemainingPrint !=null || payfeeRemainingPrint.getRemaining() != null){
+            printInvoiceData.setRemaining(payfeeRemainingPrint.getRemaining());
+            printInvoiceData.setLastRemaining(payfeeRemainingPrint.getLastRemaining());
+        }else{
+            payfeeRemainingPrint= payInvoiceMapper.getPayfeeRemainingPrint(printInvoiceData.getAccountId(),printInvoiceData.getMaxPeriod(),null);
+            if(payfeeRemainingPrint !=null && payfeeRemainingPrint.getRemaining() != null){
+                printInvoiceData.setRemaining(payfeeRemainingPrint.getRemaining());
+                printInvoiceData.setLastRemaining(payfeeRemainingPrint.getRemaining());
+            }else{
+                printInvoiceData.setLastRemaining(printInvoiceData.getRemaining());
+            }
+        }
+
+        //收费信息
+        List<PrintReceivedInfo>  payfeeInfoPrint = payInvoiceMapper.getPayfeeInfoPrint(printInvoiceData.getMinPeriod(),printInvoiceData.getMaxPeriod(),printInvoiceData.getAccountId());
+
+
+        BigDecimal receivedFee=BigDecimal.ZERO;
+        BigDecimal debt=BigDecimal.ZERO;
+        //计算出缴纳的欠费金额
+        for(PrintReceivedInfo receivedInfo:payfeeInfoPrint){
+            debt=debt.add(receivedInfo.getReceivedamount());
+        }
+        //计算出实收金额
+        receivedFee= debt.add(printInvoiceData.getRemaining()).subtract(printInvoiceData.getLastRemaining());
+        printInvoiceData.setReceivablefee(debt);
+        printInvoiceData.setTransamount(receivedFee);
+        printInvoiceData.setPrintReceivedInfo(payfeeInfoPrint);
+        printInvoiceData.setInvoiceNo(
+            DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS").format(LocalDateTime.now())+""+(int)(Math.random()*1000));
+        return printInvoiceData;
+    }
+
+
+    public String findPayseriesnoByPrint(BigInteger id,Integer type){
+        return payInvoiceMapper.findPayseriesnoByPrint(id,type);
+    }
 
+    public void cancelPrintInfo(BigInteger id){
+        LoginUser loginUser=UserUtil.getCurrentUser();
+        payInvoiceMapper.deleteTransPrint(id);
+        payInvoiceMapper.deleteReceivedPrint(id);
+        payInvoiceMapper.cancelPayInvoice(id,LocalDateTime.now(),BigInteger.valueOf(loginUser.getId()));
+    }
 }

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

@@ -42,11 +42,10 @@ public interface PayFeeService {
     /**
      * 查询客户信息
      * @param id 开户id
-     * @param queryType 查询类型 1客户名称,2客户编码,3电话,4地址
      * @param condition 查询参数
      * @return
      */
-    List<PayfeeAccountInfoDto> findPayfeeAccountInfo(BigInteger id, Integer queryType , String condition );
+    List<PayfeeAccountInfoDto> findPayfeeAccountInfo(BigInteger id , String condition );
 
     /**
      * 收费界面查询账单详情

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

@@ -7,6 +7,7 @@ import com.bz.smart_city.dto.pay.PayTransactiondetailsDto;
 import com.bz.smart_city.dto.pay.payfee.PrintInvoiceData;
 import com.bz.smart_city.entity.pay.PayInvoice;
 
+import java.math.BigInteger;
 import java.time.LocalDateTime;
 import java.util.List;
 
@@ -22,6 +23,8 @@ public interface PayinvoiceService {
      */
     void insert(PayInvoice payInvoice);
 
+    PayInvoiceDto get(BigInteger id) ;
+
     /**
      * 列表展示查询收据信息
      * @param condition
@@ -49,16 +52,29 @@ public interface PayinvoiceService {
     void savePrintInfo(String payseriesno,String invoiceno);
 
     /**
-     * 仅充值(payway==4 && transtype ==1)
+     * 打印收据——仅充值(payway==4 && transtype ==1)
      * @param payseriesno
      * @return
      */
     PrintInvoiceData getPrintDataOfTrans(String payseriesno);
 
     /**
-     * 缴纳欠费(transtype == null || (transtype ==2 ||transtype ==4))
+     * 打印收据——缴纳欠费(transtype == null || (transtype ==2 ||transtype ==4))
      * @param payseriesno
      * @return
      */
     PrintInvoiceData getPrintDataOfReceived(String payseriesno);
+
+    /**
+     * 通过票据id查询交易批次号
+     * @param id
+     * @param type 1实收 2明细
+     */
+    String findPayseriesnoByPrint(BigInteger id,Integer type);
+
+    /**
+     * 作废票据
+     * @param id
+     */
+    void cancelPrintInfo(BigInteger id);
 }

+ 166 - 5
smart-city-platform/src/main/resources/mapper/pay/PayInvoiceMapper.xml

@@ -51,6 +51,22 @@
         )
     </insert>
 
+    <select id="get" resultType="com.bz.smart_city.dto.pay.PayInvoiceDto">
+        select
+        a.id,
+        a.invoiceno as "invoiceno",
+        a.accountnumber as "accountnumber",
+        a.accountname as "accountname",
+        a.invoiceamount as "invoiceamount",
+        a.state as "state",
+        (case when a.state=2 then '已使用' else '作废' end ) as "stateLabel",
+        a.create_date as "createDate",
+        (select name from sc_user where id=a.create_by) as "createByName",
+        a.canceltime as "canceltime",
+        (select name from sc_user where id=a.cancelperson) as "cancelpersonName"
+        from pay_pay_invoice a
+        where a.id=#{id}
+    </select>
     <select id="findList" resultType="com.bz.smart_city.dto.pay.PayInvoiceDto">
         select
         a.id,
@@ -66,7 +82,7 @@
         (select name from sc_user where id=a.cancelperson) as "cancelpersonName"
         from pay_pay_invoice a
         <where>
-            a.type = 1
+            a.type = 2
             <if test="siteId != null">
                 and a.site_id=#{siteId}
             </if>
@@ -81,7 +97,7 @@
                 )
             </if>
 
-            <if test="year != null">
+            <if test="state != null">
                 and a.state=#{state}
             </if>
             <if test="startTime != null">
@@ -101,12 +117,15 @@
         order by a.create_date desc
     </select>
 
-    <select id="findTransByPayseriesno" resultType="com.bz.smart_city.dto.pay.PayTransactiondetailsDto">
+    <select id="findTransByPayseriesno" resultType="com.bz.smart_city.dto.pay.PayTransactiondetails">
         select
             id,
             payway,
             transtype,
             transamount,
+            year,
+            month,
+            office_id as "officeId",
             account_id as "accountId",
             accountname,
             accountnumber
@@ -121,6 +140,9 @@
             payway,
             account_id as "accountId",
             accountname,
+            office_id as "officeId",
+            year,
+            month,
             accountnumber,
             receivedamount
         from pay_pay_received
@@ -134,11 +156,150 @@
             where payseriesno=#{payseriesno} and site_id=#{siteId} and customer_id=#{customerId}
         </if>
 
-        <if test="type != null and type == 1">
-            ;update pay_pay_received set invoice_id=#{invoiceId}
+        <if test="type != null and type == 2">
+            update pay_pay_received set invoice_id=#{invoiceId}
             where payseriesno=#{payseriesno} and site_id=#{siteId} and customer_id=#{customerId}
         </if>
 
 	</update>
 
+
+    <select id="getPrintDataOfTran" resultType="com.bz.smart_city.dto.pay.payfee.PrintInvoiceData">
+        select
+            a.create_date AS "createDate"
+            ,a.lastrecreamaing AS "remaining"
+            ,a.transamount
+            ,a.lastrecreamaing-transamount AS "lastRemaining"
+            ,account.id AS "accountId"
+            ,account.name AS "accountname"
+            ,account.accountnumber
+            ,account.address
+            ,u.name AS "createBy"
+        from pay_pay_transactiondetails a
+        left join pay_base_account account on account.id=a.account_id
+        left join sc_user u on u.id=a.create_by
+        where a.payseriesno =#{payseriesno} and a.site_id=#{siteId} and a.customer_id=#{customerId}
+            and a.canceledrecord_id is null and a.iscanceled=0
+    </select>
+
+    <select id="getLastWaterUsedRecord"  resultType="com.bz.smart_city.dto.pay.payfee.PrintInvoiceData">
+		select top 1  reading ,recorddate
+	 from amount_waterusedamount
+	 where state=2 and site_id=#{siteId} and customer_id=#{customerId} and account_id=#{accountId} and update_date &lt; #{date}
+	 order by update_date desc
+	</select>
+
+
+    <select id="getDateRangeInfoPrint" resultType="com.bz.smart_city.dto.pay.payfee.PrintInvoiceData">
+        select
+            amount.account_id as "accountId",
+            max(amount.year*12+amount.`month`) as  "maxPeriod",
+            min(amount.year*12+amount.`month`) as  "minPeriod",
+            max(amount.recorddate) as "recorddate",
+            min(amount.lastrecorddate) as "lastrecorddate",
+            max(amount.reading) as "reading",
+            min(amount.lastreading) as "lastreading",
+            max(reced.create_date) as "createDate",
+            (select name from sc_user where id=max(reced.create_by)) as "createBy"
+        from pay_pay_received reced
+        left join pay_pay_receivable rece on reced.receivable_id=rece.id
+        left join pay_amount_waterusedamount amount on amount.id=rece.usedamount_id
+        where reced.payseriesno=#{payseriesno} and reced.site_id=#{siteId} and reced.customer_id=#{customerId}
+        group by amount.account_id
+
+    </select>
+
+    <select id="getAccountInfoPrint"  resultType="com.bz.smart_city.dto.pay.payfee.PrintInvoiceData">
+        select
+            a.id as "accountId",
+            a.accountnumber,
+            a.name as "accountname",
+            a.address,
+            r.remaining
+        from pay_base_account a
+        left join pay_pay_rechargeaccount r on a.id=r.account_id
+        where a.id=#{accountId}
+    </select>
+
+    <select id="getPayfeeInfoPrint" resultType="com.bz.smart_city.dto.pay.payfee.PrintReceivedInfo">
+        select * from (
+        select
+        a.account_id as "accountId",
+        re.feetypename,
+        re.ladderlevel,
+        (case when re.ladderlevel = 1 then '一阶'
+        when re.ladderlevel = 2 then '二阶'
+        when re.ladderlevel = 3 then '三阶'
+        when re.ladderlevel = 4 then '四阶'
+        else '' end) as "ladderlevelname",
+        re.payamount,
+        re.waterbasicprice,
+        sum(case when payway != 4 then reced.receivedamount else 0 end ) receivedamount,
+        sum(case when payway = 4 then reced.receivedamount else 0 end ) autoReceivedamount
+        from pay_amount_waterusedamount a
+        left join pay_pay_receivable re on a.id=re.usedamount_id
+        left join pay_pay_received reced on reced.receivable_id=re.id
+        where  re.feetype=1   and a.`year`*12+a.`month` >= #{minPeriod} and a.`year`*12+a.`month` &lt;= #{maxPeriod} and  a.account_id=#{accountId}
+        group by a.account_id, re.feetypename,re.ladderlevel,re.payamount,re.waterbasicprice
+        union all
+        select
+        a.account_id,
+        re.feetypename,
+        '' as "ladderlevel",
+        '' as "ladderlevelname",
+        sum(re.payamount) as "payamount",
+        max(re.waterbasicprice) as "waterbasicprice",
+        sum(case when payway != 4 then reced.receivedamount else 0 end ) receivedamount,
+        sum(case when payway = 4 then reced.receivedamount else 0 end ) autoReceivedamount
+        from pay_amount_waterusedamount a
+        left join pay_pay_receivable re on a.id=re.usedamount_id
+        left join pay_pay_received reced on reced.receivable_id=re.id
+        where  re.feetype !=1  and a.`year`*12+a.`month` >= #{minPeriod} and a.`year`*12+a.`month` &lt;= #{maxPeriod} and  a.account_id=#{accountId}
+        group by  a.account_id,re.feetypename
+        )s
+        order by s.accountId,s.feetypename,s.ladderlevel
+    </select>
+    
+    <select id="getPayfeeRemainingPrint"  resultType="com.bz.smart_city.dto.pay.payfee.PrintInvoiceData">
+        select
+        lastrecreamaing as "remaining",
+        remaining as "lastRemaining"
+        from pay_pay_transactiondetails
+        <where>
+            account_id=#{accountId}
+            <if test="maxPeriod != null">
+                and create_date >= #{maxPeriod}
+            </if>
+            <if test="payseriesno != null">
+                and payseriesno=#{payseriesno}
+            </if>
+        </where>
+        order by create_date asc
+        limit 1
+    </select>
+
+
+    <select id="findPayseriesnoByPrint" resultType="java.lang.String">
+        <if test="type != null and type == 1">
+            select distinct payseriesno from pay_pay_received where invoice_id=#{id}
+        </if>
+
+        <if test="type != null and type == 2">
+            select distinct payseriesno from pay_pay_transactiondetails where invoice_id=#{id}
+        </if>
+    </select>
+
+    <update id="deleteTransPrint">
+        update pay_pay_transactiondetails set invoice_id = null where invoice_id=#{id}
+    </update>
+    <update id="deleteReceivedPrint">
+        update pay_pay_received set invoice_id = null where invoice_id=#{id}
+    </update>
+
+    <update id="cancelPayInvoice">
+        update pay_pay_invoice
+        set canceltime=#{canceltime},cancelperson=#{cancelperson},state=3
+        where id=#{id}
+
+    </update>
 </mapper>

+ 10 - 11
smart-city-platform/src/main/resources/mapper/pay/payFeeMapper.xml

@@ -118,18 +118,17 @@
                and  c.id= #{id}
             </if>
             <if test="condition != null and condition != ''">
-                <if test="queryType != null and queryType == 1">
-                    and c.accountname  like concat('%',#{condition},'%')
-                </if>
-                <if test="queryType != null and queryType == 2">
-                    and c.accountnumber like concat('%',#{condition},'%')
-                </if>
-                <if test="queryType != null and queryType == 3">
-                    and a.mobilephone like concat('%',#{condition},'%')
-                </if>
-                <if test="queryType != null and queryType == 4">
-                    and a.address  like concat('%',#{condition},'%')
+                or c.accountname  like concat('%',#{condition},'%')
+                or c.accountnumber like concat('%',#{condition},'%')
+                or a.mobilephone like concat('%',#{condition},'%')
+                or a.address  like concat('%',#{condition},'%')
+            </if>
+            <if test="programItems != null and programItems.size() != 0">
+                and   <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
+                <if test="item.dimensionId == 10">
+                    c.${item.dimensionCode} = #{item.dimensionValue}
                 </if>
+            </foreach>
             </if>
         </where>