Commit 64f31ff4 authored by Tu Bach's avatar Tu Bach

tubn campaign execute update detail, phone

parent 7f5f3288
......@@ -9,8 +9,16 @@ import org.springframework.data.repository.query.Param;
import java.util.List;
public interface CustomerContactRepository extends JpaRepository<CustomerContact, Long> {
@Query("FROM CustomerContact WHERE status = 1 AND customerId = :customerId AND contactType = :contactType AND (contact IS NULL OR UPPER(contact) LIKE UPPER(concat('%', :contact, '%')))")
List<CustomerContact> findByCustomerIdAndAndContactTypeAndContact(@Param("customerId") Long customerId, @Param("contactType") Short contactType, @Param("contact") String contact, Pageable pageable);
List<CustomerContact> findCustomerContactsByContactEquals(String contact);
@Query("SELECT cc FROM CustomerContact cc WHERE cc.customerId = :customerId AND cc.status = :status AND cc.contactType = :contactType AND cc.isDirectLine = :isDirectLine ORDER BY cc.createBy DESC")
List<CustomerContact> getLastPhone(@Param("customerId") Long customerId, @Param("status") Short status, @Param("contactType") Short contactType, @Param("isDirectLine") Short isDirectLine);
@Query("SELECT cc FROM CustomerContact cc WHERE cc.customerId = :customerId AND cc.status = :status AND cc.contactType = :contactType ORDER BY cc.createBy DESC")
List<CustomerContact> getLastEmail(@Param("customerId") Long customerId, @Param("status") Short status, @Param("contactType") Short contactType);
}
......@@ -21,7 +21,7 @@ public interface CustomerRepository extends JpaRepository<Customer, Long>, Custo
Customer getByCustomerId(Long customerId);
List<Customer> findByCustomerId(Long customerId);
Customer findByCustomerId(Long customerId);
@Query("FROM Customer WHERE name = ?1")
List<Customer> findByName(String firstName, Pageable pageable);
......
......@@ -480,31 +480,37 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
String getExecuteCus3Str = sb3.toString();
String getExecuteCus4Str = sb4.toString();
String getExecuteCus5Str = sb5.toString();
String type = "";
try {
// Khách hàng đến thời điểm hẹn gọi lại và là khách hàng mà chính NSD hẹn gọi lại
List<CampaignCustomerDTO> lst1 = campaignCustomerRepository.getDataCampaignCustomer(dto, getExecuteCus1Str);
if (lst1.size() > 0) {
lst = lst1;
type = "1";
} else {
// Khách hàng đến thời điểm hẹn gọi lại và không là khách hàng mà NSD dùng hẹn gọi lại nhưng TVV hẹn gọi lại không đăng nhập hoặc không thực hiện chiến dịch hiện tại
List<CampaignCustomerDTO> lst2 = campaignCustomerRepository.getDataCampaignCustomer(dto, getExecuteCus2Str);
if (lst2.size() > 0) {
lst = lst2;
type = "2";
} else {
// Khách hàng là khách hàng hẹn gọi lại nhưng thời gian hẹn gọi lại đã quá thời gian hẹn gọi lại + dung sai
List<CampaignCustomerDTO> lst3 = campaignCustomerRepository.getDataCampaignCustomer(dto, getExecuteCus3Str);
if (lst3.size() > 0) {
lst = lst3;
type = "3";
} else {
// Khách hàng mới
List<CampaignCustomerDTO> lst4 = campaignCustomerRepository.getDataCampaignCustomer(dto, getExecuteCus4Str);
if (lst4.size() > 0) {
lst = lst4;
type = "4";
} else {
// Khách hàng không liên lạc được nhưng chưa phải là cuộc gọi kết thúc và có số lần đã gọi < Số lần gọi tối đa được cấu hình và khoảng cách giữa 2 lần gọi < thời gian tương tác giữa 2 lần gọi được cấu hình
List<CampaignCustomerDTO> lst5 = campaignCustomerRepository.getDataCampaignCustomer(dto, getExecuteCus5Str);
lst = lst5;
type = "5";
}
}
}
......@@ -514,7 +520,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
result.setDescription(Constants.ApiErrorDesc.SUCCESS);
result.setListData(lst);
//result.setData(data);
result.setData(type);
} else {
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription(Constants.ApiErrorDesc.ERROR);
......@@ -985,11 +991,11 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
try {
cc = campaignCustomerRepository.findCampaignCustomersByCampaignIdAndCustomerId(dto.getCampaignId(), dto.getCustomerId());
if (dto.getContactStatus().equals(1)) {
if (dto.getContactStatus().equals((short) 1)) {
cc.setStatus(dto.getCallStatus().shortValue());
} else if (dto.getContactStatus().equals(2)) {
} else if (dto.getContactStatus().equals((short) 2)) {
c = campaignRepository.findByCampaignId(dto.getCampaignId());
if (cc.getRecallCount().equals(c.getMaxRecall())) {
if (cc.getRecallCount().equals(c.getMaxRecall().longValue())) {
cc.setStatus((short) 4);
} else {
cc.setStatus(dto.getContactStatus());
......@@ -1001,6 +1007,7 @@ public class CampaignExecuteServiceImp implements CampaignExecuteService {
}
cc.setCallTime(dto.getCallTimeL() == null ? null : TimeZoneUtils.changeTimeZone(new Date(dto.getCallTimeL() * 1000), 0L));
cc.setAgentId(dto.getAgentId());
cc = campaignCustomerRepository.save(cc);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
......
......@@ -107,12 +107,15 @@ public class CustomerServiceImpl implements CustomerService {
public ResultDTO getCustomerId(Long customerId) {
ResultDTO resultDTO = new ResultDTO();
List<Customer> customer = customerRepository.findByCustomerId(customerId);
Customer customer = customerRepository.findByCustomerId(customerId);
customer.setMobileNumber(customerContactRepository.getLastPhone(customerId, (short) 1, (short) 5, (short) 1).get(0).getContact());
customer.setEmail(customerContactRepository.getLastEmail(customerId, (short) 1, (short) 2).get(0).getContact());
if (customer != null) {
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription("customer data");
resultDTO.setListData(customer);
//resultDTO.setListData(customer);
resultDTO.setData(customer);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription("customer data null");
......
......@@ -32,5 +32,6 @@ public class CampaignCustomerDTO extends BaseDTO{
private String lstCustomerId;
private List<CustomerQueryDTO> listQuery;
private Long field;
private String type;
private Integer timezoneOffset;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment