保誠-保戶業務員媒合平台
wayne
2021-12-13 ee59cafd1de5fe45133e391f3837e8f68e2a6de7
pamapi/src/main/java/com/pollex/pam/service/ConsultantService.java
@@ -18,8 +18,10 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.Instant;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@Service
@@ -53,12 +55,13 @@
        return customerFavoriteConsultantRepository.findAllByCustomerId(customerId)
            .stream()
            .map(customerFavoriteConsultantRelation -> {
                Consultant consultant = customerFavoriteConsultantRelation.getConsultant();
            .map(relation -> {
                Consultant consultant = relation.getConsultant();
                CustomerFavoriteConsultantDTO dto = consultantMapper.toCustomerFavoriteConsultantDto(consultant);
                dto.setContactStatus(ContactStatusEnum.PICKED);
                dto.setCreateTime(customerFavoriteConsultantRelation.getCreatedDate());
                dto.setCreateTime(relation.getCreatedDate());
                dto.setCustomerViewTime(relation.getViewTime());
                setAppointmentInfo(
                    dto,
@@ -164,4 +167,19 @@
        String agentNo = SecurityUtils.getAgentNo();
        appointmentService.recordAllAppointmentsView(agentNo);
    }
    public void recordMyConsultantListView() {
        Long customerId = SecurityUtils.getCustomerDBId();
        List<CustomerFavoriteConsultant> notViewRelation = customerFavoriteConsultantRepository
            .findAllByCustomerId(customerId)
            .stream()
            .filter(relation -> Objects.isNull(relation.getViewTime()))
            .collect(Collectors.toList());
        notViewRelation.forEach(relation -> {
            relation.setViewTime(Instant.now());
        });
        customerFavoriteConsultantRepository.saveAll(notViewRelation);
    }
}