Browse Source

1、修改查询根据分类查询店铺方法

qmj 6 months ago
parent
commit
11a7e5b96b

+ 8 - 0
ruoyi-admin/src/main/java/com/ruoyi/app/mendian/PosStoreController.java

@@ -22,6 +22,7 @@ import com.ruoyi.system.mapper.SysConfigMapper;
 import com.ruoyi.system.service.*;
 import com.ruoyi.system.utils.Auth;
 import com.ruoyi.system.utils.JwtUtil;
+import io.swagger.models.auth.In;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.transaction.annotation.Transactional;
@@ -32,6 +33,7 @@ import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
@@ -62,6 +64,10 @@ public class PosStoreController extends BaseController
     @Autowired
     private SysConfigMapper sysConfigMapper;
 
+
+
+
+
     /**
      * 根据评分查旬门店
      * @param longitude
@@ -184,6 +190,8 @@ public class PosStoreController extends BaseController
             org.put("telephone",posStore.getTelephone());
             org.put("Collect", !list.isEmpty() ?1:0);
             org.put("logo",posStore.getLogo());
+            org.put("isNightMarket",posStore.getIsNightMarket());
+            org.put("nightMarketId",posStore.getNightMarketId());
 
             QueryWrapper<OperatingHours> wrapper = new QueryWrapper<>();
             wrapper.eq("md_id", posStore.getId());

+ 30 - 1
ruoyi-admin/src/main/java/com/ruoyi/app/mendian/PosTypeController.java

@@ -1,8 +1,10 @@
 package com.ruoyi.app.mendian;
 
+import java.util.ArrayList;
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.ruoyi.common.annotation.Anonymous;
 import com.ruoyi.common.utils.MessageUtils;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -26,7 +28,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
 
 /**
  * 门店分类Controller
- * 
+ *
  * @author ruoyi
  * @date 2023-05-13
  */
@@ -36,6 +38,21 @@ public class PosTypeController extends BaseController
 {
     @Autowired
     private IPosTypeService posTypeService;
+    /**
+     * 根据标识获取一级分类
+     * @param tag  tag=food 美食  tag=mall商城
+     */
+    @Anonymous
+    @GetMapping("/listByTag")
+    public AjaxResult getListByTag(String  tag)
+    {
+        List<PosType> list =new ArrayList<>();
+        PosType parent=posTypeService.getOne(new LambdaQueryWrapper<PosType>().eq(PosType::getTag,tag));
+        if(parent!=null){
+            list=posTypeService.list(new LambdaQueryWrapper<PosType>().eq(PosType::getParentId,parent.getId()));
+        }
+        return success(list);
+    }
 
     /**
      * 查询门店分类列表
@@ -72,6 +89,18 @@ public class PosTypeController extends BaseController
         util.exportExcel(response, list, MessageUtils.message("no.export.excel.mendian.classify"));
     }
 
+    /**
+     * 查询门店分类树结构
+     */
+    @Anonymous
+    @GetMapping("/treeList")
+    public AjaxResult treeList(PosType posType)
+    {
+        List<PosType> list = posTypeService.selectPosTypeTreeList(posType);
+        return success(list);
+    }
+
+
     /**
      * 获取门店分类详细信息
      */

+ 3 - 2
ruoyi-admin/src/main/java/com/ruoyi/app/order/UserOrderController.java

@@ -13,9 +13,10 @@ import com.ruoyi.system.service.IOrderParentService;
 import com.ruoyi.system.service.IPosOrderService;
 import com.ruoyi.system.utils.Auth;
 import com.ruoyi.system.utils.JwtUtil;
-import io.swagger.v3.oas.annotations.parameters.RequestBody;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestHeader;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -39,7 +40,7 @@ public class UserOrderController extends BaseController {
     /**
      * 创建订单
      */
-    @RequestMapping("/createOrder")
+    @PostMapping("/createOrder")
     @Auth
     @Anonymous
     @Transactional(rollbackFor = Exception.class)

+ 24 - 15
ruoyi-admin/src/main/java/com/ruoyi/app/user/UserAppIndexController.java

@@ -1,6 +1,7 @@
 package com.ruoyi.app.user;
 
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -9,14 +10,9 @@ import com.alibaba.fastjson.JSONArray;
 import com.ruoyi.common.annotation.Anonymous;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.system.domain.PosFood;
-import com.ruoyi.system.domain.PosOrder;
-import com.ruoyi.system.domain.PosStore;
-import com.ruoyi.system.domain.PosType;
+import com.ruoyi.system.domain.*;
 import com.ruoyi.system.mapper.PosStoreMapper;
-import com.ruoyi.system.service.IPosOrderService;
-import com.ruoyi.system.service.IPosFoodService;
-import com.ruoyi.system.service.IPosTypeService;
+import com.ruoyi.system.service.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -26,8 +22,9 @@ import org.springframework.web.bind.annotation.*;
 import java.math.BigDecimal;
 import java.util.List;
 import java.util.ArrayList;
+import java.util.Map;
+
 import com.ruoyi.system.mapper.PosOrderMapper;
-import com.ruoyi.system.service.IFoodStatisticsService;
 import com.ruoyi.app.user.dto.StoreOutput;
 import org.springframework.beans.BeanUtils;
 
@@ -53,16 +50,28 @@ public class UserAppIndexController extends BaseController {
 
     @Autowired
     private PosStoreMapper posStoreMapper;
+    @Autowired
+    private IInfoUserService infoUserService;
+
     /**
-     * 获取分类列表
+     * 获取夜市列表
+     * @return
      */
     @Anonymous
-    @GetMapping("/getcategoryList")
-    public AjaxResult getCategoryList() {
-        LambdaQueryWrapper<PosType> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.ne(PosType::getId, 0);
-        List<PosType> list = posTypeService.list(queryWrapper);
-        return AjaxResult.success(list);
+    @GetMapping("/getNightMarketList")
+    public AjaxResult getNightMarketList(){
+        LambdaQueryWrapper<InfoUser> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(InfoUser::getUserType,"3");
+        List<InfoUser> list = infoUserService.list(queryWrapper);
+        List<Map<String,Object>> result = new ArrayList<>();
+//        list.forEach(infoUser -> {
+//            Map<String,Object> map = new JSONObject();
+//            map.put("id",infoUser.getUserId());
+//            map.put("name",infoUser.getUserName());
+////            map.put("phone",infoUser.getPhone());
+//            result.add(map);
+//        });
+        return success(list);
     }
 
     /**

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/domain/OrderParent.java

@@ -30,7 +30,7 @@ public class OrderParent
     @TableId(type = IdType.AUTO)
     @GeneratedValue
     /** 父订单ID */
-    private Long parentOrderId;
+    private Long id;
 
     /** 用户ID */
     @Excel(name = "用户ID")

+ 9 - 1
ruoyi-system/src/main/java/com/ruoyi/system/domain/PosStore.java

@@ -91,7 +91,7 @@ public class PosStore
 
     /** 分类 */
     @Excel(name = "分类")
-    private Long sort;
+    private String sort;
 
     /** 所属用户id */
     @Excel(name = "所属用户id")
@@ -131,6 +131,14 @@ public class PosStore
     @Excel(name = "客服电话")
     private String telephone;
 
+    /** 是否关联夜市 */
+    @Excel(name = "是否关联夜市")
+    private Integer isNightMarket;
+
+    /** 夜市id */
+    @Excel(name = "夜市id")
+    private Long nightMarketId;
+
     /** 用户名 */
     @Excel(name = "用户名")
     private transient String userName;

+ 47 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/PosType.java

@@ -1,10 +1,15 @@
 package com.ruoyi.system.domain;
 
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.ruoyi.common.core.domain.entity.SysDept;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * 门店分类对象 pos_type
  *
@@ -42,6 +47,21 @@ public class PosType
     @Excel(name = "排序")
     private String sort;
 
+   /** 父级id */
+    @Excel(name = "父级id")
+    private Long parentId;
+
+    /** 标识 */
+    @Excel(name = "标识")
+    private String tag;
+    /** 祖级列表 */
+    @Excel(name = "祖级列表")
+    private String ancestors;
+
+    @TableField(exist = false)
+    /** 子分类 */
+    private List<PosType> children = new ArrayList<PosType>();
+
     public void setId(Long id)
     {
         this.id = id;
@@ -103,6 +123,30 @@ public class PosType
         this.sort = sort;
     }
 
+    public Long getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(Long parentId) {
+        this.parentId = parentId;
+    }
+
+    public String getTag() {
+        return tag;
+    }
+
+    public void setTag(String tag) {
+        this.tag = tag;
+    }
+
+    public String getAncestors() {
+        return ancestors;
+    }
+
+    public void setAncestors(String ancestors) {
+        this.ancestors = ancestors;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@@ -113,6 +157,9 @@ public class PosType
             .append("nameTw", getNameTw())
             .append("image", getImage())
             .append("sort", getSort())
+            .append("parentId", getParentId())
+            .append("tag", getTag())
+            .append("ancestors", getAncestors())
             .toString();
     }
 }

+ 3 - 3
ruoyi-system/src/main/java/com/ruoyi/system/mapper/PosStoreMapper.java

@@ -21,7 +21,7 @@ public interface PosStoreMapper extends BaseMapper<PosStore>
     List<PosStore> getmdlist(@Param("longitude")BigDecimal longitude, @Param("latitude")BigDecimal latitude,@Param("page")Integer page,@Param("area")String area,@Param("juli")Integer juli);  //反回结果
 
     //按照分类距离查询分类商家
-    @Select("SELECT *,(st_distance(point(longitude,latitude),point(#{longitude},#{latitude}))*111195/1000 ) as juli,(SELECT del_flag FROM info_user WHERE info_user.user_id = pos_store.user_id) as xxzt FROM pos_store WHERE off_shelf='0' and area like #{area} and sort=#{sort}  HAVING xxzt=0 ORDER BY juli ASC limit #{page},20")  //查询语句
+    @Select("SELECT *,(st_distance(point(longitude,latitude),point(#{longitude},#{latitude}))*111195/1000 ) as juli,(SELECT del_flag FROM info_user WHERE info_user.user_id = pos_store.user_id) as xxzt FROM pos_store WHERE off_shelf='0' and area like #{area} and FIND_IN_SET(#{sort},sort) > 0  HAVING xxzt=0 ORDER BY juli ASC limit #{page},20")  //查询语句
     List<PosStore> getdaidiq(@Param("longitude")BigDecimal longitude, @Param("latitude")BigDecimal latitude,@Param("page")Integer page,@Param("area")String area,@Param("juli")Integer juli,@Param("sort")Integer sort);  //反回结果
 
 
@@ -42,12 +42,12 @@ public interface PosStoreMapper extends BaseMapper<PosStore>
 
     //精选门店
     @Select("<script>SELECT *,(st_distance(point(longitude,latitude),point(#{longitude},#{latitude}))*111195/1000 ) as juli,(SELECT del_flag FROM info_user WHERE info_user.user_id = pos_store.user_id) as xxzt,(SELECT IFNULL(AVG(score),0) FROM pos_review WHERE pos_review.md_id = pos_store.id) as pingf,(SELECT IFNULL(COUNT(id),0) FROM pos_order WHERE pos_order.md_id = pos_store.id) as ddsl  FROM pos_store WHERE off_shelf='0' " +
-            " <if test='flId != null and flId != 0'>and sort = #{flId}</if> " +
+            " <if test='flId != null and flId != 0'>and FIND_IN_SET(#{flId},sort) > 0</if> " +
             " HAVING xxzt=0 ORDER BY pingf DESC limit #{page},10</script>")  //查询语句
     List<PosStore> getjxStore(@Param("longitude")BigDecimal longitude, @Param("latitude")BigDecimal latitude,@Param("page")Integer page,@Param("flId")Long flId);  //反回结果
 
     @Select("<script>SELECT COUNT(*),(st_distance(point(longitude,latitude),point(#{longitude},#{latitude}))*111195/1000 ) as juli,(SELECT del_flag FROM info_user WHERE info_user.user_id = pos_store.user_id) as xxzt,(SELECT IFNULL(AVG(score),0) FROM pos_review WHERE pos_review.md_id = pos_store.id) as pingf,(SELECT IFNULL(COUNT(id),0) FROM pos_order WHERE pos_order.md_id = pos_store.id) as ddsl  FROM pos_store WHERE off_shelf='0' " +
-            " <if test='flId != null and flId != 0'>and sort = #{flId}</if> " +
+            " <if test='flId != null and flId != 0'>and FIND_IN_SET(#{flId},sort) > 0</if> " +
             " HAVING xxzt=0 ORDER BY pingf DESC</script>")  //查询语句
     int getjxStoreCount(@Param("longitude")BigDecimal longitude, @Param("latitude")BigDecimal latitude,@Param("flId")Long flId);
 

+ 16 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/PosTypeMapper.java

@@ -61,4 +61,20 @@ public interface PosTypeMapper  extends BaseMapper<PosType>
      * @return 结果
      */
     public int deletePosTypeByIds(Long[] ids);
+
+    /**
+     * 查询门店分类树结构
+     *
+     * @param posType 门店分类
+     * @return 门店分类集合
+     */
+    public List<PosType> selectPosTypeTreeList(PosType posType);
+
+    /**
+     * 查询子分类数量
+     *
+     * @param parentId 父分类ID
+     * @return 结果
+     */
+    public int selectPosTypeCountByParentId(Long parentId);
 }

+ 16 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/IPosTypeService.java

@@ -61,4 +61,20 @@ public interface IPosTypeService extends IService<PosType>
      * @return 结果
      */
     public int deletePosTypeById(Long id);
+
+    /**
+     * 查询门店分类树结构
+     *
+     * @param posType 门店分类
+     * @return 门店分类集合
+     */
+    public List<PosType> selectPosTypeTreeList(PosType posType);
+
+    /**
+     * 查询子分类数量
+     *
+     * @param parentId 父分类ID
+     * @return 结果
+     */
+    public int selectPosTypeCountByParentId(Long parentId);
 }

+ 24 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PosTypeServiceImpl.java

@@ -94,4 +94,28 @@ public class PosTypeServiceImpl extends ServiceImpl<BaseMapper<PosType>,PosType>
     {
         return posTypeMapper.deletePosTypeById(id);
     }
+
+    /**
+     * 查询门店分类树结构
+     *
+     * @param posType 门店分类
+     * @return 门店分类集合
+     */
+    @Override
+    public List<PosType> selectPosTypeTreeList(PosType posType)
+    {
+        return posTypeMapper.selectPosTypeTreeList(posType);
+    }
+
+    /**
+     * 查询子分类数量
+     *
+     * @param parentId 父分类ID
+     * @return 结果
+     */
+    @Override
+    public int selectPosTypeCountByParentId(Long parentId)
+    {
+        return posTypeMapper.selectPosTypeCountByParentId(parentId);
+    }
 }

+ 10 - 0
ruoyi-system/src/main/resources/mapper/chanting/PosStoreMapper.xml

@@ -28,6 +28,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="telephone"    column="telephone"    />
         <result property="logo"    column="logo"    />
         <result property="offShelf"    column="off_shelf"    />
+        <result property="isNightMarket"    column="is_night_market"    />
+        <result property="nightMarketId"    column="night_market_id"    />
     </resultMap>
 
     <sql id="selectPosStoreVo">
@@ -45,6 +47,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="type != null "> and type = #{type}</if>
             <if test="sort != null "> and sort = #{sort}</if>
             <if test="offShelf != null "> and off_shelf = #{offShelf}</if>
+            <if test="isNightMarket != null "> and is_night_market = #{isNightMarket}</if>
+            <if test="nightMarketId != null "> and night_market_id = #{nightMarketId}</if>
         </where>
         order by id desc
     </select>
@@ -72,6 +76,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="windingUp != null">winding_up,</if>
             <if test="sort != null">sort,</if>
             <if test="logo != null">logo,</if>
+            <if test="isNightMarket != null">is_night_market,</if>
+            <if test="nightMarketId != null">night_market_id,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="posName != null and posName != ''">#{posName},</if>
@@ -89,6 +95,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="windingUp != null">#{windingUp},</if>
             <if test="sort != null">#{sort},</if>
             <if test="logo != null">#{logo},</if>
+            <if test="isNightMarket != null">#{isNightMarket},</if>
+            <if test="nightMarketId != null">#{nightMarketId},</if>
          </trim>
     </insert>
 
@@ -110,6 +118,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="windingUp != null">winding_up = #{windingUp},</if>
             <if test="sort != null">sort = #{sort},</if>
             <if test="logo != null">logo = #{logo},</if>
+            <if test="isNightMarket != null">is_night_market = #{isNightMarket},</if>
+            <if test="nightMarketId != null">night_market_id = #{nightMarketId},</if>
         </trim>
         where id = #{id}
     </update>

+ 40 - 8
ruoyi-system/src/main/resources/mapper/fenlei/PosTypeMapper.xml

@@ -3,7 +3,7 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.system.mapper.PosTypeMapper">
-    
+
     <resultMap type="PosType" id="PosTypeResult">
         <result property="id"    column="id"    />
         <result property="name"    column="name"    />
@@ -12,29 +12,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="nameTw"    column="name_tw"    />
         <result property="image"    column="image"    />
         <result property="sort"    column="sort"    />
+        <result property="parentId"    column="parent_id"    />
+        <result property="tag"    column="tag"    />
+        <result property="ancestors"    column="ancestors"    />
     </resultMap>
 
     <sql id="selectPosTypeVo">
-        select id, name,name_vi,name_en,name_tw, image,sort from pos_type
+        select id, name,name_vi,name_en,name_tw, image,sort,parent_id,tag,ancestors from pos_type
     </sql>
 
     <select id="selectPosTypeList" parameterType="PosType" resultMap="PosTypeResult">
         <include refid="selectPosTypeVo"/>
-        <where>  
+        <where>
             <if test="name != null  and name != ''"> and name = #{name}</if>
             <if test="nameVi != null  and nameVi != ''"> and name_vi = #{nameVi}</if>
             <if test="nameEn != null  and nameEn != ''"> and name_en = #{nameEn}</if>
             <if test="nameTw != null  and nameTw != ''"> and name_tw = #{nameTw}</if>
             <if test="sort != null  and sort != ''"> and sort = #{sort}</if>
+            <if test="parentId != null"> and parent_id = #{parentId}</if>
+            <if test="tag != null  and tag != ''"> and tag = #{tag}</if>
+            <if test="ancestors != null  and ancestors != ''"> and ancestors = #{ancestors}</if>
         </where>
-        order by sort desc
+        order by parent_id, sort desc
     </select>
-    
+
     <select id="selectPosTypeById" parameterType="Long" resultMap="PosTypeResult">
         <include refid="selectPosTypeVo"/>
         where id = #{id}
     </select>
-        
+
     <insert id="insertPosType" parameterType="PosType" useGeneratedKeys="true" keyProperty="id">
         insert into pos_type
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -44,6 +50,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="nameTw != null and nameTw != ''">name_tw,</if>
             <if test="image != null and image != ''">image,</if>
             <if test="sort != null and sort != ''">sort,</if>
+            <if test="parentId != null">parent_id,</if>
+            <if test="tag != null and tag != ''">tag,</if>
+            <if test="ancestors != null and ancestors != ''">ancestors,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="name != null and name != ''">#{name},</if>
@@ -52,6 +61,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="nameTw != null and nameTw != ''">#{nameTw},</if>
             <if test="image != null and image != ''">#{image},</if>
             <if test="sort != null and sort != ''">#{sort},</if>
+            <if test="parentId != null">#{parentId},</if>
+            <if test="tag != null and tag != ''">#{tag},</if>
+            <if test="ancestors != null and ancestors != ''">#{ancestors},</if>
          </trim>
     </insert>
 
@@ -64,6 +76,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="nameTw != null and nameTw != ''">name_tw = #{nameTw},</if>
             <if test="image != null and image != ''">image = #{image},</if>
             <if test="sort != null and sort != ''">sort = #{sort},</if>
+            <if test="parentId != null">parent_id = #{parentId},</if>
+            <if test="tag != null and tag != ''">tag = #{tag},</if>
+            <if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
         </trim>
         where id = #{id}
     </update>
@@ -73,9 +88,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deletePosTypeByIds" parameterType="String">
-        delete from pos_type where id in 
+        delete from pos_type where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
     </delete>
-</mapper>
+
+        <select id="selectPosTypeTreeList" parameterType="PosType" resultMap="PosTypeResult">
+        <include refid="selectPosTypeVo"/>
+        <where>
+            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
+            <if test="nameVi != null  and nameVi != ''"> and name_vi like concat('%', #{nameVi}, '%')</if>
+            <if test="nameEn != null  and nameEn != ''"> and name_en like concat('%', #{nameEn}, '%')</if>
+            <if test="nameTw != null  and nameTw != ''"> and name_tw like concat('%', #{nameTw}, '%')</if>
+            <if test="parentId != null"> and parent_id = #{parentId}</if>
+            <if test="tag != null  and tag != ''"> and tag = #{tag}</if>
+        </where>
+        order by parent_id, sort desc
+    </select>
+
+    <select id="selectPosTypeCountByParentId" parameterType="Long" resultType="Integer">
+        select count(1) from pos_type where parent_id = #{parentId}
+    </select>
+</mapper>