Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
service-campaign
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nguyen Ha
service-campaign
Commits
34663166
Commit
34663166
authored
Sep 02, 2019
by
=
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hungtt-commit add customer to campaign
parent
ee4ad316
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
18 deletions
+23
-18
src/main/java/com/viettel/campaign/service/impl/CampaignServiceImpl.java
...om/viettel/campaign/service/impl/CampaignServiceImpl.java
+23
-18
No files found.
src/main/java/com/viettel/campaign/service/impl/CampaignServiceImpl.java
View file @
34663166
...
...
@@ -2,9 +2,7 @@ package com.viettel.campaign.service.impl;
import
com.viettel.campaign.config.DataSourceQualify
;
import
com.viettel.campaign.model.ccms_full.*
;
//import com.viettel.campaign.model.UserActionLog;
import
com.viettel.campaign.repository.ccms_full.*
;
//import com.viettel.campaign.repository.UserActionLogRepository;
import
com.viettel.campaign.service.CampaignService
;
import
com.viettel.campaign.utils.BundleUtils
;
import
com.viettel.campaign.utils.Constants
;
...
...
@@ -14,7 +12,9 @@ import com.viettel.campaign.web.dto.*;
import
com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.apache.poi.ss.usermodel.*
;
import
org.apache.poi.ss.usermodel.CellStyle
;
import
org.apache.poi.ss.usermodel.Row
;
import
org.apache.poi.ss.usermodel.Sheet
;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.modelmapper.ModelMapper
;
...
...
@@ -22,12 +22,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
//import com.viettel.campaign.model.UserActionLog;
//import com.viettel.campaign.repository.UserActionLogRepository;
@Service
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
class
CampaignServiceImpl
implements
CampaignService
{
...
...
@@ -637,20 +636,26 @@ public class CampaignServiceImpl implements CampaignService {
List
<
CustomerListDTO
>
listCustomerDto
=
dto
.
getLstCustomerCampaign
();
try
{
// Thuc hien them giam khach hang
for
(
CustomerListDTO
customerListDTO
:
listCustomerDto
)
{
for
(
CustomerListDTO
customerListDTO
:
listCustomerDto
)
{
// Duyet tung customerList
if
(
customerListDTO
.
getTotalCusAddRemove
()
>
0
)
{
// Them khach hang
// Lay ra danh sach khach hang phu hop de them
List
<
Customer
>
listCustomerToAdd
=
customerRepository
.
findAllCutomerNotInCampagin
(
customerListDTO
.
getCustomerListId
(),
campaignId
);
for
(
int
i
=
0
;
i
<
customerListDTO
.
getTotalCusAddRemove
();
i
++)
{
CampaignCustomer
campaignCustomerEntity
=
new
CampaignCustomer
();
campaignCustomerEntity
.
setCampaignId
(
campaignId
);
campaignCustomerEntity
.
setCustomerId
(
listCustomerToAdd
.
get
(
i
).
getCustomerId
());
campaignCustomerEntity
.
setStatus
((
short
)
0
);
campaignCustomerEntity
.
setRecallCount
(
0L
);
campaignCustomerEntity
.
setCustomerListId
(
customerListDTO
.
getCustomerListId
());
campaignCustomerEntity
.
setCompanySiteId
(
companySiteId
);
campaignCustomerEntity
.
setInCampaignStatus
((
short
)
1
);
campaignCustomerRepository
.
save
(
campaignCustomerEntity
);
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
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
continue
;
}
else
{
CampaignCustomer
campaignCustomerEntity
=
new
CampaignCustomer
();
campaignCustomerEntity
.
setCampaignId
(
campaignId
);
campaignCustomerEntity
.
setCustomerId
(
listCustomerToAdd
.
get
(
j
).
getCustomerId
());
campaignCustomerEntity
.
setStatus
((
short
)
0
);
campaignCustomerEntity
.
setRecallCount
(
0L
);
campaignCustomerEntity
.
setCustomerListId
(
customerListDTO
.
getCustomerListId
());
campaignCustomerEntity
.
setCompanySiteId
(
companySiteId
);
campaignCustomerEntity
.
setInCampaignStatus
((
short
)
1
);
campaignCustomerRepository
.
save
(
campaignCustomerEntity
);
i
+=
1
;
}
}
}
else
if
(
customerListDTO
.
getTotalCusAddRemove
()
<
0
){
// Loai bo khach hang
long
custToDel
=
Math
.
abs
(
customerListDTO
.
getTotalCusAddRemove
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment