<?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.xhpc.tradebill.mapper.XhpcTradebillInternetCheckRecordMapper">
    <resultMap id="BaseResultMap" type="com.xhpc.tradebill.domain.XhpcTradebillInternetCheckRecordDomain">
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="create_by" jdbcType="BIGINT" property="createBy"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
        <result column="upload_id" jdbcType="INTEGER" property="uploadId"/>
        <result column="history_order_no" jdbcType="BIGINT" property="historyOrderNo"/>
        <result column="user_id" jdbcType="VARCHAR" property="userId"/>
        <result column="internet_name" jdbcType="VARCHAR" property="internetName"/>
        <result column="platform_internet_serial_number" jdbcType="VARCHAR" property="platformInternetSerialNumber"/>
        <result column="platform_charge_station" jdbcType="VARCHAR" property="platformChargeStation"/>
        <result column="platform_start_soc" jdbcType="VARCHAR" property="platformStartSoc"/>
        <result column="platform_end_soc" jdbcType="VARCHAR" property="platformEndSoc"/>
        <result column="platform_charging_degree" jdbcType="DECIMAL" property="platformChargingDegree"/>
        <result column="platform_charging_time" jdbcType="VARCHAR" property="platformChargingTime"/>
        <result column="platform_start_time" jdbcType="TIMESTAMP" property="platformStartTime"/>
        <result column="platform_end_time" jdbcType="TIMESTAMP" property="platformEndTime"/>
        <result column="platform_order_amount" jdbcType="DECIMAL" property="platformOrderAmount"/>
        <result column="platform_power_amount" jdbcType="DECIMAL" property="platformPowerAmount"/>
        <result column="platform_server_amount" jdbcType="DECIMAL" property="platformServerAmount"/>
        <result column="platform_discount_amount" jdbcType="DECIMAL" property="platformDiscountAmount"/>
        <result column="platform_pay_amount" jdbcType="DECIMAL" property="platformPayAmount"/>
        <result column="internet_serial_number" jdbcType="VARCHAR" property="internetSerialNumber"/>
        <result column="internet_charge_station" jdbcType="VARCHAR" property="internetChargeStation"/>
        <result column="internet_start_soc" jdbcType="VARCHAR" property="internetStartSoc"/>
        <result column="internet_end_soc" jdbcType="VARCHAR" property="internetEndSoc"/>
        <result column="internet_charging_degree" jdbcType="DECIMAL" property="internetChargingDegree"/>
        <result column="internet_charging_time" jdbcType="VARCHAR" property="internetChargingTime"/>
        <result column="internet_start_time" jdbcType="TIMESTAMP" property="internetStartTime"/>
        <result column="internet_end_time" jdbcType="TIMESTAMP" property="internetEndTime"/>
        <result column="internet_order_amount" jdbcType="DECIMAL" property="internetOrderAmount"/>
        <result column="internet_power_amount" jdbcType="DECIMAL" property="internetPowerAmount"/>
        <result column="internet_server_amount" jdbcType="DECIMAL" property="internetServerAmount"/>
        <result column="internet_discount_amount" jdbcType="DECIMAL" property="internetDiscountAmount"/>
        <result column="internet_pay_amount" jdbcType="DECIMAL" property="internetPayAmount"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
        <result column="status" jdbcType="SMALLINT" property="status"/>
    </resultMap>
    <sql id="Base_Column_List">
        id, create_time, create_by, update_time, update_by, upload_id, history_order_no,
    user_id, internet_name, platform_internet_serial_number, platform_charge_station, platform_start_soc, 
    platform_end_soc, platform_charging_degree, platform_charging_time, platform_start_time, 
    platform_end_time, platform_order_amount, platform_power_amount, platform_server_amount, 
    platform_discount_amount, platform_pay_amount, internet_serial_number, internet_charge_station, 
    internet_start_soc, internet_end_soc, internet_charging_degree, internet_charging_time, internet_start_time, 
    internet_end_time, internet_order_amount, internet_power_amount, internet_server_amount, internet_discount_amount, 
    internet_pay_amount, remark, `status`
    </sql>

    <select id="selectByParams" resultType="java.util.Map">
        select
        <include refid="Base_Column_List"/>
        from xhpc_tradebill_internet_check_record
        <where>
            <if test="params.uploadId != null and params.uploadId != ''">
                and upload_id = #{params.uploadId}
            </if>
            <if test="params.internetName != null and params.internetName != ''">
                and internet_name = #{params.internetName}
            </if>
            <if test="params.platformChargeStation != null and params.platformChargeStation != '' ">
                and platform_charge_station = #{params.platformChargeStation}
            </if>
            <if test="params.checkStatus != null and params.checkStatus != ''">
                and status = #{params.checkStatus}
            </if>
        </where>
    </select>

    <select id="selectListByParams" resultType="com.xhpc.tradebill.domain.XhpcTradebillInternetCheckRecordDomain">
        select
        p.*, cu.user_name as 'create_name', uu.user_name as 'update_name',
        case when p.status=0 then '未对账' when p.status=1 then '对账错误' when p.status=2 then '对账正确' else '未知' end as
        'status_name'
        from xhpc_tradebill_internet_check_record p
        left join sys_user cu on cu.user_id=p.create_by
        left join sys_user uu on uu.user_id=p.update_by
        <where>
            <if test="params.uploadId != null and params.upload!='' and params.uploadId !=0">
                and p.upload_id = #{params.uploadId}
            </if>
            <if test="params.orderNumber != null and params.orderNumber!=''">
                and p.internet_serial_number like concat('%',#{params.orderNumber}, '%')
            </if>
            <if test="params.stationName != null and params.stationName!=''">
                and p.internet_charge_station like concat('%',  #{params.internetName},'%')
            </if>
            <if test="params.internetName != null and params.internetName!=''">
                and p.internet_name like concat('%',  #{params.internetName},'%')
            </if>
            <if test="params.status != null and params.status!=''">
                and p.status = #{params.status}
            </if>
        </where>
        order by p.upload_id desc, status asc
    </select>

    <select id="selectTotalGroupbyStatus" resultType="java.util.Map">
        select
        status, count(id) as 'total'
        from xhpc_tradebill_internet_check_record
        <where>
            <if test="params.uploadId != null and params.upload!='' and params.uploadId !=0">
                and upload_id = #{params.uploadId}
            </if>
            <if test="params.orderNumber != null and params.orderNumber!=''">
                and internet_serial_number like concat('%',#{params.orderNumber}, '%')
            </if>
            <if test="params.stationName != null and params.stationName!=''">
                and internet_charge_station like concat('%',  #{params.internetName},'%')
            </if>
            <if test="params.internetName != null and params.internetName!=''">
                and internet_name like concat('%', #{params.internetName}, '%')
            </if>
            <if test="params.status != null and params.status!=''">
                and status = #{params.status}
            </if>
        </where>
        group by status
    </select>

    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from xhpc_tradebill_internet_check_record
        where id = #{id}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete
        from xhpc_tradebill_internet_check_record
        where id = #{id}
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id"
            parameterType="com.xhpc.tradebill.domain.XhpcTradebillInternetCheckRecordDomain" useGeneratedKeys="true">
        insert into xhpc_tradebill_internet_check_record (create_time, create_by, update_time,
                                                          update_by, upload_id, history_order_no,
                                                          user_id, internet_name, platform_internet_serial_number,
                                                          platform_serial_number,
                                                          platform_charge_station, platform_start_soc,
                                                          platform_end_soc, platform_charging_degree,
                                                          platform_charging_time, platform_start_time,
                                                          platform_end_time, platform_order_amount,
                                                          platform_power_amount, platform_server_amount,
                                                          platform_discount_amount, platform_pay_amount,
                                                          internet_serial_number, internet_charge_station,
                                                          internet_start_soc,
                                                          internet_end_soc, internet_charging_degree,
                                                          internet_charging_time,
                                                          internet_start_time, internet_end_time, internet_order_amount,
                                                          internet_power_amount, internet_server_amount,
                                                          internet_discount_amount,
                                                          internet_pay_amount, remark, `status`)
        values (now(), #{createBy}, now(),
                #{updateBy}, #{uploadId}, #{historyOrderNo},
                #{userId}, #{internetName},
                #{platformInternetSerialNumber},#{platformSerialNumber},
                #{platformChargeStation}, #{platformStartSoc},
                #{platformEndSoc}, #{platformChargingDegree},
                #{platformChargingTime}, #{platformStartTime},
                #{platformEndTime}, #{platformOrderAmount},
                #{platformPowerAmount}, #{platformServerAmount},
                #{platformDiscountAmount}, #{platformPayAmount},
                #{internetSerialNumber}, #{internetChargeStation},
                #{internetStartSoc},
                #{internetEndSoc}, #{internetChargingDegree},
                #{internetChargingTime},
                #{internetStartTime}, #{internetEndTime},
                #{internetOrderAmount},
                #{internetPowerAmount}, #{internetServerAmount},
                #{internetDiscountAmount},
                #{internetPayAmount}, #{remark}, #{status,jdbcType=SMALLINT})
    </insert>

    <insert id="insertCheckList" keyColumn="id" keyProperty="id"
            parameterType="com.xhpc.tradebill.domain.XhpcTradebillInternetCheckRecordDomain" useGeneratedKeys="true">
        insert into xhpc_tradebill_internet_check_record (create_time, create_by, update_time,
        update_by, upload_id, history_order_no,
        user_id, internet_name, platform_internet_serial_number, platform_serial_number,
        platform_charge_station, platform_start_soc,
        platform_end_soc, platform_charging_degree,
        platform_charging_time, platform_start_time,
        platform_end_time, platform_order_amount,
        platform_power_amount, platform_server_amount,
        platform_discount_amount, platform_pay_amount,
        internet_serial_number, internet_charge_station, internet_start_soc,
        internet_end_soc, internet_charging_degree, internet_charging_time,
        internet_start_time, internet_end_time, internet_order_amount,
        internet_power_amount, internet_server_amount, internet_discount_amount,
        internet_pay_amount, remark, `status`
        ) values
        <foreach collection="list" item="check" index="index" separator=",">
            (
            now(), #{check.createBy}, now(),
            #{check.updateBy}, #{check.uploadId},
            #{check.historyOrderNo},
            #{check.userId}, #{check.internetName},
            #{check.platformInternetSerialNumber},#{check.platformSerialNumber},
            #{check.platformChargeStation}, #{check.platformStartSoc},
            #{check.platformEndSoc}, #{check.platformChargingDegree},
            #{check.platformChargingTime}, #{check.platformStartTime},
            #{check.platformEndTime}, #{check.platformOrderAmount},
            #{check.platformPowerAmount}, #{check.platformServerAmount},
            #{check.platformDiscountAmount}, #{check.platformPayAmount},
            #{check.internetSerialNumber}, #{check.internetChargeStation},
            #{check.internetStartSoc},
            #{check.internetEndSoc}, #{check.internetChargingDegree},
            #{check.internetChargingTime},
            #{check.internetStartTime}, #{check.internetEndTime},
            #{check.internetOrderAmount},
            #{check.internetPowerAmount}, #{check.internetServerAmount},
            #{check.internetDiscountAmount},
            #{check.internetPayAmount}, #{check.remark},
            #{check.status})
        </foreach>
    </insert>


    <insert id="insertSelective" keyColumn="id" keyProperty="id"
            parameterType="com.xhpc.tradebill.domain.XhpcTradebillInternetCheckRecordDomain" useGeneratedKeys="true">
        insert into xhpc_tradebill_internet_check_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            create_time,
            <if test="createBy != null">
                create_by,
            </if>
            update_time,
            <if test="updateBy != null">
                update_by,
            </if>
            <if test="uploadId != null">
                upload_id,
            </if>
            <if test="historyOrderNo != null">
                history_order_no,
            </if>
            <if test="userId != null">
                user_id,
            </if>
            <if test="internetName != null">
                internet_name,
            </if>
            <if test="platformInternetSerialNumber != null">
                platform_internet_serial_number,
            </if>
            <if test="platformChargeStation != null">
                platform_charge_station,
            </if>
            <if test="platformStartSoc != null">
                platform_start_soc,
            </if>
            <if test="platformEndSoc != null">
                platform_end_soc,
            </if>
            <if test="platformChargingDegree != null">
                platform_charging_degree,
            </if>
            <if test="platformChargingTime != null">
                platform_charging_time,
            </if>
            <if test="platformStartTime != null">
                platform_start_time,
            </if>
            <if test="platformEndTime != null">
                platform_end_time,
            </if>
            <if test="platformOrderAmount != null">
                platform_order_amount,
            </if>
            <if test="platformPowerAmount != null">
                platform_power_amount,
            </if>
            <if test="platformServerAmount != null">
                platform_server_amount,
            </if>
            <if test="platformDiscountAmount != null">
                platform_discount_amount,
            </if>
            <if test="platformPayAmount != null">
                platform_pay_amount,
            </if>
            <if test="internetSerialNumber != null">
                internet_serial_number,
            </if>
            <if test="internetChargeStation != null">
                internet_charge_station,
            </if>
            <if test="internetStartSoc != null">
                internet_start_soc,
            </if>
            <if test="internetEndSoc != null">
                internet_end_soc,
            </if>
            <if test="internetChargingDegree != null">
                internet_charging_degree,
            </if>
            <if test="internetChargingTime != null">
                internet_charging_time,
            </if>
            <if test="internetStartTime != null">
                internet_start_time,
            </if>
            <if test="internetEndTime != null">
                internet_end_time,
            </if>
            <if test="internetOrderAmount != null">
                internet_order_amount,
            </if>
            <if test="internetPowerAmount != null">
                internet_power_amount,
            </if>
            <if test="internetServerAmount != null">
                internet_server_amount,
            </if>
            <if test="internetDiscountAmount != null">
                internet_discount_amount,
            </if>
            <if test="internetPayAmount != null">
                internet_pay_amount,
            </if>
            <if test="remark != null">
                remark,
            </if>
            <if test="status != null">
                `status`,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            now(),
            <if test="createBy != null">
                #{createBy},
            </if>
            now(),
            <if test="updateBy != null">
                #{updateBy},
            </if>
            <if test="uploadId != null">
                #{uploadId},
            </if>
            <if test="historyOrderNo != null">
                #{historyOrderNo},
            </if>
            <if test="userId != null">
                #{userId},
            </if>
            <if test="internetName != null">
                #{internetName},
            </if>
            <if test="platformInternetSerialNumber != null">
                #{platformInternetSerialNumber},
            </if>
            <if test="platformChargeStation != null">
                #{platformChargeStation},
            </if>
            <if test="platformStartSoc != null">
                #{platformStartSoc},
            </if>
            <if test="platformEndSoc != null">
                #{platformEndSoc},
            </if>
            <if test="platformChargingDegree != null">
                #{platformChargingDegree},
            </if>
            <if test="platformChargingTime != null">
                #{platformChargingTime},
            </if>
            <if test="platformStartTime != null">
                #{platformStartTime},
            </if>
            <if test="platformEndTime != null">
                #{platformEndTime},
            </if>
            <if test="platformOrderAmount != null">
                #{platformOrderAmount},
            </if>
            <if test="platformPowerAmount != null">
                #{platformPowerAmount},
            </if>
            <if test="platformServerAmount != null">
                #{platformServerAmount},
            </if>
            <if test="platformDiscountAmount != null">
                #{platformDiscountAmount},
            </if>
            <if test="platformPayAmount != null">
                #{platformPayAmount},
            </if>
            <if test="internetSerialNumber != null">
                #{internetSerialNumber},
            </if>
            <if test="internetChargeStation != null">
                #{internetChargeStation},
            </if>
            <if test="internetStartSoc != null">
                #{internetStartSoc},
            </if>
            <if test="internetEndSoc != null">
                #{internetEndSoc},
            </if>
            <if test="internetChargingDegree != null">
                #{internetChargingDegree},
            </if>
            <if test="internetChargingTime != null">
                #{internetChargingTime},
            </if>
            <if test="internetStartTime != null">
                #{internetStartTime},
            </if>
            <if test="internetEndTime != null">
                #{internetEndTime},
            </if>
            <if test="internetOrderAmount != null">
                #{internetOrderAmount},
            </if>
            <if test="internetPowerAmount != null">
                #{internetPowerAmount},
            </if>
            <if test="internetServerAmount != null">
                #{internetServerAmount},
            </if>
            <if test="internetDiscountAmount != null">
                #{internetDiscountAmount},
            </if>
            <if test="internetPayAmount != null">
                #{internetPayAmount},
            </if>
            <if test="remark != null">
                #{remark},
            </if>
            <if test="status != null">
                #{status},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective"
            parameterType="com.xhpc.tradebill.domain.XhpcTradebillInternetCheckRecordDomain">
        update xhpc_tradebill_internet_check_record
        <set>
            update_time = now(),
            <if test="updateBy != null">
                update_by = #{updateBy},
            </if>
            <if test="uploadId != null">
                upload_id = #{uploadId},
            </if>
            <if test="historyOrderNo != null">
                history_order_no = #{historyOrderNo},
            </if>
            <if test="userId != null">
                user_id = #{userId},
            </if>
            <if test="internetName != null">
                internet_name = #{internetName},
            </if>
            <if test="platformInternetSerialNumber != null">
                platform_internet_serial_number = #{platformInternetSerialNumber},
            </if>
            <if test="platformChargeStation != null">
                platform_charge_station = #{platformChargeStation},
            </if>
            <if test="platformStartSoc != null">
                platform_start_soc = #{platformStartSoc},
            </if>
            <if test="platformEndSoc != null">
                platform_end_soc = #{platformEndSoc},
            </if>
            <if test="platformChargingDegree != null">
                platform_charging_degree = #{platformChargingDegree},
            </if>
            <if test="platformChargingTime != null">
                platform_charging_time = #{platformChargingTime},
            </if>
            <if test="platformStartTime != null">
                platform_start_time = #{platformStartTime},
            </if>
            <if test="platformEndTime != null">
                platform_end_time = #{platformEndTime},
            </if>
            <if test="platformOrderAmount != null">
                platform_order_amount = #{platformOrderAmount},
            </if>
            <if test="platformPowerAmount != null">
                platform_power_amount = #{platformPowerAmount},
            </if>
            <if test="platformServerAmount != null">
                platform_server_amount = #{platformServerAmount},
            </if>
            <if test="platformDiscountAmount != null">
                platform_discount_amount = #{platformDiscountAmount},
            </if>
            <if test="platformPayAmount != null">
                platform_pay_amount = #{platformPayAmount},
            </if>
            <if test="internetSerialNumber != null">
                internet_serial_number = #{internetSerialNumber},
            </if>
            <if test="internetChargeStation != null">
                internet_charge_station = #{internetChargeStation},
            </if>
            <if test="internetStartSoc != null">
                internet_start_soc = #{internetStartSoc},
            </if>
            <if test="internetEndSoc != null">
                internet_end_soc = #{internetEndSoc},
            </if>
            <if test="internetChargingDegree != null">
                internet_charging_degree = #{internetChargingDegree},
            </if>
            <if test="internetChargingTime != null">
                internet_charging_time = #{internetChargingTime},
            </if>
            <if test="internetStartTime != null">
                internet_start_time = #{internetStartTime},
            </if>
            <if test="internetEndTime != null">
                internet_end_time = #{internetEndTime},
            </if>
            <if test="internetOrderAmount != null">
                internet_order_amount = #{internetOrderAmount},
            </if>
            <if test="internetPowerAmount != null">
                internet_power_amount = #{internetPowerAmount},
            </if>
            <if test="internetServerAmount != null">
                internet_server_amount = #{internetServerAmount},
            </if>
            <if test="internetDiscountAmount != null">
                internet_discount_amount = #{internetDiscountAmount},
            </if>
            <if test="internetPayAmount != null">
                internet_pay_amount = #{internetPayAmount},
            </if>
            <if test="remark != null">
                remark = #{remark},
            </if>
            <if test="status != null">
                `status` = #{status,jdbcType=SMALLINT},
            </if>
        </set>
        where id = #{id}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.xhpc.tradebill.domain.XhpcTradebillInternetCheckRecordDomain">
        update xhpc_tradebill_internet_check_record
        set update_time                     = now(),
            update_by                       = #{updateBy},
            upload_id                       = #{uploadId},
            history_order_no                = #{historyOrderNo},
            user_id                         = #{userId},
            internet_name                   = #{internetName},
            platform_internet_serial_number = #{platformInternetSerialNumber},
            platform_charge_station         = #{platformChargeStation},
            platform_start_soc              = #{platformStartSoc},
            platform_end_soc                = #{platformEndSoc},
            platform_charging_degree        = #{platformChargingDegree},
            platform_charging_time          = #{platformChargingTime},
            platform_start_time             = #{platformStartTime},
            platform_end_time               = #{platformEndTime},
            platform_order_amount           = #{platformOrderAmount},
            platform_power_amount           = #{platformPowerAmount},
            platform_server_amount          = #{platformServerAmount},
            platform_discount_amount        = #{platformDiscountAmount},
            platform_pay_amount             = #{platformPayAmount},
            internet_serial_number          = #{internetSerialNumber},
            internet_charge_station         = #{internetChargeStation},
            internet_start_soc              = #{internetStartSoc},
            internet_end_soc                = #{internetEndSoc},
            internet_charging_degree        = #{internetChargingDegree},
            internet_charging_time          = #{internetChargingTime},
            internet_start_time             = #{internetStartTime},
            internet_end_time               = #{internetEndTime},
            internet_order_amount           = #{internetOrderAmount},
            internet_power_amount           = #{internetPowerAmount},
            internet_server_amount          = #{internetServerAmount},
            internet_discount_amount        = #{internetDiscountAmount},
            internet_pay_amount             = #{internetPayAmount},
            remark                          = #{remark},
            `status`                        = #{status,jdbcType=SMALLINT}
        where id = #{id}
    </update>


    <update id="updateStatusByPk" parameterType="com.xhpc.tradebill.domain.XhpcTradebillInternetCheckRecordDomain">
        update xhpc_tradebill_internet_check_record
        set update_time = now(),
            update_by   = #{updateBy},
            remark      = #{remark},
            `status`    = #{status,jdbcType=SMALLINT}
        where id = #{id}
    </update>
</mapper>