Commit 74256bb3 authored by ='s avatar =

hungtt-commit update campaignCustomer service follow template version 1.6

parent 71b19cab
......@@ -69,7 +69,7 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom
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)" +
"WHERE CC.STATUS IN (SELECT COMPLETE_VALUE from CAMPAIGN_COMPLETE_CODE where STATUS = 1 and COMPLETE_TYPE=1)" +
"AND CC.CAMPAIGN_ID = :campaignId " +
"AND CC.COMPANY_SITE_ID = :companySiteId " +
"AND CC.CUSTOMER_LIST_ID = :customerListId", nativeQuery = true)
......@@ -78,9 +78,8 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom
@Query(value = "with status_customer as (\n" +
"select complete_value \n" +
"from campaign_complete_code\n" +
"where complete_value <> 4\n" +
" and is_finish <> 1\n" +
" and campaign_type = 1\n" +
"where status = 1\n" +
" and complete_type = 1\n" +
" and company_site_id = :p_company_site_id\n" +
")\n" +
"select * from campaign_customer\n" +
......@@ -93,6 +92,6 @@ public interface CampaignCustomerRepository extends JpaRepository<CampaignCustom
List<CampaignCustomer> findCampaignCustomersByCampaignIdAndCompanySiteIdAndCustomerIdAndInCampaignStatus(Long campaignId, Long companySiteId, Long customerId, Short inCampaingStatus);
@Query(value = "select complete_value from campaign_complete_code where status = 1 and is_finish = 0 and is_recall = 0", nativeQuery = true)
@Query(value = "select complete_value from campaign_complete_code where status = 1 and complete_type = 1", nativeQuery = true)
List<Short> getStatus();
}
......@@ -624,7 +624,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
"),\n" +
"customer_interactive_table as (\n" +
" select count(a.customer_id) campaignCustomerCalled, a.customer_list_id customerListId, a.campaign_id from campaign_customer a\n" +
" where a.status <> 0 and a.campaign_id = :p_campaign_id and in_campaign_status = 1\n" +
" where a.status <> 0 and a.campaign_id = :p_campaign_id\n" +
" group by a.customer_list_id, a.campaign_id\n" +
"),\n" +
"customer_not_interactive_table as (\n" +
......@@ -833,7 +833,7 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
"),\n" +
"customer_filter_table as (\n" +
" select count(a.customer_id) customerFilter, a.customer_list_id customerListId from campaign_customer a\n" +
" where a.campaign_id = :p_campaign_id\n" +
" where a.campaign_id = :p_campaign_id and a.in_campaign_status = 1\n" +
" group by a.customer_list_id\n" +
"),\n" +
"data_temp as (\n" +
......
......@@ -674,7 +674,12 @@ public class CampaignServiceImpl implements CampaignService {
// Lay ra danh sach khach hang can loai bo
List<CampaignCustomer> listCustomerToDelete = campaignCustomerRepository.findListCustomerToDel(companySiteId, campaignId, customerListDTO.getCustomerListId());
for (int j = 0; j < custToDel; j++) {
campaignCustomerRepository.delete(listCustomerToDelete.get(j));
if (listCustomerToDelete.get(j).getStatus() == 0) {
campaignCustomerRepository.delete(listCustomerToDelete.get(j));
} else {
listCustomerToDelete.get(j).setInCampaignStatus((short) 0);
campaignCustomerRepository.save(listCustomerToDelete.get(j));
}
}
}
}
......
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