Compare commits

3 Commits

2 changed files with 38 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import com.greenorange.promotion.common.BaseResponse;
import com.greenorange.promotion.common.ErrorCode;
import com.greenorange.promotion.common.ResultUtils;
import com.greenorange.promotion.constant.UserConstant;
import com.greenorange.promotion.exception.BusinessException;
import com.greenorange.promotion.exception.ThrowUtils;
import com.greenorange.promotion.model.dto.CommonBatchRequest;
import com.greenorange.promotion.model.dto.promoCodeApply.PromoCodeApplyAddRequest;
@ -82,6 +83,12 @@ public class PromoCodeApplyController {
Long userId = (Long) request.getAttribute("userId");
// 取出当前项目的推广码
Long projectId = promoCodeApplyRequest.getProjectId();
//项目状态如果不是运行中的话无法申请推广码
LambdaQueryWrapper<Project> projectLambdaQueryWrapper = new LambdaQueryWrapper<>();
projectLambdaQueryWrapper.eq(Project::getId, projectId);
Project project2 = projectService.getOne(projectLambdaQueryWrapper);
String projectStatus = project2.getProjectStatus();
if(!projectStatus.equals("running")) throw new BusinessException(ErrorCode.OPERATION_ERROR,"该项目未处于运行状态,无法申请推广码");
String phoneNumber = promoCodeApplyRequest.getSalespersonPhone();
// 判断是否重复绑定了手机号
Map<SFunction<PromoCodeApply, ?>, Object> applyConditions = Map.of(PromoCodeApply::getUserId, userId, PromoCodeApply::getProjectId, projectId, PromoCodeApply::getSalespersonPhone, phoneNumber);
@ -100,6 +107,9 @@ public class PromoCodeApplyController {
String promoCodeImage = promoCode.getPromoCodeImage();
// 获取项目的参数信息
Project project = projectService.getById(projectId);
// 检查项目是否处于运行中
// String projectStatus = project.getProjectStatus();
// ThrowUtils.throwIf(!projectStatus.equals("running"), ErrorCode.OPERATION_ERROR, "该项目未处于运行状态,无法申请推广码");
// 更新项目的推广人数
Map<SFunction<UserProject, ?>, Object> projectConditions = Map.of(UserProject::getProjectId, projectId, UserProject::getUserId, userId);
@ -110,6 +120,8 @@ public class PromoCodeApplyController {
String projectName = project.getProjectName();
String projectImage = project.getProjectImage();
Integer projectSettlementCycle = project.getProjectSettlementCycle();
//判断项目推广人数是否满了
// 获取业务员信息
String salespersonName = promoCodeApplyRequest.getSalespersonName();
String salespersonPhone = promoCodeApplyRequest.getSalespersonPhone();

View File

@ -3,6 +3,7 @@ package com.greenorange.promotion.controller.userInfo;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.greenorange.promotion.annotation.RequiresPermission;
import com.greenorange.promotion.annotation.SysLog;
@ -293,8 +294,6 @@ public class UserInfoController {
/**
* web端管理员添加用户
* @param userInfoAddRequest 用户表添加请求体
@ -322,6 +321,30 @@ public class UserInfoController {
/**
* 给管理员封号
* @param commonRequest 用户表添加请求体
* @return 是否添加成功
*/
@PostMapping("banAdmin")
@Operation(summary = "web端管理员添加用户", description = "参数用户表添加请求体权限管理员boss, admin)方法名addUserInfo")
@RequiresPermission(mustRole = UserConstant.BOSS_ROLE)
@SysLog(title = "用户管理", content = "给管理员封号")
public BaseResponse<Boolean> banAdmin(@RequestBody CommonRequest commonRequest){
Long id = commonRequest.getId();
UserInfo userInfo = userInfoService.getById(id);
String userRole = userInfo.getUserRole();
if (!userRole.equals(UserConstant.ADMIN_ROLE)) throw new BusinessException(ErrorCode.OPERATION_ERROR, "用户权限错误");
userInfo.setUserRole(UserConstant.BAN_ROLE);
userInfoService.updateById(userInfo);
return ResultUtils.success(true);
}
/**
* web端管理员根据id修改用户信息
* @param userInfoUpdateRequest 用户表更新请求体
@ -338,6 +361,7 @@ public class UserInfoController {
}
/**
* web端管理员根据id删除用户
* @param commonRequest 用户表删除请求体