新增团队数据, 两个定时任务 , 一个初始化, 一个统计团队数据
This commit is contained in:
@@ -1,3 +1,88 @@
|
||||
CREATE INDEX idx_user_order_tptt ON user_order (order_type, payment_type, create_time);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS market_performance_day_log;
|
||||
CREATE TABLE market_performance_day_log
|
||||
(
|
||||
id int8 NOT NULL PRIMARY KEY, -- 主键ID
|
||||
user_id int8 NOT NULL, -- 用户ID
|
||||
stats_day int4 NOT NULL, -- 统计时间(按天统计)
|
||||
stats_month int4 NOT NULL, -- 统计时间(按月统计)
|
||||
owen_sales decimal(14, 2) default 0, -- 昨日个人消费业绩
|
||||
sales_amount decimal(14, 2) default 0, -- 昨日团队消费业绩
|
||||
owen_benefits decimal(14, 2) default 0, -- 昨日个人福利值业绩
|
||||
benefits_value decimal(14, 2) default 0, -- 昨日团队福利值业绩
|
||||
team_number int4 default 0, -- 昨日团队新增人数
|
||||
benefits_pack int4 default 0, -- 昨日团队兑换福利包数量
|
||||
remarks text, -- 备注
|
||||
create_user int8, -- 创建人
|
||||
create_dept int8, -- 创建部门
|
||||
create_time timestamp(6), -- 创建时间
|
||||
update_user int8, -- 修改人
|
||||
update_time timestamp(6), -- 修改时间
|
||||
status int4, -- 状态
|
||||
is_deleted int4 DEFAULT 0 -- 是否已删除
|
||||
|
||||
);
|
||||
CREATE INDEX idx_mpddl_day_user ON market_performance_day_log (stats_day, user_id);
|
||||
CREATE INDEX idx_mpddl_user_recent ON market_performance_day_log (user_id, stats_day DESC);
|
||||
|
||||
COMMENT ON TABLE market_performance_day_log IS '用户团队业绩统计表';
|
||||
COMMENT ON COLUMN market_performance_day_log.id IS '主键ID';
|
||||
COMMENT ON COLUMN market_performance_day_log.user_id IS '用户ID';
|
||||
COMMENT ON COLUMN market_performance_day_log.stats_day IS '统计时间(按天统计)';
|
||||
COMMENT ON COLUMN market_performance_day_log.stats_month IS '统计时间(按月统计)';
|
||||
COMMENT ON COLUMN market_performance_day_log.owen_sales IS '昨日个人消费业绩';
|
||||
COMMENT ON COLUMN market_performance_day_log.sales_amount IS '昨日团队消费业绩';
|
||||
COMMENT ON COLUMN market_performance_day_log.owen_benefits IS '昨日个人福利值业绩';
|
||||
COMMENT ON COLUMN market_performance_day_log.benefits_value IS '昨日团队福利值业绩';
|
||||
COMMENT ON COLUMN market_performance_day_log.team_number IS '昨日团队新增人数';
|
||||
COMMENT ON COLUMN market_performance_day_log.benefits_pack IS '昨日团队兑换福利包数量';
|
||||
COMMENT ON COLUMN market_performance_day_log.remarks IS '备注';
|
||||
COMMENT ON COLUMN market_performance_day_log.create_user IS '创建人';
|
||||
COMMENT ON COLUMN market_performance_day_log.create_dept IS '创建部门';
|
||||
COMMENT ON COLUMN market_performance_day_log.create_time IS '创建时间';
|
||||
COMMENT ON COLUMN market_performance_day_log.update_user IS '修改人';
|
||||
COMMENT ON COLUMN market_performance_day_log.update_time IS '修改时间';
|
||||
COMMENT ON COLUMN market_performance_day_log.status IS '状态';
|
||||
COMMENT ON COLUMN market_performance_day_log.is_deleted IS '是否已删除';
|
||||
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS market_team;
|
||||
CREATE TABLE market_team
|
||||
(
|
||||
id int8 NOT NULL PRIMARY KEY, -- 主键ID
|
||||
user_id int8 NOT NULL, -- 用户ID
|
||||
sales_total decimal(14, 2) default 0, -- 团队消费总业绩
|
||||
benefits_total decimal(14, 2) default 0, -- 团队福利值总业绩
|
||||
team_total int4 default 0, -- 团队总数
|
||||
remarks text, -- 备注
|
||||
create_user int8, -- 创建人
|
||||
create_dept int8, -- 创建部门
|
||||
create_time timestamp(6), -- 创建时间
|
||||
update_user int8, -- 修改人
|
||||
update_time timestamp(6), -- 修改时间
|
||||
status int4, -- 状态
|
||||
is_deleted int4 DEFAULT 0 -- 是否已删除
|
||||
|
||||
);
|
||||
CREATE INDEX idx_team_user ON market_team (user_id);
|
||||
|
||||
COMMENT ON TABLE market_team IS '用户团队数据';
|
||||
COMMENT ON COLUMN market_team.id IS '主键ID';
|
||||
COMMENT ON COLUMN market_team.user_id IS '用户ID';
|
||||
COMMENT ON COLUMN market_team.sales_total IS '团队消费总业绩';
|
||||
COMMENT ON COLUMN market_team.benefits_total IS '团队福利值总业绩';
|
||||
COMMENT ON COLUMN market_team.team_total IS '团队总数';
|
||||
COMMENT ON COLUMN market_team.remarks IS '备注';
|
||||
COMMENT ON COLUMN market_team.create_user IS '创建人';
|
||||
COMMENT ON COLUMN market_team.create_dept IS '创建部门';
|
||||
COMMENT ON COLUMN market_team.create_time IS '创建时间';
|
||||
COMMENT ON COLUMN market_team.update_user IS '修改人';
|
||||
COMMENT ON COLUMN market_team.update_time IS '修改时间';
|
||||
COMMENT ON COLUMN market_team.status IS '状态';
|
||||
COMMENT ON COLUMN market_team.is_deleted IS '是否已删除';
|
||||
|
||||
@@ -0,0 +1,239 @@
|
||||
package org.springblade.job.processor;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.common.utils.date.DateUtil;
|
||||
import org.springblade.core.redis.cache.BladeRedis;
|
||||
import org.springblade.modules.common.eums.BusinessModule;
|
||||
import org.springblade.modules.common.pojo.entity.CommonOrderConfirmLogEntity;
|
||||
import org.springblade.modules.common.service.ICommonOrderConfirmLogService;
|
||||
import org.springblade.modules.market.pojo.entity.MarketBenefitPackageEntity;
|
||||
import org.springblade.modules.market.pojo.entity.MarketInfoEntity;
|
||||
import org.springblade.modules.market.pojo.entity.MarketPerformanceDayLogEntity;
|
||||
import org.springblade.modules.market.pojo.entity.MarketTeamEntity;
|
||||
import org.springblade.modules.market.service.IMarketBenefitPackageService;
|
||||
import org.springblade.modules.market.service.IMarketInfoService;
|
||||
import org.springblade.modules.market.service.IMarketPerformanceDayLogService;
|
||||
import org.springblade.modules.market.service.IMarketTeamService;
|
||||
import org.springblade.modules.system.pojo.entity.User;
|
||||
import org.springblade.modules.system.service.IUserService;
|
||||
import org.springframework.stereotype.Component;
|
||||
import tech.powerjob.worker.core.processor.ProcessResult;
|
||||
import tech.powerjob.worker.core.processor.TaskContext;
|
||||
import tech.powerjob.worker.core.processor.sdk.BasicProcessor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* 初始化团队业绩
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class InitPerformanceDayLogProcessor implements BasicProcessor {
|
||||
|
||||
private final IUserService userService;
|
||||
private final IMarketInfoService marketInfoService;
|
||||
private final ICommonOrderConfirmLogService commonOrderConfirmLogService;
|
||||
private final IMarketBenefitPackageService marketBenefitPackageService;
|
||||
private final IMarketPerformanceDayLogService marketPerformanceDayLogService;
|
||||
private final IMarketTeamService marketTeamService;
|
||||
private final BladeRedis bladeRedis;
|
||||
|
||||
@Override
|
||||
public ProcessResult process(TaskContext taskContext) throws Exception {
|
||||
|
||||
log.info("初始化团队业绩开始执行...");
|
||||
|
||||
Date today = DateUtil.getToday();
|
||||
Map<Long , MarketPerformanceDayLogEntity> marketPerformanceDayLogMap = new HashMap<>();
|
||||
Map<Long , MarketTeamEntity> marketTeamMap = new HashMap<>();
|
||||
|
||||
List<User> marketInfoEntityList = userService.list(Wrappers.<User>lambdaQuery().eq(User::getUserType, 2).eq(User::getIsDeleted, 0).le(User::getCreateTime, today));
|
||||
log.info("初始化团队业绩开始执行...查询团队数据完成,数据量:{}", marketInfoEntityList.size());
|
||||
|
||||
if (!marketInfoEntityList.isEmpty()){
|
||||
List<Long> parentIds = new ArrayList<>();
|
||||
|
||||
for (User marketInfo : marketInfoEntityList) {
|
||||
List<Long> selectedAncestorIds = marketInfoService.selectAncestorIds(marketInfo.getId());
|
||||
selectedAncestorIds.remove(marketInfo.getId());
|
||||
parentIds.addAll(selectedAncestorIds);
|
||||
|
||||
}
|
||||
|
||||
Map<Long, Long> idCountMap = parentIds.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
id -> id, // 分组依据:ID 本身
|
||||
Collectors.counting() // 统计方式:计数
|
||||
));
|
||||
|
||||
// 计算团队总人数
|
||||
idCountMap.forEach((id, count) -> {
|
||||
|
||||
marketTeamMap.compute(id, (key, existingTeam) -> {
|
||||
// 如果不存在,先 new 一个
|
||||
MarketTeamEntity team = (existingTeam == null) ? new MarketTeamEntity() : existingTeam;
|
||||
team.setUserId(id);
|
||||
// 计算新的总数
|
||||
int currentTotal = (team.getTeamTotal() == null) ? 0 : team.getTeamTotal();
|
||||
team.setTeamTotal(currentTotal + Math.toIntExact(count));
|
||||
|
||||
return team;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 计算团队总消费
|
||||
String orderType = BusinessModule.SELF_OPERATED_MALL.getCode().toUpperCase();
|
||||
List<CommonOrderConfirmLogEntity> orderConfirmLogList = commonOrderConfirmLogService.list(
|
||||
Wrappers.lambdaQuery(CommonOrderConfirmLogEntity.class)
|
||||
.in(CommonOrderConfirmLogEntity::getPaymentType, List.of(1, 2))
|
||||
.func(queryWrapper -> queryWrapper.apply("UPPER(order_type) = {0}", orderType))
|
||||
.le(CommonOrderConfirmLogEntity::getCreateTime, today)
|
||||
.orderByAsc(CommonOrderConfirmLogEntity::getId)
|
||||
);
|
||||
|
||||
|
||||
if (!orderConfirmLogList.isEmpty()){
|
||||
Set<Long> userIds = orderConfirmLogList.stream()
|
||||
.map(CommonOrderConfirmLogEntity::getUserId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 4. 批量查询上级链 (修复 N+1) - 假设你有一个批量方法 batchSelectAncestorIds
|
||||
// 如果没有,请参考之前的方法实现它
|
||||
Map<Long, List<Long>> userAncestorCache = batchSelectAncestorIds(userIds);
|
||||
|
||||
for (CommonOrderConfirmLogEntity order : orderConfirmLogList) {
|
||||
// 安全获取金额
|
||||
BigDecimal actualAmount = order.getActualAmount();
|
||||
if (actualAmount == null) {
|
||||
actualAmount = BigDecimal.ZERO;
|
||||
}
|
||||
BigDecimal finalActualAmount = actualAmount;
|
||||
List<Long> ancestorIds = userAncestorCache.getOrDefault(order.getUserId(), Collections.emptyList());
|
||||
ancestorIds.remove(order.getUserId());
|
||||
|
||||
for (Long ancestorId : ancestorIds){
|
||||
|
||||
marketTeamMap.compute(ancestorId, (key, existingTeam) -> {
|
||||
// 如果不存在,先 new 一个
|
||||
MarketTeamEntity team = (existingTeam == null) ? new MarketTeamEntity() : existingTeam;
|
||||
team.setUserId(ancestorId);
|
||||
// 计算新的总数
|
||||
BigDecimal salesTotal = (team.getSalesTotal() == null) ? BigDecimal.ZERO : team.getSalesTotal();
|
||||
team.setSalesTotal(salesTotal.add(finalActualAmount));
|
||||
return team;
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
List<MarketBenefitPackageEntity> packageEntityList = marketBenefitPackageService.list(
|
||||
Wrappers.lambdaQuery(MarketBenefitPackageEntity.class)
|
||||
.eq(MarketBenefitPackageEntity::getType, 1)
|
||||
.eq(MarketBenefitPackageEntity::getStatus, 2)
|
||||
.le(MarketBenefitPackageEntity::getCreateTime, today)
|
||||
);
|
||||
|
||||
if (!packageEntityList.isEmpty()){
|
||||
Set<Long> userIdToPacks = orderConfirmLogList.stream()
|
||||
.map(CommonOrderConfirmLogEntity::getUserId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 4. 批量查询上级链 (修复 N+1) - 假设你有一个批量方法 batchSelectAncestorIds
|
||||
// 如果没有,请参考之前的方法实现它
|
||||
Map<Long, List<Long>> userAncestorToPackCache = batchSelectAncestorIds(userIdToPacks);
|
||||
|
||||
// stream packageEntityList 根据userId 分组
|
||||
Map<Long, List<MarketBenefitPackageEntity>> packageEntityMap = packageEntityList.stream()
|
||||
.collect(Collectors.groupingBy(MarketBenefitPackageEntity::getUserId));
|
||||
packageEntityMap.forEach((userId, packageList) -> {
|
||||
// packageList stream 计算 总消费
|
||||
BigDecimal totalUserBenefit = packageList.stream()
|
||||
.map(MarketBenefitPackageEntity::getUserBenefit)
|
||||
.reduce(BigDecimal::add)
|
||||
.orElse(BigDecimal.ZERO);
|
||||
|
||||
List<Long> ancestorIds = userAncestorToPackCache.getOrDefault(userId, Collections.emptyList());
|
||||
ancestorIds.remove(userId);
|
||||
|
||||
for (Long ancestorId : ancestorIds){
|
||||
MarketPerformanceDayLogEntity marketPerformanceDayLog;
|
||||
if (marketPerformanceDayLogMap.containsKey(ancestorId)){
|
||||
marketPerformanceDayLog = marketPerformanceDayLogMap.get(ancestorId);
|
||||
marketPerformanceDayLog.setBenefitsValue(marketPerformanceDayLog.getBenefitsValue().add(totalUserBenefit));
|
||||
marketPerformanceDayLog.setBenefitsPack(marketPerformanceDayLog.getBenefitsPack() + packageList.size());
|
||||
}else {
|
||||
marketPerformanceDayLog = new MarketPerformanceDayLogEntity();
|
||||
marketPerformanceDayLog.setUserId(ancestorId);
|
||||
marketPerformanceDayLog.setBenefitsValue(totalUserBenefit);
|
||||
marketPerformanceDayLog.setBenefitsPack(packageList.size());
|
||||
}
|
||||
marketPerformanceDayLogMap.put(ancestorId, marketPerformanceDayLog);
|
||||
|
||||
marketTeamMap.compute(ancestorId, (key, existingTeam) -> {
|
||||
// 如果不存在,先 new 一个
|
||||
MarketTeamEntity team = (existingTeam == null) ? new MarketTeamEntity() : existingTeam;
|
||||
team.setUserId(ancestorId);
|
||||
// 计算新的总数
|
||||
BigDecimal benefitsTotal = (team.getBenefitsTotal() == null) ? BigDecimal.ZERO : team.getBenefitsTotal();
|
||||
team.setSalesTotal(benefitsTotal.add(totalUserBenefit));
|
||||
return team;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Integer day = Integer.parseInt(DateUtil.convertFromDate(DateUtil.getYesterday() , "yyyyMMdd"));
|
||||
Integer mouth = Integer.parseInt(DateUtil.convertFromDate(DateUtil.getYesterday() , "yyyyMM"));
|
||||
// marketPerformanceDayLogMap 转list
|
||||
List<MarketPerformanceDayLogEntity> marketPerformanceDayLogList = new ArrayList<>(marketPerformanceDayLogMap.values());
|
||||
marketPerformanceDayLogList.forEach(marketPerformanceDayLog -> {
|
||||
marketPerformanceDayLog.setStatsDay(day);
|
||||
marketPerformanceDayLog.setStatsMonth(mouth);
|
||||
});
|
||||
marketPerformanceDayLogService.saveBatch(marketPerformanceDayLogList , 2000);
|
||||
|
||||
List<MarketTeamEntity> marketTeamList = new ArrayList<>(marketTeamMap.values());
|
||||
marketTeamService.saveBatch(marketTeamList , 2000);
|
||||
|
||||
return new ProcessResult(true, "result is success");
|
||||
}
|
||||
|
||||
private Map<Long, List<Long>> batchSelectAncestorIds(Set<Long> userIdList){
|
||||
Map<Long, List<Long>> userAncestorCache = new HashMap<>();
|
||||
String key = "yiyu:market:user:ancestor:";
|
||||
userIdList.forEach(userId -> {
|
||||
Object ancestorIdsObject = bladeRedis.get(key + userId);
|
||||
if (ancestorIdsObject == null) {
|
||||
|
||||
List<Long> ancestorIds = new ArrayList<>(List.of(userId));
|
||||
ancestorIds.addAll(marketInfoService.selectAncestorIds(userId));
|
||||
bladeRedis.set(key + userId, ancestorIds);
|
||||
userAncestorCache.put(userId, ancestorIds);
|
||||
}else {
|
||||
userAncestorCache.put(userId, JSONArray.parseArray(JSONArray.toJSONString(ancestorIdsObject), Long.class));
|
||||
}
|
||||
});
|
||||
|
||||
return userAncestorCache;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -18,9 +18,11 @@ import org.springblade.modules.common.service.ICommonOrderConfirmLogService;
|
||||
import org.springblade.modules.common.service.ICommonUserOrderService;
|
||||
import org.springblade.modules.market.pojo.entity.MarketCashPerformanceEntity;
|
||||
import org.springblade.modules.market.pojo.entity.MarketCashPerformanceLogEntity;
|
||||
import org.springblade.modules.market.pojo.entity.MarketPerformanceDayLogEntity;
|
||||
import org.springblade.modules.market.service.IMarketCashPerformanceLogService;
|
||||
import org.springblade.modules.market.service.IMarketCashPerformanceService;
|
||||
import org.springblade.modules.market.service.IMarketInfoService;
|
||||
import org.springblade.modules.market.service.IMarketPerformanceDayLogService;
|
||||
import org.springblade.modules.system.pojo.entity.User;
|
||||
import org.springblade.modules.system.service.IUserService;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -47,6 +49,7 @@ public class StatsCalculatorCashProcessor implements BasicProcessor {
|
||||
private final IMarketInfoService marketInfoService;
|
||||
private final IMarketCashPerformanceService cashPerformanceService;
|
||||
private final IMarketCashPerformanceLogService cashPerformanceLogService;
|
||||
private final IMarketPerformanceDayLogService marketPerformanceDayLogService;
|
||||
private final BladeRedis bladeRedis;
|
||||
|
||||
@Override
|
||||
@@ -90,6 +93,8 @@ public class StatsCalculatorCashProcessor implements BasicProcessor {
|
||||
Map<Long, MarketCashPerformanceEntity> cashPerformanceMap = new HashMap<>(); // 团队业绩
|
||||
Map<Long, MarketCashPerformanceEntity> owenCashPerformanceMap = new HashMap<>(); // 自身业绩
|
||||
|
||||
Map<Long , MarketPerformanceDayLogEntity> performanceDayLogMap = new HashMap<>();
|
||||
|
||||
// 6. 处理订单
|
||||
for (CommonOrderConfirmLogEntity order : orderPageList) {
|
||||
Long userId = order.getUserId();
|
||||
@@ -182,6 +187,20 @@ public class StatsCalculatorCashProcessor implements BasicProcessor {
|
||||
}
|
||||
});
|
||||
|
||||
marketCashPerformanceList.forEach(performance -> {
|
||||
|
||||
performanceDayLogMap.compute(performance.getId(), (key, existingTeam) -> {
|
||||
// 如果不存在,先 new 一个
|
||||
MarketPerformanceDayLogEntity marketPerformanceDayLog = (existingTeam == null) ? new MarketPerformanceDayLogEntity() : existingTeam;
|
||||
marketPerformanceDayLog.setUserId(performance.getId());
|
||||
// 计算新的总数
|
||||
BigDecimal benefitsTotal = (marketPerformanceDayLog.getSalesAmount() == null) ? BigDecimal.ZERO : marketPerformanceDayLog.getSalesAmount();
|
||||
marketPerformanceDayLog.setSalesAmount(benefitsTotal.add(performance.getTotalAmount()));
|
||||
return marketPerformanceDayLog;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
if (!owenCashPerformanceMap.isEmpty()) {
|
||||
ArrayList<MarketCashPerformanceEntity> marketCashPerformanceList = new ArrayList<>(owenCashPerformanceMap.values());
|
||||
@@ -198,6 +217,20 @@ public class StatsCalculatorCashProcessor implements BasicProcessor {
|
||||
}
|
||||
});
|
||||
|
||||
marketCashPerformanceList.forEach(performance -> {
|
||||
|
||||
performanceDayLogMap.compute(performance.getId(), (key, existingTeam) -> {
|
||||
// 如果不存在,先 new 一个
|
||||
MarketPerformanceDayLogEntity marketPerformanceDayLog = (existingTeam == null) ? new MarketPerformanceDayLogEntity() : existingTeam;
|
||||
marketPerformanceDayLog.setUserId(performance.getId());
|
||||
// 计算新的总数
|
||||
BigDecimal benefitsTotal = (marketPerformanceDayLog.getOwenSales() == null) ? BigDecimal.ZERO : marketPerformanceDayLog.getOwenSales();
|
||||
marketPerformanceDayLog.setOwenSales(benefitsTotal.add(performance.getOwenAmount()));
|
||||
return marketPerformanceDayLog;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// 清理本页数据,帮助 GC
|
||||
@@ -205,6 +238,34 @@ public class StatsCalculatorCashProcessor implements BasicProcessor {
|
||||
cashPerformanceMap.clear();
|
||||
owenCashPerformanceMap.clear();
|
||||
|
||||
List<MarketPerformanceDayLogEntity> performanceDayLogList = new ArrayList<>(performanceDayLogMap.values());
|
||||
Integer day = Integer.parseInt(DateUtil.convertFromDate(DateUtil.getYesterday() , "yyyyMMdd"));
|
||||
Integer mouth = Integer.parseInt(DateUtil.convertFromDate(DateUtil.getYesterday() , "yyyyMM"));
|
||||
performanceDayLogList.forEach(performanceDayLog -> {
|
||||
MarketPerformanceDayLogEntity marketPerformanceDayLog = marketPerformanceDayLogService.getOne(
|
||||
Wrappers.lambdaQuery(MarketPerformanceDayLogEntity.class)
|
||||
.eq(MarketPerformanceDayLogEntity::getUserId, performanceDayLog.getUserId())
|
||||
.eq(MarketPerformanceDayLogEntity::getStatsDay, day)
|
||||
);
|
||||
if (marketPerformanceDayLog == null){
|
||||
marketPerformanceDayLog = new MarketPerformanceDayLogEntity();
|
||||
marketPerformanceDayLog.setUserId(performanceDayLog.getUserId());
|
||||
marketPerformanceDayLog.setStatsDay(day);
|
||||
marketPerformanceDayLog.setStatsMonth(mouth);
|
||||
marketPerformanceDayLog.setOwenSales(performanceDayLog.getOwenSales());
|
||||
marketPerformanceDayLog.setSalesAmount(performanceDayLog.getSalesAmount());
|
||||
marketPerformanceDayLog.setOwenBenefits(BigDecimal.ZERO);
|
||||
marketPerformanceDayLog.setBenefitsValue(BigDecimal.ZERO);
|
||||
marketPerformanceDayLog.setTeamNumber(0);
|
||||
marketPerformanceDayLog.setBenefitsPack(0);
|
||||
marketPerformanceDayLogService.save(marketPerformanceDayLog);
|
||||
}else {
|
||||
marketPerformanceDayLog.setOwenSales(performanceDayLog.getOwenSales());
|
||||
marketPerformanceDayLog.setSalesAmount(performanceDayLog.getSalesAmount());
|
||||
marketPerformanceDayLogService.updateById(marketPerformanceDayLog);
|
||||
}
|
||||
});
|
||||
|
||||
return new ProcessResult(true, "result is success");
|
||||
|
||||
}
|
||||
|
||||
@@ -9,10 +9,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.common.utils.date.DateUtil;
|
||||
import org.springblade.core.redis.cache.BladeRedis;
|
||||
import org.springblade.core.tool.sensitive.SensitiveUtil;
|
||||
import org.springblade.modules.market.pojo.entity.MarketBenefitPackageEntity;
|
||||
import org.springblade.modules.market.pojo.entity.MarketBenefitPackageTemplateEntity;
|
||||
import org.springblade.modules.market.pojo.entity.MarketWelfarePerformanceEntity;
|
||||
import org.springblade.modules.market.pojo.entity.MarketWelfarePerformanceLogEntity;
|
||||
import org.springblade.modules.market.pojo.entity.*;
|
||||
import org.springblade.modules.market.service.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
import tech.powerjob.worker.core.processor.ProcessResult;
|
||||
@@ -38,7 +35,7 @@ public class StatsCalculatorWelfareProcessor implements BasicProcessor {
|
||||
private final IMarketWelfarePerformanceLogService welfarePerformanceLogService;
|
||||
private final IMarketBenefitPackageTemplateService benefitPackageTemplateService;
|
||||
private final IMarketBenefitPackageService benefitPackageService;
|
||||
|
||||
private final IMarketPerformanceDayLogService marketPerformanceDayLogService;
|
||||
private final BladeRedis bladeRedis;
|
||||
|
||||
@Override
|
||||
@@ -80,6 +77,8 @@ public class StatsCalculatorWelfareProcessor implements BasicProcessor {
|
||||
Map<Long, MarketWelfarePerformanceEntity> welfarePerformanceMap = new HashMap<>(); // 团队业绩
|
||||
Map<Long, MarketWelfarePerformanceEntity> owenWelfarePerformanceMap = new HashMap<>(); // 自身业绩
|
||||
|
||||
Map<Long , MarketPerformanceDayLogEntity> performanceDayLogMap = new HashMap<>();
|
||||
|
||||
// 处理每个用户的数据
|
||||
for (Map.Entry<Long, List<MarketBenefitPackageEntity>> entry : packageEntityMap.entrySet()) {
|
||||
Long userId = entry.getKey();
|
||||
@@ -142,6 +141,16 @@ public class StatsCalculatorWelfareProcessor implements BasicProcessor {
|
||||
welfarePerformanceMap.put(ancestorId, entity);
|
||||
}
|
||||
|
||||
performanceDayLogMap.compute(ancestorId, (key, existingTeam) -> {
|
||||
// 如果不存在,先 new 一个
|
||||
MarketPerformanceDayLogEntity marketPerformanceDayLog = (existingTeam == null) ? new MarketPerformanceDayLogEntity() : existingTeam;
|
||||
marketPerformanceDayLog.setUserId(ancestorId);
|
||||
// 计算新的总数
|
||||
int benefitsPack = (marketPerformanceDayLog.getBenefitsPack() == null) ? 0 : marketPerformanceDayLog.getBenefitsPack();
|
||||
marketPerformanceDayLog.setBenefitsPack(benefitsPack + packageList.size());
|
||||
return marketPerformanceDayLog;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// 3. 构建日志
|
||||
@@ -154,6 +163,8 @@ public class StatsCalculatorWelfareProcessor implements BasicProcessor {
|
||||
welfarePerformanceLogService.saveBatch(welfarePerformanceLogList, 5000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 注意:将 Map 的值转为 List 传入 Mapper
|
||||
if (!welfarePerformanceMap.isEmpty()) {
|
||||
|
||||
@@ -172,6 +183,20 @@ public class StatsCalculatorWelfareProcessor implements BasicProcessor {
|
||||
}
|
||||
});
|
||||
|
||||
marketWelfarePerformanceList.forEach(performance -> {
|
||||
|
||||
performanceDayLogMap.compute(performance.getId(), (key, existingTeam) -> {
|
||||
// 如果不存在,先 new 一个
|
||||
MarketPerformanceDayLogEntity marketPerformanceDayLog = (existingTeam == null) ? new MarketPerformanceDayLogEntity() : existingTeam;
|
||||
marketPerformanceDayLog.setUserId(performance.getId());
|
||||
// 计算新的总数
|
||||
BigDecimal benefitsTotal = (marketPerformanceDayLog.getBenefitsValue() == null) ? BigDecimal.ZERO : marketPerformanceDayLog.getBenefitsValue();
|
||||
marketPerformanceDayLog.setBenefitsValue(benefitsTotal.add(performance.getTotalAmount()));
|
||||
return marketPerformanceDayLog;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -190,8 +215,51 @@ public class StatsCalculatorWelfareProcessor implements BasicProcessor {
|
||||
}
|
||||
});
|
||||
|
||||
marketWelfarePerformanceList.forEach(performance -> {
|
||||
|
||||
performanceDayLogMap.compute(performance.getId(), (key, existingTeam) -> {
|
||||
// 如果不存在,先 new 一个
|
||||
MarketPerformanceDayLogEntity marketPerformanceDayLog = (existingTeam == null) ? new MarketPerformanceDayLogEntity() : existingTeam;
|
||||
marketPerformanceDayLog.setUserId(performance.getId());
|
||||
// 计算新的总数
|
||||
BigDecimal benefitsTotal = (marketPerformanceDayLog.getOwenBenefits() == null) ? BigDecimal.ZERO : marketPerformanceDayLog.getOwenBenefits();
|
||||
marketPerformanceDayLog.setOwenBenefits(benefitsTotal.add(performance.getOwenAmount()));
|
||||
return marketPerformanceDayLog;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
List<MarketPerformanceDayLogEntity> performanceDayLogList = new ArrayList<>(performanceDayLogMap.values());
|
||||
Integer day = Integer.parseInt(DateUtil.convertFromDate(DateUtil.getYesterday() , "yyyyMMdd"));
|
||||
Integer mouth = Integer.parseInt(DateUtil.convertFromDate(DateUtil.getYesterday() , "yyyyMM"));
|
||||
performanceDayLogList.forEach(performanceDayLog -> {
|
||||
MarketPerformanceDayLogEntity marketPerformanceDayLog = marketPerformanceDayLogService.getOne(
|
||||
Wrappers.lambdaQuery(MarketPerformanceDayLogEntity.class)
|
||||
.eq(MarketPerformanceDayLogEntity::getUserId, performanceDayLog.getUserId())
|
||||
.eq(MarketPerformanceDayLogEntity::getStatsDay, day)
|
||||
);
|
||||
if (marketPerformanceDayLog == null){
|
||||
marketPerformanceDayLog = new MarketPerformanceDayLogEntity();
|
||||
marketPerformanceDayLog.setUserId(performanceDayLog.getUserId());
|
||||
marketPerformanceDayLog.setStatsDay(day);
|
||||
marketPerformanceDayLog.setStatsMonth(mouth);
|
||||
marketPerformanceDayLog.setOwenSales(BigDecimal.ZERO);
|
||||
marketPerformanceDayLog.setSalesAmount(BigDecimal.ZERO);
|
||||
marketPerformanceDayLog.setOwenBenefits(performanceDayLog.getOwenBenefits());
|
||||
marketPerformanceDayLog.setBenefitsValue(performanceDayLog.getBenefitsValue());
|
||||
marketPerformanceDayLog.setTeamNumber(0);
|
||||
marketPerformanceDayLog.setBenefitsPack(performanceDayLog.getBenefitsPack());
|
||||
marketPerformanceDayLogService.save(marketPerformanceDayLog);
|
||||
}else {
|
||||
marketPerformanceDayLog.setOwenBenefits(performanceDayLog.getOwenBenefits());
|
||||
marketPerformanceDayLog.setBenefitsValue(performanceDayLog.getBenefitsValue());
|
||||
marketPerformanceDayLog.setBenefitsPack(performanceDayLog.getBenefitsPack());
|
||||
marketPerformanceDayLogService.updateById(marketPerformanceDayLog);
|
||||
}
|
||||
});
|
||||
|
||||
return new ProcessResult(true, "result is success");
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
package org.springblade.job.processor;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.common.utils.date.DateUtil;
|
||||
import org.springblade.modules.market.pojo.entity.MarketCashPerformanceEntity;
|
||||
import org.springblade.modules.market.pojo.entity.MarketPerformanceDayLogEntity;
|
||||
import org.springblade.modules.market.pojo.entity.MarketTeamEntity;
|
||||
import org.springblade.modules.market.pojo.entity.MarketWelfarePerformanceEntity;
|
||||
import org.springblade.modules.market.service.*;
|
||||
import org.springblade.modules.system.pojo.entity.User;
|
||||
import org.springblade.modules.system.service.IUserService;
|
||||
import org.springframework.stereotype.Component;
|
||||
import tech.powerjob.worker.core.processor.ProcessResult;
|
||||
import tech.powerjob.worker.core.processor.TaskContext;
|
||||
import tech.powerjob.worker.core.processor.sdk.BasicProcessor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 统计团队数据
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class StatsTeamProcessor implements BasicProcessor {
|
||||
|
||||
private final IUserService userService;
|
||||
private final IMarketInfoService marketInfoService;
|
||||
|
||||
private final IMarketPerformanceDayLogService marketPerformanceDayLogService;
|
||||
private final IMarketCashPerformanceService cashPerformanceService;
|
||||
private final IMarketWelfarePerformanceService welfarePerformanceService;
|
||||
private final IMarketTeamService marketTeamService;
|
||||
|
||||
@Override
|
||||
public ProcessResult process(TaskContext taskContext) throws Exception {
|
||||
|
||||
Map<Long , MarketTeamEntity> teamMap = new HashMap<>();
|
||||
Map<Long , MarketPerformanceDayLogEntity> performanceDayLogMap = new HashMap<>();
|
||||
|
||||
List<User> userList = userService.list(
|
||||
Wrappers.lambdaQuery(User.class)
|
||||
.between(User::getCreateTime, DateUtil.getYesterday(), DateUtil.getToday())
|
||||
);
|
||||
|
||||
if (!userList.isEmpty()){
|
||||
userList.forEach(user -> {
|
||||
List<Long> selectedAncestorIds = marketInfoService.selectAncestorIds(user.getId());
|
||||
selectedAncestorIds.remove(user.getId());
|
||||
|
||||
selectedAncestorIds.forEach(ancestorId -> {
|
||||
|
||||
performanceDayLogMap.compute(ancestorId, (key, existingTeam) -> {
|
||||
// 如果不存在,先 new 一个
|
||||
MarketPerformanceDayLogEntity marketPerformanceDayLog = (existingTeam == null) ? new MarketPerformanceDayLogEntity() : existingTeam;
|
||||
marketPerformanceDayLog.setUserId(ancestorId);
|
||||
// 计算新的总数
|
||||
int teamNumber = (marketPerformanceDayLog.getTeamNumber() == null) ? 0 : marketPerformanceDayLog.getTeamNumber();
|
||||
marketPerformanceDayLog.setTeamNumber(teamNumber + 1);
|
||||
return marketPerformanceDayLog;
|
||||
});
|
||||
|
||||
teamMap.compute(ancestorId, (key, existingTeam) -> {
|
||||
// 如果不存在,先 new 一个
|
||||
MarketTeamEntity marketTeam = (existingTeam == null) ? new MarketTeamEntity() : existingTeam;
|
||||
marketTeam.setUserId(ancestorId);
|
||||
// 计算新的总数
|
||||
int teamTotal = (marketTeam.getTeamTotal() == null) ? 0 : marketTeam.getTeamTotal();
|
||||
marketTeam.setTeamTotal(teamTotal + 1);
|
||||
return marketTeam;
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
Integer day = Integer.parseInt(DateUtil.convertFromDate(DateUtil.getYesterday() , "yyyyMMdd"));
|
||||
List<MarketPerformanceDayLogEntity> performanceDayLogList = marketPerformanceDayLogService.list(
|
||||
Wrappers.lambdaQuery(MarketPerformanceDayLogEntity.class)
|
||||
.eq(MarketPerformanceDayLogEntity::getStatsDay, day)
|
||||
);
|
||||
|
||||
List<Long> salesUserId = performanceDayLogList.stream()
|
||||
.filter(entity -> {
|
||||
boolean hasOwenSales = entity.getOwenSales() != null && entity.getOwenSales().compareTo(BigDecimal.ZERO) > 0;
|
||||
boolean hasSalesAmount = entity.getSalesAmount() != null && entity.getSalesAmount().compareTo(BigDecimal.ZERO) > 0;
|
||||
|
||||
return hasOwenSales || hasSalesAmount;
|
||||
})
|
||||
.map(MarketPerformanceDayLogEntity::getUserId)
|
||||
.toList();
|
||||
|
||||
List<Long> benefitsUserId = performanceDayLogList.stream()
|
||||
.filter(entity -> {
|
||||
boolean hasOwenSales = entity.getOwenBenefits() != null && entity.getOwenBenefits().compareTo(BigDecimal.ZERO) > 0;
|
||||
boolean hasSalesAmount = entity.getBenefitsValue() != null && entity.getBenefitsValue().compareTo(BigDecimal.ZERO) > 0;
|
||||
|
||||
return hasOwenSales || hasSalesAmount;
|
||||
})
|
||||
.map(MarketPerformanceDayLogEntity::getUserId)
|
||||
.toList();
|
||||
|
||||
if (!salesUserId.isEmpty()){
|
||||
List<MarketCashPerformanceEntity> cashPerformanceList = cashPerformanceService.list(
|
||||
Wrappers.lambdaQuery(MarketCashPerformanceEntity.class)
|
||||
.in(MarketCashPerformanceEntity::getId, salesUserId)
|
||||
);
|
||||
|
||||
cashPerformanceList.forEach(performance -> {
|
||||
|
||||
teamMap.compute(performance.getId(), (key, existingTeam) -> {
|
||||
MarketTeamEntity marketTeam = (existingTeam == null) ? new MarketTeamEntity() : existingTeam;
|
||||
marketTeam.setUserId(performance.getId());
|
||||
marketTeam.setSalesTotal(performance.getTotalAmount());
|
||||
return marketTeam;
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
if (!benefitsUserId.isEmpty()){
|
||||
List<MarketWelfarePerformanceEntity> welfarePerformanceList = welfarePerformanceService.list(
|
||||
Wrappers.lambdaQuery(MarketWelfarePerformanceEntity.class)
|
||||
.in(MarketWelfarePerformanceEntity::getId, benefitsUserId)
|
||||
);
|
||||
|
||||
|
||||
welfarePerformanceList.forEach(performance -> {
|
||||
teamMap.compute(performance.getId(), (key, existingTeam) -> {
|
||||
MarketTeamEntity marketTeam = (existingTeam == null) ? new MarketTeamEntity() : existingTeam;
|
||||
marketTeam.setUserId(performance.getId());
|
||||
marketTeam.setBenefitsTotal(performance.getTotalAmount());
|
||||
return marketTeam;
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
Integer mouth = Integer.parseInt(DateUtil.convertFromDate(DateUtil.getYesterday() , "yyyyMM"));
|
||||
List<MarketPerformanceDayLogEntity> updatePerformanceDayLogList = new ArrayList<>(performanceDayLogMap.values());
|
||||
|
||||
if(!updatePerformanceDayLogList.isEmpty()) {
|
||||
updatePerformanceDayLogList.forEach(performanceDayLog -> {
|
||||
MarketPerformanceDayLogEntity marketPerformanceDayLog = marketPerformanceDayLogService.getOne(
|
||||
Wrappers.lambdaQuery(MarketPerformanceDayLogEntity.class)
|
||||
.eq(MarketPerformanceDayLogEntity::getUserId, performanceDayLog.getUserId())
|
||||
.eq(MarketPerformanceDayLogEntity::getStatsDay, day)
|
||||
);
|
||||
if (marketPerformanceDayLog == null){
|
||||
marketPerformanceDayLog = new MarketPerformanceDayLogEntity();
|
||||
marketPerformanceDayLog.setUserId(performanceDayLog.getUserId());
|
||||
marketPerformanceDayLog.setStatsDay(day);
|
||||
marketPerformanceDayLog.setStatsMonth(mouth);
|
||||
marketPerformanceDayLog.setOwenSales(BigDecimal.ZERO);
|
||||
marketPerformanceDayLog.setSalesAmount(BigDecimal.ZERO);
|
||||
marketPerformanceDayLog.setOwenBenefits(BigDecimal.ZERO);
|
||||
marketPerformanceDayLog.setBenefitsValue(BigDecimal.ZERO);
|
||||
marketPerformanceDayLog.setTeamNumber(performanceDayLog.getTeamNumber());
|
||||
marketPerformanceDayLog.setBenefitsPack(0);
|
||||
marketPerformanceDayLogService.save(marketPerformanceDayLog);
|
||||
}else {
|
||||
marketPerformanceDayLog.setTeamNumber(performanceDayLog.getTeamNumber());
|
||||
marketPerformanceDayLogService.updateById(marketPerformanceDayLog);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
List<MarketTeamEntity> updateTeamList = new ArrayList<>(teamMap.values());
|
||||
|
||||
if (!updateTeamList.isEmpty()){
|
||||
updateTeamList.forEach(team -> {
|
||||
MarketTeamEntity marketTeamEntity = marketTeamService.getOne(
|
||||
Wrappers.lambdaQuery(MarketTeamEntity.class)
|
||||
.eq(MarketTeamEntity::getUserId, team.getUserId())
|
||||
);
|
||||
if (marketTeamEntity == null){
|
||||
marketTeamEntity = new MarketTeamEntity();
|
||||
marketTeamEntity.setUserId(team.getUserId());
|
||||
marketTeamEntity.setSalesTotal(team.getSalesTotal());
|
||||
marketTeamEntity.setBenefitsTotal(team.getBenefitsTotal());
|
||||
marketTeamEntity.setTeamTotal(team.getTeamTotal());
|
||||
marketTeamService.save(marketTeamEntity);
|
||||
}else {
|
||||
marketTeamEntity.setSalesTotal(team.getSalesTotal());
|
||||
marketTeamEntity.setBenefitsTotal(team.getBenefitsTotal());
|
||||
marketTeamEntity.setTeamTotal(marketTeamEntity.getTeamTotal() + team.getTeamTotal());
|
||||
marketTeamService.updateById(marketTeamEntity);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
return new ProcessResult(true, "result is success");
|
||||
}
|
||||
}
|
||||
@@ -152,8 +152,8 @@ public class MarketUserController {
|
||||
@GetMapping("/self-kpi")
|
||||
@ApiOperationSupport(order = 14)
|
||||
@Operation(summary = "昨日个人累计消费")
|
||||
public R<MarketKPIApiVO> userCommissionLogList() {
|
||||
return R.data(new MarketKPIApiVO());
|
||||
public R<MarketKPIApiVO> userSelfKpi() {
|
||||
return R.data(marketUserManager.userSelfKpi());
|
||||
}
|
||||
|
||||
@PostMapping("/real-name-verification")
|
||||
|
||||
@@ -56,31 +56,31 @@ public class MarketDirectInfoApiVO implements Serializable {
|
||||
/**
|
||||
* 团队总消费额
|
||||
*/
|
||||
private BigDecimal totalSalesAmount;
|
||||
private BigDecimal totalSalesAmount = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 昨日团队新增消费
|
||||
*/
|
||||
private BigDecimal increaseAmount;
|
||||
private BigDecimal increaseAmount = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 团队总福利值
|
||||
*/
|
||||
private BigDecimal totalBenefitsValue;
|
||||
private BigDecimal totalBenefitsValue = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 昨日团队新增福利值
|
||||
*/
|
||||
private BigDecimal increaseBenefitsValue;
|
||||
private BigDecimal increaseBenefitsValue = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 团队人数
|
||||
*/
|
||||
private Integer teamNumber;
|
||||
private Integer teamNumber = 0;
|
||||
|
||||
/**
|
||||
* 昨日团队新增人数
|
||||
*/
|
||||
private Integer increaseTeamNumber;
|
||||
private Integer increaseTeamNumber = 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.springblade.modules.api.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springblade.common.utils.date.DateUtil;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
@@ -10,6 +11,7 @@ import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class MarketKPIApiVO implements Serializable {
|
||||
|
||||
private BigDecimal totalSpending = BigDecimal.ZERO;
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
select
|
||||
upl.*,
|
||||
bu.account
|
||||
from blade_user bu
|
||||
left join user_point_log upl on bu.id = upl.user_id
|
||||
from user_point_log upl
|
||||
left join blade_user bu on bu.id = upl.user_id
|
||||
where bu.is_deleted = 0 and upl.is_deleted = 0 and upl.is_complete = 1
|
||||
<if test="pointLog.account != null">
|
||||
and bu.account = #{pointLog.account}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
package org.springblade.modules.market.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import lombok.AllArgsConstructor;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.modules.market.pojo.entity.MarketPerformanceDayLogEntity;
|
||||
import org.springblade.modules.market.pojo.vo.MarketPerformanceDayLogVO;
|
||||
import org.springblade.modules.market.wrapper.MarketPerformanceDayLogWrapper;
|
||||
import org.springblade.modules.market.service.IMarketPerformanceDayLogService;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 用户团队业绩统计表 控制器
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-04-11
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("market/performance-day-log")
|
||||
@Tag(name = "用户团队业绩统计表", description = "用户团队业绩统计表接口")
|
||||
public class MarketPerformanceDayLogController extends BladeController {
|
||||
|
||||
private final IMarketPerformanceDayLogService marketPerformanceDayLogService;
|
||||
|
||||
/**
|
||||
* 用户团队业绩统计表 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入marketPerformanceDayLog")
|
||||
public R<MarketPerformanceDayLogVO> detail(MarketPerformanceDayLogEntity marketPerformanceDayLog) {
|
||||
MarketPerformanceDayLogEntity detail = marketPerformanceDayLogService.getOne(Condition.getQueryWrapper(marketPerformanceDayLog));
|
||||
return R.data(MarketPerformanceDayLogWrapper.build().entityVO(detail));
|
||||
}
|
||||
/**
|
||||
* 用户团队业绩统计表 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入marketPerformanceDayLog")
|
||||
public R<IPage<MarketPerformanceDayLogVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> marketPerformanceDayLog, Query query) {
|
||||
IPage<MarketPerformanceDayLogEntity> pages = marketPerformanceDayLogService.page(Condition.getPage(query), Condition.getQueryWrapper(marketPerformanceDayLog, MarketPerformanceDayLogEntity.class));
|
||||
return R.data(MarketPerformanceDayLogWrapper.build().pageVO(pages));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户团队业绩统计表 自定义分页
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "分页", description = "传入marketPerformanceDayLog")
|
||||
public R<IPage<MarketPerformanceDayLogVO>> page(MarketPerformanceDayLogVO marketPerformanceDayLog, Query query) {
|
||||
IPage<MarketPerformanceDayLogVO> pages = marketPerformanceDayLogService.selectMarketPerformanceDayLogPage(Condition.getPage(query), marketPerformanceDayLog);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户团队业绩统计表 新增
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "新增", description = "传入marketPerformanceDayLog")
|
||||
public R save(@Valid @RequestBody MarketPerformanceDayLogEntity marketPerformanceDayLog) {
|
||||
return R.status(marketPerformanceDayLogService.save(marketPerformanceDayLog));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户团队业绩统计表 修改
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description = "传入marketPerformanceDayLog")
|
||||
public R update(@Valid @RequestBody MarketPerformanceDayLogEntity marketPerformanceDayLog) {
|
||||
return R.status(marketPerformanceDayLogService.updateById(marketPerformanceDayLog));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户团队业绩统计表 新增或修改
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入marketPerformanceDayLog")
|
||||
public R submit(@Valid @RequestBody MarketPerformanceDayLogEntity marketPerformanceDayLog) {
|
||||
return R.status(marketPerformanceDayLogService.saveOrUpdate(marketPerformanceDayLog));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户团队业绩统计表 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(marketPerformanceDayLogService.deleteLogic(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package org.springblade.modules.market.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import lombok.AllArgsConstructor;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.modules.market.pojo.entity.MarketTeamEntity;
|
||||
import org.springblade.modules.market.pojo.vo.MarketTeamVO;
|
||||
import org.springblade.modules.market.wrapper.MarketTeamWrapper;
|
||||
import org.springblade.modules.market.service.IMarketTeamService;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 用户团队数据 控制器
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-04-16
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("market/team/marketTeam")
|
||||
@Tag(name = "用户团队数据", description = "用户团队数据接口")
|
||||
public class MarketTeamController extends BladeController {
|
||||
|
||||
private final IMarketTeamService marketTeamService;
|
||||
|
||||
/**
|
||||
* 用户团队数据 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入marketTeam")
|
||||
public R<MarketTeamVO> detail(MarketTeamEntity marketTeam) {
|
||||
MarketTeamEntity detail = marketTeamService.getOne(Condition.getQueryWrapper(marketTeam));
|
||||
return R.data(MarketTeamWrapper.build().entityVO(detail));
|
||||
}
|
||||
/**
|
||||
* 用户团队数据 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入marketTeam")
|
||||
public R<IPage<MarketTeamVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> marketTeam, Query query) {
|
||||
IPage<MarketTeamEntity> pages = marketTeamService.page(Condition.getPage(query), Condition.getQueryWrapper(marketTeam, MarketTeamEntity.class));
|
||||
return R.data(MarketTeamWrapper.build().pageVO(pages));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户团队数据 自定义分页
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "分页", description = "传入marketTeam")
|
||||
public R<IPage<MarketTeamVO>> page(MarketTeamVO marketTeam, Query query) {
|
||||
IPage<MarketTeamVO> pages = marketTeamService.selectMarketTeamPage(Condition.getPage(query), marketTeam);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户团队数据 新增
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "新增", description = "传入marketTeam")
|
||||
public R save(@Valid @RequestBody MarketTeamEntity marketTeam) {
|
||||
return R.status(marketTeamService.save(marketTeam));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户团队数据 修改
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description = "传入marketTeam")
|
||||
public R update(@Valid @RequestBody MarketTeamEntity marketTeam) {
|
||||
return R.status(marketTeamService.updateById(marketTeam));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户团队数据 新增或修改
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入marketTeam")
|
||||
public R submit(@Valid @RequestBody MarketTeamEntity marketTeam) {
|
||||
return R.status(marketTeamService.saveOrUpdate(marketTeam));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户团队数据 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(marketTeamService.deleteLogic(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import org.springblade.core.tool.sensitive.SensitiveUtil;
|
||||
import org.springblade.modules.api.request.AcquireBenefitPackageRequest;
|
||||
import org.springblade.modules.api.vo.MarketDirectInfoApiVO;
|
||||
|
||||
import org.springblade.modules.api.vo.MarketKPIApiVO;
|
||||
import org.springblade.modules.api.vo.MarketPackageTemplateVO;
|
||||
import org.springblade.modules.api.vo.UserAssetsApiVO;
|
||||
import org.springblade.modules.common.pojo.entity.CommonUserOrderEntity;
|
||||
@@ -63,7 +64,8 @@ public class MarketUserManager {
|
||||
private final IMarketCashPerformanceService cashPerformanceService;
|
||||
private final IMarketWelfarePerformanceService welfarePerformanceService;
|
||||
|
||||
private final IParamService paramService;
|
||||
private final IMarketPerformanceDayLogService marketPerformanceDayLogService;
|
||||
private final IMarketTeamService marketTeamService;
|
||||
|
||||
public List<MarketDirectInfoApiVO> findUserPackList() {
|
||||
Long userId = AuthUtil.getUserId();
|
||||
@@ -92,30 +94,63 @@ public class MarketUserManager {
|
||||
.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){
|
||||
marketDirectInfoApiVOList.add(
|
||||
new MarketDirectInfoApiVO()
|
||||
.setPhone(SensitiveUtil.process(user.getAccount()))
|
||||
apiVO.setPhone(SensitiveUtil.process(user.getPhone()))
|
||||
.setName(desensitizationByName(marketInfo.getRealName()))
|
||||
.setRegisterTime(user.getCreateTime())
|
||||
);
|
||||
.setRegisterTime(user.getCreateTime());
|
||||
|
||||
}else {
|
||||
marketDirectInfoApiVOList.add(
|
||||
new MarketDirectInfoApiVO()
|
||||
.setPhone(SensitiveUtil.process(user.getAccount()))
|
||||
|
||||
apiVO.setPhone(SensitiveUtil.process(user.getAccount()))
|
||||
.setName(desensitizationByName(user.getName()))
|
||||
.setRegisterTime(user.getCreateTime())
|
||||
);
|
||||
.setRegisterTime(user.getCreateTime());
|
||||
}
|
||||
}
|
||||
|
||||
if (performanceDayLogMap.containsKey(user.getId())){
|
||||
apiVO.setIncreaseAmount(performanceDayLogMap.get(user.getId()).getSalesAmount())
|
||||
.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;
|
||||
|
||||
}
|
||||
@@ -481,4 +516,22 @@ public class MarketUserManager {
|
||||
return userPerformanceVO;
|
||||
|
||||
}
|
||||
|
||||
public MarketKPIApiVO userSelfKpi() {
|
||||
Long userId = AuthUtil.getUserId();
|
||||
Integer day = Integer.parseInt(DateUtil.convertFromDate(DateUtil.getYesterday() , "yyyyMMdd"));
|
||||
MarketPerformanceDayLogEntity marketPerformanceDayLog = marketPerformanceDayLogService.getOne(
|
||||
Wrappers.lambdaQuery(MarketPerformanceDayLogEntity.class)
|
||||
.eq(MarketPerformanceDayLogEntity::getUserId, userId)
|
||||
.eq(MarketPerformanceDayLogEntity::getStatsDay, day)
|
||||
);
|
||||
if (marketPerformanceDayLog == null){
|
||||
return new MarketKPIApiVO();
|
||||
}
|
||||
return new MarketKPIApiVO()
|
||||
.setTotalSpending(marketPerformanceDayLog.getOwenSales())
|
||||
.setBenefitsValue(marketPerformanceDayLog.getOwenBenefits())
|
||||
.setDate(DateUtil.getYesterday());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
select
|
||||
bpl.*,
|
||||
bu.account
|
||||
from blade_user bu
|
||||
left join benefit_point_log bpl on bu.id = bpl.user_id
|
||||
from benefit_point_log bpl
|
||||
left join blade_user bu on bu.id = bpl.user_id
|
||||
where bu.is_deleted = 0 and bu.user_type = 2 and bpl.is_deleted = 0 and bpl.is_complete = 1
|
||||
<if test="pointLog.account != null">
|
||||
and bu.account = #{pointLog.account}
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
select
|
||||
ccl.*,
|
||||
bu.account
|
||||
from blade_user bu
|
||||
left join cash_coupon_log ccl on bu.id = ccl.user_id
|
||||
from cash_coupon_log ccl
|
||||
left join blade_user bu on bu.id = ccl.user_id
|
||||
where bu.is_deleted = 0 and bu.user_type = 2 and ccl.is_deleted = 0 and ccl.is_complete = 1
|
||||
<if test="cashLog.account != null">
|
||||
and bu.account = #{cashLog.account}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.springblade.modules.market.mapper;
|
||||
|
||||
import org.springblade.modules.market.pojo.entity.MarketPerformanceDayLogEntity;
|
||||
import org.springblade.modules.market.pojo.vo.MarketPerformanceDayLogVO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户团队业绩统计表 Mapper 接口
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-04-11
|
||||
*/
|
||||
public interface MarketPerformanceDayLogMapper extends BaseMapper<MarketPerformanceDayLogEntity> {
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param marketPerformanceDayLog 查询参数
|
||||
* @return List<MarketPerformanceDayLogVO>
|
||||
*/
|
||||
List<MarketPerformanceDayLogVO> selectMarketPerformanceDayLogPage(IPage page, MarketPerformanceDayLogVO marketPerformanceDayLog);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.springblade.modules.market.mapper.MarketPerformanceDayLogMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="marketPerformanceDayLogResultMap" type="org.springblade.modules.market.pojo.entity.MarketPerformanceDayLogEntity">
|
||||
<result column="id" property="id"/>
|
||||
<result column="user_id" property="userId"/>
|
||||
<result column="stats_day" property="statsDay"/>
|
||||
<result column="stats_month" property="statsMonth"/>
|
||||
<result column="sales_amount" property="salesAmount"/>
|
||||
<result column="sales_total" property="salesTotal"/>
|
||||
<result column="benefits_value" property="benefitsValue"/>
|
||||
<result column="benefits_total" property="benefitsTotal"/>
|
||||
<result column="team_number" property="teamNumber"/>
|
||||
<result column="team_total" property="teamTotal"/>
|
||||
<result column="benefits_pack" property="benefitsPack"/>
|
||||
<result column="benefits_pack_detail" property="benefitsPackDetail"/>
|
||||
<result column="remarks" property="remarks"/>
|
||||
<result column="create_user" property="createUser"/>
|
||||
<result column="create_dept" property="createDept"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_user" property="updateUser"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="selectMarketPerformanceDayLogPage" resultMap="marketPerformanceDayLogResultMap">
|
||||
select * from market_performance_day_log where is_deleted = 0
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.springblade.modules.market.mapper;
|
||||
|
||||
import org.springblade.modules.market.pojo.entity.MarketTeamEntity;
|
||||
import org.springblade.modules.market.pojo.vo.MarketTeamVO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户团队数据 Mapper 接口
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-04-16
|
||||
*/
|
||||
public interface MarketTeamMapper extends BaseMapper<MarketTeamEntity> {
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param marketTeam 查询参数
|
||||
* @return List<MarketTeamVO>
|
||||
*/
|
||||
List<MarketTeamVO> selectMarketTeamPage(IPage page, MarketTeamVO marketTeam);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.springblade.modules.market.mapper.MarketTeamMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="marketTeamResultMap" type="org.springblade.modules.market.pojo.entity.MarketTeamEntity">
|
||||
<result column="id" property="id"/>
|
||||
<result column="user_id" property="userId"/>
|
||||
<result column="sales_total" property="salesTotal"/>
|
||||
<result column="benefits_total" property="benefitsTotal"/>
|
||||
<result column="team_total" property="teamTotal"/>
|
||||
<result column="remarks" property="remarks"/>
|
||||
<result column="create_user" property="createUser"/>
|
||||
<result column="create_dept" property="createDept"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_user" property="updateUser"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="selectMarketTeamPage" resultMap="marketTeamResultMap">
|
||||
select * from market_team where is_deleted = 0
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -29,8 +29,8 @@
|
||||
select
|
||||
ucl.*,
|
||||
bu.account
|
||||
from blade_user bu
|
||||
left join user_commission_log ucl on bu.id = ucl.user_id
|
||||
from user_commission_log ucl
|
||||
left join blade_user bu on bu.id = ucl.user_id
|
||||
where bu.is_deleted = 0 and bu.user_type = 2 and ucl.is_deleted = 0 and ucl.is_complete = 1
|
||||
<if test="commissionLog.account != null">
|
||||
and bu.account = #{commissionLog.account}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.springblade.modules.market.pojo.dto;
|
||||
|
||||
import org.springblade.modules.market.pojo.entity.MarketPerformanceDayLogEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 用户团队业绩统计表 数据传输对象实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-04-11
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class MarketPerformanceDayLogDTO extends MarketPerformanceDayLogEntity {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.springblade.modules.market.pojo.dto;
|
||||
|
||||
import org.springblade.modules.market.pojo.entity.MarketTeamEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 用户团队数据 数据传输对象实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-04-16
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class MarketTeamDTO extends MarketTeamEntity {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package org.springblade.modules.market.pojo.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.math.BigDecimal;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springblade.core.mp.base.BaseEntity;
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 用户团队业绩统计表 实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-04-11
|
||||
*/
|
||||
@Data
|
||||
@TableName("market_performance_day_log")
|
||||
@Schema(description = "MarketPerformanceDayLog对象")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class MarketPerformanceDayLogEntity extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@Schema(description = "用户ID")
|
||||
private Long userId;
|
||||
/**
|
||||
* 统计时间(按天统计)
|
||||
*/
|
||||
@Schema(description = "统计时间(按天统计)")
|
||||
private Integer statsDay;
|
||||
/**
|
||||
* 统计时间(按月统计)
|
||||
*/
|
||||
@Schema(description = "统计时间(按月统计)")
|
||||
private Integer statsMonth;
|
||||
|
||||
/**
|
||||
* 昨日个人消费业绩
|
||||
*/
|
||||
@Schema(description = "昨日个人消费业绩")
|
||||
private BigDecimal owenSales;
|
||||
|
||||
/**
|
||||
* 昨日团队消费业绩
|
||||
*/
|
||||
@Schema(description = "昨日团队消费业绩")
|
||||
private BigDecimal salesAmount;
|
||||
|
||||
/**
|
||||
* 昨日个人福利值业绩
|
||||
*/
|
||||
@Schema(description = "昨日个人福利值业绩")
|
||||
private BigDecimal owenBenefits;
|
||||
|
||||
/**
|
||||
* 昨日团队福利值业绩
|
||||
*/
|
||||
@Schema(description = "昨日团队福利值业绩")
|
||||
private BigDecimal benefitsValue;
|
||||
/**
|
||||
* 昨日团队新增人数
|
||||
*/
|
||||
@Schema(description = "昨日团队新增人数")
|
||||
private Integer teamNumber;
|
||||
|
||||
/**
|
||||
* 昨日团队兑换福利包数量
|
||||
*/
|
||||
@Schema(description = "昨日团队兑换福利包数量")
|
||||
private Integer benefitsPack;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Schema(description = "备注")
|
||||
private String remarks;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package org.springblade.modules.market.pojo.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.math.BigDecimal;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springblade.core.mp.base.BaseEntity;
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 用户团队数据 实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-04-16
|
||||
*/
|
||||
@Data
|
||||
@TableName("market_team")
|
||||
@Schema(description = "MarketTeam对象")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class MarketTeamEntity extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@Schema(description = "用户ID")
|
||||
private Long userId;
|
||||
/**
|
||||
* 团队消费总业绩
|
||||
*/
|
||||
@Schema(description = "团队消费总业绩")
|
||||
private BigDecimal salesTotal;
|
||||
/**
|
||||
* 团队福利值总业绩
|
||||
*/
|
||||
@Schema(description = "团队福利值总业绩")
|
||||
private BigDecimal benefitsTotal;
|
||||
/**
|
||||
* 团队总数
|
||||
*/
|
||||
@Schema(description = "团队总数")
|
||||
private Integer teamTotal;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Schema(description = "备注")
|
||||
private String remarks;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.springblade.modules.market.pojo.vo;
|
||||
|
||||
import org.springblade.modules.market.pojo.entity.MarketPerformanceDayLogEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 用户团队业绩统计表 视图实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-04-11
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class MarketPerformanceDayLogVO extends MarketPerformanceDayLogEntity {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.springblade.modules.market.pojo.vo;
|
||||
|
||||
import org.springblade.modules.market.pojo.entity.MarketTeamEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 用户团队数据 视图实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-04-16
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class MarketTeamVO extends MarketTeamEntity {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.springblade.modules.market.service;
|
||||
|
||||
import org.springblade.modules.market.pojo.entity.MarketPerformanceDayLogEntity;
|
||||
import org.springblade.modules.market.pojo.vo.MarketPerformanceDayLogVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.core.mp.base.BaseService;
|
||||
|
||||
/**
|
||||
* 用户团队业绩统计表 服务类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-04-11
|
||||
*/
|
||||
public interface IMarketPerformanceDayLogService extends BaseService<MarketPerformanceDayLogEntity> {
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param marketPerformanceDayLog 查询参数
|
||||
* @return IPage<MarketPerformanceDayLogVO>
|
||||
*/
|
||||
IPage<MarketPerformanceDayLogVO> selectMarketPerformanceDayLogPage(IPage<MarketPerformanceDayLogVO> page, MarketPerformanceDayLogVO marketPerformanceDayLog);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.springblade.modules.market.service;
|
||||
|
||||
import org.springblade.modules.market.pojo.entity.MarketTeamEntity;
|
||||
import org.springblade.modules.market.pojo.vo.MarketTeamVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.core.mp.base.BaseService;
|
||||
|
||||
/**
|
||||
* 用户团队数据 服务类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-04-16
|
||||
*/
|
||||
public interface IMarketTeamService extends BaseService<MarketTeamEntity> {
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param marketTeam 查询参数
|
||||
* @return IPage<MarketTeamVO>
|
||||
*/
|
||||
IPage<MarketTeamVO> selectMarketTeamPage(IPage<MarketTeamVO> page, MarketTeamVO marketTeam);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.springblade.modules.market.service.impl;
|
||||
|
||||
import org.springblade.modules.market.pojo.entity.MarketPerformanceDayLogEntity;
|
||||
import org.springblade.modules.market.pojo.vo.MarketPerformanceDayLogVO;
|
||||
import org.springblade.modules.market.mapper.MarketPerformanceDayLogMapper;
|
||||
import org.springblade.modules.market.service.IMarketPerformanceDayLogService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
|
||||
/**
|
||||
* 用户团队业绩统计表 服务实现类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-04-11
|
||||
*/
|
||||
@Service
|
||||
public class MarketPerformanceDayLogServiceImpl extends BaseServiceImpl<MarketPerformanceDayLogMapper, MarketPerformanceDayLogEntity> implements IMarketPerformanceDayLogService {
|
||||
|
||||
@Override
|
||||
public IPage<MarketPerformanceDayLogVO> selectMarketPerformanceDayLogPage(IPage<MarketPerformanceDayLogVO> page, MarketPerformanceDayLogVO marketPerformanceDayLog) {
|
||||
return page.setRecords(baseMapper.selectMarketPerformanceDayLogPage(page, marketPerformanceDayLog));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.springblade.modules.market.service.impl;
|
||||
|
||||
import org.springblade.modules.market.pojo.entity.MarketTeamEntity;
|
||||
import org.springblade.modules.market.pojo.vo.MarketTeamVO;
|
||||
import org.springblade.modules.market.mapper.MarketTeamMapper;
|
||||
import org.springblade.modules.market.service.IMarketTeamService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
|
||||
/**
|
||||
* 用户团队数据 服务实现类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-04-16
|
||||
*/
|
||||
@Service
|
||||
public class MarketTeamServiceImpl extends BaseServiceImpl<MarketTeamMapper, MarketTeamEntity> implements IMarketTeamService {
|
||||
|
||||
@Override
|
||||
public IPage<MarketTeamVO> selectMarketTeamPage(IPage<MarketTeamVO> page, MarketTeamVO marketTeam) {
|
||||
return page.setRecords(baseMapper.selectMarketTeamPage(page, marketTeam));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.springblade.modules.market.wrapper;
|
||||
|
||||
import org.springblade.core.mp.support.BaseEntityWrapper;
|
||||
import org.springblade.core.tool.utils.BeanUtil;
|
||||
import org.springblade.modules.market.pojo.entity.MarketPerformanceDayLogEntity;
|
||||
import org.springblade.modules.market.pojo.vo.MarketPerformanceDayLogVO;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 用户团队业绩统计表 包装类,返回视图层所需的字段
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-04-11
|
||||
*/
|
||||
public class MarketPerformanceDayLogWrapper extends BaseEntityWrapper<MarketPerformanceDayLogEntity, MarketPerformanceDayLogVO> {
|
||||
|
||||
public static MarketPerformanceDayLogWrapper build() {
|
||||
return new MarketPerformanceDayLogWrapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MarketPerformanceDayLogVO entityVO(MarketPerformanceDayLogEntity marketPerformanceDayLog) {
|
||||
MarketPerformanceDayLogVO marketPerformanceDayLogVO = Objects.requireNonNull(BeanUtil.copyProperties(marketPerformanceDayLog, MarketPerformanceDayLogVO.class));
|
||||
|
||||
//User createUser = UserCache.getUser(marketPerformanceDayLog.getCreateUser());
|
||||
//User updateUser = UserCache.getUser(marketPerformanceDayLog.getUpdateUser());
|
||||
//marketPerformanceDayLogVO.setCreateUserName(createUser.getName());
|
||||
//marketPerformanceDayLogVO.setUpdateUserName(updateUser.getName());
|
||||
|
||||
return marketPerformanceDayLogVO;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* 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.market.wrapper;
|
||||
|
||||
import org.springblade.core.mp.support.BaseEntityWrapper;
|
||||
import org.springblade.core.tool.utils.BeanUtil;
|
||||
import org.springblade.modules.market.pojo.entity.MarketTeamEntity;
|
||||
import org.springblade.modules.market.pojo.vo.MarketTeamVO;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 用户团队数据 包装类,返回视图层所需的字段
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-04-16
|
||||
*/
|
||||
public class MarketTeamWrapper extends BaseEntityWrapper<MarketTeamEntity, MarketTeamVO> {
|
||||
|
||||
public static MarketTeamWrapper build() {
|
||||
return new MarketTeamWrapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MarketTeamVO entityVO(MarketTeamEntity marketTeam) {
|
||||
MarketTeamVO marketTeamVO = Objects.requireNonNull(BeanUtil.copyProperties(marketTeam, MarketTeamVO.class));
|
||||
|
||||
//User createUser = UserCache.getUser(marketTeam.getCreateUser());
|
||||
//User updateUser = UserCache.getUser(marketTeam.getUpdateUser());
|
||||
//marketTeamVO.setCreateUserName(createUser.getName());
|
||||
//marketTeamVO.setUpdateUserName(updateUser.getName());
|
||||
|
||||
return marketTeamVO;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user