优化手机端首页和好友列表接口。

dev
kevin jiang 5 years ago
parent fda8fd518c
commit 36dcef8b84

@ -1,6 +1,7 @@
package com.kiisoo.ic.customer;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@ -665,102 +666,46 @@ public class CustomerService {
return results;
}
Long shopId = stafferInfoVOS.get(0).getStoreId();
List<FriendDTO> thisList;
PageHelper.startPage(pageNum, pageSize);
IPage<FriendDTO> thisList;
// PageHelper.startPage(pageNum, pageSize);
com.baomidou.mybatisplus.extension.plugins.pagination.Page<FriendDTO> page = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(pageNum,pageSize);
if (roleCode.equals(RoleEnum.ROLE_CODE_DZ.getRoleCode())) {
// 0、新增好友 1、累计好友
if (flag == 0) {
thisList = opSellerCustomerRelationDOMapper.selectFriendListByShopId(shopId, sellerId, search, startDate, endDate, type);
thisList = opSellerCustomerRelationDOMapper.selectFriendListByShopId(page,shopId, sellerId, search, startDate, endDate, type);
} else {
thisList = opSellerCustomerRelationDOMapper.selectFriendListByShopIdAndDate(shopId, sellerId, search, startDate, endDate, type);
thisList = opSellerCustomerRelationDOMapper.selectFriendListByShopIdAndDate(page, shopId, sellerId, search, startDate, endDate, type);
}
if (CollectionUtils.isNotEmpty(thisList)) {
for (int i = 0; i < thisList.size(); i++) {
if (CollectionUtils.isNotEmpty(thisList.getRecords())) {
for (int i = 0; i < thisList.getRecords().size(); i++) {
// 设置导购名称
if (!thisList.get(i).getInviteSellerId().equals(0L)) {
if (!thisList.getRecords().get(i).getInviteSellerId().equals(0L)) {
Map<String, Object> map = new HashMap<>();
map.put("id", thisList.get(i).getInviteSellerId());
String userName = poiStoreStaffDOMapper.selectUserNameById(thisList.get(i).getInviteSellerId());
map.put("id", thisList.getRecords().get(i).getInviteSellerId());
String userName = poiStoreStaffDOMapper.selectUserNameById(thisList.getRecords().get(i).getInviteSellerId());
if (StringUtils.isNotEmpty(userName)) {
thisList.get(i).setInviteSellerName(userName);
thisList.getRecords().get(i).setInviteSellerName(userName);
} else {
thisList.get(i).setInviteSellerName("");
thisList.getRecords().get(i).setInviteSellerName("");
}
} else {
thisList.get(i).setInviteSellerName("");
thisList.getRecords().get(i).setInviteSellerName("");
}
}
}
} else {
// 0、新增好友 1、累计好友
if (flag == 0) {
thisList = opSellerCustomerRelationDOMapper.selectFriendListBySeller(userId, search, startDate, endDate, type);
thisList = opSellerCustomerRelationDOMapper.selectFriendListBySeller(page, userId, search, startDate, endDate, type);
} else {
thisList = opSellerCustomerRelationDOMapper.selectFriendListBySellerAndDate(userId, search, startDate, endDate, type);
thisList = opSellerCustomerRelationDOMapper.selectFriendListBySellerAndDate(page, userId, search, startDate, endDate, type);
}
}
results.put("this", new PageInfo<>(thisList));
return results;
}
/**
* @param userId
* @param sellerId
* @param search
* @param roleCode
*/
public Map<String, Object> listCustomer(Long userId, Long sellerId, String search, String roleCode, Integer type, Date startDate, Date endDate) throws Exception {
Map<String, Object> results = new HashMap<>();
Date thisDate = new Date();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, -24);
Date lastDate = dateFormat.parse(dateFormat.format(calendar.getTime()));
calendar.set(Calendar.HOUR_OF_DAY, -24);
Date earlyDate = dateFormat.parse(dateFormat.format(calendar.getTime()));
List<StafferInfoVO> stafferInfoVOS = poiStoreStaffDOMapper.selectInfoById(userId);
if (CollectionUtils.isEmpty(stafferInfoVOS)) {
results.put("this", null);
results.put("last", null);
results.put("early", null);
return results;
}
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> lastList = opSellerCustomerRelationDOMapper.selectFriendListByShopId(shopId, sellerId, search, lastDate, lastDate, type);
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);
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);
} else {
List<FriendDTO> thisList = opSellerCustomerRelationDOMapper.selectFriendListBySeller(userId, search, startDate, endDate, type);
results.put("this", thisList);
List<FriendDTO> lastList = opSellerCustomerRelationDOMapper.selectFriendListBySeller(userId, search, lastDate, lastDate, type);
results.put("last", lastList);
List<FriendDTO> earlyList = opSellerCustomerRelationDOMapper.selectFriendListBySeller(userId, search, null, earlyDate, type);
results.put("early", earlyList);
}
results.put("this", new PageInfo<>(thisList.getRecords()));
return results;
}

@ -90,12 +90,7 @@ public class CustomerController extends BaseController {
Date endDate,
String version, @RequestParam("flag") int flag,int pageNum, int pageSize){
try {
Map<String, Object> stringObjectMap;
if(StringUtils.isNotBlank(version)){
stringObjectMap = customerService.listCustomerNew(userId, sellerId, search, roleCode, type, startDate, endDate, flag, pageNum, pageSize);
}else{
stringObjectMap = customerService.listCustomer(userId, sellerId, search, roleCode, type, startDate, endDate);
}
Map<String, Object> stringObjectMap = customerService.listCustomerNew(userId, sellerId, search, roleCode, type, startDate, endDate, flag, pageNum, pageSize);
return data(stringObjectMap);
} catch (Exception e) {
log.error("查询好友列表:",e);

@ -1,6 +1,8 @@
package com.kiisoo.ic.customer.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kiisoo.ic.customer.bean.FriendDTO;
import com.kiisoo.ic.customer.entity.OpSellerCustomerRelation;
import org.apache.ibatis.annotations.Param;
@ -25,7 +27,7 @@ public interface OpSellerCustomerRelationDOMapper extends BaseMapper<OpSellerCus
* @param type
* @return
*/
List<FriendDTO> selectFriendListBySeller(@Param("userId") Long userId,
IPage<FriendDTO> selectFriendListBySeller(Page<FriendDTO> page,@Param("userId") Long userId,
@Param("search") String search,
@Param("startDate") Date startDate,
@Param("endDate") Date endDate,
@ -41,12 +43,12 @@ public interface OpSellerCustomerRelationDOMapper extends BaseMapper<OpSellerCus
* @param type
* @return
*/
List<FriendDTO> selectFriendListByShopId(@Param("shopId") Long shopId,
@Param("sellerId") Long sellerId,
@Param("search") String search,
@Param("startDate") Date startDate,
@Param("endDate") Date endDate,
@Param("type") Integer type);
IPage<FriendDTO> selectFriendListByShopId(Page<FriendDTO> page, @Param("shopId") Long shopId,
@Param("sellerId") Long sellerId,
@Param("search") String search,
@Param("startDate") Date startDate,
@Param("endDate") Date endDate,
@Param("type") Integer type);
/**
* id
@ -73,7 +75,7 @@ public interface OpSellerCustomerRelationDOMapper extends BaseMapper<OpSellerCus
* @author dexiang.jiang
* @date 2020/05/10 21:50
*/
List<FriendDTO> selectFriendListByShopIdAndDate(@Param("shopId") Long shopId,
IPage<FriendDTO> selectFriendListByShopIdAndDate(Page<FriendDTO> page, @Param("shopId") Long shopId,
@Param("sellerId") Long sellerId,
@Param("search") String search,
@Param("startDate") Date startDate,
@ -91,7 +93,7 @@ public interface OpSellerCustomerRelationDOMapper extends BaseMapper<OpSellerCus
* @author dexiang.jiang
* @date 2020/05/10 22:01
*/
List<FriendDTO> selectFriendListBySellerAndDate(@Param("userId") Long userId,
IPage<FriendDTO> selectFriendListBySellerAndDate(Page<FriendDTO> page,@Param("userId") Long userId,
@Param("search") String search,
@Param("startDate") Date startDate,
@Param("endDate") Date endDate,
@ -99,7 +101,6 @@ public interface OpSellerCustomerRelationDOMapper extends BaseMapper<OpSellerCus
Long selectSellerCustomerRelation(@Param("customerId") Long customerId, @Param("userId") Long userId, @Param("storeId") Long storeId);
Integer countStoreCustomers(@Param("customerId") Long customerId, @Param("userId") Long userId, @Param("storeId") Long storeId);
List<Map<String, Object>> selectCustomersByCpUserId();

@ -2,10 +2,12 @@ package com.kiisoo.ic.store.bean;
import com.kiisoo.ic.store.entity.PoiStoreStaff;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
*
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class PoiStoreStaffDTO extends PoiStoreStaff {
/**名称*/

Loading…
Cancel
Save