<?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">
<!--suppress SqlDialectInspection -->
<mapper namespace="com.xhpc.card.mapper.XhpcRechargeOrderMapper">
    <resultMap id="BaseResultMap" type="com.xhpc.card.pojo.XhpcRechargeOrder">
        <id column="recharge_order_id" jdbcType="BIGINT" property="rechargeOrderId"/>
        <result column="recharge_order_number" jdbcType="VARCHAR" property="rechargeOrderNumber"/>
        <result column="user_id" jdbcType="BIGINT" property="userId"/>
        <result column="prepay_id" jdbcType="VARCHAR" property="prepayId"/>
        <result column="alipay_number" jdbcType="VARCHAR" property="alipayNumber"/>
        <result column="amount" jdbcType="DECIMAL" property="amount"/>
        <result column="type" jdbcType="INTEGER" property="type"/>
        <result column="status" jdbcType="INTEGER" property="status"/>
        <result column="source" jdbcType="INTEGER" property="source"/>
        <result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="create_by" jdbcType="VARCHAR" property="createBy"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
        <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
    </resultMap>
    <sql id="Base_Column_List">
        recharge_order_id
        , recharge_order_number, user_id, prepay_id, alipay_number, amount,
    `type`, `status`, `source`, del_flag, create_time, create_by, update_time, update_by, 
    remark, tenant_id
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from xhpc_recharge_order
        where recharge_order_id = #{rechargeOrderId,jdbcType=BIGINT}
    </select>
    <select id="selectByUserId" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM
        xhpc_recharge_order
        WHERE
        user_id = #{appUserId}
        limit #{currentPage},#{items}
    </select>
    <select id="selectCountByUserId" resultType="java.lang.Long">
        SELECT count(recharge_order_id)
        FROM xhpc_recharge_order
        WHERE user_id = #{appUserId}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete
        from xhpc_recharge_order
        where recharge_order_id = #{rechargeOrderId,jdbcType=BIGINT}
    </delete>
    <insert id="insert" keyColumn="recharge_order_id" keyProperty="rechargeOrderId"
            parameterType="com.xhpc.card.pojo.XhpcRechargeOrder" useGeneratedKeys="true">
        insert into xhpc_recharge_order (recharge_order_number, user_id, prepay_id,
                                         alipay_number, amount, `type`,
                                         `status`, `source`, del_flag,
                                         create_time, create_by, update_time,
                                         update_by, remark, tenant_id)
        values (#{rechargeOrderNumber,jdbcType=VARCHAR}, #{userId,jdbcType=BIGINT}, #{prepayId,jdbcType=VARCHAR},
                #{alipayNumber,jdbcType=VARCHAR}, #{amount,jdbcType=DECIMAL}, #{type,jdbcType=INTEGER},
                #{status,jdbcType=INTEGER}, #{source,jdbcType=INTEGER}, #{delFlag,jdbcType=INTEGER},
                #{createTime,jdbcType=TIMESTAMP}, #{createBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
                #{updateBy,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{tenantId,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" keyColumn="recharge_order_id" keyProperty="rechargeOrderId"
            parameterType="com.xhpc.card.pojo.XhpcRechargeOrder" useGeneratedKeys="true">
        insert into xhpc_recharge_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="rechargeOrderNumber != null">
                recharge_order_number,
            </if>
            <if test="userId != null">
                user_id,
            </if>
            <if test="prepayId != null">
                prepay_id,
            </if>
            <if test="alipayNumber != null">
                alipay_number,
            </if>
            <if test="amount != null">
                amount,
            </if>
            <if test="type != null">
                `type`,
            </if>
            <if test="status != null">
                `status`,
            </if>
            <if test="source != null">
                `source`,
            </if>
            <if test="delFlag != null">
                del_flag,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="createBy != null">
                create_by,
            </if>
            <if test="updateTime != null">
                update_time,
            </if>
            <if test="updateBy != null">
                update_by,
            </if>
            <if test="remark != null">
                remark,
            </if>
            <if test="tenantId != null">
                tenant_id,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="rechargeOrderNumber != null">
                #{rechargeOrderNumber,jdbcType=VARCHAR},
            </if>
            <if test="userId != null">
                #{userId,jdbcType=BIGINT},
            </if>
            <if test="prepayId != null">
                #{prepayId,jdbcType=VARCHAR},
            </if>
            <if test="alipayNumber != null">
                #{alipayNumber,jdbcType=VARCHAR},
            </if>
            <if test="amount != null">
                #{amount,jdbcType=DECIMAL},
            </if>
            <if test="type != null">
                #{type,jdbcType=INTEGER},
            </if>
            <if test="status != null">
                #{status,jdbcType=INTEGER},
            </if>
            <if test="source != null">
                #{source,jdbcType=INTEGER},
            </if>
            <if test="delFlag != null">
                #{delFlag,jdbcType=INTEGER},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="createBy != null">
                #{createBy,jdbcType=VARCHAR},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateBy != null">
                #{updateBy,jdbcType=VARCHAR},
            </if>
            <if test="remark != null">
                #{remark,jdbcType=VARCHAR},
            </if>
            <if test="tenantId != null">
                #{tenantId,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.xhpc.card.pojo.XhpcRechargeOrder">
        update xhpc_recharge_order
        <set>
            <if test="rechargeOrderNumber != null">
                recharge_order_number = #{rechargeOrderNumber,jdbcType=VARCHAR},
            </if>
            <if test="userId != null">
                user_id = #{userId,jdbcType=BIGINT},
            </if>
            <if test="prepayId != null">
                prepay_id = #{prepayId,jdbcType=VARCHAR},
            </if>
            <if test="alipayNumber != null">
                alipay_number = #{alipayNumber,jdbcType=VARCHAR},
            </if>
            <if test="amount != null">
                amount = #{amount,jdbcType=DECIMAL},
            </if>
            <if test="type != null">
                `type` = #{type,jdbcType=INTEGER},
            </if>
            <if test="status != null">
                `status` = #{status,jdbcType=INTEGER},
            </if>
            <if test="source != null">
                `source` = #{source,jdbcType=INTEGER},
            </if>
            <if test="delFlag != null">
                del_flag = #{delFlag,jdbcType=INTEGER},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="createBy != null">
                create_by = #{createBy,jdbcType=VARCHAR},
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateBy != null">
                update_by = #{updateBy,jdbcType=VARCHAR},
            </if>
            <if test="remark != null">
                remark = #{remark,jdbcType=VARCHAR},
            </if>
            <if test="tenantId != null">
                tenant_id = #{tenantId,jdbcType=VARCHAR},
            </if>
        </set>
        where recharge_order_id = #{rechargeOrderId,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.xhpc.card.pojo.XhpcRechargeOrder">
        update xhpc_recharge_order
        set recharge_order_number = #{rechargeOrderNumber,jdbcType=VARCHAR},
            user_id               = #{userId,jdbcType=BIGINT},
            prepay_id             = #{prepayId,jdbcType=VARCHAR},
            alipay_number         = #{alipayNumber,jdbcType=VARCHAR},
            amount                = #{amount,jdbcType=DECIMAL},
            `type`                = #{type,jdbcType=INTEGER},
            `status`              = #{status,jdbcType=INTEGER},
            `source`              = #{source,jdbcType=INTEGER},
            del_flag              = #{delFlag,jdbcType=INTEGER},
            create_time           = #{createTime,jdbcType=TIMESTAMP},
            create_by             = #{createBy,jdbcType=VARCHAR},
            update_time           = #{updateTime,jdbcType=TIMESTAMP},
            update_by             = #{updateBy,jdbcType=VARCHAR},
            remark                = #{remark,jdbcType=VARCHAR},
            tenant_id             = #{tenantId,jdbcType=VARCHAR}
        where recharge_order_id = #{rechargeOrderId,jdbcType=BIGINT}
    </update>
</mapper>