最新代码

This commit is contained in:
admin
2024-05-06 10:20:46 +08:00
parent a0cd0312a5
commit 2919029b81
126 changed files with 5276 additions and 1137 deletions

View File

@@ -0,0 +1,94 @@
package com.starry.admin.modules.custom.controller;
import com.starry.admin.common.exception.CustomException;
import com.starry.admin.modules.custom.module.entity.PlayCustomLevelInfoEntity;
import com.starry.admin.modules.custom.module.vo.PlayCustomLevelAddVo;
import com.starry.admin.modules.custom.module.vo.PlayCustomLevelEditVo;
import com.starry.admin.modules.custom.service.IPlayCustomLevelInfoService;
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.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 顾客等级Controller
*
* @author admin
* @since 2024-05-04
*/
@RestController
@RequestMapping("/custom/level")
public class PlayCustomLevelInfoController {
@Resource
private IPlayCustomLevelInfoService playCustomLevelInfoService;
/**
* 查询顾客等级列表
*/
@PostMapping("/listAll")
public R listAll() {
List<PlayCustomLevelInfoEntity> list = playCustomLevelInfoService.selectPlayCustomLevelInfoByPage();
return R.ok(list);
}
/**
* 获取顾客等级详细信息
*/
@GetMapping(value = "/{id}")
public R getInfo(@PathVariable("id") String id) {
return R.ok(playCustomLevelInfoService.selectPlayCustomLevelInfoById(id));
}
/**
* 新增顾客等级
*/
@Log(title = "店员等级", businessType = BusinessType.INSERT)
@PostMapping("/create")
public R create(@RequestBody PlayCustomLevelAddVo vo) {
PlayCustomLevelInfoEntity entity = ConvertUtil.entityToVo(vo, PlayCustomLevelInfoEntity.class);
int level = playCustomLevelInfoService.selectMaxLevel();
entity.setLevel(level + 1);
boolean success = playCustomLevelInfoService.create(entity);
if (success) {
return R.ok();
}
return R.error("添加失败");
}
/**
* 修改顾客等级
*/
@Log(title = "顾客等级", businessType = BusinessType.UPDATE)
@PostMapping(value = "/update")
public R update(@RequestBody PlayCustomLevelEditVo vo) {
if (playCustomLevelInfoService.selectPlayCustomLevelInfoById(vo.getId()) == null) {
throw new CustomException("对象不存在");
}
PlayCustomLevelInfoEntity entity = ConvertUtil.entityToVo(vo, PlayCustomLevelInfoEntity.class);
boolean success = playCustomLevelInfoService.update(entity);
if (success) {
return R.ok();
}
return R.error("修改失败");
}
/**
* 删除店员等级
*/
@Log(title = "店员等级", businessType = BusinessType.DELETE)
@DeleteMapping("delMaxLevel")
public R remove() {
int level = playCustomLevelInfoService.selectMaxLevel();
if (level <= 1) {
throw new CustomException("最后一级,不允许删除");
}
playCustomLevelInfoService.delMaxLevelByLevel(level);
return R.ok();
}
}

View File

@@ -1,42 +1,34 @@
package com.starry.admin.modules.custom.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;
import com.starry.admin.modules.custom.module.vo.PlayCustomUserStateEditVo;
import com.starry.admin.modules.custom.service.IPlayCustomUserInfoService;
import com.starry.common.annotation.Log;
import com.starry.common.enums.BusinessType;
import com.starry.common.result.R;
import com.starry.common.annotation.Log;
import org.springframework.security.access.prepost.PreAuthorize;
import com.starry.common.utils.ConvertUtil;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 顾客Controller
*
* @author admin
* @since 2024-04-08
* @since 2024-04-08
*/
@RestController
@RequestMapping("/play/info")
@RequestMapping("/custom/user")
public class PlayCustomUserInfoController {
@Resource
private IPlayCustomUserInfoService playCustomUserInfoService;
/**
* 查询顾客列表
*/
@PreAuthorize("@customSs.hasPermission('play:info:list')")
@GetMapping("/list")
/**
* 查询顾客列表
*/
@GetMapping("/list")
public R list(PlayCustomUserInfoEntity playCustomUserInfo) {
IPage<PlayCustomUserInfoEntity> list = playCustomUserInfoService.selectPlayCustomUserInfoByPage(playCustomUserInfo);
return R.ok(list);
@@ -45,7 +37,6 @@ public class PlayCustomUserInfoController {
/**
* 获取顾客详细信息
*/
@PreAuthorize("@customSs.hasPermission('play:info:query')")
@GetMapping(value = "/{id}")
public R getInfo(@PathVariable("id") String id) {
return R.ok(playCustomUserInfoService.selectById(id));
@@ -54,7 +45,6 @@ public class PlayCustomUserInfoController {
/**
* 新增顾客
*/
@PreAuthorize("@customSs.hasPermission('play:info:create')")
@Log(title = "顾客", businessType = BusinessType.INSERT)
@PostMapping("/create")
public R create(@RequestBody PlayCustomUserInfoEntity playCustomUserInfo) {
@@ -65,10 +55,23 @@ public class PlayCustomUserInfoController {
return R.error("添加失败");
}
/**
* 修改顾客状态
*/
@Log(title = "顾客", businessType = BusinessType.UPDATE)
@PostMapping(value = "/updateState")
public R updateState(@Validated @RequestBody PlayCustomUserStateEditVo vo) {
PlayCustomUserInfoEntity entity = ConvertUtil.entityToVo(vo, PlayCustomUserInfoEntity.class);
boolean success = playCustomUserInfoService.update(entity);
if (success) {
return R.ok();
}
return R.error("修改失败");
}
/**
* 修改顾客
*/
@PreAuthorize("@customSs.hasPermission('play:info:edit')")
@Log(title = "顾客", businessType = BusinessType.UPDATE)
@PostMapping(value = "/update/{id}")
public R update(@PathVariable String id, @RequestBody PlayCustomUserInfoEntity playCustomUserInfo) {
@@ -83,7 +86,6 @@ public class PlayCustomUserInfoController {
/**
* 删除顾客
*/
@PreAuthorize("@customSs.hasPermission('play:info:remove')")
@Log(title = "顾客", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R remove(@PathVariable String[] ids) {

View File

@@ -0,0 +1,16 @@
package com.starry.admin.modules.custom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.starry.admin.modules.custom.module.entity.PlayCustomLevelInfoEntity;
/**
* 顾客等级Mapper接口
*
* @author admin
* @since 2024-05-04
*/
public interface PlayCustomLevelInfoMapper extends BaseMapper<PlayCustomLevelInfoEntity> {
}

View File

@@ -0,0 +1,56 @@
package com.starry.admin.modules.custom.module.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.starry.common.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 顾客等级对象 play_custom_level_info
*
* @author admin
* @since 2024-05-04
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("play_custom_level_info")
public class PlayCustomLevelInfoEntity extends BaseEntity<PlayCustomLevelInfoEntity> {
/**
* UUID
*/
private String id;
/**
* 租户ID
*/
private String tenantId;
/**
* 等级名称
*/
private String name;
/**
* 等级数字(排序字段)
*/
private Integer level;
/**
* 上一级消费金额
*/
private String consumptionAmount;
/**
* 满减比例
*/
private Integer discount;
/**
* 头像框地址
*/
private String avatarFrameAddress;
}

View File

@@ -6,6 +6,7 @@ import com.starry.common.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.Date;
/**
@@ -41,12 +42,12 @@ public class PlayCustomUserInfoEntity extends BaseEntity<PlayCustomUserInfoEntit
private String unionid;
/**
* 店员昵称
* 顾客昵称
*/
private String nickname;
/**
* 店员性别0:位置;1:男,2:女)
* 顾客性别0:位置;1:男,2:女)
*/
private Integer sex;
@@ -60,6 +61,11 @@ public class PlayCustomUserInfoEntity extends BaseEntity<PlayCustomUserInfoEntit
*/
private String phone;
/**
* 微信号码
*/
private String weiChatCode;
/**
* 等级
*/
@@ -81,9 +87,9 @@ public class PlayCustomUserInfoEntity extends BaseEntity<PlayCustomUserInfoEntit
private String city;
/**
* 账户余额(单位分)
* 账户余额
*/
private String accountBalance;
private BigDecimal accountBalance;
/**
* 余额状态[0:不存在余额1:存在余额]
@@ -96,12 +102,12 @@ public class PlayCustomUserInfoEntity extends BaseEntity<PlayCustomUserInfoEntit
private String subscribeState;
/**
* 黑名单状态[0:黑名单1:黑名单]
* 黑名单状态[0:黑名单1:黑名单]
*/
private String blacklistState;
/**
* 违规状态[0:违规,1:违规]
* 违规状态[0:违规,1:违规]
*/
private String violationState;
@@ -115,6 +121,17 @@ public class PlayCustomUserInfoEntity extends BaseEntity<PlayCustomUserInfoEntit
*/
private String mobilePhoneState;
/**
* 实名状态【1已实名0未实名】
*/
private String realState;
/**
* 是否必须实名【1必须实名0非必须实名】
*/
private String mandatoryRealState;
/**
* 注册时间
*/

View File

@@ -0,0 +1,34 @@
package com.starry.admin.modules.custom.module.vo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class PlayCustomLevelAddVo {
/**
* 等级名称
*/
@NotBlank(message = "等级名称不能为空")
private String name;
/**
* 上一级消费金额
*/
@NotBlank(message = "消费金额不能为空")
private String consumptionAmount;
/**
* 满减比例
*/
@NotBlank(message = "满减比例不能为空")
private Integer discount;
/**
* 头像框地址
*/
private String avatarFrameAddress;
}

View File

@@ -0,0 +1,40 @@
package com.starry.admin.modules.custom.module.vo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class PlayCustomLevelEditVo {
/**
* UUID
*/
@NotBlank(message = "ID不能为空")
private String id;
/**
* 等级名称
*/
@NotBlank(message = "等级名称不能为空")
private String name;
/**
* 上一级消费金额
*/
@NotBlank(message = "消费金额不能为空")
private String consumptionAmount;
/**
* 满减比例
*/
@NotBlank(message = "满减比例不能为空")
private Integer discount;
/**
* 头像框地址
*/
private String avatarFrameAddress;
}

View File

@@ -0,0 +1,59 @@
package com.starry.admin.modules.custom.module.vo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class PlayCustomUserStateEditVo {
/**
* id
*/
@NotBlank(message = "id不能为空")
private String id;
/**
* 余额状态[0:不存在余额1:存在余额]
*/
private String accountState;
/**
* 关注状态[0:未关注1:已关注]
*/
private String subscribeState;
/**
* 黑名单状态[0:非黑名单1:黑名单]
*/
private String blacklistState;
/**
* 违规状态[0:未违规,1:违规]
*/
private String violationState;
/**
* 是否下单状态[0:未未下单1:下单过]
*/
private String purchaseState;
/**
* 绑定手机状态[0:未绑定,1:绑定]
*/
private String mobilePhoneState;
/**
* 实名状态【1已实名0未实名】
*/
private String realState;
/**
* 是否必须实名【1必须实名0非必须实名】
*/
private String mandatoryRealState;
}

View File

@@ -0,0 +1,90 @@
package com.starry.admin.modules.custom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.starry.admin.modules.custom.module.entity.PlayCustomLevelInfoEntity;
import java.util.List;
/**
* 顾客等级Service接口
*
* @author admin
* @since 2024-05-04
*/
public interface IPlayCustomLevelInfoService extends IService<PlayCustomLevelInfoEntity> {
/**
* 获取新增顾客时默认最低等级ID
*
* @return PlayCustomLevelInfoEntity
*/
PlayCustomLevelInfoEntity getDefaultLevel();
/**
* 查询顾客等级列表
*
* @return 顾客等级集合
*/
List<PlayCustomLevelInfoEntity> selectAll();
/**
* 查询顾客等级
*
* @param id 顾客等级主键
* @return 顾客等级
*/
PlayCustomLevelInfoEntity selectPlayCustomLevelInfoById(String id);
/**
* 查询顾客等级列表
*
* @return 顾客等级集合
*/
List<PlayCustomLevelInfoEntity> selectPlayCustomLevelInfoByPage();
/**
* 新增顾客等级
*
* @param playCustomLevelInfo 顾客等级
* @return 结果
*/
boolean create(PlayCustomLevelInfoEntity playCustomLevelInfo);
/**
* 修改顾客等级
*
* @param playCustomLevelInfo 顾客等级
* @return 结果
*/
boolean update(PlayCustomLevelInfoEntity playCustomLevelInfo);
/**
* 批量删除顾客等级
*
* @param ids 需要删除的顾客等级主键集合
* @return 结果
*/
int deletePlayCustomLevelInfoByIds(String[] ids);
/**
* 删除顾客等级信息
*
* @param id 顾客等级主键
* @return 结果
*/
int deletePlayCustomLevelInfoById(String id);
/**
* 查询最大等级
*
* @return 最大等级
*/
int selectMaxLevel();
/**
* 删除最大等级
*/
void delMaxLevelByLevel(Integer level);
}

View File

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;
import java.math.BigDecimal;
/**
* 顾客Service接口
*
@@ -21,7 +23,6 @@ public interface IPlayCustomUserInfoService extends IService<PlayCustomUserInfoE
*/
PlayCustomUserInfoEntity selectByOpenid(String openId);
/**
* 查询顾客
*
@@ -47,15 +48,25 @@ public interface IPlayCustomUserInfoService extends IService<PlayCustomUserInfoE
boolean create(PlayCustomUserInfoEntity playCustomUserInfo);
/**
* 新token
* 新token
*
* @param id UUID
* @param id 账户余额
* @param token TOKEN
* @author admin
* @since 2024/4/9 14:33
**/
void updateTokenById(String id, String token);
/**
* 更新账号余额
*
* @param id 用户ID
* @param accountBalance 账户余额
* @author admin
* @since 2024/4/9 14:33
**/
void updateAccountBalanceById(String id, BigDecimal accountBalance);
/**
* 修改顾客
*

View File

@@ -0,0 +1,131 @@
package com.starry.admin.modules.custom.service.impl;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.starry.admin.common.exception.CustomException;
import com.starry.admin.modules.custom.mapper.PlayCustomLevelInfoMapper;
import com.starry.admin.modules.custom.module.entity.PlayCustomLevelInfoEntity;
import com.starry.admin.modules.custom.service.IPlayCustomLevelInfoService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
/**
* 顾客等级Service业务层处理
*
* @author admin
* @since 2024-05-04
*/
@Service
public class PlayCustomLevelInfoServiceImpl extends ServiceImpl<PlayCustomLevelInfoMapper, PlayCustomLevelInfoEntity> implements IPlayCustomLevelInfoService {
@Resource
private PlayCustomLevelInfoMapper playCustomLevelInfoMapper;
@Override
public PlayCustomLevelInfoEntity getDefaultLevel() {
List<PlayCustomLevelInfoEntity> list = this.selectAll();
if (list != null && !list.isEmpty()) {
return list.get(0);
}
throw new CustomException("系统错误,等级数据未初始化");
}
@Override
public List<PlayCustomLevelInfoEntity> selectAll() {
LambdaQueryWrapper<PlayCustomLevelInfoEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.orderByAsc(PlayCustomLevelInfoEntity::getLevel);
return this.baseMapper.selectList(lambdaQueryWrapper);
}
/**
* 查询顾客等级
*
* @param id 顾客等级主键
* @return 顾客等级
*/
@Override
public PlayCustomLevelInfoEntity selectPlayCustomLevelInfoById(String id) {
return this.baseMapper.selectById(id);
}
/**
* 查询顾客等级列表
*
* @return 顾客等级
*/
@Override
public List<PlayCustomLevelInfoEntity> selectPlayCustomLevelInfoByPage() {
LambdaQueryWrapper<PlayCustomLevelInfoEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.orderByAsc(PlayCustomLevelInfoEntity::getLevel);
return this.baseMapper.selectList(lambdaQueryWrapper);
}
/**
* 新增顾客等级
*
* @param playCustomLevelInfo 顾客等级
* @return 结果
*/
@Override
public boolean create(PlayCustomLevelInfoEntity playCustomLevelInfo) {
if (StrUtil.isBlankIfStr(playCustomLevelInfo.getId())) {
playCustomLevelInfo.setId(IdUtil.fastSimpleUUID());
}
return save(playCustomLevelInfo);
}
/**
* 修改顾客等级
*
* @param playCustomLevelInfo 顾客等级
* @return 结果
*/
@Override
public boolean update(PlayCustomLevelInfoEntity playCustomLevelInfo) {
return updateById(playCustomLevelInfo);
}
/**
* 批量删除顾客等级
*
* @param ids 需要删除的顾客等级主键
* @return 结果
*/
@Override
public int deletePlayCustomLevelInfoByIds(String[] ids) {
return playCustomLevelInfoMapper.deleteBatchIds(Arrays.asList(ids));
}
/**
* 删除顾客等级信息
*
* @param id 顾客等级主键
* @return 结果
*/
@Override
public int deletePlayCustomLevelInfoById(String id) {
return playCustomLevelInfoMapper.deleteById(id);
}
@Override
public int selectMaxLevel() {
QueryWrapper<PlayCustomLevelInfoEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.select("max(level) as level ");
PlayCustomLevelInfoEntity entity = this.baseMapper.selectOne(queryWrapper);
return entity == null ? 0 : entity.getLevel();
}
@Override
public void delMaxLevelByLevel(Integer level) {
LambdaQueryWrapper<PlayCustomLevelInfoEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PlayCustomLevelInfoEntity::getLevel, level);
this.baseMapper.delete(queryWrapper);
}
}

View File

@@ -12,6 +12,7 @@ import com.starry.admin.modules.custom.service.IPlayCustomUserInfoService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Arrays;
/**
@@ -32,7 +33,6 @@ public class PlayCustomUserInfoServiceImpl extends ServiceImpl<PlayCustomUserInf
lambdaQueryWrapper.eq(PlayCustomUserInfoEntity::getOpenid, openId);
return this.baseMapper.selectOne(lambdaQueryWrapper);
}
/**
* 查询顾客
*
@@ -79,6 +79,15 @@ public class PlayCustomUserInfoServiceImpl extends ServiceImpl<PlayCustomUserInf
this.baseMapper.updateById(entity);
}
@Override
public void updateAccountBalanceById(String id, BigDecimal accountBalance) {
PlayCustomUserInfoEntity entity = new PlayCustomUserInfoEntity();
entity.setId(id);
entity.setAccountBalance(accountBalance);
this.baseMapper.updateById(entity);
}
/**
* 修改顾客
*