update:
1. fix
This commit is contained in:
3
doc/sql/pending/20260508.sql
Normal file
3
doc/sql/pending/20260508.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
CREATE INDEX CONCURRENTLY idx_market_daily_summary_user_id_id
|
||||
ON market_daily_summary (user_id, id DESC)
|
||||
WHERE is_deleted = 0;
|
||||
@@ -64,6 +64,7 @@ public class DailySummaryProcessor implements BasicProcessor {
|
||||
MarketDailySummaryEntity summary = new MarketDailySummaryEntity();
|
||||
summary.setStatDate(yesterday);
|
||||
summary.setUserId(info.getId());
|
||||
summary.setUserName(info.getName());
|
||||
summary.setUserAccount(info.getAccount());
|
||||
CommonUserPointEntity userPoint = userPointService.getById(info.getId());
|
||||
if (userPoint != null) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.springblade.modules.market.manager.MarketUserManager;
|
||||
import org.springblade.modules.market.manager.MarketUserPointManager;
|
||||
import org.springblade.modules.market.service.IMarketBankCardService;
|
||||
import org.springblade.modules.market.service.IMarketBenefitPackageService;
|
||||
import org.springblade.modules.market.service.IMarketDailySummaryService;
|
||||
import org.springblade.modules.market.service.IMarketInfoService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -53,6 +54,8 @@ public class MarketUserController {
|
||||
|
||||
private final ICommonRegionsInfoService commonRegionsInfoService;
|
||||
|
||||
private final IMarketDailySummaryService summaryService;
|
||||
|
||||
|
||||
@GetMapping("/package-list")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@@ -66,8 +69,8 @@ public class MarketUserController {
|
||||
@GetMapping("/my-team")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "查直推")
|
||||
public R<List<MarketDirectInfoApiVO>> myTeam() {
|
||||
return R.data(marketUserManager.findUserPackList());
|
||||
public R<List<MarketSummaryInfoApiVO>> myTeam() {
|
||||
return R.data(summaryService.selectInfoListByPid(AuthUtil.getUserId()));
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +78,7 @@ public class MarketUserController {
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "查推荐人信息")
|
||||
public R<MarketDirectInfoApiVO> myInvitor() {
|
||||
return R.data(marketUserManager.findMarketParent());
|
||||
return R.data(marketInfoService.selectParent(AuthUtil.getUserId()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@@ -53,38 +52,4 @@ public class MarketDirectInfoApiVO implements Serializable {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date registerTime;
|
||||
|
||||
/**
|
||||
* 团队总消费额
|
||||
*/
|
||||
private BigDecimal totalSalesAmount = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 昨日团队新增消费
|
||||
*/
|
||||
private BigDecimal increaseAmount = BigDecimal.ZERO;
|
||||
/**
|
||||
* 昨日团队新增分红消费
|
||||
*/
|
||||
private BigDecimal increaseDividendAmount = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 团队总福利值
|
||||
*/
|
||||
private BigDecimal totalBenefitsValue = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 昨日团队新增福利值
|
||||
*/
|
||||
private BigDecimal increaseBenefitsValue = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 团队人数
|
||||
*/
|
||||
private Integer teamNumber = 0;
|
||||
|
||||
/**
|
||||
* 昨日团队新增人数
|
||||
*/
|
||||
private Integer increaseTeamNumber = 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.modules.api.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用户拓展信息表 视图实体类
|
||||
*
|
||||
* @author RayLiu
|
||||
* @since 2026-02-05
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class MarketSummaryInfoApiVO implements Serializable {
|
||||
|
||||
private String phone;
|
||||
|
||||
private String name;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date registerTime;
|
||||
|
||||
/**
|
||||
* 团队总消费额
|
||||
*/
|
||||
private BigDecimal totalSalesAmount = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 昨日团队新增消费
|
||||
*/
|
||||
private BigDecimal increaseAmount = BigDecimal.ZERO;
|
||||
/**
|
||||
* 昨日团队新增分红消费
|
||||
*/
|
||||
private BigDecimal increaseDividendAmount = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 团队总福利值
|
||||
*/
|
||||
private BigDecimal totalBenefitsValue = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 昨日团队新增福利值
|
||||
*/
|
||||
private BigDecimal increaseBenefitsValue = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 团队人数
|
||||
*/
|
||||
private Integer teamNumber = 0;
|
||||
|
||||
/**
|
||||
* 昨日团队新增人数
|
||||
*/
|
||||
private Integer increaseTeamNumber = 0;
|
||||
|
||||
}
|
||||
@@ -36,6 +36,7 @@ import org.springblade.core.secure.BladeUser;
|
||||
import org.springblade.core.secure.annotation.IsAdmin;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.PreAuth;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -64,6 +65,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/market/daily-summary")
|
||||
@Tag(name = "用户日汇总表", description = "用户日汇总表接口")
|
||||
@PreAuth("hasAnyRole('administrator', 'admin', 'operator')")
|
||||
public class MarketDailySummaryController extends BladeController {
|
||||
|
||||
private final IMarketDailySummaryService dailySummaryService;
|
||||
|
||||
@@ -67,119 +67,119 @@ public class MarketUserManager {
|
||||
private final IMarketPerformanceDayLogService marketPerformanceDayLogService;
|
||||
private final IMarketTeamService marketTeamService;
|
||||
|
||||
public List<MarketDirectInfoApiVO> findUserPackList() {
|
||||
Long userId = AuthUtil.getUserId();
|
||||
MarketInfoEntity marketInfoEntity = marketInfoService.getById(userId);
|
||||
Assert.notNull(marketInfoEntity, "用户不存在");
|
||||
// public List<MarketDirectInfoApiVO> findUserPackList() {
|
||||
// Long userId = AuthUtil.getUserId();
|
||||
// MarketInfoEntity marketInfoEntity = marketInfoService.getById(userId);
|
||||
// Assert.notNull(marketInfoEntity, "用户不存在");
|
||||
//
|
||||
// List<MarketDirectInfoApiVO> marketDirectInfoApiVOList = new LinkedList<>();
|
||||
//
|
||||
// List<MarketInfoEntity> marketInfoEntityList = marketInfoService.list(
|
||||
// Wrappers.lambdaQuery(MarketInfoEntity.class)
|
||||
// .eq(MarketInfoEntity::getPid, marketInfoEntity.getId())
|
||||
// );
|
||||
//
|
||||
// Map<Long, MarketInfoEntity> marketInfoEntityMap = marketInfoEntityList.stream()
|
||||
// .collect(Collectors.toMap(MarketInfoEntity::getId, entity -> entity));
|
||||
//
|
||||
//
|
||||
// List<Long> marketInfoIdList = marketInfoEntityList.stream().map(MarketInfoEntity::getId).toList();
|
||||
//
|
||||
// if (marketInfoIdList.isEmpty()) {
|
||||
// return new LinkedList<>();
|
||||
// }
|
||||
//
|
||||
// List<User> userList = userService.list(
|
||||
// Wrappers.lambdaQuery(User.class)
|
||||
// .in(User::getId, marketInfoIdList)
|
||||
// );
|
||||
//
|
||||
// Integer day = Integer.parseInt(DateUtil.convertFromDate(DateUtil.getYesterday(), "yyyyMMdd"));
|
||||
// Map<Long, MarketPerformanceDayLogEntity> performanceDayLogMap = marketPerformanceDayLogService.list(
|
||||
// Wrappers.lambdaQuery(MarketPerformanceDayLogEntity.class)
|
||||
// .eq(MarketPerformanceDayLogEntity::getStatsDay, day)
|
||||
// .in(MarketPerformanceDayLogEntity::getUserId, marketInfoIdList)
|
||||
// ).stream().collect(Collectors.toMap(
|
||||
// MarketPerformanceDayLogEntity::getUserId, // Key: userId
|
||||
// entity -> entity, // Value: 实体对象本身
|
||||
// (existing, replacement) -> existing // 如果 key 重复,保留第一个(或者用 replacement 覆盖)
|
||||
// ));
|
||||
//
|
||||
// Map<Long, MarketTeamEntity> marketTeamMap = marketTeamService.list(
|
||||
// Wrappers.lambdaQuery(MarketTeamEntity.class)
|
||||
// .in(MarketTeamEntity::getUserId, marketInfoIdList)
|
||||
// ).stream().collect(Collectors.toMap(
|
||||
// MarketTeamEntity::getUserId, // Key: userId
|
||||
// entity -> entity, // Value: 实体对象本身
|
||||
// (existing, replacement) -> existing // 如果 key 重复,保留第一个(或者用 replacement 覆盖)
|
||||
// ));
|
||||
//
|
||||
// userList.forEach(user -> {
|
||||
// MarketDirectInfoApiVO apiVO = new MarketDirectInfoApiVO();
|
||||
// if (marketInfoEntityMap.containsKey(user.getId())) {
|
||||
// MarketInfoEntity marketInfo = marketInfoEntityMap.get(user.getId());
|
||||
// if (marketInfo.getVerified() == 1) {
|
||||
// apiVO.setPhone(SensitiveUtil.process(user.getPhone()))
|
||||
// .setName(desensitizationByName(marketInfo.getRealName()))
|
||||
// .setRegisterTime(user.getCreateTime());
|
||||
//
|
||||
// } else {
|
||||
// apiVO.setPhone(SensitiveUtil.process(user.getAccount()))
|
||||
// .setName(desensitizationByName(user.getName()))
|
||||
// .setRegisterTime(user.getCreateTime());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (performanceDayLogMap.containsKey(user.getId())) {
|
||||
// apiVO.setIncreaseAmount(performanceDayLogMap.get(user.getId()).getSalesAmount())
|
||||
// .setIncreaseDividendAmount(performanceDayLogMap.get(user.getId()).getDividendAmount())
|
||||
// .setIncreaseBenefitsValue(performanceDayLogMap.get(user.getId()).getBenefitsValue())
|
||||
// .setIncreaseTeamNumber(performanceDayLogMap.get(user.getId()).getTeamNumber());
|
||||
// }
|
||||
//
|
||||
// if (marketTeamMap.containsKey(user.getId())) {
|
||||
// apiVO.setTotalSalesAmount(marketTeamMap.get(user.getId()).getSalesTotal())
|
||||
// .setTotalBenefitsValue(marketTeamMap.get(user.getId()).getBenefitsTotal())
|
||||
// .setTeamNumber(marketTeamMap.get(user.getId()).getTeamTotal());
|
||||
// }
|
||||
//
|
||||
// marketDirectInfoApiVOList.add(apiVO);
|
||||
//
|
||||
// });
|
||||
//
|
||||
//
|
||||
// return marketDirectInfoApiVOList;
|
||||
//
|
||||
// }
|
||||
|
||||
List<MarketDirectInfoApiVO> marketDirectInfoApiVOList = new LinkedList<>();
|
||||
|
||||
List<MarketInfoEntity> marketInfoEntityList = marketInfoService.list(
|
||||
Wrappers.lambdaQuery(MarketInfoEntity.class)
|
||||
.eq(MarketInfoEntity::getPid, marketInfoEntity.getId())
|
||||
);
|
||||
|
||||
Map<Long, MarketInfoEntity> marketInfoEntityMap = marketInfoEntityList.stream()
|
||||
.collect(Collectors.toMap(MarketInfoEntity::getId, entity -> entity));
|
||||
|
||||
|
||||
List<Long> marketInfoIdList = marketInfoEntityList.stream().map(MarketInfoEntity::getId).toList();
|
||||
|
||||
if (marketInfoIdList.isEmpty()) {
|
||||
return new LinkedList<>();
|
||||
}
|
||||
|
||||
List<User> userList = userService.list(
|
||||
Wrappers.lambdaQuery(User.class)
|
||||
.in(User::getId, marketInfoIdList)
|
||||
);
|
||||
|
||||
Integer day = Integer.parseInt(DateUtil.convertFromDate(DateUtil.getYesterday(), "yyyyMMdd"));
|
||||
Map<Long, MarketPerformanceDayLogEntity> performanceDayLogMap = marketPerformanceDayLogService.list(
|
||||
Wrappers.lambdaQuery(MarketPerformanceDayLogEntity.class)
|
||||
.eq(MarketPerformanceDayLogEntity::getStatsDay, day)
|
||||
.in(MarketPerformanceDayLogEntity::getUserId, marketInfoIdList)
|
||||
).stream().collect(Collectors.toMap(
|
||||
MarketPerformanceDayLogEntity::getUserId, // Key: userId
|
||||
entity -> entity, // Value: 实体对象本身
|
||||
(existing, replacement) -> existing // 如果 key 重复,保留第一个(或者用 replacement 覆盖)
|
||||
));
|
||||
|
||||
Map<Long, MarketTeamEntity> marketTeamMap = marketTeamService.list(
|
||||
Wrappers.lambdaQuery(MarketTeamEntity.class)
|
||||
.in(MarketTeamEntity::getUserId, marketInfoIdList)
|
||||
).stream().collect(Collectors.toMap(
|
||||
MarketTeamEntity::getUserId, // Key: userId
|
||||
entity -> entity, // Value: 实体对象本身
|
||||
(existing, replacement) -> existing // 如果 key 重复,保留第一个(或者用 replacement 覆盖)
|
||||
));
|
||||
|
||||
userList.forEach(user -> {
|
||||
MarketDirectInfoApiVO apiVO = new MarketDirectInfoApiVO();
|
||||
if (marketInfoEntityMap.containsKey(user.getId())) {
|
||||
MarketInfoEntity marketInfo = marketInfoEntityMap.get(user.getId());
|
||||
if (marketInfo.getVerified() == 1) {
|
||||
apiVO.setPhone(SensitiveUtil.process(user.getPhone()))
|
||||
.setName(desensitizationByName(marketInfo.getRealName()))
|
||||
.setRegisterTime(user.getCreateTime());
|
||||
|
||||
} else {
|
||||
apiVO.setPhone(SensitiveUtil.process(user.getAccount()))
|
||||
.setName(desensitizationByName(user.getName()))
|
||||
.setRegisterTime(user.getCreateTime());
|
||||
}
|
||||
}
|
||||
|
||||
if (performanceDayLogMap.containsKey(user.getId())) {
|
||||
apiVO.setIncreaseAmount(performanceDayLogMap.get(user.getId()).getSalesAmount())
|
||||
.setIncreaseDividendAmount(performanceDayLogMap.get(user.getId()).getDividendAmount())
|
||||
.setIncreaseBenefitsValue(performanceDayLogMap.get(user.getId()).getBenefitsValue())
|
||||
.setIncreaseTeamNumber(performanceDayLogMap.get(user.getId()).getTeamNumber());
|
||||
}
|
||||
|
||||
if (marketTeamMap.containsKey(user.getId())) {
|
||||
apiVO.setTotalSalesAmount(marketTeamMap.get(user.getId()).getSalesTotal())
|
||||
.setTotalBenefitsValue(marketTeamMap.get(user.getId()).getBenefitsTotal())
|
||||
.setTeamNumber(marketTeamMap.get(user.getId()).getTeamTotal());
|
||||
}
|
||||
|
||||
marketDirectInfoApiVOList.add(apiVO);
|
||||
|
||||
});
|
||||
|
||||
|
||||
return marketDirectInfoApiVOList;
|
||||
|
||||
}
|
||||
|
||||
public MarketDirectInfoApiVO findMarketParent() {
|
||||
Long userId = AuthUtil.getUserId();
|
||||
MarketInfoEntity marketInfoEntity = marketInfoService.getById(userId);
|
||||
Assert.notNull(marketInfoEntity, "用户不存在");
|
||||
if (marketInfoEntity.getPid() == null || marketInfoEntity.getPid() <= 0) {
|
||||
return new MarketDirectInfoApiVO();
|
||||
}
|
||||
User user = userService.getById(marketInfoEntity.getPid());
|
||||
if (user == null) {
|
||||
return new MarketDirectInfoApiVO();
|
||||
}
|
||||
|
||||
MarketDirectInfoApiVO marketDirectInfoApiVO = new MarketDirectInfoApiVO()
|
||||
.setPhone(SensitiveUtil.process(user.getAccount()))
|
||||
.setName(desensitizationByName(user.getName()))
|
||||
.setRegisterTime(user.getCreateTime());
|
||||
|
||||
|
||||
MarketInfoEntity parentMarketInfoEntity = marketInfoService.getById(marketInfoEntity.getPid());
|
||||
|
||||
if (parentMarketInfoEntity != null && parentMarketInfoEntity.getVerified() == 1) {
|
||||
marketDirectInfoApiVO.setName(desensitizationByName(parentMarketInfoEntity.getRealName()));
|
||||
}
|
||||
|
||||
|
||||
return marketDirectInfoApiVO;
|
||||
|
||||
}
|
||||
// public MarketDirectInfoApiVO findMarketParent() {
|
||||
// Long userId = AuthUtil.getUserId();
|
||||
// MarketInfoEntity marketInfoEntity = marketInfoService.getById(userId);
|
||||
// Assert.notNull(marketInfoEntity, "用户不存在");
|
||||
// if (marketInfoEntity.getPid() == null || marketInfoEntity.getPid() <= 0) {
|
||||
// return new MarketDirectInfoApiVO();
|
||||
// }
|
||||
// User user = userService.getById(marketInfoEntity.getPid());
|
||||
// if (user == null) {
|
||||
// return new MarketDirectInfoApiVO();
|
||||
// }
|
||||
//
|
||||
// MarketDirectInfoApiVO marketDirectInfoApiVO = new MarketDirectInfoApiVO()
|
||||
// .setPhone(SensitiveUtil.process(user.getAccount()))
|
||||
// .setName(desensitizationByName(user.getName()))
|
||||
// .setRegisterTime(user.getCreateTime());
|
||||
//
|
||||
//
|
||||
// MarketInfoEntity parentMarketInfoEntity = marketInfoService.getById(marketInfoEntity.getPid());
|
||||
//
|
||||
// if (parentMarketInfoEntity != null && parentMarketInfoEntity.getVerified() == 1) {
|
||||
// marketDirectInfoApiVO.setName(desensitizationByName(parentMarketInfoEntity.getRealName()));
|
||||
// }
|
||||
//
|
||||
//
|
||||
// return marketDirectInfoApiVO;
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
@Transactional(rollbackFor = ServiceException.class)
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
package org.springblade.modules.market.mapper;
|
||||
|
||||
import org.springblade.modules.api.vo.MarketSummaryInfoApiVO;
|
||||
import org.springblade.modules.market.pojo.entity.MarketDailySummaryEntity;
|
||||
import org.springblade.modules.market.pojo.vo.MarketDailySummaryVO;
|
||||
import org.springblade.modules.market.excel.MarketDailySummaryExcel;
|
||||
@@ -60,4 +61,5 @@ public interface MarketDailySummaryMapper extends BaseMapper<MarketDailySummaryE
|
||||
*/
|
||||
List<MarketDailySummaryExcel> exportDailySummary(@Param("ew") Wrapper<MarketDailySummaryEntity> queryWrapper);
|
||||
|
||||
List<MarketSummaryInfoApiVO> selectApiVOByIds(String idArrayStr);
|
||||
}
|
||||
|
||||
@@ -71,4 +71,24 @@
|
||||
SELECT * FROM market_daily_summary ${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
<select id="selectApiVOByIds" resultType="org.springblade.modules.api.vo.MarketSummaryInfoApiVO">
|
||||
SELECT t.user_account as phone,
|
||||
t.user_name as name,
|
||||
bu.create_time as registerTime,
|
||||
t.team_total_amount as totalSalesAmount,
|
||||
t.team_increase_amount as increaseAmount,
|
||||
t.team_increase_online_amount as increaseDividendAmount,
|
||||
t.team_total_benefits_value as totalBenefitsValue,
|
||||
t.team_increase_benefits_value as increaseBenefitsValue,
|
||||
t.team_member_count as teamNumber,
|
||||
t.team_increase_count as increaseTeamNumber
|
||||
FROM (SELECT *,
|
||||
ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY id DESC) AS rn
|
||||
FROM market_daily_summary
|
||||
WHERE user_id = ANY ('${idArrayStr}'::bigint[])
|
||||
AND is_deleted = 0) t
|
||||
left join blade_user bu on t.user_id = bu.id
|
||||
WHERE rn = 1
|
||||
ORDER BY ARRAY_POSITION('${idArrayStr}'::bigint[], user_id)
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
package org.springblade.modules.market.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springblade.modules.api.vo.MarketDirectInfoApiVO;
|
||||
import org.springblade.modules.market.pojo.dto.MarketInfoSummaryDTO;
|
||||
import org.springblade.modules.market.pojo.entity.MarketInfoEntity;
|
||||
import org.springblade.modules.market.pojo.vo.MarketInfoVO;
|
||||
@@ -55,4 +56,8 @@ public interface MarketInfoMapper extends BaseMapper<MarketInfoEntity> {
|
||||
List<Long> selectAncestorIds(@Param("userId") Long userId);
|
||||
|
||||
List<MarketInfoSummaryDTO> selectMarketInfoSummaryByDate(Date date);
|
||||
|
||||
MarketDirectInfoApiVO selectParent(Long pid);
|
||||
|
||||
List<Long> selectIdsByPid(Long pid);
|
||||
}
|
||||
|
||||
@@ -77,10 +77,23 @@
|
||||
</select>
|
||||
|
||||
<select id="selectMarketInfoSummaryByDate" resultType="org.springblade.modules.market.pojo.dto.MarketInfoSummaryDTO">
|
||||
select umi.id as id, umi.pid as pid ,bu.account as account, bu.create_time as createTime
|
||||
select umi.id as id, umi.pid as pid, bu.account as account, umi.real_name as name, bu.create_time as createTime
|
||||
from user_market_info umi
|
||||
left join blade_user bu on umi.id = bu.id
|
||||
where umi.is_deleted = 0 and bu.create_time < #{date}
|
||||
where umi.is_deleted = 0
|
||||
and bu.create_time < #{date}
|
||||
</select>
|
||||
|
||||
<select id="selectParent" resultType="org.springblade.modules.api.vo.MarketDirectInfoApiVO">
|
||||
select umi.id, bu.account as phone, bu.name, bu.create_time as registerTime
|
||||
from user_market_info umi
|
||||
left join blade_user bu on umi.id = bu.id
|
||||
where umi.is_deleted = 0 and umi.id = #{pid}
|
||||
</select>
|
||||
|
||||
<select id="selectIdsByPid" resultType="java.lang.Long">
|
||||
select id
|
||||
from user_market_info where is_deleted = 0 and pid = #{pid}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -18,6 +18,8 @@ public class MarketInfoSummaryDTO implements Serializable {
|
||||
|
||||
private String account;
|
||||
|
||||
private String name;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
package org.springblade.modules.market.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import org.springblade.modules.api.vo.MarketSummaryInfoApiVO;
|
||||
import org.springblade.modules.market.pojo.entity.MarketDailySummaryEntity;
|
||||
import org.springblade.modules.market.pojo.vo.MarketDailySummaryVO;
|
||||
import org.springblade.modules.market.excel.MarketDailySummaryExcel;
|
||||
@@ -58,4 +59,5 @@ public interface IMarketDailySummaryService extends BaseService<MarketDailySumma
|
||||
*/
|
||||
List<MarketDailySummaryExcel> exportDailySummary(Wrapper<MarketDailySummaryEntity> queryWrapper);
|
||||
|
||||
List<MarketSummaryInfoApiVO> selectInfoListByPid(Long userId);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
package org.springblade.modules.market.service;
|
||||
|
||||
import org.springblade.modules.api.vo.MarketDirectInfoApiVO;
|
||||
import org.springblade.modules.market.pojo.dto.MarketInfoSummaryDTO;
|
||||
import org.springblade.modules.market.pojo.entity.MarketInfoEntity;
|
||||
import org.springblade.modules.market.pojo.vo.MarketInfoVO;
|
||||
@@ -63,4 +64,7 @@ public interface IMarketInfoService extends BaseService<MarketInfoEntity> {
|
||||
|
||||
List<MarketInfoSummaryDTO> selectMarketInfoSummaryByDate(Date date);
|
||||
|
||||
MarketDirectInfoApiVO selectParent(Long userId);
|
||||
|
||||
List<Long> selectIdsByPid(Long pid);
|
||||
}
|
||||
|
||||
@@ -25,16 +25,31 @@
|
||||
*/
|
||||
package org.springblade.modules.market.service.impl;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.tool.sensitive.SensitiveUtil;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springblade.modules.api.vo.MarketSummaryInfoApiVO;
|
||||
import org.springblade.modules.market.pojo.entity.MarketDailySummaryEntity;
|
||||
import org.springblade.modules.market.pojo.entity.MarketInfoEntity;
|
||||
import org.springblade.modules.market.pojo.vo.MarketDailySummaryVO;
|
||||
import org.springblade.modules.market.excel.MarketDailySummaryExcel;
|
||||
import org.springblade.modules.market.mapper.MarketDailySummaryMapper;
|
||||
import org.springblade.modules.market.service.IMarketDailySummaryService;
|
||||
import org.springblade.modules.market.service.IMarketInfoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 用户日汇总表 服务实现类
|
||||
@@ -42,9 +57,13 @@ import java.util.List;
|
||||
* @author RayL
|
||||
* @since 2026-04-30
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class MarketDailySummaryServiceImpl extends BaseServiceImpl<MarketDailySummaryMapper, MarketDailySummaryEntity> implements IMarketDailySummaryService {
|
||||
|
||||
private final IMarketInfoService marketInfoService;
|
||||
|
||||
@Override
|
||||
public IPage<MarketDailySummaryVO> selectDailySummaryPage(IPage<MarketDailySummaryVO> page, MarketDailySummaryVO dailySummary) {
|
||||
return page.setRecords(baseMapper.selectDailySummaryPage(page, dailySummary));
|
||||
@@ -60,4 +79,41 @@ public class MarketDailySummaryServiceImpl extends BaseServiceImpl<MarketDailySu
|
||||
return dailySummaryList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<MarketSummaryInfoApiVO> selectInfoListByPid(Long userId) {
|
||||
if (Objects.isNull(userId)) {
|
||||
throw new ServiceException("无效用户");
|
||||
}
|
||||
MarketInfoEntity marketInfo = marketInfoService.getById(userId);
|
||||
if (Objects.isNull(marketInfo)) {
|
||||
throw new ServiceException("无效用户信息");
|
||||
}
|
||||
List<Long> ids = marketInfoService.selectIdsByPid(marketInfo.getId());
|
||||
if (ids.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (ids.size() > 100) {
|
||||
log.info("User {} has too many subordinates: {}", userId, ids.size());
|
||||
throw new ServiceException("团队规模过大,暂不支持");
|
||||
}
|
||||
String idArrayStr = ids.stream()
|
||||
.map(String::valueOf)
|
||||
.collect(Collectors.joining(StringPool.COMMA, StringPool.LEFT_BRACE, StringPool.RIGHT_BRACE));
|
||||
List<MarketSummaryInfoApiVO> voList = baseMapper.selectApiVOByIds(idArrayStr);
|
||||
voList.forEach(vo -> {
|
||||
vo.setPhone(SensitiveUtil.process(vo.getPhone()));
|
||||
if (StringUtil.isNotBlank(vo.getName())) {
|
||||
vo.setName(desensitizationByName(vo.getName()));
|
||||
} else {
|
||||
vo.setName("未实名");
|
||||
}
|
||||
});
|
||||
return voList;
|
||||
}
|
||||
|
||||
private String desensitizationByName(String name) {
|
||||
return name.replaceAll("^(.).*$", "$1" + "*".repeat(name.length() - 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,12 +34,14 @@ import org.springblade.common.utils.CommonUtil;
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.redis.ratelimiter.RateLimiter;
|
||||
import org.springblade.core.tool.sensitive.SensitiveUtil;
|
||||
import org.springblade.core.tool.utils.DateUtil;
|
||||
import org.springblade.core.tool.utils.DigestUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.modules.api.client.RemoteVerifyClient;
|
||||
import org.springblade.modules.api.response.remote.VerifyIDCardData;
|
||||
import org.springblade.modules.api.response.remote.RemoteResponse;
|
||||
import org.springblade.modules.api.vo.MarketDirectInfoApiVO;
|
||||
import org.springblade.modules.auth.provider.UserType;
|
||||
import org.springblade.modules.market.eums.IDCardVerifyStatus;
|
||||
import org.springblade.modules.common.pojo.entity.CommonUserPointEntity;
|
||||
@@ -190,4 +192,29 @@ public class MarketInfoServiceImpl extends BaseServiceImpl<MarketInfoMapper, Mar
|
||||
public List<MarketInfoSummaryDTO> selectMarketInfoSummaryByDate(Date date) {
|
||||
return baseMapper.selectMarketInfoSummaryByDate(date);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public MarketDirectInfoApiVO selectParent(Long userId) {
|
||||
if (Objects.isNull(userId)) {
|
||||
throw new ServiceException("无效用户");
|
||||
}
|
||||
MarketInfoEntity marketInfo = getById(userId);
|
||||
if (Objects.isNull(marketInfo)) {
|
||||
throw new ServiceException("无效用户");
|
||||
}
|
||||
if (Objects.isNull(marketInfo.getPid())) {
|
||||
return null;
|
||||
}
|
||||
MarketDirectInfoApiVO vo = baseMapper.selectParent(marketInfo.getPid());
|
||||
if (Objects.nonNull(vo)) {
|
||||
vo.setPhone(SensitiveUtil.process(vo.getPhone()));
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> selectIdsByPid(Long pid) {
|
||||
return baseMapper.selectIdsByPid(pid);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user