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
59
<?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.McsVerifiedRecordDAO">
 
    <resultMap type="com.panzhihua.service_community.entity.McsVerifiedRecord" id="McsVerifiedRecordMap">
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="couponId" column="coupon_id" jdbcType="INTEGER"/>
        <result property="merchantId" column="merchant_id" jdbcType="INTEGER"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="award" column="award" jdbcType="VARCHAR"/>
        <result property="gameId" column="game_id" jdbcType="INTEGER"/>
        <result property="nickName" column="nick_name" jdbcType="VARCHAR"/>
        <result property="verifiedAt" column="verified_at" jdbcType="TIMESTAMP"/>
    </resultMap>
 
    <!-- 批量插入 -->
    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into smart_life.mcs_verified_record(coupon_id, name, award, verified_at)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.couponId}, #{entity.name}, #{entity.award}, #{entity.verifiedAt})
        </foreach>
    </insert>
    <!-- 批量插入或按主键更新 -->
    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into smart_life.mcs_verified_record(coupon_id, name, award, verified_at)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.couponId}, #{entity.name}, #{entity.award}, #{entity.verifiedAt})
        </foreach>
        on duplicate key update
        coupon_id = values(coupon_id) , name = values(name) , award = values(award) , verified_at = values(verified_at)
    </insert>
    <select id="pageMcsVerifyRecord"
            resultType="com.panzhihua.common.model.vos.community.microCommercialStreet.McsVerifyRecordVO">
        SELECT t1.*, t3.`type`
        FROM mcs_verified_record t1
        LEFT JOIN mcs_merchant t2 ON t1.merchant_id = t2.id
        LEFT JOIN mcs_game t3 ON t1.game_id = t3.id
        WHERE t2.user_id = #{pageVerifyRecordDTO.userId}
        <if test="pageVerifyRecordDTO.type != null">
            AND t3.`type` = #{pageVerifyRecordDTO.type}
        </if>
        <if test="pageVerifyRecordDTO.verifiedBegin != null">
            AND t1.verified_at &gt;= #{pageVerifyRecordDTO.verifiedBegin}
        </if>
        <if test="pageVerifyRecordDTO.verifiedEnd != null">
            AND t1.verified_at &lt;= #{pageVerifyRecordDTO.verifiedEnd}
        </if>
        <if test="pageVerifyRecordDTO.keyword != null and pageVerifyRecordDTO.keyword != &quot;&quot;">
            AND (t1.nick_name LIKE CONCAT('%', #{pageVerifyRecordDTO.keyword}, '%')
            OR t1.coupon_id LIKE CONCAT('%', #{pageVerifyRecordDTO.keyword}, '%')
            OR t1.`name` LIKE CONCAT('%', #{pageVerifyRecordDTO.keyword}, '%')
            )
        </if>
        ORDER BY t1.verified_at DESC
    </select>
 
</mapper>