<?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.XhpcHistoryOrderMapper">
    <resultMap id="BaseResultMap" type="com.xhpc.card.pojo.XhpcHistoryOrder">
        <id column="history_order_id" jdbcType="BIGINT" property="historyOrderId"/>
        <result column="charging_station_id" jdbcType="BIGINT" property="chargingStationId"/>
        <result column="charge_order_id" jdbcType="BIGINT" property="chargeOrderId"/>
        <result column="user_id" jdbcType="BIGINT" property="userId"/>
        <result column="terminal_id" jdbcType="BIGINT" property="terminalId"/>
        <result column="serial_number" jdbcType="VARCHAR" property="serialNumber"/>
        <result column="internet_serial_number" jdbcType="VARCHAR" property="internetSerialNumber"/>
        <result column="power_price_total" jdbcType="DECIMAL" property="powerPriceTotal"/>
        <result column="service_price_total" jdbcType="DECIMAL" property="servicePriceTotal"/>
        <result column="total_price" jdbcType="DECIMAL" property="totalPrice"/>
        <result column="promotion_discount" jdbcType="DECIMAL" property="promotionDiscount"/>
        <result column="act_price" jdbcType="DECIMAL" property="actPrice"/>
        <result column="act_power_price" jdbcType="DECIMAL" property="actPowerPrice"/>
        <result column="act_service_price" jdbcType="DECIMAL" property="actServicePrice"/>
        <result column="internet_commission" jdbcType="DECIMAL" property="internetCommission"/>
        <result column="internet_svc_commission" jdbcType="DECIMAL" property="internetSvcCommission"/>
        <result column="platform_commission" jdbcType="DECIMAL" property="platformCommission"/>
        <result column="platform_svc_commisssion" jdbcType="DECIMAL" property="platformSvcCommisssion"/>
        <result column="operation_commission" jdbcType="DECIMAL" property="operationCommission"/>
        <result column="operation_svc_commission" jdbcType="DECIMAL" property="operationSvcCommission"/>
        <result column="start_soc" jdbcType="VARCHAR" property="startSoc"/>
        <result column="end_soc" jdbcType="VARCHAR" property="endSoc"/>
        <result column="reconciliation_status" jdbcType="INTEGER" property="reconciliationStatus"/>
        <result column="sorting_status" jdbcType="INTEGER" property="sortingStatus"/>
        <result column="type" jdbcType="TINYINT" property="type"/>
        <result column="status" jdbcType="INTEGER" property="status"/>
        <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="state" jdbcType="INTEGER" property="state"/>
        <result column="vin_normal" jdbcType="VARCHAR" property="vinNormal"/>
        <result column="search_value" jdbcType="VARCHAR" property="searchValue"/>
        <result column="operator_id_evcs" jdbcType="VARCHAR" property="operatorIdEvcs"/>
        <result column="charge_model_evcs" jdbcType="INTEGER" property="chargeModelEvcs"/>
        <result column="connector_power_evcs" jdbcType="DOUBLE" property="connectorPowerEvcs"/>
        <result column="meter_value_end_evcs" jdbcType="DOUBLE" property="meterValueEndEvcs"/>
        <result column="meter_value_start_evcs" jdbcType="DOUBLE" property="meterValueStartEvcs"/>
        <result column="operator_id3rdpty_evcs" jdbcType="VARCHAR" property="operatorId3rdptyEvcs"/>
        <result column="start_time" jdbcType="TIMESTAMP" property="startTime"/>
        <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
        <result column="stop_reason_evcs" jdbcType="INTEGER" property="stopReasonEvcs"/>
        <result column="total_power" jdbcType="DOUBLE" property="totalPower"/>
        <result column="user_name_evcs" jdbcType="VARCHAR" property="userNameEvcs"/>
        <result column="phone" jdbcType="VARCHAR" property="phone"/>
        <result column="evcs_order_no" jdbcType="VARCHAR" property="evcsOrderNo"/>
        <result column="confirm_Result" jdbcType="INTEGER" property="confirmResult"/>
        <result column="rate_model_id" jdbcType="BIGINT" property="rateModelId"/>
        <result column="charging_mode" jdbcType="VARCHAR" property="chargingMode"/>
        <result column="internet_degree_commission" jdbcType="DECIMAL" property="internetDegreeCommission"/>
        <result column="source" jdbcType="INTEGER" property="source"/>
        <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
    </resultMap>
    <sql id="Base_Column_List">
        history_order_id
        , charging_station_id, charge_order_id, user_id, terminal_id, serial_number,
    internet_serial_number, power_price_total, service_price_total, total_price, promotion_discount, 
    act_price, act_power_price, act_service_price, internet_commission, internet_svc_commission, 
    platform_commission, platform_svc_commisssion, operation_commission, operation_svc_commission, 
    start_soc, end_soc, reconciliation_status, sorting_status, `type`, `status`, del_flag, 
    create_time, create_by, update_time, update_by, remark, `state`, vin_normal, search_value, 
    operator_id_evcs, charge_model_evcs, connector_power_evcs, meter_value_end_evcs, 
    meter_value_start_evcs, operator_id3rdpty_evcs, start_time, end_time, stop_reason_evcs, 
    total_power, user_name_evcs, phone, evcs_order_no, confirm_Result, rate_model_id, 
    charging_mode, internet_degree_commission, `source`, tenant_id
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from xhpc_history_order
        where history_order_id = #{historyOrderId,jdbcType=BIGINT}
    </select>
    <select id="selectUserTotalCountByTenantIdsAndChargingStationIdsAndUserTypeAndCurrentTime"
            resultType="java.lang.Long">
        SELECT
        count(user_id)
        FROM
        (
        SELECT
        user_id
        FROM
        xhpc_history_order
        WHERE
        del_flag = 0
        <if test="tenantIdsStr!=null and tenantIdsStr!='' ">
            and find_in_set(tenant_id, #{tenantIdsStr})
        </if>
        <if test="chargingStationIdList!=null and chargingStationIdList.size()!=0 ">
            AND charging_station_id IN
            <foreach collection="chargingStationIdList" separator="," open="(" close=")" item="chargingStationId">
                #{chargingStationId}
            </foreach>
        </if>
        <if test="userType!=null">
            AND source = #{userType}
        </if>
        <if test="currentTime!=null and currentTime!='' ">
            and create_time <![CDATA[>=]]> DATE_ADD(#{currentTime},INTERVAL -3 MONTH)
        </if>
        ) AS a
    </select>
    <select id="selectTotalElectricQuantity" resultType="java.lang.Long">
        SELECT
        ifnull(sum(total_power),0) AS totalPower
        FROM
        xhpc_history_order
        WHERE
        del_flag = 0
        <if test="tenantIdsStr!=null and tenantIdsStr!='' ">
            and find_in_set(tenant_id, #{tenantIdsStr})
        </if>
        <if test="chargingStationIdList!=null and chargingStationIdList.size()!=0 ">
            and charging_station_id in
            <foreach collection="chargingStationIdList" separator="," open="(" close=")" item="chargingStationId">
                #{chargingStationId}
            </foreach>
        </if>
    </select>
    <select id="selectCountByTenantIdsAndChargingStationIds" resultType="java.lang.Long">
        SELECT
        count( history_order_id )
        FROM
        xhpc_history_order
        WHERE
        del_flag = 0
        <if test="tenantIdsStr!=null and tenantIdsStr!='' ">
            and find_in_set(tenant_id, #{tenantIdsStr})
        </if>
        <if test="chargingStationIdList!=null and chargingStationIdList.size()!=0 ">
            and charging_station_id in
            <foreach collection="chargingStationIdList" separator="," open="(" close=")" item="chargingStationId">
                #{chargingStationId}
            </foreach>
        </if>
    </select>
    <select id="selectOrderCountBy" resultType="java.lang.Long">
        SELECT
        count( history_order_id )
        FROM
        xhpc_history_order
        WHERE
        del_flag = 0
        <if test="userType!=null">
            AND source = #{userType}
            <if test="userType==1">
                and operator_id3rdpty_evcs = #{operatorId3rdptyEvcs}
            </if>
        </if>
        <if test="tenantIdsStr!=null and tenantIdsStr!='' ">
            and find_in_set(tenant_id, #{tenantIdsStr})
        </if>
        <if test="chargingStationIdList!=null and chargingStationIdList.size()!=0 ">
            AND charging_station_id IN
            <foreach collection="chargingStationIdList" separator="," open="(" close=")" item="chargingStationId">
                #{chargingStationId}
            </foreach>
        </if>
    </select>

    <select id="xhpcCommunityPersonnelSum" resultType="long">
        select count(community_personnel_id) from xhpc_community_personnel where del_flag =0
    </select>
    <select id="xhpcCustomersPersonnelSum" resultType="long">
        select count(customers_personnel_id) from xhpc_customers_personnel where del_flag =0
    </select>

    <select id="selectOrderTrendByTenantIdsAndChargingStationIds" resultType="java.util.Map">
        SELECT
        `current_time`,
        IFNULL( number, 0 ) number,
        IFNULL( actPrice, 0 ) actPrice
        FROM
        (
        SELECT
        date_format( date_add( now(), INTERVAL - t.help_topic_id DAY ), '%Y-%m-%d' ) AS 'current_time'
        FROM
        mysql.help_topic t
        WHERE
        t.help_topic_id <![CDATA[<=]]> 15
        ) a
        LEFT JOIN (
        SELECT
        DATE_FORMAT( end_time, "%Y-%m-%d" ) end_time,
        count( history_order_id ) number,
        FLOOR(ifnull(sum(act_power_price+act_service_price),0)) actPrice
        FROM
        xhpc_history_order
        WHERE
        del_flag = 0
        <if test="tenantIdsStr!=null and tenantIdsStr!='' ">
            and find_in_set(tenant_id, #{tenantIdsStr})
        </if>
        <if test="chargingStationIdList!=null and chargingStationIdList.size()!=0 ">
            AND charging_station_id IN
            <foreach collection="chargingStationIdList" separator="," open="(" close=")" item="chargingStationId">
                #{chargingStationId}
            </foreach>
        </if>
        AND end_time <![CDATA[>=]]> DATE_ADD( FROM_UNIXTIME(UNIX_TIMESTAMP(CAST(SYSDATE()AS DATE))) , INTERVAL - 15 DAY )
        GROUP BY
        DATE_FORMAT( end_time, "%Y-%m-%d" )) b ON a.`current_time` = b.end_time
        ORDER BY
        `current_time`
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete
        from xhpc_history_order
        where history_order_id = #{historyOrderId,jdbcType=BIGINT}
    </delete>
    <insert id="insert" keyColumn="history_order_id" keyProperty="historyOrderId"
            parameterType="com.xhpc.card.pojo.XhpcHistoryOrder" useGeneratedKeys="true">
        insert into xhpc_history_order (charging_station_id, charge_order_id, user_id,
                                        terminal_id, serial_number, internet_serial_number,
                                        power_price_total, service_price_total, total_price,
                                        promotion_discount, act_price, act_power_price,
                                        act_service_price, internet_commission, internet_svc_commission,
                                        platform_commission, platform_svc_commisssion,
                                        operation_commission, operation_svc_commission,
                                        start_soc, end_soc, reconciliation_status,
                                        sorting_status, `type`, `status`,
                                        del_flag, create_time, create_by,
                                        update_time, update_by, remark,
                                        `state`, vin_normal, search_value,
                                        operator_id_evcs, charge_model_evcs, connector_power_evcs,
                                        meter_value_end_evcs, meter_value_start_evcs, operator_id3rdpty_evcs,
                                        start_time, end_time, stop_reason_evcs,
                                        total_power, user_name_evcs, phone,
                                        evcs_order_no, confirm_Result, rate_model_id,
                                        charging_mode, internet_degree_commission,
                                        `source`, tenant_id)
        values (#{chargingStationId,jdbcType=BIGINT}, #{chargeOrderId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT},
                #{terminalId,jdbcType=BIGINT}, #{serialNumber,jdbcType=VARCHAR},
                #{internetSerialNumber,jdbcType=VARCHAR},
                #{powerPriceTotal,jdbcType=DECIMAL}, #{servicePriceTotal,jdbcType=DECIMAL},
                #{totalPrice,jdbcType=DECIMAL},
                #{promotionDiscount,jdbcType=DECIMAL}, #{actPrice,jdbcType=DECIMAL}, #{actPowerPrice,jdbcType=DECIMAL},
                #{actServicePrice,jdbcType=DECIMAL}, #{internetCommission,jdbcType=DECIMAL},
                #{internetSvcCommission,jdbcType=DECIMAL},
                #{platformCommission,jdbcType=DECIMAL}, #{platformSvcCommisssion,jdbcType=DECIMAL},
                #{operationCommission,jdbcType=DECIMAL}, #{operationSvcCommission,jdbcType=DECIMAL},
                #{startSoc,jdbcType=VARCHAR}, #{endSoc,jdbcType=VARCHAR}, #{reconciliationStatus,jdbcType=INTEGER},
                #{sortingStatus,jdbcType=INTEGER}, #{type,jdbcType=TINYINT}, #{status,jdbcType=INTEGER},
                #{delFlag,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{createBy,jdbcType=VARCHAR},
                #{updateTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
                #{state,jdbcType=INTEGER}, #{vinNormal,jdbcType=VARCHAR}, #{searchValue,jdbcType=VARCHAR},
                #{operatorIdEvcs,jdbcType=VARCHAR}, #{chargeModelEvcs,jdbcType=INTEGER},
                #{connectorPowerEvcs,jdbcType=DOUBLE},
                #{meterValueEndEvcs,jdbcType=DOUBLE}, #{meterValueStartEvcs,jdbcType=DOUBLE},
                #{operatorId3rdptyEvcs,jdbcType=VARCHAR},
                #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{stopReasonEvcs,jdbcType=INTEGER},
                #{totalPower,jdbcType=DOUBLE}, #{userNameEvcs,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR},
                #{evcsOrderNo,jdbcType=VARCHAR}, #{confirmResult,jdbcType=INTEGER}, #{rateModelId,jdbcType=BIGINT},
                #{chargingMode,jdbcType=VARCHAR}, #{internetDegreeCommission,jdbcType=DECIMAL},
                #{source,jdbcType=INTEGER}, #{tenantId,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" keyColumn="history_order_id" keyProperty="historyOrderId"
            parameterType="com.xhpc.card.pojo.XhpcHistoryOrder" useGeneratedKeys="true">
        insert into xhpc_history_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="chargingStationId != null">
                charging_station_id,
            </if>
            <if test="chargeOrderId != null">
                charge_order_id,
            </if>
            <if test="userId != null">
                user_id,
            </if>
            <if test="terminalId != null">
                terminal_id,
            </if>
            <if test="serialNumber != null">
                serial_number,
            </if>
            <if test="internetSerialNumber != null">
                internet_serial_number,
            </if>
            <if test="powerPriceTotal != null">
                power_price_total,
            </if>
            <if test="servicePriceTotal != null">
                service_price_total,
            </if>
            <if test="totalPrice != null">
                total_price,
            </if>
            <if test="promotionDiscount != null">
                promotion_discount,
            </if>
            <if test="actPrice != null">
                act_price,
            </if>
            <if test="actPowerPrice != null">
                act_power_price,
            </if>
            <if test="actServicePrice != null">
                act_service_price,
            </if>
            <if test="internetCommission != null">
                internet_commission,
            </if>
            <if test="internetSvcCommission != null">
                internet_svc_commission,
            </if>
            <if test="platformCommission != null">
                platform_commission,
            </if>
            <if test="platformSvcCommisssion != null">
                platform_svc_commisssion,
            </if>
            <if test="operationCommission != null">
                operation_commission,
            </if>
            <if test="operationSvcCommission != null">
                operation_svc_commission,
            </if>
            <if test="startSoc != null">
                start_soc,
            </if>
            <if test="endSoc != null">
                end_soc,
            </if>
            <if test="reconciliationStatus != null">
                reconciliation_status,
            </if>
            <if test="sortingStatus != null">
                sorting_status,
            </if>
            <if test="type != null">
                `type`,
            </if>
            <if test="status != null">
                `status`,
            </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="state != null">
                `state`,
            </if>
            <if test="vinNormal != null">
                vin_normal,
            </if>
            <if test="searchValue != null">
                search_value,
            </if>
            <if test="operatorIdEvcs != null">
                operator_id_evcs,
            </if>
            <if test="chargeModelEvcs != null">
                charge_model_evcs,
            </if>
            <if test="connectorPowerEvcs != null">
                connector_power_evcs,
            </if>
            <if test="meterValueEndEvcs != null">
                meter_value_end_evcs,
            </if>
            <if test="meterValueStartEvcs != null">
                meter_value_start_evcs,
            </if>
            <if test="operatorId3rdptyEvcs != null">
                operator_id3rdpty_evcs,
            </if>
            <if test="startTime != null">
                start_time,
            </if>
            <if test="endTime != null">
                end_time,
            </if>
            <if test="stopReasonEvcs != null">
                stop_reason_evcs,
            </if>
            <if test="totalPower != null">
                total_power,
            </if>
            <if test="userNameEvcs != null">
                user_name_evcs,
            </if>
            <if test="phone != null">
                phone,
            </if>
            <if test="evcsOrderNo != null">
                evcs_order_no,
            </if>
            <if test="confirmResult != null">
                confirm_Result,
            </if>
            <if test="rateModelId != null">
                rate_model_id,
            </if>
            <if test="chargingMode != null">
                charging_mode,
            </if>
            <if test="internetDegreeCommission != null">
                internet_degree_commission,
            </if>
            <if test="source != null">
                `source`,
            </if>
            <if test="tenantId != null">
                tenant_id,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="chargingStationId != null">
                #{chargingStationId,jdbcType=BIGINT},
            </if>
            <if test="chargeOrderId != null">
                #{chargeOrderId,jdbcType=BIGINT},
            </if>
            <if test="userId != null">
                #{userId,jdbcType=BIGINT},
            </if>
            <if test="terminalId != null">
                #{terminalId,jdbcType=BIGINT},
            </if>
            <if test="serialNumber != null">
                #{serialNumber,jdbcType=VARCHAR},
            </if>
            <if test="internetSerialNumber != null">
                #{internetSerialNumber,jdbcType=VARCHAR},
            </if>
            <if test="powerPriceTotal != null">
                #{powerPriceTotal,jdbcType=DECIMAL},
            </if>
            <if test="servicePriceTotal != null">
                #{servicePriceTotal,jdbcType=DECIMAL},
            </if>
            <if test="totalPrice != null">
                #{totalPrice,jdbcType=DECIMAL},
            </if>
            <if test="promotionDiscount != null">
                #{promotionDiscount,jdbcType=DECIMAL},
            </if>
            <if test="actPrice != null">
                #{actPrice,jdbcType=DECIMAL},
            </if>
            <if test="actPowerPrice != null">
                #{actPowerPrice,jdbcType=DECIMAL},
            </if>
            <if test="actServicePrice != null">
                #{actServicePrice,jdbcType=DECIMAL},
            </if>
            <if test="internetCommission != null">
                #{internetCommission,jdbcType=DECIMAL},
            </if>
            <if test="internetSvcCommission != null">
                #{internetSvcCommission,jdbcType=DECIMAL},
            </if>
            <if test="platformCommission != null">
                #{platformCommission,jdbcType=DECIMAL},
            </if>
            <if test="platformSvcCommisssion != null">
                #{platformSvcCommisssion,jdbcType=DECIMAL},
            </if>
            <if test="operationCommission != null">
                #{operationCommission,jdbcType=DECIMAL},
            </if>
            <if test="operationSvcCommission != null">
                #{operationSvcCommission,jdbcType=DECIMAL},
            </if>
            <if test="startSoc != null">
                #{startSoc,jdbcType=VARCHAR},
            </if>
            <if test="endSoc != null">
                #{endSoc,jdbcType=VARCHAR},
            </if>
            <if test="reconciliationStatus != null">
                #{reconciliationStatus,jdbcType=INTEGER},
            </if>
            <if test="sortingStatus != null">
                #{sortingStatus,jdbcType=INTEGER},
            </if>
            <if test="type != null">
                #{type,jdbcType=TINYINT},
            </if>
            <if test="status != null">
                #{status,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="state != null">
                #{state,jdbcType=INTEGER},
            </if>
            <if test="vinNormal != null">
                #{vinNormal,jdbcType=VARCHAR},
            </if>
            <if test="searchValue != null">
                #{searchValue,jdbcType=VARCHAR},
            </if>
            <if test="operatorIdEvcs != null">
                #{operatorIdEvcs,jdbcType=VARCHAR},
            </if>
            <if test="chargeModelEvcs != null">
                #{chargeModelEvcs,jdbcType=INTEGER},
            </if>
            <if test="connectorPowerEvcs != null">
                #{connectorPowerEvcs,jdbcType=DOUBLE},
            </if>
            <if test="meterValueEndEvcs != null">
                #{meterValueEndEvcs,jdbcType=DOUBLE},
            </if>
            <if test="meterValueStartEvcs != null">
                #{meterValueStartEvcs,jdbcType=DOUBLE},
            </if>
            <if test="operatorId3rdptyEvcs != null">
                #{operatorId3rdptyEvcs,jdbcType=VARCHAR},
            </if>
            <if test="startTime != null">
                #{startTime,jdbcType=TIMESTAMP},
            </if>
            <if test="endTime != null">
                #{endTime,jdbcType=TIMESTAMP},
            </if>
            <if test="stopReasonEvcs != null">
                #{stopReasonEvcs,jdbcType=INTEGER},
            </if>
            <if test="totalPower != null">
                #{totalPower,jdbcType=DOUBLE},
            </if>
            <if test="userNameEvcs != null">
                #{userNameEvcs,jdbcType=VARCHAR},
            </if>
            <if test="phone != null">
                #{phone,jdbcType=VARCHAR},
            </if>
            <if test="evcsOrderNo != null">
                #{evcsOrderNo,jdbcType=VARCHAR},
            </if>
            <if test="confirmResult != null">
                #{confirmResult,jdbcType=INTEGER},
            </if>
            <if test="rateModelId != null">
                #{rateModelId,jdbcType=BIGINT},
            </if>
            <if test="chargingMode != null">
                #{chargingMode,jdbcType=VARCHAR},
            </if>
            <if test="internetDegreeCommission != null">
                #{internetDegreeCommission,jdbcType=DECIMAL},
            </if>
            <if test="source != null">
                #{source,jdbcType=INTEGER},
            </if>
            <if test="tenantId != null">
                #{tenantId,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.xhpc.card.pojo.XhpcHistoryOrder">
        update xhpc_history_order
        <set>
            <if test="chargingStationId != null">
                charging_station_id = #{chargingStationId,jdbcType=BIGINT},
            </if>
            <if test="chargeOrderId != null">
                charge_order_id = #{chargeOrderId,jdbcType=BIGINT},
            </if>
            <if test="userId != null">
                user_id = #{userId,jdbcType=BIGINT},
            </if>
            <if test="terminalId != null">
                terminal_id = #{terminalId,jdbcType=BIGINT},
            </if>
            <if test="serialNumber != null">
                serial_number = #{serialNumber,jdbcType=VARCHAR},
            </if>
            <if test="internetSerialNumber != null">
                internet_serial_number = #{internetSerialNumber,jdbcType=VARCHAR},
            </if>
            <if test="powerPriceTotal != null">
                power_price_total = #{powerPriceTotal,jdbcType=DECIMAL},
            </if>
            <if test="servicePriceTotal != null">
                service_price_total = #{servicePriceTotal,jdbcType=DECIMAL},
            </if>
            <if test="totalPrice != null">
                total_price = #{totalPrice,jdbcType=DECIMAL},
            </if>
            <if test="promotionDiscount != null">
                promotion_discount = #{promotionDiscount,jdbcType=DECIMAL},
            </if>
            <if test="actPrice != null">
                act_price = #{actPrice,jdbcType=DECIMAL},
            </if>
            <if test="actPowerPrice != null">
                act_power_price = #{actPowerPrice,jdbcType=DECIMAL},
            </if>
            <if test="actServicePrice != null">
                act_service_price = #{actServicePrice,jdbcType=DECIMAL},
            </if>
            <if test="internetCommission != null">
                internet_commission = #{internetCommission,jdbcType=DECIMAL},
            </if>
            <if test="internetSvcCommission != null">
                internet_svc_commission = #{internetSvcCommission,jdbcType=DECIMAL},
            </if>
            <if test="platformCommission != null">
                platform_commission = #{platformCommission,jdbcType=DECIMAL},
            </if>
            <if test="platformSvcCommisssion != null">
                platform_svc_commisssion = #{platformSvcCommisssion,jdbcType=DECIMAL},
            </if>
            <if test="operationCommission != null">
                operation_commission = #{operationCommission,jdbcType=DECIMAL},
            </if>
            <if test="operationSvcCommission != null">
                operation_svc_commission = #{operationSvcCommission,jdbcType=DECIMAL},
            </if>
            <if test="startSoc != null">
                start_soc = #{startSoc,jdbcType=VARCHAR},
            </if>
            <if test="endSoc != null">
                end_soc = #{endSoc,jdbcType=VARCHAR},
            </if>
            <if test="reconciliationStatus != null">
                reconciliation_status = #{reconciliationStatus,jdbcType=INTEGER},
            </if>
            <if test="sortingStatus != null">
                sorting_status = #{sortingStatus,jdbcType=INTEGER},
            </if>
            <if test="type != null">
                `type` = #{type,jdbcType=TINYINT},
            </if>
            <if test="status != null">
                `status` = #{status,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="state != null">
                `state` = #{state,jdbcType=INTEGER},
            </if>
            <if test="vinNormal != null">
                vin_normal = #{vinNormal,jdbcType=VARCHAR},
            </if>
            <if test="searchValue != null">
                search_value = #{searchValue,jdbcType=VARCHAR},
            </if>
            <if test="operatorIdEvcs != null">
                operator_id_evcs = #{operatorIdEvcs,jdbcType=VARCHAR},
            </if>
            <if test="chargeModelEvcs != null">
                charge_model_evcs = #{chargeModelEvcs,jdbcType=INTEGER},
            </if>
            <if test="connectorPowerEvcs != null">
                connector_power_evcs = #{connectorPowerEvcs,jdbcType=DOUBLE},
            </if>
            <if test="meterValueEndEvcs != null">
                meter_value_end_evcs = #{meterValueEndEvcs,jdbcType=DOUBLE},
            </if>
            <if test="meterValueStartEvcs != null">
                meter_value_start_evcs = #{meterValueStartEvcs,jdbcType=DOUBLE},
            </if>
            <if test="operatorId3rdptyEvcs != null">
                operator_id3rdpty_evcs = #{operatorId3rdptyEvcs,jdbcType=VARCHAR},
            </if>
            <if test="startTime != null">
                start_time = #{startTime,jdbcType=TIMESTAMP},
            </if>
            <if test="endTime != null">
                end_time = #{endTime,jdbcType=TIMESTAMP},
            </if>
            <if test="stopReasonEvcs != null">
                stop_reason_evcs = #{stopReasonEvcs,jdbcType=INTEGER},
            </if>
            <if test="totalPower != null">
                total_power = #{totalPower,jdbcType=DOUBLE},
            </if>
            <if test="userNameEvcs != null">
                user_name_evcs = #{userNameEvcs,jdbcType=VARCHAR},
            </if>
            <if test="phone != null">
                phone = #{phone,jdbcType=VARCHAR},
            </if>
            <if test="evcsOrderNo != null">
                evcs_order_no = #{evcsOrderNo,jdbcType=VARCHAR},
            </if>
            <if test="confirmResult != null">
                confirm_Result = #{confirmResult,jdbcType=INTEGER},
            </if>
            <if test="rateModelId != null">
                rate_model_id = #{rateModelId,jdbcType=BIGINT},
            </if>
            <if test="chargingMode != null">
                charging_mode = #{chargingMode,jdbcType=VARCHAR},
            </if>
            <if test="internetDegreeCommission != null">
                internet_degree_commission = #{internetDegreeCommission,jdbcType=DECIMAL},
            </if>
            <if test="source != null">
                `source` = #{source,jdbcType=INTEGER},
            </if>
            <if test="tenantId != null">
                tenant_id = #{tenantId,jdbcType=VARCHAR},
            </if>
        </set>
        where history_order_id = #{historyOrderId,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.xhpc.card.pojo.XhpcHistoryOrder">
        update xhpc_history_order
        set charging_station_id        = #{chargingStationId,jdbcType=BIGINT},
            charge_order_id            = #{chargeOrderId,jdbcType=BIGINT},
            user_id                    = #{userId,jdbcType=BIGINT},
            terminal_id                = #{terminalId,jdbcType=BIGINT},
            serial_number              = #{serialNumber,jdbcType=VARCHAR},
            internet_serial_number     = #{internetSerialNumber,jdbcType=VARCHAR},
            power_price_total          = #{powerPriceTotal,jdbcType=DECIMAL},
            service_price_total        = #{servicePriceTotal,jdbcType=DECIMAL},
            total_price                = #{totalPrice,jdbcType=DECIMAL},
            promotion_discount         = #{promotionDiscount,jdbcType=DECIMAL},
            act_price                  = #{actPrice,jdbcType=DECIMAL},
            act_power_price            = #{actPowerPrice,jdbcType=DECIMAL},
            act_service_price          = #{actServicePrice,jdbcType=DECIMAL},
            internet_commission        = #{internetCommission,jdbcType=DECIMAL},
            internet_svc_commission    = #{internetSvcCommission,jdbcType=DECIMAL},
            platform_commission        = #{platformCommission,jdbcType=DECIMAL},
            platform_svc_commisssion   = #{platformSvcCommisssion,jdbcType=DECIMAL},
            operation_commission       = #{operationCommission,jdbcType=DECIMAL},
            operation_svc_commission   = #{operationSvcCommission,jdbcType=DECIMAL},
            start_soc                  = #{startSoc,jdbcType=VARCHAR},
            end_soc                    = #{endSoc,jdbcType=VARCHAR},
            reconciliation_status      = #{reconciliationStatus,jdbcType=INTEGER},
            sorting_status             = #{sortingStatus,jdbcType=INTEGER},
            `type`                     = #{type,jdbcType=TINYINT},
            `status`                   = #{status,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},
            `state`                    = #{state,jdbcType=INTEGER},
            vin_normal                 = #{vinNormal,jdbcType=VARCHAR},
            search_value               = #{searchValue,jdbcType=VARCHAR},
            operator_id_evcs           = #{operatorIdEvcs,jdbcType=VARCHAR},
            charge_model_evcs          = #{chargeModelEvcs,jdbcType=INTEGER},
            connector_power_evcs       = #{connectorPowerEvcs,jdbcType=DOUBLE},
            meter_value_end_evcs       = #{meterValueEndEvcs,jdbcType=DOUBLE},
            meter_value_start_evcs     = #{meterValueStartEvcs,jdbcType=DOUBLE},
            operator_id3rdpty_evcs     = #{operatorId3rdptyEvcs,jdbcType=VARCHAR},
            start_time                 = #{startTime,jdbcType=TIMESTAMP},
            end_time                   = #{endTime,jdbcType=TIMESTAMP},
            stop_reason_evcs           = #{stopReasonEvcs,jdbcType=INTEGER},
            total_power                = #{totalPower,jdbcType=DOUBLE},
            user_name_evcs             = #{userNameEvcs,jdbcType=VARCHAR},
            phone                      = #{phone,jdbcType=VARCHAR},
            evcs_order_no              = #{evcsOrderNo,jdbcType=VARCHAR},
            confirm_Result             = #{confirmResult,jdbcType=INTEGER},
            rate_model_id              = #{rateModelId,jdbcType=BIGINT},
            charging_mode              = #{chargingMode,jdbcType=VARCHAR},
            internet_degree_commission = #{internetDegreeCommission,jdbcType=DECIMAL},
            `source`                   = #{source,jdbcType=INTEGER},
            tenant_id                  = #{tenantId,jdbcType=VARCHAR}
        where history_order_id = #{historyOrderId,jdbcType=BIGINT}
    </update>
</mapper>