添加查询主管信息列表
This commit is contained in:
@ -33,4 +33,16 @@ public interface SystemConstant {
|
|||||||
*/
|
*/
|
||||||
BigDecimal SECOND_LEVEL_COMMISSION_RATE = new BigDecimal("0.03");
|
BigDecimal SECOND_LEVEL_COMMISSION_RATE = new BigDecimal("0.03");
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退款比例
|
||||||
|
*/
|
||||||
|
BigDecimal REFUND_RATE = new BigDecimal("0.8");
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手续费比例
|
||||||
|
*/
|
||||||
|
BigDecimal FEE_RATE = new BigDecimal("0.2");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import com.greenorange.promotion.model.enums.UserRoleEnum;
|
|||||||
import com.greenorange.promotion.model.vo.advancementApply.AdvancementApplyApproveVO;
|
import com.greenorange.promotion.model.vo.advancementApply.AdvancementApplyApproveVO;
|
||||||
import com.greenorange.promotion.model.vo.advancementApply.AdvancementApplyVOPlus;
|
import com.greenorange.promotion.model.vo.advancementApply.AdvancementApplyVOPlus;
|
||||||
import com.greenorange.promotion.model.vo.advancementApply.AdvancementApplyVO;
|
import com.greenorange.promotion.model.vo.advancementApply.AdvancementApplyVO;
|
||||||
|
import com.greenorange.promotion.model.vo.userInfo.SupervisorUserInfoVO;
|
||||||
import com.greenorange.promotion.service.common.CommonService;
|
import com.greenorange.promotion.service.common.CommonService;
|
||||||
import com.greenorange.promotion.service.userInfo.AdvancementApplyService;
|
import com.greenorange.promotion.service.userInfo.AdvancementApplyService;
|
||||||
import com.greenorange.promotion.service.userInfo.UserInfoService;
|
import com.greenorange.promotion.service.userInfo.UserInfoService;
|
||||||
@ -216,4 +217,19 @@ public class AdvancementApplyController {
|
|||||||
voPage.setTotal(page.getTotal());
|
voPage.setTotal(page.getTotal());
|
||||||
return ResultUtils.success(voPage);
|
return ResultUtils.success(voPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Web端管理员查询主管信息列表
|
||||||
|
* @return 主管信息列表
|
||||||
|
*/
|
||||||
|
@PostMapping("query/supervisor")
|
||||||
|
@Operation(summary = "Web端管理员查询主管信息列表", description = "参数:无,权限:管理员,方法名:listSupervisorUserInfo")
|
||||||
|
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||||
|
@SysLog(title = "晋升申请管理", content = "Web端管理员分页查询晋升申请")
|
||||||
|
public BaseResponse<List<SupervisorUserInfoVO>> listSupervisorUserInfo(@Valid @RequestBody AdvancementApplyQueryRequest advancementApplyQueryRequest) {
|
||||||
|
List<UserInfo> userInfoList = commonService.findByFieldEqTargetField(UserInfo::getUserRole, UserConstant.SUPERVISOR_ROLE, userInfoService);
|
||||||
|
List<SupervisorUserInfoVO> supervisorUserInfoVOS = commonService.convertList(userInfoList, SupervisorUserInfoVO.class);
|
||||||
|
return ResultUtils.success(supervisorUserInfoVOS);
|
||||||
|
}
|
||||||
}
|
}
|
@ -4,10 +4,16 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户绩效汇总表
|
* 用户绩效汇总表
|
||||||
@ -15,11 +21,14 @@ import lombok.Data;
|
|||||||
*/
|
*/
|
||||||
@TableName(value ="user_performance_summary")
|
@TableName(value ="user_performance_summary")
|
||||||
@Data
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
public class UserPerformanceSummary implements Serializable {
|
public class UserPerformanceSummary implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 用户ID
|
* 用户ID
|
||||||
*/
|
*/
|
||||||
@TableId
|
@TableId(type = IdType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,6 +101,7 @@ public class UserPerformanceSummary implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
|
@Serial
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
}
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.greenorange.promotion.model.vo.userInfo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主管列表信息 视图对象
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "主管列表信息 视图对象")
|
||||||
|
public class SupervisorUserInfoVO implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户表 ID
|
||||||
|
*/
|
||||||
|
@Schema(description = "用户ID", example = "1")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户昵称
|
||||||
|
*/
|
||||||
|
@Schema(description = "用户昵称", example = "chenxinzhi")
|
||||||
|
private String nickName;
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
}
|
@ -176,6 +176,10 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
|
|||||||
myUserInfo.setUserAvatar(UserConstant.USER_DEFAULT_AVATAR);
|
myUserInfo.setUserAvatar(UserConstant.USER_DEFAULT_AVATAR);
|
||||||
this.save(myUserInfo);
|
this.save(myUserInfo);
|
||||||
|
|
||||||
|
// 添加用户绩效记录
|
||||||
|
UserPerformanceSummary userPerformanceSummary = UserPerformanceSummary.builder().userId(myUserInfo.getId()).build();
|
||||||
|
userPerformanceSummaryService.save(userPerformanceSummary);
|
||||||
|
|
||||||
// 更新上级用户的数量
|
// 更新上级用户的数量
|
||||||
updateParentUserInfoEmpCount(myUserInfo.getId(), userRoleEnum);
|
updateParentUserInfoEmpCount(myUserInfo.getId(), userRoleEnum);
|
||||||
|
|
||||||
@ -383,6 +387,10 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
|
|||||||
.build();
|
.build();
|
||||||
this.save(myUserInfo);
|
this.save(myUserInfo);
|
||||||
|
|
||||||
|
// 添加用户绩效记录
|
||||||
|
UserPerformanceSummary userPerformanceSummary = UserPerformanceSummary.builder().userId(myUserInfo.getId()).build();
|
||||||
|
userPerformanceSummaryService.save(userPerformanceSummary);
|
||||||
|
|
||||||
// 更新上级主管用户的员工数量和经理用户的员工数量
|
// 更新上级主管用户的员工数量和经理用户的员工数量
|
||||||
updateParentUserInfoEmpCount(myUserInfo.getId(), UserRoleEnum.STAFF);
|
updateParentUserInfoEmpCount(myUserInfo.getId(), UserRoleEnum.STAFF);
|
||||||
|
|
||||||
@ -406,6 +414,7 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
|
|||||||
*/
|
*/
|
||||||
private void updateParentUserInfoEmpCount(Long userId, UserRoleEnum userRoleEnum) {
|
private void updateParentUserInfoEmpCount(Long userId, UserRoleEnum userRoleEnum) {
|
||||||
List<Long> pathToRoot = findPathToRoot(userId);
|
List<Long> pathToRoot = findPathToRoot(userId);
|
||||||
|
pathToRoot.remove(pathToRoot.size() - 1);
|
||||||
List<UserPerformanceSummary> userPerformanceSummaryList = commonService.findByFieldInTargetField(pathToRoot, userPerformanceSummaryService, Function.identity(), UserPerformanceSummary::getUserId);
|
List<UserPerformanceSummary> userPerformanceSummaryList = commonService.findByFieldInTargetField(pathToRoot, userPerformanceSummaryService, Function.identity(), UserPerformanceSummary::getUserId);
|
||||||
for (UserPerformanceSummary userPerformanceSummary : userPerformanceSummaryList) {
|
for (UserPerformanceSummary userPerformanceSummary : userPerformanceSummaryList) {
|
||||||
if (userRoleEnum.equals(UserRoleEnum.USER)) {
|
if (userRoleEnum.equals(UserRoleEnum.USER)) {
|
||||||
|
@ -7,11 +7,9 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|||||||
import com.greenorange.promotion.common.ErrorCode;
|
import com.greenorange.promotion.common.ErrorCode;
|
||||||
import com.greenorange.promotion.config.WxPayConfig;
|
import com.greenorange.promotion.config.WxPayConfig;
|
||||||
import com.greenorange.promotion.constant.OrderStatusConstant;
|
import com.greenorange.promotion.constant.OrderStatusConstant;
|
||||||
|
import com.greenorange.promotion.constant.SystemConstant;
|
||||||
import com.greenorange.promotion.exception.ThrowUtils;
|
import com.greenorange.promotion.exception.ThrowUtils;
|
||||||
import com.greenorange.promotion.model.entity.Course;
|
import com.greenorange.promotion.model.entity.*;
|
||||||
import com.greenorange.promotion.model.entity.CourseOrder;
|
|
||||||
import com.greenorange.promotion.model.entity.CoursePromotionCommissionPending;
|
|
||||||
import com.greenorange.promotion.model.entity.RefundRecord;
|
|
||||||
import com.greenorange.promotion.model.enums.CommissionStatusEnum;
|
import com.greenorange.promotion.model.enums.CommissionStatusEnum;
|
||||||
import com.greenorange.promotion.service.common.CommonService;
|
import com.greenorange.promotion.service.common.CommonService;
|
||||||
import com.greenorange.promotion.service.course.CourseOrderService;
|
import com.greenorange.promotion.service.course.CourseOrderService;
|
||||||
@ -19,6 +17,7 @@ import com.greenorange.promotion.service.course.CoursePromotionCommissionPending
|
|||||||
import com.greenorange.promotion.service.course.CourseService;
|
import com.greenorange.promotion.service.course.CourseService;
|
||||||
import com.greenorange.promotion.service.refund.RefundRecordService;
|
import com.greenorange.promotion.service.refund.RefundRecordService;
|
||||||
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.wechat.WechatPayService;
|
import com.greenorange.promotion.service.wechat.WechatPayService;
|
||||||
import com.greenorange.promotion.utils.RefundUtils;
|
import com.greenorange.promotion.utils.RefundUtils;
|
||||||
import com.wechat.pay.java.core.notification.NotificationParser;
|
import com.wechat.pay.java.core.notification.NotificationParser;
|
||||||
@ -41,6 +40,7 @@ import java.io.BufferedReader;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 陈新知
|
* @author 陈新知
|
||||||
@ -73,6 +73,10 @@ public class WechatPayServiceImpl implements WechatPayService {
|
|||||||
private UserInfoService userInfoService;
|
private UserInfoService userInfoService;
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UserPerformanceSummaryService userPerformanceSummaryService;
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CoursePromotionCommissionPendingService coursePromotionCommissionPendingService;
|
private CoursePromotionCommissionPendingService coursePromotionCommissionPendingService;
|
||||||
|
|
||||||
@ -143,25 +147,47 @@ public class WechatPayServiceImpl implements WechatPayService {
|
|||||||
courseService.updateById(course);
|
courseService.updateById(course);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加课程推广待提成记录
|
// 更新主管和员工的绩效记录
|
||||||
Long userId = courseOrder.getUserId();
|
Long userId = courseOrder.getUserId();
|
||||||
List<Long> pathToRoot = userInfoService.findPathToRoot(userId);
|
List<Long> pathToRoot = userInfoService.findPathToRoot(userId);
|
||||||
Long firstUserId = pathToRoot.get(0);
|
List<Long> superUserIdList = pathToRoot.subList(1, 3);
|
||||||
Long secondUserId = pathToRoot.get(1);
|
List<UserPerformanceSummary> userPerformanceSummaryList = commonService.findByFieldInTargetField(superUserIdList, userPerformanceSummaryService, Function.identity(), UserPerformanceSummary::getUserId);
|
||||||
CoursePromotionCommissionPending coursePromotionCommissionPending = CoursePromotionCommissionPending.builder()
|
BigDecimal rate;
|
||||||
.firstUserId(firstUserId)
|
for (int i = 0; i < userPerformanceSummaryList.size(); i ++ ) {
|
||||||
.secondUserId(secondUserId)
|
if (i == 0) rate = SystemConstant.FIRST_LEVEL_COMMISSION_RATE;
|
||||||
.courseId(courseId)
|
else rate = SystemConstant.SECOND_LEVEL_COMMISSION_RATE;
|
||||||
.name(courseOrder.getName())
|
// 计算理论上获得的最大提成奖励
|
||||||
.type(courseOrder.getType())
|
BigDecimal rakeRewards = courseOrder.getTotalAmount().multiply(rate);
|
||||||
.image(courseOrder.getImage())
|
UserPerformanceSummary userPerformanceSummary = userPerformanceSummaryList.get(i);
|
||||||
.orderId(courseOrder.getId())
|
|
||||||
.userId(userId)
|
userPerformanceSummary.setTotalAmount(userPerformanceSummary.getTotalAmount().add(courseOrder.getTotalAmount()));
|
||||||
.totalAmount(courseOrder.getTotalAmount())
|
userPerformanceSummary.setNetAmount(userPerformanceSummary.getNetAmount().add(courseOrder.getTotalAmount().multiply(SystemConstant.FEE_RATE)));
|
||||||
.commissionStatus(CommissionStatusEnum.PENDING.getValue())
|
userPerformanceSummary.setOrderCount(userPerformanceSummary.getOrderCount() + 1);
|
||||||
.orderCreateTime(courseOrder.getCreateTime())
|
userPerformanceSummary.setToRelease(userPerformanceSummary.getToRelease().add(rakeRewards.multiply(SystemConstant.REFUND_RATE)));
|
||||||
.build();
|
userPerformanceSummary.setToSettle(userPerformanceSummary.getToSettle().add(rakeRewards.multiply(SystemConstant.FEE_RATE)));
|
||||||
coursePromotionCommissionPendingService.save(coursePromotionCommissionPending);
|
}
|
||||||
|
userPerformanceSummaryService.updateBatchById(userPerformanceSummaryList);
|
||||||
|
|
||||||
|
|
||||||
|
// // 添加课程推广待提成记录
|
||||||
|
// Long userId = courseOrder.getUserId();
|
||||||
|
// List<Long> pathToRoot = userInfoService.findPathToRoot(userId);
|
||||||
|
// Long firstUserId = pathToRoot.get(0);
|
||||||
|
// Long secondUserId = pathToRoot.get(1);
|
||||||
|
// CoursePromotionCommissionPending coursePromotionCommissionPending = CoursePromotionCommissionPending.builder()
|
||||||
|
// .firstUserId(firstUserId)
|
||||||
|
// .secondUserId(secondUserId)
|
||||||
|
// .courseId(courseId)
|
||||||
|
// .name(courseOrder.getName())
|
||||||
|
// .type(courseOrder.getType())
|
||||||
|
// .image(courseOrder.getImage())
|
||||||
|
// .orderId(courseOrder.getId())
|
||||||
|
// .userId(userId)
|
||||||
|
// .totalAmount(courseOrder.getTotalAmount())
|
||||||
|
// .commissionStatus(CommissionStatusEnum.PENDING.getValue())
|
||||||
|
// .orderCreateTime(courseOrder.getCreateTime())
|
||||||
|
// .build();
|
||||||
|
// coursePromotionCommissionPendingService.save(coursePromotionCommissionPending);
|
||||||
|
|
||||||
|
|
||||||
System.out.println("---------------------------微信支付回调(结束)-------------------------------");
|
System.out.println("---------------------------微信支付回调(结束)-------------------------------");
|
||||||
@ -246,11 +272,32 @@ public class WechatPayServiceImpl implements WechatPayService {
|
|||||||
courseService.updateById(course);
|
courseService.updateById(course);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改课程推广待提成状态为"已失效"
|
// 更新主管和员工的绩效记录
|
||||||
LambdaUpdateWrapper<CoursePromotionCommissionPending> coursePromotionUpdateWrapper = new LambdaUpdateWrapper<>();
|
Long userId = courseOrder.getUserId();
|
||||||
coursePromotionUpdateWrapper.eq(CoursePromotionCommissionPending::getOrderId, courseOrder.getId())
|
List<Long> pathToRoot = userInfoService.findPathToRoot(userId);
|
||||||
.set(CoursePromotionCommissionPending::getCommissionStatus, CommissionStatusEnum.EXPIRED.getValue());
|
List<Long> superUserIdList = pathToRoot.subList(1, 3);
|
||||||
coursePromotionCommissionPendingService.update(coursePromotionUpdateWrapper);
|
List<UserPerformanceSummary> userPerformanceSummaryList = commonService.findByFieldInTargetField(superUserIdList, userPerformanceSummaryService, Function.identity(), UserPerformanceSummary::getUserId);
|
||||||
|
BigDecimal rate;
|
||||||
|
for (int i = 0; i < userPerformanceSummaryList.size(); i ++ ) {
|
||||||
|
if (i == 0) rate = SystemConstant.FIRST_LEVEL_COMMISSION_RATE;
|
||||||
|
else rate = SystemConstant.SECOND_LEVEL_COMMISSION_RATE;
|
||||||
|
// 计算理论上获得的最大提成奖励
|
||||||
|
BigDecimal rakeRewards = courseOrder.getTotalAmount().multiply(rate);
|
||||||
|
UserPerformanceSummary userPerformanceSummary = userPerformanceSummaryList.get(i);
|
||||||
|
|
||||||
|
userPerformanceSummary.setTotalAmount(userPerformanceSummary.getTotalAmount().add(courseOrder.getTotalAmount()));
|
||||||
|
userPerformanceSummary.setNetAmount(userPerformanceSummary.getNetAmount().add(courseOrder.getTotalAmount().multiply(SystemConstant.FEE_RATE)));
|
||||||
|
userPerformanceSummary.setOrderCount(userPerformanceSummary.getOrderCount() + 1);
|
||||||
|
userPerformanceSummary.setToRelease(userPerformanceSummary.getToRelease().subtract(rakeRewards.multiply(SystemConstant.REFUND_RATE)));
|
||||||
|
userPerformanceSummary.setRefunded(userPerformanceSummary.getRefunded().add(courseOrder.getTotalAmount().multiply(SystemConstant.REFUND_RATE)));
|
||||||
|
}
|
||||||
|
userPerformanceSummaryService.updateBatchById(userPerformanceSummaryList);
|
||||||
|
|
||||||
|
// // 修改课程推广待提成状态为"已失效"
|
||||||
|
// LambdaUpdateWrapper<CoursePromotionCommissionPending> coursePromotionUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
// coursePromotionUpdateWrapper.eq(CoursePromotionCommissionPending::getOrderId, courseOrder.getId())
|
||||||
|
// .set(CoursePromotionCommissionPending::getCommissionStatus, CommissionStatusEnum.EXPIRED.getValue());
|
||||||
|
// coursePromotionCommissionPendingService.update(coursePromotionUpdateWrapper);
|
||||||
|
|
||||||
System.out.println("---------------------------微信退款回调(结束)-------------------------------");
|
System.out.println("---------------------------微信退款回调(结束)-------------------------------");
|
||||||
return true;
|
return true;
|
||||||
|
@ -62,14 +62,13 @@ mybatis-plus:
|
|||||||
mapper-locations: classpath:mapper/*.xml
|
mapper-locations: classpath:mapper/*.xml
|
||||||
configuration:
|
configuration:
|
||||||
map-underscore-to-camel-case: false
|
map-underscore-to-camel-case: false
|
||||||
# log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
|
log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||||
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
global-config:
|
global-config:
|
||||||
db-config:
|
db-config:
|
||||||
logic-delete-field: isDelete #全局逻辑删除的实体字段名
|
logic-delete-field: isDelete #全局逻辑删除的实体字段名
|
||||||
logic-delete-value: 1 #逻辑已删除值(默认为1)
|
logic-delete-value: 1 #逻辑已删除值(默认为1)
|
||||||
logic-not-delete-value: 0 #逻辑未删除值(默认为0)
|
logic-not-delete-value: 0 #逻辑未删除值(默认为0)
|
||||||
type-handlers-package: com.cultural.heritage.handler
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user