Commit 2199ddd4 authored by ='s avatar =

hungtt-commit fix bug search individual customer

parent 5027cb0d
......@@ -893,12 +893,19 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
Map<String, String> params = new HashMap<>();
StringBuilder sb = new StringBuilder();
try {
// sb.append(" with status_customer as (");
// sb.append(" select complete_value");
// sb.append(" from campaign_complete_code");
// sb.append(" where complete_value <> 4");
// sb.append(" and is_finish <> 1");
// sb.append(" and campaign_type = 1");
// sb.append(" and company_site_id = :p_company_site_id");
// sb.append(" ),");
sb.append(" with status_customer as (");
sb.append(" select complete_value");
sb.append(" from campaign_complete_code");
sb.append(" where complete_value <> 4");
sb.append(" and is_finish <> 1");
sb.append(" and campaign_type = 1");
sb.append(" where status = 1");
sb.append(" and complete_type = 1");
sb.append(" and company_site_id = :p_company_site_id");
sb.append(" ),");
sb.append(" count_customer as (");
......@@ -908,11 +915,11 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
sb.append(" else 0");
sb.append(" end) totalIndividual,");
sb.append(" sum(case");
sb.append(" when status = 0 then 1");
sb.append(" when status = 0 and in_campaign_status = 1 then 1");
sb.append(" else 0");
sb.append(" end) totalNotInteractive,");
sb.append(" sum(case");
sb.append(" when status in (select * from status_customer) then 1");
sb.append(" when status in (select * from status_customer) and in_campaign_status = 1 then 1");
sb.append(" else 0");
sb.append(" end) totalNotCall,");
sb.append(" sum(case");
......@@ -951,12 +958,19 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
Map<String, String> params = new HashMap<>();
StringBuilder sb = new StringBuilder();
try {
// sb.append(" with status_customer as (");
// sb.append(" select complete_value");
// sb.append(" from campaign_complete_code");
// sb.append(" where complete_value <> 4");
// sb.append(" and is_finish <> 1");
// sb.append(" and campaign_type = 1");
// sb.append(" and company_site_id = :p_company_site_id");
// sb.append(" ),");
sb.append(" with status_customer as (");
sb.append(" select complete_value");
sb.append(" from campaign_complete_code");
sb.append(" where complete_value <> 4");
sb.append(" and is_finish <> 1");
sb.append(" and campaign_type = 1");
sb.append(" where status =1");
sb.append(" and complete_type = 1");
sb.append(" and company_site_id = :p_company_site_id");
sb.append(" ),");
sb.append(" count_customer as (");
......@@ -967,11 +981,11 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
sb.append(" else 0");
sb.append(" end) totalIndividual,");
sb.append(" sum(case");
sb.append(" when status = 0 then 1");
sb.append(" when status = 0 and in_campaign_status = 1 then 1");
sb.append(" else 0");
sb.append(" end) totalNotInteractive,");
sb.append(" sum(case");
sb.append(" when status in (select * from status_customer) then 1");
sb.append(" when status in (select * from status_customer) and in_campaign_status = 1 then 1");
sb.append(" else 0");
sb.append(" end) totalNotCall");
sb.append(" from campaign_customer");
......
......@@ -1980,21 +1980,21 @@ public class CustomerServiceImpl implements CustomerService {
sb.append("select c.customer_id customerId,");
sb.append(" C.NAME name,");
sb.append(" a.mobile mobileNumber,");
sb.append(" b.Email email,");
sb.append(" cc.CONTACT mobileNumber,");
sb.append(" cc2.CONTACT email,");
sb.append(" c.customer_type customerType,");
sb.append(" C.COMPANY_NAME companyName,");
sb.append(" c.current_address currentAddress,");
sb.append(" c.Description description");
sb.append(" FROM CUSTOMER C");
sb.append(" inner join (SELECT CUSTOMER_ID, LISTAGG(CONTACT, ', ') WITHIN GROUP (ORDER BY ");
sb.append(" NULL) AS MOBILE");
sb.append(" NULL) AS CONTACT");
sb.append(" FROM CUSTOMER_CONTACT WHERE CONTACT_TYPE = 5 AND STATUS = 1 GROUP BY ");
sb.append(" CUSTOMER_ID) a on c.CUSTOMER_ID = a.CUSTOMER_ID");
sb.append(" CUSTOMER_ID) cc on c.CUSTOMER_ID = cc.CUSTOMER_ID");
sb.append(" inner join (SELECT CUSTOMER_ID, LISTAGG(CONTACT, ', ') WITHIN GROUP (ORDER BY ");
sb.append(" NULL) AS EMAIL");
sb.append(" NULL) AS CONTACT");
sb.append(" FROM CUSTOMER_CONTACT WHERE CONTACT_TYPE = 2 AND STATUS = 1 GROUP BY ");
sb.append(" CUSTOMER_ID) b on b.CUSTOMER_ID = c.CUSTOMER_ID ");
sb.append(" CUSTOMER_ID) cc2 on cc2.CUSTOMER_ID = c.CUSTOMER_ID ");
// sb.append(" INNER JOIN CUSTOMER_contact cc ON (C.CUSTOMER_ID = Cc.customer_id " +
// "and cc.status = 1 and cc.contact_type = 5)");
// sb.append(" INNER JOIN CUSTOMER_contact Cc2 ON (C.CUSTOMER_ID = Cc2.customer_id and cc2.status = 1 and cc2.contact_type = 2)");
......
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