|
|
@ -468,114 +468,6 @@ public class EmployeeService {
|
|
|
|
return inputStream;
|
|
|
|
return inputStream;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void syncCustoemr() throws Exception {
|
|
|
|
|
|
|
|
//初始化线程
|
|
|
|
|
|
|
|
ExecutorService newFixedThreadPool = Executors.newFixedThreadPool(8);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查询所有店长
|
|
|
|
|
|
|
|
List<PrivilageCpUserStoreDO> privilageCpUserStoreDOS = privilageCpUserStoreDOMapper.selectList(null);
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(privilageCpUserStoreDOS)){
|
|
|
|
|
|
|
|
//分组
|
|
|
|
|
|
|
|
final List<List<PrivilageCpUserStoreDO>> afterPageList = com.kiisoo.ic.utils.CollectionUtils.portListByQuantity(privilageCpUserStoreDOS, 100);
|
|
|
|
|
|
|
|
//定义线程池长度
|
|
|
|
|
|
|
|
int threadPoolSize = afterPageList.size();
|
|
|
|
|
|
|
|
//定义countDownLatch
|
|
|
|
|
|
|
|
final CountDownLatch countDownLatch = new CountDownLatch(threadPoolSize);
|
|
|
|
|
|
|
|
for (int i = 0; i < afterPageList.size(); i++) {
|
|
|
|
|
|
|
|
List<PrivilageCpUserStoreDO> cpUserStoreDOS = afterPageList.get(i);
|
|
|
|
|
|
|
|
newFixedThreadPool.execute(new Runnable() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
for (PrivilageCpUserStoreDO cpUserStoreDO : cpUserStoreDOS) {
|
|
|
|
|
|
|
|
String cpUserId = privilageCpUserStoreDOMapper.selectCpUserIdByStoreId(cpUserStoreDO.getStoreId());
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(cpUserId)){
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
List<WxCpUserExternalContactInfo> customers = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
customers = qwMailListManageService.getCustomer(cpUserId);
|
|
|
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
|
|
|
log.error("查询联系人失败:"+cpUserId,e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(customers)){
|
|
|
|
|
|
|
|
for (WxCpUserExternalContactInfo customer:customers){
|
|
|
|
|
|
|
|
TurnBackDTO turnBackDTO = new TurnBackDTO();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WxCpUserExternalContactInfo.ExternalContact externalContact = customer.getExternalContact();
|
|
|
|
|
|
|
|
List<WxCpUserExternalContactInfo.FollowedUser> followedUsers = customer.getFollowedUsers();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
turnBackDTO.setEaCode("");
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(followedUsers)){
|
|
|
|
|
|
|
|
turnBackDTO.setJoinTime(sdf.format(new Date()));
|
|
|
|
|
|
|
|
for (WxCpUserExternalContactInfo.FollowedUser followedUser:followedUsers){
|
|
|
|
|
|
|
|
if (cpUserId.equals(followedUser.getUserId())){
|
|
|
|
|
|
|
|
String state = followedUser.getState();
|
|
|
|
|
|
|
|
WxCpUserExternalContactInfo.Tag[] tags = followedUser.getTags();
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(state)){
|
|
|
|
|
|
|
|
//判断是否有导购码
|
|
|
|
|
|
|
|
turnBackDTO.setEaCode(state);
|
|
|
|
|
|
|
|
}else if(tags != null && tags.length > 0){
|
|
|
|
|
|
|
|
//判断是否有打tag
|
|
|
|
|
|
|
|
//todo 根据tag获取导购码
|
|
|
|
|
|
|
|
for (int j = 0;j<tags.length;j++){
|
|
|
|
|
|
|
|
String groupName = tags[j].getGroupName();
|
|
|
|
|
|
|
|
if ("导购".equals(groupName)){
|
|
|
|
|
|
|
|
String tagName = tags[j].getTagName();
|
|
|
|
|
|
|
|
Long staffId = poiStoreStaffDOMapper.selectStaffIdByTag(cpUserStoreDO.getStoreId(), tagName);
|
|
|
|
|
|
|
|
if (staffId != null){
|
|
|
|
|
|
|
|
PoiStoreStaff poiStoreStaff = poiStoreStaffDOMapper.selectById(staffId);
|
|
|
|
|
|
|
|
if (poiStoreStaff!=null){
|
|
|
|
|
|
|
|
turnBackDTO.setEaCode(poiStoreStaff.getStaffCode());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
//todo 绑定在标签导购上,后续删除
|
|
|
|
|
|
|
|
turnBackDTO.setEaCode(tagName);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Long joinTimeL = followedUser.getCreateTime();
|
|
|
|
|
|
|
|
Long time=new Long(joinTimeL);
|
|
|
|
|
|
|
|
String joinTime = sdf.format(time*1000);
|
|
|
|
|
|
|
|
turnBackDTO.setJoinTime(joinTime);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//type 1 微信,type 2 企业微信
|
|
|
|
|
|
|
|
turnBackDTO.setType(externalContact.getType());
|
|
|
|
|
|
|
|
turnBackDTO.setUserId(cpUserId);
|
|
|
|
|
|
|
|
turnBackDTO.setName(externalContact.getName());
|
|
|
|
|
|
|
|
WxDataDTO wxDataDTO = new WxDataDTO();
|
|
|
|
|
|
|
|
wxDataDTO.setAvatarUrl(externalContact.getAvatar());
|
|
|
|
|
|
|
|
wxDataDTO.setUserId(externalContact.getExternalUserId());
|
|
|
|
|
|
|
|
wxDataDTO.setUnionId(externalContact.getUnionId());
|
|
|
|
|
|
|
|
turnBackDTO.setWxData(wxDataDTO);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
customerService.turnBack(turnBackDTO);
|
|
|
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
|
|
|
log.error(new Gson().toJson(turnBackDTO),e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
log.error("同步客户明细", e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
//每次减去一,避免死锁
|
|
|
|
|
|
|
|
countDownLatch.countDown();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
countDownLatch.await();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void modifyTagRelation() throws Exception {
|
|
|
|
public void modifyTagRelation() throws Exception {
|
|
|
|
List<PoiStore> poiStores = poiStoreDOMapper.selectShopByCompany(110L);
|
|
|
|
List<PoiStore> poiStores = poiStoreDOMapper.selectShopByCompany(110L);
|
|
|
@ -676,213 +568,4 @@ public class EmployeeService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void cleanCustomerRelation(){
|
|
|
|
|
|
|
|
List<PrivilageCpUserStoreDO> privilageCpUserStoreDOS = privilageCpUserStoreDOMapper.selectList(null);
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(privilageCpUserStoreDOS)) {
|
|
|
|
|
|
|
|
for (PrivilageCpUserStoreDO privilageCpUserStoreDO : privilageCpUserStoreDOS) {
|
|
|
|
|
|
|
|
Long storeId = privilageCpUserStoreDO.getStoreId();
|
|
|
|
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> qw = new QueryWrapper<>();
|
|
|
|
|
|
|
|
qw.eq("store_id",storeId);
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> poiStoreStaffs = opSellerCustomerRelationDOMapper.selectList(qw);
|
|
|
|
|
|
|
|
//同一家店根据客户分组
|
|
|
|
|
|
|
|
Map<Long, List<OpSellerCustomerRelation>> customerMap = new HashMap<>();
|
|
|
|
|
|
|
|
for (OpSellerCustomerRelation opSellerCustomerRelation : poiStoreStaffs) {
|
|
|
|
|
|
|
|
Long customerId = opSellerCustomerRelation.getCustomerId();
|
|
|
|
|
|
|
|
if (customerMap.get(customerId) != null){
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> relations = customerMap.get(customerId);
|
|
|
|
|
|
|
|
relations.add(opSellerCustomerRelation);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> relations = new ArrayList<>();
|
|
|
|
|
|
|
|
relations.add(opSellerCustomerRelation);
|
|
|
|
|
|
|
|
customerMap.put(customerId,relations);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Set<Long> customerIds = customerMap.keySet();
|
|
|
|
|
|
|
|
for (Long customerId:customerIds){
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> relations = customerMap.get(customerId);
|
|
|
|
|
|
|
|
//根据导购分组
|
|
|
|
|
|
|
|
Map<Long, List<OpSellerCustomerRelation>> sellerMap = new HashMap<>();
|
|
|
|
|
|
|
|
for (OpSellerCustomerRelation opSellerCustomerRelation : relations) {
|
|
|
|
|
|
|
|
Long sellerId = opSellerCustomerRelation.getUserId();
|
|
|
|
|
|
|
|
if (sellerMap.get(sellerId) != null){
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> sellerRelations = sellerMap.get(sellerId);
|
|
|
|
|
|
|
|
sellerRelations.add(opSellerCustomerRelation);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> sellerRelations = new ArrayList<>();
|
|
|
|
|
|
|
|
sellerRelations.add(opSellerCustomerRelation);
|
|
|
|
|
|
|
|
sellerMap.put(sellerId,sellerRelations);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取sellerId为0的分组
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> storeRelation = sellerMap.get(0L);
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(storeRelation)){
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Set<Long> sellerIds = sellerMap.keySet();
|
|
|
|
|
|
|
|
for (Long sellerId : sellerIds){
|
|
|
|
|
|
|
|
if (sellerId.equals(0L)){
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取导购与客户的关系
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> sellRelations = sellerMap.get(sellerId);
|
|
|
|
|
|
|
|
//遍历关系,看是否存在店铺关系,如果存在则删除店铺关系
|
|
|
|
|
|
|
|
for (OpSellerCustomerRelation sellRelation : sellRelations) {
|
|
|
|
|
|
|
|
Long sellCustomer = sellRelation.getCustomerId();
|
|
|
|
|
|
|
|
for (OpSellerCustomerRelation opSellerCustomerRelation : storeRelation) {
|
|
|
|
|
|
|
|
if (opSellerCustomerRelation.getCustomerId().equals(sellCustomer)){
|
|
|
|
|
|
|
|
//店铺中存在则删除这条店铺记录(该记录为回调产生,保留的是同步过来的数据)
|
|
|
|
|
|
|
|
if (opSellerCustomerRelation.getType().equals(TYPE_CUSTOMER_EFFECTIVE)){
|
|
|
|
|
|
|
|
//判断是否有效,有效则说明导购数据是有效的
|
|
|
|
|
|
|
|
sellRelation.setType(TYPE_CUSTOMER_EFFECTIVE);
|
|
|
|
|
|
|
|
opSellerCustomerRelationDOMapper.updateById(sellRelation);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//删除店铺数据
|
|
|
|
|
|
|
|
opSellerCustomerRelationDOMapper.deleteById(opSellerCustomerRelation.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void cleanCustomerRelationByStoreCode(String storeCode){
|
|
|
|
|
|
|
|
QueryWrapper<PoiStore> storeQw = new QueryWrapper<>();
|
|
|
|
|
|
|
|
storeQw.eq("code",storeCode).last("limit 1");
|
|
|
|
|
|
|
|
PoiStore poiStore = poiStoreDOMapper.selectOne(storeQw);
|
|
|
|
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> qw = new QueryWrapper<>();
|
|
|
|
|
|
|
|
qw.eq("store_id",poiStore.getId());
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> poiStoreStaffs = opSellerCustomerRelationDOMapper.selectList(qw);
|
|
|
|
|
|
|
|
//同一家店根据客户分组
|
|
|
|
|
|
|
|
Map<Long, List<OpSellerCustomerRelation>> customerMap = new HashMap<>();
|
|
|
|
|
|
|
|
for (OpSellerCustomerRelation opSellerCustomerRelation : poiStoreStaffs) {
|
|
|
|
|
|
|
|
Long customerId = opSellerCustomerRelation.getCustomerId();
|
|
|
|
|
|
|
|
if (customerMap.get(customerId) != null){
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> relations = customerMap.get(customerId);
|
|
|
|
|
|
|
|
relations.add(opSellerCustomerRelation);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> relations = new ArrayList<>();
|
|
|
|
|
|
|
|
relations.add(opSellerCustomerRelation);
|
|
|
|
|
|
|
|
customerMap.put(customerId,relations);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Set<Long> customerIds = customerMap.keySet();
|
|
|
|
|
|
|
|
for (Long customerId:customerIds) {
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> relations = customerMap.get(customerId);
|
|
|
|
|
|
|
|
//根据导购分组
|
|
|
|
|
|
|
|
Map<Long, List<OpSellerCustomerRelation>> sellerMap = new HashMap<>();
|
|
|
|
|
|
|
|
for (OpSellerCustomerRelation opSellerCustomerRelation : relations) {
|
|
|
|
|
|
|
|
Long sellerId = opSellerCustomerRelation.getUserId();
|
|
|
|
|
|
|
|
if (sellerMap.get(sellerId) != null) {
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> sellerRelations = sellerMap.get(sellerId);
|
|
|
|
|
|
|
|
sellerRelations.add(opSellerCustomerRelation);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> sellerRelations = new ArrayList<>();
|
|
|
|
|
|
|
|
sellerRelations.add(opSellerCustomerRelation);
|
|
|
|
|
|
|
|
sellerMap.put(sellerId, sellerRelations);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取sellerId为0的分组
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> storeRelation = sellerMap.get(0L);
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(storeRelation)) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Set<Long> sellerIds = sellerMap.keySet();
|
|
|
|
|
|
|
|
for (Long sellerId : sellerIds) {
|
|
|
|
|
|
|
|
if (sellerId.equals(0L)) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取导购与客户的关系
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> sellRelations = sellerMap.get(sellerId);
|
|
|
|
|
|
|
|
//遍历关系,看是否存在店铺关系,如果存在则删除店铺关系
|
|
|
|
|
|
|
|
for (OpSellerCustomerRelation sellRelation : sellRelations) {
|
|
|
|
|
|
|
|
Long sellCustomer = sellRelation.getCustomerId();
|
|
|
|
|
|
|
|
for (OpSellerCustomerRelation opSellerCustomerRelation : storeRelation) {
|
|
|
|
|
|
|
|
if (opSellerCustomerRelation.getCustomerId().equals(sellCustomer)) {
|
|
|
|
|
|
|
|
//店铺中存在则删除这条店铺记录(该记录为回调产生,保留的是同步过来的数据)
|
|
|
|
|
|
|
|
if (opSellerCustomerRelation.getType().equals(TYPE_CUSTOMER_EFFECTIVE)) {
|
|
|
|
|
|
|
|
//判断是否有效,有效则说明导购数据是有效的
|
|
|
|
|
|
|
|
sellRelation.setType(TYPE_CUSTOMER_EFFECTIVE);
|
|
|
|
|
|
|
|
opSellerCustomerRelationDOMapper.updateById(sellRelation);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//删除店铺数据
|
|
|
|
|
|
|
|
opSellerCustomerRelationDOMapper.deleteById(opSellerCustomerRelation.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void cleanCustomerRelationBycompanyId(Long companyId){
|
|
|
|
|
|
|
|
List<PoiStore> poiStores = poiStoreDOMapper.selectShopByCompany(companyId);
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(poiStores)) {
|
|
|
|
|
|
|
|
for (PoiStore poiStore : poiStores) {
|
|
|
|
|
|
|
|
Long storeId = poiStore.getId();
|
|
|
|
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> qw = new QueryWrapper<>();
|
|
|
|
|
|
|
|
qw.eq("store_id",storeId);
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> poiStoreStaffs = opSellerCustomerRelationDOMapper.selectList(qw);
|
|
|
|
|
|
|
|
//同一家店根据客户分组
|
|
|
|
|
|
|
|
Map<Long, List<OpSellerCustomerRelation>> customerMap = new HashMap<>();
|
|
|
|
|
|
|
|
for (OpSellerCustomerRelation opSellerCustomerRelation : poiStoreStaffs) {
|
|
|
|
|
|
|
|
Long customerId = opSellerCustomerRelation.getCustomerId();
|
|
|
|
|
|
|
|
if (customerMap.get(customerId) != null){
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> relations = customerMap.get(customerId);
|
|
|
|
|
|
|
|
relations.add(opSellerCustomerRelation);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> relations = new ArrayList<>();
|
|
|
|
|
|
|
|
relations.add(opSellerCustomerRelation);
|
|
|
|
|
|
|
|
customerMap.put(customerId,relations);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Set<Long> customerIds = customerMap.keySet();
|
|
|
|
|
|
|
|
for (Long customerId:customerIds){
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> relations = customerMap.get(customerId);
|
|
|
|
|
|
|
|
//根据导购分组
|
|
|
|
|
|
|
|
Map<Long, List<OpSellerCustomerRelation>> sellerMap = new HashMap<>();
|
|
|
|
|
|
|
|
for (OpSellerCustomerRelation opSellerCustomerRelation : relations) {
|
|
|
|
|
|
|
|
Long sellerId = opSellerCustomerRelation.getUserId();
|
|
|
|
|
|
|
|
if (sellerMap.get(sellerId) != null){
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> sellerRelations = sellerMap.get(sellerId);
|
|
|
|
|
|
|
|
sellerRelations.add(opSellerCustomerRelation);
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> sellerRelations = new ArrayList<>();
|
|
|
|
|
|
|
|
sellerRelations.add(opSellerCustomerRelation);
|
|
|
|
|
|
|
|
sellerMap.put(sellerId,sellerRelations);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取sellerId为0的分组
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> storeRelation = sellerMap.get(0L);
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(storeRelation)){
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Set<Long> sellerIds = sellerMap.keySet();
|
|
|
|
|
|
|
|
for (Long sellerId : sellerIds){
|
|
|
|
|
|
|
|
if (sellerId.equals(0L)){
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取导购与客户的关系
|
|
|
|
|
|
|
|
List<OpSellerCustomerRelation> sellRelations = sellerMap.get(sellerId);
|
|
|
|
|
|
|
|
//遍历关系,看是否存在店铺关系,如果存在则删除店铺关系
|
|
|
|
|
|
|
|
for (OpSellerCustomerRelation sellRelation : sellRelations) {
|
|
|
|
|
|
|
|
Long sellCustomer = sellRelation.getCustomerId();
|
|
|
|
|
|
|
|
for (OpSellerCustomerRelation opSellerCustomerRelation : storeRelation) {
|
|
|
|
|
|
|
|
if (opSellerCustomerRelation.getCustomerId().equals(sellCustomer)){
|
|
|
|
|
|
|
|
//店铺中存在则删除这条店铺记录(该记录为回调产生,保留的是同步过来的数据)
|
|
|
|
|
|
|
|
if (opSellerCustomerRelation.getType().equals(TYPE_CUSTOMER_EFFECTIVE)){
|
|
|
|
|
|
|
|
//判断是否有效,有效则说明导购数据是有效的
|
|
|
|
|
|
|
|
sellRelation.setType(TYPE_CUSTOMER_EFFECTIVE);
|
|
|
|
|
|
|
|
opSellerCustomerRelationDOMapper.updateById(sellRelation);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//删除店铺数据
|
|
|
|
|
|
|
|
opSellerCustomerRelationDOMapper.deleteById(opSellerCustomerRelation.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|