<?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 ALL -->
<mapper namespace="com.xhpc.card.mapper.XhpcCustomersPersonnelMapper">
    <resultMap id="BaseResultMap" type="com.xhpc.card.pojo.XhpcCustomersPersonnel">
        <id column="customers_personnel_id" jdbcType="BIGINT" property="customersPersonnelId"/>
        <result column="customers_id" jdbcType="BIGINT" property="customersId"/>
        <result column="name" jdbcType="VARCHAR" property="name"/>
        <result column="account" jdbcType="VARCHAR" property="account"/>
        <result column="recharge_money" jdbcType="DECIMAL" property="rechargeMoney"/>
        <result column="consume_money" jdbcType="DECIMAL" property="consumeMoney"/>
        <result column="red_packet" jdbcType="DECIMAL" property="redPacket"/>
        <result column="surplus_money" jdbcType="DECIMAL" property="surplusMoney"/>
        <result column="phone" jdbcType="VARCHAR" property="phone"/>
        <result column="type" jdbcType="INTEGER" property="type"/>
        <result column="status" jdbcType="INTEGER" property="status"/>
        <result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
        <result column="create_by" jdbcType="VARCHAR" property="createBy"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
        <result column="is_refund_application" jdbcType="INTEGER" property="isRefundApplication"/>
        <result column="soc" jdbcType="INTEGER" property="soc"/>
        <result column="avatar" jdbcType="VARCHAR" property="avatar"/>
        <result column="weixin_open_id" jdbcType="VARCHAR" property="weixinOpenId"/>
        <result column="alipay_open_id" jdbcType="VARCHAR" property="alipayOpenId"/>
        <result column="weixin_login" jdbcType="INTEGER" property="weixinLogin"/>
        <result column="alipay_login" jdbcType="INTEGER" property="alipayLogin"/>
        <result column="is_refund" jdbcType="INTEGER" property="isRefund"/>
        <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
        <result column="soc_protect" jdbcType="INTEGER" property="socProtect"/>
    </resultMap>
    <sql id="Base_Column_List">
        customers_personnel_id
        , customers_id, `name`, account, recharge_money, consume_money,
    red_packet, surplus_money, phone, `type`, `status`, del_flag, create_by, create_time, 
    update_by, update_time, remark, is_refund_application, soc, avatar, weixin_open_id, 
    alipay_open_id, weixin_login, alipay_login, is_refund, tenant_id, soc_protect
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from xhpc_customers_personnel
        where customers_personnel_id = #{customersPersonnelId,jdbcType=BIGINT}
    </select>
    <select id="selectAll" resultType="com.xhpc.card.pojo.XhpcCustomersPersonnel">
        select
        <include refid="Base_Column_List"/>
        from xhpc_customers_personnel
    </select>
    <select id="selectByCondition" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from xhpc_customers_personnel
        <where>
            <if test="queryCondition.userAccount!=null and queryCondition.userAccount!='' ">
                and account like concat('%',#{queryCondition.userAccount},'%')
            </if>
            <if test="userIdList!=null and userIdList.size()!=0">
                and customers_personnel_id not in
                <foreach collection="userIdList" item="userId" open="(" close=")" separator=",">
                    #{userId}
                </foreach>
            </if>
            <if test="queryCondition.name!=null and queryCondition.name!='' ">
                and name like concat('%',#{queryCondition.name},'%')
            </if>
            <if test="queryCondition.phone!=null and queryCondition.phone!='' ">
                and phone like concat('%',#{queryCondition.phone},'%')
            </if>
        </where>
        limit #{queryCondition.currentPage},#{queryCondition.items}
    </select>
    <select id="selectCount" resultType="java.lang.Long">
        select count(customers_personnel_id)
        from xhpc_customers_personnel
        <where>
            <if test="queryCondition.userAccount!=null and queryCondition.userAccount!='' ">
                and account like concat('%',#{queryCondition.userAccount},'%')
            </if>
            <if test="userIdList!=null and userIdList.size()!=0">
                and customers_personnel_id not in
                <foreach collection="userIdList" item="userId" open="(" close=")" separator=",">
                    #{userId}
                </foreach>
            </if>
        </where>
    </select>
    <select id="selectByOperatorId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from xhpc_customers_personnel
        where create_type = 2 and create_id = #{operatorId}
        <if test="userIdList!=null and userIdList.size()!=0">
            and customers_personnel_id not in
            <foreach collection="userIdList" item="userId" open="(" close=")" separator=",">
                #{userId}
            </foreach>
        </if>
        limit #{currentPage},#{items}
    </select>
    <select id="selectCountByOperatorId" resultType="java.lang.Long">
        select count(customers_personnel_id)
        from xhpc_customers_personnel
        where create_type = 2
        and create_id = #{operatorId}
        <if test="userIdList!=null and userIdList.size()!=0">
            and customers_personnel_id not in
            <foreach collection="userIdList" item="userId" open="(" close=")" separator=",">
                #{userId}
            </foreach>
        </if>
    </select>
    <select id="selectByAccount" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from xhpc_customers_personnel
        where
        account = #{userAccount}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete
        from xhpc_customers_personnel
        where customers_personnel_id = #{customersPersonnelId,jdbcType=BIGINT}
    </delete>
    <insert id="insert" keyColumn="customers_personnel_id" keyProperty="customersPersonnelId"
            parameterType="com.xhpc.card.pojo.XhpcCustomersPersonnel" useGeneratedKeys="true">
        insert into xhpc_customers_personnel (customers_id, `name`, account,
                                              recharge_money, consume_money, red_packet,
                                              surplus_money, phone, `type`,
                                              `status`, del_flag, create_by,
                                              create_time, update_by, update_time,
                                              remark, is_refund_application, soc,
                                              avatar, weixin_open_id, alipay_open_id,
                                              weixin_login, alipay_login, is_refund,
                                              tenant_id, soc_protect)
        values (#{customersId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{account,jdbcType=VARCHAR},
                #{rechargeMoney,jdbcType=DECIMAL}, #{consumeMoney,jdbcType=DECIMAL}, #{redPacket,jdbcType=DECIMAL},
                #{surplusMoney,jdbcType=DECIMAL}, #{phone,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER},
                #{status,jdbcType=INTEGER}, #{delFlag,jdbcType=INTEGER}, #{createBy,jdbcType=VARCHAR},
                #{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
                #{remark,jdbcType=VARCHAR}, #{isRefundApplication,jdbcType=INTEGER}, #{soc,jdbcType=INTEGER},
                #{avatar,jdbcType=VARCHAR}, #{weixinOpenId,jdbcType=VARCHAR}, #{alipayOpenId,jdbcType=VARCHAR},
                #{weixinLogin,jdbcType=INTEGER}, #{alipayLogin,jdbcType=INTEGER}, #{isRefund,jdbcType=INTEGER},
                #{tenantId,jdbcType=VARCHAR}, #{socProtect,jdbcType=INTEGER})
    </insert>
    <insert id="insertSelective" keyColumn="customers_personnel_id" keyProperty="customersPersonnelId"
            parameterType="com.xhpc.card.pojo.XhpcCustomersPersonnel" useGeneratedKeys="true">
        insert into xhpc_customers_personnel
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="customersId != null">
                customers_id,
            </if>
            <if test="name != null">
                `name`,
            </if>
            <if test="account != null">
                account,
            </if>
            <if test="rechargeMoney != null">
                recharge_money,
            </if>
            <if test="consumeMoney != null">
                consume_money,
            </if>
            <if test="redPacket != null">
                red_packet,
            </if>
            <if test="surplusMoney != null">
                surplus_money,
            </if>
            <if test="phone != null">
                phone,
            </if>
            <if test="type != null">
                `type`,
            </if>
            <if test="status != null">
                `status`,
            </if>
            <if test="delFlag != null">
                del_flag,
            </if>
            <if test="createBy != null">
                create_by,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="updateBy != null">
                update_by,
            </if>
            <if test="updateTime != null">
                update_time,
            </if>
            <if test="remark != null">
                remark,
            </if>
            <if test="isRefundApplication != null">
                is_refund_application,
            </if>
            <if test="soc != null">
                soc,
            </if>
            <if test="avatar != null">
                avatar,
            </if>
            <if test="weixinOpenId != null">
                weixin_open_id,
            </if>
            <if test="alipayOpenId != null">
                alipay_open_id,
            </if>
            <if test="weixinLogin != null">
                weixin_login,
            </if>
            <if test="alipayLogin != null">
                alipay_login,
            </if>
            <if test="isRefund != null">
                is_refund,
            </if>
            <if test="tenantId != null">
                tenant_id,
            </if>
            <if test="socProtect != null">
                soc_protect,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="customersId != null">
                #{customersId,jdbcType=BIGINT},
            </if>
            <if test="name != null">
                #{name,jdbcType=VARCHAR},
            </if>
            <if test="account != null">
                #{account,jdbcType=VARCHAR},
            </if>
            <if test="rechargeMoney != null">
                #{rechargeMoney,jdbcType=DECIMAL},
            </if>
            <if test="consumeMoney != null">
                #{consumeMoney,jdbcType=DECIMAL},
            </if>
            <if test="redPacket != null">
                #{redPacket,jdbcType=DECIMAL},
            </if>
            <if test="surplusMoney != null">
                #{surplusMoney,jdbcType=DECIMAL},
            </if>
            <if test="phone != null">
                #{phone,jdbcType=VARCHAR},
            </if>
            <if test="type != null">
                #{type,jdbcType=INTEGER},
            </if>
            <if test="status != null">
                #{status,jdbcType=INTEGER},
            </if>
            <if test="delFlag != null">
                #{delFlag,jdbcType=INTEGER},
            </if>
            <if test="createBy != null">
                #{createBy,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateBy != null">
                #{updateBy,jdbcType=VARCHAR},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="remark != null">
                #{remark,jdbcType=VARCHAR},
            </if>
            <if test="isRefundApplication != null">
                #{isRefundApplication,jdbcType=INTEGER},
            </if>
            <if test="soc != null">
                #{soc,jdbcType=INTEGER},
            </if>
            <if test="avatar != null">
                #{avatar,jdbcType=VARCHAR},
            </if>
            <if test="weixinOpenId != null">
                #{weixinOpenId,jdbcType=VARCHAR},
            </if>
            <if test="alipayOpenId != null">
                #{alipayOpenId,jdbcType=VARCHAR},
            </if>
            <if test="weixinLogin != null">
                #{weixinLogin,jdbcType=INTEGER},
            </if>
            <if test="alipayLogin != null">
                #{alipayLogin,jdbcType=INTEGER},
            </if>
            <if test="isRefund != null">
                #{isRefund,jdbcType=INTEGER},
            </if>
            <if test="tenantId != null">
                #{tenantId,jdbcType=VARCHAR},
            </if>
            <if test="socProtect != null">
                #{socProtect,jdbcType=INTEGER},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.xhpc.card.pojo.XhpcCustomersPersonnel">
        update xhpc_customers_personnel
        <set>
            <if test="customersId != null">
                customers_id = #{customersId,jdbcType=BIGINT},
            </if>
            <if test="name != null">
                `name` = #{name,jdbcType=VARCHAR},
            </if>
            <if test="account != null">
                account = #{account,jdbcType=VARCHAR},
            </if>
            <if test="rechargeMoney != null">
                recharge_money = #{rechargeMoney,jdbcType=DECIMAL},
            </if>
            <if test="consumeMoney != null">
                consume_money = #{consumeMoney,jdbcType=DECIMAL},
            </if>
            <if test="redPacket != null">
                red_packet = #{redPacket,jdbcType=DECIMAL},
            </if>
            <if test="surplusMoney != null">
                surplus_money = #{surplusMoney,jdbcType=DECIMAL},
            </if>
            <if test="phone != null">
                phone = #{phone,jdbcType=VARCHAR},
            </if>
            <if test="type != null">
                `type` = #{type,jdbcType=INTEGER},
            </if>
            <if test="status != null">
                `status` = #{status,jdbcType=INTEGER},
            </if>
            <if test="delFlag != null">
                del_flag = #{delFlag,jdbcType=INTEGER},
            </if>
            <if test="createBy != null">
                create_by = #{createBy,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateBy != null">
                update_by = #{updateBy,jdbcType=VARCHAR},
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="remark != null">
                remark = #{remark,jdbcType=VARCHAR},
            </if>
            <if test="isRefundApplication != null">
                is_refund_application = #{isRefundApplication,jdbcType=INTEGER},
            </if>
            <if test="soc != null">
                soc = #{soc,jdbcType=INTEGER},
            </if>
            <if test="avatar != null">
                avatar = #{avatar,jdbcType=VARCHAR},
            </if>
            <if test="weixinOpenId != null">
                weixin_open_id = #{weixinOpenId,jdbcType=VARCHAR},
            </if>
            <if test="alipayOpenId != null">
                alipay_open_id = #{alipayOpenId,jdbcType=VARCHAR},
            </if>
            <if test="weixinLogin != null">
                weixin_login = #{weixinLogin,jdbcType=INTEGER},
            </if>
            <if test="alipayLogin != null">
                alipay_login = #{alipayLogin,jdbcType=INTEGER},
            </if>
            <if test="isRefund != null">
                is_refund = #{isRefund,jdbcType=INTEGER},
            </if>
            <if test="tenantId != null">
                tenant_id = #{tenantId,jdbcType=VARCHAR},
            </if>
            <if test="socProtect != null">
                soc_protect = #{socProtect,jdbcType=INTEGER},
            </if>
        </set>
        where customers_personnel_id = #{customersPersonnelId,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.xhpc.card.pojo.XhpcCustomersPersonnel">
        update xhpc_customers_personnel
        set customers_id          = #{customersId,jdbcType=BIGINT},
            `name`                = #{name,jdbcType=VARCHAR},
            account               = #{account,jdbcType=VARCHAR},
            recharge_money        = #{rechargeMoney,jdbcType=DECIMAL},
            consume_money         = #{consumeMoney,jdbcType=DECIMAL},
            red_packet            = #{redPacket,jdbcType=DECIMAL},
            surplus_money         = #{surplusMoney,jdbcType=DECIMAL},
            phone                 = #{phone,jdbcType=VARCHAR},
            `type`                = #{type,jdbcType=INTEGER},
            `status`              = #{status,jdbcType=INTEGER},
            del_flag              = #{delFlag,jdbcType=INTEGER},
            create_by             = #{createBy,jdbcType=VARCHAR},
            create_time           = #{createTime,jdbcType=TIMESTAMP},
            update_by             = #{updateBy,jdbcType=VARCHAR},
            update_time           = #{updateTime,jdbcType=TIMESTAMP},
            remark                = #{remark,jdbcType=VARCHAR},
            is_refund_application = #{isRefundApplication,jdbcType=INTEGER},
            soc                   = #{soc,jdbcType=INTEGER},
            avatar                = #{avatar,jdbcType=VARCHAR},
            weixin_open_id        = #{weixinOpenId,jdbcType=VARCHAR},
            alipay_open_id        = #{alipayOpenId,jdbcType=VARCHAR},
            weixin_login          = #{weixinLogin,jdbcType=INTEGER},
            alipay_login          = #{alipayLogin,jdbcType=INTEGER},
            is_refund             = #{isRefund,jdbcType=INTEGER},
            tenant_id             = #{tenantId,jdbcType=VARCHAR},
            soc_protect           = #{socProtect,jdbcType=INTEGER}
        where customers_personnel_id = #{customersPersonnelId,jdbcType=BIGINT}
    </update>
</mapper>