MobileBenefitPackageMapper.xml 3.6 KB
Newer Older
杨凯's avatar
杨凯 committed
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
<?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.ebaiyihui.family.doctor.server.mapper.MobileBenefitPackageMapper">
    <sql id="base_columns">
        x_id,productId,phone,userId,orderId,timeLimit,used
    </sql>
    <insert id="insert">
        INSERT INTO mobile_benefit_package (
                <if test="productId != '' and productId != null">productId,</if>
                <if test="userId != '' and userId != null">userId,</if>
                <if test="activateOrderId != '' and activateOrderId != null">orderId,</if>
                <if test="timeLimit != 0 and timeLimit != null">timeLimit,</if>
                <if test="orderId != '' and orderId != null">benefitOrderId,</if>
                <if test="benefitsStartTime != '' and benefitsStartTime != null">benefitsStartTime,</if>
                <if test="benefitsEndTime != '' and benefitsEndTime != null">benefitsEndTime,</if>
                <if test="isRenew != '' and isRenew != null">isRenew,</if>
                <if test="phone != '' and phone != null">phone</if>
        )
        VALUES
            (
                <if test="productId != '' and productId != null">#{productId,jdbcType=VARCHAR},</if>
                <if test="userId != '' and userId != null">#{userId,jdbcType=VARCHAR},</if>
                <if test="activateOrderId != '' and activateOrderId != null">#{activateOrderId,jdbcType=VARCHAR},</if>
                <if test="timeLimit != 0 and timeLimit != null">#{timeLimit,jdbcType=TINYINT},</if>
                <if test="orderId != '' and orderId != null">#{orderId,jdbcType=VARCHAR},</if>
                <if test="benefitsStartTime != '' and benefitsStartTime != null">#{benefitsStartTime},</if>
                <if test="benefitsEndTime != '' and benefitsEndTime != null">#{benefitsEndTime},</if>
                <if test="isRenew != '' and isRenew != null">#{isRenew,jdbcType=VARCHAR},</if>
                <if test="phone != '' and phone != null">#{phone,jdbcType=VARCHAR}</if>
            )
    </insert>
    <update id="updateUsed">
        update mobile_benefit_package set
        used = #{used,jdbcType=TINYINT}
        where phone = #{phone,jdbcType=VARCHAR} and orderId = #{orderId}
    </update>
    <update id="update">
        update mobile_benefit_package set
            userId = #{userId,jdbcType=VARCHAR}
        where phone = #{phone,jdbcType=VARCHAR} and orderId = #{orderId}
    </update>

    <select id="queryByPhone" resultType="com.ebaiyihui.family.doctor.server.entity.MobileBenefitPackageEntity">
        SELECT
        <include refid="base_columns"/>
        FROM
            mobile_benefit_package
        WHERE
            phone = #{mobile} and orderId = #{activateOrderId}
        ORDER BY
            x_create_time DESC
            LIMIT 0,1
    </select>

<!--    <select id="queryByOrderId" resultType="com.ebaiyihui.family.doctor.server.entity.MobileBenefitPackageEntity">-->
<!--        SELECT-->
<!--            <include refid="base_columns"/>-->
<!--        FROM-->
<!--            mobile_benefit_package-->
<!--        WHERE-->
<!--            orderId = #{orderId}-->
<!--        ORDER BY-->
<!--            x_create_time DESC-->
<!--            LIMIT 0,1-->
<!--    </select>-->
    <select id="getPatientIdsByPhoneAndOrderId" resultType="java.lang.String">
        SELECT DISTINCT
            ia.patient_id
        FROM
            mobile_benefit_package mbp
                LEFT JOIN inquiry_admission ia ON mbp.orderId = ia.package_id
        WHERE
            mbp.phone = #{phone}
    </select>
</mapper>