igl 1 ano atrás
pai
commit
756eabf16f

+ 1 - 1
vehicle-server/src/main/java/com/chelvc/cloud/vehicle/server/service/MerchantService.java

@@ -61,5 +61,5 @@ public interface MerchantService extends IService<Merchant> {
     MerchantDTO getMerchantByUserId(Long userId);
 
 
-
+    List<MerchantDTO> getMerchantByIds(List<Long> ids);
 }

+ 8 - 0
vehicle-server/src/main/java/com/chelvc/cloud/vehicle/server/service/impl/MerchantServiceImpl.java

@@ -400,6 +400,14 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i
         return MerchantCopier.INSTANCE.copying(merchants);
     }
 
+    @Override
+    public List<MerchantDTO> getMerchantByIds(List<Long> ids) {
+        List<MerchantDTO> list = new ArrayList<>();
+        for(Long id : ids){
+            list.add(getMerchantById(id));
+        }
+        return list;
+    }
 
 
     /**

+ 40 - 20
vehicle-server/src/main/java/com/chelvc/cloud/vehicle/server/service/impl/UserInviteServiceImpl.java

@@ -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());

+ 11 - 11
vehicle-server/src/main/resources/mapper/UserInviteMapper.xml

@@ -7,13 +7,13 @@
             i.user_id,
             target_id AS inviteUserId,
             SUM( r.reality_amount ) amount,
-            r.source_type sourceType
+            i.type sourceType
         FROM
             user_invite i
                 LEFT JOIN currency_record r ON i.user_id = r.user_id
                 AND i.target_id = r.source_id
-                AND r.source_type = 0
-                AND i.type = r.type
+                AND r.type = 0
+                AND i.type = r.source_type
         WHERE
             i.user_id = #{userId}
             <if test="type != null">
@@ -34,8 +34,8 @@
         user_invite i
         LEFT JOIN currency_record r ON i.user_id = r.user_id
         AND i.target_id = r.source_id
-        AND r.source_type = 0
-        AND i.type = r.type
+        AND r.type = 0
+        AND i.type = r.source_type
         WHERE
         i.user_id = #{userId}
         <if test="type != null">
@@ -51,13 +51,13 @@
         i.user_id,
         target_id AS inviteUserId,
         SUM( r.reality_amount ) amount,
-        r.source_type sourceType
+        i.type sourceType
         FROM
         user_invite i
         LEFT JOIN currency_record r ON i.user_id = r.user_id
         AND i.target_id = r.source_id
-        AND r.source_type = 0
-        AND i.type = r.type
+        AND r.type = 0
+        AND i.type = r.source_type
         WHERE 1=1
         <if test="type != null">
             and i.type = #{type}
@@ -78,9 +78,9 @@
         FROM
         user_invite i
         LEFT JOIN currency_record r ON i.user_id = r.user_id
-        AND i.target_id = r.source_user_id
-        AND r.source_type = 0
-        AND i.type = r.type
+        AND i.target_id = r.source_id
+        AND r.type = 0
+        AND i.type = r.source_type
         WHERE
         1=1
         <if test="type != null">