保誠-保戶業務員媒合平台
wayne
2022-02-17 4394e4248455637ab7836756058ac872fdf4af10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com.pollex.pam.appointment.process;
 
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import com.pollex.pam.domain.Appointment;
import com.pollex.pam.domain.AppointmentClosedInfo;
import com.pollex.pam.enums.ContactStatusEnum;
import com.pollex.pam.repository.AppointmentClosedInfoRepository;
import com.pollex.pam.service.AppointmentClosedInfoService;
import com.pollex.pam.service.AppointmentService;
import com.pollex.pam.service.SatisfactionService;
import com.pollex.pam.service.dto.AbstractAppointmentProcessDTO;
import com.pollex.pam.service.dto.ClosedProcessDTO;
 
@Service
@Transactional
public class ClosedProcess implements AppointmentProcessInterface{
 
    @Autowired
    AppointmentClosedInfoRepository appointmentClosedInfoRepository;
 
    @Autowired
    AppointmentService appointmentService;
 
    @Autowired
    AppointmentClosedInfoService appointmentClosedInfoService;
 
    @Autowired
    SatisfactionService satisfactionService;
 
    @Override
    public AppointmentClosedInfo create(AbstractAppointmentProcessDTO processDTO) {
        ClosedProcessDTO closeProcess = toClosedProcessDTO(processDTO);
        AppointmentClosedInfo closedInfo = new AppointmentClosedInfo();
        BeanUtils.copyProperties(closeProcess, closedInfo);
        Appointment appointment = appointmentService.findById(processDTO.getAppointmentId());
        satisfactionService.createAppointmentSatisfaction(appointment);
        return appointmentClosedInfoRepository.save(closedInfo);
    }
 
    private ClosedProcessDTO toClosedProcessDTO(AbstractAppointmentProcessDTO processDTO) {
        ClosedProcessDTO closeProcess = (ClosedProcessDTO)processDTO;
        BeanUtils.copyProperties(processDTO, closeProcess);
        return closeProcess;
    }
 
    @Override
    public ContactStatusEnum getProcessType() {
        return ContactStatusEnum.CLOSED;
    }
 
    @Override
    public AppointmentClosedInfo editClosedInfo(
            AbstractAppointmentProcessDTO abstractDTO
            , AppointmentClosedInfo closedInfo) {
        ClosedProcessDTO closeProcess =  toClosedProcessDTO(abstractDTO);
        BeanUtils.copyProperties(closeProcess, closedInfo);
        return appointmentClosedInfoRepository.save(closedInfo);
    }
 
 
}