Commit 7e6a4c2d authored by ='s avatar =

hungtt-commit fix bug add customer to campaign

parent fbeac132
......@@ -37,6 +37,8 @@ public interface CampaignRepositoryCustom {
ResultDTO getCustomerListInformation(CampaignRequestDTO dto);
ResultDTO getCountIndividualOnList(CampaignRequestDTO dto);
List<ApParamDTO> getConnectStatus(Long companySiteId);
//</editor-fold>
}
......@@ -997,6 +997,42 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
return resultDTO;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCountIndividualOnList(CampaignRequestDTO dto) {
List<CampaignInformationDTO> list = new ArrayList();
ResultDTO resultDTO = new ResultDTO();
Map<String, String> params = new HashMap<>();
StringBuilder sb = new StringBuilder();
try {
sb.append(" with customer_temp as (");
sb.append(" select c.customer_id, clm.customer_list_id");
sb.append(" from customer c");
sb.append(" inner join customer_list_mapping clm on c.customer_id = clm.customer_id");
sb.append(" where clm.customer_list_id in (select distinct cc.customer_list_id from campaign_customerlist cc where cc.campaign_id = :p_campaign_id and cc.company_site_id = :p_company_site_id)");
sb.append(" )");
sb.append(" select count(cc.customer_id) totalIndividual, c.customer_list_id customerListId");
sb.append(" from campaign_customer cc");
sb.append(" inner join customer_temp c on c.customer_id = cc.customer_id");
sb.append(" where campaign_id = :p_campaign_id");
sb.append(" and cc.customer_list_id is null");
sb.append(" and cc.in_campaign_status = 1");
sb.append(" and cc.customer_id in (select customer_id from customer_temp)");
sb.append(" group by c.customer_list_id");
params.put("p_campaign_id", dto.getCampaignId());
params.put("p_company_site_id", dto.getCompanySiteId());
list = namedParameterJdbcTemplate.query(sb.toString(), params, BeanPropertyRowMapper.newInstance(CampaignInformationDTO.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;
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public List<ApParamDTO> getConnectStatus(Long companySiteId) {
......
......@@ -70,6 +70,8 @@ public interface CampaignService {
ResultDTO getCustomerListInformation(CampaignRequestDTO dto);
ResultDTO getCountIndividualOnList(CampaignRequestDTO dto);
ResultDTO saveCustomerCampaign(CampaignRequestDTO dto);
ResultDTO getConnectStatus(Long companySiteId);
......
......@@ -627,6 +627,12 @@ public class CampaignServiceImpl implements CampaignService {
return campaignRepositoryCustom.getCustomerListInformation(dto);
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO getCountIndividualOnList(CampaignRequestDTO dto) {
return campaignRepositoryCustom.getCountIndividualOnList(dto);
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO saveCustomerCampaign(CampaignRequestDTO dto) {
......
......@@ -15,6 +15,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
......@@ -205,6 +206,13 @@ public class CampaignController {
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@PostMapping("/getCountIndividualOnList")
@ResponseBody
public ResponseEntity getCountIndividualOnList(@RequestBody CampaignRequestDTO campaignRequestDTO) {
ResultDTO resultDTO = campaignService.getCountIndividualOnList(campaignRequestDTO);
return new ResponseEntity<>(resultDTO, HttpStatus.OK);
}
@PostMapping("/saveCustomerCampaign")
@ResponseBody
public ResponseEntity saveCustomerCampaign(@RequestBody CampaignRequestDTO campaignRequestDTO) {
......
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