Commit 03ae6a62 authored by Vu Duy Anh's avatar Vu Duy Anh

anhvd accept merge

parents 7571fdbd bf5364c2
...@@ -14,4 +14,6 @@ public interface CampaignCustomerListRepository extends JpaRepository<CampaignCu ...@@ -14,4 +14,6 @@ public interface CampaignCustomerListRepository extends JpaRepository<CampaignCu
@Query("select count (c.campaignId) from CampaignCustomerList c where c.customerListId in (:ids)") @Query("select count (c.campaignId) from CampaignCustomerList c where c.customerListId in (:ids)")
Long campaignIdsCount(@Param("ids") List<Long> ids); Long campaignIdsCount(@Param("ids") List<Long> ids);
void deleteCampaignCustomerListByCampaignIdAndCustomerListIdAndCompanySiteId(Long campaignId, Long customerListId, Long companySiteId);
} }
...@@ -35,4 +35,20 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom ...@@ -35,4 +35,20 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom
Long getCustomerRecall(@Param("campaignId") Long campaignId, @Param("customerId") Long customerId); Long getCustomerRecall(@Param("campaignId") Long campaignId, @Param("customerId") Long customerId);
CampaignCustomer findCampaignCustomerByCampaignCustomerId(Long id); CampaignCustomer findCampaignCustomerByCampaignCustomerId(Long id);
@Query(value = "SELECT * FROM CAMPAIGN_CUSTOMER CC " +
"WHERE CC.STATUS = 0 " +
"AND CC.CAMPAIGN_ID = :campaignId " +
"AND CC.COMPANY_SITE_ID = :companySiteId " +
"AND CC.CUSTOMER_LIST_ID = :customerListId", nativeQuery = true)
List<CampaignCustomer> findCustomerNoContact(@Param("campaignId") Long campaignId, @Param("companySiteId") Long companySiteId, @Param("customerListId") Long customerListId);
@Query(value = "SELECT * FROM CAMPAIGN_CUSTOMER CC " +
"WHERE CC.STATUS IN (SELECT COMPLETE_VALUE from CAMPAIGN_COMPLETE_CODE where STATUS = 1 and IS_FINISH = 0 and IS_RECALL = 0)" +
"AND CC.CAMPAIGN_ID = :campaignId " +
"AND CC.COMPANY_SITE_ID = :companySiteId " +
"AND CC.CUSTOMER_LIST_ID = :customerListId", nativeQuery = true)
List<CampaignCustomer> findCustomerContacted(@Param("campaignId") Long campaignId, @Param("companySiteId") Long companySiteId, @Param("customerListId") Long customerListId);
} }
...@@ -62,6 +62,8 @@ public interface CampaignService { ...@@ -62,6 +62,8 @@ public interface CampaignService {
ResultDTO getCustomerChoosenList(CampaignRequestDTO dto); ResultDTO getCustomerChoosenList(CampaignRequestDTO dto);
ResultDTO addCustomerListToCampaign(CampaignRequestDTO dto); ResultDTO addCustomerListToCampaign(CampaignRequestDTO dto);
ResultDTO deleteCustomerListFromCampaign(CampaignRequestDTO dto);
//</editor-fold> //</editor-fold>
} }
...@@ -64,6 +64,9 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -64,6 +64,9 @@ public class CampaignServiceImpl implements CampaignService {
@Autowired @Autowired
CampaignCustomerListRepository campaignCustomerListRepository; CampaignCustomerListRepository campaignCustomerListRepository;
@Autowired
CampaignCustomerRepository campaignCustomerRepository;
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO search(CampaignRequestDTO requestDto) { public ResultDTO search(CampaignRequestDTO requestDto) {
...@@ -526,6 +529,38 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -526,6 +529,38 @@ public class CampaignServiceImpl implements CampaignService {
return resultDTO; return resultDTO;
} }
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO deleteCustomerListFromCampaign(CampaignRequestDTO dto) {
ResultDTO resultDTO = new ResultDTO();
String[] lstCusListId = dto.getLstCustomerListId().split(",");
long campaignId = Long.parseLong(dto.getCampaignId());
long companySiteId = Long.parseLong(dto.getCompanySiteId());
try {
for(String cusListId : lstCusListId) {
// Xoa danh sach khach hang khoi campaign_customerList
campaignCustomerListRepository.deleteCampaignCustomerListByCampaignIdAndCustomerListIdAndCompanySiteId(campaignId, Long.parseLong(cusListId), companySiteId);
// Thuc hien xoa cac khach hang chua lien lac tai bang campaign_customer
List<CampaignCustomer> listCampaignCustomer = campaignCustomerRepository.findCustomerNoContact(campaignId, companySiteId, Long.parseLong(cusListId));
for (CampaignCustomer entity : listCampaignCustomer) {
campaignCustomerRepository.delete(entity);
}
// Thuc hien update cac khach hang da lien lac
List<CampaignCustomer> list = campaignCustomerRepository.findCustomerContacted(campaignId, companySiteId, Long.parseLong(cusListId));
for (CampaignCustomer campaignCustomer: list) {
campaignCustomer.setInCampaignStatus((short) 0);
}
}
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;
}
// hungtt // hungtt
private Map<String, String> setMapData(Map<String, String> mapColumn, Locale locale) { private Map<String, String> setMapData(Map<String, String> mapColumn, Locale locale) {
mapColumn.put("CUSTOMER_ID", BundleUtils.getLangString("CUSTOMER_ID", locale)); mapColumn.put("CUSTOMER_ID", BundleUtils.getLangString("CUSTOMER_ID", locale));
......
...@@ -287,6 +287,13 @@ public class CampaignController { ...@@ -287,6 +287,13 @@ public class CampaignController {
ResultDTO resultDTO = campaignService.addCustomerListToCampaign(campaignRequestDTO); ResultDTO resultDTO = campaignService.addCustomerListToCampaign(campaignRequestDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK); return new ResponseEntity<>(resultDTO, HttpStatus.OK);
} }
@PostMapping("/deleteCustomerListFromCampaign")
@ResponseBody
public ResponseEntity deleteCustomerListFromCampaign(@RequestBody CampaignRequestDTO campaignRequestDTO) {
ResultDTO resultDTO = campaignService.deleteCustomerListFromCampaign(campaignRequestDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@RequestMapping(value = "/renewCampaign", method = RequestMethod.PUT) @RequestMapping(value = "/renewCampaign", method = RequestMethod.PUT)
public ResponseEntity<ResultDTO> renewCampaign(@RequestBody CampaignDTO campaignDTO) { public ResponseEntity<ResultDTO> renewCampaign(@RequestBody CampaignDTO campaignDTO) {
ResultDTO result = campaignService.renewCampaign(campaignDTO); ResultDTO result = campaignService.renewCampaign(campaignDTO);
......
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