Commit 846919de authored by đinh thị đầm's avatar đinh thị đầm

edit CampaignCfgRepository

parents e5d05c7f a3c9b61d
......@@ -13,6 +13,8 @@ import java.util.List;
@Repository
public interface CampaignCfgRepository extends JpaRepository<CampaignCfg, Long> {
@Query("select c from CampaignCfg c where c.campaignCompleteCodeId in (:p_ids) and c.completeValue =:p_campaign_cfg_id and c.companySiteId=:p_company_site_id")
List<CampaignCfg> findAllCampaignCfg(@Param("p_ids") List<Long> p_ids, @Param("p_campaign_cfg_id") Long p_campaign_cfg_id, @Param("p_company_site_id") Long p_company_site_id);
@Query("FROM CampaignCfg u WHERE u.status = 1 AND u.completeValue NOT IN (1,2,3,4)")
Page<CampaignCfg> findAll(Pageable pageable);
......
......@@ -314,16 +314,12 @@ public class AgentsServiceImpl implements AgentsService {
sqlStrBuilder.append(" AND vu.COMPANY_SITE_ID = :p_company_site_id");
sqlStrBuilder.append(" AND vu.STATUS = 1");
sqlStrBuilder.append(" AND r.ROLE_CODE IN ('AGENT', 'SUPERVISOR')");
sqlStrBuilder.append(" AND vu.USER_ID NOT IN (SELECT vu.USER_ID userId");
sqlStrBuilder.append(" FROM VSA_USERS vu");
sqlStrBuilder.append(" LEFT JOIN CAMPAIGN_AGENT ca on vu.USER_ID = ca.AGENT_ID");
sqlStrBuilder.append(" INNER JOIN USER_ROLE ur on vu.USER_ID = ur.USER_ID");
sqlStrBuilder.append(" INNER JOIN ROLE r on ur.ROLE_ID = r.ROLE_ID");
sqlStrBuilder.append(" AND vu.USER_ID NOT IN (SELECT vu.USER_ID");
sqlStrBuilder.append(" FROM CAMPAIGN_AGENT ca");
sqlStrBuilder.append(" INNER JOIN VSA_USERS vu ON ca.AGENT_ID = vu.USER_ID");
sqlStrBuilder.append(" WHERE 1 = 1");
sqlStrBuilder.append(" AND vu.COMPANY_SITE_ID = :p_company_site_id");
sqlStrBuilder.append(" AND vu.STATUS = 1");
sqlStrBuilder.append(" AND ca.COMPANY_SITE_ID = :p_company_site_id");
sqlStrBuilder.append(" AND ca.CAMPAIGN_ID = :p_campaign_id");
sqlStrBuilder.append(" AND r.ROLE_CODE IN ('AGENT', 'SUPERVISOR'))");
if (!DataUtil.isNullOrEmpty(userName)) {
sqlStrBuilder.append(" AND UPPER(vu.USER_NAME) LIKE UPPER(:p_user_name)");
......
......@@ -268,10 +268,16 @@ public class CampaignCfgServiceImpl implements CampaignCfgService {
ResultDTO resultDTO = new ResultDTO();
try {
if (completeCodeDTO != null) {
if (completeCodeRepository.findAllCampaignCfg(completeCodeDTO.getListId(), completeCodeDTO.getCampaignCompleteCodeID(), completeCodeDTO.getCompanySiteId()).size() > 0) {
completeCodeRepository.deletedList(completeCodeDTO.getListId(), completeCodeDTO.getCompanySiteId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
......
......@@ -392,14 +392,22 @@ public class CustomerServiceImpl implements CustomerService {
@Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO deleteCustomer(CustomerRequestDTO customerRequestDTO) {
ResultDTO resultDTO = new ResultDTO();
List<Long> listId = new ArrayList<>();
listId.add(customerRequestDTO.getCustomerId());
try {
if (customerRequestDTO != null) {
// delete
if (customerListMappingRepository.findAllCustomerListMapping(listId, customerRequestDTO.getCustomerListId(), customerRequestDTO.getCompanySiteId()).size() > 0) {
// delete
// customerRepository.deleteById(customerDTO.getCustomerId());
customerListMappingRepository.deleteMappingByCustomerId(customerRequestDTO.getCustomerId(), customerRequestDTO.getCustomerListId(), customerRequestDTO.getCompanySiteId());
customerListMappingRepository.deleteMappingByCustomerId(customerRequestDTO.getCustomerId(), customerRequestDTO.getCustomerListId(), customerRequestDTO.getCompanySiteId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
......
......@@ -10,4 +10,5 @@ public class CampaignCfgRequestDTO {
List<Long> listId;
Long companySiteId;
Long campaignCompleteCodeID;
String completeValue;
}
......@@ -77,9 +77,7 @@ public class CustomerController {
@ResponseBody
public ResultDTO deleteCustomer(@RequestBody @Valid CustomerRequestDTO customerRequestDTO) {
ResultDTO resultDTO = new ResultDTO();
if (customerRequestDTO != null) {
resultDTO = customerService.deleteCustomer(customerRequestDTO);
}
resultDTO = customerService.deleteCustomer(customerRequestDTO);
return resultDTO;
}
......
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