|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.chelvc.cloud.uc.api.dto.UserDTO;
|
|
|
import com.chelvc.cloud.uc.api.service.UserService;
|
|
|
import com.chelvc.cloud.vehicle.api.constant.PlatformConstant;
|
|
|
+import com.chelvc.cloud.vehicle.api.dto.MerchantDTO;
|
|
|
import com.chelvc.cloud.vehicle.api.dto.TeamDTO;
|
|
|
import com.chelvc.cloud.vehicle.api.dto.TeamDetailsDTO;
|
|
|
import com.chelvc.cloud.vehicle.api.param.TeamInvitePageParam;
|
|
@@ -28,6 +29,7 @@ import org.apache.dubbo.config.annotation.DubboService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -114,19 +116,28 @@ public class UserInviteServiceImpl extends ServiceImpl<UserInviteMapper, UserInv
|
|
|
if(CollectionUtils.isEmpty(records)){
|
|
|
return dto;
|
|
|
}
|
|
|
- Map<Long, UserDTO> map = new HashMap<>();
|
|
|
- if(param.getType() == null || param.getType() == 1){
|
|
|
- List<Long> ids = records.stream().filter(e -> e.getSourceType() == 1).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
|
|
|
+ Map<Long, String> map = new HashMap<>();
|
|
|
+ if(param.getType() == null){
|
|
|
+ List<Long> userIds = records.stream().filter(e -> e.getSourceType() == 1).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
|
|
|
+ List<UserDTO> users = this.userService.listUsers(userIds);
|
|
|
+ map = users.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
|
|
|
+ List<Long> merchantIds = records.stream().filter(e -> e.getSourceType() == 2).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
|
|
|
+ List<MerchantDTO> merchants = this.merchantService.getMerchantByIds(merchantIds);
|
|
|
+ map.putAll(merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getName)));
|
|
|
+ } else if(param.getType() == 1){
|
|
|
+ List<Long> ids = records.stream().map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
|
|
|
List<UserDTO> users = this.userService.listUsers(ids);
|
|
|
- map = users.stream().collect(Collectors.toMap(UserDTO::getId, user -> user));
|
|
|
+ map = users.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
|
|
|
+ } else if(param.getType() == 2){
|
|
|
+ List<Long> ids = records.stream().map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
|
|
|
+ List<MerchantDTO> merchants = this.merchantService.getMerchantByIds(ids);
|
|
|
+ map = merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getName));
|
|
|
}
|
|
|
for(TeamDetailsDTO detailsDTO : records){
|
|
|
- Integer sourceType = detailsDTO.getSourceType();
|
|
|
- if(sourceType == 1){
|
|
|
- UserDTO userDTO = map.get(detailsDTO.getInviteUserId());
|
|
|
- detailsDTO.setName(userDTO == null ? "" : userDTO.getNickname());
|
|
|
- } else {
|
|
|
- detailsDTO.setName(merchantService.getMerchantName(detailsDTO.getInviteUserId()));
|
|
|
+ detailsDTO.setName(map.get(detailsDTO.getInviteUserId()));
|
|
|
+ BigDecimal amount = detailsDTO.getAmount();
|
|
|
+ if(amount == null){
|
|
|
+ detailsDTO.setAmount(BigDecimal.ZERO);
|
|
|
}
|
|
|
}
|
|
|
dto = baseMapper.teamTotalStatistics(param.getType(), userId);
|
|
@@ -157,19 +168,28 @@ public class UserInviteServiceImpl extends ServiceImpl<UserInviteMapper, UserInv
|
|
|
if(CollectionUtils.isEmpty(records)){
|
|
|
return dto;
|
|
|
}
|
|
|
- Map<Long, UserDTO> map = new HashMap<>();
|
|
|
- if(param.getType() == null || param.getType() == 1){
|
|
|
- List<Long> ids = records.stream().filter(e -> e.getSourceType() == 1).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
|
|
|
+ Map<Long, String> map = new HashMap<>();
|
|
|
+ if(param.getType() == null){
|
|
|
+ List<Long> userIds = records.stream().filter(e -> e.getSourceType() == 1).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
|
|
|
+ List<UserDTO> users = this.userService.listUsers(userIds);
|
|
|
+ map = users.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
|
|
|
+ List<Long> merchantIds = records.stream().filter(e -> e.getSourceType() == 2).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
|
|
|
+ List<MerchantDTO> merchants = this.merchantService.getMerchantByIds(merchantIds);
|
|
|
+ map.putAll(merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getName)));
|
|
|
+ } else if(param.getType() == 1){
|
|
|
+ List<Long> ids = records.stream().map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
|
|
|
List<UserDTO> users = this.userService.listUsers(ids);
|
|
|
- map = users.stream().collect(Collectors.toMap(UserDTO::getId, user -> user));
|
|
|
+ map = users.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
|
|
|
+ } else if(param.getType() == 2){
|
|
|
+ List<Long> ids = records.stream().map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
|
|
|
+ List<MerchantDTO> merchants = this.merchantService.getMerchantByIds(ids);
|
|
|
+ map = merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getName));
|
|
|
}
|
|
|
for(TeamDetailsDTO detailsDTO : records){
|
|
|
- Integer sourceType = detailsDTO.getSourceType();
|
|
|
- if(sourceType == 1){
|
|
|
- UserDTO userDTO = map.get(detailsDTO.getInviteUserId());
|
|
|
- detailsDTO.setName(userDTO == null ? "" : userDTO.getNickname());
|
|
|
- } else {
|
|
|
- detailsDTO.setName(merchantService.getMerchantName(detailsDTO.getInviteUserId()));
|
|
|
+ detailsDTO.setName(map.get(detailsDTO.getInviteUserId()));
|
|
|
+ BigDecimal amount = detailsDTO.getAmount();
|
|
|
+ if(amount == null){
|
|
|
+ detailsDTO.setAmount(BigDecimal.ZERO);
|
|
|
}
|
|
|
}
|
|
|
dto = baseMapper.inviteTotalStatistics(param.getType());
|