master
jiangyunjie 6 years ago
parent b06fcfe479
commit e1c5519ee7

@ -33,6 +33,7 @@ import com.kiisoo.ic.synchronous.entity.VipDataDTO;
import com.kiisoo.ic.system.enums.RoleEnum; import com.kiisoo.ic.system.enums.RoleEnum;
import com.kiisoo.ic.webappmy.vo.StafferInfoVO; import com.kiisoo.ic.webappmy.vo.StafferInfoVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -439,10 +440,28 @@ public class CustomerService {
Long shopId = stafferInfoVOS.get(0).getStoreId(); Long shopId = stafferInfoVOS.get(0).getStoreId();
if (roleCode.equals(RoleEnum.ROLE_CODE_DZ.getRoleCode())) { if (roleCode.equals(RoleEnum.ROLE_CODE_DZ.getRoleCode())) {
List<FriendDTO> thisList = opSellerCustomerRelationDOMapper.selectFriendListByShopId(shopId, sellerId, search, thisDate, thisDate, type); List<FriendDTO> thisList = opSellerCustomerRelationDOMapper.selectFriendListByShopId(shopId, sellerId, search, thisDate, thisDate, type);
results.put("this", thisList); thisList.forEach(friendDTO -> {
String inviteSellerName = opSellerCustomerRelationDOMapper.selectStaffName(friendDTO.getInviteSellerId());
if (StringUtils.isNotBlank(inviteSellerName)) {
friendDTO.setInviteSellerName(inviteSellerName);
}
});
List<FriendDTO> lastList = opSellerCustomerRelationDOMapper.selectFriendListByShopId(shopId, sellerId, search, lastDate, lastDate, type); List<FriendDTO> lastList = opSellerCustomerRelationDOMapper.selectFriendListByShopId(shopId, sellerId, search, lastDate, lastDate, type);
results.put("last", lastList); lastList.forEach(friendDTO -> {
String inviteSellerName = opSellerCustomerRelationDOMapper.selectStaffName(friendDTO.getInviteSellerId());
if (StringUtils.isNotBlank(inviteSellerName)) {
friendDTO.setInviteSellerName(inviteSellerName);
}
});
List<FriendDTO> earlyList = opSellerCustomerRelationDOMapper.selectFriendListByShopId(shopId, sellerId, search, null, earlyDate, type); List<FriendDTO> earlyList = opSellerCustomerRelationDOMapper.selectFriendListByShopId(shopId, sellerId, search, null, earlyDate, type);
earlyList.forEach(friendDTO -> {
String inviteSellerName = opSellerCustomerRelationDOMapper.selectStaffName(friendDTO.getInviteSellerId());
if (StringUtils.isNotBlank(inviteSellerName)) {
friendDTO.setInviteSellerName(inviteSellerName);
}
});
results.put("this", thisList);
results.put("last", lastList);
results.put("early", earlyList); results.put("early", earlyList);
} else { } else {
List<FriendDTO> thisList = opSellerCustomerRelationDOMapper.selectFriendListBySeller(userId, search, thisDate, thisDate, type); List<FriendDTO> thisList = opSellerCustomerRelationDOMapper.selectFriendListBySeller(userId, search, thisDate, thisDate, type);

@ -37,7 +37,7 @@ public class FriendDTO {
/** /**
* id * id
*/ */
private String inviteSellerId; private Long inviteSellerId;
/** /**
* *

@ -48,6 +48,13 @@ public interface OpSellerCustomerRelationDOMapper extends BaseMapper<OpSellerCus
@Param("endDate") Date endDate, @Param("endDate") Date endDate,
@Param("type") Integer type); @Param("type") Integer type);
/**
* id
* @param id
* @return
*/
String selectStaffName(@Param("id") Long id);
List<Map<String, Object>> selectAllCustomer(@Param("ids") List<Long> ids); List<Map<String, Object>> selectAllCustomer(@Param("ids") List<Long> ids);
List<Map<String, Object>> selectAllCustomer1(@Param("ids") List<Long> ids); List<Map<String, Object>> selectAllCustomer1(@Param("ids") List<Long> ids);

@ -135,19 +135,25 @@ public interface StorePromotionDataDOMapper {
@Param("endDate") Date endDate); @Param("endDate") Date endDate);
/** /**
* * ()
* @param userId
* @param storeId * @param storeId
* @param startDate * @param startDate
* @param endDate * @param endDate
* @param type Type 1.()2.
* @return * @return
*/ */
Integer selectWxSumCusNumByCondition(@Param("userId") Long userId, Integer selectWxSumCusNumByConditionShopManager(@Param("storeId") Long storeId,
@Param("storeId") Long storeId, @Param("startDate") Date startDate,
@Param("endDate") Date endDate);
/**
* ()
* @param userId
* @param startDate
* @param endDate
* @return
*/
Integer selectWxSumCusNumByConditionStaff(@Param("userId") Long userId,
@Param("startDate") Date startDate, @Param("startDate") Date startDate,
@Param("endDate") Date endDate, @Param("endDate") Date endDate);
@Param("type") Integer type);
/** /**
* id * id

@ -327,9 +327,9 @@ public class StorePromotionDataService {
switch (roleCode) { switch (roleCode) {
// 店长 // 店长
case Constants.WX_USER_ROLE_SHOP_MANAGER: case Constants.WX_USER_ROLE_SHOP_MANAGER:
cusNum = storePromotionDataDOMapper.selectWxSumCusNumByCondition(null, storeId, null, null, null); cusNum = storePromotionDataDOMapper.selectWxSumCusNumByConditionShopManager(storeId, null, null);
newCusNum = storePromotionDataDOMapper.selectWxSumCusNumByCondition(null, storeId, startDate, endDate, null); newCusNum = storePromotionDataDOMapper.selectWxSumCusNumByConditionShopManager(storeId, startDate, endDate);
newCusNumLast = storePromotionDataDOMapper.selectWxSumCusNumByCondition(null, storeId, lastStartDate, lastEndDate, null); newCusNumLast = storePromotionDataDOMapper.selectWxSumCusNumByConditionShopManager(storeId, lastStartDate, lastEndDate);
// 店铺排名 // 店铺排名
List<StorePromotionDataDO> storeRankNoList = storePromotionDataDOMapper.selectStoreRankNo(startDate, endDate); List<StorePromotionDataDO> storeRankNoList = storePromotionDataDOMapper.selectStoreRankNo(startDate, endDate);
if (CollectionUtils.isNotEmpty(storeRankNoList)) { if (CollectionUtils.isNotEmpty(storeRankNoList)) {
@ -372,9 +372,9 @@ public class StorePromotionDataService {
break; break;
// 导购 // 导购
case Constants.WX_USER_ROLE_STAFF: case Constants.WX_USER_ROLE_STAFF:
cusNum = storePromotionDataDOMapper.selectWxSumCusNumByCondition(userId, null, null, null, null); cusNum = storePromotionDataDOMapper.selectWxSumCusNumByConditionStaff(userId, null, null);
newCusNum = storePromotionDataDOMapper.selectWxSumCusNumByCondition(userId, null, startDate, endDate, null); newCusNum = storePromotionDataDOMapper.selectWxSumCusNumByConditionStaff(userId, startDate, endDate);
newCusNumLast = storePromotionDataDOMapper.selectWxSumCusNumByCondition(userId, null, lastStartDate, lastEndDate, null); newCusNumLast = storePromotionDataDOMapper.selectWxSumCusNumByConditionStaff(userId, lastStartDate, lastEndDate);
// 店铺排名 // 店铺排名
List<StorePromotionDataDO> staffRankNoList = storePromotionDataDOMapper.selectStaffRankNo(startDate, endDate, storeId); List<StorePromotionDataDO> staffRankNoList = storePromotionDataDOMapper.selectStaffRankNo(startDate, endDate, storeId);
if (CollectionUtils.isNotEmpty(staffRankNoList)) { if (CollectionUtils.isNotEmpty(staffRankNoList)) {

@ -8,7 +8,7 @@
t2.id AS customerId, t2.id AS customerId,
t2.phone AS mobile, t2.phone AS mobile,
t5.NAME AS inviteSellerName, t5.NAME AS inviteSellerName,
t4.user_id AS inviteSellerId, t4.id AS inviteSellerId,
t1.create_time AS addTime, t1.create_time AS addTime,
t2.avatar_url as avatar, t2.avatar_url as avatar,
t3.level as vipFlag t3.level as vipFlag
@ -19,8 +19,8 @@
privilage_user t5 privilage_user t5
WHERE WHERE
t1.customer_id = t2.id t1.customer_id = t2.id
AND t1.user_id = t5.id AND t1.user_id = t4.id
AND t1.user_id = t4.user_id AND t4.user_id = t5.id
AND t1.store_id = t4.store_id AND t1.store_id = t4.store_id
<if test="type == 1"> <if test="type == 1">
and t3.id is not null and t3.id is not null
@ -50,18 +50,15 @@
t2.NAME AS customerName, t2.NAME AS customerName,
t2.id AS customerId, t2.id AS customerId,
t2.phone AS mobile, t2.phone AS mobile,
t4.user_id AS inviteSellerId, t1.user_id AS inviteSellerId,
t1.create_time AS addTime, t1.create_time AS addTime,
t2.avatar_url as avatar, t2.avatar_url as avatar,
t3.level as vipFlag t3.level as vipFlag
FROM FROM
op_seller_customer_relation t1, op_seller_customer_relation t1,
op_customer t2 left join op_vip t3 on t2.member_id = t3.id and t3.status = 1, op_customer t2 left join op_vip t3 on t2.member_id = t3.id and t3.status = 1
poi_store_staff t4
WHERE WHERE
t1.customer_id = t2.id t1.customer_id = t2.id
AND t1.user_id = t4.user_id
AND t1.store_id = t4.store_id
<if test="type == 1"> <if test="type == 1">
and t3.id is not null and t3.id is not null
</if> </if>
@ -72,7 +69,7 @@
and t1.store_id = #{shopId} and t1.store_id = #{shopId}
</if> </if>
<if test="sellerId != null and sellerId != 0"> <if test="sellerId != null and sellerId != 0">
and t4.user_id = #{sellerId} and t1.user_id = #{sellerId}
</if> </if>
<if test="search != null and search !=''"> <if test="search != null and search !=''">
and and
@ -87,6 +84,10 @@
</if> </if>
order by t1.create_time desc order by t1.create_time desc
</select> </select>
<!--根据导购id查询导购名-->
<select id="selectStaffName" resultType="java.lang.String">
SELECT t1.NAME from privilage_user t1, poi_store_staff t2 where t1.id = t2.user_id AND t2.id = #{id} AND t2.type = 4
</select>
<select id="selectAllCustomer" resultType="java.util.Map"> <select id="selectAllCustomer" resultType="java.util.Map">
select user_id,count(0) as count from op_seller_customer_relation select user_id,count(0) as count from op_seller_customer_relation
where 1 = 1 where 1 = 1

@ -289,30 +289,31 @@
group by store_id group by store_id
</select> </select>
<select id="selectWxSumCusNumByCondition" resultType="java.lang.Integer"> <select id="selectWxSumCusNumByConditionShopManager" resultType="java.lang.Integer">
SELECT count(customer_id) from op_seller_customer_relation SELECT count(customer_id) from op_seller_customer_relation
where 1 = 1 WHERE store_id = #{storeId}
<if test="userId != null">
AND user_id = #{userId}
</if>
<if test="storeId != null">
AND store_id = #{storeId}
</if>
<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_FORMAT(create_time,'%Y-%m-%d') &gt;= DATE_FORMAT(#{startDate},'%Y-%m-%d')
</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_FORMAT(create_time,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate},'%Y-%m-%d')
</if> </if>
<if test="type != null"> group by store_id
AND `type` = #{type} </select>
</if>
<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
and t2.type = 4
<if test="userId != null"> <if test="userId != null">
group by user_id AND t2.user_id = #{userId}
</if> </if>
<if test="storeId != null"> <if test="startDate != null">
group by store_id and DATE_FORMAT(t1.create_time,'%Y-%m-%d') &gt;= DATE_FORMAT(#{startDate},'%Y-%m-%d')
</if>
<if test="endDate != null">
and DATE_FORMAT(t1.create_time,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate},'%Y-%m-%d')
</if> </if>
group by t1.user_id
</select> </select>
<select id="selectStoreIdByUserId" resultType="java.lang.Long"> <select id="selectStoreIdByUserId" resultType="java.lang.Long">
@ -339,7 +340,7 @@
<select id="selectWxValidStaffNameList" resultType="com.kiisoo.ic.store.entity.StaffDO"> <select id="selectWxValidStaffNameList" resultType="com.kiisoo.ic.store.entity.StaffDO">
SELECT SELECT
DISTINCT DISTINCT
t1.user_id as id, t1.id as id,
t2.NAME AS staffName t2.NAME AS staffName
FROM FROM
poi_store_staff t1, poi_store_staff t1,
@ -388,7 +389,7 @@
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
LEFT JOIN `op_seller_customer_relation` t2 ON t1.user_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(t2.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>

Loading…
Cancel
Save