|
|
|
@ -2,6 +2,9 @@ package com.kiisoo.ic.customer;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.github.pagehelper.Page;
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
@ -9,6 +12,10 @@ import com.google.gson.Gson;
|
|
|
|
|
import com.kiisoo.ic.activity.bean.ActivityInstanceVO;
|
|
|
|
|
import com.kiisoo.ic.activity.entity.*;
|
|
|
|
|
import com.kiisoo.ic.activity.service.*;
|
|
|
|
|
import com.kiisoo.ic.common.utils.RedisUtil;
|
|
|
|
|
import com.kiisoo.ic.activity.bean.ActivityInstanceVO;
|
|
|
|
|
import com.kiisoo.ic.activity.entity.*;
|
|
|
|
|
import com.kiisoo.ic.activity.service.*;
|
|
|
|
|
import com.kiisoo.ic.constants.Constants;
|
|
|
|
|
import com.kiisoo.ic.customer.bean.CustomerDTO;
|
|
|
|
|
import com.kiisoo.ic.customer.bean.CustomerModifyDTO;
|
|
|
|
@ -107,8 +114,6 @@ public class CustomerService {
|
|
|
|
|
private IPmnPromotionSrcService pmnPromotionSrcService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IPmnActivityInstanceService pmnActivityInstanceService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IPmnActivityInstanceConfigService pmnActivityInstanceConfigService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private StoreEmployeeService storeEmployeeService;
|
|
|
|
@ -116,6 +121,9 @@ public class CustomerService {
|
|
|
|
|
private IPmnActivityStoreRelationService pmnActivityStoreRelationService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IPmnPromotionFriendsSrcService pmnPromotionFriendsSrcService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private RedisUtil redisUtil;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* token
|
|
|
|
|
*/
|
|
|
|
@ -294,6 +302,10 @@ public class CustomerService {
|
|
|
|
|
insertCustomer.setExternalUserid(turnBackDTOS.getWxData().getUserId());
|
|
|
|
|
insertCustomer.setCpUserId(turnBackDTOS.getUserId());
|
|
|
|
|
insertCustomer.setPhone(turnBackDTOS.getPhone());
|
|
|
|
|
if (turnBackDTOS.getVipData() != null && !turnBackDTOS.getVipData().getPhone().equals("")) {
|
|
|
|
|
//有vip数据就不需要重新请求bsd的vip接口
|
|
|
|
|
insertCustomer.setPhone(turnBackDTOS.getVipData().getPhone());
|
|
|
|
|
}
|
|
|
|
|
if (shop != null && StringUtils.isNotBlank(shop.getName())) {
|
|
|
|
|
insertCustomer.setShopName(shop.getName());
|
|
|
|
|
}
|
|
|
|
@ -426,8 +438,12 @@ public class CustomerService {
|
|
|
|
|
insertRelation.setCreateTime(joinTime);
|
|
|
|
|
insertRelation.setUpdateTime(new Date());
|
|
|
|
|
insertRelation.setCustomerId(opCustomer.getId());
|
|
|
|
|
PoiStore poiStore = poiStoreDOMapper.selectById(shopId);
|
|
|
|
|
insertRelation.setStoreId(shopId);
|
|
|
|
|
insertRelation.setStoreCode(poiStore.getCode());
|
|
|
|
|
PoiStoreStaff staff = poiStoreStaffDOMapper.selectById(sellerId);
|
|
|
|
|
insertRelation.setUserId(sellerId);
|
|
|
|
|
insertRelation.setStaffCode(staff.getStaffCode());
|
|
|
|
|
insertRelation.setCreateBy(Constants.SYS_OPERATION);
|
|
|
|
|
insertRelation.setUpdateBy(Constants.SYS_OPERATION);
|
|
|
|
|
|
|
|
|
@ -445,14 +461,14 @@ public class CustomerService {
|
|
|
|
|
opSellerCustomerRelationDOMapper.insert(insertRelation);
|
|
|
|
|
} else {
|
|
|
|
|
//可能是同步过来的数据,此时已经存在的话,用有导购的代替
|
|
|
|
|
opSellerCustomerRelation.setCreateTime(joinTime);
|
|
|
|
|
opSellerCustomerRelation.setUpdateTime(new Date());
|
|
|
|
|
opSellerCustomerRelation.setCustomerId(opCustomer.getId());
|
|
|
|
|
opSellerCustomerRelation.setStoreId(shopId);
|
|
|
|
|
opSellerCustomerRelation.setUserId(sellerId);
|
|
|
|
|
opSellerCustomerRelation.setCreateBy(Constants.SYS_OPERATION);
|
|
|
|
|
opSellerCustomerRelation.setUpdateBy(Constants.SYS_OPERATION);
|
|
|
|
|
opSellerCustomerRelationDOMapper.updateById(opSellerCustomerRelation);
|
|
|
|
|
// opSellerCustomerRelation.setCreateTime(joinTime);
|
|
|
|
|
// opSellerCustomerRelation.setUpdateTime(new Date());
|
|
|
|
|
// opSellerCustomerRelation.setCustomerId(opCustomer.getId());
|
|
|
|
|
// opSellerCustomerRelation.setStoreId(shopId);
|
|
|
|
|
// opSellerCustomerRelation.setUserId(sellerId);
|
|
|
|
|
// opSellerCustomerRelation.setCreateBy(Constants.SYS_OPERATION);
|
|
|
|
|
// opSellerCustomerRelation.setUpdateBy(Constants.SYS_OPERATION);
|
|
|
|
|
// opSellerCustomerRelationDOMapper.updateById(opSellerCustomerRelation);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -498,6 +514,9 @@ public class CustomerService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
insertRelation.setType(3);
|
|
|
|
|
}else{
|
|
|
|
|
PoiStore poiStore = poiStoreDOMapper.selectById(shopId);
|
|
|
|
|
insertRelation.setStoreCode(poiStore.getCode());
|
|
|
|
|
}
|
|
|
|
|
opSellerCustomerRelationDOMapper.insert(insertRelation);
|
|
|
|
|
}
|
|
|
|
@ -619,102 +638,50 @@ 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(startDate.getTime() == endDate.getTime()){
|
|
|
|
|
endDate = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|