From c41e8d372cdabbe1fd5973c9322e38a40bfa1a39 Mon Sep 17 00:00:00 2001
From: 姜友瑶 <935090232@qq.com>
Date: Thu, 05 May 2022 15:50:07 +0800
Subject: [PATCH] Merge branch 'developer' into alpha

---
 zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml |   77 ++++++++++++++++++++++++++++++++++++--
 1 files changed, 72 insertions(+), 5 deletions(-)

diff --git a/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml b/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml
index 9437453..b23d511 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml
+++ b/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml
@@ -61,6 +61,7 @@
         <result property="country" column="country" />
         <result property="sessionKey" column="session_key" />
         <result property="userIsAuthorize" column="user_is_authorize" />
+        <result property="validFlag" column="valid_flag" />
 
         <!-- 扩展属性 -->
         <result property="staffName" column="STAFF_NAME"/>
@@ -124,6 +125,7 @@
         <result property="country" column="country" />
         <result property="sessionKey" column="session_key" />
         <result property="userIsAuthorize" column="user_is_authorize" />
+        <result property="validFlag" column="valid_flag" />
 
         <!-- 扩展属性 -->
         <result property="staffName" column="STAFF_NAME"/>
@@ -499,9 +501,7 @@
             <if test="isDeal != null  ">
                 is_deal = #{isDeal},
             </if>
-            <if test="recommendId != null  ">
-                recommend_id = #{recommendId},
-            </if>
+
             <if test="province != null and province !=''  ">
                 province = #{province},
             </if>
@@ -539,6 +539,9 @@
             <if test="avatarUrl != null and avatarUrl != '' ">
                 avatar_url  = #{avatarUrl},
             </if>
+            <if test="validFlag != null and validFlag != '' ">
+                valid_flag  = #{validFlag},
+            </if>
 
 
         </set>
@@ -551,6 +554,9 @@
 
     <update id="unbundlingSaleMan">
         UPDATE sys_vip_info set recommend_id = NULL where id=#{userId};
+    </update>
+    <update id="bindingRecommend">
+        UPDATE sys_vip_info set recommend_id = #{recommendId} where id=#{userId};
     </update>
 
     <!-- 批量删除 -->
@@ -1207,7 +1213,7 @@
 
     <select id="selectByPhone" resultMap="SysVipInfoMapSimple">
 
-		select * from sys_vip_info where  PHONE = #{phone}
+		select * from sys_vip_info where  PHONE = #{phone} and company_id=#{companyId}
 	</select>
 
 
@@ -1360,6 +1366,7 @@
         select
                a.ID id,
                a.VIP_NAME vipName,
+               a.VIP_NO vipNo,
                a.PHONE phone,
                a.photo photo,
                b.arriveCnt arriveCnt,
@@ -1459,7 +1466,7 @@
                c.LEVEL_NAME vipLevel,
                a.POINT_ALL integral,
                e.shop_short_name shopName,
-               sum(IFNULL(b.gift_money, 0) + IFNULL(b.real_money, 0)) totalBalance,
+               sum(IFNULL(b.real_money, 0)) totalBalance,
                sum(IFNULL(b.gift_money, 0)) giftBalance,
                (select sum(IFNULL(d.goods_cash, 0) + IFNULL(d.proj_cash, 0) + IFNULL(d.card_cash, 0)) from achieve_new d where d.vip_id=a.id) totalShopping
         from sys_vip_info a
@@ -1471,8 +1478,68 @@
 
 
 
+    <select id="selectVipArrearsStatistics" resultType="java.util.Map">
+        select
+            a.VIP_NAME vipName,
+            a.PHONE phone,
+            c.shop_short_name shopName,
+            sum(b.arrears) arrears,
+            count(1) cnt,
+            d.su_name staffName
+        from sys_vip_info a
+         inner join sys_order b on a.ID=b.VIP_ID
+         inner join sys_shop_info c on a.SHOP_ID=c.ID
+         left join sys_users d on a.STAFF_ID=d.su_id
+        where b.STATU='欠款' and b.arrears!=0
+            <if test="record.companyId!=null">
+                and a.company_id=#{record.companyId}
+            </if>
+            <if test="record.shopId!=null">
+                and a.shop_id=#{record.shopId}
+            </if>
+            <if test='record.vipName!=null and record.vipName!="" '>
+                and (a.vip_name like concat('%', #{record.vipName}, '%') or a.vip_no like concat('%', #{record.vipName}, '%') or a.phone like concat('%', #{record.vipName}, '%'))
+            </if>
+        group by a.id
+        <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
+            <if test="pageVo.sort !=null  and pageVo.order !=null">
+                order by
+                ${pageVo.sort} ${pageVo.order}
+            </if>
+            <if test="pageVo.offset >=0  and pageVo.limit >0">
+                limit
+                #{pageVo.offset},#{pageVo.limit}
+            </if>
+        </if>
+    </select>
 
 
+    <select id="selectVipArrearsStatisticsTotal" resultType="java.lang.Integer">
+        select count(1) from (
+            select
+                a.VIP_NAME vipName,
+                a.PHONE phone,
+                c.shop_short_name shopName,
+                sum(b.arrears) arrears,
+                count(1) cnt,
+                d.su_name staffName
+            from sys_vip_info a
+                inner join sys_order b on a.ID=b.VIP_ID
+                inner join sys_shop_info c on a.SHOP_ID=c.ID
+                left join sys_users d on a.STAFF_ID=d.su_id
+            where b.STATU='欠款' and b.arrears!=0
+                <if test="record.companyId!=null">
+                    and a.company_id=#{record.companyId}
+                </if>
+                <if test="record.shopId!=null">
+                    and a.shop_id=#{record.shopId}
+                </if>
 
+                <if test='record.vipName!=null and record.vipName!="" '>
+                    and (a.vip_name like concat('%', #{record.vipName}, '%') or a.vip_no like concat('%', #{record.vipName}, '%') or a.phone like concat('%', #{record.vipName}, '%'))
+                </if>
+            group by a.id
+        ) a
+    </select>
 </mapper>
 	

--
Gitblit v1.9.1