|  |  |  | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectClientIds4YearStatistics" resultType="com.dy.pipIrrGlobal.voSt.VoStClientIdAmountYearRecord"> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | mtb.id as clientId | 
|---|
|  |  |  | from se_client mtb | 
|---|
|  |  |  | where mtb.deleted != 1 | 
|---|
|  |  |  | <trim prefix="and" suffixOverrides="and"> | 
|---|
|  |  |  | <if test="name != null and name != ''"> | 
|---|
|  |  |  | mtb.name like concat('%', #{name}, '%') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | order by mtb.id DESC | 
|---|
|  |  |  | <trim prefix="limit " > | 
|---|
|  |  |  | <if test="start != null and count != null"> | 
|---|
|  |  |  | #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="selectYearStatistics" resultType="com.dy.pipIrrGlobal.voSt.VoStClientAmountYearRecord"> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | ctb.id as clientId, | 
|---|
|  |  |  | 
|---|
|  |  |  | cayTb.money as money, | 
|---|
|  |  |  | cayTb.times as times | 
|---|
|  |  |  | from se_client ctb | 
|---|
|  |  |  | LEFT JOIN st_client_amount_year cayTb on cayTb.client_id = ctb.id | 
|---|
|  |  |  | <if test="clientIdsJson != null and clientIdsJson !=''"> | 
|---|
|  |  |  | INNER JOIN JSON_TABLE( | 
|---|
|  |  |  | <!--'[{"clientId":"37142501020100215"},{"clientId":"37142501020100215"}]'--> | 
|---|
|  |  |  | #{clientIdsJson}, | 
|---|
|  |  |  | '$[*]' COLUMNS ( | 
|---|
|  |  |  | clientId BIGINT PATH '$.clientId' | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | ) clientIdTb ON clientIdTb.clientId = ctb.id | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | LEFT JOIN | 
|---|
|  |  |  | ( | 
|---|
|  |  |  | select * | 
|---|
|  |  |  | from st_client_amount_year | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="year != null"> | 
|---|
|  |  |  | `year` = #{year,jdbcType=INTEGER} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | ) as cayTb | 
|---|
|  |  |  | on cayTb.client_id = clientIdTb.clientId | 
|---|
|  |  |  | where ctb.deleted != 1 | 
|---|
|  |  |  | <trim prefix="and" suffixOverrides="and"> | 
|---|
|  |  |  | <if test="year != null"> | 
|---|
|  |  |  | cayTb.`year` = #{year,jdbcType=INTEGER} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <!-- 2025-07-14 的selectClientIds4YearStatisticssselectClientIds4YearStatistics查询中已经用了name条件 | 
|---|
|  |  |  | <if test="name != null and name != ''"> | 
|---|
|  |  |  | and ctb.name like concat('%', #{name}, '%') | 
|---|
|  |  |  | and ctb.name like concat('%', #{clientName}, '%') | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | --> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | order by ctb.id DESC | 
|---|
|  |  |  | <!-- 2025-07-14 因为有clientIdsJson限制了数量,所以不再用limit了 | 
|---|
|  |  |  | <trim prefix="limit " > | 
|---|
|  |  |  | <if test="start != null and count != null"> | 
|---|
|  |  |  | #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | --> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!-- ////////////////////////////////// --> | 
|---|