手机端-好友列表,客户数对不上问题修改,查询优化。

master
kevin jiang 6 years ago
parent bd2a207c68
commit cd12030aa8

@ -37,12 +37,12 @@
CONCAT('%',#{search},'%')) CONCAT('%',#{search},'%'))
</if> </if>
<if test="startDate != null"> <if test="startDate != null">
and DATE_FORMAT(t2.create_time,'%Y-%m-%d') &gt;= DATE_FORMAT(#{startDate},'%Y-%m-%d') and date(t1.create_time) &gt;= #{startDate}
</if> </if>
<if test="endDate != null"> <if test="endDate != null">
and DATE_FORMAT(t2.create_time,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate},'%Y-%m-%d') and date(t1.create_time &lt;= #{endDate}
</if> </if>
GROUP BY t4.id order by t2.create_time desc GROUP BY t4.id order by t1.create_time desc
</select> </select>
<select id="selectFriendListByShopId" resultType="com.kiisoo.ic.customer.bean.FriendDTO"> <select id="selectFriendListByShopId" resultType="com.kiisoo.ic.customer.bean.FriendDTO">
@ -57,11 +57,11 @@
t5.`name` as inviteSellerName t5.`name` as inviteSellerName
FROM FROM
op_seller_customer_relation t1 op_seller_customer_relation t1
join op_customer t2 on t1.customer_id = t2.id left join op_customer t2 on t1.customer_id = t2.id
LEFT JOIN op_vip t3 ON t2.member_id = t3.id LEFT JOIN op_vip t3 ON t2.member_id = t3.id
AND t3. STATUS = 1 AND t3. STATUS = 1
JOIN poi_store_staff t4 ON t4.store_id = t1.store_id left JOIN poi_store_staff t4 ON t4.store_id = t1.store_id and t4.id = t1.user_id
JOIN privilage_user t5 ON t4.user_id = t5.id left JOIN privilage_user t5 ON t4.user_id = t5.id
WHERE WHERE
1 = 1 1 = 1
<if test="type == 1"> <if test="type == 1">
@ -82,13 +82,13 @@
CONCAT('%',#{search},'%')) CONCAT('%',#{search},'%'))
</if> </if>
<if test="startDate != null"> <if test="startDate != null">
and DATE_FORMAT(t2.create_time,'%Y-%m-%d') &gt;= DATE_FORMAT(#{startDate},'%Y-%m-%d') and date(t1.create_time) &gt;= #{startDate}
</if> </if>
<if test="endDate != null"> <if test="endDate != null">
and DATE_FORMAT(t2.create_time,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate},'%Y-%m-%d') and date(t1.create_time) &lt;= #{endDate}
</if> </if>
group by t2.id group by t2.id
order by t2.create_time desc order by t1.create_time desc
</select> </select>
<!--根据导购id查询导购名--> <!--根据导购id查询导购名-->
<select id="selectStaffName" resultType="java.lang.String"> <select id="selectStaffName" resultType="java.lang.String">
@ -142,13 +142,13 @@
t2.create_time AS addTime , t2.create_time AS addTime ,
t2.avatar_url AS avatar , t2.avatar_url AS avatar ,
t3. LEVEL AS vipFlag, t3. LEVEL AS vipFlag,
t5.`name` as sellerName t5.`name` as inviteSellerName
FROM FROM
op_seller_customer_relation t1 op_seller_customer_relation t1
join op_customer t2 on t1.customer_id = t2.id join op_customer t2 on t1.customer_id = t2.id
LEFT JOIN op_vip t3 ON t2.member_id = t3.id LEFT JOIN op_vip t3 ON t2.member_id = t3.id
AND t3. STATUS = 1 AND t3. STATUS = 1
JOIN poi_store_staff t4 ON t4.store_id = t1.store_id JOIN poi_store_staff t4 ON t4.store_id = t1.store_id and t4.id = t1.user_id
JOIN privilage_user t5 ON t4.user_id = t5.id JOIN privilage_user t5 ON t4.user_id = t5.id
WHERE WHERE
1 = 1 1 = 1
@ -170,7 +170,7 @@
CONCAT('%',#{search},'%')) CONCAT('%',#{search},'%'))
</if> </if>
group by t2.id,t1.user_id group by t2.id,t1.user_id
order by t2.create_time desc order by t1.create_time desc
</select> </select>
<select id="selectFriendListBySellerAndDate" resultType="com.kiisoo.ic.customer.bean.FriendDTO"> <select id="selectFriendListBySellerAndDate" resultType="com.kiisoo.ic.customer.bean.FriendDTO">
@ -208,6 +208,6 @@
(t2.name LIKE CONCAT('%',#{search},'%') OR t3.phone LIKE (t2.name LIKE CONCAT('%',#{search},'%') OR t3.phone LIKE
CONCAT('%',#{search},'%')) CONCAT('%',#{search},'%'))
</if> </if>
GROUP BY t4.id order by t2.create_time desc GROUP BY t4.id order by t1.create_time desc
</select> </select>
</mapper> </mapper>

@ -294,25 +294,25 @@
WHERE t.store_id = #{storeId} WHERE t.store_id = #{storeId}
and t.customer_id = t2.id and t.customer_id = t2.id
<if test="startDate != null"> <if test="startDate != null">
and DATE_FORMAT(t2.create_time,'%Y-%m-%d') &gt;= DATE_FORMAT(#{startDate},'%Y-%m-%d') and date(t.create_time) &gt;= #{startDate}
</if> </if>
<if test="endDate != null"> <if test="endDate != null">
and DATE_FORMAT(t2.create_time,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate},'%Y-%m-%d') and date(t.create_time) &lt;= #{endDate}
</if> </if>
group by store_id group by store_id
</select> </select>
<select id="selectWxSumCusNumByConditionStaff" resultType="java.lang.Integer"> <select id="selectWxSumCusNumByConditionStaff" resultType="java.lang.Integer">
SELECT count(customer_id) from op_seller_customer_relation t1, poi_store_staff t2 where t1.user_id = t2.id SELECT count(customer_id) from op_seller_customer_relation t1, poi_store_staff t2, op_customer t3 where t1.customer_id = t3.id and t1.user_id = t2.id
and t2.type = 4 and t2.type = 4
<if test="userId != null"> <if test="userId != null">
AND t2.user_id = #{userId} AND t2.user_id = #{userId}
</if> </if>
<if test="startDate != null"> <if test="startDate != null">
and DATE_FORMAT(t1.create_time,'%Y-%m-%d') &gt;= DATE_FORMAT(#{startDate},'%Y-%m-%d') and date(t1.create_time) &gt;= #{startDate}
</if> </if>
<if test="endDate != null"> <if test="endDate != null">
and DATE_FORMAT(t1.create_time,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate},'%Y-%m-%d') and date(t1.create_time) &lt;= #{endDate}
</if> </if>
group by t1.user_id group by t1.user_id
</select> </select>
@ -326,17 +326,18 @@
user_id AS id, user_id AS id,
count( customer_id ) AS cusNum count( customer_id ) AS cusNum
FROM FROM
`op_seller_customer_relation` `op_seller_customer_relation` t,op_customer t2
WHERE WHERE
store_id = #{storeId} t.customer_id = t2.id
and t. store_id = #{storeId}
<if test="startDate != null"> <if test="startDate != null">
and DATE_FORMAT(create_time,'%Y-%m-%d') &gt;= DATE_FORMAT(#{startDate},'%Y-%m-%d') and date(t.create_time) &gt;= #{startDate}
</if> </if>
<if test="endDate != null"> <if test="endDate != null">
and DATE_FORMAT(create_time,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate},'%Y-%m-%d') and date(t.create_time) &lt;= #{endDate}
</if> </if>
GROUP BY GROUP BY
user_id t.user_id
</select> </select>
<select id="selectWxValidStaffNameList" resultType="com.kiisoo.ic.store.entity.StaffDO"> <select id="selectWxValidStaffNameList" resultType="com.kiisoo.ic.store.entity.StaffDO">
SELECT SELECT
@ -370,10 +371,10 @@
JOIN `op_seller_customer_relation` t2 ON t1.id = t2.store_id JOIN `op_seller_customer_relation` t2 ON t1.id = t2.store_id
JOIN op_customer t3 on t2.customer_id = t3.id JOIN op_customer t3 on t2.customer_id = t3.id
<if test="startDate != null"> <if test="startDate != null">
and DATE_FORMAT(t3.create_time,'%Y-%m-%d') &gt;= DATE_FORMAT(#{startDate},'%Y-%m-%d') and date(t2.create_time) &gt;= #{startDate}
</if> </if>
<if test="endDate != null"> <if test="endDate != null">
and DATE_FORMAT(t3.create_time,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate},'%Y-%m-%d') and date(t2.create_time) &lt;= #{endDate}
</if> </if>
WHERE WHERE
t1.STATUS = 1 t1.STATUS = 1
@ -393,15 +394,16 @@
( SELECT count( t2.customer_id ) AS newCusNum, t1.user_id AS userId FROM ( SELECT count( t2.customer_id ) AS newCusNum, t1.user_id AS userId FROM
poi_store_staff t1 poi_store_staff t1
LEFT JOIN `op_seller_customer_relation` t2 ON t1.id = t2.user_id LEFT JOIN `op_seller_customer_relation` t2 ON t1.id = t2.user_id
left join op_customer t3 on t2.customer_id = t3.id
<if test="startDate != null"> <if test="startDate != null">
and DATE_FORMAT(t2.create_time,'%Y-%m-%d') &gt;= DATE_FORMAT(#{startDate},'%Y-%m-%d') and date(t2.create_time) &gt;= #{startDate}
</if> </if>
<if test="endDate != null"> <if test="endDate != null">
and DATE_FORMAT(t2.create_time,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate},'%Y-%m-%d') and date(t2.create_time) &lt;= #{endDate}
</if> </if>
where t1.store_id = #{storeId} where t1.store_id = #{storeId}
and t1.type = 4 and t1.type = 4
GROUP BY userId ORDER BY newCusNum DESC, userId DESC ) a, GROUP BY userId,t3.id ORDER BY newCusNum DESC, userId DESC ) a,
( SELECT @rank := 0 ) b ( SELECT @rank := 0 ) b
</select> </select>
<select id="selectLatestUpdateTime" resultType="java.util.Date"> <select id="selectLatestUpdateTime" resultType="java.util.Date">

Loading…
Cancel
Save