Преглед на файлове

缴费修改用水余额

wangli преди 4 години
родител
ревизия
3e540692d5

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

@@ -27,7 +27,7 @@ public interface PayFeeMapper {
 
     void updatePayReceivable(PayReceivable payReceivable);
 
-    void updateRechargeaccount(@Param("remaining") BigDecimal remaining, @Param("updateBy")BigInteger updateBy, @Param("updateDate")LocalDateTime updateDate, @Param("id")BigInteger id);
+    void updateRechargeaccount(@Param("balance") BigDecimal balance,@Param("remaining") BigDecimal remaining, @Param("updateBy")BigInteger updateBy, @Param("updateDate")LocalDateTime updateDate, @Param("id")BigInteger id);
 
     List<PayReceivable> getReceivable(@Param("siteId") Integer siteId, @Param("customerId") Integer customerId, @Param("accountId") BigInteger accountId,@Param("list") List<BigInteger> list);
 

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

@@ -33,5 +33,7 @@ public class PayCustomRechargeDto {
     private BigInteger rechargeId;
     @ApiModelProperty("预存余额")
     private BigDecimal remaining;
+    @ApiModelProperty("用水余额")
+    private BigDecimal balance;
 
 }

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

@@ -575,7 +575,7 @@ public class AmountWaterUsedAmountServiceImpl implements AmountWaterUsedAmountSe
 
                         }
                         //修改预存账户
-                        payFeeMapper.updateRechargeaccount(remaining, BigInteger.valueOf(userId), localDateTime, rechargeaccount.getId());
+                        payFeeMapper.updateRechargeaccount(null,remaining, BigInteger.valueOf(userId), localDateTime, rechargeaccount.getId());
 
                         //赋值交易明细交易前后余额并保存
                         for (PayTransactiondetails payTransactiondetails : transactiondetailsDtoList) {

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

@@ -98,6 +98,7 @@ public class PayFeeServiceImp implements PayFeeService {
         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);
@@ -121,6 +122,7 @@ public class PayFeeServiceImp implements PayFeeService {
         //查询欠费信息
         List<PayReceivable> payReceivableList =payFeeMapper.getReceivable(loginUser.getSiteId(),loginUser.getCustomerId(),payCustomRechargeDto.getAccountId(),null);
 
+
         //购水金额 = 单价*水量
         BigDecimal waterAmount = price.multiply(new BigDecimal(amount));
 
@@ -170,6 +172,7 @@ public class PayFeeServiceImp implements PayFeeService {
         int year =baseClosingAccountInfo.getYear();
         //余额
         BigDecimal remaining = payCustomRechargeDto.getRemaining();
+        BigDecimal balance = payCustomRechargeDto.getBalance();
         //用作明细记录交易前余额
         BigDecimal oldRemaining = payCustomRechargeDto.getRemaining();
         //交易明细最后统一赋值交易前后余额,批量保存
@@ -246,7 +249,6 @@ public class PayFeeServiceImp implements PayFeeService {
                     fees=fees.add(payReceivable.getDebt());
                     iteratorTransAmount.remove();
                     transAmount = transAmount.subtract(payReceivable.getDebt());//修改剩余交易金额
-
                     //生成并保存实收
                     getReceived(payReceivable, year, month, localDateTime,payway,payseriesno,payReceivable.getDebt(),feetypeMap, siteId, customerId, userId );
                     //修改应收
@@ -271,11 +273,17 @@ public class PayFeeServiceImp implements PayFeeService {
             }
         }
         result+="; 支付金额抵扣:"+String.format("%.2f",fees)+"元;买水:"+amount+"吨;";
+        if(balance!= null){
+            balance=balance.add(fees);
+        }
         //余额充值或划扣有余额
         if(balancetype == 1 && transAmount.compareTo(BigDecimal.ZERO) == 1){
             result+="; 余额转预存:"+String.format("%.2f",transAmount)+"元";
             //修改余额
             remaining=remaining.add(transAmount);
+            if(balance!= null){
+                balance=balance.add(transAmount);
+            }
             //生成交易明细
             PayTransactiondetails payTransactiondetails = getPayTransactiondetails(payway, paywayName,localDateTime, payCustomRechargeDto, payseriesno, month, year, transAmount, siteId, customerId, userId  );
             payTransactiondetails.setName(payCustomRechargeDto.getAccountname() + payCustomRechargeDto.getAccountnumber() + "缴费");
@@ -288,6 +296,9 @@ public class PayFeeServiceImp implements PayFeeService {
             transAmount = transAmount.subtract(waterAmount);
             //购水金额转预存
             remaining=remaining.add(waterAmount);
+            if(balance!= null){
+                balance=balance.add(waterAmount);
+            }
             //生成交易明细
             PayTransactiondetails payTransactiondetails = getPayTransactiondetails(payway, paywayName,localDateTime, payCustomRechargeDto, payseriesno, month, year, waterAmount, siteId, customerId, userId  );
             payTransactiondetails.setName(payCustomRechargeDto.getAccountname() + payCustomRechargeDto.getAccountnumber() + "缴费");
@@ -299,7 +310,7 @@ public class PayFeeServiceImp implements PayFeeService {
         }
 
         //修改预存账户
-        payFeeMapper.updateRechargeaccount(remaining,BigInteger.valueOf(userId),localDateTime,payCustomRechargeDto.getRechargeId());
+        payFeeMapper.updateRechargeaccount(balance,remaining,BigInteger.valueOf(userId),localDateTime,payCustomRechargeDto.getRechargeId());
         //更新客户状态
         payFeeMapper.updateAccountState(payCustomRechargeDto.getAccountId());
         //赋值交易明细交易前后余额并保存
@@ -478,6 +489,7 @@ public class PayFeeServiceImp implements PayFeeService {
         int year =baseClosingAccountInfo.getYear();
         //余额
         BigDecimal remaining = payCustomRechargeDto.getRemaining();
+        BigDecimal balance = payCustomRechargeDto.getBalance();
         //用作明细记录交易前余额
         BigDecimal oldRemaining = payCustomRechargeDto.getRemaining();
         //交易明细最后统一赋值交易前后余额,批量保存
@@ -547,7 +559,9 @@ public class PayFeeServiceImp implements PayFeeService {
                     //交易金额不小于欠费(完全抵扣)
                     iteratorTransAmount.remove();
                       transAmount = transAmount.subtract(payReceivable.getDebt());//修改剩余交易金额
-
+                        if(balance != null){
+                            balance=balance.add(payReceivable.getDebt());
+                        }
                     //生成并保存实收
                     getReceived(payReceivable, year, month, localDateTime,payway,payseriesno,payReceivable.getDebt(),feetypeMap, siteId, customerId, userId );
 
@@ -566,7 +580,9 @@ public class PayFeeServiceImp implements PayFeeService {
                     //交易金额小于于欠费(部分抵扣)
                     //生成并保存实收
                     getReceived(payReceivable, year, month, localDateTime,payway,payseriesno,transAmount,feetypeMap, siteId, customerId, userId );
-
+                    if(balance != null){
+                        balance=balance.add(transAmount);
+                    }
 //                    PayTransactiondetails payTransactiondetailsDto = getPayTransactiondetails(payway, localDateTime, payCustomRechargeDto, payseriesno, month, year, remaining );
 //                    payTransactiondetailsDto.setReceivedId(payPayReceived.getId());
 //                    payTransactiondetailsDto.setName(payCustomRechargeDto.getAccountname() + payCustomRechargeDto.getAccountnumber() + "扣费");
@@ -588,6 +604,9 @@ public class PayFeeServiceImp implements PayFeeService {
         if(transAmount.compareTo(BigDecimal.ZERO) == 1){
             //修改余额
             remaining=remaining.add(transAmount);
+            if(balance != null){
+                balance=balance.add(transAmount);
+            }
             //生成交易明细
             PayTransactiondetails payTransactiondetails = getPayTransactiondetails(payway, paywayName,localDateTime, payCustomRechargeDto, payseriesno, month, year, transAmount, siteId, customerId, userId  );
             payTransactiondetails.setName(payCustomRechargeDto.getAccountname() + payCustomRechargeDto.getAccountnumber() + "缴费");
@@ -597,7 +616,7 @@ public class PayFeeServiceImp implements PayFeeService {
         }
 
         //修改预存账户
-        payFeeMapper.updateRechargeaccount(remaining,BigInteger.valueOf(userId),localDateTime,payCustomRechargeDto.getRechargeId());
+        payFeeMapper.updateRechargeaccount(balance,remaining,BigInteger.valueOf(userId),localDateTime,payCustomRechargeDto.getRechargeId());
        //更新客户状态
         payFeeMapper.updateAccountState(payCustomRechargeDto.getAccountId());
         //赋值交易明细交易前后余额并保存
@@ -780,6 +799,8 @@ public class PayFeeServiceImp implements PayFeeService {
         //余额
         BigDecimal remaining = payCustomRechargeDto.getRemaining();
 
+        BigDecimal balance = payCustomRechargeDto.getBalance();
+
         //生成交易明细
         PayTransactiondetails payTransactiondetails = getPayTransactiondetails(payway, paywayName, localDateTime, payCustomRechargeDto, payseriesno, month, year, transAmount, siteId, customerId, userId);
         payTransactiondetails.setName(payCustomRechargeDto.getAccountname() + payCustomRechargeDto.getAccountnumber() + "充值");
@@ -787,11 +808,14 @@ public class PayFeeServiceImp implements PayFeeService {
         payTransactiondetails.setTranstypeLabel("充值");
         payTransactiondetails.setRemaining(remaining);//交易前账户余额
         remaining = remaining.add(transAmount);
+        if(balance != null){
+            balance =balance.add(transAmount);
+        }
         payTransactiondetails.setLastrecreamaing(remaining);//交易后账户余额
         payTransactiondetailsMapper.insert(payTransactiondetails);
 
         //修改预存账户
-        payFeeMapper.updateRechargeaccount(remaining, BigInteger.valueOf(userId), localDateTime, payCustomRechargeDto.getRechargeId());
+        payFeeMapper.updateRechargeaccount(balance,remaining, BigInteger.valueOf(userId), localDateTime, payCustomRechargeDto.getRechargeId());
         //更新客户状态
         payFeeMapper.updateAccountState(payCustomRechargeDto.getAccountId());
         return payseriesno;
@@ -1100,6 +1124,7 @@ public class PayFeeServiceImp implements PayFeeService {
         if(payReceivableList.size() == 0 ){ //没有应收信息走仅充值
             //余额
             BigDecimal remaining = payCustomRechargeDto.getRemaining();
+            BigDecimal balance = payCustomRechargeDto.getBalance();
             //生成交易明细
             PayTransactiondetails payTransactiondetails = getPayTransactiondetails(3, paywayName, localDateTime, payCustomRechargeDto, payseriesno, month, year, payfee, siteId, customerId, 1);
             payTransactiondetails.setName(payCustomRechargeDto.getAccountname() + payCustomRechargeDto.getAccountnumber() + "充值");
@@ -1107,10 +1132,13 @@ public class PayFeeServiceImp implements PayFeeService {
             payTransactiondetails.setTranstypeLabel("充值");
             payTransactiondetails.setRemaining(remaining);//交易前账户余额
             remaining = remaining.add(payfee);
+            if(balance != null){
+                balance = balance.add(payfee);
+            }
             payTransactiondetails.setLastrecreamaing(remaining);//交易后账户余额
             payTransactiondetailsMapper.insert(payTransactiondetails);
             //修改预存账户
-            payFeeMapper.updateRechargeaccount(remaining, BigInteger.valueOf(1), localDateTime, payCustomRechargeDto.getRechargeId());
+            payFeeMapper.updateRechargeaccount(balance,remaining, BigInteger.valueOf(1), localDateTime, payCustomRechargeDto.getRechargeId());
             //更新客户状态
             payFeeMapper.updateAccountState(payCustomRechargeDto.getAccountId());
 
@@ -1127,6 +1155,7 @@ public class PayFeeServiceImp implements PayFeeService {
 
             //余额
             BigDecimal remaining = payCustomRechargeDto.getRemaining();
+            BigDecimal balance = payCustomRechargeDto.getBalance();
             //用作明细记录交易前余额
             BigDecimal oldRemaining = payCustomRechargeDto.getRemaining();
             //交易明细最后统一赋值交易前后余额,批量保存
@@ -1198,7 +1227,9 @@ public class PayFeeServiceImp implements PayFeeService {
                         //交易金额不小于欠费(完全抵扣)
                         iteratorTransAmount.remove();
                         payfee = payfee.subtract(payReceivable.getDebt());//修改剩余交易金额
-
+                        if(balance != null){
+                            balance=balance.add(payReceivable.getDebt());
+                        }
                         //生成并保存实收
                         getReceived(payReceivable, year, month, localDateTime,3,payseriesno,payReceivable.getDebt(),feetypeMap, siteId, customerId, 1 );
                         //修改应收
@@ -1210,7 +1241,9 @@ public class PayFeeServiceImp implements PayFeeService {
                     }else{
                         //交易金额小于于欠费(部分抵扣)
                         //生成并保存实收
-
+                        if(balance != null){
+                            balance=balance.add(payfee);
+                        }
                         getReceived(payReceivable, year, month, localDateTime,3,payseriesno,payfee,feetypeMap, siteId, customerId, 1 );
                         //修改应收
                         payReceivable.setDebt(payReceivable.getDebt().subtract(payfee));
@@ -1226,6 +1259,9 @@ public class PayFeeServiceImp implements PayFeeService {
             if( payfee.compareTo(BigDecimal.ZERO) == 1){
                 //修改余额
                 remaining=remaining.add(payfee);
+                if(balance != null){
+                    balance=balance.add(payfee);
+                }
                 //生成交易明细
                 PayTransactiondetails payTransactiondetails = getPayTransactiondetails(3, paywayName,localDateTime, payCustomRechargeDto, payseriesno, month, year, payfee, siteId, customerId, 1  );
                 payTransactiondetails.setName(payCustomRechargeDto.getAccountname() + payCustomRechargeDto.getAccountnumber() + "缴费");
@@ -1235,7 +1271,7 @@ public class PayFeeServiceImp implements PayFeeService {
             }
 
             //修改预存账户
-            payFeeMapper.updateRechargeaccount(remaining,BigInteger.valueOf(1),localDateTime,payCustomRechargeDto.getRechargeId());
+            payFeeMapper.updateRechargeaccount(balance,remaining,BigInteger.valueOf(1),localDateTime,payCustomRechargeDto.getRechargeId());
             //更新客户状态
             payFeeMapper.updateAccountState(payCustomRechargeDto.getAccountId());
             //赋值交易明细交易前后余额并保存

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

@@ -11,7 +11,8 @@
             c.watermeter_id as "watermeterId",
             c.office_id as "officeId",
             rech.id as "rechargeId",
-            rech.remaining as "remaining"
+            rech.remaining as "remaining",
+            rech.balance as "balance"
         from pay_base_customerandmeterrela c
         left join pay_pay_rechargeaccount rech on rech.account_id=c.account_id
         <where>
@@ -40,6 +41,9 @@
     <update id="updateRechargeaccount">
         update pay_pay_rechargeaccount set
         remaining=#{remaining}
+        <if test="balance != null">
+        ,balance=#{balance}
+        </if>
         ,update_by=#{updateBy}
         ,update_date=#{updateDate}
         where id=#{id}