Xiaojh 4 years ago
parent
commit
1b249a2195

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

@@ -110,7 +110,7 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
 
             //上一账期汇总
             String lastDate = list.get(1).getYear() +"-"+String.format("%02d", list.get(1).getMonth())+"-01";
-            PayAccountSurvey accountSurvey = payChargeSurveyMapper.getlastAccount(null,siteId,customerId);
+            PayAccountSurvey accountSurvey = payChargeSurveyMapper.getlastAccount(lastDate,siteId,customerId);
 
             //客户总数计算
             //当前账期以内客户总数
@@ -344,7 +344,9 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
                 payTransactionSurveyDto = this.tranCompute(payTransactionSurvey);
             }else {
                 //查询交易记录表
-                PayTransactionSurvey transactionSurver = payChargeSurveyMapper.getLastTranRocord(year,month,siteId,customerId);
+                PayTransactionSurvey transactionSurver = new PayTransactionSurvey();
+                transactionSurver = payChargeSurveyMapper.getLastTranRocord(year,month,siteId,customerId);
+                transactionSurver = transactionSurver != null ? transactionSurver : new PayTransactionSurvey();
                 transactionSurver.setYear(year);
                 transactionSurver.setMonth(month);
                 payTransactionSurveyDto = this.tranCompute(transactionSurver);
@@ -380,8 +382,10 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
         String lastAlipayRate = "";//支付宝比率
         String lastBankRate = "";//银行比率
         try {
-            BigDecimal currentIncome = transactionSurver.getIncomeNumber();//本月收入总数
-            BigDecimal lastIncome = transactionSurver.getLastIncomeNumber();//上月收入总数
+            //本月收入总数
+            BigDecimal currentIncome = transactionSurver != null && transactionSurver.getIncomeNumber() != null ? transactionSurver.getIncomeNumber() : defc;
+            //上月收入总数
+            BigDecimal lastIncome = transactionSurver != null && transactionSurver.getLastIncomeNumber() != null ? transactionSurver.getLastIncomeNumber() : defc;
 
             RecordInfo info = this.calculationRate(currentIncome,lastIncome);
             BigDecimal income = info.getIncome();
@@ -390,17 +394,18 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
 
 
             //按支付方式
-            cashIncome = transactionSurver.getCashIncome();//本账期现金收入
-            lastcashIncome = transactionSurver.getLastCashIncome();//上期现金收入
+            cashIncome = transactionSurver != null && transactionSurver.getCashIncome() != null ? transactionSurver.getCashIncome() : defc;//本账期现金收入
 
-            wechatIncome = transactionSurver.getWechatIncome();//本账期微信
-            lastwechatIncome = transactionSurver.getLastWechatIncome();//上期微信
+            lastcashIncome = transactionSurver != null && transactionSurver.getLastCashIncome() != null ? transactionSurver.getLastCashIncome() : defc;//上期现金收入
 
-            alipayIncome = transactionSurver.getAlipayIncome();//本账期支付宝
-            lastalipayIncome = transactionSurver.getLastAlipayIncome();//上期支付宝
+            wechatIncome = transactionSurver != null && transactionSurver.getWechatIncome() != null ? transactionSurver.getWechatIncome() : defc;//本账期微信
+            lastwechatIncome = transactionSurver != null && transactionSurver.getLastWechatIncome() != null ? transactionSurver.getLastWechatIncome() : defc;//上期微信
 
-            bankIncome = transactionSurver.getBankIncome();//本账期银行
-            lastbankIncome = transactionSurver.getLastBankIncome();//上期银行
+            alipayIncome = transactionSurver != null && transactionSurver.getAlipayIncome() != null ? transactionSurver.getAlipayIncome() : defc;//本账期支付宝
+            lastalipayIncome = transactionSurver != null && transactionSurver.getLastAlipayIncome() != null ? transactionSurver.getLastAlipayIncome() : defc;//上期支付宝
+
+            bankIncome = transactionSurver != null && transactionSurver.getBankIncome() != null ? transactionSurver.getBankIncome() : defc;//本账期银行
+            lastbankIncome = transactionSurver != null && transactionSurver.getLastBankIncome() != null ? transactionSurver.getLastBankIncome() : defc;//上期银行
 
 
             info = this.calculationRate(cashIncome,lastcashIncome);
@@ -761,7 +766,7 @@ public class PayChargeSurveyServiceImpl implements PayChargeSurveyService {
         BigDecimal defb = new BigDecimal("1.0");
         DecimalFormat df = new DecimalFormat("0.0");
         try{
-            if(lastIncome.compareTo(BigDecimal.ZERO) == 1){
+            if(lastIncome != null && lastIncome.compareTo(BigDecimal.ZERO) == 1){
                 if(currentIncome.subtract(lastIncome).compareTo(BigDecimal.ZERO) == 0){
                     //本期减上期持平显示→
                     lastIncomeIsUp = 2;

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

@@ -177,9 +177,9 @@
 
     <select id="getlastAccount" resultType="com.bz.smart_city.entity.pay.PayAccountSurvey">
         select
-            IFNULL(sum(a.account_number),0) as "accountNumber",
-            IFNULL(sum(a.meter_number),0) as "meterNumber",
-            IFNULL(sum(a.customer_number),0) as "customerNumber"
+            IFNULL(a.account_number,0) as "accountNumber",
+            IFNULL(a.meter_number,0) as "meterNumber",
+            IFNULL(a.customer_number,0) as "customerNumber"
         from pay_account_survey a
         <where>
             <if test="periodDate != null">