Commit 295d13ca authored by ='s avatar =

hungtt-commit customer list

parent 56ae38e7
...@@ -26,4 +26,6 @@ public interface CampaignRepositoryCustom { ...@@ -26,4 +26,6 @@ public interface CampaignRepositoryCustom {
ResultDTO getListFieldsNotShow(CampaignRequestDTO dto); ResultDTO getListFieldsNotShow(CampaignRequestDTO dto);
//hungtt //hungtt
ResultDTO getListFieldsToShow(CampaignRequestDTO dto); ResultDTO getListFieldsToShow(CampaignRequestDTO dto);
//hungtt
ResultDTO getCampaignCustomerList(CampaignRequestDTO dto);
} }
...@@ -8,10 +8,7 @@ import com.viettel.campaign.utils.Constants; ...@@ -8,10 +8,7 @@ import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.utils.DataUtil; import com.viettel.campaign.utils.DataUtil;
import com.viettel.campaign.utils.HibernateUtil; import com.viettel.campaign.utils.HibernateUtil;
import com.viettel.campaign.utils.SQLBuilder; import com.viettel.campaign.utils.SQLBuilder;
import com.viettel.campaign.web.dto.CampaignDTO; import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.CustomerCustomDTO;
import com.viettel.campaign.web.dto.FieldsToShowDTO;
import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO; import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
...@@ -571,4 +568,27 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -571,4 +568,27 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
return resultDTO; return resultDTO;
} }
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCampaignCustomerList(CampaignRequestDTO dto) {
List<CustomerListDTO> list = new ArrayList();
ResultDTO resultDTO = new ResultDTO();
Map<String, String> params = new HashMap<>();
// StringBuilder sb = new StringBuilder();
try {
String sql = SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "get-list-campaign-customer");
params.put("p_campaign_id", dto.getCampaignId());
list = namedParameterJdbcTemplate.query(sql, params, BeanPropertyRowMapper.newInstance(CustomerListDTO.class));
resultDTO.setListData(list);
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;
}
} }
...@@ -54,6 +54,8 @@ public interface CampaignService { ...@@ -54,6 +54,8 @@ public interface CampaignService {
ResultDTO getListFieldsNotShow(CampaignRequestDTO dto); ResultDTO getListFieldsNotShow(CampaignRequestDTO dto);
ResultDTO getListFieldsToShow(CampaignRequestDTO dto); ResultDTO getListFieldsToShow(CampaignRequestDTO dto);
ResultDTO getCampaignCustomerList(CampaignRequestDTO dto);
//</editor-fold> //</editor-fold>
} }
...@@ -28,7 +28,6 @@ import java.util.HashMap; ...@@ -28,7 +28,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
@Service @Service
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
...@@ -482,6 +481,12 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -482,6 +481,12 @@ public class CampaignServiceImpl implements CampaignService {
return resultDTO; return resultDTO;
} }
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCampaignCustomerList(CampaignRequestDTO dto) {
return campaignRepositoryCustom.getCampaignCustomerList(dto);
}
// 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));
......
...@@ -24,4 +24,7 @@ public class CustomerListDTO extends BaseDTO { ...@@ -24,4 +24,7 @@ public class CustomerListDTO extends BaseDTO {
private Long totalCusInList; private Long totalCusInList;
private Long totalCusInteract; private Long totalCusInteract;
private Long totalCusNotInteract; private Long totalCusNotInteract;
private Long totalCusList;
private Long totalCusCampaign;
private Long totalCusCalled;
} }
...@@ -247,4 +247,11 @@ public class CampaignController { ...@@ -247,4 +247,11 @@ public class CampaignController {
ResultDTO result = campaignExecuteService.getCustomerRecall(campaignId, customerId); ResultDTO result = campaignExecuteService.getCustomerRecall(campaignId, customerId);
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
@PostMapping("/getCampaignCustomerList")
@ResponseBody
public ResponseEntity getCampaignCustomerList(@RequestBody CampaignRequestDTO campaignRequestDTO) {
ResultDTO resultDTO = campaignService.getCampaignCustomerList(campaignRequestDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
} }
with customer_table as (
select count(a.customer_id) totalCustomer, a.customer_list_id customerListId from customer_list_mapping a
left join customer b on a.customer_id = b.customer_id
where b.status = 1
group by a.customer_list_id
),
campaign_customer_table as (
select count(a.customer_id) campaignCustomer, a.customer_list_id customerListId, a.campaign_id from campaign_customer a
where a.campaign_id = :p_campaign_id
group by a.customer_list_id, a.campaign_id
),
customer_interactive_table as (
select count(a.customer_id) campaignCustomerCalled, a.customer_list_id customerListId, a.campaign_id from campaign_customer a
where a.status <> 0 and a.campaign_id = :p_campaign_id
group by a.customer_list_id, a.campaign_id
),
customer_not_interactive_table as (
select count(a.customer_id) cusNotInteractive, a.customer_list_id customerListId, a.campaign_id from campaign_customer a
where a.status = 0 and a.campaign_id = :p_campaign_id and a.in_campaign_status = 1
group by a.customer_list_id, a.campaign_id
)
select a.customer_list_id customerListId,
a.customer_list_code customerListCode,
a.customer_list_name customerListName,
nvl(b.totalCustomer, 0) totalCusList,
nvl(c.campaignCustomer, 0) totalCusCampaign,
nvl(d.campaignCustomerCalled, 0) totalCusCalled,
nvl(e.cusNotInteractive, 0) totalCusNotInteract
from customer_list a
left join customer_table b on a.customer_list_id = b.customerListId
left join campaign_customer_table c on a.customer_list_id = c.customerListId
left join customer_interactive_table d on a.customer_list_id = d.customerListId
left join customer_not_interactive_table e on a.customer_list_id = e.customerListId
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