Bläddra i källkod

完成相关代码提交

wangzhijun 2 veckor sedan
förälder
incheckning
ec8eb677d5

+ 11 - 12
nightFragrance-massage/src/main/java/com/ylx/massage/service/impl/ProductSelectionServiceImpl.java

@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ylx.massage.domain.Product;
-import com.ylx.massage.domain.TXiangmu;
 import com.ylx.massage.domain.dto.OptionDTO;
 import com.ylx.massage.domain.dto.ServiceOptionDTO;
 import com.ylx.massage.domain.vo.ProductOptionVO;
@@ -13,11 +12,11 @@ import com.ylx.massage.domain.vo.ProductServiceOptionVO;
 import com.ylx.massage.enums.ProductTypeEnum;
 import com.ylx.massage.service.ProductSelectionService;
 import com.ylx.massage.service.ProductService;
-import com.ylx.massage.service.TXiangmuService;
+import com.ylx.project.domain.Project;
+import com.ylx.project.service.ProjectService;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -25,7 +24,7 @@ import java.util.stream.Collectors;
 public class ProductSelectionServiceImpl implements ProductSelectionService {
 
     @Resource
-    private TXiangmuService xiangmuService; // 项目服务
+    private ProjectService projectService;
 
     @Resource
     private ProductService productService; // 积分商品服务
@@ -51,7 +50,7 @@ public class ProductSelectionServiceImpl implements ProductSelectionService {
 
     @Override
     public Page<ProductServiceOptionVO> serviceOptionsPage(ServiceOptionDTO dto) {
-        Page<ProductServiceOptionVO> resultPage = xiangmuService.selectServiceOptionsPage(new Page(dto.getCurrent(), dto.getSize()), dto);
+        Page<ProductServiceOptionVO> resultPage = projectService.selectServiceOptionsPage(new Page(dto.getCurrent(), dto.getSize()), dto);
         return resultPage;
     }
 
@@ -85,19 +84,19 @@ public class ProductSelectionServiceImpl implements ProductSelectionService {
      */
     private Page<ProductOptionVO> queryProjectProducts(Page page, OptionDTO dto) {
         // 构建查询条件
-        LambdaQueryWrapper<TXiangmu> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(TXiangmu::getIsDelete, 0);
+        LambdaQueryWrapper<Project> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(Project::getIsDelete, 0);
         if (StrUtil.isNotEmpty(dto.getTitle())) {
-            wrapper.like(TXiangmu::getcTitle, dto.getTitle());
+            wrapper.like(Project::getCTitle, dto.getTitle());
         }
         // 执行分页查询
-        Page<TXiangmu> xiangmuPage = xiangmuService.page(page, wrapper);
+        Page<Project> xiangmuPage = this.projectService.page(page, wrapper);
 
         // 转换 VO
         return convertToVOPage(xiangmuPage, x -> {
             ProductOptionVO vo = new ProductOptionVO();
-            vo.setId(x.getcId()); // String 直接赋值
-            vo.setTitle(x.getcTitle());
+            vo.setId(x.getId().toString()); // String 直接赋值
+            vo.setTitle(x.getCTitle());
             vo.setProductType(0); // 设置商品类型
             return vo;
         });
@@ -113,7 +112,7 @@ public class ProductSelectionServiceImpl implements ProductSelectionService {
      */
     private Page<ProductOptionVO> queryAllProductsUnion(Page page, OptionDTO dto) {
         // 调用自定义 SQL
-        IPage<ProductOptionVO> resultPage = xiangmuService.selectOptionUnionPage(page, dto);
+        IPage<ProductOptionVO> resultPage = this.projectService.selectOptionUnionPage(page, dto);
 
         // 将 IPage 转为具体的 Page 实现类返回(如果需要)
         Page<ProductOptionVO> returnPage = new Page<>(page.getCurrent(), page.getSize());

+ 6 - 0
nightFragrance-massage/src/main/java/com/ylx/project/domain/Project.java

@@ -66,4 +66,10 @@ public class Project extends BaseEntity {
     @ApiModelProperty("前端展示排序")
     private Long sortOrder;
 
+    @ApiModelProperty("是否删除0否1是")
+    private Integer isDelete;
+
+    @ApiModelProperty("项目详情 富文本")
+    private String detail;
+
 }

+ 11 - 0
nightFragrance-massage/src/main/java/com/ylx/project/domain/dto/ProjectAddDTO.java

@@ -58,6 +58,17 @@ public class ProjectAddDTO implements Serializable {
     @ApiModelProperty("适用人群")
     private String targetAudience;
 
+    @ApiModelProperty("项目详情 富文本")
+    private String detail;
+
+    public String getDetail() {
+        return detail;
+    }
+
+    public void setDetail(String detail) {
+        this.detail = detail;
+    }
+
     public String getcTitle() {
         return cTitle;
     }

+ 11 - 0
nightFragrance-massage/src/main/java/com/ylx/project/mapper/ProjectMapper.java

@@ -1,7 +1,18 @@
 package com.ylx.project.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ylx.massage.domain.dto.OptionDTO;
+import com.ylx.massage.domain.dto.ServiceOptionDTO;
+import com.ylx.massage.domain.vo.ProductOptionVO;
+import com.ylx.massage.domain.vo.ProductServiceOptionVO;
 import com.ylx.project.domain.Project;
+import org.apache.ibatis.annotations.Param;
 
 public interface ProjectMapper extends BaseMapper<Project> {
+
+    Page<ProductOptionVO> selectOptionUnionPage(Page<ProductOptionVO> page, @Param("dto") OptionDTO dto);
+
+
+    Page<ProductServiceOptionVO> selectServiceOptionsPage(Page page, @Param("dto") ServiceOptionDTO dto);
 }

+ 9 - 0
nightFragrance-massage/src/main/java/com/ylx/project/service/ProjectService.java

@@ -1,7 +1,12 @@
 package com.ylx.project.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.ylx.massage.domain.dto.OptionDTO;
+import com.ylx.massage.domain.dto.ServiceOptionDTO;
+import com.ylx.massage.domain.vo.ProductOptionVO;
+import com.ylx.massage.domain.vo.ProductServiceOptionVO;
 import com.ylx.project.domain.Project;
 import com.ylx.project.domain.dto.ProjectAddDTO;
 import com.ylx.project.domain.dto.ProjectSearchDTO;
@@ -15,4 +20,8 @@ public interface ProjectService extends IService<Project> {
     void edit(ProjectUpdateDTO dto);
 
     void add(ProjectAddDTO dto);
+
+    IPage<ProductOptionVO> selectOptionUnionPage(Page page, OptionDTO dto);
+
+    Page<ProductServiceOptionVO> selectServiceOptionsPage(Page page, ServiceOptionDTO dto);
 }

+ 15 - 0
nightFragrance-massage/src/main/java/com/ylx/project/service/impl/ProjectServiceImpl.java

@@ -5,11 +5,16 @@ import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ylx.common.exception.ServiceException;
 import com.ylx.common.utils.DateUtils;
 import com.ylx.common.utils.SecurityUtils;
+import com.ylx.massage.domain.dto.OptionDTO;
+import com.ylx.massage.domain.dto.ServiceOptionDTO;
+import com.ylx.massage.domain.vo.ProductOptionVO;
+import com.ylx.massage.domain.vo.ProductServiceOptionVO;
 import com.ylx.point.domain.PointActivity;
 import com.ylx.point.domain.vo.PointActivityPageVo;
 import com.ylx.project.domain.Project;
@@ -96,6 +101,16 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 
     }
 
+    @Override
+    public IPage<ProductOptionVO> selectOptionUnionPage(Page page, OptionDTO dto) {
+        return baseMapper.selectOptionUnionPage(page, dto);
+    }
+
+    @Override
+    public Page<ProductServiceOptionVO> selectServiceOptionsPage(Page page, ServiceOptionDTO dto) {
+        return baseMapper.selectServiceOptionsPage(page, dto);
+    }
+
     private ProjectPageVo convertToVo(Project entity) {
         ProjectPageVo vo = new ProjectPageVo();
         // 属性拷贝(推荐)

+ 115 - 0
nightFragrance-massage/src/main/resources/mapper/project/ProjectMapper.xml

@@ -4,5 +4,120 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ylx.project.mapper.ProjectMapper">
 
+    <!-- 结果集映射 -->
+    <resultMap id="OptionVOMap" type="com.ylx.massage.domain.vo.ProductOptionVO">
+        <result column="id" property="id"/>
+        <result column="title" property="title"/>
+        <result column="productType" property="productType"/>
+    </resultMap>
+
+    <!-- 核心 SQL:UNION ALL 分页查询 -->
+    <select id="selectOptionUnionPage" resultMap="OptionVOMap">
+        SELECT * FROM (
+        <!-- 第一部分:积分商品 -->
+        SELECT
+        CAST(id AS CHAR) as id,
+        name as title,
+        1 as productType
+        FROM product
+        WHERE status = 1 AND deleted = 0
+        <if test="dto.title != null and dto.title != ''">
+            AND name LIKE CONCAT('%', #{dto.title}, '%')
+        </if>
+        UNION ALL
+        <!-- 第二部分:项目商品 -->
+        SELECT
+        id,
+        c_title as title,
+        0 as productType
+        FROM project
+        WHERE is_delete = 0
+        <if test="dto.title != null and dto.title != ''">
+            AND c_title LIKE CONCAT('%', #{dto.title}, '%')
+        </if>
+        ) as temp_table
+    </select>
+
+    <!-- 结果集映射保持不变 -->
+    <resultMap id="ServiceOptionsVOMap" type="com.ylx.massage.domain.vo.ProductServiceOptionVO">
+        <result column="id" property="id"/>
+        <result column="title" property="title"/>
+        <result column="productType" property="productType"/>
+        <result column="serviceAreaCode" property="areaCode"/>
+        <result column="serviceAreaName" property="areaName"/>
+        <result column="price" property="price"/>
+        <result column="merchantName" property="merchantName"/>
+        <result column="merchantId" property="merchantId"/>
+    </resultMap>
+
+    <select id="selectServiceOptionsPage" resultMap="ServiceOptionsVOMap">
+        SELECT
+        p.id AS id,
+        ANY_VALUE(p.c_title) AS title,
+        CASE WHEN p.type = '1' THEN 0 ELSE 0 END AS productType,
+        ANY_VALUE(p.d_price) AS price,
+        '广誉源' AS merchantName,
+        '10000' AS merchantId,
+        ANY_VALUE(
+        CASE
+        WHEN #{dto.areaCode} IS NOT NULL THEN (SELECT name FROM area WHERE code = #{dto.areaCode})
+        ELSE agg.area_names
+        END
+        ) AS serviceAreaName,
+        ANY_VALUE(
+        CASE
+        WHEN #{dto.areaCode} IS NOT NULL THEN #{dto.areaCode}
+        ELSE agg.area_codes
+        END
+        ) AS serviceAreaCode
+        FROM project p
+        INNER JOIN (
+        SELECT
+        j_inner.c_bh_list,
+        GROUP_CONCAT(DISTINCT a.code SEPARATOR ',') AS area_codes,  -- code拼接
+        GROUP_CONCAT(DISTINCT a.name SEPARATOR ',') AS area_names  -- 名称拼接
+        FROM t_js j_inner
+        JOIN area a ON FIND_IN_SET(a.code, j_inner.service_area_codes)
+        WHERE j_inner.is_delete = 0
+        AND j_inner.n_tong = 1
+        GROUP BY j_inner.c_bh_list
+        ) agg ON FIND_IN_SET(p.id, agg.c_bh_list)
+        WHERE
+        p.is_delete = 0
+        <if test="dto.productType != null and dto.productType == 0">
+            AND p.type = 1
+        </if>
+        <if test="dto.productType != null and dto.productType == 1">
+            AND 1 = 0
+        </if>
+        <if test="dto.productType != null and dto.productType != 0 and dto.productType != 1">
+            AND p.type = #{dto.productType}
+        </if>
+        <if test="dto.productType == null">
+            AND p.type = 1
+        </if>
+        <if test="dto.title != null and dto.title != ''">
+            AND p.c_title LIKE CONCAT('%', #{dto.title}, '%')
+        </if>
+        <if test="dto.ids != null and dto.ids.size() > 0">
+            AND p.id IN
+            <foreach collection="dto.ids" item="id" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
+        AND EXISTS (
+        SELECT 1
+        FROM t_js j
+        WHERE j.is_delete = 0
+        AND j.n_tong = 1
+        AND (#{dto.areaCode} IS NULL OR FIND_IN_SET(#{dto.areaCode}, j.service_area_codes))
+        AND FIND_IN_SET(p.id, j.c_bh_list)
+        )
+        GROUP BY
+        p.id
+        ORDER BY
+        p.create_time DESC
+    </select>
+
 
 </mapper>