<?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.tofly.gpsboot.mapper.comm.MeiCunCarOilMapper">

    <resultMap id="meicunCarOilMap" type="com.tofly.pojo.car.MeiCunCarOil">
        <id property="id" column="ID"/>
        <result property="vehicleId" column="VEHICLE_ID"/>
        <result property="contactNumber" column="CONTACT_NUMBER"/>
        <result property="refuelLocation" column="REFUEL_LOCATION"/>
        <result property="paymentMethod" column="PAYMENT_METHOD"/>
        <result property="responsiblePerson" column="RESPONSIBLE_PERSON"/>
        <result property="fuelGrade" column="FUEL_GRADE"/>
        <result property="mileage" column="MILEAGE"/>
        <result property="unitPrice" column="UNIT_PRICE"/>
        <result property="fuelQuantity" column="FUEL_QUANTITY"/>
        <result property="totalCost" column="TOTAL_COST"/>
        <result property="refuelDate" column="REFUEL_DATE"/>
        <result property="dataStatus" column="DATA_STATU"/>
        <result property="snowflakeId" column="SNOWFLAKE_ID"/>
        <result property="createdDate" column="CREATED_DATE"/>
        <result property="responsibleId" column="RESPONSIBLE_ID"/>
        <result property="remark" column="REMARK"/>
    </resultMap>

    <resultMap id="meicunCarOilListVOMap" type="com.tofly.pojo.car.vo.MeiCunCarOilVO">
        <id property="id" column="ID"/>
        <result property="vehicleId" column="VEHICLE_ID"/>
        <result property="contactNumber" column="CONTACT_NUMBER"/>
        <result property="refuelLocation" column="REFUEL_LOCATION"/>
        <result property="paymentMethod" column="PAYMENT_METHOD"/>
        <result property="responsiblePerson" column="RESPONSIBLE_PERSON"/>
        <result property="fuelGrade" column="FUEL_GRADE"/>
        <result property="mileage" column="MILEAGE"/>
        <result property="unitPrice" column="UNIT_PRICE"/>
        <result property="fuelQuantity" column="FUEL_QUANTITY"/>
        <result property="totalCost" column="TOTAL_COST"/>
        <result property="refuelDate" column="REFUEL_DATE"/>
        <result property="dataStatus" column="DATA_STATU"/>
        <result property="snowflakeId" column="SNOWFLAKE_ID"/>
        <result property="createdDate" column="CREATED_DATE"/>
        <result property="responsibleId" column="RESPONSIBLE_ID"/>
        <result property="remark" column="REMARK"/>
        <result property="paymentMethodStr" column="paymentMethodStr"/>
        <result property="responsibleName" column="responsibleName"/>
        <result property="carNumber" column="carNumber"/>
        <result property="carType" column="CAR_TYPE"/>
    </resultMap>

    <select id="customPage" resultMap="meicunCarOilListVOMap">
        SELECT b.REAL_NAME  AS responsibleName,
               CASE
                   WHEN a.PAYMENT_METHOD = 1 THEN '微信支付'
                   WHEN a.PAYMENT_METHOD = 2 THEN '支付宝支付'
                   WHEN a.PAYMENT_METHOD = 3 THEN '现金支付'
                   WHEN a.PAYMENT_METHOD = 4 THEN '银行卡支付'
                   ELSE ''
                   END      AS paymentMethodStr,
               c.CAR_NUMBER as carNumber,
               d.name as CAR_TYPE,
               a.*
        FROM CAR_OIL a
                 LEFT JOIN tf_smpn_user_x b ON a.RESPONSIBLE_ID = b.id
                 left join TF_CAR_BASEINFO c on a.vehicle_id = c.id
                 left JOIN TF_CAR_TYPE d on c.car_type=d.id
        order by a.id desc
    </select>

</mapper>