Merge branch 'master' of http://124.223.211.244:8418/zianxin/biz-api-cloud
This commit is contained in:
commit
4dfd2bcc75
5 files changed
+165
-56
No files matched your search
+61
@@ -0,0 +1,61 @@
|
||||
package com.bsd.pjcloud.canteen.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 每日菜谱选择菜品dto
|
||||
*
|
||||
* @author zhangjiafu
|
||||
* @date 2024-12-10 12:51:53
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "菜品spudto")
|
||||
public class CanteenDailySpuDTO {
|
||||
|
||||
|
||||
/**
|
||||
* 商品 SPU 编号,自增
|
||||
*/
|
||||
@Schema(description="商品 SPU 编号,自增")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@Schema(description="商品名称")
|
||||
private String name;
|
||||
|
||||
|
||||
/**
|
||||
* 商品分类编号
|
||||
*/
|
||||
@Schema(description="商品分类编号")
|
||||
private Long categoryId;
|
||||
|
||||
|
||||
|
||||
@Schema(description = "开始时间")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@NotNull
|
||||
private LocalDate startTime;
|
||||
|
||||
|
||||
/**
|
||||
* 时间类型
|
||||
*/
|
||||
@Schema(description = "时间类型")
|
||||
@NotNull
|
||||
private Integer hourType;
|
||||
|
||||
|
||||
}
|
||||
+16
@@ -6,6 +6,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenDailySpuDTO;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenSpuUpdateStockReqDTO;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenOnlineSpuEntity;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
@@ -60,6 +61,21 @@ public class CanteenSpuController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 每日分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "每日菜谱选择菜品分页查询", description = "每日菜谱选择菜品分页查询")
|
||||
@GetMapping("/pageDaily")
|
||||
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_view')")
|
||||
public R getCanteenSpuPageDaily(@ParameterObject Page page, @ParameterObject CanteenDailySpuDTO canteenDailySpuDTO) {
|
||||
return R.ok(canteenSpuService.pageDailyScope(page,canteenDailySpuDTO));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id查询菜品spu
|
||||
*
|
||||
|
||||
+10
@@ -3,6 +3,7 @@ package com.bsd.pjcloud.canteen.service;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenDailySpuDTO;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenSpuUpdateStockReqDTO;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenSpuEntity;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
@@ -41,4 +42,13 @@ public interface CanteenSpuService extends IService<CanteenSpuEntity> {
|
||||
* @return
|
||||
*/
|
||||
Object pageScope(Page page, LambdaQueryWrapper<CanteenSpuEntity> wrapper);
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询,并且过滤已选择的菜品
|
||||
* @param page
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
Object pageDailyScope(Page page, CanteenDailySpuDTO canteenDailySpuDTO);
|
||||
}
|
||||
+27
@@ -1,9 +1,13 @@
|
||||
package com.bsd.pjcloud.canteen.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenDailySpuDTO;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenSpuUpdateStockReqDTO;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenDailyMenuEntity;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenOnlineSpuEntity;
|
||||
import com.bsd.pjcloud.canteen.entity.CanteenSpuEntity;
|
||||
import com.bsd.pjcloud.canteen.mapper.CanteenSpuMapper;
|
||||
@@ -17,8 +21,10 @@ import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 菜品spu
|
||||
@@ -30,6 +36,8 @@ import java.util.List;
|
||||
@AllArgsConstructor
|
||||
public class CanteenSpuServiceImpl extends ServiceImpl<CanteenSpuMapper, CanteenSpuEntity> implements CanteenSpuService {
|
||||
|
||||
|
||||
private final CanteenDailyMenuService canteenDailyMenuService;
|
||||
@Override
|
||||
public Object selectFoodList(LambdaQueryWrapper<CanteenSpuEntity> wrapper) {
|
||||
return baseMapper.selectListByScope(wrapper, DataScope.of());
|
||||
@@ -73,5 +81,24 @@ public class CanteenSpuServiceImpl extends ServiceImpl<CanteenSpuMapper, Canteen
|
||||
return baseMapper.selectPageByScope(page, wrapper, DataScope.of());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object pageDailyScope(Page page, CanteenDailySpuDTO canteenDailySpuDTO) {
|
||||
LambdaQueryWrapper<CanteenSpuEntity> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.like(StrUtil.isNotBlank(canteenDailySpuDTO.getName()), CanteenSpuEntity::getName, canteenDailySpuDTO.getName());
|
||||
wrapper.eq(Objects.nonNull(canteenDailySpuDTO.getCategoryId()), CanteenSpuEntity::getCategoryId, canteenDailySpuDTO.getCategoryId());
|
||||
|
||||
//查询今时今日已经选择的菜品
|
||||
LambdaQueryWrapper<CanteenDailyMenuEntity> DyWrapper = Wrappers.lambdaQuery();
|
||||
DyWrapper.eq(CanteenDailyMenuEntity::getStartTime, canteenDailySpuDTO.getStartTime());
|
||||
DyWrapper.eq(CanteenDailyMenuEntity::getHourType, canteenDailySpuDTO.getHourType());
|
||||
List<CanteenDailyMenuEntity> list = canteenDailyMenuService.list(DyWrapper);
|
||||
|
||||
List<Long> spuIds = list.stream().map(CanteenDailyMenuEntity::getSpuId).distinct().collect(java.util.stream.Collectors.toList());
|
||||
wrapper.notIn(!CollectionUtils.isEmpty(list), CanteenSpuEntity::getId, spuIds);
|
||||
|
||||
return baseMapper.selectPageByScope(page, wrapper, DataScope.of());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+51
-56
@@ -20,6 +20,7 @@ import com.bsd.pjcloud.supermarket.service.SupermarketAuxiliaryCodeService;
|
||||
import com.bsd.pjcloud.supermarket.service.SupermarketSpuService;
|
||||
import com.bsd.pjcloud.supermarket.service.SupermarketUnitService;
|
||||
import com.bsd.pjcloud.supermarket.vo.app.SupermarketAppSpuVo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
@@ -41,12 +42,12 @@ import java.util.List;
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/supermarketSpu")
|
||||
@Tag(description = "supermarketSpu", name = "商品spu管理")
|
||||
@RequestMapping("/supermarketSpu" )
|
||||
@Tag(description = "supermarketSpu" , name = "商品spu管理" )
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class SupermarketSpuController {
|
||||
|
||||
private final SupermarketSpuService supermarketSpuService;
|
||||
private final SupermarketSpuService supermarketSpuService;
|
||||
|
||||
private final SupermarketUnitService supermarketUnitService;
|
||||
|
||||
@@ -54,33 +55,31 @@ public class SupermarketSpuController {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param page 分页对象
|
||||
* @param supermarketSpu 商品spu
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_view')")
|
||||
@Operation(summary = "分页查询" , description = "分页查询" )
|
||||
@GetMapping("/page" )
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_view')" )
|
||||
public R getSupermarketSpuPage(@ParameterObject Page page, @ParameterObject SupermarketSpuEntity supermarketSpu) {
|
||||
LambdaQueryWrapper<SupermarketSpuEntity> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(StrUtil.isNotBlank(supermarketSpu.getProductCode()), SupermarketSpuEntity::getProductCode, supermarketSpu.getProductCode());
|
||||
wrapper.eq(StrUtil.isNotBlank(supermarketSpu.getBarcode()), SupermarketSpuEntity::getBarcode, supermarketSpu.getBarcode());
|
||||
wrapper.eq(StrUtil.isNotBlank(supermarketSpu.getProductName()), SupermarketSpuEntity::getProductName, supermarketSpu.getProductName());
|
||||
wrapper.eq(StringUtils.isNotBlank(supermarketSpu.getProductCode()),SupermarketSpuEntity::getProductCode,supermarketSpu.getProductCode());
|
||||
wrapper.eq(StringUtils.isNotBlank(supermarketSpu.getBarcode()),SupermarketSpuEntity::getBarcode,supermarketSpu.getBarcode());
|
||||
wrapper.eq(StringUtils.isNotBlank(supermarketSpu.getProductName()),SupermarketSpuEntity::getProductName,supermarketSpu.getProductName());
|
||||
return R.ok(supermarketSpuService.pageScope(page, wrapper));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id查询商品spu
|
||||
*
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_view')")
|
||||
public R getById(@PathVariable("id") Long id) {
|
||||
@Operation(summary = "通过id查询" , description = "通过id查询" )
|
||||
@GetMapping("/{id}" )
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_view')" )
|
||||
public R getById(@PathVariable("id" ) Long id) {
|
||||
SupermarketSpuEntity supermarketSpuEntity = supermarketSpuService.getById(id);
|
||||
List<SupermarketUnitEntity> list = supermarketUnitService.list(new LambdaQueryWrapper<SupermarketUnitEntity>().eq(SupermarketUnitEntity::getSpuId, id));
|
||||
supermarketSpuEntity.setSupermarketUnitEntityList(list);
|
||||
@@ -93,14 +92,13 @@ public class SupermarketSpuController {
|
||||
|
||||
/**
|
||||
* 新增商品spu
|
||||
*
|
||||
* @param supermarketSpu 商品spu
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "新增商品spu", description = "新增商品spu")
|
||||
@SysLog("新增商品spu")
|
||||
@Operation(summary = "新增商品spu" , description = "新增商品spu" )
|
||||
@SysLog("新增商品spu" )
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_add')")
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_add')" )
|
||||
public R save(@RequestBody SupermarketSpuEntity supermarketSpu) {
|
||||
supermarketSpu.setDeptId(SecurityUtils.getUser().getDeptId());
|
||||
return supermarketSpuService.saveSpu(supermarketSpu);
|
||||
@@ -108,28 +106,26 @@ public class SupermarketSpuController {
|
||||
|
||||
/**
|
||||
* 修改商品spu
|
||||
*
|
||||
* @param supermarketSpu 商品spu
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "修改商品spu", description = "修改商品spu")
|
||||
@SysLog("修改商品spu")
|
||||
@Operation(summary = "修改商品spu" , description = "修改商品spu" )
|
||||
@SysLog("修改商品spu" )
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_edit')")
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_edit')" )
|
||||
public R updateById(@RequestBody SupermarketSpuEntity supermarketSpu) {
|
||||
return supermarketSpuService.updateSpuById(supermarketSpu);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除商品spu
|
||||
*
|
||||
* @param ids id列表
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id删除商品spu", description = "通过id删除商品spu")
|
||||
@SysLog("通过id删除商品spu")
|
||||
@Operation(summary = "通过id删除商品spu" , description = "通过id删除商品spu" )
|
||||
@SysLog("通过id删除商品spu" )
|
||||
@DeleteMapping
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_del')")
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_del')" )
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(supermarketSpuService.removeSpuBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
@@ -137,31 +133,30 @@ public class SupermarketSpuController {
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
*
|
||||
* @param supermarketSpu 查询条件
|
||||
* @param ids 导出指定ID
|
||||
* @param ids 导出指定ID
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_export')")
|
||||
public List<SupermarketSpuEntity> export(SupermarketSpuEntity supermarketSpu, Long[] ids) {
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_export')" )
|
||||
public List<SupermarketSpuEntity> export(SupermarketSpuEntity supermarketSpu,Long[] ids) {
|
||||
return supermarketSpuService.list(Wrappers.lambdaQuery(supermarketSpu).in(ArrayUtil.isNotEmpty(ids), SupermarketSpuEntity::getId, ids));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// --------APP-----------------
|
||||
|
||||
|
||||
/**
|
||||
* 条件查询spu单表 列表信息
|
||||
*
|
||||
* @param supermarketSpuQueryDTO 商品spu
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "安卓机条件查询所有", description = "安卓机条件查询所有")
|
||||
@PostMapping("/ad/selectListAll")
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_view')")
|
||||
@Operation(summary = "安卓机条件查询所有" , description = "安卓机条件查询所有" )
|
||||
@PostMapping("/ad/selectListAll" )
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_view')" )
|
||||
public R getSupermarketSpuByScope(@RequestBody SupermarketSpuQueryDTO supermarketSpuQueryDTO) {
|
||||
return R.ok(supermarketSpuService.selectListAllScope(supermarketSpuQueryDTO));
|
||||
}
|
||||
@@ -169,36 +164,37 @@ public class SupermarketSpuController {
|
||||
|
||||
/**
|
||||
* 根据spu id 查询spu详情,详情包括辅助条码和包装单位基本信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "条件查询所有", description = "条件查询所有")
|
||||
@GetMapping("/ad/SpuDetails")
|
||||
public R getSupermarketSpuDetailById(@RequestParam("id") Long id) {
|
||||
@Operation(summary = "条件查询所有" , description = "条件查询所有" )
|
||||
@GetMapping("/ad/SpuDetails" )
|
||||
public R getSupermarketSpuDetailById(@RequestParam("id")Long id) {
|
||||
return R.ok(supermarketSpuService.getSupermarketSpuDetailById(id));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/ad/updateSpuStock")
|
||||
@Operation(summary = "更新库存", description = "app和安卓公用")
|
||||
@Operation(summary = "更新库存" , description = "app和安卓公用" )
|
||||
@SysLog("更新商品库存")
|
||||
public R updateSkuStock(@RequestBody SupermarketSpuUpdateStockReqDTO updateStockReqDTO) {
|
||||
public R updateSkuStock(@RequestBody SupermarketSpuUpdateStockReqDTO updateStockReqDTO){
|
||||
return supermarketSpuService.updateSpuStock(updateStockReqDTO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 条件查询spu单表 列表信息
|
||||
*
|
||||
* @param supermarketSpuQueryDTO 商品spu
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "APP根据条件查询分页SPU", description = "APP条件分页查询")
|
||||
@PostMapping("/app/selectListAll")
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_view')")
|
||||
public R getSupermarketSpu(@RequestBody SupermarketSpuAppQueryDTO supermarketSpuQueryDTO, @ParameterObject Page page) {
|
||||
LambdaQueryWrapper<SupermarketSpuEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
@Operation(summary = "APP根据条件查询分页SPU" , description = "APP条件分页查询" )
|
||||
@PostMapping("/app/selectListAll" )
|
||||
@PreAuthorize("@pms.hasPermission('supermarket_supermarketSpu_view')" )
|
||||
public R getSupermarketSpu(@RequestBody SupermarketSpuAppQueryDTO supermarketSpuQueryDTO,@ParameterObject Page page) {
|
||||
LambdaQueryWrapper<SupermarketSpuEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(supermarketSpuQueryDTO.getMerchantId() != null, SupermarketSpuEntity::getMerchantId, supermarketSpuQueryDTO.getMerchantId());
|
||||
wrapper.eq(supermarketSpuQueryDTO.getCategoryId() != null, SupermarketSpuEntity::getCategoryId, supermarketSpuQueryDTO.getCategoryId());
|
||||
// wrapper.eq(StrUtil.isNotBlank(supermarketSpuQueryDTO.getProductCode()), SupermarketSpuEntity::getProductCode, supermarketSpuQueryDTO.getProductCode());
|
||||
@@ -213,25 +209,24 @@ public class SupermarketSpuController {
|
||||
|
||||
/**
|
||||
* 根据spu id 查询spu详情,详情包括辅助条码和包装单位基本信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "app获取spu详情", description = "根据spu的id")
|
||||
@GetMapping("/app/SpuDetails")
|
||||
public R getSupermarketSpuAppDetailById(@RequestParam("id") Long id) {
|
||||
@Operation(summary = "app获取spu详情" , description = "根据spu的id" )
|
||||
@GetMapping("/app/SpuDetails" )
|
||||
public R getSupermarketSpuAppDetailById(@RequestParam("id")Long id) {
|
||||
return R.ok(supermarketSpuService.getSupermarketSpuAppDetailById(id));
|
||||
}
|
||||
|
||||
@GetMapping("/app/checkSpuStock")
|
||||
@SysLog("购物车效验库存")
|
||||
@Transactional
|
||||
public R checkSpuStock(@RequestParam(value = "spuId") Long spuId, @RequestParam("incrCount") Integer incrCount) {
|
||||
SupermarketSpuEntity spu = supermarketSpuService.getById(spuId);
|
||||
public R checkSpuStock(@RequestParam(value ="spuId")Long spuId,@RequestParam("incrCount")Integer incrCount) {
|
||||
SupermarketSpuEntity spu= supermarketSpuService.getById(spuId);
|
||||
if (spu == null) {
|
||||
return R.failed("商品不存在");
|
||||
R.failed("商品不存在");
|
||||
}
|
||||
if (spu.getStock() < Math.abs(incrCount)) {
|
||||
if (spu.getStock()<Math.abs(incrCount)){
|
||||
return R.failed("库存不足");
|
||||
}
|
||||
return R.ok();
|
||||
|
||||
Reference in new issue
Block a user