mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?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.panzhihua.service_community.dao.ConvenientServiceCategoryDAO">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ConvenientServiceCategoryDO">
                <id column="id" property="id" />
                <id column="name" property="name" />
                <id column="icon" property="icon" />
                <id column="remark" property="remark" />
                <id column="weight" property="weight" />
                <id column="is_del" property="isDel" />
                <id column="created_at" property="createdAt" />
                <id column="created_by" property="createdBy" />
                <id column="updated_at" property="updatedAt" />
                <id column="updated_by" property="updatedBy" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
    id,`name`,icon,remark,weight,is_del,created_at,created_by,updated_at,updated_by
    </sql>
    <insert id="createMerchantServiceRelation">
        INSERT INTO com_convenient_service_scope (id,merchant_id, service_category_id, service_name, created_by, created_at)
        VALUES (#{id},#{merchantId}, #{serviceId}, #{name}, #{createdBy}, NOW())
    </insert>
    <delete id="deleteMerchantServiceRelation">
        DELETE FROM com_convenient_service_scope WHERE merchant_id = #{merchantId}
    </delete>
    <select id="pageServiceCategory" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientServiceCategoryVO">
        SELECT <include refid="Base_Column_List"/>
        FROM com_convenient_service_categories
        WHERE is_del = 0
            <if test="pageConvenientServiceCategoryDTO.name != null and pageConvenientServiceCategoryDTO.name.trim() != &quot;&quot;">
                AND `name` LIKE concat('%', #{pageConvenientServiceCategoryDTO.name}, '%' )
            </if>
        <if test="pageConvenientServiceCategoryDTO.areaCode != null and pageConvenientServiceCategoryDTO.areaCode.trim() != &quot;&quot;">
            AND area_code = #{pageConvenientServiceCategoryDTO.areaCode}
        </if>
        ORDER BY weight DESC
    </select>
    <select id="selectServiceScopeByMerchantId" resultType="java.lang.String">
        SELECT GROUP_CONCAT(`service_name`) serviceScope FROM com_convenient_service_scope WHERE merchant_id = #{merchantId}
    </select>
    <select id="selectServiceIdsForMerchant" resultType="java.lang.String">
        SELECT service_category_id FROM com_convenient_service_scope WHERE merchant_id = #{merchantId}
    </select>
    <select id="checkCategoryIsUsing" resultType="java.lang.Integer">
        SELECT COUNT(1) FROM com_convenient_service_scope WHERE service_category_id = #{categoryId}
    </select>
    <select id="selectSuitableServiceCategories" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientServiceCategoryVO">
        SELECT ccsc.id, ccsc.name, ccsc.icon, ccsc.remark, ccsc.weight
        FROM com_convenient_service_categories ccsc
        INNER JOIN com_convenient_service_scope ccss ON ccsc.id = ccss.service_category_id
        INNER JOIN com_convenient_merchants ccm ON ccss.merchant_id = ccm.id
        WHERE ccsc.is_del = 0 AND ccm.is_del = 0 AND( ccm.community_id = ${communityId} or ccm.community_id =0) and ccsc.area_code = #{areaCode} AND ccm.business_status = 1 GROUP BY ccsc.id ORDER BY ccsc.weight desc
    </select>
</mapper>