qxy 3 månader sedan
förälder
incheckning
7b569cca02

+ 5 - 0
alien-entity/src/main/java/shop/alien/entity/store/StorePrice.java

@@ -9,6 +9,7 @@ import lombok.Data;
 
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 
 /**
  * 美食价目表
@@ -108,6 +109,10 @@ public class StorePrice {
     @TableField(value = "updated_time", fill = FieldFill.INSERT_UPDATE)
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date updatedTime;
+
+    @ApiModelProperty("通用套餐列表")
+    @TableField(exist = false)
+    private List<StorePrice> storePriceList;
 }
 
 

+ 3 - 0
alien-entity/src/main/java/shop/alien/entity/store/dto/CuisineDetailDto.java

@@ -36,5 +36,8 @@ public class CuisineDetailDto {
         @ApiModelProperty("分类名称(中间表 category)")
         private String category;
     }
+
+    @ApiModelProperty("美食套餐/单品列表")
+    private List<StoreCuisine> storeCuisineList;
 }
 

+ 101 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/PriceListVo.java

@@ -0,0 +1,101 @@
+package shop.alien.entity.store.vo;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import shop.alien.entity.store.StoreCuisine;
+import shop.alien.entity.store.StorePrice;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 价目表通用VO
+ * 用于返回美食价目表list 通用价目表list
+ *
+ * @author assistant
+ * @since 2025-12-31
+ */
+@Data
+@JsonInclude
+@ApiModel(value = "PriceListVo对象", description = "价目表通用VO")
+public class PriceListVo {
+
+    @ApiModelProperty(value = "主键")
+    private Integer id;
+
+    @ApiModelProperty(value = "商户id")
+    private Integer stroeId;
+
+    @ApiModelProperty(value = "名字")
+    private String name;
+
+    @ApiModelProperty(value = "总价")
+    private BigDecimal totalPrice;
+
+    @ApiModelProperty(value = "图片列表,最多 9 张 URL")
+    private String images;
+
+    @ApiModelProperty(value = "图文详情-图片")
+    private String imageContent;
+
+    @ApiModelProperty(value = "服务项目json(服务名称:name,数量:num,单位:unit,服务说明:details)")
+    private String serviceJson;
+
+    @ApiModelProperty(value = "图文详情-文字")
+    private String detailContent;
+
+    @ApiModelProperty(value = "补充说明")
+    private String extraNote;
+
+    @ApiModelProperty(value = "是否需要预约:0=否,1=是")
+    private Integer needReserve;
+
+    @ApiModelProperty(value = "预约规则")
+    private String reserveRule;
+
+    @ApiModelProperty(value = "适用人数")
+    private Integer peopleLimit;
+
+    @ApiModelProperty(value = "使用规则")
+    private String usageRule;
+
+    @ApiModelProperty(value = "状态:0-待审核 1-审核通过 2-审核拒绝")
+    private Integer status;
+
+    @ApiModelProperty(value = "上下架状态:1-上架,2-下架")
+    private Integer shelfStatus;
+
+    @ApiModelProperty(value = "美食类型: 1-单品,2-套餐")
+    private Integer cuisineType;
+
+    @ApiModelProperty(value = "拒绝原因")
+    private String rejectionReason;
+
+    @ApiModelProperty(value = "删除标记, 0:未删除, 1:已删除")
+    @TableLogic
+    private Integer deleteFlag;
+
+    @ApiModelProperty(value = "创建人")
+    @TableField(value = "created_user_id", fill = FieldFill.INSERT)
+    private Integer createdUserId;
+
+    @ApiModelProperty(value = "更新人")
+    @TableField(value = "updated_user_id", fill = FieldFill.UPDATE)
+    private Integer updatedUserId;
+
+    @ApiModelProperty(value = "创建时间")
+    @TableField(value = "created_time", fill = FieldFill.INSERT)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createdTime;
+
+    @ApiModelProperty(value = "更新时间")
+    @TableField(value = "updated_time", fill = FieldFill.INSERT_UPDATE)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date updatedTime;
+}

+ 71 - 22
alien-store/src/main/java/shop/alien/store/controller/StoreCuisineController.java

@@ -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("根据菜品和位置查询推荐菜价")

+ 2 - 0
alien-store/src/main/java/shop/alien/store/controller/StorePriceController.java

@@ -80,6 +80,8 @@ public class StorePriceController {
         log.info("StorePriceController.getById?id={}", id);
         StorePrice storePrice = storePriceService.getById(id);
         if (storePrice != null) {
+            List<StorePrice> storePrices = storePriceService.list(new LambdaQueryWrapper<StorePrice>().eq(StorePrice :: getStroeId, storePrice.getStroeId()));
+            storePrice.setStorePriceList(storePrices);
             return R.data(storePrice);
         }
         return R.fail("查询失败");

+ 6 - 1
alien-store/src/main/java/shop/alien/store/service/impl/StoreCuisineServiceImpl.java

@@ -40,6 +40,8 @@ public class StoreCuisineServiceImpl extends ServiceImpl<StoreCuisineMapper, Sto
 
     private final ObjectMapper objectMapper = new ObjectMapper();
 
+    private final StoreCuisineMapper storeCuisineMapper;
+
     /**
      * 新增美食(单品或套餐)
      */
@@ -126,6 +128,10 @@ public class StoreCuisineServiceImpl extends ServiceImpl<StoreCuisineMapper, Sto
         CuisineDetailDto dto = new CuisineDetailDto();
         dto.setBaseInfo(base);
 
+        //查询当前门店套餐/单品列表 详情头部使用
+        List<StoreCuisine> cuisineList = storeCuisineMapper.selectList(new LambdaQueryWrapper<StoreCuisine>().eq(StoreCuisine :: getStroeId, base.getStroeId()));
+        dto.setStoreCuisineList(cuisineList);
+
         // 单品:直接返回主信息,items 为空
         if (cuisineType != null && cuisineType == 1) {
             dto.setItems(Collections.emptyList());
@@ -167,7 +173,6 @@ public class StoreCuisineServiceImpl extends ServiceImpl<StoreCuisineMapper, Sto
             detail.setCategory(combo.getCategory());
             itemDetails.add(detail);
         }
-
         dto.setItems(itemDetails);
         return dto;
     }