From 1bf57dbbb7025facb8a3e3c2074e82af6f13b24f Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Thu, 28 Apr 2022 15:13:59 +0800
Subject: [PATCH] fix

---
 src/main/resources/mapper/modules/MallMemberMapper.xml |  122 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 118 insertions(+), 4 deletions(-)

diff --git a/src/main/resources/mapper/modules/MallMemberMapper.xml b/src/main/resources/mapper/modules/MallMemberMapper.xml
index cc2fdca..960799d 100644
--- a/src/main/resources/mapper/modules/MallMemberMapper.xml
+++ b/src/main/resources/mapper/modules/MallMemberMapper.xml
@@ -3,7 +3,9 @@
 <mapper namespace="cc.mrbird.febs.mall.mapper.MallMemberMapper">
 
     <select id="selectMallMemberListInPage" resultType="cc.mrbird.febs.mall.entity.MallMember">
-        SELECT * FROM mall_member m
+        SELECT m.*,a.name referrerName,IFNULL(c.balance,0) balance  FROM mall_member m
+        left join mall_member a on m.referrer_id = a.invite_id
+        LEFT JOIN mall_member_wallet c on c.member_id = m.id
         <where>
             <if test="record != null" >
                 <if test="record.name!=null and record.name!=''">
@@ -13,6 +15,7 @@
                     and (
                         m.phone like concat('%',  #{record.account},'%')
                         or m.email like concat('%',  #{record.account},'%')
+                        or m.bind_phone like concat('%',  #{record.account},'%')
                         or m.invite_id like concat('%',  #{record.account},'%')
                         )
                 </if>
@@ -28,7 +31,8 @@
     </select>
 
     <select id="getMallMemberInfoById" resultType="cc.mrbird.febs.mall.vo.MallMemberVo">
-        SELECT a.name,
+        SELECT a.id,
+               a.name,
                a.phone,
                a.email,
                a.sex,
@@ -36,12 +40,15 @@
                a.level,
                a.account_status,
                a.CREATED_TIME,
-               c.balance,
+               IFNULL(c.balance,0) balance,
+               d.description levelName,
                b.name
                FROM mall_member a
             LEFT JOIN mall_member b on a.referrer_id = b.invite_id
             LEFT JOIN mall_member_wallet c on c.member_id = a.id
+            LEFT JOIN data_dictionary_custom d on d.code = a.level
             where a.id = #{id}
+            GROUP BY a.id
     </select>
 
     <select id="selectInfoByAccount" resultType="cc.mrbird.febs.mall.entity.MallMember">
@@ -158,7 +165,7 @@
 
     <select id="selectMemberParentAgentList" resultType="cc.mrbird.febs.mall.entity.MallMember">
         select * from mall_member
-        where level not in  ('ZERO_LEVEL', 'FIRST_LEVEL') and invteId!=#{refererId} and invite_id IN
+        where level not in  ('ZERO_LEVEL', 'FIRST_LEVEL') and invite_id!=#{refererId} and invite_id IN
         <foreach collection = "list" item = "item"  separator=","  open = "(" close = ")" >
             #{item}
         </foreach >
@@ -207,4 +214,111 @@
     <select id="getAppVersionListInPage" resultType="cc.mrbird.febs.mall.entity.AppVersion">
         select a.* from app_version a
     </select>
+
+    <select id="selectByIdAndNoLevel" resultType="cc.mrbird.febs.mall.entity.MallMember">
+        select * from mall_member where referrer_id=#{refererId} and level != #{level}
+    </select>
+
+    <select id="selectMallMemberByInviteIdAndLevel" resultType="cc.mrbird.febs.mall.entity.MallMember">
+        SELECT
+            m.*, b.
+            VALUE
+
+        FROM
+            mall_member m
+                LEFT JOIN data_dictionary_custom b ON m. LEVEL = b. CODE
+        WHERE
+            find_in_set(#{inviteId}, m.referrer_ids)
+          AND b.type = 'AGENT_LEVEL'
+          AND b.VALUE > (
+            SELECT
+                VALUE
+            FROM
+                data_dictionary_custom a
+            WHERE
+                a. CODE = #{level}
+              AND a.type = 'AGENT_LEVEL'
+        )
+        GROUP BY
+            m.id
+    </select>
+
+
+
+    <select id="getAgentLevelSetInfoByMemberId" resultType="cc.mrbird.febs.mall.vo.AdminAgentLevelSetInfoVo">
+        SELECT a.id,d.code levelCode
+        FROM mall_member a
+                 LEFT JOIN data_dictionary_custom d on d.code = a.level
+        where a.id = #{id} and d.type = 'AGENT_LEVEL'
+        GROUP BY a.id
+    </select>
+
+    <select id="getMallDataListInPage" resultType="cc.mrbird.febs.mall.vo.MallDataVo">
+        SELECT
+            DATE_FORMAT(a.CREATED_TIME, '%Y-%m-%d') createdTime,
+            IFNULL(t1.tol, 0) *- 1 AS payMoney,
+            IFNULL(t2.to2, 0) AS refundMoney,
+            IFNULL(t3.to3, 0) *- 1 AS rewordMoney,
+            (
+                    (IFNULL(t1.tol, 0)*- 1) - (IFNULL(t2.to2, 0)) + (IFNULL(t3.to3, 0)*- 1)
+                ) AS surplusMoney
+        FROM
+            mall_money_flow a
+                LEFT JOIN (
+                SELECT
+                    b.CREATED_TIME,
+                    IFNULL(SUM(b.amount), 0) AS tol
+                FROM
+                    mall_money_flow b
+                WHERE
+                    b.type = 3
+                GROUP BY
+                    DATE_FORMAT(b.CREATED_TIME, '%Y-%m-%d')
+            ) t1 ON DATE_FORMAT(t1.CREATED_TIME, '%Y-%m-%d') = DATE_FORMAT(a.CREATED_TIME, '%Y-%m-%d')
+                LEFT JOIN (
+                SELECT
+                    c.CREATED_TIME,
+                    IFNULL(SUM(c.amount), 0) AS to2
+                FROM
+                    mall_money_flow c
+                WHERE
+                    c.type = 4
+                GROUP BY
+                    DATE_FORMAT(c.CREATED_TIME, '%Y-%m-%d')
+            ) t2 ON DATE_FORMAT(t2.CREATED_TIME, '%Y-%m-%d') = DATE_FORMAT(a.CREATED_TIME, '%Y-%m-%d')
+                LEFT JOIN (
+                SELECT
+                    d.CREATED_TIME,
+                    IFNULL(SUM(d.amount), 0) AS to3
+                FROM
+                    mall_money_flow d
+                WHERE
+                    d.type IN (1, 2)
+                GROUP BY
+                    DATE_FORMAT(d.CREATED_TIME, '%Y-%m-%d')
+            ) t3 ON DATE_FORMAT(t3.CREATED_TIME, '%Y-%m-%d') = DATE_FORMAT(a.CREATED_TIME, '%Y-%m-%d')
+        GROUP BY
+            DATE_FORMAT(a.CREATED_TIME, '%Y-%m-%d')
+        ORDER BY
+            DATE_FORMAT(a.CREATED_TIME, '%Y-%m-%d') DESC
+    </select>
+
+    <select id="selectRankListInPage" resultType="cc.mrbird.febs.mall.entity.MallMember">
+        select * from (
+          select a.id, a.name, a.invite_id, a.avatar, sum(b.amount) amount,max(order_time) orderTime from mall_member a, mall_order_info b
+          where  a.id=b.member_id and b.status = 4
+        <!-- 日 -->
+        <if test="record.query == '1'">
+
+        </if>
+        <!-- 月 -->
+        <if test="record.query == '2'">
+            and date_format(#{record.createdTime},'%Y-%m') = date_format(b.order_time,'%Y-%m')
+        </if>
+        <if test="record.amount != null">
+            and amount = #{record.amount}
+        </if>
+          group by a.id
+      ) a order by amount desc, a.orderTime desc
+    </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.1