From 10ad2e710d2bd52aac31d5d63a7bb6beae76b6a8 Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Tue, 07 Nov 2023 14:35:32 +0800
Subject: [PATCH] 用户列表增加搜索条件

---
 src/main/resources/mapper/modules/ChatUserMapper.xml |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 54 insertions(+), 4 deletions(-)

diff --git a/src/main/resources/mapper/modules/ChatUserMapper.xml b/src/main/resources/mapper/modules/ChatUserMapper.xml
index 5847b58..ef87b68 100644
--- a/src/main/resources/mapper/modules/ChatUserMapper.xml
+++ b/src/main/resources/mapper/modules/ChatUserMapper.xml
@@ -32,6 +32,9 @@
                 <if test="record.status != null and record.status != ''">
                     and a.status = #{record.status}
                 </if>
+                <if test="record.isRobot != null">
+                    and a.is_robot = #{record.isRobot}
+                </if>
             </if>
         </where>
         group by a.user_id
@@ -56,10 +59,17 @@
             FROM chat_red_bag c
             where c.from_user_id = a.user_id
                 AND c.msg_type = 'GROUP'
-        ) groupRedBagNum
+        ) groupRedBagNum,
+        (
+            select IFNULL(sum(IFNULL(d.amount,0)),0)
+            from chat_amount_flow d
+            where (d.type = 7 or d.type = 9)
+            and d.user_id = a.user_id
+        ) teamPerkAmount
         from chat_user a
-        left join chat_wallet b on b.user_id = a.user_id and type = 'USDT'
+        left join chat_wallet b on b.user_id = a.user_id and b.type = 'USDT'
         <where>
+            a.is_robot = 0
             <if test="record.phone != null and record.phone != ''">
                 and a.phone like CONCAT('%', CONCAT(#{record.phone}, '%'))
             </if>
@@ -74,7 +84,7 @@
             </if>
         </where>
         group by a.user_id
-        HAVING groupRedBagNum > 0
+        HAVING teamPerkAmount > 0
         order by
         a.user_id asc ,a.create_time asc
     </select>
@@ -175,9 +185,18 @@
         b.nick_name nickName,
         b.phone phone,
         a.id id,
-        a.amount amount,
+        (a.amount - a.fee) amount,
+        CASE
+            WHEN a.type = 1 THEN NULL
+        ELSE
+            FORMAT(
+                (a.amount - a.fee) / ( SELECT VALUE FROM data_dictionary WHERE type = 'USDT_TIME' AND CODE = 'USDT_TIME' ),
+                2
+            )
+        END AS amountUSDT,
         a.type type,
         a.address address,
+        a.address_type addressType,
         a.state state
         from member_coin_withdraw a
         left join chat_user b on b.user_id = a.user_id
@@ -306,6 +325,7 @@
         select
         a.*,
         b.nick_name nickName,
+        b.is_robot isRobot,
         c.name groupName
         from chat_red_bag a
         left join chat_user b on b.user_id = a.from_user_id
@@ -315,6 +335,12 @@
             <if test="record != null">
                 <if test="record.name != null and record.name != ''">
                     and c.name like CONCAT('%', CONCAT(#{record.name}, '%'))
+                </if>
+                <if test="record.nickName != null and record.nickName != ''">
+                    and b.nick_name like CONCAT('%', CONCAT(#{record.nickName}, '%'))
+                </if>
+                <if test="record.isRobot != null">
+                    and b.is_robot = #{record.isRobot}
                 </if>
             </if>
         </where>
@@ -429,5 +455,29 @@
         where user_id = #{userId}
     </update>
 
+    <delete  id="deleteMsgByCreateTime">
+        DELETE from chat_msg where create_time &lt; #{dateTime}
+    </delete>
+
+    <select id="selectChatRedBagByCreateTime" resultType="java.lang.Long">
+        select id
+        from chat_red_bag
+        where create_time &lt; #{dateTime} order By create_time desc limit 1
+    </select>
+
+    <delete  id="deleteChatRedBagById">
+        DELETE from chat_red_bag where id &lt; #{id}
+    </delete>
+
+    <select id="selectChatRedBagRecordByRebBagId" resultType="java.lang.Long">
+        select id
+        from chat_red_bag_record
+        where red_bag_id = #{id}
+    </select>
+
+    <delete  id="deleteChatRedBagRecordById">
+        DELETE from chat_red_bag_record where id &lt; #{id}
+    </delete>
+
 
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.1