好友列表接口修改和优化加载速度。

master
kevin jiang 6 years ago
parent a6c6865584
commit 91d1783481

@ -436,12 +436,21 @@ public class CustomerService {
}
/**
* @param userId
* @param sellerId
* @param search
* @param roleCode
*
* @param userId ID
* @param sellerId ID
* @param search
* @param roleCode
* @param type
* @param startDate
* @param endDate
* @param flag 0 1
* @return
* @throws Exception
* @author dexiang.jiang
* @date 2020/05/10 21:50
*/
public Map<String, Object> listCustomerNew(Long userId, Long sellerId, String search, String roleCode, Integer type, Date startDate, Date endDate) throws Exception {
public Map<String, Object> listCustomerNew(Long userId, Long sellerId, String search, String roleCode, Integer type, Date startDate, Date endDate, int flag) throws Exception {
Map<String, Object> results = new HashMap<>();
// Date thisDate = new Date();
// DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
@ -459,13 +468,19 @@ public class CustomerService {
}
Long shopId = stafferInfoVOS.get(0).getStoreId();
if (roleCode.equals(RoleEnum.ROLE_CODE_DZ.getRoleCode())) {
List<FriendDTO> thisList = opSellerCustomerRelationDOMapper.selectFriendListByShopId(shopId, sellerId, search, startDate, endDate, type);
thisList.forEach(friendDTO -> {
String inviteSellerName = opSellerCustomerRelationDOMapper.selectStaffName(friendDTO.getInviteSellerId());
if (StringUtils.isNotBlank(inviteSellerName)) {
friendDTO.setInviteSellerName(inviteSellerName);
List<FriendDTO> thisList;
// 0、新增好友 1、累计好友
if(flag == 0){
thisList = opSellerCustomerRelationDOMapper.selectFriendListByShopId(shopId, sellerId, search, startDate, endDate, type);
}else{
thisList = opSellerCustomerRelationDOMapper.selectFriendListByShopIdAndDate(shopId, sellerId, search, startDate, endDate, type);
}
});
// 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);
// lastList.forEach(friendDTO -> {
// String inviteSellerName = opSellerCustomerRelationDOMapper.selectStaffName(friendDTO.getInviteSellerId());
@ -484,7 +499,13 @@ public class CustomerService {
// results.put("last", lastList);
// results.put("early", earlyList);
} else {
List<FriendDTO> thisList = opSellerCustomerRelationDOMapper.selectFriendListBySeller(userId, search, startDate, endDate, type);
List<FriendDTO> thisList;
// 0、新增好友 1、累计好友
if(flag == 0){
thisList = opSellerCustomerRelationDOMapper.selectFriendListBySeller(userId, search, startDate, endDate, type);
}else{
thisList = opSellerCustomerRelationDOMapper.selectFriendListBySellerAndDate(userId, search, startDate, endDate, type);
}
results.put("this", thisList);
// List<FriendDTO> lastList = opSellerCustomerRelationDOMapper.selectFriendListBySeller(userId, search, lastDate, lastDate, type);
// results.put("last", lastList);

@ -88,11 +88,11 @@ public class CustomerController extends BaseController {
@RequestParam("type") Integer type,
Date startDate,
Date endDate,
String version){
String version, @RequestParam("flag") int flag){
try {
Map<String, Object> stringObjectMap;
if(StringUtils.isNotBlank(version)){
stringObjectMap = customerService.listCustomerNew(userId, sellerId, search, roleCode, type, startDate, endDate);
stringObjectMap = customerService.listCustomerNew(userId, sellerId, search, roleCode, type, startDate, endDate, flag);
}else{
stringObjectMap = customerService.listCustomer(userId, sellerId, search, roleCode, type, startDate, endDate);
}

@ -60,4 +60,40 @@ public interface OpSellerCustomerRelationDOMapper extends BaseMapper<OpSellerCus
List<Map<String, Object>> selectAllCustomerShop(@Param("ids") List<Long> ids);
List<Map<String, Object>> selectAllCustomerShop1(@Param("ids") List<Long> ids);
/**
*
* @param shopId ID
* @param sellerId ID
* @param search
* @param startDate
* @param endDate
* @param type
* @return
* @author dexiang.jiang
* @date 2020/05/10 21:50
*/
List<FriendDTO> selectFriendListByShopIdAndDate(@Param("shopId") Long shopId,
@Param("sellerId") Long sellerId,
@Param("search") String search,
@Param("startDate") Date startDate,
@Param("endDate") Date endDate,
@Param("type") Integer type);
/**
*
* @param userId
* @param search
* @param startDate
* @param endDate
* @param type
* @return
* @author dexiang.jiang
* @date 2020/05/10 22:01
*/
List<FriendDTO> selectFriendListBySellerAndDate(@Param("userId") Long userId,
@Param("search") String search,
@Param("startDate") Date startDate,
@Param("endDate") Date endDate,
@Param("type") Integer type);
}

@ -33,8 +33,8 @@
</if>
<if test="search != null and search !=''">
and
CONCAT(IFNULL(t2.name,''),IFNULL(t2.phone,''))
LIKE CONCAT('%',#{search},'%')
(t2.name LIKE CONCAT('%',#{search},'%') OR t3.phone LIKE
CONCAT('%',#{search},'%'))
</if>
<if test="startDate != null">
and DATE_FORMAT(t2.create_time,'%Y-%m-%d') &gt;= DATE_FORMAT(#{startDate},'%Y-%m-%d')
@ -45,20 +45,25 @@
GROUP BY t4.id order by t2.create_time desc
</select>
<select id="selectFriendListByShopId" resultType="com.kiisoo.ic.customer.bean.FriendDTO">
SELECT
DISTINCT
SELECT DISTINCT
t2. NAME AS customerName ,
t2.id AS customerId ,
IFNULL(t3.phone , '') AS mobile ,
t1.user_id AS inviteSellerId ,
t2.create_time AS addTime ,
t2.avatar_url as avatar,
t3.level as vipFlag
t2.avatar_url AS avatar ,
t3. LEVEL AS vipFlag,
t5.`name` as sellerName
FROM
op_seller_customer_relation t1,
op_customer t2 left join op_vip t3 on t2.member_id = t3.id and t3.status = 1
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 privilage_user t5 ON t4.user_id = t5.id
WHERE
t1.customer_id = t2.id
1 = 1
<if test="type == 1">
and t3.id is not null
</if>
@ -73,8 +78,8 @@
</if>
<if test="search != null and search !=''">
and
CONCAT(IFNULL(t2.name,''),IFNULL(t2.phone,''))
LIKE CONCAT('%',#{search},'%')
(t2.name LIKE CONCAT('%',#{search},'%') OR t3.phone LIKE
CONCAT('%',#{search},'%'))
</if>
<if test="startDate != null">
and DATE_FORMAT(t2.create_time,'%Y-%m-%d') &gt;= DATE_FORMAT(#{startDate},'%Y-%m-%d')
@ -82,6 +87,7 @@
<if test="endDate != null">
and DATE_FORMAT(t2.create_time,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate},'%Y-%m-%d')
</if>
group by t2.id
order by t2.create_time desc
</select>
<!--根据导购id查询导购名-->
@ -126,4 +132,82 @@
</foreach>
group by user_id
</select>
<select id="selectFriendListByShopIdAndDate" resultType="com.kiisoo.ic.customer.bean.FriendDTO">
SELECT DISTINCT
t2. NAME AS customerName ,
t2.id AS customerId ,
IFNULL(t3.phone , '') AS mobile ,
t1.user_id AS inviteSellerId ,
t2.create_time AS addTime ,
t2.avatar_url AS avatar ,
t3. LEVEL AS vipFlag,
t5.`name` as sellerName
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 privilage_user t5 ON t4.user_id = t5.id
WHERE
1 = 1
<if test="type == 1">
and t3.id is not null
</if>
<if test="type == 2">
and t3.id is null
</if>
<if test="shopId != null">
and t1.store_id = #{shopId}
</if>
<if test="sellerId != null and sellerId != 0">
and t1.user_id = #{sellerId}
</if>
<if test="search != null and search !=''">
and
(t2.name LIKE CONCAT('%',#{search},'%') OR t3.phone LIKE
CONCAT('%',#{search},'%'))
</if>
group by t2.id
order by t2.create_time desc
</select>
<select id="selectFriendListBySellerAndDate" resultType="com.kiisoo.ic.customer.bean.FriendDTO">
SELECT
DISTINCT
t2.NAME AS customerName,
t2.id AS customerId,
IFNULL(t3.phone,'') AS mobile,
t5.NAME AS inviteSellerName,
t4.id AS inviteSellerId,
t2.create_time AS addTime,
t2.avatar_url as avatar,
t3.level as vipFlag
FROM
op_seller_customer_relation t1,
op_customer t2 left join op_vip t3 on t2.member_id = t3.id and t3.status = 1,
poi_store_staff t4,
privilage_user t5
WHERE
t1.customer_id = t2.id
AND t1.user_id = t4.id
AND t4.user_id = t5.id
AND t1.store_id = t4.store_id
<if test="type == 1">
and t3.id is not null
</if>
<if test="type == 2">
and t3.id is null
</if>
<if test="userId != null">
and t5.id = #{userId}
</if>
<if test="search != null and search !=''">
and
(t2.name LIKE CONCAT('%',#{search},'%') OR t3.phone LIKE
CONCAT('%',#{search},'%'))
</if>
GROUP BY t4.id order by t2.create_time desc
</select>
</mapper>

Loading…
Cancel
Save