| Line 26... |
Line 26... |
| 26 |
import com.spice.profitmandi.dao.entity.dtr.Retailer;
|
26 |
import com.spice.profitmandi.dao.entity.dtr.Retailer;
|
| 27 |
import com.spice.profitmandi.dao.entity.dtr.RetailerRegisteredAddress;
|
27 |
import com.spice.profitmandi.dao.entity.dtr.RetailerRegisteredAddress;
|
| 28 |
import com.spice.profitmandi.dao.entity.dtr.Shop;
|
28 |
import com.spice.profitmandi.dao.entity.dtr.Shop;
|
| 29 |
import com.spice.profitmandi.dao.entity.dtr.ShopAddress;
|
29 |
import com.spice.profitmandi.dao.entity.dtr.ShopAddress;
|
| 30 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
30 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
| 31 |
import com.spice.profitmandi.dao.entity.dtr.UserAccounts;
|
31 |
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
|
| 32 |
import com.spice.profitmandi.dao.entity.dtr.UserRole;
|
32 |
import com.spice.profitmandi.dao.entity.dtr.UserRole;
|
| 33 |
import com.spice.profitmandi.dao.entity.user.Address;
|
33 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| 34 |
import com.spice.profitmandi.dao.entity.user.Cart;
|
34 |
import com.spice.profitmandi.dao.entity.user.Cart;
|
| 35 |
import com.spice.profitmandi.dao.entity.user.Counter;
|
35 |
import com.spice.profitmandi.dao.entity.user.Counter;
|
| 36 |
import com.spice.profitmandi.dao.entity.user.PrivateDealUser;
|
36 |
import com.spice.profitmandi.dao.entity.user.PrivateDealUser;
|
| Line 160... |
Line 160... |
| 160 |
mongoClient.updateColumnsById(entry.getValue(), entry.getKey());
|
160 |
mongoClient.updateColumnsById(entry.getValue(), entry.getKey());
|
| 161 |
}
|
161 |
}
|
| 162 |
|
162 |
|
| 163 |
}
|
163 |
}
|
| 164 |
|
164 |
|
| 165 |
private Set<Integer> toRetailerIds(List<UserAccounts> userAccounts){
|
165 |
private Set<Integer> toRetailerIds(List<UserAccount> userAccounts){
|
| 166 |
Set<Integer> retailerIds = new HashSet<>();
|
166 |
Set<Integer> retailerIds = new HashSet<>();
|
| 167 |
for(UserAccounts saholicUserAccount : userAccounts){
|
167 |
for(UserAccount saholicUserAccount : userAccounts){
|
| 168 |
int retailerId = Integer.parseInt(saholicUserAccount.getAccount_key());
|
168 |
int retailerId = saholicUserAccount.getAccountKey();
|
| 169 |
retailerIds.add(retailerId);
|
169 |
retailerIds.add(retailerId);
|
| 170 |
}
|
170 |
}
|
| 171 |
return retailerIds;
|
171 |
return retailerIds;
|
| 172 |
}
|
172 |
}
|
| 173 |
|
173 |
|
| 174 |
private Set<Integer> toUserIds(List<UserAccounts> userAccounts, Set<Integer> retailerIds){
|
174 |
private Set<Integer> toUserIds(List<UserAccount> userAccounts, Set<Integer> retailerIds){
|
| 175 |
Set<Integer> userIds = new HashSet<>();
|
175 |
Set<Integer> userIds = new HashSet<>();
|
| 176 |
for(UserAccounts saholicUserAccount : userAccounts){
|
176 |
for(UserAccount saholicUserAccount : userAccounts){
|
| 177 |
int retailerId = Integer.parseInt(saholicUserAccount.getAccount_key());
|
177 |
int retailerId = saholicUserAccount.getAccountKey();
|
| 178 |
if(retailerIds.contains(retailerId)){
|
178 |
if(retailerIds.contains(retailerId)){
|
| 179 |
userIds.add(saholicUserAccount.getUser_id());
|
179 |
userIds.add(saholicUserAccount.getUserId());
|
| 180 |
}
|
180 |
}
|
| 181 |
}
|
181 |
}
|
| 182 |
return userIds;
|
182 |
return userIds;
|
| 183 |
}
|
183 |
}
|
| 184 |
|
184 |
|
| 185 |
public void migrateUserToRetailer(){
|
185 |
public void migrateUserToRetailer(){
|
| 186 |
|
186 |
|
| 187 |
List<UserAccounts> saholicUserAccounts = userAccountRepository.selectAllSaholicByUserIds(new HashSet<>(userRepository.selectIdAll()));
|
187 |
List<UserAccount> saholicUserAccounts = userAccountRepository.selectAllSaholicByUserIds(new HashSet<>(userRepository.selectIdAll()));
|
| 188 |
if(saholicUserAccounts.isEmpty()){
|
188 |
if(saholicUserAccounts.isEmpty()){
|
| 189 |
return;
|
189 |
return;
|
| 190 |
}
|
190 |
}
|
| 191 |
Set<Integer> retailerIds = this.toRetailerIds(saholicUserAccounts);
|
191 |
Set<Integer> retailerIds = this.toRetailerIds(saholicUserAccounts);
|
| 192 |
List<Integer> foundRetailerIds = retailerRepository.selectIdsByIds(retailerIds);
|
192 |
List<Integer> foundRetailerIds = retailerRepository.selectIdsByIds(retailerIds);
|
| Line 361... |
Line 361... |
| 361 |
shopAddress.setAddressId(retailerAddress.getId());
|
361 |
shopAddress.setAddressId(retailerAddress.getId());
|
| 362 |
shopAddress.setShopId(shop.getId());
|
362 |
shopAddress.setShopId(shop.getId());
|
| 363 |
shopAddressRepository.persist(shopAddress);
|
363 |
shopAddressRepository.persist(shopAddress);
|
| 364 |
}
|
364 |
}
|
| 365 |
|
365 |
|
| 366 |
UserAccounts saholicUserAccounts = null;
|
366 |
UserAccount saholicUserAccounts = null;
|
| 367 |
try{
|
367 |
try{
|
| 368 |
saholicUserAccounts = userAccountRepository.selectByUserIdRetailerIdAccountType(user.getId(), retailer.getId(), AccountType.saholic);
|
368 |
saholicUserAccounts = userAccountRepository.selectByUserIdRetailerIdAccountType(user.getId(), retailer.getId(), AccountType.saholic);
|
| 369 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
369 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
| 370 |
saholicUserAccounts = new UserAccounts();
|
370 |
saholicUserAccounts = new UserAccount();
|
| 371 |
saholicUserAccounts.setAccount_key(String.valueOf(saholicUser.getId()));
|
371 |
saholicUserAccounts.setAccountKey(saholicUser.getId());
|
| 372 |
saholicUserAccounts.setAccount_type(AccountType.saholic);
|
372 |
saholicUserAccounts.setType(AccountType.saholic);
|
| 373 |
saholicUserAccounts.setUser_id(user.getId());
|
373 |
saholicUserAccounts.setUserId(user.getId());
|
| 374 |
userAccountRepository.persist(saholicUserAccounts);
|
374 |
userAccountRepository.persist(saholicUserAccounts);
|
| 375 |
UserAccounts cartUserAccounts = new UserAccounts();
|
375 |
UserAccount cartUserAccounts = new UserAccount();
|
| 376 |
cartUserAccounts.setAccount_key(String.valueOf(saholicUser.getActiveCartId()));
|
376 |
cartUserAccounts.setAccountKey(saholicUser.getActiveCartId());
|
| 377 |
cartUserAccounts.setAccount_type(AccountType.cartId);
|
377 |
cartUserAccounts.setType(AccountType.cartId);
|
| 378 |
cartUserAccounts.setUser_id(user.getId());
|
378 |
cartUserAccounts.setUserId(user.getId());
|
| 379 |
userAccountRepository.persist(cartUserAccounts);
|
379 |
userAccountRepository.persist(cartUserAccounts);
|
| 380 |
}
|
380 |
}
|
| 381 |
|
381 |
|
| 382 |
|
382 |
|
| 383 |
UserRole userRole = null;
|
383 |
UserRole userRole = null;
|