人员导入和绑定餐盘数量管理
This commit is contained in:
@ -182,5 +182,9 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode WX_STORE_ORDER_DETAIL_NOT_EXISTS = new ErrorCode(1_004_032_01, "微信付款码订单详情不存在");
|
||||
|
||||
ErrorCode ORDER_DETAIL_LOG_NOT_EXISTS = new ErrorCode(1_004_033_01, "打菜日志不存在");
|
||||
|
||||
ErrorCode STORE_DINING_PLATES_NOT_EXISTS = new ErrorCode(1_004_033_02, "设置不存在");
|
||||
|
||||
ErrorCode DINING_PLATES_BIND_MAX = new ErrorCode(1_004_033_02, "可绑定的餐盘已达到上限");
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,10 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.excelImport;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.excelImport.vo.*;
|
||||
@ -16,6 +20,7 @@ import cn.iocoder.yudao.module.system.api.dish.dto.DishExcelDto;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -44,9 +49,12 @@ public class ExcelImportController {
|
||||
@Resource
|
||||
private DishesApi dishesApi;
|
||||
@Resource
|
||||
StoreGoodsService storeGoodsService;
|
||||
private StoreGoodsService storeGoodsService;
|
||||
@Resource
|
||||
StoreGoodsTypeService storeGoodsTypeService;
|
||||
private StoreGoodsTypeService storeGoodsTypeService;
|
||||
@Resource
|
||||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
|
||||
@PostMapping("/easyExcelImport")
|
||||
public void importExcel(MultipartFile file, HttpServletResponse response,Long storeId) {
|
||||
@ -194,4 +202,66 @@ public class ExcelImportController {
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "人员导入")
|
||||
@PostMapping("/userImport")
|
||||
public void importExcelGoods(MultipartFile file) {
|
||||
if (!file.isEmpty()) {
|
||||
//文件名称
|
||||
int begin = Objects.requireNonNull(file.getOriginalFilename()).indexOf(".");
|
||||
//文件名称长度
|
||||
int last = file.getOriginalFilename().length();
|
||||
//判断文件格式是否正确
|
||||
String fileName = file.getOriginalFilename().substring(begin, last);
|
||||
if (!fileName.endsWith(".xls") && !fileName.endsWith(".xlsx")) {
|
||||
throw new IllegalArgumentException("上传文件格式错误");
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("文件不能为空");
|
||||
}
|
||||
try (InputStream inputStream = file.getInputStream()) {
|
||||
userRead(inputStream);
|
||||
} catch (IOException e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void userRead(InputStream inputStream) {
|
||||
//获取正确数据
|
||||
ArrayList<UserExcel> successArrayList = new ArrayList<>();
|
||||
EasyExcel.read(inputStream)
|
||||
.head(UserExcel.class)
|
||||
.registerReadListener(new UserExcelListener(
|
||||
// 监听器中doAfterAllAnalysed执行此方法;所有读取完成之后处理逻辑
|
||||
successArrayList::addAll))
|
||||
// 设置sheet,默认读取第一个
|
||||
.sheet()
|
||||
// 设置标题(字段列表)所在行数
|
||||
.headRowNumber(1)
|
||||
.doRead();
|
||||
for (UserExcel vo : successArrayList){
|
||||
|
||||
MemberUserDO userByMobile = memberUserService.getUserByMobile(vo.getMobile());
|
||||
|
||||
if(ObjectUtil.isNotEmpty(userByMobile)){
|
||||
continue;
|
||||
}
|
||||
|
||||
// 生成密码
|
||||
String password = IdUtil.fastSimpleUUID();
|
||||
// 插入用户
|
||||
MemberUserDO user = new MemberUserDO();
|
||||
user.setMobile(vo.getMobile());
|
||||
user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启
|
||||
user.setPassword(passwordEncoder.encode(password)); // 加密密码
|
||||
user.setRegisterIp("null");
|
||||
user.setNickname(vo.getName()); // 基础信息
|
||||
user.setName(vo.getName());
|
||||
if (StrUtil.isEmpty(vo.getName())) {
|
||||
// 昵称为空时,随机一个名字,避免一些依赖 nickname 的逻辑报错,或者有点丑。例如说,短信发送有昵称时~
|
||||
user.setNickname("用户" + RandomUtil.randomNumbers(6));
|
||||
}
|
||||
memberUserService.insert(user);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.excelImport.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
/**
|
||||
* @author zt
|
||||
* @description <description class purpose>
|
||||
* @since 2024/11/5
|
||||
*/
|
||||
|
||||
@ExcelIgnoreUnannotated
|
||||
public class UserExcel {
|
||||
|
||||
/**
|
||||
* 用名字去匹配,这里需要注意,如果名字重复,会导致只有一个字段读取到数据
|
||||
*/
|
||||
@ExcelProperty(index = 0)
|
||||
public String name;
|
||||
|
||||
@ExcelProperty(index = 1)
|
||||
public String mobile;
|
||||
|
||||
@ExcelProperty( index = 2)
|
||||
public String company;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public String getCompany() {
|
||||
return company;
|
||||
}
|
||||
|
||||
public void setCompany(String company) {
|
||||
this.company = company;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.excelImport.vo;
|
||||
|
||||
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.event.AnalysisEventListener;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
||||
/**
|
||||
* 读取excel数据
|
||||
*/
|
||||
public class UserExcelListener extends AnalysisEventListener<UserExcel> {
|
||||
|
||||
/**临时存储正常数据集合,最大存储100*/
|
||||
private List<UserExcel> successDataList = Lists.newArrayListWithExpectedSize(300);
|
||||
|
||||
/**自定义消费者函数接口用于自定义监听器中数据组装*/
|
||||
private final Consumer<List<UserExcel>> successConsumer;
|
||||
|
||||
public UserExcelListener(Consumer<List<UserExcel>> successConsumer) {
|
||||
this.successConsumer = successConsumer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(UserExcel userExcel, AnalysisContext analysisContext) {
|
||||
successDataList.add(userExcel);
|
||||
System.out.println("数据:"+userExcel);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
||||
if (CollectionUtils.isNotEmpty(successDataList)) {
|
||||
successConsumer.accept(successDataList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.storediningplates;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.storediningplates.vo.StoreDiningPlatesPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.storediningplates.vo.StoreDiningPlatesRespVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.storediningplates.vo.StoreDiningPlatesSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.storediningplates.StoreDiningPlatesDO;
|
||||
import cn.iocoder.yudao.module.member.service.storediningplates.StoreDiningPlatesService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
|
||||
|
||||
@Tag(name = "管理后台 - 门店餐盘设置")
|
||||
@RestController
|
||||
@RequestMapping("/t/store-dining-plates")
|
||||
@Validated
|
||||
public class StoreDiningPlatesController {
|
||||
|
||||
@Resource
|
||||
private StoreDiningPlatesService storeDiningPlatesService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建门店餐盘设置")
|
||||
@PreAuthorize("@ss.hasPermission('t:store-dining-plates:create')")
|
||||
public CommonResult<Long> createStoreDiningPlates(@Valid @RequestBody StoreDiningPlatesSaveReqVO createReqVO) {
|
||||
return success(storeDiningPlatesService.createStoreDiningPlates(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新门店餐盘设置")
|
||||
@PreAuthorize("@ss.hasPermission('t:store-dining-plates:update')")
|
||||
public CommonResult<Boolean> updateStoreDiningPlates(@Valid @RequestBody StoreDiningPlatesSaveReqVO updateReqVO) {
|
||||
storeDiningPlatesService.updateStoreDiningPlates(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除门店餐盘设置")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('t:store-dining-plates:delete')")
|
||||
public CommonResult<Boolean> deleteStoreDiningPlates(@RequestParam("id") Long id) {
|
||||
storeDiningPlatesService.deleteStoreDiningPlates(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得门店餐盘设置")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('t:store-dining-plates:query')")
|
||||
public CommonResult<StoreDiningPlatesRespVO> getStoreDiningPlates(@RequestParam("id") Long id) {
|
||||
StoreDiningPlatesDO storeDiningPlates = storeDiningPlatesService.getStoreDiningPlates(id);
|
||||
return success(BeanUtils.toBean(storeDiningPlates, StoreDiningPlatesRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得门店餐盘设置分页")
|
||||
@PreAuthorize("@ss.hasPermission('t:store-dining-plates:query')")
|
||||
public CommonResult<PageResult<StoreDiningPlatesRespVO>> getStoreDiningPlatesPage(@Valid StoreDiningPlatesPageReqVO pageReqVO) {
|
||||
PageResult<StoreDiningPlatesDO> pageResult = storeDiningPlatesService.getStoreDiningPlatesPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, StoreDiningPlatesRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出门店餐盘设置 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('t:store-dining-plates:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportStoreDiningPlatesExcel(@Valid StoreDiningPlatesPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<StoreDiningPlatesDO> list = storeDiningPlatesService.getStoreDiningPlatesPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "门店餐盘设置.xls", "数据", StoreDiningPlatesRespVO.class,
|
||||
BeanUtils.toBean(list, StoreDiningPlatesRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.storediningplates.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 门店餐盘设置分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class StoreDiningPlatesPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "门店id", example = "27434")
|
||||
private Long storeId;
|
||||
|
||||
@Schema(description = "起始金额(不包含)")
|
||||
private BigDecimal amountStart;
|
||||
|
||||
@Schema(description = "结束金额(包含)")
|
||||
private BigDecimal amountEnd;
|
||||
|
||||
@Schema(description = "餐盘个数")
|
||||
private Integer num;
|
||||
|
||||
@Schema(description = "是否适用于招待卡")
|
||||
private Boolean applyToCard;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.storediningplates.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.util.*;
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 门店餐盘设置 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class StoreDiningPlatesRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "140")
|
||||
@ExcelProperty("编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "门店id", example = "27434")
|
||||
@ExcelProperty("门店id")
|
||||
private Long storeId;
|
||||
|
||||
@Schema(description = "起始金额(不包含)")
|
||||
@ExcelProperty("起始金额(不包含)")
|
||||
private BigDecimal amountStart;
|
||||
|
||||
@Schema(description = "结束金额(包含)")
|
||||
@ExcelProperty("结束金额(包含)")
|
||||
private BigDecimal amountEnd;
|
||||
|
||||
@Schema(description = "餐盘个数")
|
||||
@ExcelProperty("餐盘个数")
|
||||
private Integer num;
|
||||
|
||||
@Schema(description = "是否适用于招待卡", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("是否适用于招待卡")
|
||||
private Boolean applyToCard;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.storediningplates.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Schema(description = "管理后台 - 门店餐盘设置新增/修改 Request VO")
|
||||
@Data
|
||||
public class StoreDiningPlatesSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "140")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "门店id", example = "27434")
|
||||
private Long storeId;
|
||||
|
||||
@Schema(description = "起始金额(不包含)")
|
||||
private BigDecimal amountStart;
|
||||
|
||||
@Schema(description = "结束金额(包含)")
|
||||
private BigDecimal amountEnd;
|
||||
|
||||
@Schema(description = "餐盘个数")
|
||||
private Integer num;
|
||||
|
||||
@Schema(description = "是否适用于招待卡", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "是否适用于招待卡不能为空")
|
||||
private Boolean applyToCard;
|
||||
|
||||
}
|
@ -28,6 +28,9 @@ public class MemberUserExportVo {
|
||||
@ExcelProperty("卡号")
|
||||
private String cardId;
|
||||
|
||||
@ExcelProperty("地址")
|
||||
private String address;
|
||||
|
||||
@ExcelProperty("最后登录时间")
|
||||
private LocalDateTime loginDate;
|
||||
|
||||
|
@ -47,6 +47,8 @@ public class MemberUserPageReqVO extends PageParam {
|
||||
@Schema(description = "分组筛选", example = "1")
|
||||
private List<Long> userIds;
|
||||
|
||||
private String address;
|
||||
|
||||
// TODO 芋艿:注册用户类型;
|
||||
|
||||
// TODO 芋艿:登录用户类型;
|
||||
|
@ -54,4 +54,6 @@ public class MemberUserRespVO extends MemberUserBaseVO {
|
||||
|
||||
private String type;
|
||||
|
||||
private String address;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,53 @@
|
||||
package cn.iocoder.yudao.module.member.dal.dataobject.storediningplates;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 门店餐盘设置 DO
|
||||
*
|
||||
* @author 我是秦俊旗
|
||||
*/
|
||||
@TableName("t_store_dining_plates")
|
||||
@KeySequence("t_store_dining_plates_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class StoreDiningPlatesDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 门店id
|
||||
*/
|
||||
private Long storeId;
|
||||
/**
|
||||
* 起始金额(不包含)
|
||||
*/
|
||||
private BigDecimal amountStart;
|
||||
/**
|
||||
* 结束金额(包含)
|
||||
*/
|
||||
private BigDecimal amountEnd;
|
||||
/**
|
||||
* 餐盘个数
|
||||
*/
|
||||
private Integer num;
|
||||
/**
|
||||
* 是否适用于招待卡
|
||||
*/
|
||||
private Boolean applyToCard;
|
||||
|
||||
}
|
@ -42,7 +42,7 @@ public interface DishOrderMapper extends BaseMapperX<DishOrderDO> {
|
||||
.betweenIfPresent(DishOrderDO::getTotalMoney, reqVO.getMinAmount(), reqVO.getMaxAmount())
|
||||
.betweenIfPresent(DishOrderDO::getCreateTime, startTime, endTime)
|
||||
.eqIfPresent(DishOrderDO::getPayMethods, reqVO.getPayMethods())
|
||||
.eq(DishOrderDO::getDiningPlatesNum,reqVO.getDiningPlatesNum())
|
||||
.eqIfPresent(DishOrderDO::getDiningPlatesNum,reqVO.getDiningPlatesNum())
|
||||
.orderByDesc(DishOrderDO::getId));
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.member.dal.mysql.storediningplates;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.storediningplates.vo.StoreDiningPlatesPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.storediningplates.StoreDiningPlatesDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
/**
|
||||
* 门店餐盘设置 Mapper
|
||||
*
|
||||
* @author 我是秦俊旗
|
||||
*/
|
||||
@Mapper
|
||||
public interface StoreDiningPlatesMapper extends BaseMapperX<StoreDiningPlatesDO> {
|
||||
|
||||
default PageResult<StoreDiningPlatesDO> selectPage(StoreDiningPlatesPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<StoreDiningPlatesDO>()
|
||||
.eqIfPresent(StoreDiningPlatesDO::getStoreId, reqVO.getStoreId())
|
||||
.eqIfPresent(StoreDiningPlatesDO::getAmountStart, reqVO.getAmountStart())
|
||||
.eqIfPresent(StoreDiningPlatesDO::getAmountEnd, reqVO.getAmountEnd())
|
||||
.eqIfPresent(StoreDiningPlatesDO::getNum, reqVO.getNum())
|
||||
.eqIfPresent(StoreDiningPlatesDO::getApplyToCard, reqVO.getApplyToCard())
|
||||
.betweenIfPresent(StoreDiningPlatesDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(StoreDiningPlatesDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -17,6 +17,7 @@ import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserInfoCardVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.admincard.AdminCardDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.diningplates.DiningPlatesDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.order.DishOrderDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.storediningplates.StoreDiningPlatesDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.diningplates.DiningPlatesMapper;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.order.DishOrderMapper;
|
||||
@ -27,7 +28,7 @@ import cn.iocoder.yudao.module.member.service.amount.DeductionService;
|
||||
import cn.iocoder.yudao.module.member.service.async.MemberAsyncService;
|
||||
import cn.iocoder.yudao.module.member.service.group.MemberGroupService;
|
||||
import cn.iocoder.yudao.module.member.service.holiday.HolidayService;
|
||||
import cn.iocoder.yudao.module.member.service.money.MoneyService;
|
||||
import cn.iocoder.yudao.module.member.service.storediningplates.StoreDiningPlatesService;
|
||||
import cn.iocoder.yudao.module.member.util.MemberConstants;
|
||||
import cn.iocoder.yudao.module.system.api.carteen.CarteenApi;
|
||||
import cn.iocoder.yudao.module.system.api.carteen.dto.CarteenRespDto;
|
||||
@ -79,7 +80,7 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
@Resource
|
||||
private DeductionService deductionService;
|
||||
@Resource
|
||||
private MoneyService moneyService;
|
||||
private StoreDiningPlatesService storeDiningPlatesService;
|
||||
@Resource
|
||||
private MemberGroupService memberGroupService;
|
||||
@Resource
|
||||
@ -220,7 +221,7 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
checkOrder(memberUserDO.getId(),diningPlatesDO.getStoreId());
|
||||
|
||||
//余额验证
|
||||
BigDecimal money = checkMoney(memberUserDO, storeId);
|
||||
BigDecimal money = checkMoney(memberUserDO, storeId,true);
|
||||
|
||||
diningPlatesDO.setUserId(memberUserDO.getId());
|
||||
|
||||
@ -274,7 +275,7 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
//订单验证
|
||||
checkOrder(memberUserDO.getId(),diningPlatesDO.getStoreId());
|
||||
//余额验证
|
||||
BigDecimal money = checkMoney(memberUserDO,storeId);
|
||||
BigDecimal money = checkMoney(memberUserDO,storeId,false);
|
||||
|
||||
diningPlatesDO.setUserId(memberUserDO.getId());
|
||||
//创建初始订单
|
||||
@ -390,7 +391,7 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
//}
|
||||
}
|
||||
|
||||
public BigDecimal checkMoney(MemberUserDO memberUserDO,Long storeId) {
|
||||
public BigDecimal checkMoney(MemberUserDO memberUserDO,Long storeId,boolean isCard) {
|
||||
//获取所有现金
|
||||
BigDecimal cashAmount = memberUserDO.getCashAmount();
|
||||
//获取用户所在组分类
|
||||
@ -403,7 +404,6 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
}
|
||||
BigDecimal money = memberUserDO.getWxAmount().add(cashAmount);
|
||||
|
||||
|
||||
BigDecimal compareMoney = carteenApi.getCarteenById(storeId).getBindMoney();
|
||||
if (money.compareTo(compareMoney) < 0) {
|
||||
if(typeHoliday){
|
||||
@ -411,6 +411,18 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
}
|
||||
throw exception(INSUFFICIENT_BALANCE);
|
||||
}
|
||||
|
||||
boolean applyToCard = isCard && memberUserDO.getReception() == 1;
|
||||
//餐盘个数验证
|
||||
StoreDiningPlatesDO byAmount = storeDiningPlatesService.getByAmount(money, storeId, applyToCard);
|
||||
if(byAmount != null){
|
||||
Integer checkNum = byAmount.getNum();
|
||||
Integer num = getDiningPlatesByUserId(memberUserDO.getId(), storeId);
|
||||
if(num >= checkNum){
|
||||
throw exception(DINING_PLATES_BIND_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
return money;
|
||||
}
|
||||
|
||||
@ -427,6 +439,12 @@ public class DiningPlatesServiceImpl implements DiningPlatesService {
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getDiningPlatesByUserId(Long userId,Long storeId){
|
||||
return diningPlatesMapper.selectCount(Wrappers.<DiningPlatesDO>lambdaQuery()
|
||||
.eq(DiningPlatesDO::getUserId, userId).eq(DiningPlatesDO::getStoreId,storeId)).intValue();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<DiningPlatesStoreVO> getDiningPlatesNum(LocalDateTime localDateTime, Integer time) {
|
||||
|
@ -0,0 +1,58 @@
|
||||
package cn.iocoder.yudao.module.member.service.storediningplates;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.storediningplates.vo.StoreDiningPlatesPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.storediningplates.vo.StoreDiningPlatesSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.storediningplates.StoreDiningPlatesDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 门店餐盘设置 Service 接口
|
||||
*
|
||||
* @author 我是秦俊旗
|
||||
*/
|
||||
public interface StoreDiningPlatesService {
|
||||
|
||||
/**
|
||||
* 创建门店餐盘设置
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createStoreDiningPlates(@Valid StoreDiningPlatesSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新门店餐盘设置
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateStoreDiningPlates(@Valid StoreDiningPlatesSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除门店餐盘设置
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteStoreDiningPlates(Long id);
|
||||
|
||||
/**
|
||||
* 获得门店餐盘设置
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 门店餐盘设置
|
||||
*/
|
||||
StoreDiningPlatesDO getStoreDiningPlates(Long id);
|
||||
|
||||
/**
|
||||
* 获得门店餐盘设置分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 门店餐盘设置分页
|
||||
*/
|
||||
PageResult<StoreDiningPlatesDO> getStoreDiningPlatesPage(StoreDiningPlatesPageReqVO pageReqVO);
|
||||
|
||||
|
||||
StoreDiningPlatesDO getByAmount(BigDecimal amount,Long storeId,boolean applyToCard);
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
package cn.iocoder.yudao.module.member.service.storediningplates;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.storediningplates.vo.StoreDiningPlatesPageReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.storediningplates.vo.StoreDiningPlatesSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.storediningplates.StoreDiningPlatesDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.storediningplates.StoreDiningPlatesMapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.STORE_DINING_PLATES_NOT_EXISTS;
|
||||
|
||||
|
||||
/**
|
||||
* 门店餐盘设置 Service 实现类
|
||||
*
|
||||
* @author 我是秦俊旗
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class StoreDiningPlatesServiceImpl implements StoreDiningPlatesService {
|
||||
|
||||
@Resource
|
||||
private StoreDiningPlatesMapper storeDiningPlatesMapper;
|
||||
|
||||
@Override
|
||||
public Long createStoreDiningPlates(StoreDiningPlatesSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
StoreDiningPlatesDO storeDiningPlates = BeanUtils.toBean(createReqVO, StoreDiningPlatesDO.class);
|
||||
storeDiningPlatesMapper.insert(storeDiningPlates);
|
||||
// 返回
|
||||
return storeDiningPlates.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStoreDiningPlates(StoreDiningPlatesSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateStoreDiningPlatesExists(updateReqVO.getId());
|
||||
// 更新
|
||||
StoreDiningPlatesDO updateObj = BeanUtils.toBean(updateReqVO, StoreDiningPlatesDO.class);
|
||||
storeDiningPlatesMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteStoreDiningPlates(Long id) {
|
||||
// 校验存在
|
||||
validateStoreDiningPlatesExists(id);
|
||||
// 删除
|
||||
storeDiningPlatesMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateStoreDiningPlatesExists(Long id) {
|
||||
if (storeDiningPlatesMapper.selectById(id) == null) {
|
||||
throw exception(STORE_DINING_PLATES_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoreDiningPlatesDO getStoreDiningPlates(Long id) {
|
||||
return storeDiningPlatesMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<StoreDiningPlatesDO> getStoreDiningPlatesPage(StoreDiningPlatesPageReqVO pageReqVO) {
|
||||
return storeDiningPlatesMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoreDiningPlatesDO getByAmount(BigDecimal amount, Long storeId, boolean applyToCard) {
|
||||
|
||||
List<StoreDiningPlatesDO> storeDiningPlatesDOS = storeDiningPlatesMapper.selectList(Wrappers.<StoreDiningPlatesDO>lambdaQuery().lt(StoreDiningPlatesDO::getAmountStart, amount)
|
||||
.ge(StoreDiningPlatesDO::getAmountEnd, amount).eq(StoreDiningPlatesDO::getStoreId, storeId)
|
||||
.eq(StoreDiningPlatesDO::getApplyToCard, applyToCard));
|
||||
if(CollectionUtil.isNotEmpty(storeDiningPlatesDOS)){
|
||||
return storeDiningPlatesDOS.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -238,6 +238,11 @@ public interface MemberUserService {
|
||||
*/
|
||||
MemberUserDO create(MemberUserAddVO addVO);
|
||||
|
||||
/**
|
||||
* 后台创建用户
|
||||
*/
|
||||
void insert(MemberUserDO user);
|
||||
|
||||
/**
|
||||
* 查询小组外的用户
|
||||
*/
|
||||
|
@ -761,6 +761,11 @@ public class MemberUserServiceImpl implements MemberUserService {
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insert(MemberUserDO user) {
|
||||
memberUserMapper.insert(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<MemberUserDO> getGroupUserList(MemberUserListVO listVO) {
|
||||
return memberUserMapper.selectUserList(listVO);
|
||||
@ -1094,9 +1099,6 @@ public class MemberUserServiceImpl implements MemberUserService {
|
||||
// 插入用户
|
||||
MemberUserDO user = new MemberUserDO();
|
||||
user.setMobile(phoneNumber);
|
||||
user.setLimitAmount(new BigDecimal("30"));
|
||||
user.setNickname(name);
|
||||
user.setName(name);
|
||||
user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启
|
||||
user.setPassword(encodePassword(password)); // 加密密码
|
||||
user.setRegisterIp("null");
|
||||
|
Reference in New Issue
Block a user