浏览代码

价格表-酒吧相关通用代码,临时版本,防止冲突

liyafei 3 天之前
父节点
当前提交
b5bd514b7b
共有 21 个文件被更改,包括 359 次插入163 次删除
  1. 24 0
      alien-entity/src/main/java/shop/alien/entity/result/CommonEnum.java
  2. 8 4
      alien-entity/src/main/java/shop/alien/entity/store/StoreProductBar.java
  3. 4 4
      alien-entity/src/main/java/shop/alien/entity/store/StoreProductDelicacies.java
  4. 4 4
      alien-entity/src/main/java/shop/alien/entity/store/StoreProductGym.java
  5. 10 5
      alien-entity/src/main/java/shop/alien/entity/store/StoreProductItem.java
  6. 58 0
      alien-entity/src/main/java/shop/alien/entity/store/dto/StoreProductItemDto.java
  7. 4 0
      alien-entity/src/main/java/shop/alien/mapper/StoreProductItemMapper.java
  8. 76 0
      alien-entity/src/main/resources/mapper/StoreProductItemMapper.xml
  9. 0 2
      alien-store/src/main/java/shop/alien/store/config/MyBatisFieldHandler.java
  10. 11 11
      alien-store/src/main/java/shop/alien/store/controller/StoreProductBarController.java
  11. 10 10
      alien-store/src/main/java/shop/alien/store/controller/StoreProductDelicaciesController.java
  12. 11 11
      alien-store/src/main/java/shop/alien/store/controller/StoreProductGymController.java
  13. 9 43
      alien-store/src/main/java/shop/alien/store/controller/StoreProductItemController.java
  14. 10 6
      alien-store/src/main/java/shop/alien/store/service/StoreProductBarService.java
  15. 6 6
      alien-store/src/main/java/shop/alien/store/service/StoreProductDelicaciesService.java
  16. 6 6
      alien-store/src/main/java/shop/alien/store/service/StoreProductGymService.java
  17. 8 6
      alien-store/src/main/java/shop/alien/store/service/StoreProductItemService.java
  18. 14 9
      alien-store/src/main/java/shop/alien/store/service/impl/StoreProductBarServiceImpl.java
  19. 9 9
      alien-store/src/main/java/shop/alien/store/service/impl/StoreProductDelicaciesServiceImpl.java
  20. 9 9
      alien-store/src/main/java/shop/alien/store/service/impl/StoreProductGymServiceImpl.java
  21. 68 18
      alien-store/src/main/java/shop/alien/store/service/impl/StoreProductItemServiceImpl.java

+ 24 - 0
alien-entity/src/main/java/shop/alien/entity/result/CommonEnum.java

@@ -0,0 +1,24 @@
+package shop.alien.entity.result;
+
+
+public interface CommonEnum {
+
+      enum StoreProductItemProdType {
+        BAR_DRINK(1, "酒吧-酒水"),
+        BAR_FOOD(2, "酒吧-餐食"),
+        DELICACY_FOOD(3, "美食-餐食"),
+        GYM_SINGLE(4, "运动健身-单次"),
+        GYM_MULTI(5, "运动健身-多次");
+
+        private final int code;
+        private final String desc;
+
+        StoreProductItemProdType(int code, String desc) {
+            this.code = code;
+            this.desc = desc;
+        }
+
+        public int getCode() { return code; }
+        public String getDesc() { return desc; }
+    }
+}

+ 8 - 4
alien-entity/src/main/java/shop/alien/entity/store/StoreProductBar.java

@@ -27,11 +27,15 @@ public class StoreProductBar implements Serializable {
 
     @ApiModelProperty(value = "主键")
     @TableId(value = "id", type = IdType.AUTO)
-    private Long id;
+    private Integer id;
 
     @ApiModelProperty(value = "商品表主键")
     @TableField("ext_id")
-    private Long extId;
+    private Integer extId;
+
+    @ApiModelProperty(value = "区分套餐下的酒水1,餐食2")
+    @TableField("sub_type")
+    private int sub_type;
 
     @ApiModelProperty(value = "名称(酒水,餐食)")
     @TableField("name")
@@ -80,11 +84,11 @@ public class StoreProductBar implements Serializable {
 
     @ApiModelProperty(value = "创建人")
     @TableField("created_user_id")
-    private Long createdUserId;
+    private Integer createdUserId;
 
     @ApiModelProperty(value = "更新人")
     @TableField("updated_user_id")
-    private Long updatedUserId;
+    private Integer updatedUserId;
 
     @ApiModelProperty(value = "创建时间")
     @TableField(value = "created_time", fill = FieldFill.INSERT)

+ 4 - 4
alien-entity/src/main/java/shop/alien/entity/store/StoreProductDelicacies.java

@@ -27,11 +27,11 @@ public class StoreProductDelicacies implements Serializable {
 
     @ApiModelProperty(value = "主键")
     @TableId(value = "id", type = IdType.AUTO)
-    private Long id;
+    private Integer id;
 
     @ApiModelProperty(value = "商品表主键")
     @TableField("ext_id")
-    private Long extId;
+    private Integer extId;
 
     @ApiModelProperty(value = "名称")
     @TableField("name")
@@ -72,11 +72,11 @@ public class StoreProductDelicacies implements Serializable {
 
     @ApiModelProperty(value = "创建人")
     @TableField("created_user_id")
-    private Long createdUserId;
+    private Integer createdUserId;
 
     @ApiModelProperty(value = "更新人")
     @TableField("updated_user_id")
-    private Long updatedUserId;
+    private Integer updatedUserId;
 
     @ApiModelProperty(value = "创建时间")
     @TableField(value = "created_time", fill = FieldFill.INSERT)

+ 4 - 4
alien-entity/src/main/java/shop/alien/entity/store/StoreProductGym.java

@@ -27,11 +27,11 @@ public class StoreProductGym implements Serializable {
 
     @ApiModelProperty(value = "主键")
     @TableId(value = "id", type = IdType.AUTO)
-    private Long id;
+    private Integer id;
 
     @ApiModelProperty(value = "商品表主键")
     @TableField("ext_id")
-    private Long extId;
+    private Integer extId;
 
     @ApiModelProperty(value = "名称")
     @TableField("name")
@@ -84,11 +84,11 @@ public class StoreProductGym implements Serializable {
 
     @ApiModelProperty(value = "创建人")
     @TableField("created_user_id")
-    private Long createdUserId;
+    private Integer createdUserId;
 
     @ApiModelProperty(value = "更新人")
     @TableField("updated_user_id")
-    private Long updatedUserId;
+    private Integer updatedUserId;
 
     @ApiModelProperty(value = "创建时间")
     @TableField(value = "created_time", fill = FieldFill.INSERT)

+ 10 - 5
alien-entity/src/main/java/shop/alien/entity/store/StoreProductItem.java

@@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
 import java.util.Date;
 
 /**
@@ -26,11 +27,11 @@ public class StoreProductItem implements Serializable {
 
     @ApiModelProperty(value = "主键")
     @TableId(value = "id", type = IdType.AUTO)
-    private Long id;
+    private Integer id;
 
     @ApiModelProperty(value = "父id")
-    @TableField(value = "pid", fill = FieldFill.INSERT)
-    private Long pid;
+    @TableField(value = "pid")
+    private Integer pid;
 
     @ApiModelProperty(value = "门店id")
     @TableField("store_id")
@@ -40,6 +41,10 @@ public class StoreProductItem implements Serializable {
     @TableField("prod_name")
     private String prodName;
 
+    @ApiModelProperty(value = "总价")
+    @TableField("total_price")
+    private BigDecimal totalPrice;
+
     @ApiModelProperty(value = "商品类型,整型枚举:1酒吧-酒水 2酒吧-餐食 3美食-餐食 4运动健身-单次 5运动健身-多次")
     @TableField("prod_type")
     private Integer prodType;
@@ -91,11 +96,11 @@ public class StoreProductItem implements Serializable {
 
     @ApiModelProperty(value = "创建人")
     @TableField("created_user_id")
-    private Long createdUserId;
+    private Integer createdUserId;
 
     @ApiModelProperty(value = "更新人")
     @TableField("updated_user_id")
-    private Long updatedUserId;
+    private Integer updatedUserId;
 
     @ApiModelProperty(value = "创建时间")
     @TableField(value = "created_time", fill = FieldFill.INSERT)

+ 58 - 0
alien-entity/src/main/java/shop/alien/entity/store/dto/StoreProductItemDto.java

@@ -0,0 +1,58 @@
+package shop.alien.entity.store.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+@ApiModel(value = "StoreProductItemDto", description = "商品表 DTO")
+public class StoreProductItemDto implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty("区分模块:1酒吧 2美食 3运动健身")
+    private Integer modelType;
+
+    @ApiModelProperty("主键")
+    private Integer id;
+
+    @ApiModelProperty("门店id")
+    private Integer storeId;
+
+    @ApiModelProperty("商品名称")
+    private String prodName;
+
+    @ApiModelProperty("商品类型,整型枚举:1酒吧-酒水 2酒吧-餐食 3美食-餐食 4运动健身-单次 5运动健身-多次")
+    private Integer prodType;
+
+    @ApiModelProperty("图片列表,最多 9 张 URL")
+    private String images;
+
+    @ApiModelProperty("图文详情-图片")
+    private String imageContent;
+
+    @ApiModelProperty("图文详情-文字")
+    private String detailContent;
+
+    @ApiModelProperty("补充说明")
+    private String extraNote;
+
+    @ApiModelProperty("是否需要预约:0=否,1=是")
+    private Integer needReserve;
+
+    @ApiModelProperty("预约规则")
+    private String reserveRule;
+
+    @ApiModelProperty("适用人数")
+    private Integer peopleLimit;
+
+    @ApiModelProperty("使用规则")
+    private String usageRule;
+
+    @ApiModelProperty("子项列表(后端按类型转换)")
+    private List<?> subList;
+
+}

+ 4 - 0
alien-entity/src/main/java/shop/alien/mapper/StoreProductItemMapper.java

@@ -6,6 +6,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import shop.alien.entity.store.StoreProductItem;
+import shop.alien.entity.store.dto.StoreProductItemDto;
+
+import java.util.ArrayList;
 import shop.alien.entity.store.vo.StoreProductItemGymVo;
 
 /**
@@ -19,6 +22,7 @@ import shop.alien.entity.store.vo.StoreProductItemGymVo;
 @Mapper
 public interface StoreProductItemMapper extends BaseMapper<StoreProductItem> {
 
+    ArrayList<StoreProductItemDto> getByPId(Integer id);
     /**
      * 分页查询商品表与运动健身商品表关联数据
      *

+ 76 - 0
alien-entity/src/main/resources/mapper/StoreProductItemMapper.xml

@@ -32,6 +32,82 @@
         extra_note, need_reserve, reserve_rule, people_limit, usage_rule, status, 
         rejection_reason, delete_flag, created_user_id, updated_user_id, created_time, updated_time
     </sql>
+    <!-- 酒吧商品模块 -->
+    <resultMap id="StoreProductItemDtoMap" type="shop.alien.entity.store.dto.StoreProductItemDto">
+        <id column="id" property="id"/>
+        <result column="store_id" property="storeId"/>
+        <result column="prod_name" property="prodName"/>
+        <result column="prod_type" property="prodType"/>
+        <result column="images" property="images"/>
+        <result column="image_content" property="imageContent"/>
+        <result column="detail_content" property="detailContent"/>
+        <result column="extra_note" property="extraNote"/>
+        <result column="need_reserve" property="needReserve"/>
+        <result column="reserve_rule" property="reserveRule"/>
+        <result column="people_limit" property="peopleLimit"/>
+        <result column="usage_rule" property="usageRule"/>
+
+        <collection property="subList" ofType="shop.alien.entity.store.StoreProductBar">
+            <id column="bar_id" property="id"/>
+            <result column="bar_ext_id" property="extId"/>
+            <result column="sub_type" property="sub_type"/>
+            <result column="name" property="name"/>
+            <result column="price" property="price"/>
+            <result column="cost_price" property="costPrice"/>
+            <result column="unit" property="unit"/>
+            <result column="quantity" property="quantity"/>
+            <result column="category" property="category"/>
+            <result column="alcohol_vol" property="alcoholVol"/>
+            <result column="volume_ml" property="volumeMl"/>
+            <result column="flavor" property="flavor"/>
+            <result column="bar_status" property="status"/>
+            <result column="bar_delete_flag" property="deleteFlag"/>
+            <result column="created_user_id" property="createdUserId" />
+            <result column="updated_user_id" property="updatedUserId" />
+            <result column="bar_created_time" property="createdTime"/>
+            <result column="bar_updated_time" property="updatedTime"/>
+        </collection>
+    </resultMap>
+
+    <select id="getByPId" resultMap="StoreProductItemDtoMap">
+        SELECT
+            spi.id,
+            spi.store_id,
+            spi.prod_name,
+            spi.prod_type,
+            spi.images,
+            spi.image_content,
+            spi.detail_content,
+            spi.extra_note,
+            spi.need_reserve,
+            spi.reserve_rule,
+            spi.people_limit,
+            spi.usage_rule,
+            spb.id           AS bar_id,
+            spb.ext_id       AS bar_ext_id,
+            spb.sub_type,
+            spb.name,
+            spb.price,
+            spb.cost_price,
+            spb.unit,
+            spb.quantity,
+            spb.category,
+            spb.alcohol_vol,
+            spb.volume_ml,
+            spb.flavor,
+            spb.status       AS bar_status,
+            spb.delete_flag  AS bar_delete_flag,
+            spb.created_user_id AS bar_created_user_id,
+            spb.updated_user_id AS bar_updated_user_id,
+            spb.created_time AS bar_created_time,
+            spb.updated_time AS bar_updated_time
+        FROM store_product_item spi
+                 LEFT JOIN store_product_bar spb
+                           ON spb.ext_id = spi.id
+                               AND spb.delete_flag = 0
+        WHERE spi.pid = #{id}
+          AND spi.delete_flag = 0
+    </select>
 
     <!-- 商品表与运动健身商品表关联查询结果映射 -->
     <resultMap id="StoreProductItemGymVoResultMap" type="shop.alien.entity.store.vo.StoreProductItemGymVo">

+ 0 - 2
alien-store/src/main/java/shop/alien/store/config/MyBatisFieldHandler.java

@@ -36,8 +36,6 @@ public class MyBatisFieldHandler implements MetaObjectHandler {
         //字段为实体类名, 不是表字段名
         this.setFieldValByName("createdTime", new Date(), metaObject);
         this.setFieldValByName("updatedTime", new Date(), metaObject);
-        // 设置pid默认值为0
-        this.setFieldValByName("pid", 0L, metaObject);
         if (JwtUtil.hasToken()) {
             this.setFieldValByName("createdUserId", Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getInteger("userId"), metaObject);
             this.setFieldValByName("updatedUserId", Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getInteger("userId"), metaObject);

+ 11 - 11
alien-store/src/main/java/shop/alien/store/controller/StoreProductBarController.java

@@ -72,10 +72,10 @@ public class StoreProductBarController {
     @ApiOperation("删除酒吧商品")
     @ApiOperationSupport(order = 3)
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Long", paramType = "path", required = true)
+            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Integer", paramType = "path", required = true)
     })
     @DeleteMapping("/{id}")
-    public R<String> deleteBar(@PathVariable("id") Long id) {
+    public R<String> deleteBar(@PathVariable("id") Integer id) {
         log.info("StoreProductBarController.deleteBar?id={}", id);
         R<Boolean> result = storeProductBarService.deleteStoreProductBar(id);
         if (result.getCode() == 200) {
@@ -87,10 +87,10 @@ public class StoreProductBarController {
     @ApiOperation("根据ID查询酒吧商品详情")
     @ApiOperationSupport(order = 4)
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Long", paramType = "path", required = true)
+            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Integer", paramType = "path", required = true)
     })
     @GetMapping("/{id}")
-    public R<StoreProductBar> getById(@PathVariable("id") Long id) {
+    public R<StoreProductBar> getById(@PathVariable("id") Integer id) {
         log.info("StoreProductBarController.getById?id={}", id);
         R<StoreProductBar> result = storeProductBarService.getStoreProductBarById(id);
         if (result.getCode() == 200 && result.getData() != null) {
@@ -107,7 +107,7 @@ public class StoreProductBarController {
             @ApiImplicitParam(name = "name", value = "名称(模糊查询)", dataType = "String", paramType = "query"),
             @ApiImplicitParam(name = "category", value = "品类", dataType = "String", paramType = "query"),
             @ApiImplicitParam(name = "status", value = "状态(0:禁用,1:启用)", dataType = "Integer", paramType = "query"),
-            @ApiImplicitParam(name = "extId", value = "商品表主键", dataType = "Long", paramType = "query")
+            @ApiImplicitParam(name = "extId", value = "商品表主键", dataType = "Integer", paramType = "query")
     })
     @GetMapping("/page")
     public R<IPage<StoreProductBar>> getPage(
@@ -116,7 +116,7 @@ public class StoreProductBarController {
             @RequestParam(required = false) String name,
             @RequestParam(required = false) String category,
             @RequestParam(required = false) Integer status,
-            @RequestParam(required = false) Long extId) {
+            @RequestParam(required = false) Integer extId) {
         log.info("StoreProductBarController.getPage?pageNum={}, pageSize={}, name={}, category={}, status={}, extId={}",
                 pageNum, pageSize, name, category, status, extId);
         IPage<StoreProductBar> page = storeProductBarService.getPage(pageNum, pageSize, name, category, status, extId);
@@ -126,7 +126,7 @@ public class StoreProductBarController {
     @ApiOperation("批量删除酒吧商品")
     @ApiOperationSupport(order = 6)
     @PostMapping("/batchDelete")
-    public R<String> deleteBatch(@RequestBody List<Long> ids) {
+    public R<String> deleteBatch(@RequestBody List<Integer> ids) {
         log.info("StoreProductBarController.deleteBatch?ids={}", ids);
         if (ids == null || ids.isEmpty()) {
             return R.fail("ID列表不能为空");
@@ -141,12 +141,12 @@ public class StoreProductBarController {
     @ApiOperation("更新酒吧商品状态")
     @ApiOperationSupport(order = 7)
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Long", paramType = "path", required = true),
+            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Integer", paramType = "path", required = true),
             @ApiImplicitParam(name = "status", value = "状态(0:禁用,1:启用)", dataType = "Integer", paramType = "query", required = true)
     })
     @PutMapping("/{id}/status")
     public R<String> updateStatus(
-            @PathVariable("id") Long id,
+            @PathVariable("id") Integer id,
             @RequestParam("status") Integer status) {
         log.info("StoreProductBarController.updateStatus?id={}, status={}", id, status);
         if (status == null || (status != 0 && status != 1)) {
@@ -162,10 +162,10 @@ public class StoreProductBarController {
     @ApiOperation("根据商品表主键查询酒吧商品列表")
     @ApiOperationSupport(order = 8)
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "extId", value = "商品表主键", dataType = "Long", paramType = "query", required = true)
+            @ApiImplicitParam(name = "extId", value = "商品表主键", dataType = "Integer", paramType = "query", required = true)
     })
     @GetMapping("/listByExtId")
-    public R<List<StoreProductBar>> getListByExtId(@RequestParam("extId") Long extId) {
+    public R<List<StoreProductBar>> getListByExtId(@RequestParam("extId") Integer extId) {
         log.info("StoreProductBarController.getListByExtId?extId={}", extId);
         List<StoreProductBar> list = storeProductBarService.getListByExtId(extId);
         return R.data(list);

+ 10 - 10
alien-store/src/main/java/shop/alien/store/controller/StoreProductDelicaciesController.java

@@ -37,7 +37,7 @@ public class StoreProductDelicaciesController {
             @ApiImplicitParam(name = "category", value = "类别", dataType = "String", paramType = "query"),
             @ApiImplicitParam(name = "extGroup", value = "菜品分组", dataType = "String", paramType = "query"),
             @ApiImplicitParam(name = "status", value = "状态(0:禁用,1:启用)", dataType = "Integer", paramType = "query"),
-            @ApiImplicitParam(name = "extId", value = "商品表主键", dataType = "Long", paramType = "query")
+            @ApiImplicitParam(name = "extId", value = "商品表主键", dataType = "Integer", paramType = "query")
     })
     @GetMapping("/page")
     public R<IPage<StoreProductDelicacies>> getPage(
@@ -47,7 +47,7 @@ public class StoreProductDelicaciesController {
             @RequestParam(required = false) String category,
             @RequestParam(required = false) String extGroup,
             @RequestParam(required = false) Integer status,
-            @RequestParam(required = false) Long extId) {
+            @RequestParam(required = false) Integer extId) {
         log.info("StoreProductDelicaciesController.getPage?pageNum={}, pageSize={}, name={}, category={}, extGroup={}, status={}, extId={}",
                 pageNum, pageSize, name, category, extGroup, status, extId);
         IPage<StoreProductDelicacies> page = storeProductDelicaciesService.getPage(pageNum, pageSize, name, category, extGroup, status, extId);
@@ -57,10 +57,10 @@ public class StoreProductDelicaciesController {
     @ApiOperation("根据ID查询美食商品详情")
     @ApiOperationSupport(order = 2)
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Long", paramType = "path", required = true)
+            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Integer", paramType = "path", required = true)
     })
     @GetMapping("/{id}")
-    public R<StoreProductDelicacies> getById(@PathVariable("id") Long id) {
+    public R<StoreProductDelicacies> getById(@PathVariable("id") Integer id) {
         log.info("StoreProductDelicaciesController.getById?id={}", id);
         StoreProductDelicacies delicacies = storeProductDelicaciesService.getById(id);
         if (delicacies == null) {
@@ -120,7 +120,7 @@ public class StoreProductDelicaciesController {
             @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Long", paramType = "path", required = true)
     })
     @DeleteMapping("/{id}")
-    public R<String> deleteDelicacies(@PathVariable("id") Long id) {
+    public R<String> deleteDelicacies(@PathVariable("id") Integer id) {
         log.info("StoreProductDelicaciesController.deleteDelicacies?id={}", id);
         boolean result = storeProductDelicaciesService.deleteDelicacies(id);
         if (result) {
@@ -132,7 +132,7 @@ public class StoreProductDelicaciesController {
     @ApiOperation("批量删除美食商品")
     @ApiOperationSupport(order = 6)
     @PostMapping("/batchDelete")
-    public R<String> deleteBatch(@RequestBody List<Long> ids) {
+    public R<String> deleteBatch(@RequestBody List<Integer> ids) {
         log.info("StoreProductDelicaciesController.deleteBatch?ids={}", ids);
         if (ids == null || ids.isEmpty()) {
             return R.fail("ID列表不能为空");
@@ -147,12 +147,12 @@ public class StoreProductDelicaciesController {
     @ApiOperation("更新美食商品状态")
     @ApiOperationSupport(order = 7)
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Long", paramType = "path", required = true),
+            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Integer", paramType = "path", required = true),
             @ApiImplicitParam(name = "status", value = "状态(0:禁用,1:启用)", dataType = "Integer", paramType = "query", required = true)
     })
     @PutMapping("/{id}/status")
     public R<String> updateStatus(
-            @PathVariable("id") Long id,
+            @PathVariable("id") Integer id,
             @RequestParam("status") Integer status) {
         log.info("StoreProductDelicaciesController.updateStatus?id={}, status={}", id, status);
         if (status == null || (status != 0 && status != 1)) {
@@ -168,10 +168,10 @@ public class StoreProductDelicaciesController {
     @ApiOperation("根据商品表主键查询美食商品列表")
     @ApiOperationSupport(order = 8)
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "extId", value = "商品表主键", dataType = "Long", paramType = "query", required = true)
+            @ApiImplicitParam(name = "extId", value = "商品表主键", dataType = "Integer", paramType = "query", required = true)
     })
     @GetMapping("/listByExtId")
-    public R<List<StoreProductDelicacies>> getListByExtId(@RequestParam("extId") Long extId) {
+    public R<List<StoreProductDelicacies>> getListByExtId(@RequestParam("extId") Integer extId) {
         log.info("StoreProductDelicaciesController.getListByExtId?extId={}", extId);
         List<StoreProductDelicacies> list = storeProductDelicaciesService.getListByExtId(extId);
         return R.data(list);

+ 11 - 11
alien-store/src/main/java/shop/alien/store/controller/StoreProductGymController.java

@@ -69,10 +69,10 @@ public class StoreProductGymController {
     @ApiOperation("删除运动健身商品")
     @ApiOperationSupport(order = 3)
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Long", paramType = "path", required = true)
+            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Integer", paramType = "path", required = true)
     })
     @DeleteMapping("/{id}")
-    public R<String> deleteGym(@PathVariable("id") Long id) {
+    public R<String> deleteGym(@PathVariable("id") Integer id) {
         log.info("StoreProductGymController.deleteGym?id={}", id);
         R<Boolean> result = storeProductGymService.deleteStoreProductGym(id);
         if (result.getCode() == 200) {
@@ -84,10 +84,10 @@ public class StoreProductGymController {
     @ApiOperation("根据ID查询运动健身商品详情")
     @ApiOperationSupport(order = 4)
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Long", paramType = "path", required = true)
+            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Integer", paramType = "path", required = true)
     })
     @GetMapping("/{id}")
-    public R<StoreProductGym> getById(@PathVariable("id") Long id) {
+    public R<StoreProductGym> getById(@PathVariable("id") Integer id) {
         log.info("StoreProductGymController.getById?id={}", id);
         R<StoreProductGym> result = storeProductGymService.getStoreProductGymById(id);
         if (result.getCode() == 200 && result.getData() != null) {
@@ -104,7 +104,7 @@ public class StoreProductGymController {
             @ApiImplicitParam(name = "name", value = "名称(模糊查询)", dataType = "String", paramType = "query"),
             @ApiImplicitParam(name = "classMode", value = "上课形式", dataType = "String", paramType = "query"),
             @ApiImplicitParam(name = "status", value = "状态(0:禁用,1:启用)", dataType = "Integer", paramType = "query"),
-            @ApiImplicitParam(name = "extId", value = "商品表主键", dataType = "Long", paramType = "query")
+            @ApiImplicitParam(name = "extId", value = "商品表主键", dataType = "Integer", paramType = "query")
     })
     @GetMapping("/page")
     public R<IPage<StoreProductGym>> getPage(
@@ -113,7 +113,7 @@ public class StoreProductGymController {
             @RequestParam(required = false) String name,
             @RequestParam(required = false) String classMode,
             @RequestParam(required = false) Integer status,
-            @RequestParam(required = false) Long extId) {
+            @RequestParam(required = false) Integer extId) {
         log.info("StoreProductGymController.getPage?pageNum={}, pageSize={}, name={}, classMode={}, status={}, extId={}",
                 pageNum, pageSize, name, classMode, status, extId);
         IPage<StoreProductGym> page = storeProductGymService.getPage(pageNum, pageSize, name, classMode, status, extId);
@@ -123,7 +123,7 @@ public class StoreProductGymController {
     @ApiOperation("批量删除运动健身商品")
     @ApiOperationSupport(order = 6)
     @PostMapping("/batchDelete")
-    public R<String> deleteBatch(@RequestBody List<Long> ids) {
+    public R<String> deleteBatch(@RequestBody List<Integer> ids) {
         log.info("StoreProductGymController.deleteBatch?ids={}", ids);
         if (ids == null || ids.isEmpty()) {
             return R.fail("ID列表不能为空");
@@ -138,12 +138,12 @@ public class StoreProductGymController {
     @ApiOperation("更新运动健身商品状态")
     @ApiOperationSupport(order = 7)
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Long", paramType = "path", required = true),
+            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "Integer", paramType = "path", required = true),
             @ApiImplicitParam(name = "status", value = "状态(0:禁用,1:启用)", dataType = "Integer", paramType = "query", required = true)
     })
     @PutMapping("/{id}/status")
     public R<String> updateStatus(
-            @PathVariable("id") Long id,
+            @PathVariable("id") Integer id,
             @RequestParam("status") Integer status) {
         log.info("StoreProductGymController.updateStatus?id={}, status={}", id, status);
         if (status == null || (status != 0 && status != 1)) {
@@ -159,10 +159,10 @@ public class StoreProductGymController {
     @ApiOperation("根据商品表主键查询运动健身商品列表")
     @ApiOperationSupport(order = 8)
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "extId", value = "商品表主键", dataType = "Long", paramType = "query", required = true)
+            @ApiImplicitParam(name = "extId", value = "商品表主键", dataType = "Integer", paramType = "query", required = true)
     })
     @GetMapping("/listByExtId")
-    public R<List<StoreProductGym>> getListByExtId(@RequestParam("extId") Long extId) {
+    public R<List<StoreProductGym>> getListByExtId(@RequestParam("extId") Integer extId) {
         log.info("StoreProductGymController.getListByExtId?extId={}", extId);
         List<StoreProductGym> list = storeProductGymService.getListByExtId(extId);
         return R.data(list);

+ 9 - 43
alien-store/src/main/java/shop/alien/store/controller/StoreProductItemController.java

@@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
 import shop.alien.entity.result.R;
 import shop.alien.entity.store.StoreProductItem;
+import shop.alien.entity.store.dto.StoreProductItemDto;
 import shop.alien.entity.store.vo.StoreProductItemGymVo;
 import shop.alien.store.service.StoreProductItemService;
 import shop.alien.util.myBaticsPlus.QueryBuilder;
@@ -32,23 +33,23 @@ public class StoreProductItemController {
     @ApiOperation("新增商品")
     @ApiOperationSupport(order = 1)
     @PostMapping("/add")
-    public R<StoreProductItem> addStoreProductItem(@RequestBody StoreProductItem storeProductItem) {
-        log.info("StoreProductItemController.addStoreProductItem?storeProductItem={}", storeProductItem);
-        return storeProductItemService.addStoreProductItem(storeProductItem);
+    public R<StoreProductItem> addStoreProductItem(@RequestBody StoreProductItemDto storeProductItemDto) {
+        log.info("StoreProductItemController.addStoreProductItem?storeProductItem={}", storeProductItemDto);
+        return storeProductItemService.addStoreProductItemDto(storeProductItemDto);
     }
 
     @ApiOperation("编辑商品")
     @ApiOperationSupport(order = 2)
     @PostMapping("/edit")
-    public R<StoreProductItem> editStoreProductItem(@RequestBody StoreProductItem storeProductItem) {
-        log.info("StoreProductItemController.editStoreProductItem?storeProductItem={}", storeProductItem);
-        return storeProductItemService.editStoreProductItem(storeProductItem);
+    public R<StoreProductItem> editStoreProductItem(@RequestBody StoreProductItemDto storeProductItemDto) {
+        log.info("StoreProductItemController.editStoreProductItem?storeProductItem={}", storeProductItemDto);
+        return storeProductItemService.editStoreProductItem(storeProductItemDto);
     }
 
     @ApiOperation("删除商品")
     @ApiOperationSupport(order = 3)
     @DeleteMapping("/delete")
-    public R<Boolean> deleteStoreProductItem(@RequestParam(value = "id") Long id) {
+    public R<Boolean> deleteStoreProductItem(@RequestParam(value = "id") Integer id) {
         log.info("StoreProductItemController.deleteStoreProductItem?id={}", id);
         return storeProductItemService.deleteStoreProductItem(id);
     }
@@ -56,46 +57,11 @@ public class StoreProductItemController {
     @ApiOperation("根据ID查询商品")
     @ApiOperationSupport(order = 4)
     @GetMapping("/getById")
-    public R<StoreProductItem> getStoreProductItemById(@RequestParam(value = "id") Long id) {
+    public R<List<StoreProductItemDto>> getStoreProductItemById(@RequestParam(value = "id") Integer id) {
         log.info("StoreProductItemController.getStoreProductItemById?id={}", id);
         return storeProductItemService.getStoreProductItemById(id);
     }
 
-    @ApiOperation("保存或更新商品")
-    @ApiOperationSupport(order = 5)
-    @PostMapping("/saveOrUpdate")
-    public R<StoreProductItem> saveOrUpdate(@RequestBody StoreProductItem storeProductItem) {
-        log.info("StoreProductItemController.saveOrUpdate?storeProductItem={}", storeProductItem);
-        boolean result = storeProductItemService.saveOrUpdate(storeProductItem);
-        if (result) {
-            return R.data(storeProductItem);
-        }
-        return R.fail("操作失败");
-    }
-
-    @ApiOperation("通用列表查询")
-    @ApiOperationSupport(order = 6)
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "id", value = "主键", dataType = "Long", paramType = "query"),
-            @ApiImplicitParam(name = "pid", value = "父id", dataType = "Long", paramType = "query"),
-            @ApiImplicitParam(name = "storeId", value = "门店id", dataType = "Integer", paramType = "query"),
-            @ApiImplicitParam(name = "prodName", value = "商品名称", dataType = "String", paramType = "query"),
-            @ApiImplicitParam(name = "prodType", value = "商品类型(1酒吧-酒水 2酒吧-餐食 3美食-餐食 4运动健身-单次 5运动健身-多次)", dataType = "Integer", paramType = "query"),
-            @ApiImplicitParam(name = "needReserve", value = "是否需要预约(0=否,1=是)", dataType = "Integer", paramType = "query"),
-            @ApiImplicitParam(name = "status", value = "状态(0-待审核 1-审核通过 2-审核拒绝)", dataType = "Integer", paramType = "query"),
-            @ApiImplicitParam(name = "rejectionReason", value = "拒绝原因", dataType = "String", paramType = "query"),
-            @ApiImplicitParam(name = "createdTime_Start", value = "创建时间开始(范围查询)", dataType = "String", paramType = "query"),
-            @ApiImplicitParam(name = "createdTime_End", value = "创建时间结束(范围查询)", dataType = "String", paramType = "query")
-    })
-    @GetMapping("/getList")
-    public R<List<StoreProductItem>> getList(@ModelAttribute StoreProductItem storeProductItem) {
-        log.info("StoreProductItemController.getList?storeProductItem={}", storeProductItem);
-        List<StoreProductItem> list = QueryBuilder.of(storeProductItem)
-                .build()
-                .list(storeProductItemService);
-        return R.data(list);
-    }
-
     @ApiOperation("通用分页查询")
     @ApiOperationSupport(order = 7)
     @ApiImplicitParams({

+ 10 - 6
alien-store/src/main/java/shop/alien/store/service/StoreProductBarService.java

@@ -37,7 +37,7 @@ public interface StoreProductBarService extends IService<StoreProductBar> {
      * @param id 主键
      * @return R<Boolean>
      */
-    R<Boolean> deleteStoreProductBar(Long id);
+    R<Boolean> deleteStoreProductBar(Integer id);
 
     /**
      * 根据ID查询酒吧商品
@@ -45,7 +45,7 @@ public interface StoreProductBarService extends IService<StoreProductBar> {
      * @param id 主键
      * @return R<StoreProductBar>
      */
-    R<StoreProductBar> getStoreProductBarById(Long id);
+    R<StoreProductBar> getStoreProductBarById(Integer id);
 
     /**
      * 分页查询酒吧商品列表
@@ -58,7 +58,7 @@ public interface StoreProductBarService extends IService<StoreProductBar> {
      * @param extId    商品表主键
      * @return IPage<StoreProductBar>
      */
-    IPage<StoreProductBar> getPage(int pageNum, int pageSize, String name, String category, Integer status, Long extId);
+    IPage<StoreProductBar> getPage(int pageNum, int pageSize, String name, String category, Integer status, Integer extId);
 
     /**
      * 根据商品表主键查询酒吧商品列表
@@ -66,7 +66,7 @@ public interface StoreProductBarService extends IService<StoreProductBar> {
      * @param extId 商品表主键
      * @return List<StoreProductBar>
      */
-    List<StoreProductBar> getListByExtId(Long extId);
+    List<StoreProductBar> getListByExtId(Integer extId);
 
     /**
      * 根据品类查询酒吧商品列表
@@ -83,7 +83,7 @@ public interface StoreProductBarService extends IService<StoreProductBar> {
      * @param status 状态(0:禁用,1:启用)
      * @return boolean
      */
-    boolean updateStatus(Long id, Integer status);
+    boolean updateStatus(Integer id, Integer status);
 
     /**
      * 批量删除酒吧商品(逻辑删除)
@@ -91,5 +91,9 @@ public interface StoreProductBarService extends IService<StoreProductBar> {
      * @param ids 主键ID列表
      * @return boolean
      */
-    boolean deleteBatch(List<Long> ids);
+    boolean deleteBatch(List<Integer> ids);
+
+
+    List<StoreProductBar> getByExtId(Integer id);
+
 }

+ 6 - 6
alien-store/src/main/java/shop/alien/store/service/StoreProductDelicaciesService.java

@@ -25,7 +25,7 @@ public interface StoreProductDelicaciesService {
      * @param extId    商品表主键
      * @return IPage<StoreProductDelicacies>
      */
-    IPage<StoreProductDelicacies> getPage(int pageNum, int pageSize, String name, String category, String extGroup, Integer status, Long extId);
+    IPage<StoreProductDelicacies> getPage(int pageNum, int pageSize, String name, String category, String extGroup, Integer status, Integer extId);
 
     /**
      * 根据ID查询美食商品详情
@@ -33,7 +33,7 @@ public interface StoreProductDelicaciesService {
      * @param id 主键ID
      * @return StoreProductDelicacies
      */
-    StoreProductDelicacies getById(Long id);
+    StoreProductDelicacies getById(Integer id);
 
     /**
      * 新增美食商品
@@ -57,7 +57,7 @@ public interface StoreProductDelicaciesService {
      * @param id 主键ID
      * @return boolean
      */
-    boolean deleteDelicacies(Long id);
+    boolean deleteDelicacies(Integer id);
 
     /**
      * 批量删除美食商品(逻辑删除)
@@ -65,7 +65,7 @@ public interface StoreProductDelicaciesService {
      * @param ids 主键ID列表
      * @return boolean
      */
-    boolean deleteBatch(List<Long> ids);
+    boolean deleteBatch(List<Integer> ids);
 
     /**
      * 更新美食商品状态
@@ -74,7 +74,7 @@ public interface StoreProductDelicaciesService {
      * @param status 状态(0:禁用,1:启用)
      * @return boolean
      */
-    boolean updateStatus(Long id, Integer status);
+    boolean updateStatus(Integer id, Integer status);
 
     /**
      * 根据商品表主键查询美食商品列表
@@ -82,7 +82,7 @@ public interface StoreProductDelicaciesService {
      * @param extId 商品表主键
      * @return List<StoreProductDelicacies>
      */
-    List<StoreProductDelicacies> getListByExtId(Long extId);
+    List<StoreProductDelicacies> getListByExtId(Integer extId);
 
     /**
      * 根据类别查询美食商品列表

+ 6 - 6
alien-store/src/main/java/shop/alien/store/service/StoreProductGymService.java

@@ -37,7 +37,7 @@ public interface StoreProductGymService extends IService<StoreProductGym> {
      * @param id 主键
      * @return R<Boolean>
      */
-    R<Boolean> deleteStoreProductGym(Long id);
+    R<Boolean> deleteStoreProductGym(Integer id);
 
     /**
      * 根据ID查询运动健身商品
@@ -45,7 +45,7 @@ public interface StoreProductGymService extends IService<StoreProductGym> {
      * @param id 主键
      * @return R<StoreProductGym>
      */
-    R<StoreProductGym> getStoreProductGymById(Long id);
+    R<StoreProductGym> getStoreProductGymById(Integer id);
 
     /**
      * 分页查询运动健身商品列表
@@ -58,7 +58,7 @@ public interface StoreProductGymService extends IService<StoreProductGym> {
      * @param extId    商品表主键
      * @return IPage<StoreProductGym>
      */
-    IPage<StoreProductGym> getPage(int pageNum, int pageSize, String name, String classMode, Integer status, Long extId);
+    IPage<StoreProductGym> getPage(int pageNum, int pageSize, String name, String classMode, Integer status, Integer extId);
 
     /**
      * 根据商品表主键查询运动健身商品列表
@@ -66,7 +66,7 @@ public interface StoreProductGymService extends IService<StoreProductGym> {
      * @param extId 商品表主键
      * @return List<StoreProductGym>
      */
-    List<StoreProductGym> getListByExtId(Long extId);
+    List<StoreProductGym> getListByExtId(Integer extId);
 
     /**
      * 更新运动健身商品状态
@@ -75,7 +75,7 @@ public interface StoreProductGymService extends IService<StoreProductGym> {
      * @param status 状态(0:禁用,1:启用)
      * @return boolean
      */
-    boolean updateStatus(Long id, Integer status);
+    boolean updateStatus(Integer id, Integer status);
 
     /**
      * 批量删除运动健身商品(逻辑删除)
@@ -83,5 +83,5 @@ public interface StoreProductGymService extends IService<StoreProductGym> {
      * @param ids 主键ID列表
      * @return boolean
      */
-    boolean deleteBatch(List<Long> ids);
+    boolean deleteBatch(List<Integer> ids);
 }

+ 8 - 6
alien-store/src/main/java/shop/alien/store/service/StoreProductItemService.java

@@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import shop.alien.entity.result.R;
 import shop.alien.entity.store.StoreProductItem;
+import shop.alien.entity.store.dto.StoreProductItemDto;
 import shop.alien.entity.store.vo.StoreProductItemGymVo;
 
+import java.util.List;
+
 /**
  * 商品表 服务类
  *
@@ -16,11 +19,9 @@ public interface StoreProductItemService extends IService<StoreProductItem> {
 
     /**
      * 新增商品
-     *
-     * @param storeProductItem 商品
      * @return R<StoreProductItem>
      */
-    R<StoreProductItem> addStoreProductItem(StoreProductItem storeProductItem);
+    R<StoreProductItem> addStoreProductItemDto(StoreProductItemDto storeProductItemDto);
 
     /**
      * 编辑商品
@@ -28,7 +29,7 @@ public interface StoreProductItemService extends IService<StoreProductItem> {
      * @param storeProductItem 商品
      * @return R<StoreProductItem>
      */
-    R<StoreProductItem> editStoreProductItem(StoreProductItem storeProductItem);
+    R<StoreProductItem> editStoreProductItem(StoreProductItemDto storeProductItem);
 
     /**
      * 删除商品
@@ -36,7 +37,7 @@ public interface StoreProductItemService extends IService<StoreProductItem> {
      * @param id 主键
      * @return R<Boolean>
      */
-    R<Boolean> deleteStoreProductItem(Long id);
+    R<Boolean> deleteStoreProductItem(Integer id);
 
     /**
      * 根据ID查询商品
@@ -44,7 +45,8 @@ public interface StoreProductItemService extends IService<StoreProductItem> {
      * @param id 主键
      * @return R<StoreProductItem>
      */
-    R<StoreProductItem> getStoreProductItemById(Long id);
+    R<List<StoreProductItemDto>> getStoreProductItemById(Integer id);
+
 
     /**
      * 分页查询商品表与运动健身商品表关联数据

+ 14 - 9
alien-store/src/main/java/shop/alien/store/service/impl/StoreProductBarServiceImpl.java

@@ -43,10 +43,10 @@ public class StoreProductBarServiceImpl extends ServiceImpl<StoreProductBarMappe
             storeProductBar.setStatus(1);
         }
         if (storeProductBar.getCreatedUserId() == null) {
-            storeProductBar.setCreatedUserId(0L);
+            storeProductBar.setCreatedUserId(0);
         }
         if (storeProductBar.getUpdatedUserId() == null) {
-            storeProductBar.setUpdatedUserId(0L);
+            storeProductBar.setUpdatedUserId(0);
         }
 
         boolean result = this.save(storeProductBar);
@@ -66,7 +66,7 @@ public class StoreProductBarServiceImpl extends ServiceImpl<StoreProductBarMappe
 
         // 设置更新人
         if (storeProductBar.getUpdatedUserId() == null) {
-            storeProductBar.setUpdatedUserId(0L);
+            storeProductBar.setUpdatedUserId(0);
         }
 
         boolean result = this.updateById(storeProductBar);
@@ -77,7 +77,7 @@ public class StoreProductBarServiceImpl extends ServiceImpl<StoreProductBarMappe
     }
 
     @Override
-    public R<Boolean> deleteStoreProductBar(Long id) {
+    public R<Boolean> deleteStoreProductBar(Integer id) {
         log.info("StoreProductBarServiceImpl.deleteStoreProductBar?id={}", id);
         boolean result = this.removeById(id);
         if (result) {
@@ -87,7 +87,7 @@ public class StoreProductBarServiceImpl extends ServiceImpl<StoreProductBarMappe
     }
 
     @Override
-    public R<StoreProductBar> getStoreProductBarById(Long id) {
+    public R<StoreProductBar> getStoreProductBarById(Integer id) {
         log.info("StoreProductBarServiceImpl.getStoreProductBarById?id={}", id);
         StoreProductBar storeProductBar = this.getById(id);
         if (storeProductBar != null) {
@@ -97,7 +97,7 @@ public class StoreProductBarServiceImpl extends ServiceImpl<StoreProductBarMappe
     }
 
     @Override
-    public IPage<StoreProductBar> getPage(int pageNum, int pageSize, String name, String category, Integer status, Long extId) {
+    public IPage<StoreProductBar> getPage(int pageNum, int pageSize, String name, String category, Integer status, Integer extId) {
         LambdaQueryWrapper<StoreProductBar> queryWrapper = new LambdaQueryWrapper<>();
 
         // 名称模糊查询
@@ -127,7 +127,7 @@ public class StoreProductBarServiceImpl extends ServiceImpl<StoreProductBarMappe
     }
 
     @Override
-    public List<StoreProductBar> getListByExtId(Long extId) {
+    public List<StoreProductBar> getListByExtId(Integer extId) {
         if (extId == null) {
             return null;
         }
@@ -149,7 +149,7 @@ public class StoreProductBarServiceImpl extends ServiceImpl<StoreProductBarMappe
     }
 
     @Override
-    public boolean updateStatus(Long id, Integer status) {
+    public boolean updateStatus(Integer id, Integer status) {
         if (id == null) {
             log.error("更新酒吧商品状态失败:ID不能为空");
             return false;
@@ -167,7 +167,7 @@ public class StoreProductBarServiceImpl extends ServiceImpl<StoreProductBarMappe
     }
 
     @Override
-    public boolean deleteBatch(List<Long> ids) {
+    public boolean deleteBatch(List<Integer> ids) {
         if (ids == null || ids.isEmpty()) {
             log.error("批量删除酒吧商品失败:ID列表不能为空");
             return false;
@@ -175,4 +175,9 @@ public class StoreProductBarServiceImpl extends ServiceImpl<StoreProductBarMappe
         // 逻辑删除,MyBatis-Plus会自动处理
         return this.removeByIds(ids);
     }
+
+    @Override
+    public List<StoreProductBar> getByExtId(Integer id) {
+        return this.lambdaQuery().eq(StoreProductBar::getExtId, id).list();
+    }
 }

+ 9 - 9
alien-store/src/main/java/shop/alien/store/service/impl/StoreProductDelicaciesServiceImpl.java

@@ -30,7 +30,7 @@ public class StoreProductDelicaciesServiceImpl implements StoreProductDelicacies
     private final StoreProductDelicaciesMapper storeProductDelicaciesMapper;
 
     @Override
-    public IPage<StoreProductDelicacies> getPage(int pageNum, int pageSize, String name, String category, String extGroup, Integer status, Long extId) {
+    public IPage<StoreProductDelicacies> getPage(int pageNum, int pageSize, String name, String category, String extGroup, Integer status, Integer extId) {
         LambdaQueryWrapper<StoreProductDelicacies> queryWrapper = new LambdaQueryWrapper<>();
 
         // 名称模糊查询
@@ -65,7 +65,7 @@ public class StoreProductDelicaciesServiceImpl implements StoreProductDelicacies
     }
 
     @Override
-    public StoreProductDelicacies getById(Long id) {
+    public StoreProductDelicacies getById(Integer id) {
         return storeProductDelicaciesMapper.selectById(id);
     }
 
@@ -82,10 +82,10 @@ public class StoreProductDelicaciesServiceImpl implements StoreProductDelicacies
             delicacies.setStatus(1);
         }
         if (delicacies.getCreatedUserId() == null) {
-            delicacies.setCreatedUserId(0L);
+            delicacies.setCreatedUserId(0);
         }
         if (delicacies.getUpdatedUserId() == null) {
-            delicacies.setUpdatedUserId(0L);
+            delicacies.setUpdatedUserId(0);
         }
 
         return storeProductDelicaciesMapper.insert(delicacies) > 0;
@@ -100,20 +100,20 @@ public class StoreProductDelicaciesServiceImpl implements StoreProductDelicacies
 
         // 设置更新人
         if (delicacies.getUpdatedUserId() == null) {
-            delicacies.setUpdatedUserId(0L);
+            delicacies.setUpdatedUserId(0);
         }
 
         return storeProductDelicaciesMapper.updateById(delicacies) > 0;
     }
 
     @Override
-    public boolean deleteDelicacies(Long id) {
+    public boolean deleteDelicacies(Integer id) {
         // 逻辑删除,MyBatis-Plus会自动处理
         return storeProductDelicaciesMapper.deleteById(id) > 0;
     }
 
     @Override
-    public boolean deleteBatch(List<Long> ids) {
+    public boolean deleteBatch(List<Integer> ids) {
         if (ids == null || ids.isEmpty()) {
             log.error("批量删除美食商品失败:ID列表不能为空");
             return false;
@@ -123,7 +123,7 @@ public class StoreProductDelicaciesServiceImpl implements StoreProductDelicacies
     }
 
     @Override
-    public boolean updateStatus(Long id, Integer status) {
+    public boolean updateStatus(Integer id, Integer status) {
         if (id == null) {
             log.error("更新美食商品状态失败:ID不能为空");
             return false;
@@ -141,7 +141,7 @@ public class StoreProductDelicaciesServiceImpl implements StoreProductDelicacies
     }
 
     @Override
-    public List<StoreProductDelicacies> getListByExtId(Long extId) {
+    public List<StoreProductDelicacies> getListByExtId(Integer extId) {
         if (extId == null) {
             return null;
         }

+ 9 - 9
alien-store/src/main/java/shop/alien/store/service/impl/StoreProductGymServiceImpl.java

@@ -40,10 +40,10 @@ public class StoreProductGymServiceImpl extends ServiceImpl<StoreProductGymMappe
             storeProductGym.setStatus(1);
         }
         if (storeProductGym.getCreatedUserId() == null) {
-            storeProductGym.setCreatedUserId(0L);
+            storeProductGym.setCreatedUserId(0);
         }
         if (storeProductGym.getUpdatedUserId() == null) {
-            storeProductGym.setUpdatedUserId(0L);
+            storeProductGym.setUpdatedUserId(0);
         }
 
         boolean result = this.save(storeProductGym);
@@ -63,7 +63,7 @@ public class StoreProductGymServiceImpl extends ServiceImpl<StoreProductGymMappe
 
         // 设置更新人
         if (storeProductGym.getUpdatedUserId() == null) {
-            storeProductGym.setUpdatedUserId(0L);
+            storeProductGym.setUpdatedUserId(0);
         }
 
         boolean result = this.updateById(storeProductGym);
@@ -74,7 +74,7 @@ public class StoreProductGymServiceImpl extends ServiceImpl<StoreProductGymMappe
     }
 
     @Override
-    public R<Boolean> deleteStoreProductGym(Long id) {
+    public R<Boolean> deleteStoreProductGym(Integer id) {
         log.info("StoreProductGymServiceImpl.deleteStoreProductGym?id={}", id);
         boolean result = this.removeById(id);
         if (result) {
@@ -84,7 +84,7 @@ public class StoreProductGymServiceImpl extends ServiceImpl<StoreProductGymMappe
     }
 
     @Override
-    public R<StoreProductGym> getStoreProductGymById(Long id) {
+    public R<StoreProductGym> getStoreProductGymById(Integer id) {
         log.info("StoreProductGymServiceImpl.getStoreProductGymById?id={}", id);
         StoreProductGym storeProductGym = this.getById(id);
         if (storeProductGym != null) {
@@ -94,7 +94,7 @@ public class StoreProductGymServiceImpl extends ServiceImpl<StoreProductGymMappe
     }
 
     @Override
-    public IPage<StoreProductGym> getPage(int pageNum, int pageSize, String name, String classMode, Integer status, Long extId) {
+    public IPage<StoreProductGym> getPage(int pageNum, int pageSize, String name, String classMode, Integer status, Integer extId) {
         LambdaQueryWrapper<StoreProductGym> queryWrapper = new LambdaQueryWrapper<>();
 
         // 名称模糊查询
@@ -124,7 +124,7 @@ public class StoreProductGymServiceImpl extends ServiceImpl<StoreProductGymMappe
     }
 
     @Override
-    public List<StoreProductGym> getListByExtId(Long extId) {
+    public List<StoreProductGym> getListByExtId(Integer extId) {
         if (extId == null) {
             return null;
         }
@@ -135,7 +135,7 @@ public class StoreProductGymServiceImpl extends ServiceImpl<StoreProductGymMappe
     }
 
     @Override
-    public boolean updateStatus(Long id, Integer status) {
+    public boolean updateStatus(Integer id, Integer status) {
         if (id == null) {
             log.error("更新运动健身商品状态失败:ID不能为空");
             return false;
@@ -153,7 +153,7 @@ public class StoreProductGymServiceImpl extends ServiceImpl<StoreProductGymMappe
     }
 
     @Override
-    public boolean deleteBatch(List<Long> ids) {
+    public boolean deleteBatch(List<Integer> ids) {
         if (ids == null || ids.isEmpty()) {
             log.error("批量删除运动健身商品失败:ID列表不能为空");
             return false;

+ 68 - 18
alien-store/src/main/java/shop/alien/store/service/impl/StoreProductItemServiceImpl.java

@@ -5,14 +5,24 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import shop.alien.entity.result.CommonEnum;
 import shop.alien.entity.result.R;
+import shop.alien.entity.store.StoreProductBar;
 import shop.alien.entity.store.StoreProductItem;
 import shop.alien.entity.store.vo.StoreProductItemGymVo;
+import shop.alien.entity.store.dto.StoreProductItemDto;
 import shop.alien.mapper.StoreProductItemMapper;
+import shop.alien.store.service.StoreProductBarService;
 import shop.alien.store.service.StoreProductItemService;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
  * 商品表 服务实现类
  *
@@ -20,33 +30,66 @@ import shop.alien.store.service.StoreProductItemService;
  * @since 2025-01-XX
  */
 @Slf4j
-@Transactional
+@Transactional(rollbackFor = Exception.class)
 @Service
 @RequiredArgsConstructor
 public class StoreProductItemServiceImpl extends ServiceImpl<StoreProductItemMapper, StoreProductItem> implements StoreProductItemService {
 
+    private final ObjectMapper objectMapper;
+
+    private final StoreProductBarService storeProductBarService;
+
     @Override
-    public R<StoreProductItem> addStoreProductItem(StoreProductItem storeProductItem) {
-        log.info("StoreProductItemServiceImpl.addStoreProductItem?storeProductItem={}", storeProductItem);
-        boolean result = this.save(storeProductItem);
-        if (result) {
-            return R.data(storeProductItem);
+    public R<StoreProductItem> addStoreProductItemDto(StoreProductItemDto storeProductItemDto) {
+        log.info("StoreProductItemServiceImpl.addStoreProductItem?storeProductItem={}", storeProductItemDto);
+        StoreProductItem storeProductItem = new StoreProductItem();
+        BeanUtils.copyProperties(storeProductItemDto,storeProductItem);
+        // 设置pid默认值为0
+        storeProductItem.setPid(0);
+        // MySQL 驱动开启 useGeneratedKeys(Spring Boot 默认开启,通常不用改)。
+        this.save(storeProductItem);
+        // 添加套餐时,需要前端在子集合内元素分别设置type
+        // 处理子项(判空)
+        List<?> rawSubList = storeProductItemDto.getSubList();
+        if (rawSubList != null && !rawSubList.isEmpty()) {
+            List<StoreProductBar> subList = rawSubList.stream()
+                    .map(v -> objectMapper.convertValue(v, StoreProductBar.class))
+                    .collect(Collectors.toList());
+            Integer parentId = storeProductItem.getId();
+            subList.forEach(v -> v.setExtId(parentId));
+            boolean subSaved = storeProductBarService.saveBatch(subList);
+            if (!subSaved) {
+                throw new RuntimeException("子项保存失败");
+            }
         }
-        return R.fail("新增失败");
+        return R.data(storeProductItem);
     }
 
     @Override
-    public R<StoreProductItem> editStoreProductItem(StoreProductItem storeProductItem) {
-        log.info("StoreProductItemServiceImpl.editStoreProductItem?storeProductItem={}", storeProductItem);
-        boolean result = this.updateById(storeProductItem);
-        if (result) {
-            return R.data(storeProductItem);
+    public R<StoreProductItem> editStoreProductItem(StoreProductItemDto storeProductItemDto) {
+        log.info("StoreProductItemServiceImpl.editStoreProductItem?storeProductItem={}", storeProductItemDto);
+        StoreProductItem storeProductItem = new StoreProductItem();
+        BeanUtils.copyProperties(storeProductItemDto,storeProductItem);
+        this.updateById(storeProductItem);
+        // 添加套餐时,需要前端在子集合内元素分别设置type
+        // 处理子项(判空)
+        List<?> rawSubList = storeProductItemDto.getSubList();
+        if (rawSubList != null && !rawSubList.isEmpty()) {
+            List<StoreProductBar> subList = rawSubList.stream()
+                    .map(v -> objectMapper.convertValue(v, StoreProductBar.class))
+                    .collect(Collectors.toList());
+            Integer parentId = storeProductItem.getId();
+            subList.forEach(v -> v.setExtId(parentId));
+            boolean subSaved = storeProductBarService.saveBatch(subList);
+            if (!subSaved) {
+                throw new RuntimeException("子项保存失败");
+            }
         }
-        return R.fail("修改失败");
+        return R.data(storeProductItem);
     }
 
     @Override
-    public R<Boolean> deleteStoreProductItem(Long id) {
+    public R<Boolean> deleteStoreProductItem(Integer id) {
         log.info("StoreProductItemServiceImpl.deleteStoreProductItem?id={}", id);
         boolean result = this.removeById(id);
         if (result) {
@@ -56,13 +99,20 @@ public class StoreProductItemServiceImpl extends ServiceImpl<StoreProductItemMap
     }
 
     @Override
-    public R<StoreProductItem> getStoreProductItemById(Long id) {
+    public R<List<StoreProductItemDto>> getStoreProductItemById(Integer id) {
         log.info("StoreProductItemServiceImpl.getStoreProductItemById?id={}", id);
         StoreProductItem storeProductItem = this.getById(id);
-        if (storeProductItem != null) {
-            return R.data(storeProductItem);
+        ArrayList<StoreProductItemDto> list = new ArrayList<>();
+        StoreProductItemDto storeProductItemDto = new StoreProductItemDto();
+        list.add(storeProductItemDto);
+        BeanUtils.copyProperties(storeProductItem,storeProductItemDto);
+        if (CommonEnum.StoreProductItemProdType.DELICACY_FOOD.getCode() == storeProductItem.getProdType()) {
+            list = this.getBaseMapper().getByPId(id);
+        }else {
+            List<StoreProductBar> barList = storeProductBarService.getByExtId(id);
+            storeProductItemDto.setSubList(barList);
         }
-        return R.fail("查询失败,数据不存在");
+        return R.data(list);
     }
 
     @Override