|
@ -22,17 +22,24 @@ import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.dao.StaffAgencyVisitedDao; |
|
|
import com.epmet.dao.StaffAgencyVisitedDao; |
|
|
|
|
|
import com.epmet.dto.CustomerDTO; |
|
|
|
|
|
import com.epmet.dto.CustomerStaffDTO; |
|
|
import com.epmet.dto.StaffAgencyVisitedDTO; |
|
|
import com.epmet.dto.StaffAgencyVisitedDTO; |
|
|
import com.epmet.dto.form.StaffLoginAgencyRecordFormDTO; |
|
|
import com.epmet.dto.form.StaffLoginAgencyRecordFormDTO; |
|
|
|
|
|
import com.epmet.dto.result.LatestCustomerResultDTO; |
|
|
import com.epmet.dto.result.StaffLatestAgencyResultDTO; |
|
|
import com.epmet.dto.result.StaffLatestAgencyResultDTO; |
|
|
import com.epmet.entity.StaffAgencyVisitedEntity; |
|
|
import com.epmet.entity.StaffAgencyVisitedEntity; |
|
|
|
|
|
import com.epmet.feign.OperCrmFeignClient; |
|
|
|
|
|
import com.epmet.service.CustomerStaffService; |
|
|
import com.epmet.service.StaffAgencyVisitedService; |
|
|
import com.epmet.service.StaffAgencyVisitedService; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
@ -48,74 +55,99 @@ import java.util.Map; |
|
|
*/ |
|
|
*/ |
|
|
@Service |
|
|
@Service |
|
|
public class StaffAgencyVisitedServiceImpl extends BaseServiceImpl<StaffAgencyVisitedDao, StaffAgencyVisitedEntity> implements StaffAgencyVisitedService { |
|
|
public class StaffAgencyVisitedServiceImpl extends BaseServiceImpl<StaffAgencyVisitedDao, StaffAgencyVisitedEntity> implements StaffAgencyVisitedService { |
|
|
private static final Logger logger = LoggerFactory.getLogger(StaffAgencyVisitedServiceImpl.class); |
|
|
private static final Logger logger = LoggerFactory.getLogger(StaffAgencyVisitedServiceImpl.class); |
|
|
|
|
|
|
|
|
@Override |
|
|
@Autowired |
|
|
public PageData<StaffAgencyVisitedDTO> page(Map<String, Object> params) { |
|
|
private CustomerStaffService customerStaffService; |
|
|
IPage<StaffAgencyVisitedEntity> page = baseDao.selectPage( |
|
|
@Autowired |
|
|
getPage(params, FieldConstant.CREATED_TIME, false), |
|
|
private OperCrmFeignClient operCrmFeignClient; |
|
|
getWrapper(params) |
|
|
|
|
|
); |
|
|
@Override |
|
|
return getPageData(page, StaffAgencyVisitedDTO.class); |
|
|
public PageData<StaffAgencyVisitedDTO> page(Map<String, Object> params) { |
|
|
} |
|
|
IPage<StaffAgencyVisitedEntity> page = baseDao.selectPage( |
|
|
|
|
|
getPage(params, FieldConstant.CREATED_TIME, false), |
|
|
@Override |
|
|
getWrapper(params) |
|
|
public List<StaffAgencyVisitedDTO> list(Map<String, Object> params) { |
|
|
); |
|
|
List<StaffAgencyVisitedEntity> entityList = baseDao.selectList(getWrapper(params)); |
|
|
return getPageData(page, StaffAgencyVisitedDTO.class); |
|
|
|
|
|
} |
|
|
return ConvertUtils.sourceToTarget(entityList, StaffAgencyVisitedDTO.class); |
|
|
|
|
|
} |
|
|
@Override |
|
|
|
|
|
public List<StaffAgencyVisitedDTO> list(Map<String, Object> params) { |
|
|
private QueryWrapper<StaffAgencyVisitedEntity> getWrapper(Map<String, Object> params){ |
|
|
List<StaffAgencyVisitedEntity> entityList = baseDao.selectList(getWrapper(params)); |
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
|
return ConvertUtils.sourceToTarget(entityList, StaffAgencyVisitedDTO.class); |
|
|
QueryWrapper<StaffAgencyVisitedEntity> wrapper = new QueryWrapper<>(); |
|
|
} |
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
|
|
|
|
|
|
private QueryWrapper<StaffAgencyVisitedEntity> getWrapper(Map<String, Object> params) { |
|
|
return wrapper; |
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
} |
|
|
|
|
|
|
|
|
QueryWrapper<StaffAgencyVisitedEntity> wrapper = new QueryWrapper<>(); |
|
|
@Override |
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
public StaffAgencyVisitedDTO get(String id) { |
|
|
|
|
|
StaffAgencyVisitedEntity entity = baseDao.selectById(id); |
|
|
return wrapper; |
|
|
return ConvertUtils.sourceToTarget(entity, StaffAgencyVisitedDTO.class); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public StaffAgencyVisitedDTO get(String id) { |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
StaffAgencyVisitedEntity entity = baseDao.selectById(id); |
|
|
public void save(StaffAgencyVisitedDTO dto) { |
|
|
return ConvertUtils.sourceToTarget(entity, StaffAgencyVisitedDTO.class); |
|
|
StaffAgencyVisitedEntity entity = ConvertUtils.sourceToTarget(dto, StaffAgencyVisitedEntity.class); |
|
|
} |
|
|
insert(entity); |
|
|
|
|
|
} |
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Override |
|
|
public void save(StaffAgencyVisitedDTO dto) { |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
StaffAgencyVisitedEntity entity = ConvertUtils.sourceToTarget(dto, StaffAgencyVisitedEntity.class); |
|
|
public void update(StaffAgencyVisitedDTO dto) { |
|
|
insert(entity); |
|
|
StaffAgencyVisitedEntity entity = ConvertUtils.sourceToTarget(dto, StaffAgencyVisitedEntity.class); |
|
|
} |
|
|
updateById(entity); |
|
|
|
|
|
} |
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Override |
|
|
public void update(StaffAgencyVisitedDTO dto) { |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
StaffAgencyVisitedEntity entity = ConvertUtils.sourceToTarget(dto, StaffAgencyVisitedEntity.class); |
|
|
public void delete(String[] ids) { |
|
|
updateById(entity); |
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
} |
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
|
|
} |
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Override |
|
|
public void delete(String[] ids) { |
|
|
public Result<StaffLatestAgencyResultDTO> getLatestStaffWechatLoginRecord(String openId) { |
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
if (StringUtils.isNotBlank(openId)) { |
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
logger.error("openId 不能为空"); |
|
|
} |
|
|
return new Result(); |
|
|
|
|
|
} |
|
|
@Override |
|
|
StaffLatestAgencyResultDTO latestStaffWechatLoginDTO = baseDao.selectLatestStaffWechatLoginRecord(openId); |
|
|
public Result<StaffLatestAgencyResultDTO> getLatestStaffWechatLoginRecord(String openId) { |
|
|
return new Result<StaffLatestAgencyResultDTO>().ok(latestStaffWechatLoginDTO); |
|
|
if (StringUtils.isNotBlank(openId)) { |
|
|
} |
|
|
logger.error("openId 不能为空"); |
|
|
|
|
|
return new Result(); |
|
|
@Override |
|
|
} |
|
|
public Result saveStaffLoginRecord(StaffLoginAgencyRecordFormDTO formDTO) { |
|
|
StaffLatestAgencyResultDTO latestStaffWechatLoginDTO = baseDao.selectLatestStaffWechatLoginRecord(openId); |
|
|
StaffAgencyVisitedEntity entity = ConvertUtils.sourceToTarget(formDTO, StaffAgencyVisitedEntity.class); |
|
|
return new Result<StaffLatestAgencyResultDTO>().ok(latestStaffWechatLoginDTO); |
|
|
insert(entity); |
|
|
} |
|
|
return new Result(); |
|
|
|
|
|
} |
|
|
@Override |
|
|
|
|
|
public Result saveStaffLoginRecord(StaffLoginAgencyRecordFormDTO formDTO) { |
|
|
|
|
|
StaffAgencyVisitedEntity entity = ConvertUtils.sourceToTarget(formDTO, StaffAgencyVisitedEntity.class); |
|
|
|
|
|
insert(entity); |
|
|
|
|
|
return new Result(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Result<LatestCustomerResultDTO> getLatestCustomer(String userId) { |
|
|
|
|
|
LatestCustomerResultDTO resultDTO = new LatestCustomerResultDTO(); |
|
|
|
|
|
StaffLatestAgencyResultDTO latestCustomer = baseDao.selectLatestCustomer(userId); |
|
|
|
|
|
resultDTO.setAgencyId(latestCustomer.getAgencyId()); |
|
|
|
|
|
resultDTO.setCustomerId(latestCustomer.getCustomerId()); |
|
|
|
|
|
//获取工作人员头像
|
|
|
|
|
|
CustomerStaffDTO customerStaffParam = new CustomerStaffDTO(); |
|
|
|
|
|
customerStaffParam.setUserId(userId); |
|
|
|
|
|
Result<CustomerStaffDTO> staffInfo = |
|
|
|
|
|
customerStaffService.getCustomerStaffInfoByUserId(customerStaffParam); |
|
|
|
|
|
resultDTO.setStaffHeadPhoto(staffInfo.getData().getHeadPhoto()); |
|
|
|
|
|
//获取客户名称
|
|
|
|
|
|
CustomerDTO customerDTO = new CustomerDTO(); |
|
|
|
|
|
customerDTO.setId(latestCustomer.getCustomerId()); |
|
|
|
|
|
Result<CustomerDTO> customerResult = operCrmFeignClient.getCustomerInfo(customerDTO); |
|
|
|
|
|
resultDTO.setCustomerName(customerResult.getData().getCustomerName()); |
|
|
|
|
|
return new Result<LatestCustomerResultDTO>().ok(resultDTO); |
|
|
|
|
|
} |
|
|
} |
|
|
} |