ソースを参照

Merge remote-tracking branch 'origin/0727' into 0727

zhoujiangyuan 5 年 前
コミット
3389b63345
33 ファイル変更2462 行追加83 行削除
  1. 1 0
      smart-city-platform/src/main/java/com/bz/smart_city/commom/model/ResultStatus.java
  2. 10 1
      smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayChargeSurveyController.java
  3. 125 5
      smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayFeeController.java
  4. 58 0
      smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayInvoiceController.java
  5. 18 1
      smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayPayReceiveContorller.java
  6. 15 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayChargeSurveyMapper.java
  7. 21 1
      smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayFeeMapper.java
  8. 26 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayInvoiceMapper.java
  9. 61 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayInvoiceDto.java
  10. 48 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayTransactionSurveyDto.java
  11. 53 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/PayfeeAccountInfoDto.java
  12. 23 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/PayfeeDetaileBill.java
  13. 36 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/PayfeeDetailed.java
  14. 37 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/PayfeeInvoice.java
  15. 41 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/PayfeeReceivableInfo.java
  16. 38 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/PayfeeReceivedInfo.java
  17. 43 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/PayfeeWaterusedamount.java
  18. 58 0
      smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/payfee/PrintInvoiceData.java
  19. 41 0
      smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/PayAmountSurvey.java
  20. 46 0
      smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/PayInvoice.java
  21. 63 0
      smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/PayTransactionSurvey.java
  22. 12 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/AmountWaterUsedAmountServiceImpl.java
  23. 175 52
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/BaseClosingAccountInfoServiceImpl.java
  24. 193 2
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayChargeSurveyServiceImpl.java
  25. 365 19
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayFeeServiceImp.java
  26. 174 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayInvoiceServiceImpl.java
  27. 4 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PayChargeSurveyService.java
  28. 101 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PayFeeService.java
  29. 64 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PayinvoiceService.java
  30. 160 0
      smart-city-platform/src/main/resources/mapper/pay/PayChargeSurveyMapper.xml
  31. 144 0
      smart-city-platform/src/main/resources/mapper/pay/PayInvoiceMapper.xml
  32. 9 2
      smart-city-platform/src/main/resources/mapper/pay/PayPayReceivedMapper.xml
  33. 199 0
      smart-city-platform/src/main/resources/mapper/pay/payFeeMapper.xml

+ 1 - 0
smart-city-platform/src/main/java/com/bz/smart_city/commom/model/ResultStatus.java

@@ -84,6 +84,7 @@ public enum ResultStatus {
     PAY_ADD_CUSTOMER_UPDATEAMOUNT(-722,"添加开户失败,计算阶梯可用量有误"),
     WATER_PROPERTY_CHENCK_NAME(-723,"该名称已经存在,请修改"),
     ACCOUNT_OPERATOR_EERROR(-724,"操作员信息异常"),
+    PAYFEE_NOT_ENOUGH(-724,"缴费金额不足"),
     CUSTOMER_IS_EXISTED(-3001,"客户名称已存在");
 
     private final int status;

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

@@ -7,6 +7,8 @@ import com.bz.smart_city.commom.util.UserUtil;
 import com.bz.smart_city.dto.LoginUser;
 import com.bz.smart_city.dto.pay.BaseClosingAccountInfoDto;
 import com.bz.smart_city.dto.pay.PayChargeSurveyDto;
+import com.bz.smart_city.dto.pay.PayTransactionSurveyDto;
+import com.bz.smart_city.entity.pay.PayTransactionSurvey;
 import com.bz.smart_city.entity.pay.archives.CustomerListInfo;
 import com.bz.smart_city.service.pay.PayChargeSurveyService;
 import io.swagger.annotations.Api;
@@ -34,11 +36,18 @@ public class PayChargeSurveyController {
     private PayChargeSurveyService payChargeSurveyService;
 
     @PostMapping("/accountSurvey")
-    @ApiOperation(value = "计费系统-客户概")
+    @ApiOperation(value = "计费系统-客户概")
     public AjaxMessage<PayChargeSurveyDto> accountSurvey(){
 
         PayChargeSurveyDto payChargeSurveyDto = payChargeSurveyService.accountSurvey();
 
         return new AjaxMessage<PayChargeSurveyDto>(ResultStatus.OK, payChargeSurveyDto);
     }
+
+    @PostMapping("/tranSurvey")
+    @ApiOperation(value = "计费系统-交易概况")
+    public AjaxMessage<PayTransactionSurveyDto> tranSurvey(@ApiParam(value = "账期", required = true,defaultValue = "2020-07") @RequestParam(required = true) String periodDate){
+        PayTransactionSurveyDto payTransactionSurvey = payChargeSurveyService.tranSurvey(periodDate);
+        return new AjaxMessage<PayTransactionSurveyDto>(ResultStatus.OK, payTransactionSurvey);
+    }
 }

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

@@ -2,16 +2,18 @@ package com.bz.smart_city.controller.pay;
 
 import com.bz.smart_city.commom.model.AjaxMessage;
 import com.bz.smart_city.commom.model.ResultStatus;
+import com.bz.smart_city.dto.pay.PayInvoiceDto;
+import com.bz.smart_city.dto.pay.PayTransactiondetailsDto;
+import com.bz.smart_city.dto.pay.payfee.*;
 import com.bz.smart_city.service.pay.PayFeeService;
+import com.bz.smart_city.service.pay.PayPayReceivedService;
+import com.bz.smart_city.service.pay.PayTransactiondetailsService;
 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.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
 import java.math.BigInteger;
@@ -29,12 +31,17 @@ import java.util.stream.Collectors;
  */
 @RestController
 @RequestMapping("payFee")
-@Api(tags = "计费系统(水查查)—缴费—冲账接口")
+@Api(tags = "计费系统—缴费管理")
 public class PayFeeController {
 
 
     @Autowired
     PayFeeService payFeeService;
+    @Autowired
+    private PayPayReceivedService payPayReceivedService;
+    @Autowired
+    PayTransactiondetailsService payTransactiondetailsService;
+
 
     @PostMapping("/payFee")
     @ApiOperation(value="冲账接口,客户名称、客户编码、应收id不能同时为空")
@@ -66,4 +73,117 @@ public class PayFeeController {
                                                                             userId != null?Integer.parseInt(userId):null)
                 );
     }
+
+
+    @PostMapping("/payFeeCounter")
+    @ApiOperation(value="柜台缴费接口")
+    public AjaxMessage<String> payFeeCounter(
+            @ApiParam(value = "客户id", required = true) @RequestParam(required = true)String accountId,
+            @ApiParam(value = "支付方式", required = true) @RequestParam(required = true)Integer payway,
+            @ApiParam(value = "交易金额", required = true) @RequestParam(required = true)String transAmount,
+            @ApiParam(value = "是否转预存,0否 1是", required = true) @RequestParam(required = true)Integer balancetype
+
+    ){
+        //暂时先默认柜台支付为现金支付,后期区分
+     return new AjaxMessage(ResultStatus.OK, payFeeService.payFeeCounter(accountId,4,new BigDecimal(transAmount),balancetype));
+    }
+
+    @GetMapping("/findPayfeeAccountInfo")
+    @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 ));
+    }
+
+    @GetMapping("/getPayfeeDetaileBill")
+    @ApiOperation(value="查询账单详情")
+    public AjaxMessage<PayfeeDetaileBill> getPayfeeDetaileBill(
+            @ApiParam(value = "客户id",required = true) @RequestParam(required = true)BigInteger accountId){
+        return new AjaxMessage<PayfeeDetaileBill>(ResultStatus.OK,payFeeService.getPayfeeDetaileBill(accountId));
+
+    }
+
+    @GetMapping("/getPayfeeDetailed")
+    @ApiOperation(value="查询本账期欠费明细")
+    public AjaxMessage<PayfeeDetailed> getPayfeeDetailed(
+            @ApiParam(value = "客户id",required = true) @RequestParam(required = true)BigInteger accountId ){
+        return new AjaxMessage<>(ResultStatus.OK,payFeeService.getPayfeeDetailed(accountId));
+    }
+
+    @GetMapping("/getPayreceiveDebt")
+    @ApiOperation(value="收费页面————欠费信息")
+    public AjaxMessage<List<PayfeeReceivableInfo>> getPayreceiveDebt(
+            @ApiParam(value = "客户id",required = true) @RequestParam(required = true)BigInteger accountId ,
+            @ApiParam(value = "账期年",required = true) @RequestParam(required = true)Integer year
+    ){
+        return new AjaxMessage<>(ResultStatus.OK,payFeeService.getPayreceiveDebt(accountId,year));
+    }
+
+    @GetMapping("/getPayreceiveDebtDetailed")
+    @ApiOperation(value="收费页面————欠费信息详情")
+    public AjaxMessage<List<PayfeeReceivableInfo>> getPayreceiveDebtDetailed(
+            @ApiParam(value = "客户id",required = true) @RequestParam(required = true)BigInteger accountId,
+            @ApiParam(value = "账期年",required = true) @RequestParam(required = true)Integer year,
+            @ApiParam(value = "账期月",required = true) @RequestParam(required = true)Integer month
+    ){
+        return new AjaxMessage<>(ResultStatus.OK,payFeeService.getPayreceiveDebtDetailed(accountId,year,month));
+    }
+
+    @GetMapping("/getPayreceived")
+    @ApiOperation(value="收费页面————实收信息")
+    public AjaxMessage<List<PayfeeReceivedInfo>> getPayreceived(
+            @ApiParam(value = "客户id",required = true) @RequestParam(required = true)BigInteger accountId ,
+            @ApiParam(value = "账期年",required = true) @RequestParam(required = true)Integer year
+    ){
+        return new AjaxMessage<>(ResultStatus.OK,payFeeService.getPayreceived(accountId,year));
+    }
+
+    @GetMapping("/getPayreceivedDetailed")
+    @ApiOperation(value="收费页面————实收信息详情")
+    public AjaxMessage<List<PayfeeReceivedInfo>> getPayreceivedDetailed(
+            @ApiParam(value = "客户id" ,required = true) @RequestParam(required = true)BigInteger accountId,
+            @ApiParam(value = "交易流水号" ,required = true) @RequestParam(required = true)String payseriesno,
+            @ApiParam(value = "账期年",required = true) @RequestParam(required = true)Integer year,
+            @ApiParam(value = "账期月",required = true) @RequestParam(required = true)Integer month
+    ){
+        return new AjaxMessage<>(ResultStatus.OK,payFeeService.getPayreceivedDetailed(accountId,payseriesno,year,month));
+    }
+
+
+    @GetMapping("/getTransDetailed")
+    @ApiOperation(value="收费页面————交易明细详情")
+    public AjaxMessage<List<PayTransactiondetailsDto>> getListByYear(
+            @ApiParam(value = "客户id", required = true) @RequestParam(required = true) BigInteger accountId,
+            @ApiParam(value = "账期年", required = true) @RequestParam(required = true) Integer year
+    ){
+
+        PayTransactiondetailsDto payTransactiondetailsDto =new PayTransactiondetailsDto();
+        payTransactiondetailsDto.setAccountId(accountId);
+        payTransactiondetailsDto.setYear(year);
+        return new AjaxMessage<>(ResultStatus.OK, payTransactiondetailsService.selectTransactionList(payTransactiondetailsDto));
+    }
+
+    @GetMapping("/getWaterusedamount")
+    @ApiOperation(value="收费页面————水量信息")
+    public AjaxMessage<List<PayfeeWaterusedamount>> getWaterusedamount(
+            @ApiParam(value = "客户id" ,required = true) @RequestParam(required = true)BigInteger id,
+            @ApiParam(value = "账期年",required = true) @RequestParam(required = true)Integer year
+    ){
+        return new AjaxMessage<>(ResultStatus.OK,payFeeService.getWaterusedamount(id,year));
+    }
+
+    @GetMapping("/getPayinvoiceInfo")
+    @ApiOperation(value="收费页面————收据信息")
+    public AjaxMessage<List<PayInvoiceDto>> getPayinvoiceInfo(
+            @ApiParam(value = "客户id" ,required = true) @RequestParam(required = true)BigInteger id,
+            @ApiParam(value = "账期年",required = true) @RequestParam(required = true)Integer year
+    ){
+        return new AjaxMessage<>(ResultStatus.OK,payFeeService.getPayinvoiceInfo(id,year));
+    }
 }
+
+
+

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

@@ -0,0 +1,58 @@
+package com.bz.smart_city.controller.pay;
+
+import com.bz.smart_city.commom.model.AjaxMessage;
+import com.bz.smart_city.commom.model.Pagination;
+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.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.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+
+import java.time.format.DateTimeFormatter;
+
+/**
+ * @description
+ * @auto wangli
+ * @data 2020-07-30 10:30
+ */
+@RestController
+@RequestMapping("payInvoice")
+@Api(tags = "计费系统—收据管理")
+public class PayInvoiceController {
+
+    @Autowired
+    private PayinvoiceService payinvoiceService;
+
+    @GetMapping("/getMessageTemplate")
+    @ApiOperation("查询收据")
+    public AjaxMessage<Pagination<PayInvoiceDto>> getMessageTemplate(
+            @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,
+            @ApiParam(value = "开票时间结束", required = false) @RequestParam(required = false) String endTime,
+            @ApiParam(value = "页数,非必传,默认第一页", required = false, defaultValue = "1") @RequestParam(required = false, defaultValue = "1") int pageNum,
+            @ApiParam(value = "条数,非必传,默认10条", required = false, defaultValue = "10") @RequestParam(required = false, defaultValue = "10") int pageSize
+
+    ){
+        return new AjaxMessage<>(ResultStatus.OK,payinvoiceService.findListPage(condition, state, startTime, endTime,pageNum,pageSize));
+    }
+
+
+    @PostMapping("/savePrintInfo")
+    @ApiOperation("保存收据打印信息")
+    public AjaxMessage<String> savePrintInfo(
+            @ApiParam(value = "缴费批次号", required = true) @RequestParam(required = true) String payseriesno,
+            @ApiParam(value = "票据号码", required = true) @RequestParam(required = true) String invoiceno
+    ){
+        payinvoiceService.savePrintInfo( payseriesno, invoiceno);
+        return new AjaxMessage<>(ResultStatus.OK);
+    }
+
+}

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

@@ -76,6 +76,7 @@ public class PayPayReceiveContorller {
         @ApiParam(value = "账期年", required = true) @RequestParam(required = true)Integer year,
         @ApiParam(value = "账期月", required = true) @RequestParam(required = true) Integer month,
         @ApiParam(value = "客户编码", required = true) @RequestParam(required = true)String accountnumber,
+        @ApiParam(value = "客户Id", required = true) @RequestParam(required = true)String accountId,
         @ApiParam(value = "状态", required = false) @RequestParam(required = false) Integer state,
         @ApiParam(value = "支付方式", required = false) @RequestParam(required = false) Integer payway,
         @ApiParam(value = "开始日期,2020-04-08", required = false) @RequestParam(required = false) String beginDate,
@@ -102,7 +103,9 @@ public class PayPayReceiveContorller {
 
     @PostMapping("/cancelReceived")
     @ApiOperation(value = "计费系统-取消实收")
-    public AjaxMessage cancelReceived(BigInteger id){
+    public AjaxMessage cancelReceived(
+            @ApiParam(value = "实收id", required = true) @RequestParam(required = true)BigInteger id
+    ){
 
         //回退实收
         //作废第三方支付
@@ -111,4 +114,18 @@ public class PayPayReceiveContorller {
         int result = payPayReceivedService.cancelReceived(id);
         return new AjaxMessage<>(ResultStatus.OK,result);
     }
+
+    @PostMapping("/cancelReceivedByPayseriesno")
+    @ApiOperation(value = "计费系统-取消实收By流水号")
+    public AjaxMessage cancelReceivedByPayseriesno(
+            @ApiParam(value = "交易流水号", required = true) @RequestParam(required = true)String payseriesno
+    ){
+
+        //回退实收
+        //作废第三方支付
+        //生成负数实收
+        //回退预存账户
+        payPayReceivedService.cancelReceivedByPayseriesno(payseriesno);
+        return new AjaxMessage<>(ResultStatus.OK,1);
+    }
 }

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

@@ -2,6 +2,7 @@ package com.bz.smart_city.dao.pay;
 
 import com.bz.smart_city.dto.pay.PayChangePeriodDto;
 import com.bz.smart_city.entity.pay.PayAccountSurvey;
+import com.bz.smart_city.entity.pay.PayTransactionSurvey;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -33,4 +34,18 @@ public interface PayChargeSurveyMapper {
 
     public PayAccountSurvey getlastAccount(@Param("periodDate")String startDate,
                                            @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
+
+    public BigDecimal getCurrentTran(@Param("year")Integer year,@Param("month")Integer month,
+            @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
+
+    public List<PayTransactionSurvey> getPayAmountList(@Param("year")Integer year,@Param("month")Integer month,
+                                                 @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
+
+    public void insertTransaction(PayTransactionSurvey payTransactionSurvey);
+
+    public List<PayTransactionSurvey> getCurrentTranRocord(@Param("year")Integer year,@Param("month")Integer month,
+                                @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
+
+    public PayTransactionSurvey getLastTranRocord(@Param("year")Integer year,@Param("month")Integer month,
+                                                  @Param("siteId")BigInteger siteId, @Param("customerId")BigInteger customerId);
 }

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

@@ -1,6 +1,8 @@
 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.pay.BaseClosingAccountInfo;
 import com.bz.smart_city.entity.pay.PayReceivable;
 import org.apache.ibatis.annotations.Mapper;
@@ -19,7 +21,7 @@ import java.util.List;
  */
 @Mapper
 public interface PayFeeMapper {
-    PayCustomRechargeDto getCustomInfoByMeterOrAccount(@Param("accountnumber") String accountnumber, @Param("metercode") String metercode,@Param("siteId") BigInteger siteId,@Param("customerId")BigInteger customerId );
+    PayCustomRechargeDto getCustomInfoByMeterOrAccount(@Param("accountId") String accountId, @Param("accountnumber") String accountnumber, @Param("metercode") String metercode,@Param("siteId") BigInteger siteId,@Param("customerId")BigInteger customerId );
 
     void updatePayReceivable(PayReceivable payReceivable);
 
@@ -28,6 +30,24 @@ public interface PayFeeMapper {
     List<PayReceivable> getReceivable(@Param("siteId") Integer siteId, @Param("customerId") Integer customerId, @Param("accountId") BigInteger accountId,@Param("list") List<BigInteger> list);
 
     BaseClosingAccountInfo getLastClosingAccount(@Param("siteId") Integer siteId, @Param("customerId") Integer customerId );
+
     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);
+
+    PayfeeDetaileBill getPayfeeDetaileBill(@Param("accountId") BigInteger accountId);
+
+    PayfeeDetailed getPayfeeDetailed(@Param("accountId")BigInteger accountId ,@Param("year")Integer year ,@Param("month")Integer month);
+
+    List<PayfeeReceivableInfo> getPayreceivableDebt(@Param("accountId")BigInteger accountId , @Param("year")Integer year);
+
+    List<PayfeeReceivableInfo> getPayreceivableDebtDetailed(@Param("accountId")BigInteger accountId , @Param("year")Integer year , @Param("month")Integer month);
+
+    List<PayfeeReceivedInfo> getPayreceived(@Param("accountId")BigInteger accountId , @Param("year")Integer year, @Param("siteId") Integer siteId, @Param("customerId") Integer customerId);
+
+    List<PayfeeReceivedInfo> getPayreceivedDetailed(@Param("accountId")BigInteger accountId ,@Param("payseriesno")String payseriesno, @Param("year")Integer year , @Param("month")Integer month, @Param("siteId") Integer siteId, @Param("customerId") Integer customerId);
+
+    List<PayfeeWaterusedamount> getWaterusedamount(@Param("accountId")BigInteger accountId , @Param("year")Integer year , @Param("siteId") Integer siteId, @Param("customerId") Integer customerId);
+
+    List<PayInvoiceDto> getPayinvoiceInfo(@Param("accountId")BigInteger accountId , @Param("year")Integer year);
 }

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

@@ -0,0 +1,26 @@
+package com.bz.smart_city.dao.pay;
+
+import com.bz.smart_city.dto.pay.PayInvoiceDto;
+import com.bz.smart_city.dto.pay.PayTransactiondetailsDto;
+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.util.List;
+
+/**
+ * @description
+ * @auto wangli
+ * @data 2020-07-30 8:39
+ */
+@Mapper
+public interface PayInvoiceMapper {
+    void insert(PayInvoice payInvoice);
+    List<PayInvoiceDto> findList(PayInvoiceDto payInvoiceDto);
+
+    List<PayTransactiondetailsDto> 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);
+}

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

@@ -0,0 +1,61 @@
+package com.bz.smart_city.dto.pay;
+
+import com.bz.smart_city.entity.ProgramItem;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigInteger;
+import java.time.LocalDateTime;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @description
+ * @auto wangli
+ * @data 2020-07-30 8:18
+ */
+@Data
+public class PayInvoiceDto {
+
+    @ApiModelProperty(value = "收据id")
+    private BigInteger id;
+    @ApiModelProperty(value = "收据号码")
+    private String invoiceno;
+    @ApiModelProperty(value = "客户编号")
+    private String accountnumber;
+    @ApiModelProperty(value = "客户名称")
+    private String accountname;
+    @ApiModelProperty(value = "开票金额")
+    private String invoiceamount;
+    @ApiModelProperty(value = "票据状态,2已使用,3作废")
+    private Integer state;
+    @ApiModelProperty(value = "票据状态")
+    private String stateLabel;
+    @ApiModelProperty(value = "开票日期")
+    private LocalDateTime createDate;
+    @ApiModelProperty(value = "开票人")
+    private String createByName;
+    @ApiModelProperty(value = "作废时间")
+    private LocalDateTime canceltime;
+    @ApiModelProperty(value = "作废人")
+    private BigInteger cancelpersonName;
+
+
+    @ApiModelProperty(value = "数据查询(票据号、户编、户名)",  hidden = true)
+    private String condition;
+    @ApiModelProperty(value = "站点id",  hidden = true)
+    private Integer siteId;
+    @ApiModelProperty(value = "客户id",  hidden = true)
+    private Integer customerId;
+    @ApiModelProperty(value = "开票时间",  hidden = true)
+    private LocalDateTime startTime;
+    @ApiModelProperty(value = "开票时间",  hidden = true)
+    private LocalDateTime endTime;
+
+    //权限项
+    @ApiModelProperty(value = "权限项",  hidden = true)
+    @JsonIgnore
+    private List<ProgramItem> programItems;
+
+}

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

@@ -0,0 +1,48 @@
+package com.bz.smart_city.dto.pay;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+@Data
+@ApiModel("交易概况DTO")
+public class PayTransactionSurveyDto {
+    @ApiModelProperty(value = "收入总数")
+    private BigDecimal incomeNumber;
+    @ApiModelProperty(value = "较上月比率")
+    private String lastIncomeRate;
+    @ApiModelProperty(value = "现金")
+    private BigDecimal cashIncome;
+    @ApiModelProperty(value = "较上月比率")
+    private String lastCashRate;
+    @ApiModelProperty(value = "微信支付")
+    private BigDecimal wechatIncome;
+    @ApiModelProperty(value = "较上月比率")
+    private String lastWechatRate;
+    @ApiModelProperty(value = "支付宝支付")
+    private BigDecimal alipayIncome;
+    @ApiModelProperty(value = "较上月比率")
+    private String lastAlipayRate;
+    @ApiModelProperty(value = "银行收入")
+    private BigDecimal bankIncome;
+    @ApiModelProperty(value = "较上月比率")
+    private String lastBankRate;
+    @ApiModelProperty(value = "账期年")
+    private Integer year;
+    @ApiModelProperty(value = "账期月")
+    private Integer month;
+    @ApiModelProperty(value = "账期")
+    private LocalDateTime periodDate;
+    private String periodDates;
+    @ApiModelProperty(value = "现金占比率")
+    private String CashRate;
+    @ApiModelProperty(value = "支付宝占比率")
+    private String alipayRate;
+    @ApiModelProperty(value = "微信占比率")
+    private String wechatRate;
+    @ApiModelProperty(value = "银行占比率")
+    private String bankRate;
+}

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

@@ -0,0 +1,53 @@
+package com.bz.smart_city.dto.pay.payfee;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigInteger;
+import java.time.LocalDateTime;
+
+/**
+ * @Author wangli
+ * @Description 缴费界面客户信息展示
+ * @Version 1.0
+ */
+
+@Data
+@ApiModel("缴费界面————客户信息")
+public class PayfeeAccountInfoDto {
+
+
+    @ApiModelProperty(value = "客户信息id")
+    private BigInteger accountId;
+    @ApiModelProperty(value = "开户信息id" )
+    private BigInteger custId;
+    @ApiModelProperty(value = "客户编码" )
+    private String accountnumber;
+    @ApiModelProperty(value = "客户名称" )
+    private String accountname;
+    @ApiModelProperty(value = "手机号" )
+    private String mobilephone;
+    @ApiModelProperty(value = "地址" )
+    private String address;
+    @ApiModelProperty(value = "证件号" )
+    private String idcardno;
+    @ApiModelProperty(value = "公司税号" )
+    private String vatno;
+    @ApiModelProperty(value = "电子邮箱" )
+    private String email;
+    @ApiModelProperty(value = "开户时间" )
+    private LocalDateTime opendate;
+    @ApiModelProperty(value = "水表编码" )
+    private String metercode;
+    @ApiModelProperty(value = "住房类型" )
+    private String housetype;
+    @ApiModelProperty(value = "结算方式" )
+    private String calculateway;
+    @ApiModelProperty(value = "用水性质id" )
+    private BigInteger waterPropertyId;
+    @ApiModelProperty(value = "用水性质名称" )
+    private String waterPropertyName;
+
+
+}

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

@@ -0,0 +1,23 @@
+package com.bz.smart_city.dto.pay.payfee;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @description 缴费界面账单详情
+ * @auto wangli
+ * @date 2020-07-28
+ */
+
+@Data
+@ApiModel("缴费界面——账单详情")
+public class PayfeeDetaileBill {
+
+    @ApiModelProperty(value = "欠费金额")
+    private Double debt;
+    @ApiModelProperty(value = "用水金额")
+    private Double waterFee;
+    @ApiModelProperty(value = "应缴金额")
+    private Double receivableFee;
+}

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

@@ -0,0 +1,36 @@
+package com.bz.smart_city.dto.pay.payfee;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.val;
+
+/**
+ * @description 缴费界面本期应缴明细
+ * @auto wangli
+ * @date 2020-07-28
+ */
+
+@Data
+@ApiModel("缴费界面————本期应缴明细")
+public class PayfeeDetailed {
+
+
+    @ApiModelProperty(value = "客户id")
+    private Double accountId;
+
+    @ApiModelProperty(value = "水费")
+    private Double waterFee1;
+    @ApiModelProperty(value = "二次加压费")
+    private Double waterFee2;
+    @ApiModelProperty(value = "不征税自来水")
+    private Double waterFee3;
+    @ApiModelProperty(value = "污水处理费")
+    private Double waterFee4;
+    @ApiModelProperty(value = "开采费")
+    private Double waterFee5;
+    @ApiModelProperty(value = "违约金")
+    private Double waterFee6;
+
+
+}

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

@@ -0,0 +1,37 @@
+package com.bz.smart_city.dto.pay.payfee;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigInteger;
+import java.util.Date;
+
+/**
+ * @description
+ * @auto wangli
+ * @data 2020-07-30 8:18
+ */
+@Data
+public class PayfeeInvoice {
+
+    @ApiModelProperty(value = "客户id")
+    private BigInteger accountId;
+    @ApiModelProperty(value = "客户名称")
+    private String accountname;
+    @ApiModelProperty(value = "客户编号")
+    private String accountnumber;
+    @ApiModelProperty(value = "收据金额")
+    private String invoiceamount;
+    @ApiModelProperty(value = "收据号码")
+    private String invoiceno;
+    @ApiModelProperty(value = "票据状态")
+    private Integer state;
+    @ApiModelProperty(value = "票据类型")
+    private Integer type;
+    @ApiModelProperty(value = "片区id")
+    private BigInteger officeId;
+    @ApiModelProperty(value = "作废人")
+    private BigInteger cancelperson;
+    @ApiModelProperty(value = "作废时间")
+    private Date canceltime;
+}

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

@@ -0,0 +1,41 @@
+package com.bz.smart_city.dto.pay.payfee;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Date;
+
+/**
+ * @description 收费页面欠费信息
+ * @auto wangli
+ * @data 2020-07-29 11:18
+ */
+@Data
+@ApiModel(value = "缴费界面————欠费信息")
+public class PayfeeReceivableInfo {
+
+    @ApiModelProperty(value = "客户id")
+    private BigInteger accountId ;
+    @ApiModelProperty(value = "账期年")
+    private Integer year ;
+    @ApiModelProperty(value = "账期月")
+    private Integer month;
+    @ApiModelProperty(value = "收费项目")
+    private String name;
+    @ApiModelProperty(value = "欠费金额")
+    private BigDecimal debt;
+    @ApiModelProperty(value = "阶梯")
+    private String ladderlevelname;
+    @ApiModelProperty(value = "水价")
+    private BigDecimal price;
+    @ApiModelProperty(value = "结算水量")
+    private BigDecimal payamount;
+    @ApiModelProperty(value = "应收金额")
+    private BigDecimal receivablefee;
+    @ApiModelProperty(value = "创建时间")
+    private Date createDate;
+}

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

@@ -0,0 +1,38 @@
+package com.bz.smart_city.dto.pay.payfee;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @description 收费界面实收信息
+ * @auto wangli
+ * @data 2020-07-29 12:12
+ */
+@Data
+@ApiModel(value = "缴费界面——实收信息")
+public class PayfeeReceivedInfo {
+    @ApiModelProperty(value = "收费项目")
+    private String name;
+    @ApiModelProperty(value = "水价阶梯")
+    private String ladderlevelname;
+    @ApiModelProperty(value = "交易流水号")
+    private String payseriesno;
+    @ApiModelProperty(value = "交易金额")
+    private String receivedamount;
+    @ApiModelProperty(value = "支付方式")
+    private String paywayname;
+    @ApiModelProperty(value = "交易状态")
+    private String statename;
+    @ApiModelProperty(value = "创建日期")
+    private String createDate;
+    @ApiModelProperty(value = "是否作废")
+    private String iscanceled;
+    @ApiModelProperty(value = "作废人id")
+    private String canceledrecordId;
+    @ApiModelProperty(value = "作废人")
+    private String cancelperson;
+    @ApiModelProperty(value = "收据id")
+    private String invoiceId;
+
+}

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

@@ -0,0 +1,43 @@
+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.util.Date;
+
+/**
+ * @description
+ * @auto wangli
+ * @data 2020-07-29 16:39
+ */
+@Data
+@ApiModel("缴费界面——水量信息")
+public class PayfeeWaterusedamount {
+
+    @ApiModelProperty(value = "水表编码")
+    private String metercode;
+    @ApiModelProperty(value = "上次止度")
+    private BigDecimal lastreading;
+    @ApiModelProperty(value = "上次抄表时间")
+    private Date lastrecorddate;
+    @ApiModelProperty(value = "本次止度")
+    private BigDecimal reading;
+    @ApiModelProperty(value = "本次抄表时间")
+    private Date recorddate;
+    @ApiModelProperty(value = "实际水量")
+    private BigDecimal amount;
+    @ApiModelProperty(value = "结算水量")
+    private BigDecimal payamount;
+    @ApiModelProperty(value = "账期")
+    private String closingName;
+    @ApiModelProperty(value = "状态")
+    private String stateLabel;
+//    @ApiModelProperty(value = "账期年")
+//    private Integer year;
+//    @ApiModelProperty(value = "账期月")
+//    private Integer month;
+    @ApiModelProperty(value = "是否生成应收")
+    private String isReceivable;
+}

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

@@ -0,0 +1,58 @@
+package com.bz.smart_city.dto.pay.payfee;
+
+import com.bz.smart_city.entity.pay.PayPayReceived;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * @description
+ * @auto wangli
+ * @data 2020-07-30 16:18
+ */
+public class PrintInvoiceData {
+
+    @ApiModelProperty(value = "充值日期")
+    private LocalDateTime createDate;	//充值日期
+    @ApiModelProperty(value = "本期余额")
+    private Double remaining;	//本期余额
+    @ApiModelProperty(value = "交易金额\t·实收金额")
+    private Double transamount;	//交易金额	·实收金额
+    @ApiModelProperty(value = "上期金额")
+    private Double lastRemaining;	//上期金额
+    @ApiModelProperty(value = "客户ID")
+    private String accountId;	//客户ID
+    @ApiModelProperty(value = "客户名称")
+    private String accountname;	//客户名称
+    @ApiModelProperty(value = "客户编码")
+    private String accountnumber;	//客户编码
+    @ApiModelProperty(value = "客户地址")
+    private String address;	//客户地址
+    @ApiModelProperty(value = "抄表止度")
+    private Double reading;	//抄表止度
+    @ApiModelProperty(value = "收费日期")
+    private String paydate;	//收费日期
+    @ApiModelProperty(value = "抄表日期")
+    private LocalDateTime recorddate;	//抄表日期
+    @ApiModelProperty(value = "应收金额")
+    private Double receivablefee;	//应收金额
+    @ApiModelProperty(value = "上期止度")
+    private Double lastreading;	//上期止度
+    @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
+    @ApiModelProperty(value = "实收信息")
+    private List<PayPayReceived> payReceiveds;
+}

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

@@ -0,0 +1,41 @@
+package com.bz.smart_city.entity.pay;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigInteger;
+import java.time.LocalDateTime;
+
+@Data
+@ApiModel("用水量统计表")
+public class PayAmountSurvey {
+    @ApiModelProperty(value = "id", position = 1)
+    private BigInteger id;
+    @ApiModelProperty(value = "水量统计", position = 2)
+    private BigInteger amountNumber;
+    @ApiModelProperty(value = "账期年", position = 3)
+    private String year;
+    @ApiModelProperty(value = "账期月", position = 4)
+    private String month;
+    @ApiModelProperty(value = "创建者", hidden = true)
+    private BigInteger createBy;
+    @ApiModelProperty(value = "修改者", hidden = true)
+    private BigInteger updateBy;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间", hidden = true)
+    private LocalDateTime createDate = LocalDateTime.now();
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间", hidden = true)
+    private LocalDateTime updateDate = LocalDateTime.now();
+    @ApiModelProperty(value = "备注", hidden = true)
+    private String remarks;
+    @ApiModelProperty(value = "删除标识", hidden = true)
+    private String delFlag;
+    @ApiModelProperty(value = "站点ID", hidden = true)
+    private BigInteger siteId;
+    @ApiModelProperty(value = "水司ID", hidden = true)
+    private BigInteger customerId;
+
+}

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

@@ -0,0 +1,46 @@
+package com.bz.smart_city.entity.pay;
+
+import com.bz.smart_city.dto.pay.BaseDto;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+/**
+ * @description
+ * @auto wangli
+ * @data 2020-07-30 8:18
+ */
+@Data
+public class PayInvoice extends PayBaseInfo{
+
+    @ApiModelProperty(value = "客户id")
+    private BigInteger accountId;
+    @ApiModelProperty(value = "客户名称")
+    private String accountname;
+    @ApiModelProperty(value = "客户编号")
+    private String accountnumber;
+    @ApiModelProperty(value = "收据金额")
+    private BigDecimal invoiceamount;
+    @ApiModelProperty(value = "收据号码")
+    private String invoiceno;
+    @ApiModelProperty(value = "票据状态")
+    private Integer state;
+    @ApiModelProperty(value = "票据类型")
+    private Integer type;
+    @ApiModelProperty(value = "片区id")
+    private BigInteger officeId;
+    @ApiModelProperty(value = "作废人")
+    private BigInteger cancelperson;
+    @ApiModelProperty(value = "作废时间")
+    private LocalDateTime canceltime;
+    @ApiModelProperty(value = "账期年")
+    private Integer year;
+    @ApiModelProperty(value = "账期月")
+    private Integer month;
+    @ApiModelProperty(value = "id")
+    private BigInteger id;
+}

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

@@ -0,0 +1,63 @@
+package com.bz.smart_city.entity.pay;
+
+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;
+
+@Data
+@ApiModel("交易概况表")
+public class PayTransactionSurvey {
+    @ApiModelProperty(value = "id")
+    private String id;
+    @ApiModelProperty(value = "收入总数")
+    private BigDecimal incomeNumber;
+    @ApiModelProperty(value = "上一账期收入总数")
+    private BigDecimal lastIncomeNumber;
+    @ApiModelProperty(value = "现金")
+    private BigDecimal cashIncome;
+    @ApiModelProperty(value = "上一账期现金汇总")
+    private BigDecimal lastCashIncome;
+    @ApiModelProperty(value = "微信支付")
+    private BigDecimal wechatIncome;
+    @ApiModelProperty(value = "上一账期微信支付汇总")
+    private BigDecimal lastWechatIncome;
+    @ApiModelProperty(value = "支付宝支付")
+    private BigDecimal alipayIncome;
+    @ApiModelProperty(value = "上一账期支付宝汇总")
+    private BigDecimal lastAlipayIncome;
+    @ApiModelProperty(value = "银行收入")
+    private BigDecimal bankIncome;
+    @ApiModelProperty(value = "上一账期银行汇总")
+    private BigDecimal lastBankIncome;
+    @ApiModelProperty(value = "账期年")
+    private Integer year;
+    @ApiModelProperty(value = "账期月")
+    private Integer month;
+    @ApiModelProperty(value = "账期")
+    private LocalDateTime periodDate;
+    @ApiModelProperty(value = "支付方式")
+    private Integer payway;
+    @ApiModelProperty(value = "创建者", hidden = true)
+    private String createBy;
+    @ApiModelProperty(value = "修改者", hidden = true)
+    private String updateBy;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间", hidden = true)
+    private LocalDateTime createDate = LocalDateTime.now();
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间", hidden = true)
+    private LocalDateTime updateDate = LocalDateTime.now();
+    @ApiModelProperty(value = "备注", hidden = true)
+    private String remarks;
+    @ApiModelProperty(value = "删除标识", hidden = true)
+    private String delFlag;
+    @ApiModelProperty(value = "站点ID", hidden = true)
+    private BigInteger siteId;
+    @ApiModelProperty(value = "水司ID", hidden = true)
+    private BigInteger customerId;
+}

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

@@ -468,6 +468,18 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
             PayRechargeaccountDto rechargeaccount = payRechargeaccountMapper.findById(null, amountWaterUsedAmount.getAccountId());
             //应收信息 优先级 水费
             List<PayReceivable> payPayReceivables = payPayReceivableMapper.getReceivableByAmountId(amountWaterUsedAmount.getId());
+
+            BigDecimal debts=BigDecimal.ZERO;
+            for(PayReceivable payReceivable: payPayReceivables){
+                debts=debts.add(payReceivable.getDebt());
+            }
+            //预存<欠费 金额不足不划扣
+            if(rechargeaccount.getRemaining().compareTo(debts) == -1){
+                result =2;
+                return result;
+            }
+
+
             if(rechargeaccount!=null&& payPayReceivables!=null && payPayReceivables.size()>0) {
                 BigDecimal remaining = rechargeaccount.getRemaining();
                 if (remaining.compareTo(BigDecimal.ZERO) == 1) {

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

@@ -12,12 +12,14 @@ import com.bz.smart_city.dto.LoginUser;
 import com.bz.smart_city.dto.pay.BaseClosingAccountInfoDto;
 import com.bz.smart_city.dto.pay.PayBaseConfigDto;
 import com.bz.smart_city.entity.pay.PayAccountSurvey;
+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.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
@@ -125,16 +127,20 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
                     int state = list.get(i).getState();
                     if(state == 1){
                         //把历史结账数据存进去,但不包含本期未结账的
-                        this.insertAccountNumber(list.get(i).getYear(),list.get(i).getMonth());
+                        //this.insertAccountNumber(list.get(i).getYear(),list.get(i).getMonth());
+                        //历史交易数据
+                        this.insertTransaction(list.get(i).getYear(),list.get(i).getMonth());
                     }
                 }
             }else if(count > 0){
                 //存储本期未结账数据
-                this.insertAccountNumber(year,month);
+                //this.insertAccountNumber(year,month);
+                //本期交易未结账数据
+                this.insertTransaction(year,month);
             }
 
             // 更新本账期
-            String msg2 = year + "年" + String.format("%02d", month) + "月已经结账";
+            /*String msg2 = year + "年" + String.format("%02d", month) + "月已经结账";
             baseClosingAccountInfoDto.setEndTime(new Date());
             baseClosingAccountInfoDto.setRemarks(msg2);
             baseClosingAccountInfoDto.setState(1);
@@ -158,7 +164,7 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
                 baseClosingAccountInfoDto.setMonth(1);
             }
             baseClosingAccountInfoDto.setName(baseClosingAccountInfoDto.getYear()+"年"+String.format("%02d", baseClosingAccountInfoDto.getMonth())+"月");
-            this.add(baseClosingAccountInfoDto);
+            this.add(baseClosingAccountInfoDto);*/
         }else{
             message.setStatus(-707);
             message.setMsg(msg);
@@ -168,6 +174,7 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
         return message;
     }
 
+    //添加客户概况信息
     public void insertAccountNumber(Integer year,Integer month){
         LoginUser loginUser = UserUtil.getCurrentUser();
 
@@ -177,57 +184,173 @@ public class BaseClosingAccountInfoServiceImpl implements BaseClosingAccountInfo
         //查询上月总数
         Integer lastYear = null;
         Integer lastMonth = null;
-        if(month == 1){
-            lastYear = year-1;
-            lastMonth = 12;
-        }else{
-            lastYear = year;
-            lastMonth = month -1;
+        try {
+            if(month == 1){
+                lastYear = year-1;
+                lastMonth = 12;
+            }else{
+                lastYear = year;
+                lastMonth = month -1;
+            }
+
+            //根据账期查找历史客户数(仅统计状态为欠费与正常的客户总数之和)
+            Integer accountNumber = payChargeSurveyMapper.getAccountNumber
+                    (start,end,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
+            //根据账期查找历史水表数(仅统计状态为已开户的水表总数)
+            Integer meterNumber = payChargeSurveyMapper.getMeterNumber
+                    (start,end,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
+            //根据账期查找历史开户数(仅统计状态为正常的开户总数)
+            Integer customerNumber = payChargeSurveyMapper.getCustomerNumber
+                    (start,end,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
+
+            //上一账期汇总
+            PayAccountSurvey lastAccount = payChargeSurveyMapper.getlastNumber(lastYear,lastMonth,
+                    BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
+
+            PayAccountSurvey account = new PayAccountSurvey();
+            if(lastAccount != null){
+                //上月总数赋值
+                account.setLastAccountNumber(lastAccount.getAccountNumber() != null ? lastAccount.getAccountNumber() : 0);
+                account.setLastMeterNumber(lastAccount.getMeterNumber() != null ? lastAccount.getMeterNumber() : 0);
+                account.setLastCustomerNumber(lastAccount.getCustomerNumber() != null ? lastAccount.getCustomerNumber() : 0);
+            }else{
+                account.setLastAccountNumber( 0);
+                account.setLastMeterNumber( 0);
+                account.setLastCustomerNumber( 0);
+            }
+            DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+            LocalDateTime ldt = LocalDateTime.parse(start+" 00:00:00",df);
+            account.setPeriodDate(ldt);
+            account.setId(Util.createUUIDId());
+            account.setAccountNumber(accountNumber);
+            account.setMeterNumber(meterNumber);
+            account.setCustomerNumber(customerNumber);
+            account.setYear(year);
+            account.setMonth(month);
+            account.setDelFlag("0");
+            account.setRemarks("");
+            account.setCreateBy(loginUser.getCreateBy());
+            account.setCreateDate(LocalDateTime.now());
+            account.setUpdateBy(loginUser.getCreateBy());
+            account.setUpdateDate(LocalDateTime.now());
+            account.setSiteId(BigInteger.valueOf(loginUser.getSiteId()));
+            account.setCustomerId(BigInteger.valueOf(loginUser.getCustomerId()));
+            //保存记录
+            payChargeSurveyMapper.insertAccountNumber(account);
+        }catch (Exception e) {
+            e.printStackTrace();
         }
+    }
 
-        //根据账期查找历史客户数(仅统计状态为欠费与正常的客户总数之和)
-        Integer accountNumber = payChargeSurveyMapper.getAccountNumber
-                (start,end,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
-        //根据账期查找历史水表数(仅统计状态为已开户的水表总数)
-        Integer meterNumber = payChargeSurveyMapper.getMeterNumber
-                (start,end,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
-        //根据账期查找历史开户数(仅统计状态为正常的开户总数)
-        Integer customerNumber = payChargeSurveyMapper.getCustomerNumber
-                (start,end,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
-
-        PayAccountSurvey lastAccount = payChargeSurveyMapper.getlastNumber(lastYear,lastMonth,
-                BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
-
-        PayAccountSurvey account = new PayAccountSurvey();
-        if(lastAccount != null){
-            //上月总数赋值
-            account.setLastAccountNumber(lastAccount.getAccountNumber() != null ? lastAccount.getAccountNumber() : 0);
-            account.setLastMeterNumber(lastAccount.getMeterNumber() != null ? lastAccount.getMeterNumber() : 0);
-            account.setLastCustomerNumber(lastAccount.getCustomerNumber() != null ? lastAccount.getCustomerNumber() : 0);
-        }else{
-            account.setLastAccountNumber( 0);
-            account.setLastMeterNumber( 0);
-            account.setLastCustomerNumber( 0);
+    /**
+     * 添加交易汇总数据
+     * @param year
+     * @param month
+     */
+    public void insertTransaction(Integer year,Integer month){
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        BigInteger siteId = BigInteger.valueOf(loginUser.getSiteId());
+        BigInteger customerId = BigInteger.valueOf(loginUser.getCustomerId());
+        String start = year+"-"+(String.format("%02d",month))+"-01";
+        String end = year+"-"+(String.format("%02d",month))+"-31";
+        //查询上月总数
+        Integer lastYear = null;
+        Integer lastMonth = null;
+
+         PayTransactionSurvey transactionSurver= new PayTransactionSurvey();
+        try {
+            if(month == 1){
+                lastYear = year-1;
+                lastMonth = 12;
+            }else{
+                lastYear = year;
+                lastMonth = month -1;
+            }
+            //根据账期查找历史数据(现金、微信支付、支付宝、银行)
+            BigDecimal bigDecimalStr = new BigDecimal("0.0");
+            BigDecimal cuttentAmount = payChargeSurveyMapper.getCurrentTran(year,month,siteId,customerId);
+            cuttentAmount = cuttentAmount != null ? cuttentAmount : bigDecimalStr;
+            //上一账期
+            BigDecimal lastAmount = payChargeSurveyMapper.getCurrentTran(lastYear,lastMonth,siteId,customerId);
+            lastAmount = lastAmount != null ? lastAmount : bigDecimalStr;
+            //当前账期按支付方式划分
+            List<PayTransactionSurvey> tranList = payChargeSurveyMapper.getPayAmountList(year,month,siteId,customerId);
+            //上一账期按支付方式划分
+            List<PayTransactionSurvey> lasttranList = payChargeSurveyMapper.getPayAmountList(lastYear,lastMonth,siteId,customerId);
+
+            transactionSurver.setIncomeNumber(cuttentAmount);
+            transactionSurver.setLastIncomeNumber(lastAmount);
+            BigDecimal cashIncome = bigDecimalStr;//现金
+            BigDecimal wechatIncome = bigDecimalStr;//微信
+            BigDecimal alipayIncome = bigDecimalStr;//支付宝
+            BigDecimal bankIncome = bigDecimalStr;//银行
+            //当前账期
+            for(int i=0; i<tranList.size(); i++){
+                Integer payway = tranList.get(i).getPayway();
+                if(payway == 1){
+                    //支付宝
+                    alipayIncome = tranList.get(i).getIncomeNumber();
+                }else if(payway == 2){
+                    //微信
+                    wechatIncome = tranList.get(i).getIncomeNumber();
+                }else if (payway == 3) {
+                    //银行
+                    bankIncome = tranList.get(i).getIncomeNumber();
+                }else if (payway == 4) {
+                    //现金
+                    cashIncome = tranList.get(i).getIncomeNumber();
+                }
+            }
+            transactionSurver.setAlipayIncome(alipayIncome);
+            transactionSurver.setWechatIncome(wechatIncome);
+            transactionSurver.setBankIncome(bankIncome);
+            transactionSurver.setCashIncome(cashIncome);
+            BigDecimal lastAlipayIncome = bigDecimalStr;
+            BigDecimal lastWechatIncome = bigDecimalStr;
+            BigDecimal lastBankIncome = bigDecimalStr;
+            BigDecimal lastCashIncome = bigDecimalStr;
+            //上一账期
+            for(int i=0; i<lasttranList.size(); i++){
+                Integer payway = lasttranList.get(i).getPayway();
+                if(payway == 1){
+                    //支付宝
+                    lastAlipayIncome = lasttranList.get(i).getIncomeNumber();
+                }else if(payway == 2){
+                    //微信
+                    lastWechatIncome = lasttranList.get(i).getIncomeNumber();
+                }else if (payway == 3) {
+                    //银行
+                    lastBankIncome = lasttranList.get(i).getIncomeNumber();
+                }else if (payway == 4) {
+                    //现金
+                    lastCashIncome = lasttranList.get(i).getIncomeNumber();
+                }
+            }
+            transactionSurver.setLastAlipayIncome(lastCashIncome);
+            transactionSurver.setLastWechatIncome(lastWechatIncome);
+            transactionSurver.setLastBankIncome(lastBankIncome);
+            transactionSurver.setLastCashIncome(lastCashIncome);
+
+            DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+            LocalDateTime ldt = LocalDateTime.parse(start+" 00:00:00",df);
+            transactionSurver.setPeriodDate(ldt);
+            transactionSurver.setId(Util.createUUIDId());
+            transactionSurver.setYear(year);
+            transactionSurver.setMonth(month);
+            transactionSurver.setDelFlag("0");
+            transactionSurver.setRemarks("");
+            transactionSurver.setCreateBy(loginUser.getCreateBy());
+            transactionSurver.setCreateDate(LocalDateTime.now());
+            transactionSurver.setUpdateBy(loginUser.getCreateBy());
+            transactionSurver.setUpdateDate(LocalDateTime.now());
+            transactionSurver.setSiteId(BigInteger.valueOf(loginUser.getSiteId()));
+            transactionSurver.setCustomerId(BigInteger.valueOf(loginUser.getCustomerId()));
+
+            payChargeSurveyMapper.insertTransaction(transactionSurver);
+
+        }catch (Exception e) {
+            e.printStackTrace();
         }
-        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
-        LocalDateTime ldt = LocalDateTime.parse(start+" 00:00:00",df);
-        account.setPeriodDate(ldt);
-        account.setId(Util.createUUIDId());
-        account.setAccountNumber(accountNumber);
-        account.setMeterNumber(meterNumber);
-        account.setCustomerNumber(customerNumber);
-        account.setYear(year);
-        account.setMonth(month);
-        account.setDelFlag("0");
-        account.setRemarks("");
-        account.setCreateBy(loginUser.getCreateBy());
-        account.setCreateDate(LocalDateTime.now());
-        account.setUpdateBy(loginUser.getCreateBy());
-        account.setUpdateDate(LocalDateTime.now());
-        account.setSiteId(BigInteger.valueOf(loginUser.getSiteId()));
-        account.setCustomerId(BigInteger.valueOf(loginUser.getCustomerId()));
-        //保存记录
-        payChargeSurveyMapper.insertAccountNumber(account);
     }
 
     @Override

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

@@ -7,7 +7,9 @@ import com.bz.smart_city.dto.LoginUser;
 import com.bz.smart_city.dto.pay.BaseClosingAccountInfoDto;
 import com.bz.smart_city.dto.pay.PayChangePeriodDto;
 import com.bz.smart_city.dto.pay.PayChargeSurveyDto;
+import com.bz.smart_city.dto.pay.PayTransactionSurveyDto;
 import com.bz.smart_city.entity.pay.PayAccountSurvey;
+import com.bz.smart_city.entity.pay.PayTransactionSurvey;
 import com.bz.smart_city.service.pay.PayChargeSurveyService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -37,7 +39,7 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
 
     public static void main(String[] args) {
       try {
-          SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//格式化为年月日
+          /*SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//格式化为年月日
           Calendar startDate = Calendar.getInstance();//起始年月
           startDate.setTime(sdf.parse("2020-07-01"));
           startDate.add(Calendar.YEAR, -1); //月份减1;
@@ -45,7 +47,13 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
 
           Date lastStartMonth = startDate.getTime(); //结果
           String lastStart = sdf.format(lastStartMonth);
-          System.out.println("时间:"+lastStart);
+          System.out.println("时间:"+lastStart);*/
+          DecimalFormat df = new DecimalFormat("0.0");
+          BigDecimal currentIncome = new BigDecimal("100");
+          BigDecimal lastIncome = new BigDecimal("80");
+          BigDecimal income = currentIncome.subtract(lastIncome).divide(lastIncome).multiply(new BigDecimal("100"));
+          String a = df.format(income);
+          System.out.println("收入费率:"+a);
       }catch (Exception e) {
           e.printStackTrace();
       }
@@ -166,4 +174,187 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
         }
         return payChargeSurveyDto;
     }
+
+
+    public PayTransactionSurveyDto tranSurvey(String periodDate){
+        PayTransactionSurveyDto payTransactionSurveyDto = new PayTransactionSurveyDto();
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        BigInteger siteId = BigInteger.valueOf(loginUser.getSiteId());
+        BigInteger customerId = BigInteger.valueOf(loginUser.getCustomerId());
+        BigDecimal defc = new BigDecimal("0.0");
+        try {
+            //判断传过来的时间是否为当前账期,当前账期则查交易明细表,否则查交易记录表
+            String[] split = periodDate.split("-");
+            String y = split[0];
+            String m = split[1];
+            Integer year = Integer.valueOf(y);
+            Integer month = Integer.valueOf(m);
+
+            //本月
+            BigDecimal cashIncome = defc;//现金
+            BigDecimal wechatIncome = defc;//微信支付
+            BigDecimal alipayIncome = defc; //支付宝
+            BigDecimal bankIncome = defc;//银行
+            Integer lastYear = null;
+            Integer lastMonth = null;
+            if(Integer.valueOf(month) == 1){
+                lastYear = year-1;
+                lastMonth = 12;
+            }else{
+                lastYear = year;
+                lastMonth = month -1;
+            }
+
+            List<BaseClosingAccountInfoDto> list = baseClosingAccountInfoMapper.getList(null,null,
+                    siteId,customerId,null);
+            if((year.equals(list.get(0).getYear())) && (month.equals(list.get(0).getMonth()))){
+                //当前账期查询交易明细表
+                List<PayTransactionSurvey> tranList = payChargeSurveyMapper.getCurrentTranRocord(year,month,siteId,customerId);
+                for(int i=0; i<tranList.size(); i++){
+                    Integer payway = tranList.get(i).getPayway();
+                    if(payway == 1){
+                        //支付宝
+                        alipayIncome = tranList.get(i).getIncomeNumber();
+                    }else if(payway == 2){
+                        //微信
+                        wechatIncome = tranList.get(i).getIncomeNumber();
+                    }else if (payway == 3) {
+                        //银行
+                        bankIncome = tranList.get(i).getIncomeNumber();
+                    }else if (payway == 4) {
+                        //现金
+                        cashIncome = tranList.get(i).getIncomeNumber();
+                    }
+                }
+                BigDecimal currentIncome = alipayIncome.add(wechatIncome).add(bankIncome).add(cashIncome);//当前账期收入总数
+                //查找上月收入
+                PayTransactionSurvey lastTran = payChargeSurveyMapper.getLastTranRocord(lastYear,lastMonth,siteId,customerId);
+                BigDecimal lastIncome = lastTran.getIncomeNumber();//上月总数
+                PayTransactionSurvey payTransactionSurvey = new PayTransactionSurvey();
+                payTransactionSurvey.setIncomeNumber(currentIncome);
+                payTransactionSurvey.setLastIncomeNumber(lastIncome);
+                payTransactionSurvey.setCashIncome(cashIncome);
+                payTransactionSurvey.setLastCashIncome(lastTran.getCashIncome() != null ? lastTran.getCashIncome() : defc);
+                payTransactionSurvey.setWechatIncome(wechatIncome);
+                payTransactionSurvey.setLastWechatIncome(lastTran.getWechatIncome() != null ? lastTran.getWechatIncome() : defc);
+                payTransactionSurvey.setAlipayIncome(alipayIncome);
+                payTransactionSurvey.setLastAlipayIncome(lastTran.getAlipayIncome() != null ? lastTran.getAlipayIncome() : defc);
+                payTransactionSurvey.setBankIncome(bankIncome);
+                payTransactionSurvey.setLastBankIncome(lastTran.getBankIncome() != null ? lastTran.getBankIncome() : defc);
+                payTransactionSurvey.setYear(year);
+                payTransactionSurvey.setMonth(month);
+                payTransactionSurveyDto = this.tranCompute(payTransactionSurvey);
+            }else {
+                //查询交易记录表
+                PayTransactionSurvey transactionSurver = payChargeSurveyMapper.getLastTranRocord(year,month,siteId,customerId);
+                transactionSurver.setYear(year);
+                transactionSurver.setMonth(month);
+                payTransactionSurveyDto = this.tranCompute(transactionSurver);
+
+            }
+        }catch (Exception e) {
+            e.printStackTrace();
+        }
+        return payTransactionSurveyDto;
+    }
+
+
+    public PayTransactionSurveyDto tranCompute(PayTransactionSurvey transactionSurver){
+        PayTransactionSurveyDto payTransactionSurveyDto = new PayTransactionSurveyDto();
+        Integer year = transactionSurver.getYear();
+        Integer month = transactionSurver.getMonth();
+        DecimalFormat df = new DecimalFormat("0.0");
+        BigDecimal defc = new BigDecimal("0.0");
+        BigDecimal defb = new BigDecimal("1.0");
+
+        //计算较上月比率
+        String lastCashRate = "";//现金比率
+        String lastWechatRate = "";//微信比率
+        String lastAlipayRate = "";//支付宝比率
+        String lastBankRate = "";//银行比率
+
+        //本月
+        BigDecimal cashIncome = defc;//现金
+        BigDecimal wechatIncome = defc;//微信支付
+        BigDecimal alipayIncome = defc; //支付宝
+        BigDecimal bankIncome = defc;//银行
+        //上月
+        BigDecimal lastcashIncome = defc;//现金
+        BigDecimal lastwechatIncome = defc;//微信支付
+        BigDecimal lastalipayIncome = defc; //支付宝
+        BigDecimal lastbankIncome = defc;//银行
+        try {
+            BigDecimal currentIncome = transactionSurver.getIncomeNumber();//本月收入总数
+            BigDecimal lastIncome = transactionSurver.getLastIncomeNumber();//上月收入总数
+            BigDecimal income = currentIncome.subtract(lastIncome).divide((lastIncome != null && lastIncome.compareTo(BigDecimal.ZERO)==1 ? lastIncome : defb),2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
+            String lastIncomeRate = "";
+            lastIncomeRate = df.format(income);
+
+            //按支付方式
+            cashIncome = transactionSurver.getCashIncome();//本月现金收入
+            lastcashIncome = transactionSurver.getLastCashIncome();//上月现金收入
+            wechatIncome = transactionSurver.getWechatIncome();//本月微信
+            lastwechatIncome = transactionSurver.getLastWechatIncome();//上月微信
+            alipayIncome = transactionSurver.getAlipayIncome();//本月支付宝
+            lastalipayIncome = transactionSurver.getLastAlipayIncome();//上月支付宝
+            bankIncome = transactionSurver.getBankIncome();//本账期银行
+            lastbankIncome = transactionSurver.getLastBankIncome();//上期银行
+            //现金
+            income = cashIncome.subtract(lastcashIncome).divide((lastcashIncome != null && lastcashIncome.compareTo(BigDecimal.ZERO)==1 ? lastcashIncome : defb),2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
+            lastCashRate = df.format(income);
+
+            //微信
+            income = wechatIncome.subtract(lastwechatIncome).divide((lastwechatIncome != null && lastwechatIncome.compareTo(BigDecimal.ZERO)==1 ? lastwechatIncome : defb),2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
+            lastWechatRate = df.format(income);
+
+            //支付宝
+            income = alipayIncome.subtract(lastalipayIncome).divide((lastalipayIncome != null && lastalipayIncome.compareTo(BigDecimal.ZERO)==1 ? lastalipayIncome : defb), 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
+            lastAlipayRate = df.format(income);
+
+            //银行
+            income = bankIncome.subtract(lastbankIncome).divide((lastbankIncome != null && lastbankIncome.compareTo(BigDecimal.ZERO)==1 ? lastbankIncome : defb),2,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
+            lastBankRate = df.format(income);
+
+            //饼状态占比率
+            currentIncome = alipayIncome.add(wechatIncome).add(bankIncome).add(cashIncome);
+            String CashRate = "";
+            String alipayRate = "";
+            String wechatRate = "";
+            String bankRate = "";
+            income = cashIncome.divide(currentIncome,2, BigDecimal.ROUND_HALF_UP);
+            CashRate = df.format(income);
+
+            income = alipayIncome.divide(currentIncome,2, BigDecimal.ROUND_HALF_UP);
+            alipayRate = df.format(income);
+
+            income = wechatIncome.divide(currentIncome,2, BigDecimal.ROUND_HALF_UP);
+            wechatRate = df.format(income);
+
+            income = bankIncome.divide(currentIncome,2, BigDecimal.ROUND_HALF_UP);
+            bankRate = df.format(income);
+
+            //收入总数
+            payTransactionSurveyDto.setIncomeNumber(currentIncome);
+            payTransactionSurveyDto.setLastIncomeRate(lastIncomeRate);
+            //按支付方式
+            payTransactionSurveyDto.setCashIncome(cashIncome);
+            payTransactionSurveyDto.setLastCashRate(lastCashRate);
+            payTransactionSurveyDto.setWechatIncome(wechatIncome);
+            payTransactionSurveyDto.setLastWechatRate(lastWechatRate);
+            payTransactionSurveyDto.setAlipayIncome(alipayIncome);
+            payTransactionSurveyDto.setLastAlipayRate(lastAlipayRate);
+            payTransactionSurveyDto.setBankIncome(bankIncome);
+            payTransactionSurveyDto.setLastBankRate(lastBankRate);
+            payTransactionSurveyDto.setCashRate(CashRate);
+            payTransactionSurveyDto.setAlipayRate(alipayRate);
+            payTransactionSurveyDto.setWechatRate(wechatRate);
+            payTransactionSurveyDto.setBankRate(bankRate);
+            payTransactionSurveyDto.setYear(year);
+            payTransactionSurveyDto.setMonth(month);
+            payTransactionSurveyDto.setPeriodDates(year+"-"+String.format("%02d",month));
+        }catch (Exception e) {
+            e.printStackTrace();
+        }
+        return payTransactionSurveyDto;
+    }
 }

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

@@ -5,14 +5,10 @@ import com.bz.smart_city.commom.exception.ServiceException;
 import com.bz.smart_city.commom.model.ResultStatus;
 import com.bz.smart_city.commom.util.UserUtil;
 import com.bz.smart_city.commom.util.Util;
-import com.bz.smart_city.dao.pay.PayFeeMapper;
-import com.bz.smart_city.dao.pay.PayPayReceivedMapper;
-import com.bz.smart_city.dao.pay.PaySysDictMapper;
-import com.bz.smart_city.dao.pay.PayTransactiondetailsMapper;
+import com.bz.smart_city.dao.pay.*;
 import com.bz.smart_city.dto.LoginUser;
-import com.bz.smart_city.dto.pay.PayCustomRechargeDto;
-import com.bz.smart_city.dto.pay.PaySysDictSelectDto;
-import com.bz.smart_city.dto.pay.PayTransactiondetails;
+import com.bz.smart_city.dto.pay.*;
+import com.bz.smart_city.dto.pay.payfee.*;
 import com.bz.smart_city.entity.pay.BaseClosingAccountInfo;
 import com.bz.smart_city.entity.pay.PayPayReceived;
 import com.bz.smart_city.entity.pay.PayReceivable;
@@ -52,6 +48,197 @@ public class PayFeeServiceImp implements PayFeeService {
     @Resource
     PaySysDictMapper sysDictMapper;
 
+    @Resource
+    BaseClosingAccountInfoMapper baseClosingAccountInfoMapper;
+
+    public String payFeeCounter( String id,Integer payway,BigDecimal transAmount, Integer balancetype){
+        LoginUser loginUser = UserUtil.getCurrentUser();
+
+        Integer siteId = loginUser.getSiteId();
+
+        Integer customerId = loginUser.getCustomerId();
+
+        Integer userId = loginUser.getId();
+
+        if(siteId ==null || customerId == null || userId == null){
+            throw new ServiceException(ResultStatus.ACCOUNT_OPERATOR_EERROR);
+        }
+        //根据客编或者水编获取客户信息
+        PayCustomRechargeDto payCustomRechargeDto = payFeeMapper.getCustomInfoByMeterOrAccount(id,null,null,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
+
+        List<PayReceivable> payReceivableList =payFeeMapper.getReceivable(loginUser.getSiteId(),loginUser.getCustomerId(),payCustomRechargeDto.getAccountId(),null);
+
+        if(payReceivableList.size() == 0){ //没有应收信息走仅充值
+            return rechargefeeCounter(id, transAmount, payway);
+        }else{
+            BigDecimal debts=BigDecimal.ZERO;
+            for(PayReceivable payReceivable: payReceivableList){
+                debts=debts.add(payReceivable.getDebt());
+            }
+            //预存+实收<欠费 金额不足
+            if(payCustomRechargeDto.getRemaining().add(transAmount).compareTo(debts) == -1){
+                throw new ServiceException(ResultStatus.PAYFEE_NOT_ENOUGH);
+            }
+        }
+
+        //支付方式
+        List<PaySysDictSelectDto> payways = sysDictMapper.getDicts("支付方式",BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
+        if(payways.size() == 0){
+            throw new ServiceException(ResultStatus.PAYFEE_QUERY_NO_PAYWAY);
+        }
+        String paywayName = payways.stream().filter(item -> item.getValue().equals(payway.toString())).findFirst().get().getLabel();
+
+//         Map<String,PaySysDictSelectDto> paywayMap = payways.stream().collect(Collectors.toMap(PaySysDictSelectDto::getValue, PaySysDictSelectDto->PaySysDictSelectDto));
+        //收费类型
+        List<PaySysDictSelectDto> feetypes = sysDictMapper.getDicts("收费类型",BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
+        if(payways.size() == 0) {
+            throw new ServiceException(ResultStatus.PAYFEE_QUERY_NO_TRANSTYPE);
+        }
+        Map<String, PaySysDictSelectDto> feetypeMap = feetypes.stream().collect(Collectors.toMap(PaySysDictSelectDto::getValue, PaySysDictSelectDto -> PaySysDictSelectDto));
+        //如果传入时间则用传入的时间做交易时间
+        LocalDateTime localDateTime=LocalDateTime.now();
+
+        //交易金额不可为负数
+        if(transAmount.compareTo(BigDecimal.ZERO)==-1){
+            throw new ServiceException(ResultStatus.PAYFEE_TRANSAMOUNT_BELOW_ZERO);
+        }
+
+        //生成批次号
+        // 微信:W  现金、预存账户:C 银行:B 支付宝:A
+        String payseriesno= Util.getBatchNo(paywayName.equals("微信支付")?"W":paywayName.equals("支付宝")?"A":paywayName.equals("银行")?"B":"C"
+                ,payCustomRechargeDto.getAccountnumber());
+        //获取账期
+        BaseClosingAccountInfo baseClosingAccountInfo=payFeeMapper.getLastClosingAccount(siteId,customerId);
+        if(baseClosingAccountInfo == null){
+            //获取账期信息失败
+            throw new ServiceException(ResultStatus.PAYFEE_QUERY_NO_CLOSINGACCOUNT);
+        }
+        int month =baseClosingAccountInfo.getMonth();
+        int year =baseClosingAccountInfo.getYear();
+        //余额
+        BigDecimal remaining = payCustomRechargeDto.getRemaining();
+        //用作明细记录交易前余额
+        BigDecimal oldRemaining = payCustomRechargeDto.getRemaining();
+        //交易明细最后统一赋值交易前后余额,批量保存
+        List<PayTransactiondetails> transactiondetailsDtoList = new ArrayList();
+        //预存抵扣
+        Iterator<PayReceivable> iterator = payReceivableList.iterator();
+        while(iterator.hasNext()) {
+            //抵扣的应收
+            PayReceivable payReceivable=iterator.next();
+            //账户余额先抵扣
+            if (remaining.compareTo(BigDecimal.ZERO) == 1) {
+                if(payReceivable.getDebt().compareTo(BigDecimal.ZERO) != 1){
+                    //欠费不大于零直接移除
+                    iterator.remove();
+                }else if(remaining.compareTo(payReceivable.getDebt()) != -1){
+                    //预存余额不小于欠费(完全抵扣)
+                    iterator.remove();
+                    remaining = remaining.subtract(payReceivable.getDebt());//修改余额
+                    //生成并保存实收
+                    PayPayReceived payPayReceived = getReceived(payReceivable, year, month, localDateTime,payway,payseriesno,payReceivable.getDebt(),feetypeMap, siteId, customerId, userId );
+                    //生成交易明细
+                    PayTransactiondetails payTransactiondetails = getPayTransactiondetails(5,paywayName, localDateTime, payCustomRechargeDto, payseriesno, month, year, payReceivable.getDebt().negate(), siteId, customerId, userId );
+                    payTransactiondetails.setReceivedId(payPayReceived.getId());
+                    payTransactiondetails.setName(payCustomRechargeDto.getAccountname() + payCustomRechargeDto.getAccountnumber() + "扣费");
+                    payTransactiondetails.setTranstype(2);
+                    payTransactiondetails.setTranstypeLabel("扣费");
+                    transactiondetailsDtoList.add(payTransactiondetails);
+                    //修改应收
+                    payReceivable.setDebt(BigDecimal.ZERO);
+                    payReceivable.setUpdateDate(localDateTime);
+                    payReceivable.setUpdateBy(BigInteger.valueOf(userId));
+                    payFeeMapper.updatePayReceivable(payReceivable);
+                }else{
+                    //预存余额小于于欠费(部分抵扣)
+                    //生成并保存实收
+                    PayPayReceived payPayReceived = getReceived(payReceivable, year, month, localDateTime,payway,payseriesno,remaining,feetypeMap, siteId, customerId, userId );
+
+                    PayTransactiondetails payTransactiondetails = getPayTransactiondetails(5, paywayName,localDateTime, payCustomRechargeDto, payseriesno, month, year, remaining.negate() , siteId, customerId, userId );
+                    payTransactiondetails.setReceivedId(payPayReceived.getId());
+                    payTransactiondetails.setName(payCustomRechargeDto.getAccountname() + payCustomRechargeDto.getAccountnumber() + "扣费");
+                    payTransactiondetails.setTranstype(2);
+                    payTransactiondetails.setTranstypeLabel("扣费");
+                    transactiondetailsDtoList.add(payTransactiondetails);
+                    //修改应收
+                    payReceivable.setDebt(payReceivable.getDebt().subtract(remaining));
+                    payReceivable.setUpdateDate(localDateTime);
+                    payReceivable.setUpdateBy(BigInteger.valueOf(userId));
+                    payFeeMapper.updatePayReceivable(payReceivable);
+
+                    remaining = BigDecimal.ZERO;//修改余额
+                    break;
+                }
+            }
+        }
+
+        //缴费抵扣
+        Iterator<PayReceivable> iteratorTransAmount = payReceivableList.iterator();
+        while(iteratorTransAmount.hasNext()) {
+            //抵扣的应收
+            PayReceivable payReceivable=iteratorTransAmount.next();
+            //交易金额抵扣
+            if (transAmount.compareTo(BigDecimal.ZERO) == 1) {
+                if(payReceivable.getDebt().compareTo(BigDecimal.ZERO) != 1){
+                    //欠费不大于零直接移除
+                    iteratorTransAmount.remove();
+                }else if(transAmount.compareTo(payReceivable.getDebt()) != -1){
+                    //交易金额不小于欠费(完全抵扣)
+                    iteratorTransAmount.remove();
+                    transAmount = transAmount.subtract(payReceivable.getDebt());//修改剩余交易金额
+
+                    //生成并保存实收
+                    getReceived(payReceivable, year, month, localDateTime,payway,payseriesno,payReceivable.getDebt(),feetypeMap, siteId, customerId, userId );
+                    //修改应收
+                    payReceivable.setDebt(BigDecimal.ZERO);
+                    payReceivable.setUpdateDate(localDateTime);
+                    payReceivable.setUpdateBy(BigInteger.valueOf(userId));
+                    payFeeMapper.updatePayReceivable(payReceivable);
+
+                }else{
+                    //交易金额小于于欠费(部分抵扣)
+                    //生成并保存实收
+                    getReceived(payReceivable, year, month, localDateTime,payway,payseriesno,transAmount,feetypeMap, siteId, customerId, userId );
+                    //修改应收
+                    payReceivable.setDebt(payReceivable.getDebt().subtract(transAmount));
+                    payReceivable.setUpdateDate(localDateTime);
+                    payReceivable.setUpdateBy(BigInteger.valueOf(userId));
+                    payFeeMapper.updatePayReceivable(payReceivable);
+                    transAmount = BigDecimal.ZERO;//修改余额
+                    break;
+                }
+            }
+        }
+        //余额充值或划扣有余额
+        if(balancetype == 1 && transAmount.compareTo(BigDecimal.ZERO) == 1){
+            //修改余额
+            remaining=remaining.add(transAmount);
+            //生成交易明细
+            PayTransactiondetails payTransactiondetails = getPayTransactiondetails(payway, paywayName,localDateTime, payCustomRechargeDto, payseriesno, month, year, transAmount, siteId, customerId, userId  );
+            payTransactiondetails.setName(payCustomRechargeDto.getAccountname() + payCustomRechargeDto.getAccountnumber() + "充值");
+            payTransactiondetails.setTranstype(4);
+            payTransactiondetails.setTranstypeLabel("账户转预存");
+            transactiondetailsDtoList.add(payTransactiondetails);
+        }
+
+        //修改预存账户
+        payFeeMapper.updateRechargeaccount(remaining,BigInteger.valueOf(userId),localDateTime,payCustomRechargeDto.getRechargeId());
+        //更新客户状态
+        payFeeMapper.updateAccountState(payCustomRechargeDto.getAccountId());
+        //赋值交易明细交易前后余额并保存
+        for(PayTransactiondetails payTransactiondetails : transactiondetailsDtoList){
+            payTransactiondetails.setRemaining(oldRemaining);//交易前账户余额
+            payTransactiondetails.setLastrecreamaing(remaining);//交易后账户余额
+        }
+        //批量保存交易明细
+        if(transactiondetailsDtoList.size()>0)
+            payTransactiondetailsMapper.batchInsert(transactiondetailsDtoList);
+        //返回批次号
+        return  payseriesno;
+
+
+    }
+
    /*
     * @Description: 缴纳欠费
     * @auther: wangli
@@ -88,7 +275,7 @@ public class PayFeeServiceImp implements PayFeeService {
        //根据客编或者水编获取客户信息
        PayCustomRechargeDto payCustomRechargeDto = null;
        if(StringUtils.isEmpty(accountnumber) || StringUtils.isEmpty(metercode)){
-           payCustomRechargeDto= payFeeMapper.getCustomInfoByMeterOrAccount(accountnumber,metercode,BigInteger.valueOf(siteId),BigInteger.valueOf(customerId));
+           payCustomRechargeDto= payFeeMapper.getCustomInfoByMeterOrAccount(null,accountnumber,metercode,BigInteger.valueOf(siteId),BigInteger.valueOf(customerId));
        }
 
        List<PayReceivable> payReceivableList =null;
@@ -99,7 +286,7 @@ public class PayFeeServiceImp implements PayFeeService {
            payReceivableList=payFeeMapper.getReceivable(siteId,customerId,null,receivableIds);
            //未传客编或者水编,通过应收信息查询客户信息
            if(payReceivableList != null && payReceivableList.size()>0){
-               payCustomRechargeDto = payFeeMapper.getCustomInfoByMeterOrAccount(payReceivableList.get(0).getAccountnumber(),null,BigInteger.valueOf(siteId),BigInteger.valueOf(customerId));
+               payCustomRechargeDto = payFeeMapper.getCustomInfoByMeterOrAccount(null,payReceivableList.get(0).getAccountnumber(),null,BigInteger.valueOf(siteId),BigInteger.valueOf(customerId));
            }else{
                //获取客户信息失败
                throw new ServiceException(ResultStatus.PAYFEE_QUERY_NO_CUSTOMER);
@@ -110,6 +297,15 @@ public class PayFeeServiceImp implements PayFeeService {
        }
        if(payReceivableList.size() == 0){ //没有应收信息走仅充值
            return rechargefee( accountnumber,  metercode,  transAmount,  payway ,  transTime,siteId,customerId,userId);
+       }else{
+           BigDecimal debts=BigDecimal.ZERO;
+           for(PayReceivable payReceivable: payReceivableList){
+               debts=debts.add(payReceivable.getDebt());
+           }
+           //预存+实收<欠费 金额不足
+           if(payCustomRechargeDto.getRemaining().add(transAmount).compareTo(debts) == -1){
+               throw new ServiceException(ResultStatus.PAYFEE_NOT_ENOUGH);
+           }
        }
 
         //支付方式
@@ -285,6 +481,63 @@ public class PayFeeServiceImp implements PayFeeService {
 
     }
 
+    /*
+     * @Description: 仅充值
+     * @auther: wangli
+     * @date: 2020-04-28 10:32
+     * @param: accountnumber 客户编码
+     * @param: metercode 水表编码
+     * @param: transAmount 交易金额
+     * @param: payway 支付方式
+     * @param: transTime 交易时间 :为空时取当前时间
+     * @return: payseriesno 交易流水号
+     *
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public String rechargefeeCounter(String  accountId , BigDecimal transAmount, Integer payway ){
+        LoginUser loginUser = UserUtil.getCurrentUser();
+
+        Integer siteId = loginUser.getSiteId();
+
+        Integer customerId = loginUser.getCustomerId();
+
+        Integer userId = loginUser.getId();
+
+        if(siteId ==null || customerId == null || userId == null){
+            throw new ServiceException(ResultStatus.ACCOUNT_OPERATOR_EERROR);
+        }
+        //支付方式
+        List<PaySysDictSelectDto> payways = sysDictMapper.getDicts("支付方式",BigInteger.valueOf(siteId),BigInteger.valueOf(customerId));
+        if(payways.size() == 0){
+            throw new ServiceException(ResultStatus.PAYFEE_QUERY_NO_PAYWAY);
+        }
+        String paywayName = payways.stream().filter(item -> item.getValue().equals(payway.toString())).findFirst().get().getLabel();
+
+        //如果传入时间则用传入的时间做交易时间
+        LocalDateTime localDateTime=LocalDateTime.now();
+
+        //交易金额不可为负数
+        if(transAmount.compareTo(BigDecimal.ZERO)==-1){
+            throw new ServiceException(ResultStatus.PAYFEE_TRANSAMOUNT_BELOW_ZERO);
+        }
+
+        //根据客编或者水编获取客户信息
+        PayCustomRechargeDto payCustomRechargeDto = null;
+        if(StringUtils.isEmpty(accountId)){
+            payCustomRechargeDto= payFeeMapper.getCustomInfoByMeterOrAccount(accountId,null,null,BigInteger.valueOf(siteId),BigInteger.valueOf(customerId));
+        }
+
+        if(payCustomRechargeDto == null ){
+            //获取客户信息失败
+            throw new ServiceException(ResultStatus.PAYFEE_QUERY_NO_CUSTOMER);
+        }
+        //生成批次号
+        // 微信:W  现金、预存账户:C 银行:B 支付宝:A
+        String payseriesno = recharge(transAmount, payway, siteId, customerId, userId, paywayName, localDateTime, payCustomRechargeDto);
+        return payseriesno;
+    }
+
+
     /*
      * @Description: 仅充值
      * @auther: wangli
@@ -334,40 +587,45 @@ public class PayFeeServiceImp implements PayFeeService {
         //根据客编或者水编获取客户信息
         PayCustomRechargeDto payCustomRechargeDto = null;
         if(StringUtils.isEmpty(accountnumber) || StringUtils.isEmpty(metercode)){
-            payCustomRechargeDto= payFeeMapper.getCustomInfoByMeterOrAccount(accountnumber,metercode,BigInteger.valueOf(siteId),BigInteger.valueOf(customerId));
+            payCustomRechargeDto= payFeeMapper.getCustomInfoByMeterOrAccount(null,accountnumber,metercode,BigInteger.valueOf(siteId),BigInteger.valueOf(customerId));
         }
 
         if(payCustomRechargeDto == null ){
             //获取客户信息失败
             throw new ServiceException(ResultStatus.PAYFEE_QUERY_NO_CUSTOMER);
         }
+        String payseriesno = recharge(transAmount, payway, siteId, customerId, userId, paywayName, localDateTime, payCustomRechargeDto);
+        return payseriesno;
+    }
+
+    private String recharge(BigDecimal transAmount, Integer payway, Integer siteId, Integer customerId, Integer userId, String paywayName, LocalDateTime localDateTime, PayCustomRechargeDto payCustomRechargeDto) {
         //生成批次号
         // 微信:W  现金、预存账户:C 银行:B 支付宝:A
-        String payseriesno= Util.getBatchNo(paywayName.equals("微信支付")?"W":paywayName.equals("支付宝")?"A":paywayName.equals("银行")?"B":"C"
-                ,payCustomRechargeDto.getAccountnumber());
+        String payseriesno = Util.getBatchNo(paywayName.equals("微信支付") ? "W" : paywayName.equals("支付宝") ? "A" : paywayName.equals("银行") ? "B" : "C"
+                , payCustomRechargeDto.getAccountnumber());
         //获取账期
-        BaseClosingAccountInfo baseClosingAccountInfo=payFeeMapper.getLastClosingAccount(siteId,customerId);
-        if(baseClosingAccountInfo == null){
+        BaseClosingAccountInfo baseClosingAccountInfo = payFeeMapper.getLastClosingAccount(siteId, customerId);
+        if (baseClosingAccountInfo == null) {
             //获取账期信息失败
             throw new ServiceException(ResultStatus.PAYFEE_QUERY_NO_CLOSINGACCOUNT);
         }
-        int month =baseClosingAccountInfo.getMonth();
-        int year =baseClosingAccountInfo.getYear();
+        int month = baseClosingAccountInfo.getMonth();
+        int year = baseClosingAccountInfo.getYear();
         //余额
         BigDecimal remaining = payCustomRechargeDto.getRemaining();
 
         //生成交易明细
-        PayTransactiondetails payTransactiondetails = getPayTransactiondetails(payway, paywayName,localDateTime, payCustomRechargeDto, payseriesno, month, year, transAmount, siteId, customerId, userId );
+        PayTransactiondetails payTransactiondetails = getPayTransactiondetails(payway, paywayName, localDateTime, payCustomRechargeDto, payseriesno, month, year, transAmount, siteId, customerId, userId);
         payTransactiondetails.setName(payCustomRechargeDto.getAccountname() + payCustomRechargeDto.getAccountnumber() + "充值");
         payTransactiondetails.setTranstype(1);
         payTransactiondetails.setTranstypeLabel("充值");
         payTransactiondetails.setRemaining(remaining);//交易前账户余额
-        remaining=remaining.add(transAmount);
+        remaining = remaining.add(transAmount);
         payTransactiondetails.setLastrecreamaing(remaining);//交易后账户余额
         payTransactiondetailsMapper.insert(payTransactiondetails);
 
         //修改预存账户
-        payFeeMapper.updateRechargeaccount(remaining,BigInteger.valueOf(userId),localDateTime,payCustomRechargeDto.getRechargeId());
+        payFeeMapper.updateRechargeaccount(remaining, BigInteger.valueOf(userId), localDateTime, payCustomRechargeDto.getRechargeId());
         //更新客户状态
         payFeeMapper.updateAccountState(payCustomRechargeDto.getAccountId());
         return payseriesno;
@@ -471,4 +729,92 @@ public class PayFeeServiceImp implements PayFeeService {
         payPayReceivedMapper.insert(payReceived);
         return payReceived;
     }
+
+    public List<PayfeeAccountInfoDto> findPayfeeAccountInfo(BigInteger id, Integer queryType , String condition ){
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        return payFeeMapper.findPayfeeAccountInfo(id, queryType , condition ,loginUser.getSiteId(),loginUser.getCustomerId());
+    }
+
+    public PayfeeDetaileBill getPayfeeDetaileBill(BigInteger id){
+        if(id == null){
+            return new PayfeeDetaileBill();
+        }
+        return payFeeMapper.getPayfeeDetaileBill(id);
+    }
+
+    public PayfeeDetailed getPayfeeDetailed(BigInteger id  ){
+        if(id == null){
+            return new PayfeeDetailed();
+        }
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        //获取最新账期
+        BaseClosingAccountInfoDto baseClosingAccountInfoDto=baseClosingAccountInfoMapper.getLastClosingAccount(loginUser.getSiteId(),loginUser.getCustomerId());
+       return  payFeeMapper.getPayfeeDetailed(id,baseClosingAccountInfoDto.getYear(),baseClosingAccountInfoDto.getMonth());
+    }
+
+    /**
+     * 查询客户欠费信息
+     * @param accountId
+     * @param year
+     * @return
+     */
+    public List<PayfeeReceivableInfo> getPayreceiveDebt(BigInteger accountId , Integer year){
+        return payFeeMapper.getPayreceivableDebt(accountId,year);
+    }
+
+    /**
+     * 查询账期内欠费详情
+     * @param accountId 客户id
+     * @param year
+     * @param month
+     * @return
+     */
+    public List<PayfeeReceivableInfo> getPayreceiveDebtDetailed(BigInteger accountId , Integer year , Integer month){
+        return payFeeMapper.getPayreceivableDebtDetailed(accountId, year, month);
+    }
+
+    /**
+     * 查询实收信息
+     * @param accountId
+     * @param year
+     * @return
+     */
+    public List<PayfeeReceivedInfo> getPayreceived(BigInteger accountId , Integer year ){
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        return payFeeMapper.getPayreceived(accountId, year,  loginUser.getSiteId(), loginUser.getCustomerId());
+    }
+
+    /**
+     * 查询实收明细
+     * @param accountId
+     * @param payseriesno
+     * @param year
+     * @param month
+     * @return
+     */
+    public List<PayfeeReceivedInfo> getPayreceivedDetailed(BigInteger accountId , String payseriesno,Integer year , Integer month){
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        return payFeeMapper.getPayreceivedDetailed(accountId, payseriesno, year, month, loginUser.getSiteId(), loginUser.getCustomerId());
+    }
+
+    /**
+     * 查询水量信息
+     * @param accountId
+     * @param year
+     * @return
+     */
+    public List<PayfeeWaterusedamount> getWaterusedamount(BigInteger accountId , Integer year){
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        return payFeeMapper.getWaterusedamount(accountId, year,  loginUser.getSiteId(), loginUser.getCustomerId());
+    }
+
+    /**
+     * 查询收据信息
+     * @param accountId
+     * @param year
+     * @return
+     */
+    public List<PayInvoiceDto> getPayinvoiceInfo(BigInteger accountId, Integer year) {
+        return payFeeMapper.getPayinvoiceInfo(accountId, year);
+    }
 }

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

@@ -0,0 +1,174 @@
+package com.bz.smart_city.service.impl.pay;
+
+import com.bz.smart_city.commom.model.Pagination;
+import com.bz.smart_city.commom.util.UserUtil;
+import com.bz.smart_city.dao.pay.PayInvoiceMapper;
+import com.bz.smart_city.dto.LoginUser;
+import com.bz.smart_city.dto.pay.PayInvoiceDto;
+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.entity.pay.PayInvoice;
+import com.bz.smart_city.entity.pay.PayPayReceived;
+import com.bz.smart_city.service.pay.PayinvoiceService;
+import com.github.pagehelper.PageHelper;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.List;
+
+/**
+ * @description
+ * @auto wangli
+ * @data 2020-07-30 9:50
+ */
+@Service
+public class PayInvoiceServiceImpl implements PayinvoiceService {
+
+    @Resource
+    private PayInvoiceMapper payInvoiceMapper;
+
+    public void insert(PayInvoice payInvoice) {
+        payInvoiceMapper.insert(payInvoice);
+    }
+
+    public List<PayInvoiceDto> findList(String condition, Integer state, String startTime, String endTime) {
+        LoginUser loginUser= UserUtil.getCurrentUser();
+        PayInvoiceDto payInvoiceDto=new PayInvoiceDto();
+        payInvoiceDto.setCondition(condition);
+        payInvoiceDto.setState(state);
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
+        if(StringUtils.isNotBlank(startTime)){
+            payInvoiceDto.setStartTime( LocalDateTime.parse(startTime,df));
+        }
+        if(StringUtils.isNotBlank(endTime)){
+            payInvoiceDto.setEndTime(LocalDateTime.parse(endTime, df));
+        }
+
+        payInvoiceDto.setSiteId(loginUser.getSiteId());
+        payInvoiceDto.setProgramItems(UserUtil.getCurrentSiteProgramItems(loginUser));
+        payInvoiceDto.setCustomerId(loginUser.getCustomerId());
+
+        return payInvoiceMapper.findList(payInvoiceDto);
+    }
+
+    public Pagination<PayInvoiceDto> findListPage(String condition,Integer state, String startTime, String endTime, int pageNum, int pageSize) {
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        //分页
+        PageHelper.startPage(pageNum,pageSize);
+
+        PayInvoiceDto payInvoiceDto=new PayInvoiceDto();
+        payInvoiceDto.setCondition(condition);
+        payInvoiceDto.setState(state);
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
+        if(StringUtils.isNotBlank(startTime)){
+            payInvoiceDto.setStartTime( LocalDateTime.parse(startTime,df));
+        }
+        if(StringUtils.isNotBlank(endTime)){
+            payInvoiceDto.setEndTime(LocalDateTime.parse(endTime, df));
+        }
+        //站点为空则加入用户站点查询
+        if( loginUser !=null){
+            //站点权限
+            payInvoiceDto.setSiteId(loginUser.getSiteId());
+            //客户权限
+            payInvoiceDto.setCustomerId(loginUser.getCustomerId());
+            //数据权限
+            payInvoiceDto.setProgramItems(UserUtil.getCurrentSiteProgramItems(loginUser));
+        }
+
+        List<PayInvoiceDto> list = payInvoiceMapper.findList(payInvoiceDto);
+        return new Pagination<>(list);
+    }
+
+    @Transactional(rollbackFor=Exception.class)
+    public void savePrintInfo(String payseriesno,String invoiceno) {
+        LoginUser loginUser=UserUtil.getCurrentUser();
+               BigDecimal countReceivedamount=BigDecimal.ZERO;
+        PayInvoice invoice=new PayInvoice();
+        invoice.setInvoiceno(invoiceno);
+
+        invoice.setState(2);
+        invoice.setType(2);
+        invoice.setCreateDate(LocalDateTime.now());
+        invoice.setCreateBy(BigInteger.valueOf(loginUser.getId()));
+        invoice.setUpdateBy(BigInteger.valueOf(loginUser.getId()));
+        invoice.setUpdateDate(LocalDateTime.now());
+        invoice.setDelFlag("0");
+        invoice.setSiteId(BigInteger.valueOf(loginUser.getSiteId()));
+        invoice.setCustomerId(BigInteger.valueOf(loginUser.getCustomerId()));
+        invoice.setRemarks("");
+
+        //获取同批次号的交易明细
+        List<PayTransactiondetailsDto> payTransactiondetailsList=payInvoiceMapper.findTransByPayseriesno(payseriesno,loginUser.getSiteId(),loginUser.getCustomerId());
+
+        for(PayTransactiondetailsDto payTransactiondetailsDto:payTransactiondetailsList){
+            //转预存或充值金额
+            if(payTransactiondetailsDto.getPayway()!=4&&(payTransactiondetailsDto.getTranstype()==1||payTransactiondetailsDto.getTranstype()==4)){
+                countReceivedamount = countReceivedamount.add(payTransactiondetailsDto.getTransamount()!=null?payTransactiondetailsDto.getTransamount():BigDecimal.ZERO);
+
+                invoice.setAccountId(payTransactiondetailsDto.getAccountId());
+                invoice.setAccountname(payTransactiondetailsDto.getAccountname());
+                invoice.setAccountnumber(payTransactiondetailsDto.getAccountnumber());
+            }
+        }
+        //获取同批次号的实收信息
+        List<PayPayReceived> Receiveds=payInvoiceMapper.findReceivedByPayseriesno(payseriesno,loginUser.getSiteId(),loginUser.getCustomerId());
+
+        for(PayPayReceived received:Receiveds){
+            //非预存划扣(即支付金额抵扣)
+            if(received.getPayway()!=4){
+                countReceivedamount = countReceivedamount.add(received.getReceivedamount()!=null?received.getReceivedamount():BigDecimal.ZERO);
+
+                invoice.setAccountId(received.getAccountId());
+                invoice.setAccountname(received.getAccountname());
+                invoice.setAccountnumber(received.getAccountnumber());
+            }
+
+        }
+        invoice.setInvoiceamount(countReceivedamount);
+        //插入成功后返回id
+        payInvoiceMapper.insert(invoice);
+        if(payTransactiondetailsList.size()>0){
+            //修改明细的收据信息
+            payInvoiceMapper.updatePrintInvoiceRecord(1, payseriesno, invoice.getId(),loginUser.getSiteId(),loginUser.getCustomerId());
+        }
+        if(Receiveds.size()>0){
+            //修改实收的收据信息
+            payInvoiceMapper.updatePrintInvoiceRecord(2, payseriesno, invoice.getId(),loginUser.getSiteId(),loginUser.getCustomerId());
+        }
+    }
+
+    /**
+     * 仅充值
+     * @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;
+    }
+    public PrintInvoiceData getPrintDataOfReceived(String payseriesno){
+        return null;
+    }
+
+
+
+
+}

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

@@ -1,9 +1,13 @@
 package com.bz.smart_city.service.pay;
 
 import com.bz.smart_city.dto.pay.PayChargeSurveyDto;
+import com.bz.smart_city.dto.pay.PayTransactionSurveyDto;
+import com.bz.smart_city.entity.pay.PayTransactionSurvey;
 
 public interface PayChargeSurveyService {
     public Integer getAccountCount();
 
     public PayChargeSurveyDto accountSurvey();
+
+    public PayTransactionSurveyDto tranSurvey(String periodDate);
 }

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

@@ -1,5 +1,8 @@
 package com.bz.smart_city.service.pay;
 
+import com.bz.smart_city.dto.pay.PayInvoiceDto;
+import com.bz.smart_city.dto.pay.payfee.*;
+
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.time.LocalDateTime;
@@ -12,5 +15,103 @@ import java.util.List;
  * @Version 1.0
  */
 public interface PayFeeService {
+    /**
+     * @Description: 缴纳欠费
+     * @auther: wangli
+     * @date: 2020-04-22 16:35
+     * @param: accountnumber 客户编码
+     * @param: metercode 水表编码
+     * @param: transAmount 交易金额
+     * @param: payway 支付方式
+     * @param: transTime 交易时间 :为空时取当前时间
+     * @param: receivableIds 应收id
+     * @return: payseriesno 交易流水号
+     *
+     */
     String payFee(String accountnumber , String metercode , BigDecimal transAmount, Integer paytype , LocalDateTime transTime, List<BigInteger> receivableIds,Integer siteId,Integer customerId,Integer userId);
+
+    /**
+     *  柜台缴费
+     * @param id 客户id
+     * @param payway 支付方式
+     * @param transAmount 交易金额
+     * @param balancetype 余额处理 1转预存 2找零
+     */
+     String payFeeCounter( String id,Integer payway,BigDecimal transAmount, Integer balancetype);
+
+    /**
+     * 查询客户信息
+     * @param id 开户id
+     * @param queryType 查询类型 1客户名称,2客户编码,3电话,4地址
+     * @param condition 查询参数
+     * @return
+     */
+    List<PayfeeAccountInfoDto> findPayfeeAccountInfo(BigInteger id, Integer queryType , String condition );
+
+    /**
+     * 收费界面查询账单详情
+     * @param id 客户id
+     * @return
+     */
+    PayfeeDetaileBill getPayfeeDetaileBill(BigInteger id);
+
+    /**
+     * 查询本期欠费详情
+     * @param id 客户id
+     * @return
+     */
+    PayfeeDetailed getPayfeeDetailed(BigInteger id );
+
+    /**
+     * 查询客户欠费信息
+     * @param accountId
+     * @param year
+     * @return
+     */
+    List<PayfeeReceivableInfo> getPayreceiveDebt(BigInteger accountId , Integer year);
+
+    /**
+     * 查询账期内欠费详情
+     * @param accountId 客户id
+     * @param year
+     * @param month
+     * @return
+     */
+    List<PayfeeReceivableInfo> getPayreceiveDebtDetailed(BigInteger accountId , Integer year , Integer month);
+
+    /**
+     * 查询实收信息
+     * @param accountId
+     * @param year
+     * @return
+     */
+    List<PayfeeReceivedInfo> getPayreceived(BigInteger accountId , Integer year );
+
+    /**
+     * 查询实收明细
+     * @param accountId
+     * @param year
+     * @param month
+     * @return
+     */
+    List<PayfeeReceivedInfo> getPayreceivedDetailed(BigInteger accountId ,String payseriesno, Integer year , Integer month);
+
+    /**
+     * 查询水量信息
+     * @param accountId
+     * @param year
+     * @return
+     */
+    List<PayfeeWaterusedamount> getWaterusedamount(BigInteger accountId , Integer year);
+
+    /**
+     * 查询收据信息
+     * @param accountId
+     * @param year
+     * @return
+     */
+    List<PayInvoiceDto> getPayinvoiceInfo(BigInteger accountId, Integer year);
+
+
+
 }

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

@@ -0,0 +1,64 @@
+package com.bz.smart_city.service.pay;
+
+import com.bz.smart_city.commom.model.Pagination;
+import com.bz.smart_city.dto.pay.PayInvoiceDto;
+import com.bz.smart_city.dto.pay.PayPayReceivedDto;
+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.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * @description
+ * @auto wangli
+ * @data 2020-07-30 9:48
+ */
+public interface PayinvoiceService {
+    /**
+     * 插入收据信息
+     * @param payInvoice
+     */
+    void insert(PayInvoice payInvoice);
+
+    /**
+     * 列表展示查询收据信息
+     * @param condition
+     * @param state
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<PayInvoiceDto> findList(String condition, Integer state, String startTime, String endTime) ;
+
+    /**
+     * 分页查询
+     * @param
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    Pagination<PayInvoiceDto> findListPage(String condition,Integer state, String startTime, String endTime, int pageNum, int pageSize);
+
+    /**
+     * 保存打印记录
+     * @param payseriesno   批次号
+     * @param invoiceno 票据号
+     */
+    void savePrintInfo(String payseriesno,String invoiceno);
+
+    /**
+     * 仅充值(payway==4 && transtype ==1)
+     * @param payseriesno
+     * @return
+     */
+    PrintInvoiceData getPrintDataOfTrans(String payseriesno);
+
+    /**
+     * 缴纳欠费(transtype == null || (transtype ==2 ||transtype ==4))
+     * @param payseriesno
+     * @return
+     */
+    PrintInvoiceData getPrintDataOfReceived(String payseriesno);
+}

+ 160 - 0
smart-city-platform/src/main/resources/mapper/pay/PayChargeSurveyMapper.xml

@@ -187,4 +187,164 @@
             </if>
         </where>
     </select>
+
+    <select id="getCurrentTran" resultType="java.math.BigDecimal">
+        select
+            sum(transamount)
+        from pay_pay_transactiondetails a
+        <where>
+            <!-- 排除退款跟预存抵扣-->
+            a.state =  1 and a.payway != 5
+            <if test="siteId != null">
+                and a.site_id =#{siteId}
+            </if>
+            <if test="customerId != null">
+                and a.customer_id =#{customerId}
+            </if>
+            <if test="year != null">
+                and a.year =#{year}
+            </if>
+            <if test="month != null">
+                and a.month =#{month}
+            </if>
+        </where>
+    </select>
+
+    <select id="getPayAmountList" resultType="com.bz.smart_city.entity.pay.PayTransactionSurvey">
+        select
+            case when a.payway =  1 then sum(transamount)
+            when a.payway = 2 then sum(transamount)
+            when a.payway = 3 then sum(transamount)
+            when a.payway = 4 then sum(transamount)
+            else sum(transamount) end as "incomeNumber",
+            payway
+        from pay_pay_transactiondetails a
+        <where>
+            a.payway != 5 and a.state =  1
+            <if test="year != null">
+                and a.year =#{year}
+            </if>
+            <if test="month != null">
+                and a.month =#{month}
+            </if>
+            <if test="siteId != null">
+                and a.site_id =#{siteId}
+            </if>
+            <if test="customerId != null">
+                and a.customer_id =#{customerId}
+            </if>
+        </where>
+        GROUP BY a.payway
+    </select>
+
+    <insert id="insertTransaction">
+        insert into pay_transaction_survey
+        (
+            id,
+            income_number,
+            last_income_number,
+            cash_income,
+            last_cash_income,
+            wechat_income,
+            last_wechat_income,
+            alipay_income,
+            last_alipay_income,
+            bank_income,
+            last_bank_income,
+            year,
+            month,
+            period_date,
+            site_id,
+            customer_id,
+            create_by,
+            create_date,
+            update_by,
+            update_date,
+            remarks,
+            del_flag
+        )
+        values
+        (
+            #{id},
+            #{incomeNumber},
+            #{lastIncomeNumber},
+            #{cashIncome},
+            #{lastCashIncome},
+            #{wechatIncome},
+            #{lastWechatIncome},
+            #{alipayIncome},
+            #{lastAlipayIncome},
+            #{bankIncome},
+            #{lastBankIncome},
+            #{year},
+            #{month},
+            #{periodDate},
+            #{siteId},
+            #{customerId},
+            #{createBy},
+            #{createDate},
+            #{updateBy},
+            #{updateDate},
+            #{remarks},
+            #{delFlag}
+        )
+    </insert>
+
+    <select id="getCurrentTranRocord" resultType="com.bz.smart_city.entity.pay.PayTransactionSurvey">
+        select
+        case when a.payway =  1 then sum(transamount)
+        when a.payway = 2 then sum(transamount)
+        when a.payway = 3 then sum(transamount)
+        when a.payway = 4 then sum(transamount)
+        end as "incomeNumber",
+        payway as "payway"
+        from pay_pay_transactiondetails a
+        <where>
+            a.payway != 5 and a.state =  1
+            <if test="year != null">
+                and a.year =#{year}
+            </if>
+            <if test="month != null">
+                and a.month =#{month}
+            </if>
+            <if test="siteId != null">
+                and a.site_id =#{siteId}
+            </if>
+            <if test="customerId != null">
+                and a.customer_id =#{customerId}
+            </if>
+        </where>
+        GROUP BY a.payway
+    </select>
+
+    <select id="getLastTranRocord" resultType="com.bz.smart_city.entity.pay.PayTransactionSurvey">
+        select
+            income_number as "incomeNumber",
+            last_income_number as "lastIncomeNumber",
+            cash_income as "cashIncome",
+            last_cash_income as "lastCashIncome",
+            wechat_income as "wechatIncome",
+            last_wechat_income as "lastWechatIncome",
+            alipay_income as "alipayIncome",
+            last_alipay_income as "lastAlipayIncome",
+            bank_income as "bankIncome",
+            last_bank_income as "lastBankIncome",
+            year as "year",
+            month as "month"
+        from pay_transaction_survey a
+        <where>
+            <if test="year != null">
+                and a.year =#{year}
+            </if>
+            <if test="month != null">
+                and a.month =#{month}
+            </if>
+            <if test="siteId != null">
+                and a.site_id =#{siteId}
+            </if>
+            <if test="customerId != null">
+                and a.customer_id =#{customerId}
+            </if>
+        </where>
+    </select>
 </mapper>

+ 144 - 0
smart-city-platform/src/main/resources/mapper/pay/PayInvoiceMapper.xml

@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.bz.smart_city.dao.pay.PayInvoiceMapper">
+    <insert id="insert" parameterType="com.bz.smart_city.entity.pay.PayInvoice" useGeneratedKeys="true" keyProperty="id">
+        insert into pay_pay_invoice
+        (
+            site_id,
+            customer_id,
+            create_date,
+            create_by,
+            update_date,
+            update_by,
+            remarks,
+            del_flag,
+
+            account_id,
+            year,
+            month,
+            accountname,
+            accountnumber,
+            invoiceamount,
+            invoiceno,
+            state,
+            type,
+            office_id,
+            cancelperson,
+            canceltime
+        )
+        values(
+            #{siteId},
+            #{customerId},
+            #{createDate},
+            #{createBy},
+            #{updateDate},
+            #{updateBy},
+            #{remarks},
+            #{delFlag},
+
+            #{accountId},
+            #{year},
+            #{month},
+            #{accountname},
+            #{accountnumber},
+            #{invoiceamount},
+            #{invoiceno},
+            #{state},
+            #{type},
+            #{officeId},
+            #{cancelperson},
+            #{canceltime}
+        )
+    </insert>
+
+    <select id="findList" 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.type = 1
+            <if test="siteId != null">
+                and a.site_id=#{siteId}
+            </if>
+            <if test="customerId != null">
+                and a.customer_id=#{customerId}
+            </if>
+            <if test="condition != null and condition != '' ">
+                and (
+                    a.invoiceno like concat('%',#{condition},'%')
+                or a.accountnumber like concat('%',#{condition},'%')
+                or a.accountname like concat('%',#{condition},'%')
+                )
+            </if>
+
+            <if test="year != null">
+                and a.state=#{state}
+            </if>
+            <if test="startTime != null">
+                and a.create_date >=#{startTime}
+            </if>
+            <if test="endTime != null">
+                and a.create_date &lt;= #{endTime}
+            </if>
+            <if test="programItems != null and programItems.size() != 0">
+                and   <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
+                <if test="item.dimensionId == 10">
+                    a.${item.dimensionCode} = #{item.dimensionValue}
+                </if>
+            </foreach>
+            </if>
+        </where>
+        order by a.create_date desc
+    </select>
+
+    <select id="findTransByPayseriesno" resultType="com.bz.smart_city.dto.pay.PayTransactiondetailsDto">
+        select
+            id,
+            payway,
+            transtype,
+            transamount,
+            account_id as "accountId",
+            accountname,
+            accountnumber
+        from pay_pay_transactiondetails
+        where payseriesno= #{payseriesno} and site_id=#{siteId} and customer_id=#{customerId}
+
+    </select>
+
+    <select id="findReceivedByPayseriesno" resultType="com.bz.smart_city.entity.pay.PayPayReceived">
+        select
+            id,
+            payway,
+            account_id as "accountId",
+            accountname,
+            accountnumber,
+            receivedamount
+        from pay_pay_received
+        where payseriesno=#{payseriesno} and site_id=#{siteId} and customer_id=#{customerId}
+
+    </select>
+
+    <update id="updatePrintInvoiceRecord">
+        <if test="type != null and type == 1">
+            update pay_pay_transactiondetails set invoice_id=#{invoiceId}
+            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}
+            where payseriesno=#{payseriesno} and site_id=#{siteId} and customer_id=#{customerId}
+        </if>
+
+	</update>
+
+</mapper>

+ 9 - 2
smart-city-platform/src/main/resources/mapper/pay/PayPayReceivedMapper.xml

@@ -75,7 +75,7 @@
             rece.accountname as "accountname",
             max(groy.name) as "watertypename",
             '' as "ladderlevelname",
-            max(rece.payseriesno) as "payseriesno",
+            rece.payseriesno as "payseriesno",
             sum(rece.receivedamount) as "receivedamount",
         (select label from pay_sys_dict where type = '支付方式' and value = min(rece.payway) and site_id = #{siteId} and customer_id =#{customerId}) as "paywayname",
         (select label from pay_sys_dict where type = '交易状态' and value = max(rece.state) and site_id = #{siteId} and customer_id =#{customerId}) as "statename",
@@ -94,6 +94,13 @@
             <if test="customerId != null">
                 and rece.customer_id=#{customerId}
             </if>
+            <if test="year != null">
+                rece.`year`=#{year}
+            </if>
+            <if test="accountId != null">
+                rece.account_id=#{accountId}
+            </if>
+
             <if test="condition != null">
                 and
                 (
@@ -121,7 +128,7 @@
                 </if>
             </foreach>
             </if>
-            group by accountnumber,accountname,rece.year,rece.month
+            group by rece.accountnumber,rece.accountname,rece.year,rece.month,rece.payseriesno
             order by max(rece.create_date) desc
         </where>
 

+ 199 - 0
smart-city-platform/src/main/resources/mapper/pay/payFeeMapper.xml

@@ -22,6 +22,9 @@
             <if test="metercode != null and metercode != '' ">
                 and c.metercode =#{metercode}
             </if>
+            <if test="accountId != null and accountId != '' ">
+                and c.account_id =#{accountId}
+            </if>
         </where>
         limit 1
     </select>
@@ -87,4 +90,200 @@
     <update id="updateAccountState">
         call updateAccountState(#{accountId});
     </update>
+
+
+    <select id="findPayfeeAccountInfo" resultType="com.bz.smart_city.dto.pay.payfee.PayfeeAccountInfoDto">
+        select
+            c.id as "custId",
+            a.id as "accountId",
+            c.accountnumber,
+            c.accountname,
+            a.mobilephone,
+            a.address,
+            a.idcardno,
+            c.vatno,
+            a.email,
+            c.opendate,
+            c.metercode,
+            c.housetype,
+            c.calculateway,
+            p.id as "waterPropertyId",
+            p.name as "waterPropertyName"
+        from pay_base_customerandmeterrela c
+        left join pay_base_account a on c.account_id=a.id
+        left join pay_base_waterproperty p on c.waterProperty_id=p.id
+        <where>
+            c.businessstate=1 and c.site_id=#{siteId} and c.customer_id=#{customerId}
+            <if test="id != null and id != ''">
+               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},'%')
+                </if>
+            </if>
+        </where>
+
+    </select>
+
+    <select id="getPayfeeDetaileBill" resultType="com.bz.smart_city.dto.pay.payfee.PayfeeDetaileBill">
+        select
+            sum(debt) debt ,
+            sum(debt)-(select remaining from pay_pay_rechargeaccount where account_id=#{accountId}) as "waterFee",
+            (select remaining from pay_pay_rechargeaccount where account_id=#{accountId})-sum(debt) as "receivableFee"
+        from pay_pay_receivable
+        where debt>0
+        and account_id=#{accountId}
+
+    </select>
+
+    <select id="getPayfeeDetailed" resultType="com.bz.smart_city.dto.pay.payfee.PayfeeDetailed">
+        select
+            account_id as "acountID",
+            sum(case when feetype=1 then debt else 0 end) waterFee1,
+            sum(case when feetype=2 then debt else 0 end) waterFee2,
+            sum(case when feetype=3 then debt else 0 end) waterFee3,
+            sum(case when feetype=4 then debt else 0 end) waterFee4,
+            sum(case when feetype=5 then debt else 0 end) waterFee5,
+            sum(case when feetype=6 then debt else 0 end) waterFee6
+        from pay_pay_receivable
+        where debt>0
+        and account_id=#{accountId}
+        and `year`= #{year} and `month`=#{month}
+        group by  account_id
+    </select>
+
+    <select id="getPayreceivableDebt" resultType="com.bz.smart_city.dto.pay.payfee.PayfeeReceivableInfo">
+        select
+            account_id as "accountId",
+            year,
+            month,
+             CONCAT(rece.year,'年',LPAD(rece.month, 2, 0),'月费用') as "name",
+             sum(rece.debt) as "debt",
+             "--" as "ladderlevelname",
+             null as "price",
+             max(rece.payamount) as "payamount",
+             sum(rece.receivablefee) as "receivablefee",
+             max(rece.create_date) as "createDate"
+        from pay_pay_receivable rece
+        where rece.debt > 0
+        and rece.account_id=#{accountId}
+        and `year`=#{year}
+        group by `year`,`month`
+    </select>
+    <select id="getPayreceivableDebtDetailed" resultType="com.bz.smart_city.dto.pay.payfee.PayfeeReceivableInfo">
+        select
+            account_id as "accountId",
+            year,
+            month,
+             rece.payitemname as "name",
+             rece.debt as "debt",
+             (case when rece.ladderlevel =  1 then '一阶'
+                        when rece.ladderlevel = 2 then '二阶'
+                        when rece.ladderlevel = 3 then '三阶'
+                        when rece.ladderlevel = 4 then '四阶'
+                        else '' end) as "ladderlevelname",
+             rece.waterbasicprice as "price",
+             rece.payamount,
+             rece.receivablefee,
+             rece.create_date
+        from pay_pay_receivable rece
+        where rece.debt > 0
+        and rece.account_id=#{accountId}
+        and `year`=#{year} and `month`=#{month}
+
+    </select>
+
+
+    <select id="getPayreceivedDetailed" resultType="com.bz.smart_city.dto.pay.payfee.PayfeeReceivedInfo">
+        select
+         name as "name",
+         (case when ladderlevel =  1 then '一阶'
+                    when ladderlevel = 2 then '二阶'
+                    when ladderlevel = 3 then '三阶'
+                    when ladderlevel = 4 then '四阶'
+                    else '' end) as "ladderlevelname",
+         payseriesno as "payseriesno",
+         receivedamount,
+         (select label from pay_sys_dict where type = '支付方式' and value = reced.payway and site_id = #{siteId} and customer_id =#{customerId}) as "paywayname",
+         (select label from pay_sys_dict where type = '交易状态' and value = reced.state and site_id = #{siteId} and customer_id =#{customerId}) as "statename",
+         create_date as "createDate",
+         iscanceled,
+          (select name from sc_user where id = reced.cancelperson) as "cancelperson",
+         canceltime,
+         invoice_id as "invoiceId"
+        from pay_pay_received reced
+        where account_id=#{accountId}
+        and `year`=#{year} and `month` = #{month} and payseriesno=#{payseriesno}
+
+    </select>
+
+    <select id="getPayreceived" resultType="com.bz.smart_city.dto.pay.payfee.PayfeeReceivedInfo">
+       select
+             CONCAT(year,'年',LPAD(month, 2, 0),'月费用') as "name" ,
+             '--'as "ladderlevelname",
+             payseriesno as "payseriesno",
+             sum(receivedamount) as "receivedamount",
+             (select label from pay_sys_dict where type = '支付方式' and value =
+                (case when  min(reced.payway) != 5 then min(reced.payway) else max(reced.payway) end )
+                 and site_id = #{siteId} and customer_id =#{customerId}) as "paywayname",
+            (select label from pay_sys_dict where type = '交易状态' and value =  max(reced.state) and site_id = #{siteId} and customer_id =#{customerId}) as "statename",
+
+             max(create_date) as "createDate"
+        from pay_pay_received reced
+        where
+         account_id=#{accountId}
+        and `year`=#{year}
+        group by `year`,`month`,payseriesno
+    </select>
+    <select id="getWaterusedamount" resultType="com.bz.smart_city.dto.pay.payfee.PayfeeWaterusedamount">
+        select
+                a.metercode AS "metercode",
+                a.lastreading AS "lastreading",
+                a.lastrecorddate AS "lastrecorddate",
+                a.reading AS "reading",
+                a.recorddate AS "recorddate",
+                a.amount AS "amount",
+                a.payamount AS "payamount",
+                 CONCAT(a.`year`,'年',LPAD(a.month, 2, 0),'月') as "closingName",
+                (select label from pay_sys_dict where type = '水量状态' and value = a.state and site_id = #{siteId} and customer_id = #{customerId}) stateLabel,
+                (case when a.state = 2 then '是' else '否' end ) isReceivable
+        from pay_amount_waterusedamount a
+        where a.`year`=#{year} and a.account_id=#{accountId}
+    </select>
+
+    <select id="getPayinvoiceInfo" 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.type = 2
+            <if test="accountId != null">
+                and a.account_id=#{accountId}
+            </if>
+            <if test="year != null">
+                and a.year = #{year}
+            </if>
+        </where>
+        order by a.create_date desc
+    </select>
 </mapper>