From 75ac3d5acdd448f063a3c307b4c733e37b4fc04f Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期六, 08 二月 2025 18:17:02 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev

---
 server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java |    4 
 server/service/src/main/java/com/doumee/dao/business/BrandMapper.java               |    7 -
 server/service/src/main/java/com/doumee/dao/business/GoodsMapper.java               |   14 ---
 server/service/src/main/resources/mappers/GoodsMapper.xml                           |  131 ++++++++++++++++++++++++++++++++
 server/service/src/main/resources/mappers/BrandMapper.xml                           |   68 +++++++++++++++++
 5 files changed, 206 insertions(+), 18 deletions(-)

diff --git a/server/service/src/main/java/com/doumee/dao/business/BrandMapper.java b/server/service/src/main/java/com/doumee/dao/business/BrandMapper.java
index c8de851..6ee0d12 100644
--- a/server/service/src/main/java/com/doumee/dao/business/BrandMapper.java
+++ b/server/service/src/main/java/com/doumee/dao/business/BrandMapper.java
@@ -2,11 +2,8 @@
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.doumee.dao.business.model.Brand;
+import java.util.List;
 
-/**
- * @author 姹熻箘韫�
- * @date 2023/05/12 13:58
- */
 public interface BrandMapper extends BaseMapper<Brand> {
-
+    List<Brand> selectListByConditon(Brand paramBrand);
 }
diff --git a/server/service/src/main/java/com/doumee/dao/business/GoodsMapper.java b/server/service/src/main/java/com/doumee/dao/business/GoodsMapper.java
index 9a22e9a..2b71159 100644
--- a/server/service/src/main/java/com/doumee/dao/business/GoodsMapper.java
+++ b/server/service/src/main/java/com/doumee/dao/business/GoodsMapper.java
@@ -1,19 +1,9 @@
 package com.doumee.dao.business;
 
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.doumee.dao.business.model.Goods;
-import com.doumee.dao.business.model.dto.GoodsRequest;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
+import java.util.List;
 
-/**
- * @author 姹熻箘韫�
- * @date 2023/05/12 13:58
- */
 public interface GoodsMapper extends BaseMapper<Goods> {
-
-
+    List<Goods> selectListByCollection(Goods paramGoods);
 }
diff --git a/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java
index 344e395..ce663b5 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java
@@ -646,6 +646,7 @@
         queryWrapper.leftJoin(Category.class, Category::getId, Goods::getCategoryId);
         queryWrapper.leftJoin(Brand.class, Brand::getId, Goods::getBrandId);
         queryWrapper.eq(Goods::getStatus,Constants.ZERO);
+        queryWrapper.eq(Goods::getCompanyId, goods.getCompanyId());
         queryWrapper.eq(Goods::getIsdeleted,Constants.ZERO);
         queryWrapper.like(StringUtils.isNotBlank(goods.getAttrFirstIds()),Goods::getAttrFirstIds,goods.getAttrFirstIds());
         queryWrapper.like(StringUtils.isNotBlank(goods.getAttrFirstNames()),Goods::getAttrFirstNames,goods.getAttrFirstNames());
@@ -656,7 +657,8 @@
         queryWrapper.between(!Objects.isNull(goods.getSPrice())&&!Objects.isNull(goods.getEPrice()),
                 Goods::getPrice,goods.getSPrice(),goods.getEPrice());
         queryWrapper.orderByDesc(Goods::getId);
-        List<Goods> goodsList = goodsJoinMapper.selectJoinList(Goods.class,queryWrapper);
+        List<Goods> goodsList =  this.goodsMapper.selectListByCollection(goods);
+      //  List<Goods> goodsList = goodsJoinMapper.selectJoinList(Goods.class,queryWrapper);
         if(!Objects.isNull(goodsList)&&goodsList.size()>Constants.ZERO){
             this.dealGoodsMsg(goodsList);
         }
diff --git a/server/service/src/main/resources/mappers/BrandMapper.xml b/server/service/src/main/resources/mappers/BrandMapper.xml
new file mode 100644
index 0000000..1547b3d
--- /dev/null
+++ b/server/service/src/main/resources/mappers/BrandMapper.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.doumee.dao.business.BrandMapper">
+
+
+    <select id="selectListByConditon" parameterType="com.doumee.dao.business.model.Brand" resultType="com.doumee.dao.business.model.Brand">
+
+        select aal.id, aal.NAME,aal.type,aal.sortnum
+        FROM (
+        SELECT id, NAME,type,sortnum
+        FROM `brand`
+        <where>
+            <if test="isdeleted!=null and isdeleted!=''">and isdeleted = #{isdeleted}
+            </if>
+            <choose>
+                <when test="type!=null and type =='0'.toString()">
+                    and type=1
+                </when>
+                <otherwise>
+                    <if test="categoryId!=null and categoryId!=''">
+                        AND EXISTS(
+                        SELECT g.id
+                        FROM goods g
+                        WHERE g.brand_id = brand.id
+                        AND g.category_id = #{categoryId}
+                        AND g.COMPANY_ID = #{companyId}
+                        AND g.STATUS = 0
+                        AND g.ISDELETED = 0
+                        )
+                        AND company_id = #{companyId}
+                    </if>
+                </otherwise>
+            </choose>
+        </where>
+        UNION all
+
+        SELECT id,NAME,type,sortnum
+        FROM `brand`
+        <where>
+            <if test="isdeleted!=null and isdeleted!=''">
+                and  isdeleted = #{isdeleted}
+            </if>
+            <choose>
+                <when test="type!=null and type =='0'.toString()">
+                    and type=1
+                </when>
+                <otherwise>
+                    <if test="categoryId!=null and categoryId!=''">
+                        AND EXISTS(
+                        SELECT g.id
+                        FROM goods g
+                        WHERE g.brand_id = brand.id
+                        AND g.category_id = #{categoryId}
+                        AND g.COMPANY_ID = #{companyId}
+                        AND g.STATUS = 0
+                        AND g.ISDELETED = 0
+                        )
+                        AND type = 1   	AND company_id is NULL
+                    </if>
+                </otherwise>
+            </choose>
+        </where>
+        ) aal
+        ORDER BY
+        aal.type ASC,
+        aal.sortnum ASC
+    </select>
+</mapper>
diff --git a/server/service/src/main/resources/mappers/GoodsMapper.xml b/server/service/src/main/resources/mappers/GoodsMapper.xml
new file mode 100644
index 0000000..d9bacea
--- /dev/null
+++ b/server/service/src/main/resources/mappers/GoodsMapper.xml
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.doumee.dao.business.GoodsMapper">
+
+
+    <resultMap id="BaseResultMap" type="com.doumee.dao.business.model.Goods">
+        <id property="id" column="id"/>
+        <collection property="goodsParamList" ofType="com.doumee.dao.business.model.GoodsParam"
+                    select="selectParamByGoodsId" column="{goodsId=id}"
+        >
+
+        </collection>
+
+    </resultMap>
+    <select id="selectParamByGoodsId"   resultType="com.doumee.dao.business.model.GoodsParam">
+        SELECT  gp.GOODS_ID   FROM  cate_param_select cps  ,  goods_param gp
+        where     gp.PRAMA_ID = cps.PARAM_ID     and gp.VAL = cps.`NAME`
+          and gp.GOODS_ID =#{goodsId}
+    </select>
+
+    <select id="selectListByCollection1" parameterType="com.doumee.dao.business.model.Goods" resultType="com.doumee.dao.business.model.Goods">
+        SELECT
+        t.id,
+        t.creator,
+        t.create_date,
+        t.editor,
+        t.edit_date,
+        t.isdeleted,
+        t.remark,
+        t.company_id,
+        t.NAME,
+        t.STATUS,
+        t.sortnum,
+        t.imgurl,
+        t.category_id,
+        t.brand_id,
+        t.zd_price,
+        t.price,
+        t.content,
+
+        t.attr_secod_ids,
+        t.attr_first_names,
+        t.attr_secod_names,
+        t.pinyin,
+        t.short_pinyin,
+        t.goods_id,
+        t.type,
+        t.categoryName,
+        t.brandName,
+        t.attrFirst,
+        t.attrSecond,
+        t.categoryImgurl,
+        t.attr_first_ids
+        FROM
+        `zhuboshoplist` t
+        WHERE
+        t.STATUS = 0
+        <if test="companyId!=null and companyId!=''">
+            AND t.company_id =#{companyId}
+        </if>
+        <if test="brandId!=null and brandId!=''">
+            AND t.brand_id =#{brandId}
+        </if>
+        <if test="categoryId!=null and categoryId!=''">
+            AND t.CATEGORY_ID =#{categoryId}
+        </if>
+        AND t.isdeleted = 0
+        ORDER BY
+        t.id DESC
+    </select>
+
+
+    <select id="selectListByCollection" parameterType="com.doumee.dao.business.model.Goods" resultType="com.doumee.dao.business.model.Goods">
+        SELECT
+        t.id,
+        t.creator,
+        t.create_date,
+        t.editor,
+        t.edit_date,
+        t.isdeleted,
+        t.remark,
+        t.company_id,
+        t.NAME,
+        t.STATUS,
+        t.sortnum,
+        t.imgurl,
+        t.category_id,
+        t.brand_id,
+        t.zd_price,
+        t.price,
+        t.content,
+
+        t.attr_secod_ids,
+        t.attr_first_names,
+        t.attr_secod_names,
+        t.pinyin,
+        t.short_pinyin,
+        t.goods_id,
+        t.type,
+        t1.NAME AS categoryName,
+        t2.NAME AS brandName,
+        t1.attr_first AS attrFirst,
+        t1.attr_second AS attrSecond,
+        t1.imgurl AS categoryImgurl,
+        (
+        SELECT IFNULL(GROUP_CONCAT(cps.id),"" )   FROM  cate_param_select cps  ,  goods_param gp
+        where     gp.PRAMA_ID = cps.PARAM_ID     and gp.VAL = cps.`NAME`
+        and gp.GOODS_ID =t.id
+        ) as attr_first_ids
+        FROM
+        `goods` t
+        LEFT JOIN `category` t1 ON ( t1.id = t.category_id )
+        LEFT JOIN `brand` t2 ON ( t2.id = t.brand_id )
+        WHERE
+        t.STATUS = 0
+        <if test="companyId!=null and companyId!=''">
+            AND t.company_id =#{companyId}
+        </if>
+        <if test="brandId!=null and brandId!=''">
+            AND t.brand_id =#{brandId}
+        </if>
+        <if test="categoryId!=null and categoryId!=''">
+            AND t.CATEGORY_ID =#{categoryId}
+        </if>
+        AND t.isdeleted = 0
+        ORDER BY
+        t.id DESC
+    </select>
+
+
+</mapper>

--
Gitblit v1.9.3