|
|
@ -89,10 +89,10 @@
|
|
|
|
poi_store t1
|
|
|
|
poi_store t1
|
|
|
|
LEFT JOIN op_seller_customer_relation t4 on t1.id = t4.store_id
|
|
|
|
LEFT JOIN op_seller_customer_relation t4 on t1.id = t4.store_id
|
|
|
|
<if test="startDate != null">
|
|
|
|
<if test="startDate != null">
|
|
|
|
and DATE_FORMAT(t4.create_time,'%Y-%m-%d') >= DATE_FORMAT(#{startDate},'%Y-%m-%d')
|
|
|
|
and t4.create_time >= #{startDate}
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
<if test="endDate != null">
|
|
|
|
<if test="endDate != null">
|
|
|
|
and DATE_FORMAT(t4.create_time,'%Y-%m-%d') <= DATE_FORMAT(#{endDate},'%Y-%m-%d')
|
|
|
|
and t4.create_time <= #{endDate}
|
|
|
|
</if>,
|
|
|
|
</if>,
|
|
|
|
poi_store_region t2
|
|
|
|
poi_store_region t2
|
|
|
|
WHERE
|
|
|
|
WHERE
|
|
|
@ -169,10 +169,10 @@
|
|
|
|
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
|
|
|
|
<if test="startDate != null">
|
|
|
|
<if test="startDate != null">
|
|
|
|
and DATE_FORMAT(t4.create_time,'%Y-%m-%d') >= DATE_FORMAT(#{startDate},'%Y-%m-%d')
|
|
|
|
and t4.create_time >= #{startDate}
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
<if test="endDate != null">
|
|
|
|
<if test="endDate != null">
|
|
|
|
and DATE_FORMAT(t4.create_time,'%Y-%m-%d') <= DATE_FORMAT(#{endDate},'%Y-%m-%d')
|
|
|
|
and t4.create_time <= #{endDate}
|
|
|
|
</if>,
|
|
|
|
</if>,
|
|
|
|
privilage_user t3,
|
|
|
|
privilage_user t3,
|
|
|
|
poi_store_region t4
|
|
|
|
poi_store_region t4
|
|
|
@ -290,29 +290,28 @@
|
|
|
|
</select>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="selectWxSumCusNumByConditionShopManager" resultType="java.lang.Integer">
|
|
|
|
<select id="selectWxSumCusNumByConditionShopManager" resultType="java.lang.Integer">
|
|
|
|
SELECT count(customer_id) from op_seller_customer_relation t, op_customer t2
|
|
|
|
SELECT count(t.customer_id) from op_seller_customer_relation t
|
|
|
|
WHERE t.store_id = #{storeId}
|
|
|
|
WHERE t.store_id = #{storeId}
|
|
|
|
and t.customer_id = t2.id
|
|
|
|
|
|
|
|
<if test="startDate != null">
|
|
|
|
<if test="startDate != null">
|
|
|
|
and date(t.create_time) >= #{startDate}
|
|
|
|
and t.create_time >= #{startDate}
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
<if test="endDate != null">
|
|
|
|
<if test="endDate != null">
|
|
|
|
and date(t.create_time) <= #{endDate}
|
|
|
|
and t.create_time <= #{endDate}
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
group by store_id
|
|
|
|
group by t.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, op_customer t3 where t1.customer_id = t3.id and t1.user_id = t2.id
|
|
|
|
SELECT count(customer_id) from op_seller_customer_relation t1, poi_store_staff t2 where 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(t1.create_time) >= #{startDate}
|
|
|
|
and t1.create_time >= #{startDate}
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
<if test="endDate != null">
|
|
|
|
<if test="endDate != null">
|
|
|
|
and date(t1.create_time) <= #{endDate}
|
|
|
|
and t1.create_time <= #{endDate}
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
group by t1.user_id
|
|
|
|
group by t1.user_id
|
|
|
|
</select>
|
|
|
|
</select>
|
|
|
@ -326,15 +325,14 @@
|
|
|
|
user_id AS id,
|
|
|
|
user_id AS id,
|
|
|
|
count( customer_id ) AS cusNum
|
|
|
|
count( customer_id ) AS cusNum
|
|
|
|
FROM
|
|
|
|
FROM
|
|
|
|
`op_seller_customer_relation` t,op_customer t2
|
|
|
|
`op_seller_customer_relation` t
|
|
|
|
WHERE
|
|
|
|
WHERE
|
|
|
|
t.customer_id = t2.id
|
|
|
|
t. store_id = #{storeId}
|
|
|
|
and t. store_id = #{storeId}
|
|
|
|
|
|
|
|
<if test="startDate != null">
|
|
|
|
<if test="startDate != null">
|
|
|
|
and date(t.create_time) >= #{startDate}
|
|
|
|
and t.create_time >= #{startDate}
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
<if test="endDate != null">
|
|
|
|
<if test="endDate != null">
|
|
|
|
and date(t.create_time) <= #{endDate}
|
|
|
|
and t.create_time <= #{endDate}
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
GROUP BY
|
|
|
|
GROUP BY
|
|
|
|
t.user_id
|
|
|
|
t.user_id
|
|
|
@ -365,23 +363,20 @@
|
|
|
|
(
|
|
|
|
(
|
|
|
|
SELECT
|
|
|
|
SELECT
|
|
|
|
count( t2.customer_id ) AS newCusNum,
|
|
|
|
count( t2.customer_id ) AS newCusNum,
|
|
|
|
t1.id AS storeId
|
|
|
|
t2.store_id AS storeId
|
|
|
|
FROM
|
|
|
|
FROM
|
|
|
|
poi_store t1
|
|
|
|
`op_seller_customer_relation` t2
|
|
|
|
JOIN `op_seller_customer_relation` t2 ON t1.id = t2.store_id
|
|
|
|
where 1=1
|
|
|
|
JOIN op_customer t3 on t2.customer_id = t3.id
|
|
|
|
|
|
|
|
<if test="startDate != null">
|
|
|
|
<if test="startDate != null">
|
|
|
|
and date(t2.create_time) >= #{startDate}
|
|
|
|
and t2.create_time >= #{startDate}
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
<if test="endDate != null">
|
|
|
|
<if test="endDate != null">
|
|
|
|
and date(t2.create_time) <= #{endDate}
|
|
|
|
and t2.create_time <= #{endDate}
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
WHERE
|
|
|
|
|
|
|
|
t1.STATUS = 1
|
|
|
|
|
|
|
|
GROUP BY
|
|
|
|
GROUP BY
|
|
|
|
storeId
|
|
|
|
t2.store_id
|
|
|
|
ORDER BY
|
|
|
|
ORDER BY
|
|
|
|
newCusNum DESC, storeId DESC
|
|
|
|
newCusNum DESC, t2.store_id DESC
|
|
|
|
) a,
|
|
|
|
) a,
|
|
|
|
( SELECT @rank := 0 ) b
|
|
|
|
( SELECT @rank := 0 ) b
|
|
|
|
</select>
|
|
|
|
</select>
|
|
|
@ -392,18 +387,17 @@
|
|
|
|
@rank := @rank + 1 AS rankNo
|
|
|
|
@rank := @rank + 1 AS rankNo
|
|
|
|
FROM
|
|
|
|
FROM
|
|
|
|
( 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, `op_seller_customer_relation` t2
|
|
|
|
LEFT JOIN `op_seller_customer_relation` t2 ON t1.id = t2.user_id
|
|
|
|
where 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(t2.create_time) >= #{startDate}
|
|
|
|
and t2.create_time >= #{startDate}
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
<if test="endDate != null">
|
|
|
|
<if test="endDate != null">
|
|
|
|
and date(t2.create_time) <= #{endDate}
|
|
|
|
and t2.create_time <= #{endDate}
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
where t1.store_id = #{storeId}
|
|
|
|
and t1.store_id = #{storeId}
|
|
|
|
and t1.type = 4
|
|
|
|
and t1.type = 4
|
|
|
|
GROUP BY userId,t3.id ORDER BY newCusNum DESC, userId DESC ) a,
|
|
|
|
GROUP BY userId,t2.customer_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">
|
|
|
@ -413,7 +407,7 @@
|
|
|
|
SELECT
|
|
|
|
SELECT
|
|
|
|
t1.customer_id as customerId,t2.name as customerName,t2.external_userid as customerUserId,count( t1.store_id ) as count
|
|
|
|
t1.customer_id as customerId,t2.name as customerName,t2.external_userid as customerUserId,count( t1.store_id ) as count
|
|
|
|
FROM
|
|
|
|
FROM
|
|
|
|
op_seller_customer_relation t1 left join op_customer t2 on t1.customer_id = t2.id
|
|
|
|
op_seller_customer_relation t1 , op_customer t2 where t1.customer_id = t2.id
|
|
|
|
GROUP BY
|
|
|
|
GROUP BY
|
|
|
|
t1.customer_id
|
|
|
|
t1.customer_id
|
|
|
|
HAVING
|
|
|
|
HAVING
|
|
|
|