|
|
|
@ -19,13 +19,17 @@ package com.logpm.basicdata.service.impl;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.logpm.basicdata.entity.BasicdataClientEntity; |
|
|
|
|
import com.logpm.basicdata.entity.BasicdataStoreContactEntity; |
|
|
|
|
import com.logpm.basicdata.excel.BasicdataStoreContactExcel; |
|
|
|
|
import com.logpm.basicdata.mapper.BasicdataStoreContactMapper; |
|
|
|
|
import com.logpm.basicdata.service.IBasicdataClientService; |
|
|
|
|
import com.logpm.basicdata.service.IBasicdataStoreContactService; |
|
|
|
|
import com.logpm.basicdata.vo.BasicdataStoreContactVO; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.context.annotation.Lazy; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
@ -41,6 +45,11 @@ import java.util.stream.Collectors;
|
|
|
|
|
@Slf4j |
|
|
|
|
public class BasicdataStoreContactServiceImpl extends BaseServiceImpl<BasicdataStoreContactMapper, BasicdataStoreContactEntity> implements IBasicdataStoreContactService { |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
@Lazy |
|
|
|
|
private IBasicdataClientService basicdataClientService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<BasicdataStoreContactVO> selectBasicdataStoreContactPage(IPage<BasicdataStoreContactVO> page, BasicdataStoreContactVO basicdataStoreContact) { |
|
|
|
|
return page.setRecords(baseMapper.selectBasicdataStoreContactPage(page, basicdataStoreContact)); |
|
|
|
@ -62,6 +71,13 @@ public class BasicdataStoreContactServiceImpl extends BaseServiceImpl<BasicdataS
|
|
|
|
|
List<BasicdataStoreContactEntity> storeContactEntities = baseMapper.selectList(Wrappers.<BasicdataStoreContactEntity>query().lambda() |
|
|
|
|
.eq(BasicdataStoreContactEntity::getShopId, basicdataStoreContact.getShopId()) |
|
|
|
|
); |
|
|
|
|
if (!basicdataStoreContact.getDefaultType()){ |
|
|
|
|
boolean flag = storeContactEntities.stream().filter(f->!f.getId().equals(basicdataStoreContact.getId())).allMatch(b -> b.getDefaultType().equals(false)); |
|
|
|
|
if (flag){ |
|
|
|
|
throw new RuntimeException("商场必须存在一个默认联系人"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<Long> ids = storeContactEntities.stream().filter(f -> !f.getId().equals(basicdataStoreContact.getId())).map(BasicdataStoreContactEntity::getId).collect(Collectors.toList()); |
|
|
|
|
if (!ids.isEmpty()) { |
|
|
|
|
this.update(Wrappers.<BasicdataStoreContactEntity>update().lambda() |
|
|
|
@ -69,8 +85,13 @@ public class BasicdataStoreContactServiceImpl extends BaseServiceImpl<BasicdataS
|
|
|
|
|
.set(BasicdataStoreContactEntity::getDefaultType,false) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
//修改客户的展示联系人为默认联系人
|
|
|
|
|
basicdataClientService.update(Wrappers.<BasicdataClientEntity>update().lambda() |
|
|
|
|
.eq(BasicdataClientEntity::getId,basicdataStoreContact.getShopId()) |
|
|
|
|
.set(BasicdataClientEntity::getLinkman,basicdataStoreContact.getLinkman()) |
|
|
|
|
.set(BasicdataClientEntity::getPhone,basicdataStoreContact.getPhone()) |
|
|
|
|
); |
|
|
|
|
this.updateById(basicdataStoreContact); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
log.info("报错信息:{}",e.getMessage()); |
|
|
|
|