Commit 17f6c980 authored by Vu Duy Anh's avatar Vu Duy Anh

anhvd accetp merge

parents 9a32f07d 38eaf724
...@@ -12,5 +12,5 @@ public interface CustomerContactRepository extends JpaRepository<CustomerContact ...@@ -12,5 +12,5 @@ public interface CustomerContactRepository extends JpaRepository<CustomerContact
@Query("FROM CustomerContact WHERE status = 1 AND customerId = :customerId AND contactType = :contactType AND (contact IS NULL OR UPPER(contact) LIKE UPPER(concat('%', :contact, '%')))") @Query("FROM CustomerContact WHERE status = 1 AND customerId = :customerId AND contactType = :contactType AND (contact IS NULL OR UPPER(contact) LIKE UPPER(concat('%', :contact, '%')))")
List<CustomerContact> findByCustomerIdAndAndContactTypeAndContact(@Param("customerId") Long customerId, @Param("contactType") Short contactType, @Param("contact") String contact, Pageable pageable); List<CustomerContact> findByCustomerIdAndAndContactTypeAndContact(@Param("customerId") Long customerId, @Param("contactType") Short contactType, @Param("contact") String contact, Pageable pageable);
CustomerContact findCustomerContactByContactEquals(String contact); List<CustomerContact> findCustomerContactsByContactEquals(String contact);
} }
...@@ -39,6 +39,6 @@ public interface CustomerRepository extends JpaRepository<Customer, Long> { ...@@ -39,6 +39,6 @@ public interface CustomerRepository extends JpaRepository<Customer, Long> {
@Query(value = "select * from customer a\n" + @Query(value = "select * from customer a\n" +
"left join customer_list_mapping b on a.customer_id = b.customer_id\n" + "left join customer_list_mapping b on a.customer_id = b.customer_id\n" +
"where b.customer_list_id = :p_customer_list_id\n" + "where b.customer_list_id = :p_customer_list_id\n" +
" and a.customer_id not in (select cc.customer_id from campaign_customer cc where cc.campaign_id = :p_campaign_id and cc.customer_list_id = :p_customer_list_id)", nativeQuery = true) " and a.customer_id not in (select cc.customer_id from campaign_customer cc where cc.campaign_id = :p_campaign_id and cc.customer_list_id = :p_customer_list_id and cc.in_campaign_status <> 0)", nativeQuery = true)
List<Customer> findAllCutomerNotInCampagin(@Param("p_customer_list_id") Long customerListId, @Param("p_campaign_id") Long campaignId); List<Customer> findAllCutomerNotInCampagin(@Param("p_customer_list_id") Long customerListId, @Param("p_campaign_id") Long campaignId);
} }
...@@ -621,12 +621,12 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -621,12 +621,12 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
"),\n" + "),\n" +
"campaign_customer_table as (\n" + "campaign_customer_table as (\n" +
" select count(a.customer_id) campaignCustomer, a.customer_list_id customerListId, a.campaign_id from campaign_customer a\n" + " select count(a.customer_id) campaignCustomer, a.customer_list_id customerListId, a.campaign_id from campaign_customer a\n" +
" where a.campaign_id = :p_campaign_id\n" + " where a.campaign_id = :p_campaign_id and in_campaign_status = 1\n" +
" group by a.customer_list_id, a.campaign_id\n" + " group by a.customer_list_id, a.campaign_id\n" +
"),\n" + "),\n" +
"customer_interactive_table as (\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" + " 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\n" + " where a.status <> 0 and a.campaign_id = :p_campaign_id and in_campaign_status = 1\n" +
" group by a.customer_list_id, a.campaign_id\n" + " group by a.customer_list_id, a.campaign_id\n" +
"),\n" + "),\n" +
"customer_not_interactive_table as (\n" + "customer_not_interactive_table as (\n" +
......
...@@ -640,9 +640,15 @@ public class CampaignServiceImpl implements CampaignService { ...@@ -640,9 +640,15 @@ public class CampaignServiceImpl implements CampaignService {
if (customerListDTO.getTotalCusAddRemove() > 0) { // Them khach hang if (customerListDTO.getTotalCusAddRemove() > 0) { // Them khach hang
// Lay ra danh sach khach hang phu hop de them // Lay ra danh sach khach hang phu hop de them
List<Customer> listCustomerToAdd = customerRepository.findAllCutomerNotInCampagin(customerListDTO.getCustomerListId(), campaignId); List<Customer> listCustomerToAdd = customerRepository.findAllCutomerNotInCampagin(customerListDTO.getCustomerListId(), campaignId);
int numOfCusInList = listCustomerToAdd.size(); // Số khách hàng còn lại của chiến dịch chưa đc add vào campaign int numOfCusInList = listCustomerToAdd.size(); // Số khách hàng còn lại của chiến dịch chưa đc add vào campaign hoặc đã add nhưng in_campaign_status = 0
for (int i = 0, j = 0; (i < customerListDTO.getTotalCusAddRemove() && j < numOfCusInList); j++) { for (int i = 0, j = 0; (i < customerListDTO.getTotalCusAddRemove() && j < numOfCusInList); j++) {
if (campaignCustomerRepository.findCampaignCustomerByCampaignIdAndCompanySiteIdAndCustomerId(campaignId, companySiteId, listCustomerToAdd.get(j).getCustomerId()) != null) { // Khach hang đã đc chèn vào campaign theo individual CampaignCustomer tempEntity = campaignCustomerRepository.findCampaignCustomerByCampaignIdAndCompanySiteIdAndCustomerId(campaignId, companySiteId, listCustomerToAdd.get(j).getCustomerId());
if (tempEntity != null) { // Khach hang đã đc chèn vào campaign theo individual / hoặc in_campaign_status = 0
if ((tempEntity.getCustomerListId() == customerListDTO.getCustomerListId()) && tempEntity.getInCampaignStatus() == 0) {
tempEntity.setInCampaignStatus((short) 1);
campaignCustomerRepository.save(tempEntity);
i+=1;
}
continue; continue;
} else { } else {
CampaignCustomer campaignCustomerEntity = new CampaignCustomer(); CampaignCustomer campaignCustomerEntity = new CampaignCustomer();
......
...@@ -1067,7 +1067,13 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1067,7 +1067,13 @@ public class CustomerServiceImpl implements CustomerService {
sb.append(validateLength(BundleUtils.getLangString("customer.email", locale).split("#")[0], rawDataList.get(i)[4].toString(), 50, locale)); sb.append(validateLength(BundleUtils.getLangString("customer.email", locale).split("#")[0], rawDataList.get(i)[4].toString(), 50, locale));
sb.append(str); sb.append(str);
} else { } else {
sb.append(BundleUtils.getLangString("customer.invalidCustomer", locale)); if (rawDataList.get(i).length > 2 && rawDataList.get(i)[2] == null) {
sb.append(BundleUtils.getLangString("customer.mainPhoneRequired", locale));
} else if (rawDataList.get(i).length > 3 && rawDataList.get(i)[3] == null) {
sb.append(BundleUtils.getLangString("customer.secondPhoneRequired", locale));
} else if (rawDataList.get(i).length > 4 && rawDataList.get(i)[4] == null) {
sb.append(BundleUtils.getLangString("customer.emailRequired", locale));
}
} }
if (rawDataList.get(i).length > 5 && rawDataList.get(i)[5] != null) { if (rawDataList.get(i).length > 5 && rawDataList.get(i)[5] != null) {
sb.append(validateLength(BundleUtils.getLangString("customer.address", locale).split("#")[0], rawDataList.get(i)[5].toString(), 500, locale)); sb.append(validateLength(BundleUtils.getLangString("customer.address", locale).split("#")[0], rawDataList.get(i)[5].toString(), 500, locale));
...@@ -1105,11 +1111,11 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1105,11 +1111,11 @@ public class CustomerServiceImpl implements CustomerService {
if (failedCount == 0) { if (failedCount == 0) {
for (int i = 0; i < rawDataList.size(); i++) { for (int i = 0; i < rawDataList.size(); i++) {
Customer c = new Customer(); Customer c = new Customer();
c.setName(rawDataList.get(i)[1].toString()); c.setName(rawDataList.get(i)[1].toString().trim());
c.setSiteId(userSession.getSiteId()); c.setSiteId(userSession.getSiteId());
c.setCode(null); c.setCode(null);
c.setDescription(rawDataList.get(i)[8].toString()); c.setDescription(rawDataList.get(i)[8].toString().trim());
c.setCompanyName(rawDataList.get(i)[7].toString()); c.setCompanyName(rawDataList.get(i)[7].toString().trim());
c.setCustomerImg(null); c.setCustomerImg(null);
c.setCreateDate(new Date()); c.setCreateDate(new Date());
c.setUpdateDate(null); c.setUpdateDate(null);
...@@ -1117,14 +1123,14 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1117,14 +1123,14 @@ public class CustomerServiceImpl implements CustomerService {
c.setCreateBy(userSession.getUserName()); c.setCreateBy(userSession.getUserName());
c.setUpdateBy(null); c.setUpdateBy(null);
c.setGender((short) 1); c.setGender((short) 1);
c.setCurrentAddress(rawDataList.get(i)[5].toString()); c.setCurrentAddress(rawDataList.get(i)[5].toString().trim());
// c.setPlaceOfBirth(); // c.setPlaceOfBirth();
// c.setDateOfBirth(); // c.setDateOfBirth();
c.setMobileNumber(null); c.setMobileNumber(null);
c.setEmail(null); c.setEmail(null);
c.setUserName(null); c.setUserName(null);
c.setAreaCode(null); c.setAreaCode(null);
switch (rawDataList.get(i)[6].toString()) { switch (rawDataList.get(i)[6].toString().trim()) {
case "VIP": case "VIP":
c.setCustomerType(2L); c.setCustomerType(2L);
break; break;
...@@ -1135,17 +1141,17 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1135,17 +1141,17 @@ public class CustomerServiceImpl implements CustomerService {
c.setCustomerType(1L); c.setCustomerType(1L);
break; break;
} }
if (rawDataList.get(i)[9].toString().equals(BundleUtils.getLangString("customer.yes", locale))) { if (rawDataList.get(i)[9].toString().trim().equals(BundleUtils.getLangString("customer.yes", locale))) {
c.setCallAllowed(1L); c.setCallAllowed(1L);
} else { } else {
c.setCallAllowed(0L); c.setCallAllowed(0L);
} }
if (rawDataList.get(i)[10].toString().equals(BundleUtils.getLangString("customer.yes", locale))) { if (rawDataList.get(i)[10].toString().trim().equals(BundleUtils.getLangString("customer.yes", locale))) {
c.setEmailAllowed(1L); c.setEmailAllowed(1L);
} else { } else {
c.setEmailAllowed(0L); c.setEmailAllowed(0L);
} }
if (rawDataList.get(i)[11].toString().equals(BundleUtils.getLangString("customer.yes", locale))) { if (rawDataList.get(i)[11].toString().trim().equals(BundleUtils.getLangString("customer.yes", locale))) {
c.setSmsAllowed(1L); c.setSmsAllowed(1L);
} else { } else {
c.setSmsAllowed(0L); c.setSmsAllowed(0L);
...@@ -1153,13 +1159,13 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1153,13 +1159,13 @@ public class CustomerServiceImpl implements CustomerService {
c.setIpccStatus("active"); c.setIpccStatus("active");
Customer saved = customerRepository.save(c); Customer saved = customerRepository.save(c);
if (rawDataList.get(i).length > 2 && rawDataList.get(i)[2] != null) { if (rawDataList.get(i).length > 2 && rawDataList.get(i)[2] != null) {
String[] mainPhone = rawDataList.get(i)[2].toString().split(";"); String[] mainPhone = rawDataList.get(i)[2].toString().trim().split(";");
for (int j = 0; j < mainPhone.length; j++) { for (int j = 0; j < mainPhone.length; j++) {
CustomerContact cc = new CustomerContact(); CustomerContact cc = new CustomerContact();
cc.setCustomerId(saved.getCustomerId()); cc.setCustomerId(saved.getCustomerId());
cc.setSiteId(userSession.getSiteId()); cc.setSiteId(userSession.getSiteId());
cc.setContactType((short) 5); cc.setContactType((short) 5);
cc.setContact(mainPhone[j]); cc.setContact(mainPhone[j].trim());
cc.setIsDirectLine((short) 1); cc.setIsDirectLine((short) 1);
cc.setStatus((short) 1); cc.setStatus((short) 1);
cc.setCreateDate(new Date()); cc.setCreateDate(new Date());
...@@ -1170,13 +1176,13 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1170,13 +1176,13 @@ public class CustomerServiceImpl implements CustomerService {
} }
} }
if (rawDataList.get(i).length > 3 && rawDataList.get(i)[3] != null) { if (rawDataList.get(i).length > 3 && rawDataList.get(i)[3] != null) {
String[] subPhone = rawDataList.get(i)[3].toString().split(";"); String[] subPhone = rawDataList.get(i)[3].toString().trim().split(";");
for (int j = 0; j < subPhone.length; j++) { for (int j = 0; j < subPhone.length; j++) {
CustomerContact cc = new CustomerContact(); CustomerContact cc = new CustomerContact();
cc.setCustomerId(saved.getCustomerId()); cc.setCustomerId(saved.getCustomerId());
cc.setSiteId(userSession.getSiteId()); cc.setSiteId(userSession.getSiteId());
cc.setContactType((short) 5); cc.setContactType((short) 5);
cc.setContact(subPhone[j]); cc.setContact(subPhone[j].trim());
cc.setIsDirectLine((short) 0); cc.setIsDirectLine((short) 0);
cc.setStatus((short) 1); cc.setStatus((short) 1);
cc.setCreateDate(new Date()); cc.setCreateDate(new Date());
...@@ -1193,7 +1199,7 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1193,7 +1199,7 @@ public class CustomerServiceImpl implements CustomerService {
cc.setCustomerId(saved.getCustomerId()); cc.setCustomerId(saved.getCustomerId());
cc.setSiteId(userSession.getSiteId()); cc.setSiteId(userSession.getSiteId());
cc.setContactType((short) 2); cc.setContactType((short) 2);
cc.setContact(email[j]); cc.setContact(email[j].trim());
cc.setIsDirectLine((short) 1); cc.setIsDirectLine((short) 1);
cc.setStatus((short) 1); cc.setStatus((short) 1);
cc.setCreateDate(new Date()); cc.setCreateDate(new Date());
...@@ -1211,25 +1217,25 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1211,25 +1217,25 @@ public class CustomerServiceImpl implements CustomerService {
switch (dynamicHeader.get(j).getType()) { switch (dynamicHeader.get(j).getType()) {
case "combobox": case "combobox":
CustomizeFieldOptionValue cfov = CustomizeFieldOptionValue cfov =
customizeFieldOptionValueRepository.findCustomizeFieldOptionValueByNameEqualsAndStatus(rawDataList.get(i)[12 + j].toString(), 1L); customizeFieldOptionValueRepository.findCustomizeFieldOptionValueByNameEqualsAndStatus(rawDataList.get(i)[12 + j].toString().trim(), 1L);
cfo.setFieldOptionValueId(cfov.getFieldOptionValueId()); cfo.setFieldOptionValueId(cfov.getFieldOptionValueId());
break; break;
case "checkbox": case "checkbox":
if (rawDataList.get(i)[12 + j].toString().equals(BundleUtils.getLangString("customer.yes", locale))) { if (rawDataList.get(i)[12 + j].toString().trim().equals(BundleUtils.getLangString("customer.yes", locale))) {
cfo.setValueCheckbox(1L); cfo.setValueCheckbox(1L);
} else { } else {
cfo.setValueCheckbox(0L); cfo.setValueCheckbox(0L);
} }
break; break;
case "date": case "date":
Date date = dateFormat.parse(rawDataList.get(i)[12 + j].toString()); Date date = dateFormat.parse(rawDataList.get(i)[12 + j].toString().trim());
cfo.setValueDate(date); cfo.setValueDate(date);
break; break;
case "number": case "number":
cfo.setValueNumber((Long) rawDataList.get(i)[12 + j]); cfo.setValueNumber(Long.parseLong(rawDataList.get(i)[12 + j].toString().trim()));
break; break;
default: default:
cfo.setValueText(rawDataList.get(i)[12 + j].toString()); cfo.setValueText(rawDataList.get(i)[12 + j].toString().trim());
break; break;
} }
} }
...@@ -1280,8 +1286,8 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1280,8 +1286,8 @@ public class CustomerServiceImpl implements CustomerService {
result = BundleUtils.getLangString("customer.phoneMax50", locale); result = BundleUtils.getLangString("customer.phoneMax50", locale);
} }
for (int i = 0; i < arr.length; i++) { for (int i = 0; i < arr.length; i++) {
CustomerContact cc = customerContactRepository.findCustomerContactByContactEquals(arr[i]); List<CustomerContact> contactList = customerContactRepository.findCustomerContactsByContactEquals(arr[i]);
if (cc != null) { if (contactList.size() != 0) {
return result.concat(BundleUtils.getLangString("customer.phoneExists", locale)); return result.concat(BundleUtils.getLangString("customer.phoneExists", locale));
} }
} }
...@@ -1292,8 +1298,8 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -1292,8 +1298,8 @@ public class CustomerServiceImpl implements CustomerService {
String result = ""; String result = "";
String[] arr = str.split(";"); String[] arr = str.split(";");
for (int i = 0; i < arr.length; i++) { for (int i = 0; i < arr.length; i++) {
CustomerContact cc = customerContactRepository.findCustomerContactByContactEquals(arr[i]); List<CustomerContact> contactList = customerContactRepository.findCustomerContactsByContactEquals(arr[i]);
if (cc != null) { if (contactList.size() != 0) {
return result.concat(BundleUtils.getLangString("customer.emailExists", locale)); return result.concat(BundleUtils.getLangString("customer.emailExists", locale));
} }
} }
......
...@@ -6,7 +6,6 @@ import com.viettel.campaign.model.ccms_full.CustomizeFields; ...@@ -6,7 +6,6 @@ import com.viettel.campaign.model.ccms_full.CustomizeFields;
import com.viettel.campaign.repository.ccms_full.CustomerQueryRepository; import com.viettel.campaign.repository.ccms_full.CustomerQueryRepository;
import com.viettel.campaign.service.CustomerService; import com.viettel.campaign.service.CustomerService;
import com.viettel.campaign.utils.Config; import com.viettel.campaign.utils.Config;
import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.utils.RedisUtil; import com.viettel.campaign.utils.RedisUtil;
import com.viettel.campaign.web.dto.*; import com.viettel.campaign.web.dto.*;
import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO; import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO;
...@@ -33,7 +32,6 @@ import java.text.SimpleDateFormat; ...@@ -33,7 +32,6 @@ import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
@Controller @Controller
@RequestMapping("/ipcc/customer") @RequestMapping("/ipcc/customer")
...@@ -202,9 +200,9 @@ public class CustomerController { ...@@ -202,9 +200,9 @@ public class CustomerController {
if (file.isEmpty()) { if (file.isEmpty()) {
return new ResponseEntity<>("file-empty", HttpStatus.OK); return new ResponseEntity<>("file-empty", HttpStatus.OK);
} }
if (!Objects.equals(FilenameUtils.getExtension(file.getOriginalFilename()), Constants.FileType.xlsx)) { // if (!Objects.equals(FilenameUtils.getExtension(file.getOriginalFilename()), Constants.FileType.xlsx)) {
return new ResponseEntity<>("template-invalid", HttpStatus.OK); // return new ResponseEntity<>("template-invalid", HttpStatus.OK);
} // }
String path = saveUploadFile(file); String path = saveUploadFile(file);
List<CustomizeFields> dynamicHeaders = customerService.getDynamicHeader(userSession.getCompanySiteId()); List<CustomizeFields> dynamicHeaders = customerService.getDynamicHeader(userSession.getCompanySiteId());
Map<String, Object> map = customerService.readAndValidateCustomer(path, dynamicHeaders, userSession, Long.parseLong(customerListId)); Map<String, Object> map = customerService.readAndValidateCustomer(path, dynamicHeaders, userSession, Long.parseLong(customerListId));
......
...@@ -90,7 +90,6 @@ customer.not = No ...@@ -90,7 +90,6 @@ customer.not = No
customer.noData = Template empty customer.noData = Template empty
customer.nameRequired = Full name required; customer.nameRequired = Full name required;
customer.emailMax50 = Email must less than 50 character; customer.emailMax50 = Email must less than 50 character;
customer.invalidCustomer = All 3 fields Main phone, second phone and email must not null;
customer.importSuccess = Import Successful customer.importSuccess = Import Successful
customer.importFailed = Import Failed customer.importFailed = Import Failed
customer.errorValidate = Error while validating customer.errorValidate = Error while validating
......
...@@ -92,7 +92,9 @@ customer.not = Không ...@@ -92,7 +92,9 @@ customer.not = Không
customer.noData = Template không có dữ liệu customer.noData = Template không có dữ liệu
customer.nameRequired = Họ và tên không được để trống; customer.nameRequired = Họ và tên không được để trống;
customer.emailMax50 = Email không được quá 50 kí tự; customer.emailMax50 = Email không được quá 50 kí tự;
customer.invalidCustomer = Cả 3 thông tin số điện thoại chính, số điện phụ và email không được để trống; customer.mainPhoneRequired=Số điện thoại chính không được để trống
customer.secondPhoneRequired=Số điện thoại phụ không được để trống
customer.emailRequired=Số điện thoại email không được để trống
customer.importSuccess = Import dữ liệu thành công customer.importSuccess = Import dữ liệu thành công
customer.importFailed = Import dữ liệu thất bại customer.importFailed = Import dữ liệu thất bại
customer.errorValidate = Validate dữ liệu lỗi customer.errorValidate = Validate dữ liệu lỗi
......
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