Explorar o código

1开鲁收据修改

Xiaojh %!s(int64=4) %!d(string=hai) anos
pai
achega
a707800869

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

@@ -76,7 +76,7 @@ public enum ResultStatus {
     OPERATE_RECORD_NOT_EXIT(-704,"未查询到有效记录"),
     ClOSING_ACCCOUNT_ERROR_EXIT(-705,"添加失败:账期已存在,不允许重复添加"),
     ClOSING_ACCCOUNT_ERROR_NOT_EXIT(-706,"结账失败:账期不存在"),
-    PAYFEE_TRANSAMOUNT_BELOW_ZERO(-707,"交易金额必须不小于零"),
+    PAYFEE_TRANSAMOUNT_BELOW_ZERO(-707,"实收金额必须不小于零"),
     PAYFEE_QUERY_NO_CUSTOMER(-708,"未查询到有效客户信息"),
     WATER_PROPERTY_EDIT_EXIT(-709,"该用水性质已被应用,无法编辑"),
     WATER_PROPERTY_DELETE_EXIT(-709,"该用水性质已被应用,无法删除"),
@@ -98,6 +98,9 @@ public enum ResultStatus {
     PAYFEE_NOT_ENOUGH(-725,"缴费金额不足"),
     PAY_INVOICE_EXISTED(-726,"收据信息已存在"),
     PAY_CONDITION_ISNULL(-727,"查询条件为空"),
+    PAYFEE_DEBT_BELOW_ZERO(-728,"欠费金额必须不小于零"),
+    PAYFEE_REMAINING_BELOW_ZERO(-729,"预存金额必须不小于零"),
+    PAYFEE_WATERAMOUNT_BELOW_ZERO(-730,"购水金额必须不小于零"),
     CUSTOMER_IS_EXISTED(-3001,"客户名称已存在"),
     SYBC_DATA_PARM_ERROR(-3002,"档案号个数太多,限制为30个");
     private final int status;

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

@@ -3,9 +3,11 @@ package com.bz.smart_city.controller.pay;
 import com.bz.smart_city.annotation.LogAnnotation;
 import com.bz.smart_city.commom.model.AjaxMessage;
 import com.bz.smart_city.commom.model.ResultStatus;
+import com.bz.smart_city.dto.pay.BaseWaterPropertyFormDto;
 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.BaseWaterPropertyService;
 import com.bz.smart_city.service.pay.PayFeeService;
 import com.bz.smart_city.service.pay.PayPayReceivedService;
 import com.bz.smart_city.service.pay.PayTransactiondetailsService;
@@ -13,7 +15,9 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import org.apache.commons.lang3.StringUtils;
+import org.aspectj.weaver.loadtime.Aj;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
@@ -40,6 +44,8 @@ public class PayFeeController {
     PayFeeService payFeeService;
     @Autowired
     PayTransactiondetailsService payTransactiondetailsService;
+    @Autowired
+    private BaseWaterPropertyService baseWaterPropertyService;
 
 
     @PostMapping("/payFee")
@@ -78,13 +84,18 @@ public class PayFeeController {
     @ApiOperation(value="柜台缴费接口")
     public AjaxMessage<PayfeeResult> payFeeCounter(
             @ApiParam(value = "客户id", required = true) @RequestParam(required = true)String accountId,
+            @ApiParam(value = "欠费金额", required = false) @RequestParam(required = false)String debt,
+            @ApiParam(value = "预存金额", required = false) @RequestParam(required = false)String remaining,
+            @ApiParam(value = "购水量", required = false) @RequestParam(required = false)String amount,
+            @ApiParam(value = "购水金额", required = false) @RequestParam(required = false)String waterAmount,
+            @ApiParam(value = "实收金额", required = true) @RequestParam(required = true)String transAmount,
             @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));
+     return new AjaxMessage<>(ResultStatus.OK, payFeeService.payFeeCounter(accountId,4,new BigDecimal(transAmount),balancetype,
+             new BigDecimal(debt),new BigDecimal(remaining),Integer.valueOf(amount),new BigDecimal(waterAmount)));
     }
 
     @GetMapping("/findPayfeeAccountInfo")
@@ -100,7 +111,21 @@ public class PayFeeController {
     @ApiOperation(value="查询账单详情")
     public AjaxMessage<PayfeeDetaileBill> getPayfeeDetaileBill(
             @ApiParam(value = "客户id",required = true) @RequestParam(required = true)BigInteger accountId){
-        return new AjaxMessage<>(ResultStatus.OK,payFeeService.getPayfeeDetaileBill(accountId));
+        //根据客户id查找用水性质ID
+        BigInteger propertyId = payFeeService.getWaterPropertyId(accountId);
+        BaseWaterPropertyFormDto baseWaterPropertyFormDto = new BaseWaterPropertyFormDto();
+        if(propertyId != null){
+            //根据用水性质ID去查找对应的用水性质
+            baseWaterPropertyFormDto = baseWaterPropertyService.getEditPage(propertyId);
+        }else{
+            baseWaterPropertyFormDto = new BaseWaterPropertyFormDto();
+        }
+        PayfeeDetaileBill bill = payFeeService.getPayfeeDetaileBill(accountId);
+        bill.setProp1(baseWaterPropertyFormDto.getProp1());//一阶用水性质
+        bill.setProp2(baseWaterPropertyFormDto.getProp2());//二阶用水性质
+        bill.setProp3(baseWaterPropertyFormDto.getProp3());//三阶用水性质
+        bill.setProp4(baseWaterPropertyFormDto.getProp4());//四阶用水性质
+        return new AjaxMessage<>(ResultStatus.OK,bill);
 
     }
 

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

@@ -51,4 +51,6 @@ public interface PayFeeMapper {
     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, @Param("siteId") Integer siteId, @Param("customerId") Integer customerId);
+
+    BigInteger getWaterPropertyId(@Param("id")BigInteger id);
 }

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

@@ -16,10 +16,20 @@ public class PayfeeDetaileBill {
 
     @ApiModelProperty(value = "欠费金额")
     private Double debt;
+    @ApiModelProperty(value = "实际欠费金额")
+    private Double actualDebt;
     @ApiModelProperty(value = "用水金额")
     private Double waterFee;
     @ApiModelProperty(value = "应缴金额")
     private Double receivableFee;
     @ApiModelProperty(value = "账户余额")
     private Double remaining;
+    @ApiModelProperty(value = "用水价格数组1",example="[\"id1,price1,Ladderlimit1\",\"id2,price2,Ladderlimit2\"]" ,position = 1)
+    private String[] prop1;
+    @ApiModelProperty(value = "用水价格数组2','",example="[1,1,100]", position = 1)
+    private String[] prop2;
+    @ApiModelProperty(value = "用水价格数组3','", position = 1)
+    private String[] prop3;
+    @ApiModelProperty(value = "用水价格数组4','", position = 1)
+    private String[] prop4;
 }

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

@@ -52,12 +52,40 @@ public class PayFeeServiceImp implements PayFeeService {
     @Resource
     BaseClosingAccountInfoMapper baseClosingAccountInfoMapper;
 
-    public PayfeeResult payFeeCounter( String id,Integer payway,BigDecimal transAmount, Integer balancetype){
-        //交易金额不可为负数
+    /**
+     *  柜台缴费
+     * @param id 客户id
+     * @param payway 支付方式
+     * @param transAmount 实收金额
+     * @param balancetype 余额处理 1转预存 2找零
+     * @param debt 欠费金额
+     * @param ycremaining 预存金额
+     * @param amount 购水量
+     * @pram waterAmount 购水金额
+     */
+    public PayfeeResult payFeeCounter( String id,Integer payway,BigDecimal transAmount, Integer balancetype,BigDecimal debt,
+                                       BigDecimal ycremaining,Integer amount, BigDecimal waterAmount){
+        //实收金额不可为负数
         if(transAmount.compareTo(BigDecimal.ZERO)!=1){
             throw new ServiceException(ResultStatus.PAYFEE_TRANSAMOUNT_BELOW_ZERO);
         }
-//        String result="";   //执行结果描述
+        //欠费金额不能为负数
+        if(debt.compareTo(BigDecimal.ZERO) == -1){
+            throw new ServiceException(ResultStatus.PAYFEE_DEBT_BELOW_ZERO);
+        }
+        //预存金额不能为负数
+        if(ycremaining.compareTo(BigDecimal.ZERO) == -1){
+            throw new ServiceException(ResultStatus.PAYFEE_REMAINING_BELOW_ZERO);
+        }
+        //购水量不能为负数
+        if(amount < 0){
+            throw new ServiceException(ResultStatus.PAYFEE_REMAINING_BELOW_ZERO);
+        }
+        //购水金额不能为负数
+        if(waterAmount.compareTo(BigDecimal.ZERO) != 1){
+            throw new ServiceException(ResultStatus.PAYFEE_WATERAMOUNT_BELOW_ZERO);
+        }
+        //String result="";   //执行结果描述
         String result="实收金额:"+String.format("%.2f",transAmount)+"元";
         BigDecimal fees=BigDecimal.ZERO;    //抵扣金额
         LoginUser loginUser = UserUtil.getCurrentUser();
@@ -73,11 +101,11 @@ public class PayFeeServiceImp implements PayFeeService {
         }
         //根据客编或者水编获取客户信息
         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);
+        if(payReceivableList.size() == 0 && debt.compareTo(BigDecimal.ZERO) ==0){ //没有应收信息走仅充值
+            return rechargefeeCounter(id, transAmount, payway,balancetype,waterAmount);
         }else{
             BigDecimal debts=BigDecimal.ZERO;
             for(PayReceivable payReceivable: payReceivableList){
@@ -179,6 +207,8 @@ public class PayFeeServiceImp implements PayFeeService {
                 }
             }
         }
+        //实收金额 = 实收金额 - 总的欠费金额
+        //transAmount = transAmount.subtract(fees);
     //    result+="<br>预存款抵扣:"+String.format("%.2f",fees)+"元";
         fees=BigDecimal.ZERO;//
         //缴费抵扣
@@ -220,7 +250,7 @@ public class PayFeeServiceImp implements PayFeeService {
                 }
             }
         }
-        result+="; 支付金额抵扣:"+String.format("%.2f",fees)+"元";
+        result+="; 支付金额抵扣:"+String.format("%.2f",fees)+"元;买水:"+amount+"吨;";
         //余额充值或划扣有余额
         if(balancetype == 1 && transAmount.compareTo(BigDecimal.ZERO) == 1){
             result+="; 余额转预存:"+String.format("%.2f",transAmount)+"元";
@@ -233,6 +263,18 @@ public class PayFeeServiceImp implements PayFeeService {
             payTransactiondetails.setTranstypeLabel("账户转预存");
             transactiondetailsDtoList.add(payTransactiondetails);
         }else{
+            //找零金额 = 实收金额-欠费-购水金额
+            //transAmount 已划扣掉欠费
+            transAmount = transAmount.subtract(waterAmount);
+            //购水金额转预存
+            remaining=remaining.add(waterAmount);
+            //生成交易明细
+            PayTransactiondetails payTransactiondetails = getPayTransactiondetails(payway, paywayName,localDateTime, payCustomRechargeDto, payseriesno, month, year, waterAmount, siteId, customerId, userId  );
+            payTransactiondetails.setName(payCustomRechargeDto.getAccountname() + payCustomRechargeDto.getAccountnumber() + "缴费");
+            payTransactiondetails.setTranstype(4);
+            payTransactiondetails.setTranstypeLabel("账户转预存");
+            transactiondetailsDtoList.add(payTransactiondetails);
+
             result+="; 余额找零:"+String.format("%.2f", transAmount)+"元";
         }
 
@@ -516,7 +558,7 @@ public class PayFeeServiceImp implements PayFeeService {
      *
      */
     @Transactional(rollbackFor = Exception.class)
-    public PayfeeResult rechargefeeCounter(String  accountId , BigDecimal transAmount, Integer payway ){
+    public PayfeeResult rechargefeeCounter(String  accountId , BigDecimal transAmount, Integer payway ,Integer balancetype,BigDecimal waterAmount){
 
         //交易金额不可为负数
         if(transAmount.compareTo(BigDecimal.ZERO)!=1){
@@ -555,14 +597,30 @@ public class PayFeeServiceImp implements PayFeeService {
             //获取客户信息失败
             throw new ServiceException(ResultStatus.PAYFEE_QUERY_NO_CUSTOMER);
         }
+        //余额处理 1转预存 0找零
+        if(balancetype == 0){
+            //如果有找零的记录,则  充值金额=实收金额-购水金额
+            transAmount = transAmount.subtract(waterAmount);
+        }
+
         //生成批次号
         // 微信:W  现金、预存账户:C 银行:B 支付宝:A
-        String payseriesno = recharge(transAmount, payway, siteId, customerId, userId, paywayName, localDateTime, payCustomRechargeDto);
+        String payseriesno = "";
+        if(balancetype == 0){
+            payseriesno = recharge(waterAmount, payway, siteId, customerId, userId, paywayName, localDateTime, payCustomRechargeDto);
+        }else if (balancetype == 1) {
+            payseriesno = recharge(transAmount, payway, siteId, customerId, userId, paywayName, localDateTime, payCustomRechargeDto);
+        }
         PayfeeResult payfeeResult =new PayfeeResult();
         payfeeResult.setPayseriesno(payseriesno);
         payfeeResult.setTransType(1);
         payfeeResult.setPayway(payway);
-        payfeeResult.setMsg("充值金额:"+String.format("%.2f", transAmount)+"元");
+        if(balancetype == 0){
+            payfeeResult.setMsg("充值金额:"+String.format("%.2f", waterAmount)+"元;找零:"+transAmount+"元");
+        }else if (balancetype == 1){
+            payfeeResult.setMsg("充值金额:"+String.format("%.2f", transAmount)+"元");
+        }
+
         return payfeeResult;
     }
 
@@ -709,6 +767,58 @@ public class PayFeeServiceImp implements PayFeeService {
     }
 
 
+    public List<PayfeeAccountInfoDto> findPayfeeAccountInfo(BigInteger id, String condition ){
+        if(StringUtils.isBlank(condition)&&id == null){
+            throw new ServiceException(ResultStatus.PAY_CONDITION_ISNULL);
+        }
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        //数据权限
+        return payFeeMapper.findPayfeeAccountInfo(id, condition ,loginUser.getSiteId(),loginUser.getCustomerId(),UserUtil.getCurrentSiteProgramItems(loginUser));
+    }
+
+    public PayfeeDetaileBill getPayfeeDetaileBill(BigInteger id){
+        if(id == null){
+            return new PayfeeDetaileBill();
+        }
+        PayfeeDetaileBill bill = payFeeMapper.getPayfeeDetaileBill(id);
+        Double debt = bill.getDebt();//原有欠费
+        Double remaining = bill.getRemaining();//预存金额
+        Double actualDebt = 0.0;//实际欠费金额
+        if((remaining != null && remaining>0) && (debt != null && debt > 0)){
+            //又有预存金额,又有欠费金额的情况下
+            if(remaining > debt){
+                //预存金额大于欠费的情况下
+                //预存金额 = 账户余额 - 欠费
+                actualDebt = remaining - debt;
+                BigDecimal bg = new BigDecimal(actualDebt);
+                remaining = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
+                bill.setRemaining(remaining);
+                bill.setDebt(0.0);
+                bill.setActualDebt(0.0);
+            }else if(debt > remaining){
+                //欠费金额大于预存金额
+                //实际欠费金额 = 欠费金额-预存金额
+                actualDebt = debt - remaining;
+                BigDecimal bg = new BigDecimal(actualDebt);
+                actualDebt = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
+                bill.setActualDebt(actualDebt);
+                bill.setDebt(debt);
+                bill.setRemaining(0.0);
+            }
+        }
+        return bill;
+    }
+
+    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);
+    }
+
     /**
      * 应收生成实收信息(相对应信息)
      * @param payReceivable 应收信息
@@ -760,32 +870,6 @@ public class PayFeeServiceImp implements PayFeeService {
         return payReceived;
     }
 
-    public List<PayfeeAccountInfoDto> findPayfeeAccountInfo(BigInteger id, String condition ){
-        if(StringUtils.isBlank(condition)&&id == null){
-            throw new ServiceException(ResultStatus.PAY_CONDITION_ISNULL);
-        }
-        LoginUser loginUser = UserUtil.getCurrentUser();
-        //数据权限
-        return payFeeMapper.findPayfeeAccountInfo(id, condition ,loginUser.getSiteId(),loginUser.getCustomerId(),UserUtil.getCurrentSiteProgramItems(loginUser));
-    }
-
-    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);
-    }
-
     /**
      * 查询客户欠费信息
      * @param accountId
@@ -853,4 +937,8 @@ public class PayFeeServiceImp implements PayFeeService {
         return payFeeMapper.getPayinvoiceInfo(accountId, year,  loginUser.getSiteId(), loginUser.getCustomerId());
     }
 
+    public BigInteger getWaterPropertyId(BigInteger id){
+        return payFeeMapper.getWaterPropertyId(id);
+    }
+
 }

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

@@ -36,8 +36,13 @@ public interface PayFeeService {
      * @param payway 支付方式
      * @param transAmount 交易金额
      * @param balancetype 余额处理 1转预存 2找零
+     * @param debt 欠费金额
+     * @param remaining 预存金额
+     * @param amount 购水量
+     * @pram waterAmount 购水金额
      */
-    PayfeeResult payFeeCounter( String id,Integer payway,BigDecimal transAmount, Integer balancetype);
+    PayfeeResult payFeeCounter( String id,Integer payway,BigDecimal transAmount, Integer balancetype,BigDecimal debt,
+                               BigDecimal remaining,Integer amount, BigDecimal waterAmount);
 
     /**
      * 查询客户信息
@@ -111,6 +116,8 @@ public interface PayFeeService {
      */
     List<PayInvoiceDto> getPayinvoiceInfo(BigInteger accountId, Integer year);
 
+    BigInteger getWaterPropertyId(BigInteger id);
+
 
 
 }

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

@@ -312,4 +312,11 @@
         </where>
         order by a.create_date desc
     </select>
+
+    <select id="getWaterPropertyId" resultType="java.math.BigInteger">
+        select
+            waterproperty_id as "id"
+        from pay_base_customerandmeterrela
+        where account_id =#{id}
+    </select>
 </mapper>