Commit 2052d254 authored by ='s avatar =

hungtt-commit individual-customer campaign-mng

parent 1d784ca9
...@@ -88,4 +88,9 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom ...@@ -88,4 +88,9 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom
" and customer_list_id = :p_cus_list_id\n" + " and customer_list_id = :p_cus_list_id\n" +
" and (status = 0 or status in (select * from status_customer))", nativeQuery = true) " and (status = 0 or status in (select * from status_customer))", nativeQuery = true)
List<CampaignCustomer> findListCustomerToDel(@Param("p_company_site_id") Long companySiteId, @Param("p_campaign_id") Long campaignId, @Param("p_cus_list_id") Long customerListId); List<CampaignCustomer> findListCustomerToDel(@Param("p_company_site_id") Long companySiteId, @Param("p_campaign_id") Long campaignId, @Param("p_cus_list_id") Long customerListId);
CampaignCustomer findCampaignCustomerByCampaignIdAndCompanySiteIdAndCustomerId(Long campaignId, Long companySiteId, Long customerId);
@Query(value = "select complete_value from campaign_complete_code where status = 1 and is_finish = 0 and is_recall = 0", nativeQuery = true)
List<Short> getStatus();
} }
...@@ -58,6 +58,8 @@ public interface CustomerService { ...@@ -58,6 +58,8 @@ public interface CustomerService {
List<CustomerDTO> getIndividualCustomerInfo(CampaignCustomerDTO campaignCustomerDTO); List<CustomerDTO> getIndividualCustomerInfo(CampaignCustomerDTO campaignCustomerDTO);
ResultDTO deleteCustomerFromCampaign(CampaignCustomerDTO campaignCustomerDTO);
// ------------ customer ------------ // // ------------ customer ------------ //
......
...@@ -1635,6 +1635,35 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1635,6 +1635,35 @@ public class CustomerServiceImpl implements CustomerService {
return customerList; return customerList;
} }
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO deleteCustomerFromCampaign(CampaignCustomerDTO campaignCustomerDTO) {
ResultDTO resultDTO = new ResultDTO();
Long companySiteId = campaignCustomerDTO.getCompanySiteId();
Long campaignId = campaignCustomerDTO.getCampaignId();
String[] lstCusId = campaignCustomerDTO.getLstCustomerId().split(",");
List<Short> lstStatus = campaignCustomerRepository.getStatus();
try {
for (String cusId: lstCusId) {
CampaignCustomer entity = campaignCustomerRepository.findCampaignCustomerByCampaignIdAndCompanySiteIdAndCustomerId(campaignId, companySiteId, Long.parseLong(cusId));
if (entity.getStatus() == 0) {
campaignCustomerRepository.delete(entity);
} else if (lstStatus.contains(entity.getStatus())){
entity.setInCampaignStatus((short)0);
campaignCustomerRepository.save(entity);
}
}
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
return resultDTO;
}
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public List<Customer> findAllByCondition(Long siteId, Date endTime) { public List<Customer> findAllByCondition(Long siteId, Date endTime) {
...@@ -1750,20 +1779,20 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1750,20 +1779,20 @@ public class CustomerServiceImpl implements CustomerService {
" C.CURRENT_ADDRESS currentAddress," + " C.CURRENT_ADDRESS currentAddress," +
" C.USERNAME username," + " C.USERNAME username," +
" C.GENDER gender," + " C.GENDER gender," +
" C.COMPANY_NAME companyName" + " C.COMPANY_NAME companyName," +
" C.DATE_OF_BIRTH dateOfBirth," + " C.DATE_OF_BIRTH dateOfBirth," +
" C.COMPANY_NAME companyName," + " C.COMPANY_NAME companyName," +
" C.CUSTOMER_TYPE customerType," + " C.CUSTOMER_TYPE customerType," +
" C.PLACE_OF_BIRTH placeOfBirth," + " C.PLACE_OF_BIRTH placeOfBirth," +
" C.CUSTOMER_TYPE customerType," + " C.CUSTOMER_TYPE customerType," +
" C.EMAIL email," + " C.EMAIL email," +
" C.USERNAME username" + " C.USERNAME username," +
" C.NAME name," + " C.NAME name," +
" C.MOBILE_NUMBER mobileNumber," + " C.MOBILE_NUMBER mobileNumber," +
" C.SITE_ID siteId," + " C.SITE_ID siteId," +
" C.STATUS status," + " C.STATUS status," +
" CF.FUNCTION_CODE functionCode," + " CF.FUNCTION_CODE functionCode," +
" CFO.ACTIVE active" + " CFO.ACTIVE active," +
" CFO.*"); " CFO.*");
stringBuilder.append("FROM CUSTOMER C"); stringBuilder.append("FROM CUSTOMER C");
stringBuilder.append(" INNER JOIN CUSTOMIZE_FIELD_OBJECT CFO ON C.CUSTOMER_ID = CFO.OBJECT_ID"); stringBuilder.append(" INNER JOIN CUSTOMIZE_FIELD_OBJECT CFO ON C.CUSTOMER_ID = CFO.OBJECT_ID");
......
...@@ -26,4 +26,5 @@ public class CampaignCustomerDTO extends BaseDTO{ ...@@ -26,4 +26,5 @@ public class CampaignCustomerDTO extends BaseDTO{
private Long callStatus; private Long callStatus;
private Long companySiteId; private Long companySiteId;
private Long complainId; private Long complainId;
private String lstCustomerId;
} }
package com.viettel.campaign.web.rest; package com.viettel.campaign.web.rest;
import com.viettel.campaign.model.ccms_full.CampaignCustomer;
import com.viettel.campaign.model.ccms_full.Customer; import com.viettel.campaign.model.ccms_full.Customer;
import com.viettel.campaign.model.ccms_full.CustomizeFieldObject; import com.viettel.campaign.model.ccms_full.CustomizeFieldObject;
import com.viettel.campaign.model.ccms_full.CustomizeFields; import com.viettel.campaign.model.ccms_full.CustomizeFields;
...@@ -252,6 +253,13 @@ public class CustomerController { ...@@ -252,6 +253,13 @@ public class CustomerController {
return new ResponseEntity<>(data, HttpStatus.OK); return new ResponseEntity<>(data, HttpStatus.OK);
} }
@PostMapping("/deleteCustomerFromCampaign")
@ResponseBody
public ResponseEntity<?> deleteCustomerFromCampaign(@RequestBody CampaignCustomerDTO dto) {
ResultDTO resultDTO = customerService.deleteCustomerFromCampaign(dto);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
private String saveUploadFile(MultipartFile file) { private String saveUploadFile(MultipartFile file) {
......
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