This commit is contained in:
starrySky
2024-07-19 15:11:27 +08:00
parent 08050d7000
commit 27e28980f8
5 changed files with 89 additions and 8 deletions

View File

@@ -2,6 +2,7 @@ package com.starry.admin.modules.custom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.starry.admin.modules.custom.module.entity.PlayCustomLevelInfoEntity;
import com.starry.admin.modules.platform.entity.SysTenantEntity;
import java.util.List;
@@ -13,6 +14,14 @@ import java.util.List;
*/
public interface IPlayCustomLevelInfoService extends IService<PlayCustomLevelInfoEntity> {
/**
* 初始化顾客等级
*
* @param sysTenantEntity 租户细信息
* @author admin
* @since 2024/7/19 15:13
**/
void initDefaultLevel(SysTenantEntity sysTenantEntity);
/**
* 获取新增顾客时默认最低等级ID

View File

@@ -1,14 +1,14 @@
package com.starry.admin.modules.custom.service.impl;
import com.starry.common.utils.IdUtils;
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 com.starry.admin.modules.platform.entity.SysTenantEntity;
import com.starry.common.utils.IdUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -27,13 +27,34 @@ public class PlayCustomLevelInfoServiceImpl extends ServiceImpl<PlayCustomLevelI
private PlayCustomLevelInfoMapper playCustomLevelInfoMapper;
@Override
public void initDefaultLevel(SysTenantEntity sysTenantEntity) {
List<PlayCustomLevelInfoEntity> list = this.selectAll();
if (list == null || list.isEmpty()) {
PlayCustomLevelInfoEntity entity = new PlayCustomLevelInfoEntity();
entity.setLevel(1);
entity.setName("V1");
entity.setConsumptionAmount("1");
entity.setDiscount(100);
entity.setTenantId(sysTenantEntity.getTenantId());
this.baseMapper.insert(entity);
}
}
@Override
public PlayCustomLevelInfoEntity getDefaultLevel() {
List<PlayCustomLevelInfoEntity> list = this.selectAll();
if (list != null && !list.isEmpty()) {
return list.get(0);
} else {
PlayCustomLevelInfoEntity entity = new PlayCustomLevelInfoEntity();
entity.setLevel(1);
entity.setName("V1");
entity.setConsumptionAmount("1");
entity.setDiscount(100);
this.baseMapper.insert(entity);
return entity;
}
throw new CustomException("系统错误,等级数据未初始化");
}
@Override