店员业绩
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package com.starry.admin.modules.statistics.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.starry.admin.modules.clerk.module.entity.PlayClerkLevelInfoEntity;
|
||||
import com.starry.admin.modules.clerk.module.entity.PlayClerkUserInfoEntity;
|
||||
import com.starry.admin.modules.clerk.service.IPlayClerkLevelInfoService;
|
||||
import com.starry.admin.modules.clerk.service.IPlayClerkUserInfoService;
|
||||
import com.starry.admin.modules.order.module.entity.PlayOrderInfoEntity;
|
||||
import com.starry.admin.modules.order.service.IPlayOrderInfoService;
|
||||
import com.starry.admin.modules.personnel.module.entity.PlayPersonnelGroupInfoEntity;
|
||||
import com.starry.admin.modules.personnel.service.IPlayPersonnelGroupInfoService;
|
||||
import com.starry.admin.modules.statistics.module.vo.PlayClerkPerformanceInfoQueryVo;
|
||||
import com.starry.admin.modules.statistics.module.vo.PlayClerkPerformanceInfoReturnVo;
|
||||
import com.starry.admin.modules.statistics.service.IPlayClerkPerformanceService;
|
||||
import com.starry.common.result.R;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 店员业绩查询对
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024/6/15 下午3:15
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/statistics/performance")
|
||||
public class PlayClerkPerformanceController {
|
||||
|
||||
@Resource
|
||||
private IPlayClerkUserInfoService clerkUserInfoService;
|
||||
|
||||
@Resource
|
||||
private IPlayOrderInfoService playOrderInfoService;
|
||||
|
||||
@Resource
|
||||
private IPlayClerkLevelInfoService playClerkLevelInfoService;
|
||||
|
||||
@Resource
|
||||
private IPlayPersonnelGroupInfoService playPersonnelGroupInfoService;
|
||||
|
||||
@Resource
|
||||
private IPlayClerkPerformanceService playClerkPerformanceService;
|
||||
|
||||
|
||||
@PostMapping("/listByPage")
|
||||
public R listByPage(@Validated @RequestBody PlayClerkPerformanceInfoQueryVo vo) {
|
||||
IPage<PlayClerkUserInfoEntity> page = clerkUserInfoService.selectByPage(vo);
|
||||
IPage<PlayClerkPerformanceInfoReturnVo> voPage = page.convert(u -> {
|
||||
List<PlayClerkLevelInfoEntity> clerkLevelInfoEntity = playClerkLevelInfoService.selectAll();
|
||||
String startTime = vo.getEndOrderTime() != null ? vo.getEndOrderTime().get(0) : "";
|
||||
String endTime = vo.getEndOrderTime() != null ? vo.getEndOrderTime().get(1) : "";
|
||||
List<PlayOrderInfoEntity> orderInfoEntities = playOrderInfoService.clerkSelectOrderInfoList(u.getId(), startTime, endTime);
|
||||
List<PlayPersonnelGroupInfoEntity> groupInfoEntities = playPersonnelGroupInfoService.selectAll();
|
||||
return playClerkPerformanceService.getClerkPerformanceInfo(u, orderInfoEntities, clerkLevelInfoEntity, groupInfoEntities);
|
||||
});
|
||||
return R.ok(voPage);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.starry.admin.modules.statistics.module.vo;
|
||||
|
||||
import com.starry.common.domain.BasePageEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @since 2024/6/10 下午8:58
|
||||
**/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class PlayClerkPerformanceInfoQueryVo extends BasePageEntity {
|
||||
|
||||
/**
|
||||
* 分组ID
|
||||
*/
|
||||
private String groupId;
|
||||
|
||||
|
||||
/**
|
||||
* 店员ID
|
||||
*/
|
||||
private String clerkId;
|
||||
|
||||
|
||||
/**
|
||||
* 店员性别
|
||||
*/
|
||||
private String sex;
|
||||
|
||||
|
||||
/**
|
||||
* 店员上架状态
|
||||
*/
|
||||
private String listingState;
|
||||
|
||||
|
||||
/**
|
||||
* 完成订单时间
|
||||
*/
|
||||
private List<String> endOrderTime;
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.starry.admin.modules.statistics.module.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @since 2024/6/10 下午8:58
|
||||
**/
|
||||
@Data
|
||||
public class PlayClerkPerformanceInfoReturnVo {
|
||||
|
||||
|
||||
/**
|
||||
* 店员ID
|
||||
*/
|
||||
private String clerkId;
|
||||
|
||||
/**
|
||||
* 店员昵称
|
||||
*/
|
||||
private String clerkNickname;
|
||||
|
||||
/**
|
||||
* 店员昵称
|
||||
*/
|
||||
private String clerkSex;
|
||||
/**
|
||||
* 分组名称
|
||||
*/
|
||||
private String groupName = "";
|
||||
/**
|
||||
* 分组名称
|
||||
*/
|
||||
private String levelName = "";
|
||||
/**
|
||||
* 在线时长
|
||||
*/
|
||||
private Integer onlineDuration = 0;
|
||||
/**
|
||||
* 订单总数
|
||||
*/
|
||||
private Integer orderNumber = 0;
|
||||
/**
|
||||
* 首单数
|
||||
*/
|
||||
private Integer orderFirstNumber = 0;
|
||||
/**
|
||||
* 续单数
|
||||
*/
|
||||
private Integer orderContinueNumber = 0;
|
||||
/**
|
||||
* 退款单数
|
||||
*/
|
||||
private Integer orderRefundNumber = 0;
|
||||
/**
|
||||
* 超时未接单数
|
||||
*/
|
||||
private Integer ordersExpiredNumber = 0;
|
||||
/**
|
||||
* 订单金额
|
||||
*/
|
||||
private BigDecimal finalAmount = BigDecimal.ZERO;
|
||||
/**
|
||||
* 首单金额
|
||||
*/
|
||||
private BigDecimal orderFirstAmount = BigDecimal.ZERO;
|
||||
/**
|
||||
* 续单金额
|
||||
*/
|
||||
private BigDecimal orderTotalAmount = BigDecimal.ZERO;
|
||||
/**
|
||||
* 打赏金额
|
||||
*/
|
||||
private BigDecimal orderRewardAmount = BigDecimal.ZERO;
|
||||
/**
|
||||
* 退款金额
|
||||
*/
|
||||
private BigDecimal orderRefundAmount = BigDecimal.ZERO;
|
||||
/**
|
||||
* 用户数
|
||||
*/
|
||||
private Integer customNumber = 0;
|
||||
|
||||
/**
|
||||
* 连续用户数
|
||||
*/
|
||||
private final Integer continuousCustomNumber = 0;
|
||||
/**
|
||||
* 续单比例
|
||||
*/
|
||||
private final BigDecimal orderContinueProportion = BigDecimal.ZERO;
|
||||
/**
|
||||
* 订单平均价格
|
||||
*/
|
||||
private final BigDecimal averageUnitPrice = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 续费率
|
||||
*/
|
||||
private BigDecimal orderContinueRechargeProportion = BigDecimal.ZERO;
|
||||
/**
|
||||
* 退单率
|
||||
*/
|
||||
private BigDecimal orderChargebackProportion = BigDecimal.ZERO;
|
||||
/**
|
||||
* 续客率
|
||||
*/
|
||||
private BigDecimal continuousCustomProportion = BigDecimal.ZERO;
|
||||
/**
|
||||
* 店员预计收入
|
||||
*/
|
||||
private BigDecimal estimatedRevenue = BigDecimal.ZERO;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.starry.admin.modules.statistics.service;
|
||||
|
||||
import com.starry.admin.modules.clerk.module.entity.PlayClerkLevelInfoEntity;
|
||||
import com.starry.admin.modules.clerk.module.entity.PlayClerkUserInfoEntity;
|
||||
import com.starry.admin.modules.order.module.entity.PlayOrderInfoEntity;
|
||||
import com.starry.admin.modules.personnel.module.entity.PlayPersonnelGroupInfoEntity;
|
||||
import com.starry.admin.modules.statistics.module.vo.PlayClerkPerformanceInfoReturnVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @since 2024/6/15 下午3:29
|
||||
**/
|
||||
public interface IPlayClerkPerformanceService {
|
||||
|
||||
|
||||
/**
|
||||
* 根据店员订单ID,生成店员业绩信息
|
||||
*
|
||||
* @param userInfo 店员信息
|
||||
* @param orderInfoEntities 店员订单列表
|
||||
* @param clerkLevelInfoEntity 店员等级信息
|
||||
* @param groupInfoEntities 店员分组信息
|
||||
* @return 业绩信息
|
||||
*/
|
||||
PlayClerkPerformanceInfoReturnVo getClerkPerformanceInfo(PlayClerkUserInfoEntity userInfo, List<PlayOrderInfoEntity> orderInfoEntities, List<PlayClerkLevelInfoEntity> clerkLevelInfoEntity, List<PlayPersonnelGroupInfoEntity> groupInfoEntities);
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.starry.admin.modules.statistics.service.impl;
|
||||
|
||||
import com.starry.admin.modules.clerk.module.entity.PlayClerkLevelInfoEntity;
|
||||
import com.starry.admin.modules.clerk.module.entity.PlayClerkUserInfoEntity;
|
||||
import com.starry.admin.modules.order.module.entity.PlayOrderInfoEntity;
|
||||
import com.starry.admin.modules.personnel.module.entity.PlayPersonnelGroupInfoEntity;
|
||||
import com.starry.admin.modules.statistics.module.vo.PlayClerkPerformanceInfoReturnVo;
|
||||
import com.starry.admin.modules.statistics.service.IPlayClerkPerformanceService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @since 2024/6/15 下午3:29
|
||||
**/
|
||||
@Service
|
||||
public class PlayClerkPerformanceServiceImpl implements IPlayClerkPerformanceService {
|
||||
|
||||
@Override
|
||||
public PlayClerkPerformanceInfoReturnVo getClerkPerformanceInfo(PlayClerkUserInfoEntity userInfo, List<PlayOrderInfoEntity> orderInfoEntities, List<PlayClerkLevelInfoEntity> clerkLevelInfoEntities, List<PlayPersonnelGroupInfoEntity> groupInfoEntities) {
|
||||
|
||||
Set<String> customIds = new HashSet<>();
|
||||
int orderContinueNumber = 0;
|
||||
int orderRefundNumber = 0;
|
||||
int ordersExpiredNumber = 0;
|
||||
BigDecimal finalAmount = BigDecimal.ZERO;
|
||||
BigDecimal orderFirstAmount = BigDecimal.ZERO;
|
||||
BigDecimal orderTotalAmount = BigDecimal.ZERO;
|
||||
BigDecimal orderRewardAmount = BigDecimal.ZERO;
|
||||
BigDecimal orderRefundAmount = BigDecimal.ZERO;
|
||||
BigDecimal estimatedRevenue = BigDecimal.ZERO;
|
||||
for (PlayOrderInfoEntity orderInfoEntity : orderInfoEntities) {
|
||||
customIds.add(orderInfoEntity.getPurchaserBy());
|
||||
finalAmount = finalAmount.add(orderInfoEntity.getFinalAmount());
|
||||
if ("1".equals(orderInfoEntity.getFirstOrder())) {
|
||||
orderFirstAmount = orderFirstAmount.add(orderInfoEntity.getFinalAmount());
|
||||
} else {
|
||||
orderContinueNumber++;
|
||||
orderTotalAmount = orderTotalAmount.add(orderInfoEntity.getFinalAmount());
|
||||
}
|
||||
if ("2".equals(orderInfoEntity.getPlaceType())) {
|
||||
orderRewardAmount = orderRewardAmount.add(orderInfoEntity.getFinalAmount());
|
||||
}
|
||||
if ("1".equals(orderInfoEntity.getRefundType())) {
|
||||
orderRefundNumber++;
|
||||
orderRefundAmount = orderRefundAmount.add(orderInfoEntity.getRefundAmount());
|
||||
}
|
||||
if ("1".equals(orderInfoEntity.getOrdersExpiredState())) {
|
||||
ordersExpiredNumber++;
|
||||
}
|
||||
}
|
||||
PlayClerkPerformanceInfoReturnVo returnVo = new PlayClerkPerformanceInfoReturnVo();
|
||||
returnVo.setClerkId(userInfo.getId());
|
||||
returnVo.setClerkNickname(userInfo.getNickname());
|
||||
returnVo.setClerkSex(userInfo.getSex());
|
||||
for (PlayClerkLevelInfoEntity infoEntity : clerkLevelInfoEntities) {
|
||||
if (infoEntity.getId().equals(userInfo.getLevelId())) {
|
||||
returnVo.setLevelName(infoEntity.getName());
|
||||
}
|
||||
}
|
||||
for (PlayPersonnelGroupInfoEntity infoEntity : groupInfoEntities) {
|
||||
if (infoEntity.getId().equals(userInfo.getGroupId())) {
|
||||
returnVo.setGroupName(infoEntity.getGroupName());
|
||||
}
|
||||
}
|
||||
returnVo.setOrderNumber(orderInfoEntities.size());
|
||||
returnVo.setOrderContinueNumber(orderContinueNumber);
|
||||
returnVo.setOrderRefundNumber(orderRefundNumber);
|
||||
returnVo.setOrdersExpiredNumber(ordersExpiredNumber);
|
||||
returnVo.setFinalAmount(finalAmount);
|
||||
returnVo.setOrderFirstAmount(orderFirstAmount);
|
||||
returnVo.setOrderTotalAmount(orderTotalAmount);
|
||||
returnVo.setOrderRewardAmount(orderRewardAmount);
|
||||
returnVo.setOrderRefundAmount(orderRefundAmount);
|
||||
returnVo.setCustomNumber(customIds.size());
|
||||
returnVo.setEstimatedRevenue(estimatedRevenue);
|
||||
|
||||
return returnVo;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user