From cbcada79d9326529fb968b4a0e1d9e12f5008574 Mon Sep 17 00:00:00 2001
From: wuzeyu <1223318623@qq.com>
Date: 星期五, 18 十月 2024 08:42:38 +0800
Subject: [PATCH] 实现接口 最近未充值的农户

---
 pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientSv.java   |   27 +++++++++++++
 pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmClientAmountDayLastMapper.xml                       |   51 +++++++++++++++++++++++++
 pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java |   18 +++++++++
 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmClientAmountDayLastMapper.java        |   15 +++++++
 4 files changed, 111 insertions(+), 0 deletions(-)

diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmClientAmountDayLastMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmClientAmountDayLastMapper.java
index 332281a..df753e4 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmClientAmountDayLastMapper.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoRm/RmClientAmountDayLastMapper.java
@@ -3,6 +3,7 @@
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.dy.pipIrrGlobal.pojoRm.RmClientAmountDayLast;
 import com.dy.pipIrrGlobal.voRm.VoClientAmountDay;
+import com.dy.pipIrrGlobal.voSt.VoClient;
 import com.dy.pipIrrGlobal.voSt.VoDayClient;
 import com.dy.pipIrrGlobal.voSt.VoMonthClient;
 import org.apache.ibatis.annotations.Mapper;
@@ -109,4 +110,18 @@
      * @return
      */
     List<VoMonthClient> getMonthAmountAndMoney(Map<?, ?> params);
+
+    /**
+     * 鏈�杩戞湭鍏呭�肩殑鍐滄埛鏁伴噺
+     * @param params
+     * @return
+     */
+    Long getNotRechargeLastClientsCount(Map<String, Object> params);
+
+    /**
+     * 鏈�杩戞湭鍏呭�肩殑鍐滄埛
+     * @param params
+     * @return
+     */
+    List<VoClient> getNotRechargeLastClients(Map<String, Object> params);
 }
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmClientAmountDayLastMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmClientAmountDayLastMapper.xml
index 07fb518..927a12d 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmClientAmountDayLastMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmClientAmountDayLastMapper.xml
@@ -833,4 +833,55 @@
             </if>
         </trim>
     </select>
+    <!--鏈�杩戞湭鍏呭�肩殑鍐滄埛鏁伴噺-->
+    <select id="getNotRechargeLastClientsCount" resultType="java.lang.Long">
+        SELECT COUNT(*)
+        FROM
+        (        SELECT
+        sc.id    AS clientId,
+        sc.`name`   AS clientName,
+        sc.clientNum  AS clientNum,
+        sc.address   AS address,
+        sc.phone    AS phone,
+        sc.idCard   AS idCard
+        FROM
+        se_client sc
+        LEFT JOIN (SELECT srh.clientId FROM `se_recharge_history` srh
+        <where>
+            srh.amount > 0 AND srh.operate_valid = 2
+            <if test="timeStart != null and timeStart != ''">
+                AND srh.operateDt > #{timeStart}
+            </if>
+        </where>
+        ) c on c.clientId = sc.id
+        WHERE c.clientId IS NULL
+        GROUP BY sc.id) d
+    </select>
+    <!--鏈�杩戞湭鍏呭�肩殑鍐滄埛-->
+    <select id="getNotRechargeLastClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient">
+        SELECT
+        sc.id    AS clientId,
+        sc.`name`   AS clientName,
+        sc.clientNum  AS clientNum,
+        sc.address   AS address,
+        sc.phone    AS phone,
+        sc.idCard   AS idCard
+        FROM
+            se_client sc
+                LEFT JOIN (SELECT srh.clientId FROM `se_recharge_history` srh
+        <where>
+            srh.amount > 0 AND srh.operate_valid = 2
+            <if test="timeStart != null and timeStart != ''">
+                AND srh.operateDt > #{timeStart}
+            </if>
+        </where>
+        ) c on c.clientId = sc.id
+        WHERE c.clientId IS NULL
+        GROUP BY sc.id
+        <trim prefix="limit ">
+            <if test="start != null and count != null">
+                #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER}
+            </if>
+        </trim>
+    </select>
 </mapper>
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java
index 7675944..d485488 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientCtrl.java
@@ -298,4 +298,22 @@
         }
     }
 
+
+    /**
+     * 鏈�杩戞湭鍏呭�肩殑鍐滄埛
+     *
+     * @param qo
+     * @return
+     */
+    @GetMapping(path = "/getNotRechargeLastClients")
+    @SsoAop()
+    public BaseResponse<QueryResultVo<List<VoClient>>> getNotRechargeLastClients(CommonQO qo) {
+        try {
+            QueryResultVo<List<VoClient>> res = clientSv.getNotRechargeLastClients(qo);
+            return BaseResponseUtils.buildSuccess(res);
+        }catch (Exception e){
+            log.error("鑾峰彇璁板綍寮傚父", e);
+            return BaseResponseUtils.buildException(e.getMessage());
+        }
+    }
 }
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientSv.java
index 1e5b1ad..334c320 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/client/ClientSv.java
@@ -493,4 +493,31 @@
         rsVo.obj = rmClientAmountDayLastMapper.getMonthAmountAndMoney(params);
         return rsVo ;
     }
+
+    /**
+     * 鏈�杩戞湭鍏呭�肩殑鍐滄埛
+     * @param qo
+     * @return
+     */
+    public QueryResultVo<List<VoClient>> getNotRechargeLastClients(CommonQO qo) {
+        String timeStart = qo.getTimeStart();
+        if (timeStart != null && timeStart != ""){
+            timeStart = timeStart + " 00:00:00";
+            qo.setTimeStart(timeStart);
+        }
+        // 鐢熸垚鏌ヨ鍙傛暟
+        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ;
+
+        // 鑾峰彇绗﹀悎鏉′欢鐨勮褰曟暟
+        Long itemTotal = Optional.ofNullable(rmClientAmountDayLastMapper.getNotRechargeLastClientsCount(params)).orElse(0L);
+
+        QueryResultVo<List<VoClient>> rsVo = new QueryResultVo<>() ;
+
+        rsVo.pageSize = qo.pageSize ;
+        rsVo.pageCurr = qo.pageCurr ;
+
+        rsVo.calculateAndSet(itemTotal, params);
+        rsVo.obj = rmClientAmountDayLastMapper.getNotRechargeLastClients(params);
+        return rsVo ;
+    }
 }

--
Gitblit v1.8.0