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

master
kevin jiang 6 years ago
parent bd2a207c68
commit cd12030aa8

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

@ -294,25 +294,25 @@
WHERE t.store_id = #{storeId}
and t.customer_id = t2.id
<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 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>
group by store_id
</select>
<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
<if test="userId != null">
AND t2.user_id = #{userId}
</if>
<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 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>
group by t1.user_id
</select>
@ -326,17 +326,18 @@
user_id AS id,
count( customer_id ) AS cusNum
FROM
`op_seller_customer_relation`
`op_seller_customer_relation` t,op_customer t2
WHERE
store_id = #{storeId}
t.customer_id = t2.id
and t. store_id = #{storeId}
<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 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>
GROUP BY
user_id
t.user_id
</select>
<select id="selectWxValidStaffNameList" resultType="com.kiisoo.ic.store.entity.StaffDO">
SELECT
@ -370,10 +371,10 @@
JOIN `op_seller_customer_relation` t2 ON t1.id = t2.store_id
JOIN op_customer t3 on t2.customer_id = t3.id
<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 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>
WHERE
t1.STATUS = 1
@ -393,15 +394,16 @@
( SELECT count( t2.customer_id ) AS newCusNum, t1.user_id AS userId FROM
poi_store_staff t1
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">
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 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>
where t1.store_id = #{storeId}
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>
<select id="selectLatestUpdateTime" resultType="java.util.Date">

Loading…
Cancel
Save