|
|
@@ -7,14 +7,19 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import io.swagger.annotations.*;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import shop.alien.entity.result.R;
|
|
|
import shop.alien.entity.store.StoreCuisine;
|
|
|
+import shop.alien.entity.store.StorePrice;
|
|
|
import shop.alien.entity.store.dto.CuisineComboDto;
|
|
|
import shop.alien.entity.store.dto.CuisineDetailDto;
|
|
|
+import shop.alien.entity.store.vo.PriceListVo;
|
|
|
import shop.alien.store.service.StoreCuisineService;
|
|
|
+import shop.alien.store.service.StorePriceService;
|
|
|
import shop.alien.store.util.ai.AiGetPriceUtil;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -36,6 +41,8 @@ public class StoreCuisineController {
|
|
|
|
|
|
private final AiGetPriceUtil aiGetPriceUtil;
|
|
|
|
|
|
+ private final StorePriceService storePriceService;
|
|
|
+
|
|
|
@ApiOperation("新增美食套餐或单品")
|
|
|
@ApiOperationSupport(order = 1)
|
|
|
@PostMapping("/addCuisineCombo")
|
|
|
@@ -118,39 +125,81 @@ public class StoreCuisineController {
|
|
|
return R.fail("操作失败");
|
|
|
}
|
|
|
|
|
|
- @ApiOperation("分页查询美食价目")
|
|
|
+ @ApiOperation("分页查询美食价目/通用价目")
|
|
|
@ApiOperationSupport(order = 7)
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name = "pageNum", value = "页码", dataType = "int", paramType = "query", required = true),
|
|
|
@ApiImplicitParam(name = "pageSize", value = "页容", dataType = "int", paramType = "query", required = true),
|
|
|
@ApiImplicitParam(name = "stroeId", value = "商户id", dataType = "Integer", paramType = "query"),
|
|
|
@ApiImplicitParam(name = "name", value = "菜名", dataType = "String", paramType = "query"),
|
|
|
- @ApiImplicitParam(name = "status", value = "状态:0-待审核 1-审核通过 2-审核拒绝", dataType = "Integer", paramType = "query")
|
|
|
+ @ApiImplicitParam(name = "status", value = "状态:0-待审核 1-审核通过 2-审核拒绝", dataType = "Integer", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "type", value = "类型:1-美食 2-通用", dataType = "Integer", paramType = "query")
|
|
|
})
|
|
|
@GetMapping("/getPage")
|
|
|
- public R<IPage<StoreCuisine>> getPage(
|
|
|
- @RequestParam(defaultValue = "1") int pageNum,
|
|
|
- @RequestParam(defaultValue = "10") int pageSize,
|
|
|
+ public R<List<PriceListVo>> getPage(
|
|
|
+ @RequestParam int pageNum,
|
|
|
+ @RequestParam int pageSize,
|
|
|
@RequestParam(required = false) Integer stroeId,
|
|
|
@RequestParam(required = false) String name,
|
|
|
- @RequestParam(required = false) Integer status) {
|
|
|
- log.info("StoreCuisineController.getPage?pageNum={},pageSize={},stroeId={},name={},status={}", pageNum, pageSize, stroeId, name, status);
|
|
|
- Page<StoreCuisine> page = new Page<>(pageNum, pageSize);
|
|
|
- LambdaQueryWrapper<StoreCuisine> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- // 默认只查询已上架的菜品/套餐(shelf_status = 1)
|
|
|
- queryWrapper.eq(StoreCuisine::getShelfStatus, 1);
|
|
|
- if (stroeId != null) {
|
|
|
- queryWrapper.eq(StoreCuisine::getStroeId, stroeId);
|
|
|
- }
|
|
|
- if (name != null && !name.isEmpty()) {
|
|
|
- queryWrapper.like(StoreCuisine::getName, name);
|
|
|
- }
|
|
|
- if (status != null) {
|
|
|
- queryWrapper.eq(StoreCuisine::getStatus, status);
|
|
|
+ @RequestParam(required = false) Integer status,
|
|
|
+ @RequestParam(required = true) Integer type) {
|
|
|
+ log.info("StoreCuisineController.getPage?pageNum={},pageSize={},stroeId={},name={},status={},type={}", pageNum, pageSize, stroeId, name, status, type);
|
|
|
+ List<PriceListVo> priceListVo = new ArrayList<>();
|
|
|
+
|
|
|
+ if(type == 1){
|
|
|
+ Page<StoreCuisine> page = new Page<>(pageNum, pageSize);
|
|
|
+ LambdaQueryWrapper<StoreCuisine> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ // 默认只查询已上架的菜品/套餐(shelf_status = 1)
|
|
|
+ queryWrapper.eq(StoreCuisine::getShelfStatus, 1);
|
|
|
+ if (stroeId != null) {
|
|
|
+ queryWrapper.eq(StoreCuisine::getStroeId, stroeId);
|
|
|
+ }
|
|
|
+ if (name != null && !name.isEmpty()) {
|
|
|
+ queryWrapper.like(StoreCuisine::getName, name);
|
|
|
+ }
|
|
|
+ if (status != null) {
|
|
|
+ queryWrapper.eq(StoreCuisine::getStatus, status);
|
|
|
+ }
|
|
|
+ queryWrapper.orderByDesc(StoreCuisine::getCreatedTime);
|
|
|
+ IPage<StoreCuisine> result = storeCuisineService.page(page, queryWrapper);
|
|
|
+ List<StoreCuisine> cuisineList = result.getRecords();
|
|
|
+
|
|
|
+ if (cuisineList != null && !cuisineList.isEmpty()) {
|
|
|
+ for (StoreCuisine cuisine : cuisineList) {
|
|
|
+ PriceListVo vo = new PriceListVo();
|
|
|
+
|
|
|
+ BeanUtils.copyProperties(cuisine, vo);
|
|
|
+ priceListVo.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(priceListVo);
|
|
|
+ }else{
|
|
|
+ Page<StorePrice> page = new Page<>(pageNum, pageSize);
|
|
|
+ LambdaQueryWrapper<StorePrice> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ if (stroeId != null) {
|
|
|
+ queryWrapper.eq(StorePrice::getStroeId, stroeId);
|
|
|
+ }
|
|
|
+ if (name != null && !name.isEmpty()) {
|
|
|
+ queryWrapper.like(StorePrice::getName, name);
|
|
|
+ }
|
|
|
+ if (status != null) {
|
|
|
+ queryWrapper.eq(StorePrice::getStatus, status);
|
|
|
+ }
|
|
|
+ // 默认只查询已上架的菜品/套餐(shelf_status = 1)
|
|
|
+ queryWrapper.eq(StorePrice::getShelfStatus, 1);
|
|
|
+ queryWrapper.orderByDesc(StorePrice::getCreatedTime);
|
|
|
+ IPage<StorePrice> result = storePriceService.page(page, queryWrapper);
|
|
|
+ List<StorePrice> storePrices = result.getRecords();
|
|
|
+ if (storePrices != null && !storePrices.isEmpty()) {
|
|
|
+ for (StorePrice storePrice : storePrices) {
|
|
|
+ PriceListVo vo = new PriceListVo();
|
|
|
+
|
|
|
+ BeanUtils.copyProperties(storePrice, vo);
|
|
|
+ priceListVo.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(priceListVo);
|
|
|
}
|
|
|
- queryWrapper.orderByDesc(StoreCuisine::getCreatedTime);
|
|
|
- IPage<StoreCuisine> result = storeCuisineService.page(page, queryWrapper);
|
|
|
- return R.data(result);
|
|
|
}
|
|
|
|
|
|
@ApiOperation("根据菜品和位置查询推荐菜价")
|