From b8d50f6ad9d1ab407e5b2a6867cf47bc4640a43c Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Mon, 12 Apr 2021 18:11:55 +0800
Subject: [PATCH] modify taocanlist api

---
 zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml |  226 ++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 169 insertions(+), 57 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 417b21f..9437453 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml
+++ b/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml
@@ -52,6 +52,15 @@
         <result property="isDeal" column="is_deal"/>
         <result property="createDistributionTime" column="create_distribution_time"/>
 
+        <result property="isSales" column="is_sales" />
+        <result property="withdrawalCash" column="withdrawal_cash" />
+        <result property="salesmanGrade" column="salesman_grade" />
+        <result property="nickName" column="nick_name" />
+        <result property="avatarUrl" column="avatar_url" />
+        <result property="gender" column="gender" />
+        <result property="country" column="country" />
+        <result property="sessionKey" column="session_key" />
+        <result property="userIsAuthorize" column="user_is_authorize" />
 
         <!-- 扩展属性 -->
         <result property="staffName" column="STAFF_NAME"/>
@@ -105,6 +114,17 @@
         <result property="createDistributionTime" column="create_distribution_time"/>
         <result property="disease" column="disease"/>
         <result property="companyId" column="company_id"/>
+
+        <result property="isSales" column="is_sales" />
+        <result property="withdrawalCash" column="withdrawal_cash" />
+        <result property="salesmanGrade" column="salesman_grade" />
+        <result property="nickName" column="nick_name" />
+        <result property="avatarUrl" column="avatar_url" />
+        <result property="gender" column="gender" />
+        <result property="country" column="country" />
+        <result property="sessionKey" column="session_key" />
+        <result property="userIsAuthorize" column="user_is_authorize" />
+
         <!-- 扩展属性 -->
         <result property="staffName" column="STAFF_NAME"/>
         <result property="shopName" column="SHOP_NAME"/>
@@ -286,7 +306,16 @@
         province,
         city,
         area,
-        recommend_id
+        recommend_id,
+        is_sales,
+        withdrawal_cash,
+        salesman_grade,
+        nick_name,
+        avatar_url,
+        gender,
+        country,
+        session_key,
+        user_is_authorize
         )
 
 
@@ -334,7 +363,16 @@
         #{province},
         #{city},
         #{area},
-        #{recommendId}
+        #{recommendId},
+        #{isSales},
+        #{withdrawalCash},
+        #{salesmanGrade},
+        #{nickName},
+        #{avatarUrl},
+        #{gender},
+        #{country},
+        #{sessionKey},
+        #{userIsAuthorize}
         )
 
     </insert>
@@ -473,6 +511,34 @@
             <if test="area != null and area !=''  ">
                 area = #{area},
             </if>
+            <if test="isSales != null ">
+                is_sales  = #{isSales},
+            </if>
+            <if test="withdrawalCash != null ">
+                withdrawal_cash  = #{withdrawalCash},
+            </if>
+            <if test="salesmanGrade != null ">
+                salesman_grade  = #{salesmanGrade},
+            </if>
+
+            <if test="gender != null and gender != '' ">
+                gender  = #{gender},
+            </if>
+            <if test="country != null and country != '' ">
+                country  = #{country},
+            </if>
+            <if test="sessionKey != null and sessionKey != '' ">
+                session_key  = #{sessionKey},
+            </if>
+            <if test="userIsAuthorize != null ">
+                user_is_authorize  = #{userIsAuthorize},
+            </if>
+            <if test="nickName != null and nickName != '' ">
+                nick_name  = #{nickName},
+            </if>
+            <if test="avatarUrl != null and avatarUrl != '' ">
+                avatar_url  = #{avatarUrl},
+            </if>
 
 
         </set>
@@ -482,6 +548,10 @@
     <update id="pointClose">
 		UPDATE sys_vip_info set POINT_ALL = 0
 	</update>
+
+    <update id="unbundlingSaleMan">
+        UPDATE sys_vip_info set recommend_id = NULL where id=#{userId};
+    </update>
 
     <!-- 批量删除 -->
     <delete id="deleteByIds" parameterType="java.util.List">
@@ -536,6 +606,11 @@
         <include refid="select"></include>
         <include refid="from"></include>
         where a.ID=#{id}
+    </select>
+
+    <select id="findByOpenId" resultMap="SysVipInfoMap">
+        select *
+        from sys_vip_info where openid=#{openId}
     </select>
 
     <!-- 根据手机和密码查询 -->
@@ -640,14 +715,11 @@
 		COMMISSION_ALL,IN_DATE,STAFF_ID,SHOP_ID,IS_DELETE,REMARK,PASSWORD,
 		EMAIL,CREATE_TIME,UUID,BALANCE,blood,sfCard,link,marry,vocation 
 	     from sys_vip_info 
-	     where
-	     SHOP_ID=#{shopId}
-	    and  (
-	    instr(PHONE,#{keyWord})
+	     where company_id=#{companyId}
+	   and (instr(PHONE,#{keyWord})
 	      or instr(VIP_NAME ,#{keyWord})
 	      or instr(zjm ,#{keyWord})
-	        or instr(VIP_NO ,#{keyWord})
-	    )
+	        or instr(VIP_NO ,#{keyWord}))
 	      limit 0,15
 	</select>
 
@@ -672,7 +744,7 @@
         and
         (a.VIP_NO =#{key} or
         a.VIP_NAME =#{key} or
-        a.PHONE =#{key}) and a.shop_id=#{shopId}
+        a.PHONE =#{key})
     </select>
 
     <select id="getLevelIdByMoney" resultMap="SysVipInfoMap">
@@ -814,6 +886,28 @@
             <if test="(record.companyId!=null and record.companyId!='') ">
                 and a.company_id = #{record.companyId}
             </if>
+
+            <if test="(record.nickName!=null and record.nickName!='') or  (record.nickName!='' and record.nickName==0)  ">
+                and a.nick_name  like concat('%',#{record.nickName},'%')
+            </if>
+            <if test="(record.avatarUrl!=null and record.avatarUrl!='') or  (record.avatarUrl!='' and record.avatarUrl==0)  ">
+                and a.avatar_url  = #{record.avatarUrl}
+            </if>
+            <if test="record.isSales != null and record.isSales !='' ">
+                and a.is_sales = #{record.isSales}
+            </if>
+
+            <if test="record.withdrawalCash != null and record.withdrawalCash !='' ">
+                and a.withdrawal_cash = #{record.withdrawalCash}
+            </if>
+
+            <if test="record.salesmanGrade != null and record.salesmanGrade !='' ">
+                and a.salesman_grade = #{record.salesmanGrade}
+            </if>
+            <if test="(record.userIsAuthorize!=null and record.userIsAuthorize!='') or  (record.userIsAuthorize!='' and record.userIsAuthorize==0)  ">
+                and a.user_is_authorize  = #{record.userIsAuthorize}
+            </if>
+
         </if>
     </sql>
 
@@ -919,57 +1013,34 @@
             <if test="record.isDeal != null and record.isDeal !='' ">
                 and a.is_deal = #{record.isDeal}
             </if>
+            <if test="(record.nickName!=null and record.nickName!='') or  (record.nickName!='' and record.nickName==0)  ">
+                and a.nick_name  like concat('%',#{record.nickName},'%')
+            </if>
+            <if test="(record.avatarUrl!=null and record.avatarUrl!='') or  (record.avatarUrl!='' and record.avatarUrl==0)  ">
+                and a.avatar_url  = #{record.avatarUrl}
+            </if>
+            <if test="record.isSales != null and record.isSales !='' ">
+                and a.is_sales = #{record.isSales}
+            </if>
+
+            <if test="record.withdrawalCash != null and record.withdrawalCash !='' ">
+                and a.withdrawal_cash = #{record.withdrawalCash}
+            </if>
+
+            <if test="record.salesmanGrade != null and record.salesmanGrade !='' ">
+                and a.salesman_grade = #{record.salesmanGrade}
+            </if>
+            <if test="(record.userIsAuthorize!=null and record.userIsAuthorize!='') or  (record.userIsAuthorize!='' and record.userIsAuthorize==0)  ">
+                and a.user_is_authorize  = #{record.userIsAuthorize}
+            </if>
         </if>
     </sql>
 
     <sql id="select">
 		select
-	 	a.ID,
-		a.VIP_NO,
-		a.VIP_NAME,
-		a.PHONE,
-		a.SEX,
-		a.BIRTHDAY1,
-		a.photo,
-		a.ADDR,
-		a.CONSTELL,
-		a.ANIMAL_SIGN,
-		a.ARRIVAL_WAY,
-		a.VIP_TYPE,
-		a.VIP_STATE,
-		a.POINT_ALL,
-		a.COMMISSION_ALL,
-		a.IN_DATE,
-		a.REMARK,
-		a.SHOP_ID,
-		a.IS_DELETE,
-		a.EMAIL,
-		a.STAFF_ID,
-		a.CREATE_TIME,
-		a.LEVEL_ID,
-		a.UUID,
-		a.BALANCE,
-		a.BEATUY_ID,
-		a.PASSWORD,
+	 	a.*,
 		c.su_name as STAFF_NAME,
 		d.SHOP_NAME,
-		a.blood,
-		a.sfCard,
-		a.link,
-		a.marry,
-		a.vocation,
-		a.handle_time,
-		a.statu,
-		a.openid,
-		a.parent_id,
-		a.create_distribution_time,
-		a.birthdayType,
-		a.disease,
-		a.is_deal,
-		a.province,
-		a.city,
-		a.area,
-		a.recommend_id,
 		e.level_name levelName,
 		e.vip_level vipLevel
 	</sql>
@@ -1206,7 +1277,22 @@
         create_distribution_time,
         birthdayType,
         disease,
-        is_deal
+        is_deal,
+        zjm,
+        company_id,
+        province,
+        city,
+        area,
+        recommend_id,
+        is_sales,
+        withdrawal_cash,
+        salesman_grade,
+        nick_name,
+        avatar_url,
+        gender,
+        country,
+        session_key,
+        user_is_authorize
         )
         VALUES
         <foreach collection="list" item="item" index="index" separator=",">(
@@ -1247,7 +1333,22 @@
             #{item.createDistributionTime},
             #{item.birthdayType},
             #{item.disease},
-            #{item.isDeal}
+            #{item.isDeal},
+            #{zjm},
+            #{companyId},
+            #{province},
+            #{city},
+            #{area},
+            #{recommendId},
+            #{isSales},
+            #{withdrawalCash},
+            #{salesmanGrade},
+            #{nickName},
+            #{avatarUrl},
+            #{gender},
+            #{country},
+            #{sessionKey},
+            #{userIsAuthorize}
             )</foreach>
     </insert>
 
@@ -1318,6 +1419,9 @@
         <if test="record.shopId != null">
             and a.shop_id=#{record.shopId}
         </if>
+        <if test="record.companyId != null">
+            and a.company_id=#{record.companyId}
+        </if>
         <if test='record.birthType=="1"'>
             and a.BIRTHDAY1 between curdate() and DATE_ADD(CURDATE(), INTERVAL 3 DAY)
         </if>
@@ -1340,6 +1444,9 @@
         <if test="record.sort != 'monthArrived' and record.sort != 'yearArrived'">
             order by ${record.sort} ${record.order}
         </if>
+        <if test="record.offset >=0  and record.limit >0">
+            limit #{record.offset},#{record.limit}
+        </if>
     </select>
 
     <select id="selectVipInfoById" resultType="com.matrix.system.app.vo.VipInfoVo">
@@ -1354,13 +1461,18 @@
                e.shop_short_name shopName,
                sum(IFNULL(b.gift_money, 0) + IFNULL(b.real_money, 0)) totalBalance,
                sum(IFNULL(b.gift_money, 0)) giftBalance,
-               sum(IFNULL(d.goods_cash, 0) + IFNULL(d.proj_cash, 0) + IFNULL(d.card_cash, 0)) totalShopping
+               (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
         left join money_card_use b on a.ID = b.vip_id and b.status='有效'
         left join sys_vip_level c on  a.LEVEL_ID = c.ID
-        left join achieve_new d on a.ID = d.vip_id
         left join sys_shop_info e on a.SHOP_ID=e.ID
         where a.ID=#{id}
     </select>
+
+
+
+
+
+
 </mapper>
 	

--
Gitblit v1.9.1