puzhibing
2024-01-30 03f1f3372a10a08f96f3308bfa099e86a55046d0
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?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.ruoyi.shop.mapper.shop.ShopCertificateMapper">
 
    <resultMap type="ShopCertificate" id="ShopCertificateResult">
        <result property="cerId"    column="cer_id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="cerStatus"    column="cer_status"    />
        <result property="shopId"    column="shop_id"    />
        <result property="cerName"    column="cer_name"    />
        <result property="cerNumber"    column="cer_number"    />
        <result property="cerPicture"    column="cer_picture"    />
    </resultMap>
 
    <sql id="selectShopCertificateVo">
        select cer_id, del_flag, cer_status, shop_id, cer_name, cer_number, cer_picture from t_shop_certificate
    </sql>
 
    <select id="selectShopCertificateList" parameterType="ShopCertificate" resultMap="ShopCertificateResult">
        <include refid="selectShopCertificateVo"/>
        <where>
            <if test="cerStatus != null "> and cer_status = #{cerStatus}</if>
            <if test="shopId != null "> and shop_id = #{shopId}</if>
            <if test="cerName != null  and cerName != ''"> and cer_name like concat('%', #{cerName}, '%')</if>
            <if test="cerNumber != null "> and cer_number = #{cerNumber}</if>
            <if test="cerPicture != null  and cerPicture != ''"> and cer_picture = #{cerPicture}</if>
        </where>
    </select>
 
    <select id="selectShopCertificateByCerId" parameterType="Long" resultMap="ShopCertificateResult">
        <include refid="selectShopCertificateVo"/>
        where cer_id = #{cerId}
    </select>
 
    <insert id="insertShopCertificate" parameterType="ShopCertificate" useGeneratedKeys="true" keyProperty="cerId">
        insert into t_shop_certificate
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="delFlag != null">del_flag,</if>
            <if test="cerStatus != null">cer_status,</if>
            <if test="shopId != null">shop_id,</if>
            <if test="cerName != null">cer_name,</if>
            <if test="cerNumber != null">cer_number,</if>
            <if test="cerPicture != null">cer_picture,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="delFlag != null">#{delFlag},</if>
            <if test="cerStatus != null">#{cerStatus},</if>
            <if test="shopId != null">#{shopId},</if>
            <if test="cerName != null">#{cerName},</if>
            <if test="cerNumber != null">#{cerNumber},</if>
            <if test="cerPicture != null">#{cerPicture},</if>
        </trim>
    </insert>
 
    <update id="updateShopCertificate" parameterType="ShopCertificate">
        update t_shop_certificate
        <trim prefix="SET" suffixOverrides=",">
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="cerStatus != null">cer_status = #{cerStatus},</if>
            <if test="shopId != null">shop_id = #{shopId},</if>
            <if test="cerName != null">cer_name = #{cerName},</if>
            <if test="cerNumber != null">cer_number = #{cerNumber},</if>
            <if test="cerPicture != null">cer_picture = #{cerPicture},</if>
        </trim>
        where cer_id = #{cerId}
    </update>
 
    <delete id="deleteShopCertificateByCerId" parameterType="Long">
        delete from t_shop_certificate where cer_id = #{cerId}
    </delete>
 
    <delete id="deleteShopCertificateByCerIds" parameterType="String">
        delete from t_shop_certificate where cer_id in
        <foreach item="cerId" collection="array" open="(" separator="," close=")">
            #{cerId}
        </foreach>
    </delete>
 
    <select id="listShopCertificateVo" resultType="com.ruoyi.shop.domain.vo.MerShopCertificateListVo">
        SELECT
        cer_id cerId,
        cer_name cerName,
        cer_number cerNumber,
        cer_picture cerPicture,
        cer_status cerStatus,
        refuse_reason refuseReason
        FROM t_shop_certificate
        WHERE del_flag = 0 AND shop_id = #{param.shopId}
        <if test="param.status != null and param.status == 1">
            AND cer_status = 1
        </if>
        <if test="param.status != null and param.status == 2">
            AND (cer_status = 0 OR  cer_status = 2)
        </if>
        ORDER BY create_time DESC
    </select>
    <select id="pageMgtShopCertificate" resultType="com.ruoyi.shop.domain.vo.MgtShopCertificatePageVo">
        SELECT
        tsc.cer_id cerId,
        tsc.cer_name cerName,
        tsc.cer_number cerNumber,
        tsc.cer_picture cerPicture,
        tsc.cer_status cerStatus,
        tsc.create_time createTime,
        ts.shop_name shopName,
        ts.shopowner_name shopownerName,
        ts.shopowner_phone shopownerPhone
        FROM t_shop_certificate tsc
        INNER JOIN t_shop ts ON tsc.shop_id = ts.shop_id
        WHERE tsc.del_flag = 0 AND ts.del_flag = 0
        <if test="param.cerStatus != null">
            AND tsc.cer_status = #{param.cerStatus}
        </if>
        <if test="param.keyword!=null and param.keyword!=''">
            AND (ts.shop_name LIKE CONCAT('%',#{param.keyword},'%') OR ts.shopowner_name LIKE CONCAT('%',#{param.keyword},'%')
            OR ts.shopowner_phone LIKE CONCAT('%',#{param.keyword},'%'))
        </if>
        <if test="param.createStartTime!=null and param.createStartTime!=''">
            AND Date(tsc.create_time) &gt;= #{param.createStartTime}
        </if>
        <if test="param.createEndTime!=null and param.createEndTime!=''">
            AND Date(tsc.create_time) &lt;= #{param.createEndTime}
        </if>
        ORDER BY tsc.create_time DESC
    </select>
</mapper>