完成了Web端仪表盘

This commit is contained in:
2025-07-13 21:08:38 +08:00
parent 455802ee9f
commit 6ac8765b39
8 changed files with 314 additions and 34 deletions

View File

@ -1,11 +1,8 @@
package com.greenorange.promotion.controller.userInfo; package com.greenorange.promotion.controller.userInfo;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.hash.Hash;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.greenorange.promotion.annotation.RequiresPermission; import com.greenorange.promotion.annotation.RequiresPermission;
import com.greenorange.promotion.common.BaseResponse; import com.greenorange.promotion.common.BaseResponse;
@ -13,13 +10,12 @@ import com.greenorange.promotion.common.ResultUtils;
import com.greenorange.promotion.constant.OrderStatusConstant; import com.greenorange.promotion.constant.OrderStatusConstant;
import com.greenorange.promotion.constant.SystemConstant; import com.greenorange.promotion.constant.SystemConstant;
import com.greenorange.promotion.constant.UserConstant; import com.greenorange.promotion.constant.UserConstant;
import com.greenorange.promotion.model.dto.CommonStringRequest;
import com.greenorange.promotion.model.dto.userPerformanceSummary.*; import com.greenorange.promotion.model.dto.userPerformanceSummary.*;
import com.greenorange.promotion.model.entity.*; import com.greenorange.promotion.model.entity.*;
import com.greenorange.promotion.model.enums.CommissionStatusEnum; import com.greenorange.promotion.model.enums.CommissionStatusEnum;
import com.greenorange.promotion.model.enums.UserRoleEnum; import com.greenorange.promotion.model.enums.UserRoleEnum;
import com.greenorange.promotion.model.vo.courseOrder.CourseOrderBaseInfoVO;
import com.greenorange.promotion.model.vo.courseOrder.CourseOrderDetailInfoVO; import com.greenorange.promotion.model.vo.courseOrder.CourseOrderDetailInfoVO;
import com.greenorange.promotion.model.vo.dashboard.WebQueryDashboardVO;
import com.greenorange.promotion.model.vo.userPerformanceSummary.SupervisorPerformanceSummaryVO; import com.greenorange.promotion.model.vo.userPerformanceSummary.SupervisorPerformanceSummaryVO;
import com.greenorange.promotion.model.vo.userPerformanceSummary.UserPerformanceSummaryDetailVO; import com.greenorange.promotion.model.vo.userPerformanceSummary.UserPerformanceSummaryDetailVO;
import com.greenorange.promotion.service.common.CommonService; import com.greenorange.promotion.service.common.CommonService;
@ -33,8 +29,6 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@ -82,6 +76,101 @@ public class UserPerformanceSummaryController {
/**
* Web端仪表盘
* @return 用户绩效汇总
*/
@PostMapping("query/dashboard")
@Operation(summary = "Web端管理员分页查询主管绩效汇总", description = "参数权限管理员方法名webQueryDashboard")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
public BaseResponse<WebQueryDashboardVO> webQueryDashboard() {
BigDecimal totalAmount = BigDecimal.ZERO;
BigDecimal netAmount = BigDecimal.ZERO;
Integer promoCount = 0;
Integer superCount;
Integer empCount = 0;
Integer orderCount = 0;
BigDecimal toRelease = BigDecimal.ZERO;
BigDecimal toSettle = BigDecimal.ZERO;
BigDecimal settled = BigDecimal.ZERO;
BigDecimal refunded = BigDecimal.ZERO;
Integer todayOrderCount;
BigDecimal todayOrderAmount;
Integer todayRefundCount;
BigDecimal todayRefundAmount;
Integer todayPromotionCount;
Integer monthOrderCount;
BigDecimal monthOrderAmount;
Integer monthRefundCount;
BigDecimal monthRefundAmount;
Integer monthPromotionCount;
List<UserInfo> userInfoList = commonService.findByFieldEqTargetField(UserInfo::getUserRole, UserConstant.SUPERVISOR_ROLE, userInfoService);
List<UserPerformanceSummary> userPerformanceSummaryList = commonService.findByFieldInTargetField(userInfoList, userPerformanceSummaryService, UserInfo::getId, UserPerformanceSummary::getUserId);
superCount = userPerformanceSummaryList.size();
for (UserPerformanceSummary userPerformanceSummary : userPerformanceSummaryList) {
totalAmount = totalAmount.add(userPerformanceSummary.getTotalAmount());
netAmount = netAmount.add(userPerformanceSummary.getNetAmount());
promoCount += userPerformanceSummary.getPromoCount();
empCount += userPerformanceSummary.getEmpCount();
orderCount += userPerformanceSummary.getOrderCount();
toRelease = toRelease.add(userPerformanceSummary.getToRelease());
toSettle = toSettle.add(userPerformanceSummary.getToSettle());
settled = settled.add(userPerformanceSummary.getSettled());
refunded = refunded.add(userPerformanceSummary.getRefunded());
}
DateTime now = DateUtil.date();
// 查看今天的绩效
DateTime beginOfDay = DateUtil.beginOfDay(now);
DateTime endOfDay = DateUtil.endOfDay(now);
Map<String, Object> todayPerformanceSummary = userPerformanceSummaryService.getPerformanceSummaryByStartAndEndTime(beginOfDay, endOfDay);
todayOrderCount = (Integer) todayPerformanceSummary.get("orderCount");
todayOrderAmount = (BigDecimal) todayPerformanceSummary.get("orderAmount");
todayRefundCount = (Integer) todayPerformanceSummary.get("refundCount");
todayRefundAmount = (BigDecimal) todayPerformanceSummary.get("refundAmount");
todayPromotionCount = (Integer) todayPerformanceSummary.get("promotionCount");
// 查看本月的绩效
DateTime beginOfMonth = DateUtil.beginOfMonth(now);
DateTime endOfMonth = DateUtil.beginOfMonth(now);
Map<String, Object> monthPerformanceSummary = userPerformanceSummaryService.getPerformanceSummaryByStartAndEndTime(beginOfMonth, endOfMonth);
monthOrderCount = (Integer) monthPerformanceSummary.get("orderCount");
monthOrderAmount = (BigDecimal) monthPerformanceSummary.get("orderAmount");
monthRefundCount = (Integer) monthPerformanceSummary.get("refundCount");
monthRefundAmount = (BigDecimal) monthPerformanceSummary.get("refundAmount");
monthPromotionCount = (Integer) monthPerformanceSummary.get("promotionCount");
WebQueryDashboardVO webQueryDashboardVO = WebQueryDashboardVO.builder()
.totalAmount(totalAmount)
.netAmount(netAmount)
.promoCount(promoCount)
.superCount(superCount)
.empCount(empCount)
.orderCount(orderCount)
.toRelease(toRelease)
.toSettle(toSettle)
.settled(settled)
.refunded(refunded)
.todayOrderCount(todayOrderCount)
.todayOrderAmount(todayOrderAmount)
.todayRefundCount(todayRefundCount)
.todayRefundAmount(todayRefundAmount)
.todayPromotionCount(todayPromotionCount)
.monthOrderCount(monthOrderCount)
.monthOrderAmount(monthOrderAmount)
.monthRefundCount(monthRefundCount)
.monthRefundAmount(monthRefundAmount)
.monthPromotionCount(monthPromotionCount)
.build();
return ResultUtils.success(webQueryDashboardVO);
}
/** /**
@ -263,8 +352,8 @@ public class UserPerformanceSummaryController {
// 封装Map集合主管id, 值:净成交金额) // 封装Map集合主管id, 值:净成交金额)
Map<Long, BigDecimal> supervisorNetSalesAmountMap = new HashMap<>(); Map<Long, BigDecimal> supervisorNetSalesAmountMap = new HashMap<>();
QueryWrapper<CoursePromotionCommissionPending> coursePromotionQueryWrapper = new QueryWrapper<>(); QueryWrapper<CoursePromotionCommissionPending> coursePromotionQueryWrapper = new QueryWrapper<>();
coursePromotionQueryWrapper.ge(StringUtils.isNotBlank(startTimeStr), "createTime", startDate); coursePromotionQueryWrapper.ge(StringUtils.isNotBlank(startTimeStr), "orderCreateTime", startDate);
coursePromotionQueryWrapper.le(StringUtils.isNotBlank(endTimeStr), "createTime", endDate); coursePromotionQueryWrapper.le(StringUtils.isNotBlank(endTimeStr), "orderCreateTime", endDate);
List<CoursePromotionCommissionPending> coursePromotionCommissionPendingList = coursePromotionCommissionPendingService.list(coursePromotionQueryWrapper); List<CoursePromotionCommissionPending> coursePromotionCommissionPendingList = coursePromotionCommissionPendingService.list(coursePromotionQueryWrapper);
for (CoursePromotionCommissionPending coursePromotionCommissionPending : coursePromotionCommissionPendingList) { for (CoursePromotionCommissionPending coursePromotionCommissionPending : coursePromotionCommissionPendingList) {
Long firstUserId = coursePromotionCommissionPending.getFirstUserId(); Long firstUserId = coursePromotionCommissionPending.getFirstUserId();
@ -343,8 +432,8 @@ public class UserPerformanceSummaryController {
// 封装Map集合员工id, 值:净成交金额) // 封装Map集合员工id, 值:净成交金额)
Map<Long, BigDecimal> staffNetSalesAmountMap = new HashMap<>(); Map<Long, BigDecimal> staffNetSalesAmountMap = new HashMap<>();
QueryWrapper<CoursePromotionCommissionPending> coursePromotionQueryWrapper = new QueryWrapper<>(); QueryWrapper<CoursePromotionCommissionPending> coursePromotionQueryWrapper = new QueryWrapper<>();
coursePromotionQueryWrapper.ge(StringUtils.isNotBlank(startTimeStr), "createTime", startDate); coursePromotionQueryWrapper.ge(StringUtils.isNotBlank(startTimeStr), "orderCreateTime", startDate);
coursePromotionQueryWrapper.le(StringUtils.isNotBlank(endTimeStr), "createTime", endDate); coursePromotionQueryWrapper.le(StringUtils.isNotBlank(endTimeStr), "orderCreateTime", endDate);
List<CoursePromotionCommissionPending> coursePromotionCommissionPendingList = coursePromotionCommissionPendingService.list(coursePromotionQueryWrapper); List<CoursePromotionCommissionPending> coursePromotionCommissionPendingList = coursePromotionCommissionPendingService.list(coursePromotionQueryWrapper);
for (CoursePromotionCommissionPending coursePromotionCommissionPending : coursePromotionCommissionPendingList) { for (CoursePromotionCommissionPending coursePromotionCommissionPending : coursePromotionCommissionPendingList) {
Long secondUserId = coursePromotionCommissionPending.getSecondUserId(); Long secondUserId = coursePromotionCommissionPending.getSecondUserId();
@ -658,8 +747,8 @@ public class UserPerformanceSummaryController {
// 封装Map集合主管id, 值:净成交金额) // 封装Map集合主管id, 值:净成交金额)
Map<Long, BigDecimal> supervisorNetSalesAmountMap = new HashMap<>(); Map<Long, BigDecimal> supervisorNetSalesAmountMap = new HashMap<>();
QueryWrapper<CoursePromotionCommissionPending> coursePromotionQueryWrapper = new QueryWrapper<>(); QueryWrapper<CoursePromotionCommissionPending> coursePromotionQueryWrapper = new QueryWrapper<>();
coursePromotionQueryWrapper.ge(StringUtils.isNotBlank(startTimeStr), "createTime", startDate); coursePromotionQueryWrapper.ge(StringUtils.isNotBlank(startTimeStr), "orderCreateTime", startDate);
coursePromotionQueryWrapper.le(StringUtils.isNotBlank(endTimeStr), "createTime", endDate); coursePromotionQueryWrapper.le(StringUtils.isNotBlank(endTimeStr), "orderCreateTime", endDate);
List<CoursePromotionCommissionPending> coursePromotionCommissionPendingList = coursePromotionCommissionPendingService.list(coursePromotionQueryWrapper); List<CoursePromotionCommissionPending> coursePromotionCommissionPendingList = coursePromotionCommissionPendingService.list(coursePromotionQueryWrapper);
for (CoursePromotionCommissionPending coursePromotionCommissionPending : coursePromotionCommissionPendingList) { for (CoursePromotionCommissionPending coursePromotionCommissionPending : coursePromotionCommissionPendingList) {
Long firstUserId = coursePromotionCommissionPending.getFirstUserId(); Long firstUserId = coursePromotionCommissionPending.getFirstUserId();
@ -737,8 +826,8 @@ public class UserPerformanceSummaryController {
// 封装Map集合员工id, 值:净成交金额) // 封装Map集合员工id, 值:净成交金额)
Map<Long, BigDecimal> staffNetSalesAmountMap = new HashMap<>(); Map<Long, BigDecimal> staffNetSalesAmountMap = new HashMap<>();
QueryWrapper<CoursePromotionCommissionPending> coursePromotionQueryWrapper = new QueryWrapper<>(); QueryWrapper<CoursePromotionCommissionPending> coursePromotionQueryWrapper = new QueryWrapper<>();
coursePromotionQueryWrapper.ge(StringUtils.isNotBlank(startTimeStr), "createTime", startDate); coursePromotionQueryWrapper.ge(StringUtils.isNotBlank(startTimeStr), "orderCreateTime", startDate);
coursePromotionQueryWrapper.le(StringUtils.isNotBlank(endTimeStr), "createTime", endDate); coursePromotionQueryWrapper.le(StringUtils.isNotBlank(endTimeStr), "orderCreateTime", endDate);
List<CoursePromotionCommissionPending> coursePromotionCommissionPendingList = coursePromotionCommissionPendingService.list(coursePromotionQueryWrapper); List<CoursePromotionCommissionPending> coursePromotionCommissionPendingList = coursePromotionCommissionPendingService.list(coursePromotionQueryWrapper);
for (CoursePromotionCommissionPending coursePromotionCommissionPending : coursePromotionCommissionPendingList) { for (CoursePromotionCommissionPending coursePromotionCommissionPending : coursePromotionCommissionPendingList) {
Long secondUserId = coursePromotionCommissionPending.getSecondUserId(); Long secondUserId = coursePromotionCommissionPending.getSecondUserId();

View File

@ -46,11 +46,6 @@ public class UserPerformanceSummary implements Serializable {
*/ */
private Integer promoCount; private Integer promoCount;
/**
* 主管数量
*/
private Integer superCount;
/** /**
* 员工数量 * 员工数量
*/ */

View File

@ -0,0 +1,142 @@
package com.greenorange.promotion.model.vo.dashboard;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class WebQueryDashboardVO implements Serializable {
/**
* 订单总金额
*/
@Schema(description = "订单总金额", example = "1000.00")
private BigDecimal totalAmount;
/**
* 净成交
*/
@Schema(description = "净成交", example = "800.00")
private BigDecimal netAmount;
/**
* 客户数量
*/
@Schema(description = "客户数量", example = "10")
private Integer promoCount;
/**
* 主管数量
*/
@Schema(description = "主管数量", example = "15")
private Integer superCount;
/**
* 员工数量
*/
@Schema(description = "员工数量", example = "15")
private Integer empCount;
/**
* 下单数量
*/
@Schema(description = "下单数量", example = "25")
private Integer orderCount;
/**
* 待释放
*/
@Schema(description = "待释放", example = "1000.00")
private BigDecimal toRelease;
/**
* 可结算
*/
@Schema(description = "可结算", example = "600.00")
private BigDecimal toSettle;
/**
* 已结算
*/
@Schema(description = "已结算", example = "200.00")
private BigDecimal settled;
/**
* 已回退
*/
@Schema(description = "已回退", example = "100.00")
private BigDecimal refunded;
/**
* 今日下单数量
*/
@Schema(description = "今日下单数量", example = "10")
private Integer todayOrderCount;
/**
* 今日下单总金额
*/
@Schema(description = "今日下单总金额", example = "100.00")
private BigDecimal todayOrderAmount;
/**
* 今日退款数量
*/
@Schema(description = "今日退款数量", example = "10")
private Integer todayRefundCount;
/**
* 今日下单退款金额
*/
@Schema(description = "今日下单退款金额", example = "90.00")
private BigDecimal todayRefundAmount;
/**
* 今日推广数量
*/
@Schema(description = "今日推广数量", example = "10")
private Integer todayPromotionCount;
/**
* 本月下单数量
*/
@Schema(description = "本月下单数量", example = "100")
private Integer monthOrderCount;
/**
* 本月下单金额
*/
@Schema(description = "本月下单金额", example = "1000.00")
private BigDecimal monthOrderAmount;
/**
* 本月退款数量
*/
@Schema(description = "本月退款数量", example = "10")
private Integer monthRefundCount;
/**
* 本月退款金额
*/
@Schema(description = "本月退款金额", example = "1000.00")
private BigDecimal monthRefundAmount;
/**
* 本月推广数量
*/
@Schema(description = "本月推广数量", example = "10")
private Integer monthPromotionCount;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -50,12 +50,6 @@ public class UserPerformanceSummaryDetailVO implements Serializable {
@Schema(description = "推广人数", example = "300") @Schema(description = "推广人数", example = "300")
private Integer promoCount; private Integer promoCount;
/**
* 主管数量
*/
@Schema(description = "主管数量", example = "5")
private Integer superCount;
/** /**
* 员工数量 * 员工数量
*/ */

View File

@ -38,12 +38,6 @@ public class UserPerformanceSummaryVO implements Serializable {
@Schema(description = "推广人数", example = "") @Schema(description = "推广人数", example = "")
private Integer promoCount; private Integer promoCount;
/**
* 主管数量
*/
@Schema(description = "主管数量", example = "")
private Integer superCount;
/** /**
* 员工数量 * 员工数量
*/ */

View File

@ -1,5 +1,6 @@
package com.greenorange.promotion.service.userInfo; package com.greenorange.promotion.service.userInfo;
import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.greenorange.promotion.common.PageRequest; import com.greenorange.promotion.common.PageRequest;
@ -55,4 +56,10 @@ public interface UserPerformanceSummaryService extends IService<UserPerformanceS
* 在内存 List 上模拟 MyBatis-Plus 的分页 * 在内存 List 上模拟 MyBatis-Plus 的分页
*/ */
Page<SupervisorPerformanceSummaryVO> queryPage(UserPerformanceSummaryRankQueryRequest req, List<SupervisorPerformanceSummaryVO> allVos); Page<SupervisorPerformanceSummaryVO> queryPage(UserPerformanceSummaryRankQueryRequest req, List<SupervisorPerformanceSummaryVO> allVos);
/**
* 查看某个时间段的绩效
*/
Map<String, Object> getPerformanceSummaryByStartAndEndTime(DateTime beginOfDay, DateTime endOfDay);
} }

View File

@ -412,8 +412,6 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
userPerformanceSummary.setPromoCount(userPerformanceSummary.getPromoCount() + 1); userPerformanceSummary.setPromoCount(userPerformanceSummary.getPromoCount() + 1);
} else if (userRoleEnum.equals(UserRoleEnum.STAFF)) { } else if (userRoleEnum.equals(UserRoleEnum.STAFF)) {
userPerformanceSummary.setEmpCount(userPerformanceSummary.getEmpCount() + 1); userPerformanceSummary.setEmpCount(userPerformanceSummary.getEmpCount() + 1);
} else if (userRoleEnum.equals(UserRoleEnum.SUPERVISOR)) {
userPerformanceSummary.setSuperCount(userPerformanceSummary.getSuperCount() + 1);
} }
} }
userPerformanceSummaryService.updateBatchById(userPerformanceSummaryList); userPerformanceSummaryService.updateBatchById(userPerformanceSummaryList);

View File

@ -7,11 +7,17 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.greenorange.promotion.common.PageRequest; import com.greenorange.promotion.common.PageRequest;
import com.greenorange.promotion.constant.CommonConstant; import com.greenorange.promotion.constant.CommonConstant;
import com.greenorange.promotion.constant.SystemConstant;
import com.greenorange.promotion.model.dto.CommonStringRequest; import com.greenorange.promotion.model.dto.CommonStringRequest;
import com.greenorange.promotion.model.dto.userPerformanceSummary.*; import com.greenorange.promotion.model.dto.userPerformanceSummary.*;
import com.greenorange.promotion.model.entity.CourseOrder; import com.greenorange.promotion.model.entity.CourseOrder;
import com.greenorange.promotion.model.entity.CoursePromotionCommissionPending;
import com.greenorange.promotion.model.entity.EmployeePromotionRecords;
import com.greenorange.promotion.model.entity.UserPerformanceSummary; import com.greenorange.promotion.model.entity.UserPerformanceSummary;
import com.greenorange.promotion.model.enums.CommissionStatusEnum;
import com.greenorange.promotion.model.vo.userPerformanceSummary.SupervisorPerformanceSummaryVO; import com.greenorange.promotion.model.vo.userPerformanceSummary.SupervisorPerformanceSummaryVO;
import com.greenorange.promotion.service.course.CoursePromotionCommissionPendingService;
import com.greenorange.promotion.service.userInfo.EmployeePromotionRecordsService;
import com.greenorange.promotion.service.userInfo.UserInfoService; import com.greenorange.promotion.service.userInfo.UserInfoService;
import com.greenorange.promotion.service.userInfo.UserPerformanceSummaryService; import com.greenorange.promotion.service.userInfo.UserPerformanceSummaryService;
import com.greenorange.promotion.mapper.UserPerformanceSummaryMapper; import com.greenorange.promotion.mapper.UserPerformanceSummaryMapper;
@ -25,6 +31,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.security.Key; import java.security.Key;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
@ -39,11 +46,22 @@ import java.util.stream.Collectors;
public class UserPerformanceSummaryServiceImpl extends ServiceImpl<UserPerformanceSummaryMapper, UserPerformanceSummary> public class UserPerformanceSummaryServiceImpl extends ServiceImpl<UserPerformanceSummaryMapper, UserPerformanceSummary>
implements UserPerformanceSummaryService{ implements UserPerformanceSummaryService{
private static final String KEY = "rakeRate"; private static final String KEY = "rakeRate";
@Resource @Resource
private RedisTemplate<String, String> redisTemplate; private RedisTemplate<String, String> redisTemplate;
@Resource
private CoursePromotionCommissionPendingService coursePromotionCommissionPendingService;
@Resource
private EmployeePromotionRecordsService employeePromotionRecordsService;
/** /**
* 获取查询条件 * 获取查询条件
*/ */
@ -170,6 +188,49 @@ public class UserPerformanceSummaryServiceImpl extends ServiceImpl<UserPerforman
return page; return page;
} }
/**
* 查看某个时间段的绩效
*/
@Override
public Map<String, Object> getPerformanceSummaryByStartAndEndTime(DateTime beginOfDay, DateTime endOfDay) {
Map<String, Object> performanceSummaryMap = new HashMap<>();
Integer orderCount;
BigDecimal orderAmount = BigDecimal.ZERO;
Integer refundedCount = 0;
BigDecimal refundedAmount = BigDecimal.ZERO;
Integer promotionCount;
QueryWrapper<CoursePromotionCommissionPending> coursePromotionQueryWrapper = new QueryWrapper<>();
coursePromotionQueryWrapper.ge("orderCreateTime", beginOfDay);
coursePromotionQueryWrapper.le("orderCreateTime", endOfDay);
List<CoursePromotionCommissionPending> coursePromotionCommissionPendingList = coursePromotionCommissionPendingService.list(coursePromotionQueryWrapper);
orderCount = coursePromotionCommissionPendingList.size();
for (CoursePromotionCommissionPending coursePromotionCommissionPending : coursePromotionCommissionPendingList) {
String commissionStatus = coursePromotionCommissionPending.getCommissionStatus();
CommissionStatusEnum commissionStatusEnum = CommissionStatusEnum.getEnumByValue(commissionStatus);
orderAmount = orderAmount.add(coursePromotionCommissionPending.getTotalAmount());
if (CommissionStatusEnum.EXPIRED.equals(commissionStatusEnum)) {
refundedCount ++;
refundedAmount = refundedAmount.add(coursePromotionCommissionPending.getTotalAmount().multiply(SystemConstant.REFUND_RATE));
}
}
QueryWrapper<EmployeePromotionRecords> empQueryWrapper = new QueryWrapper<>();
empQueryWrapper.ge("createTime", beginOfDay);
empQueryWrapper.le("createTime", endOfDay);
List<EmployeePromotionRecords> employeePromotionRecordsList = employeePromotionRecordsService.list(empQueryWrapper);
promotionCount = employeePromotionRecordsList.size();
performanceSummaryMap.put("orderCount", orderCount);
performanceSummaryMap.put("orderAmount", orderAmount);
performanceSummaryMap.put("refundCount", refundedCount);
performanceSummaryMap.put("refundAmount", refundedAmount);
performanceSummaryMap.put("promotionCount", promotionCount);
return performanceSummaryMap;
}
} }