|
@@ -24,13 +24,15 @@ import com.chelvc.framework.common.function.Executor;
|
|
import com.chelvc.framework.common.model.Paging;
|
|
import com.chelvc.framework.common.model.Paging;
|
|
import com.chelvc.framework.database.context.DatabaseContextHolder;
|
|
import com.chelvc.framework.database.context.DatabaseContextHolder;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.time.LocalDate;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
+import java.time.LocalTime;
|
|
|
|
+import java.time.temporal.TemporalAdjusters;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -105,7 +107,22 @@ public class UserInviteServiceImpl extends ServiceImpl<UserInviteMapper, UserInv
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public TeamDTO teamList(TeamInvitePageParam param, Long userId) {
|
|
public TeamDTO teamList(TeamInvitePageParam param, Long userId) {
|
|
- TeamDTO dto = new TeamDTO();
|
|
|
|
|
|
+ LocalDate today = LocalDate.now(); // 获取今天的日期
|
|
|
|
+ LocalDateTime midnight = LocalDateTime.of(today, LocalTime.MIDNIGHT); // 获取今天凌晨的时间
|
|
|
|
+ LocalDate yesterday = today.minusDays(1);
|
|
|
|
+ LocalDateTime yesterdayMidnight = LocalDateTime.of(yesterday, LocalTime.MIN);
|
|
|
|
+ LocalDateTime toMonth = LocalDateTime.of(LocalDate.from(LocalDateTime.now()
|
|
|
|
+ .with(TemporalAdjusters.firstDayOfMonth())), LocalTime.MIN);
|
|
|
|
+ LocalDateTime lastMonth = toMonth.minusMonths(1);
|
|
|
|
+ TeamDTO dto = baseMapper.teamTotalStatistics(param.getType(), userId,
|
|
|
|
+ midnight, yesterdayMidnight, toMonth, lastMonth);
|
|
|
|
+ if(dto == null){
|
|
|
|
+ return new TeamDTO();
|
|
|
|
+ }
|
|
|
|
+ BigDecimal totalAmount = dto.getTotalAmount();
|
|
|
|
+ if(totalAmount == null){
|
|
|
|
+ dto.setTotalAmount(BigDecimal.ZERO);
|
|
|
|
+ }
|
|
Paging paging = param.getPaging();
|
|
Paging paging = param.getPaging();
|
|
int pageNum = (paging.getNumber() - 1) * paging.getSize();
|
|
int pageNum = (paging.getNumber() - 1) * paging.getSize();
|
|
if(pageNum < 0){
|
|
if(pageNum < 0){
|
|
@@ -115,53 +132,69 @@ public class UserInviteServiceImpl extends ServiceImpl<UserInviteMapper, UserInv
|
|
if(CollectionUtils.isEmpty(records)){
|
|
if(CollectionUtils.isEmpty(records)){
|
|
return dto;
|
|
return dto;
|
|
}
|
|
}
|
|
- List<Long> userList = records.stream().map(TeamDetailsDTO::getUserId).collect(Collectors.toList());
|
|
|
|
- List<UserDTO> usersLists = this.userService.listUsers(userList);
|
|
|
|
- Map<Long, String> userMap = usersLists.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
|
|
|
|
- Map<Long, String> map = new HashMap<>();
|
|
|
|
- Map<Long,String> avatar = new HashMap<>();
|
|
|
|
|
|
+ Map<Long, TeamDetailsDTO> userMap = new HashMap<>();
|
|
if(param.getType() == null){
|
|
if(param.getType() == null){
|
|
List<Long> userIds = records.stream().filter(e -> e.getSourceType() == 1).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
|
|
List<Long> userIds = records.stream().filter(e -> e.getSourceType() == 1).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
|
|
List<UserDTO> users = this.userService.listUsers(userIds);
|
|
List<UserDTO> users = this.userService.listUsers(userIds);
|
|
if(!CollectionUtils.isEmpty(users)){
|
|
if(!CollectionUtils.isEmpty(users)){
|
|
- map = users.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
|
|
|
|
- avatar = users.stream().filter(e -> StringUtils.isNotBlank(e.getAvatar())).collect(Collectors.toMap(UserDTO::getId, UserDTO::getAvatar));
|
|
|
|
|
|
+ users.forEach(e ->{
|
|
|
|
+ TeamDetailsDTO detailsDTO = new TeamDetailsDTO();
|
|
|
|
+ detailsDTO.setInviteUserAvatar(e.getAvatar());
|
|
|
|
+ detailsDTO.setNickname(e.getNickname());
|
|
|
|
+ detailsDTO.setMobile(e.getMobile());
|
|
|
|
+ userMap.put(e.getId(), detailsDTO);
|
|
|
|
+ });
|
|
}
|
|
}
|
|
List<Long> merchantIds = records.stream().filter(e -> e.getSourceType() == 2).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
|
|
List<Long> merchantIds = records.stream().filter(e -> e.getSourceType() == 2).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
|
|
List<MerchantDTO> merchants = this.merchantService.getMerchantByIds(merchantIds);
|
|
List<MerchantDTO> merchants = this.merchantService.getMerchantByIds(merchantIds);
|
|
- if(!CollectionUtils.isEmpty(users)){
|
|
|
|
- map.putAll(merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getName)));
|
|
|
|
- avatar.putAll(merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getLogo)));
|
|
|
|
|
|
+ if(!CollectionUtils.isEmpty(merchants)){
|
|
|
|
+ merchants.forEach(e ->{
|
|
|
|
+ TeamDetailsDTO detailsDTO = new TeamDetailsDTO();
|
|
|
|
+ detailsDTO.setInviteUserAvatar(e.getLogo());
|
|
|
|
+ detailsDTO.setNickname(e.getName());
|
|
|
|
+ detailsDTO.setMobile(e.getMobile());
|
|
|
|
+ userMap.put(e.getId(), detailsDTO);
|
|
|
|
+ });
|
|
}
|
|
}
|
|
} else if(param.getType() == 1){
|
|
} else if(param.getType() == 1){
|
|
List<Long> ids = records.stream().map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
|
|
List<Long> ids = records.stream().map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
|
|
List<UserDTO> users = this.userService.listUsers(ids);
|
|
List<UserDTO> users = this.userService.listUsers(ids);
|
|
if(!CollectionUtils.isEmpty(users)){
|
|
if(!CollectionUtils.isEmpty(users)){
|
|
- map = users.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
|
|
|
|
- avatar = users.stream().filter(e -> StringUtils.isNotBlank(e.getAvatar())).collect(Collectors.toMap(UserDTO::getId, UserDTO::getAvatar));
|
|
|
|
|
|
+ users.forEach(e ->{
|
|
|
|
+ TeamDetailsDTO detailsDTO = new TeamDetailsDTO();
|
|
|
|
+ detailsDTO.setInviteUserAvatar(e.getAvatar());
|
|
|
|
+ detailsDTO.setNickname(e.getNickname());
|
|
|
|
+ detailsDTO.setMobile(e.getMobile());
|
|
|
|
+ userMap.put(e.getId(), detailsDTO);
|
|
|
|
+ });
|
|
}
|
|
}
|
|
} else if(param.getType() == 2){
|
|
} else if(param.getType() == 2){
|
|
List<Long> ids = records.stream().map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
|
|
List<Long> ids = records.stream().map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
|
|
List<MerchantDTO> merchants = this.merchantService.getMerchantByIds(ids);
|
|
List<MerchantDTO> merchants = this.merchantService.getMerchantByIds(ids);
|
|
if(!CollectionUtils.isEmpty(merchants)) {
|
|
if(!CollectionUtils.isEmpty(merchants)) {
|
|
- map = merchants.stream().collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getName));
|
|
|
|
- avatar = merchants.stream().filter(e -> StringUtils.isNotBlank(e.getLogo())).collect(Collectors.toMap(MerchantDTO::getId, MerchantDTO::getLogo));
|
|
|
|
|
|
+ merchants.forEach(e ->{
|
|
|
|
+ TeamDetailsDTO detailsDTO = new TeamDetailsDTO();
|
|
|
|
+ detailsDTO.setInviteUserAvatar(e.getLogo());
|
|
|
|
+ detailsDTO.setNickname(e.getName());
|
|
|
|
+ detailsDTO.setMobile(e.getMobile());
|
|
|
|
+ userMap.put(e.getId(), detailsDTO);
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for(TeamDetailsDTO detailsDTO : records){
|
|
for(TeamDetailsDTO detailsDTO : records){
|
|
- detailsDTO.setName(map.get(detailsDTO.getInviteUserId()));
|
|
|
|
- detailsDTO.setNickname(userMap.get(detailsDTO.getUserId()));
|
|
|
|
- detailsDTO.setInviteUserAvatar(avatar.get(detailsDTO.getInviteUserId()));
|
|
|
|
|
|
+ Long id = detailsDTO.getInviteUserId();
|
|
|
|
+ TeamDetailsDTO teamDetailsDTO = userMap.get(id);
|
|
|
|
+ if(teamDetailsDTO != null){
|
|
|
|
+ detailsDTO.setName(teamDetailsDTO.getNickname());
|
|
|
|
+ detailsDTO.setNickname(teamDetailsDTO.getNickname());
|
|
|
|
+ detailsDTO.setInviteUserAvatar(teamDetailsDTO.getInviteUserAvatar());
|
|
|
|
+ detailsDTO.setMobile(teamDetailsDTO.getMobile());
|
|
|
|
+ }
|
|
BigDecimal amount = detailsDTO.getAmount();
|
|
BigDecimal amount = detailsDTO.getAmount();
|
|
if(amount == null){
|
|
if(amount == null){
|
|
detailsDTO.setAmount(BigDecimal.ZERO);
|
|
detailsDTO.setAmount(BigDecimal.ZERO);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- dto = baseMapper.teamTotalStatistics(param.getType(), userId);
|
|
|
|
- BigDecimal totalAmount = dto.getTotalAmount();
|
|
|
|
- if(totalAmount == null){
|
|
|
|
- dto.setTotalAmount(BigDecimal.ZERO);
|
|
|
|
- }
|
|
|
|
dto.setRecords(records);
|
|
dto.setRecords(records);
|
|
return dto;
|
|
return dto;
|
|
}
|
|
}
|
|
@@ -192,6 +225,7 @@ public class UserInviteServiceImpl extends ServiceImpl<UserInviteMapper, UserInv
|
|
List<Long> userList = records.stream().map(TeamDetailsDTO::getUserId).collect(Collectors.toList());
|
|
List<Long> userList = records.stream().map(TeamDetailsDTO::getUserId).collect(Collectors.toList());
|
|
List<UserDTO> usersLists = this.userService.listUsers(userList);
|
|
List<UserDTO> usersLists = this.userService.listUsers(userList);
|
|
Map<Long, String> userMap = usersLists.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
|
|
Map<Long, String> userMap = usersLists.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
|
|
|
|
+ Map<Long, String> mobileMap = usersLists.stream().collect(Collectors.toMap(UserDTO::getId, UserDTO::getNickname));
|
|
Map<Long, String> map = new HashMap<>();
|
|
Map<Long, String> map = new HashMap<>();
|
|
if(param.getType() == null){
|
|
if(param.getType() == null){
|
|
List<Long> userIds = records.stream().filter(e -> e.getSourceType() == 1).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
|
|
List<Long> userIds = records.stream().filter(e -> e.getSourceType() == 1).map(TeamDetailsDTO::getInviteUserId).collect(Collectors.toList());
|