<?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="org.springblade.customer.mapper.DimVipidMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="org.springblade.customer.entity.DimVipid">
        <result column="ID" property="id" />
        <result column="VIPID" property="vipid" />
        <result column="VNAME" property="vname" />
        <result column="CTYPE" property="ctype" />
        <result column="COMPANY" property="company" />
        <result column="PTYPE" property="ptype" />
        <result column="QYTYPE" property="qytype" />
        <result column="BUSS" property="buss" />
        <result column="SALEPRICE" property="saleprice" />
        <result column="SALEPRICE_OPER" property="salepriceOper" />
        <result column="SALEPRICE_OPTIME" property="salepriceOptime" />
        <result column="COSTPRICE" property="costprice" />
        <result column="COSTPRICE_OPER" property="costpriceOper" />
        <result column="COSTPRICE_OPTIME" property="costpriceOptime" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        ID, VIPID, VNAME, CTYPE, COMPANY, PTYPE, QYTYPE, BUSS, SALEPRICE, SALEPRICE_OPER, SALEPRICE_OPTIME, COSTPRICE, COSTPRICE_OPER, COSTPRICE_OPTIME
    </sql>

    <insert id="sysOperationLog">
        insert into  LOG_VIPID_PRICE (LOGID,DIM_VIPID_ID,OPER_TYPE,PRICE_O,PRICE_N,PRICE_OPER,PRICE_OPTIME)
        values(SEQ_LOG_VIPID_PRICE.nextval,#{id},#{openType},#{oldPrice},#{newPrice},#{realName},sysdate)
    </insert>

    <select id="getPageByQuery" resultType="org.springblade.customer.entity.DimVipid">
        SELECT
        *
        FROM
        DIM_VIPID
        where 1=1
        <if test="query.ctype != null and query.ctype != ''">
            and CTYPE = #{query.ctype}
        </if>
        <if test="query.qytype != null and query.qytype != ''">
            and QYTYPE = #{query.qytype}
        </if>
        <if test="query.company != null and query.company != ''">
            and COMPANY = #{query.company}
        </if>
        <if test="query.vipid != null and query.vipid != ''">
            AND instr(VIPID,#{query.vipid}) > 0
        </if>
        <if test="query.vname != null and query.vname != ''">
            AND instr(VNAME,#{query.vname}) > 0
        </if>
        <if test="query.ptype != null and query.ptype != ''">
            AND instr(PTYPE,#{query.ptype}) > 0
        </if>
    </select>

</mapper>
