This commit is contained in:
admin
2024-06-14 16:34:37 +08:00
parent 12422d8c06
commit b7afadce44
11 changed files with 302 additions and 35 deletions

View File

@@ -1,14 +1,27 @@
package com.starry.admin.modules.clerk.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.starry.admin.common.exception.CustomException;
import com.starry.admin.modules.clerk.module.entity.PlayClerkGroupInfoEntity;
import com.starry.admin.modules.clerk.module.entity.PlayClerkUserInfoEntity;
import com.starry.admin.modules.clerk.module.vo.PlayClerkGroupInfoEditAddInfoVo;
import com.starry.admin.modules.clerk.module.vo.PlayClerkGroupInfoEditBaseInfoVo;
import com.starry.admin.modules.clerk.module.vo.PlayClerkGroupInfoQueryVo;
import com.starry.admin.modules.clerk.module.vo.PlayClerkGroupInfoReturnVo;
import com.starry.admin.modules.clerk.service.IPlayClerkGroupInfoService;
import com.starry.admin.modules.clerk.service.IPlayClerkUserInfoService;
import com.starry.admin.modules.system.entity.SysUserEntity;
import com.starry.admin.modules.system.service.SysUserService;
import com.starry.common.annotation.Log;
import com.starry.common.enums.BusinessType;
import com.starry.common.result.R;
import com.starry.common.utils.ConvertUtil;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
/**
* 店员分组信息Controller
@@ -19,33 +32,43 @@ import javax.annotation.Resource;
@RestController
@RequestMapping("/clerk/group")
public class PlayClerkGroupInfoController {
@Resource
private IPlayClerkGroupInfoService playClerkGroupInfoService;
@Resource
private IPlayClerkUserInfoService playClerkUserInfoService;
@Resource
private SysUserService sysUserService;
/**
* 查询店员分组信息列表
*/
@GetMapping("/list")
public R list(PlayClerkGroupInfoEntity playClerkGroupInfo) {
IPage<PlayClerkGroupInfoEntity> list = playClerkGroupInfoService.selectPlayClerkGroupInfoByPage(playClerkGroupInfo);
@PostMapping("/listByPage")
public R listByPage(@Validated @RequestBody PlayClerkGroupInfoQueryVo vo) {
IPage<PlayClerkGroupInfoReturnVo> list = playClerkGroupInfoService.selectByPage(vo);
for (PlayClerkGroupInfoReturnVo record : list.getRecords()) {
List<PlayClerkUserInfoEntity> clerkUserInfoEntities = playClerkUserInfoService.selecyByGroupId(record.getId());
record.setTotalEmployeesNumber(clerkUserInfoEntities.size());
record.setListingEmployeesNumber(clerkUserInfoEntities.stream().collect(Collectors.toMap(PlayClerkUserInfoEntity::getListingState, PlayClerkUserInfoEntity::getId)).size());
}
return R.ok(list);
}
/**
* 获取店员分组信息详细信息
*/
@GetMapping(value = "/{id}")
public R getInfo(@PathVariable("id") String id) {
return R.ok(playClerkGroupInfoService.selectPlayClerkGroupInfoById(id));
}
/**
* 新增店员分组信息
*/
@Log(title = "店员分组信息", businessType = BusinessType.INSERT)
@PostMapping("/create")
public R create(@RequestBody PlayClerkGroupInfoEntity playClerkGroupInfo) {
boolean success = playClerkGroupInfoService.create(playClerkGroupInfo);
@PostMapping("/createBaseInfo")
public R createBaseInfo(@Validated @RequestBody PlayClerkGroupInfoEditAddInfoVo vo) {
SysUserEntity sysUserEntity = sysUserService.selectUserById(vo.getSysUserId());
PlayClerkGroupInfoEntity entity = ConvertUtil.entityToVo(vo, PlayClerkGroupInfoEntity.class);
entity.setSysUserCode(sysUserEntity.getUserCode());
boolean success = playClerkGroupInfoService.create(entity);
if (success) {
return R.ok();
}
@@ -56,22 +79,31 @@ public class PlayClerkGroupInfoController {
* 修改店员分组信息
*/
@Log(title = "店员分组信息", businessType = BusinessType.UPDATE)
@PostMapping(value = "/update/{id}")
public R update(@PathVariable String id, @RequestBody PlayClerkGroupInfoEntity playClerkGroupInfo) {
playClerkGroupInfo.setId(id);
boolean success = playClerkGroupInfoService.update(playClerkGroupInfo);
@PostMapping(value = "/updateBaseInfo")
public R updateBaseInfo(@Validated @RequestBody PlayClerkGroupInfoEditBaseInfoVo vo) {
SysUserEntity sysUserEntity = sysUserService.selectUserById(vo.getSysUserId());
PlayClerkGroupInfoEntity entity = ConvertUtil.entityToVo(vo, PlayClerkGroupInfoEntity.class);
entity.setSysUserCode(sysUserEntity.getUserCode());
boolean success = playClerkGroupInfoService.update(entity);
if (success) {
return R.ok();
}
return R.error("修改失败");
}
/**
* 删除店员分组信息
*/
@Log(title = "店员分组信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R remove(@PathVariable String[] ids) {
for (String id : ids) {
List<PlayClerkUserInfoEntity> clerkUserInfoEntities = playClerkUserInfoService.selecyByGroupId(id);
if (!clerkUserInfoEntities.isEmpty()) {
throw new CustomException("分组中存在店员,禁止删除");
}
}
return R.ok(playClerkGroupInfoService.deletePlayClerkGroupInfoByIds(ids));
}
}

View File

@@ -2,6 +2,7 @@ package com.starry.admin.modules.clerk.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.starry.admin.modules.clerk.module.entity.PlayClerkGroupInfoEntity;
/**
@@ -10,7 +11,7 @@ import com.starry.admin.modules.clerk.module.entity.PlayClerkGroupInfoEntity;
* @author admin
* @since 2024-05-31
*/
public interface PlayClerkGroupInfoMapper extends BaseMapper<PlayClerkGroupInfoEntity> {
public interface PlayClerkGroupInfoMapper extends MPJBaseMapper<PlayClerkGroupInfoEntity> {
}

View File

@@ -22,16 +22,34 @@ public class PlayClerkGroupInfoEntity extends BaseEntity<PlayClerkGroupInfoEntit
*/
private String id;
/**
* 租户ID
*/
private String tenantId;
/**
* 用户ID
**/
private String sysUserId;
/**
* 用户账号
**/
private String sysUserCode;
/**
* 分组名称
*/
private String groupName;
/**
* 组长名称
**/
private String leaderName;
/**
* 排序
*/

View File

@@ -0,0 +1,39 @@
package com.starry.admin.modules.clerk.module.vo;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
/**
* 店员分组基本信息修改
*
* @author 杭州世平信息科技有限公司-xuhq
* @since 2024/6/14 14:45
**/
@Data
public class PlayClerkGroupInfoEditAddInfoVo {
/**
* 分组名称
*/
@NotBlank(message = "用户ID不能为空")
private String sysUserId;
/**
* 分组名称
*/
@NotBlank(message = "分组名称不能为空")
@Length(min = 1, max = 100, message = "字符长度在1-100之间")
private String groupName;
/**
* 分组名称
*/
@NotBlank(message = "组长名称不能为空")
@Length(min = 1, max = 100, message = "字符长度在1-100之间")
private String leaderName;
}

View File

@@ -0,0 +1,47 @@
package com.starry.admin.modules.clerk.module.vo;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
/**
* 店员分组基本信息修改
*
* @author 杭州世平信息科技有限公司-xuhq
* @since 2024/6/14 14:45
**/
@Data
public class PlayClerkGroupInfoEditBaseInfoVo {
/**
* UUID
*
* @since 2024/6/14 16:08
**/
@NotBlank(message = "ID不能为空")
private String id;
/**
* 分组名称
*/
@NotBlank(message = "用户ID不能为空")
private String sysUserId;
/**
* 分组名称
*/
@NotBlank(message = "分组名称不能为空")
@Length(min = 1, max = 100, message = "字符长度在1-100之间")
private String groupName;
/**
* 分组名称
*/
@NotBlank(message = "组长名称不能为空")
@Length(min = 1, max = 100, message = "字符长度在1-100之间")
private String leaderName;
}

View File

@@ -0,0 +1,23 @@
package com.starry.admin.modules.clerk.module.vo;
import com.starry.common.domain.BasePageEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 店员分组管理信息
*
* @author 杭州世平信息科技有限公司-xuhq
* @since 2024/6/14 14:45
**/
@EqualsAndHashCode(callSuper = true)
@Data
public class PlayClerkGroupInfoQueryVo extends BasePageEntity {
/**
* 分组名称
*/
private String groupName;
}

View File

@@ -0,0 +1,65 @@
package com.starry.admin.modules.clerk.module.vo;
import lombok.Data;
/**
* 店员分组管理信息
*
* @author 杭州世平信息科技有限公司-xuhq
* @since 2024/6/14 14:45
**/
@Data
public class PlayClerkGroupInfoReturnVo {
/**
* UUID
*/
private String id;
/**
* 租户ID
*/
private String tenantId;
/**
* 用户ID
**/
private String sysUserId;
/**
* 用户账号
**/
private String userCode;
/**
* 分组名称
*/
private String groupName;
/**
* 组长名称
**/
private String leaderName;
/**
* 排序
*/
private Long sort;
/**
* 员工总数量
**/
private Integer totalEmployeesNumber;
/**
* 上架员工数量
**/
private Integer listingEmployeesNumber;
}

View File

@@ -3,6 +3,8 @@ package com.starry.admin.modules.clerk.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.starry.admin.modules.clerk.module.entity.PlayClerkGroupInfoEntity;
import com.starry.admin.modules.clerk.module.vo.PlayClerkGroupInfoQueryVo;
import com.starry.admin.modules.clerk.module.vo.PlayClerkGroupInfoReturnVo;
/**
* 店员分组信息Service接口
@@ -27,6 +29,16 @@ public interface IPlayClerkGroupInfoService extends IService<PlayClerkGroupInfoE
*/
IPage<PlayClerkGroupInfoEntity> selectPlayClerkGroupInfoByPage(PlayClerkGroupInfoEntity playClerkGroupInfo);
/**
* 分页查询店员分组信息列表
*
* @param vo 查询店员分组信息查询对象
* @return com.baomidou.mybatisplus.core.metadata.IPage<com.starry.admin.modules.clerk.module.entity.PlayClerkGroupInfoEntity>
* @author 杭州世平信息科技有限公司-xuhq
* @since 2024/6/14 15:46
**/
IPage<PlayClerkGroupInfoReturnVo> selectByPage(PlayClerkGroupInfoQueryVo vo);
/**
* 新增店员分组信息
*

View File

@@ -25,6 +25,7 @@ import java.util.List;
public interface IPlayClerkUserInfoService extends IService<PlayClerkUserInfoEntity> {
List<PlayClerkUserInfoEntity> selecyByGroupId(String groupId);
/**
* 查询当前租户店员总数
*

View File

@@ -5,14 +5,21 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.starry.admin.modules.clerk.mapper.PlayClerkGroupInfoMapper;
import com.starry.admin.modules.clerk.module.entity.PlayClerkGroupInfoEntity;
import com.starry.admin.modules.clerk.module.entity.PlayClerkUserInfoEntity;
import com.starry.admin.modules.clerk.module.vo.PlayClerkGroupInfoQueryVo;
import com.starry.admin.modules.clerk.module.vo.PlayClerkGroupInfoReturnVo;
import com.starry.admin.modules.clerk.service.IPlayClerkGroupInfoService;
import com.starry.admin.modules.clerk.service.IPlayClerkUserInfoService;
import com.starry.common.utils.IdUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* 店员分组信息Service业务层处理
@@ -25,6 +32,9 @@ public class PlayClerkGroupInfoServiceImpl extends ServiceImpl<PlayClerkGroupInf
@Resource
private PlayClerkGroupInfoMapper playClerkGroupInfoMapper;
@Resource
private IPlayClerkUserInfoService playClerkUserInfoService;
/**
* 查询店员分组信息
*
@@ -36,6 +46,16 @@ public class PlayClerkGroupInfoServiceImpl extends ServiceImpl<PlayClerkGroupInf
return this.baseMapper.selectById(id);
}
@Override
public IPage<PlayClerkGroupInfoReturnVo> selectByPage(PlayClerkGroupInfoQueryVo vo) {
MPJLambdaWrapper<PlayClerkGroupInfoEntity> lambdaQueryWrapper = new MPJLambdaWrapper<>();
if (StrUtil.isNotBlank(vo.getGroupName())) {
lambdaQueryWrapper.eq(PlayClerkGroupInfoEntity::getGroupName, vo.getGroupName());
}
return this.baseMapper.selectJoinPage(new Page<>(vo.getPageNum(), vo.getPageSize()), PlayClerkGroupInfoReturnVo.class, lambdaQueryWrapper);
}
/**
* 查询店员分组信息列表
*

View File

@@ -63,6 +63,14 @@ public class PlayClerkUserInfoServiceImpl extends ServiceImpl<PlayClerkUserInfoM
private IPlayOrderInfoService playOrderInfoService;
@Override
public List<PlayClerkUserInfoEntity> selecyByGroupId(String groupId) {
MPJLambdaWrapper<PlayClerkUserInfoEntity> lambdaWrapper = new MPJLambdaWrapper<>();
lambdaWrapper.select(PlayClerkUserInfoEntity::getId, PlayClerkUserInfoEntity::getListingState);
lambdaWrapper.eq(PlayClerkUserInfoEntity::getGroupId, groupId);
return this.baseMapper.selectList(lambdaWrapper);
}
@Override
public Long getTotalClerkUser(String tenantId) {
MPJLambdaWrapper<PlayClerkUserInfoEntity> lambdaWrapper = new MPJLambdaWrapper<>();
@@ -74,10 +82,10 @@ public class PlayClerkUserInfoServiceImpl extends ServiceImpl<PlayClerkUserInfoM
public PlayClerkLevelInfoEntity queryLevelCommission(String clerkId) {
MPJLambdaWrapper<PlayClerkUserInfoEntity> lambdaWrapper = new MPJLambdaWrapper<>();
lambdaWrapper.selectAll(PlayClerkLevelInfoEntity.class);
lambdaWrapper.selectAs(PlayClerkUserInfoEntity::getLevelId,"levelId");
lambdaWrapper.leftJoin(PlayClerkLevelInfoEntity.class,PlayClerkLevelInfoEntity::getId,PlayClerkUserInfoEntity::getLevelId);
lambdaWrapper.eq(PlayClerkUserInfoEntity::getId,clerkId);
return this.baseMapper.selectJoinOne(PlayClerkLevelInfoEntity.class,lambdaWrapper);
lambdaWrapper.selectAs(PlayClerkUserInfoEntity::getLevelId, "levelId");
lambdaWrapper.leftJoin(PlayClerkLevelInfoEntity.class, PlayClerkLevelInfoEntity::getId, PlayClerkUserInfoEntity::getLevelId);
lambdaWrapper.eq(PlayClerkUserInfoEntity::getId, clerkId);
return this.baseMapper.selectJoinOne(PlayClerkLevelInfoEntity.class, lambdaWrapper);
}
@@ -125,9 +133,9 @@ public class PlayClerkUserInfoServiceImpl extends ServiceImpl<PlayClerkUserInfoM
if (map.containsKey("3")) {
result.setAudioAllowEdit(false);
}
//是店员之后,判断是否可以登录
if (result.getClerkState().equals("1")) {
//设置店员是否运行登录
// 是店员之后,判断是否可以登录
if ("1".equals(result.getClerkState())) {
// 设置店员是否运行登录
if ("0".equals(userInfo.getOnboardingState())) {
result.setAllowLogin("1");
result.setDisableLoginReason("你已离职,需要复职请联系店铺管理员");
@@ -140,7 +148,7 @@ public class PlayClerkUserInfoServiceImpl extends ServiceImpl<PlayClerkUserInfoM
}
//如果存在未审批的申请,或者当前已经是店员-可以申请陪聊
// 如果存在未审批的申请,或者当前已经是店员-可以申请陪聊
PlayClerkUserReviewInfoEntity entity = playClerkUserReviewInfoService.queryByClerkId(userInfo.getId(), "0");
if (entity != null || "1".equals(result.getClerkState())) {
result.setClerkAllowEdit(false);
@@ -175,10 +183,10 @@ public class PlayClerkUserInfoServiceImpl extends ServiceImpl<PlayClerkUserInfoM
@Override
public void updateAccountBalanceById(String userId, BigDecimal balanceBeforeOperation, BigDecimal balanceAfterOperation, String operationType, String operationAction, BigDecimal balanceMoney, String orderId) {
//修改用户余额
// 修改用户余额
this.baseMapper.updateById(new PlayClerkUserInfoEntity(userId, balanceAfterOperation));
//记录余额变更记录
playBalanceDetailsInfoService.insertBalanceDetailsInfo("0", userId, balanceBeforeOperation, balanceAfterOperation, operationType, operationAction, balanceMoney, BigDecimal.ZERO,orderId);
// 记录余额变更记录
playBalanceDetailsInfoService.insertBalanceDetailsInfo("0", userId, balanceBeforeOperation, balanceAfterOperation, operationType, operationAction, balanceMoney, BigDecimal.ZERO, orderId);
}
/**
@@ -236,7 +244,7 @@ public class PlayClerkUserInfoServiceImpl extends ServiceImpl<PlayClerkUserInfoM
@Override
public IPage<PlayClerkUnsettledWagesInfoReturnVo> listUnsettledWagesByPage(PlayClerkUnsettledWagesInfoQueryVo vo) {
MPJLambdaWrapper<PlayClerkUserInfoEntity> lambdaQueryWrapper = new MPJLambdaWrapper<>();
//查询所有店员
// 查询所有店员
lambdaQueryWrapper.selectAs(PlayClerkUserInfoEntity::getNickname, "clerkNickname").selectAs(PlayClerkUserInfoEntity::getId, "clerkId");
lambdaQueryWrapper.eq(PlayClerkUserInfoEntity::getClerkState, "1");
if (StrUtil.isNotBlank(vo.getClerkId())) {
@@ -245,24 +253,25 @@ public class PlayClerkUserInfoServiceImpl extends ServiceImpl<PlayClerkUserInfoM
if (StrUtil.isNotBlank(vo.getListingState())) {
lambdaQueryWrapper.eq(PlayClerkUserInfoEntity::getListingState, vo.getListingState());
}
//查询店员订单信息
// 查询店员订单信息
lambdaQueryWrapper.selectCollection(PlayOrderInfoEntity.class, PlayClerkUnsettledWagesInfoReturnVo::getOrderInfoEntities);
lambdaQueryWrapper.leftJoin(PlayOrderInfoEntity.class, PlayOrderInfoEntity::getAcceptBy, PlayClerkUserInfoEntity::getId);
lambdaQueryWrapper.eq(PlayOrderInfoEntity::getOrderSettlementState, "0");
return this.baseMapper.selectJoinPage(new Page<>(vo.getPageNum(), vo.getPageSize()), PlayClerkUnsettledWagesInfoReturnVo.class, lambdaQueryWrapper);
}
@Override
public IPage<PlayClerkUserReturnVo> selectByPage(PlayClerkUserQueryVo vo) {
MPJLambdaWrapper<PlayClerkUserInfoEntity> lambdaQueryWrapper = new MPJLambdaWrapper<>();
//主表(店员表全部字段)
// 主表(店员表全部字段)
lambdaQueryWrapper.selectAll(PlayClerkUserInfoEntity.class);
if(StrUtil.isNotBlank(vo.getId())) {
if (StrUtil.isNotBlank(vo.getId())) {
lambdaQueryWrapper.eq(PlayClerkUserInfoEntity::getId, vo.getId());
}
if(StrUtil.isNotBlank(vo.getNickname())) {
if (StrUtil.isNotBlank(vo.getNickname())) {
lambdaQueryWrapper.eq(PlayClerkUserInfoEntity::getNickname, vo.getNickname());
}
if(StrUtil.isNotBlank(vo.getNickname())) {
if (StrUtil.isNotBlank(vo.getNickname())) {
lambdaQueryWrapper.eq(PlayClerkUserInfoEntity::getNickname, vo.getNickname());
}
if (StrUtil.isNotBlank(vo.getPhone())) {