master
jiangyunjie 6 years ago
parent ef0d33e14b
commit f5330be210

@ -187,8 +187,10 @@ public interface StorePromotionDataDOMapper {
*
* @param startDate
* @param endDate
* @param storeId
* @return
*/
List<StorePromotionDataDO> selectStaffRankNo(@Param("startDate") Date startDate,
@Param("endDate") Date endDate);
@Param("endDate") Date endDate,
@Param("storeId") Long storeId);
}

@ -315,13 +315,13 @@ public class StorePromotionDataService {
Integer newCusNumLast = null;
Integer rankNo = null;
Integer differFromChampion = null;
switch (roleCode) {
// 店长
case Constants.WX_USER_ROLE_SHOP_MANAGER:
Long storeId = storePromotionDataDOMapper.selectStoreIdByUserId(userId);
if (storeId == null) {
break;
return storePromotionDataDO;
}
switch (roleCode) {
// 店长
case Constants.WX_USER_ROLE_SHOP_MANAGER:
cusNum = storePromotionDataDOMapper.selectWxSumCusNumByCondition(null, storeId, null, null, Constants.STORE_SELLER_CUS_RELATION_TYPE_VALID);
newCusNum = storePromotionDataDOMapper.selectWxSumCusNumByCondition(null, storeId, startDate, endDate, Constants.STORE_SELLER_CUS_RELATION_TYPE_VALID);
newCusNumLast = storePromotionDataDOMapper.selectWxSumCusNumByCondition(null, storeId, lastStartDate, lastEndDate, Constants.STORE_SELLER_CUS_RELATION_TYPE_VALID);
@ -367,7 +367,7 @@ public class StorePromotionDataService {
newCusNum = storePromotionDataDOMapper.selectWxSumCusNumByCondition(userId, null, startDate, endDate, null);
newCusNumLast = storePromotionDataDOMapper.selectWxSumCusNumByCondition(userId, null, lastStartDate, lastEndDate, null);
// 店铺排名
List<StorePromotionDataDO> staffRankNoList = storePromotionDataDOMapper.selectStaffRankNo(startDate, endDate);
List<StorePromotionDataDO> staffRankNoList = storePromotionDataDOMapper.selectStaffRankNo(startDate, endDate, storeId);
if (CollectionUtils.isNotEmpty(staffRankNoList)) {
for (int i = 0; i < staffRankNoList.size(); i++) {
if (staffRankNoList.get(i).getUserId().equals(userId.toString())) {

@ -49,6 +49,7 @@
<if test="endDate != null">
and DATE_FORMAT(t1.create_time,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate},'%Y-%m-%d')
</if>
order by t1.create_time desc
</select>
<select id="selectAllCustomer" resultType="java.util.Map">
select user_id,count(0) as count from op_seller_customer_relation

@ -316,7 +316,7 @@
</select>
<select id="selectStoreIdByUserId" resultType="java.lang.Long">
SELECT store_id FROM poi_store_staff WHERE user_id = #{userId} and type = 1 and status = 1 and deleted = 0
SELECT store_id FROM poi_store_staff WHERE user_id = #{userId} and status = 1 and deleted = 0
</select>
<select id="selectWxStaffDOList" resultType="com.kiisoo.ic.store.entity.StaffDO">
@ -358,15 +358,26 @@
a.newCusNum,
@rank := @rank + 1 AS rankNo
FROM
( SELECT count( customer_id ) AS newCusNum, store_id AS storeId FROM
`op_seller_customer_relation`
(
SELECT
count( t2.customer_id ) AS newCusNum,
t1.id AS storeId
FROM
poi_store t1
LEFT JOIN `op_seller_customer_relation` t2 ON t1.id = t2.store_id
<if test="startDate != null">
WHERE DATE_FORMAT(create_time,'%Y-%m-%d') &gt;= DATE_FORMAT(#{startDate},'%Y-%m-%d')
and DATE_FORMAT(t2.create_time,'%Y-%m-%d') &gt;= DATE_FORMAT(#{startDate},'%Y-%m-%d')
</if>
<if test="endDate != null">
and DATE_FORMAT(create_time,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate},'%Y-%m-%d')
and DATE_FORMAT(t2.create_time,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate},'%Y-%m-%d')
</if>
GROUP BY store_id ORDER BY newCusNum DESC ) a,
WHERE
t1.STATUS = 1
GROUP BY
storeId
ORDER BY
newCusNum DESC
) a,
( SELECT @rank := 0 ) b
</select>
<select id="selectStaffRankNo" resultType="com.kiisoo.ic.store.entity.StorePromotionDataDO">
@ -375,15 +386,18 @@
a.newCusNum,
@rank := @rank + 1 AS rankNo
FROM
( SELECT count( customer_id ) AS newCusNum, user_id AS userId FROM
`op_seller_customer_relation`
( 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.user_id = t2.user_id
<if test="startDate != null">
WHERE DATE_FORMAT(create_time,'%Y-%m-%d') &gt;= DATE_FORMAT(#{startDate},'%Y-%m-%d')
and DATE_FORMAT(t2.create_time,'%Y-%m-%d') &gt;= DATE_FORMAT(#{startDate},'%Y-%m-%d')
</if>
<if test="endDate != null">
and DATE_FORMAT(create_time,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate},'%Y-%m-%d')
and DATE_FORMAT(t2.create_time,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate},'%Y-%m-%d')
</if>
GROUP BY user_id ORDER BY newCusNum DESC ) a,
where t1.store_id = #{storeId}
and t1.type = 4
GROUP BY userId ORDER BY newCusNum DESC ) a,
( SELECT @rank := 0 ) b
</select>

Loading…
Cancel
Save