<?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.platform.yijia.dao.StationClassStructureMapper">

    <resultMap type="com.platform.yijia.pojo.StationClassStructure" id="StationClassStructureResult">
        <result property="id"    column="id"    />
        <result property="orderNo"    column="order_no"    />
        <result property="stationId"    column="station_id"    />
        <result property="stationName"    column="station_name"    />
        <result property="oilGun"    column="oil_gun"    />
        <result property="oilName"    column="oil_name"    />
        <result property="oilPirce"    column="oil_pirce"    />
        <result property="oilType"    column="oil_type"    />
        <result property="consumerId"    column="consumer_id"    />
        <result property="consumer"    column="consumer"    />
        <result property="amt"    column="amt"    />
        <result property="orderLiters"    column="order_liters"    />
        <result property="payType"    column="pay_type"    />
        <result property="payWay"    column="pay_way"    />
        <result property="payDate"    column="pay_date"    />
        <result property="oilPersonnel"    column="oil_personnel"    />
        <result property="oilPersonnelId"    column="oil_personnel_id"    />
        <result property="orderType"    column="order_type"    />
        <result property="printNum"    column="print_num"    />
        <result property="classStructureNo"    column="class_structure_no"    />
        <result property="classStartDate"    column="class_start_date"    />
        <result property="classStructureDate"    column="class_structure_date"    />
        <result property="classStructureMan"    column="class_structure_man"    />
        <result property="oils"    column="oils"    />
        <result property="receivableAmt"    column="receivable_amt"    />
        <result property="receivedAmt"    column="received_amt"    />
        <result property="discountAmt"    column="discount_amt"    />
        <result property="discountCouponAmt"    column="discount_coupon_amt"    />
        <result property="discountCoupon"    column="discount_coupon"    />
        <result property="wxAmt"    column="wx_amt"    />
        <result property="zfbAmt"    column="zfb_amt"    />
        <result property="posAmt"    column="pos_amt"    />
        <result property="xjAmt"    column="xj_amt"    />
        <result property="didiAppAmt"    column="didi_app_amt"    />
        <result property="tyAppAmt"    column="ty_app_amt"    />
        <result property="otherAmt"    column="other_amt"    />
        <result property="dzkAmt"    column="dzk_amt"    />
        <result property="score"    column="score"    />
        <result property="memberNo"    column="member_no"    />
        <result property="memberAmt"    column="member_amt"    />
        <result property="carNo"    column="car_no"    />
        <result property="customerPhone"    column="customer_phone"    />
        <result property="customerGrade"    column="customer_grade"    />
        <result property="num"    column="num"    />
        <result property="wxNum"    column="wx_num"    />
        <result property="zfbNum"    column="zfb_num"    />
        <result property="xjNum"    column="xj_num"    />
    </resultMap>

    <select id="selectClassStructureSum" parameterType="com.platform.yijia.pojo.StationClassStructure" resultType="Map">
        <if test="groupBy !=null and groupBy =='oilName'">
            <include refid="Base_Column_List_oilName"/>
        </if>
        <if test="groupBy !=null and groupBy =='payType'">
            <include refid="Base_Column_List_payType"/>
        </if>
        <if test="groupBy ==''">
            <include refid="Base_Column_List_NoGroupBy"/>
        </if>
        <if test="groupBy =='timeAndMan'">
            <include refid="Base_Column_List_timeAndMan"/>
        </if>
    </select>

    <sql id="Base_Column_List_oilName">
        SELECT
            T1.dict_label                         AS oilName,
            COUNT(T2.order_no)                    AS orderSum,
            SUM(IFNULL(T2.order_liters,0))        AS orderLitersSum,
            SUM(IFNULL(T2.receivable_amt,0))      AS receivableAmtSum,
            SUM(IFNULL(T2.discount_amt,0))        AS discountAmtSum,
            SUM(IFNULL(T2.amt,0))                 AS amtSum
        FROM         sys_dict_data                AS T1
        LEFT JOIN    station_class_structure      AS T2   ON T1.dict_label = T2.oil_name
        <if test="stationId !=null">
            AND T2.station_id= #{stationId}
        </if>
        <if test="classStructureNo !=null">
            AND T2.class_structure_no= #{classStructureNo}
        </if>
        WHERE
            T1.dict_type ="oil_name"
        GROUP BY T1.dict_label
        ORDER BY amtSum DESC
    </sql>
    <sql id="Base_Column_List_payType">
        SELECT
            T1.dict_label                         AS payType,
            COUNT(T2.order_no)                    AS orderSum,
            SUM(IFNULL(T2.order_liters,0))        AS orderLitersSum,
            SUM(IFNULL(T2.receivable_amt,0))      AS receivableAmtSum,
            SUM(IFNULL(T2.discount_amt,0))        AS discountAmtSum,
            SUM(IFNULL(T2.amt,0))                 AS amtSum
        FROM         sys_dict_data                AS T1
        LEFT JOIN    station_class_structure      AS T2   ON T1.dict_value = T2.pay_type
        <if test="stationId !=null">
            AND T2.station_id= #{stationId}
        </if>
        <if test="classStructureNo !=null">
            AND T2.class_structure_no= #{classStructureNo}
        </if>
        WHERE
            T1.dict_type ="pay_type"
        GROUP BY T1.dict_label
        ORDER BY amtSum DESC
    </sql>
    <sql id="Base_Column_List_NoGroupBy">
        SELECT
            COUNT(T2.order_no)                  AS orderSum,
            SUM(IFNULL(T2.order_liters,0))      AS orderLitersSum,
            SUM(IFNULL(T2.receivable_amt,0))    AS receivableAmtSum,
            SUM(IFNULL(T2.discount_amt,0))      AS discountAmtSum,
            SUM(IFNULL(T2.amt,0))               AS amtSum,
            SUM(IFNULL(T2.received_amt,0))      AS receivedAmtSum,
            SUM(IFNULL(T2.print_num,0))         AS printCountSum
        FROM
            station_class_structure             AS T2
        <where>
            <if test="stationId !=null">
                T2.station_id= #{stationId}
            </if>
            <if test="classStructureNo !=null">
                AND T2.class_structure_no= #{classStructureNo}
            </if>
        </where>
    </sql>
    <sql id="Base_Column_List_timeAndMan">
        SELECT
            T2.class_structure_no                                                    AS classStructureNo,
            IFNULL(DATE_FORMAT(T2.class_start_date, '%Y-%m-%d %H:%i:%s'), "")        AS beginTime,
            DATE_FORMAT(T2.class_structure_date, '%Y-%m-%d %H:%i:%s')                AS endTime,
            T2.class_structure_man                                                   AS classStructureMan
        FROM
            station_class_structure                                                  AS T2
        <where>
            <if test="stationId !=null">
                T2.station_id= #{stationId}
            </if>
            <if test="classStructureNo !=null">
                AND T2.class_structure_no= #{classStructureNo}
            </if>
        </where>
        ORDER BY  T2.class_structure_no ASC LIMIT 0,1
    </sql>


    <sql id="selectStationClassStructureVo">
        select id, order_no, station_id, station_name, oil_gun, oil_name, oil_pirce, oil_type, consumer_id, consumer, amt, order_liters, pay_type, pay_way, pay_date, oil_personnel, oil_personnel_id, order_type, print_num, class_structure_no, class_start_date, class_structure_date, class_structure_man, oils, receivable_amt, received_amt, discount_amt, discount_coupon_amt, discount_coupon, wx_amt, zfb_amt, pos_amt, xj_amt, didi_app_amt, ty_app_amt, other_amt, dzk_amt, score, member_no, member_amt, car_no, customer_phone, customer_grade from station_class_structure
    </sql>

    <select id="selectStationClassStructureList" parameterType="com.platform.yijia.pojo.StationClassStructure" resultMap="StationClassStructureResult">
        <include refid="selectStationClassStructureVo"/>
        <where>
            <if test="orderNo != null  and orderNo != ''"> and order_no = #{orderNo}</if>
            <if test="stationId != null "> and station_id = #{stationId}</if>
            <if test="stationName != null  and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
            <if test="oilGun != null  and oilGun != ''"> and oil_gun = #{oilGun}</if>
            <if test="oilName != null  and oilName != ''"> and oil_name like concat('%', #{oilName}, '%')</if>
            <if test="oilPirce != null "> and oil_pirce = #{oilPirce}</if>
            <if test="oilType != null  and oilType != ''"> and oil_type = #{oilType}</if>
            <if test="consumerId != null "> and consumer_id = #{consumerId}</if>
            <if test="consumer != null  and consumer != ''"> and consumer = #{consumer}</if>
            <if test="amt != null "> and amt = #{amt}</if>
            <if test="orderLiters != null "> and order_liters = #{orderLiters}</if>
            <if test="payType != null  and payType != ''"> and pay_type = #{payType}</if>
            <if test="payWay != null  and payWay != ''"> and pay_way = #{payWay}</if>
            <if test="payDate != null "> and pay_date = #{payDate}</if>
            <if test="oilPersonnel != null  and oilPersonnel != ''"> and oil_personnel = #{oilPersonnel}</if>
            <if test="oilPersonnelId != null  and oilPersonnelId != ''"> and oil_personnel_id = #{oilPersonnelId}</if>
            <if test="orderType != null  and orderType != ''"> and order_type = #{orderType}</if>
            <if test="printNum != null "> and print_num = #{printNum}</if>
            <if test="classStructureNo != null  and classStructureNo != ''"> and class_structure_no = #{classStructureNo}</if>
            <if test="classStartDate != null "> and class_start_date = #{classStartDate}</if>
            <if test="classStructureDate != null "> and class_structure_date = #{classStructureDate}</if>
            <if test="classStructureMan != null  and classStructureMan != ''"> and class_structure_man = #{classStructureMan}</if>
            <if test="oils != null  and oils != ''"> and oils = #{oils}</if>
            <if test="receivableAmt != null "> and receivable_amt = #{receivableAmt}</if>
            <if test="receivedAmt != null "> and received_amt = #{receivedAmt}</if>
            <if test="discountAmt != null "> and discount_amt = #{discountAmt}</if>
            <if test="discountCouponAmt != null "> and discount_coupon_amt = #{discountCouponAmt}</if>
            <if test="discountCoupon != null  and discountCoupon != ''"> and discount_coupon = #{discountCoupon}</if>
            <if test="wxAmt != null "> and wx_amt = #{wxAmt}</if>
            <if test="zfbAmt != null "> and zfb_amt = #{zfbAmt}</if>
            <if test="posAmt != null "> and pos_amt = #{posAmt}</if>
            <if test="xjAmt != null "> and xj_amt = #{xjAmt}</if>
            <if test="didiAppAmt != null "> and didi_app_amt = #{didiAppAmt}</if>
            <if test="tyAppAmt != null "> and ty_app_amt = #{tyAppAmt}</if>
            <if test="otherAmt != null "> and other_amt = #{otherAmt}</if>
            <if test="dzkAmt != null "> and dzk_amt = #{dzkAmt}</if>
            <if test="score != null "> and score = #{score}</if>
            <if test="memberNo != null  and memberNo != ''"> and member_no = #{memberNo}</if>
            <if test="memberAmt != null "> and member_amt = #{memberAmt}</if>
            <if test="carNo != null  and carNo != ''"> and car_no = #{carNo}</if>
            <if test="customerPhone != null  and customerPhone != ''"> and customer_phone = #{customerPhone}</if>
            <if test="customerGrade != null  and customerGrade != ''"> and customer_grade = #{customerGrade}</if>
        </where>
        order by  id desc
    </select>

    <select id="listPersonnelStructure" parameterType="com.platform.yijia.pojo.StationClassStructure" resultMap="StationClassStructureResult">
        SELECT a.oil_personnel,GROUP_CONCAT(DISTINCT a.oil_gun) as oil_gun,ROUND(SUM(a.amt),2) as amt,ROUND(SUM(order_liters),2) as order_liters,COUNT(order_no) as order_no
        from station_class_structure a
        <where>
            <if test="stationId != null "> and a.station_id = #{stationId}</if>
            <if test="classStructureNo != null and classStructureNo != ''"> and class_structure_no = #{classStructureNo}</if>
        </where>
        GROUP BY a.oil_personnel
    </select>

    <select id="listOilStructure" parameterType="com.platform.yijia.pojo.StationClassStructure" resultMap="StationClassStructureResult">
       	SELECT a.station_id, a.oil_name,GROUP_CONCAT(DISTINCT oil_gun) as oil_gun,ROUND(SUM(a.amt),2) as amt,ROUND(SUM(a.receivable_amt),2) as receivable_amt,ROUND(SUM(order_liters),2) as order_liters,ROUND(SUM(a.discount_amt),2) as discount_amt ,COUNT(order_no) as order_no,a.class_start_date,a.class_structure_date,a.class_structure_man,sum(a.print_num) print_num
        from station_class_structure a
        <where>
            <if test="stationId != null "> and a.station_id = #{stationId}</if>
            <if test="classStructureNo != null and classStructureNo != ''"> and class_structure_no = #{classStructureNo}</if>
        </where>
        GROUP BY a.oil_name,a.station_id,a.class_start_date,a.class_structure_date,a.class_structure_man
    </select>
    <select id="selectStationClassStructureMax" parameterType="com.platform.yijia.pojo.StationClassStructure" resultMap="StationClassStructureResult">
        select id, station_id, order_no, oil_gun, oil_name, consumer_id, consumer, amt, station_name, order_liters, pay_type, pay_way, pay_date, oil_personnel, order_type, oil_type, print_num, class_structure_no, class_structure_date, class_structure_man, oils
         from station_class_structure
       	 where id = (
            SELECT MAX(id) from station_class_structure
            <where>
                <if test="stationId != null "> and station_id = #{stationId}</if>
            </where>
		)
    </select>

    <select id="selectStationClassStructureById" parameterType="Long" resultMap="StationClassStructureResult">
        <include refid="selectStationClassStructureVo"/>
        where id = #{id}
    </select>
    <select id="selectDistnctClassStructure" parameterType="com.platform.yijia.pojo.StationClassStructure" resultMap="StationClassStructureResult">
      select count(DISTINCT class_structure_no) as num
            from station_class_structure
        <where>
            <if test="stationId != null and stationId != ''"> and station_id = #{stationId}</if>
            <if test="likeClassStructureNo != null  and likeClassStructureNo != ''">  and class_structure_no like concat( #{likeClassStructureNo}, '%') </if>
        </where>
    </select>
    <!--根据班次号汇总班结数据-->
    <select id="selectSummyClassStructure" parameterType="com.platform.yijia.pojo.StationClassStructure" resultMap="StationClassStructureResult">
        SELECT
            class_structure_no,
            class_start_date,
            class_structure_date,
            station_id,
            station_name,
            count(order_no) as num,
            sum(order_liters) as order_liters,
            sum(amt) as amt,
            sum(receivable_amt)   AS receivable_amt,
            sum(wx_amt) as wx_amt,
            sum(zfb_amt) as zfb_amt,
            sum(pos_amt) as pos_amt,
            sum(dzk_amt) as dzk_amt,
            sum(xj_amt) as xj_amt,
            sum(other_amt) as other_amt,
            SUM(print_num)      AS print_num,
            SUM(discount_amt)   AS discount_amt,
            class_structure_man
        from station_class_structure
        <where>
            <if test="stationId != null and stationId != ''"> and station_id = #{stationId}</if>
            <if test="classStructureNo != null and classStructureNo != ''"> and class_structure_no = #{classStructureNo}</if>
        </where>
        GROUP BY class_structure_no,class_start_date,station_id,station_name,class_structure_date,class_structure_man
    </select>

    <!--按员工/支付方式汇总数据-->
    <select id="listPersonnelPayStructure" parameterType="com.platform.yijia.pojo.StationClassStructure" resultMap="StationClassStructureResult">
        SELECT oil_personnel,GROUP_CONCAT(DISTINCT oil_gun) oil_gun,count(wx_amt) wx_num,count(zfb_amt) zfb_num,count(xj_amt) xj_num,sum(discount_amt) discount_amt,SUM(discount_coupon_amt) discount_coupon_amt,SUM(wx_amt) wx_amt,SUM(zfb_amt) zfb_amt,SUM(xj_amt) xj_amt,sum(member_amt) member_amt
        from  station_class_structure
        <where>
            <if test="stationId != null and stationId != ''"> and station_id = #{stationId}</if>
            <if test="classStructureNo != null and classStructureNo != ''"> and class_structure_no = #{classStructureNo}</if>
        </where>
        GROUP BY oil_personnel
    </select>

    <select id="listClass" parameterType="com.platform.yijia.pojo.StationClassStructure" resultMap="StationClassStructureResult">
        SELECT *  from
        station_class_structure
        where id =(SELECT max(id) from station_class_structure
            <where>
                <if test="classStructureMan != null and classStructureMan != ''"> and class_structure_man = #{classStructureMan}</if>
                <if test="classStructureNo != null and classStructureNo != ''"> and class_structure_no = #{classStructureNo}</if>
            </where>
        )
    </select>

    <!--批量插入-->
    <insert id="insertStationClassStructureBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">

        <foreach collection="stationClassStructureList" item="item" index="index" separator=",">
            INSERT INTO
            station_class_structure
            <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="item.orderNo != null">order_no,</if>
                <if test="item.stationId != null">station_id,</if>
                <if test="item.stationName != null">station_name,</if>
                <if test="item.oilGun != null">oil_gun,</if>
                <if test="item.oilName != null">oil_name,</if>
                <if test="item.oilPirce != null">oil_pirce,</if>
                <if test="item.oilType != null">oil_type,</if>
                <if test="item.consumerId != null">consumer_id,</if>
                <if test="item.consumer != null">consumer,</if>
                <if test="item.amt != null">amt,</if>
                <if test="item.orderLiters != null">order_liters,</if>
                <if test="item.payType != null">pay_type,</if>
                <if test="item.payWay != null">pay_way,</if>
                <if test="item.payDate != null">pay_date,</if>
                <if test="item.oilPersonnel != null">oil_personnel,</if>
                <if test="item.orderType != null">order_type,</if>
                <if test="item.printNum != null">print_num,</if>
                <if test="item.classStructureNo != null">class_structure_no,</if>
                <if test="item.classStartDate != null">class_start_date,</if>
                <if test="item.classStructureDate != null">class_structure_date,</if>
                <if test="item.classStructureMan != null">class_structure_man,</if>
                <if test="item.oils != null">oils,</if>
                <if test="item.receivableAmt != null">receivable_amt,</if>
                <if test="item.receivedAmt != null">received_amt,</if>
                <if test="item.discountAmt != null">discount_amt,</if>
                <if test="item.discountCouponAmt != null">discount_coupon_amt,</if>
                <if test="item.discountCoupon != null">discount_coupon,</if>
                <if test="item.wxAmt != null">wx_amt,</if>
                <if test="item.zfbAmt != null">zfb_amt,</if>
                <if test="item.posAmt != null">pos_amt,</if>
                <if test="item.xjAmt != null">xj_amt,</if>
                <if test="item.didiAppAmt != null">didi_app_amt,</if>
                <if test="item.tyAppAmt != null">ty_app_amt,</if>
                <if test="item.otherAmt != null">other_amt,</if>
                <if test="item.dzkAmt != null">dzk_amt,</if>
                <if test="item.score != null">score,</if>
                <if test="item.memberNo != null">member_no,</if>
                <if test="item.memberAmt != null">member_amt,</if>
                <if test="item.carNo != null">car_no,</if>
                <if test="item.customerPhone != null">customer_phone,</if>
                <if test="item.customerGrade != null">customer_grade,</if>
            </trim>
            VALUES
            <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="item.orderNo != null">#{item.orderNo},</if>
                <if test="item.stationId != null">#{item.stationId},</if>
                <if test="item.stationName != null">#{item.stationName},</if>
                <if test="item.oilGun != null">#{item.oilGun},</if>
                <if test="item.oilName != null">#{item.oilName},</if>
                <if test="item.oilPirce != null">#{item.oilPirce},</if>
                <if test="item.oilType != null">#{item.oilType},</if>
                <if test="item.consumerId != null">#{item.consumerId},</if>
                <if test="item.consumer != null">#{item.consumer},</if>
                <if test="item.amt != null">#{item.amt},</if>
                <if test="item.orderLiters != null">#{item.orderLiters},</if>
                <if test="item.payType != null">#{item.payType},</if>
                <if test="item.payWay != null">#{item.payWay},</if>
                <if test="item.payDate != null">#{item.payDate},</if>
                <if test="item.oilPersonnel != null">#{item.oilPersonnel},</if>
                <if test="item.orderType != null">#{item.orderType},</if>
                <if test="item.printNum != null">#{item.printNum},</if>
                <if test="item.classStructureNo != null">#{item.classStructureNo},</if>
                <if test="item.classStartDate != null">#{item.classStartDate},</if>
                <if test="item.classStructureDate != null">#{item.classStructureDate},</if>
                <if test="item.classStructureMan != null">#{item.classStructureMan},</if>
                <if test="item.oils != null">#{item.oils},</if>
                <if test="item.receivableAmt != null">#{item.receivableAmt},</if>
                <if test="item.receivedAmt != null">#{item.receivedAmt},</if>
                <if test="item.discountAmt != null">#{item.discountAmt},</if>
                <if test="item.discountCouponAmt != null">#{item.discountCouponAmt},</if>
                <if test="item.discountCoupon != null">#{item.discountCoupon},</if>
                <if test="item.wxAmt != null">#{item.wxAmt},</if>
                <if test="item.zfbAmt != null">#{item.zfbAmt},</if>
                <if test="item.posAmt != null">#{item.posAmt},</if>
                <if test="item.xjAmt != null">#{item.xjAmt},</if>
                <if test="item.didiAppAmt != null">#{item.didiAppAmt},</if>
                <if test="item.tyAppAmt != null">#{item.tyAppAmt},</if>
                <if test="item.otherAmt != null">#{item.otherAmt},</if>
                <if test="item.dzkAmt != null">#{item.dzkAmt},</if>
                <if test="item.score != null">#{item.score},</if>
                <if test="item.memberNo != null">#{item.memberNo},</if>
                <if test="item.memberAmt != null">#{item.memberAmt},</if>
                <if test="item.carNo != null">#{item.carNo},</if>
                <if test="item.customerPhone != null">#{item.customerPhone},</if>
                <if test="item.customerGrade != null">#{item.customerGrade},</if>
            </trim>
        </foreach>
    </insert>


    <insert id="insertStationClassStructure" parameterType="com.platform.yijia.pojo.StationClassStructure" useGeneratedKeys="true" keyProperty="id">
        insert into station_class_structure
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderNo != null">order_no,</if>
            <if test="stationId != null">station_id,</if>
            <if test="stationName != null">station_name,</if>
            <if test="oilGun != null">oil_gun,</if>
            <if test="oilName != null">oil_name,</if>
            <if test="oilPirce != null">oil_pirce,</if>
            <if test="oilType != null">oil_type,</if>
            <if test="consumerId != null">consumer_id,</if>
            <if test="consumer != null">consumer,</if>
            <if test="amt != null">amt,</if>
            <if test="orderLiters != null">order_liters,</if>
            <if test="payType != null">pay_type,</if>
            <if test="payWay != null">pay_way,</if>
            <if test="payDate != null">pay_date,</if>
            <if test="oilPersonnel != null">oil_personnel,</if>
            <if test="oilPersonnelId != null">oil_personnel_id,</if>
            <if test="orderType != null">order_type,</if>
            <if test="printNum != null">print_num,</if>
            <if test="classStructureNo != null">class_structure_no,</if>
            <if test="classStartDate != null">class_start_date,</if>
            <if test="classStructureDate != null">class_structure_date,</if>
            <if test="classStructureMan != null">class_structure_man,</if>
            <if test="oils != null">oils,</if>
            <if test="receivableAmt != null">receivable_amt,</if>
            <if test="receivedAmt != null">received_amt,</if>
            <if test="discountAmt != null">discount_amt,</if>
            <if test="discountCouponAmt != null">discount_coupon_amt,</if>
            <if test="discountCoupon != null">discount_coupon,</if>
            <if test="wxAmt != null">wx_amt,</if>
            <if test="zfbAmt != null">zfb_amt,</if>
            <if test="posAmt != null">pos_amt,</if>
            <if test="xjAmt != null">xj_amt,</if>
            <if test="didiAppAmt != null">didi_app_amt,</if>
            <if test="tyAppAmt != null">ty_app_amt,</if>
            <if test="otherAmt != null">other_amt,</if>
            <if test="dzkAmt != null">dzk_amt,</if>
            <if test="score != null">score,</if>
            <if test="memberNo != null">member_no,</if>
            <if test="memberAmt != null">member_amt,</if>
            <if test="carNo != null">car_no,</if>
            <if test="customerPhone != null">customer_phone,</if>
            <if test="customerGrade != null">customer_grade,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderNo != null">#{orderNo},</if>
            <if test="stationId != null">#{stationId},</if>
            <if test="stationName != null">#{stationName},</if>
            <if test="oilGun != null">#{oilGun},</if>
            <if test="oilName != null">#{oilName},</if>
            <if test="oilPirce != null">#{oilPirce},</if>
            <if test="oilType != null">#{oilType},</if>
            <if test="consumerId != null">#{consumerId},</if>
            <if test="consumer != null">#{consumer},</if>
            <if test="amt != null">#{amt},</if>
            <if test="orderLiters != null">#{orderLiters},</if>
            <if test="payType != null">#{payType},</if>
            <if test="payWay != null">#{payWay},</if>
            <if test="payDate != null">#{payDate},</if>
            <if test="oilPersonnel != null">#{oilPersonnel},</if>
            <if test="oilPersonnelId != null">#{oilPersonnelId},</if>
            <if test="orderType != null">#{orderType},</if>
            <if test="printNum != null">#{printNum},</if>
            <if test="classStructureNo != null">#{classStructureNo},</if>
            <if test="classStartDate != null">#{classStartDate},</if>
            <if test="classStructureDate != null">#{classStructureDate},</if>
            <if test="classStructureMan != null">#{classStructureMan},</if>
            <if test="oils != null">#{oils},</if>
            <if test="receivableAmt != null">#{receivableAmt},</if>
            <if test="receivedAmt != null">#{receivedAmt},</if>
            <if test="discountAmt != null">#{discountAmt},</if>
            <if test="discountCouponAmt != null">#{discountCouponAmt},</if>
            <if test="discountCoupon != null">#{discountCoupon},</if>
            <if test="wxAmt != null">#{wxAmt},</if>
            <if test="zfbAmt != null">#{zfbAmt},</if>
            <if test="posAmt != null">#{posAmt},</if>
            <if test="xjAmt != null">#{xjAmt},</if>
            <if test="didiAppAmt != null">#{didiAppAmt},</if>
            <if test="tyAppAmt != null">#{tyAppAmt},</if>
            <if test="otherAmt != null">#{otherAmt},</if>
            <if test="dzkAmt != null">#{dzkAmt},</if>
            <if test="score != null">#{score},</if>
            <if test="memberNo != null">#{memberNo},</if>
            <if test="memberAmt != null">#{memberAmt},</if>
            <if test="carNo != null">#{carNo},</if>
            <if test="customerPhone != null">#{customerPhone},</if>
            <if test="customerGrade != null">#{customerGrade},</if>
         </trim>
    </insert>

    <update id="updateStationClassStructure" parameterType="com.platform.yijia.pojo.StationClassStructure">
        update station_class_structure
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderNo != null">order_no = #{orderNo},</if>
            <if test="stationId != null">station_id = #{stationId},</if>
            <if test="stationName != null">station_name = #{stationName},</if>
            <if test="oilGun != null">oil_gun = #{oilGun},</if>
            <if test="oilName != null">oil_name = #{oilName},</if>
            <if test="oilPirce != null">oil_pirce = #{oilPirce},</if>
            <if test="oilType != null">oil_type = #{oilType},</if>
            <if test="consumerId != null">consumer_id = #{consumerId},</if>
            <if test="consumer != null">consumer = #{consumer},</if>
            <if test="amt != null">amt = #{amt},</if>
            <if test="orderLiters != null">order_liters = #{orderLiters},</if>
            <if test="payType != null">pay_type = #{payType},</if>
            <if test="payWay != null">pay_way = #{payWay},</if>
            <if test="payDate != null">pay_date = #{payDate},</if>
            <if test="oilPersonnel != null">oil_personnel = #{oilPersonnel},</if>
            <if test="oilPersonnelId != null">oil_personnel_id = #{oilPersonnelId},</if>
            <if test="orderType != null">order_type = #{orderType},</if>
            <if test="printNum != null">print_num = #{printNum},</if>
            <if test="classStructureNo != null">class_structure_no = #{classStructureNo},</if>
            <if test="classStartDate != null">class_start_date = #{classStartDate},</if>
            <if test="classStructureDate != null">class_structure_date = #{classStructureDate},</if>
            <if test="classStructureMan != null">class_structure_man = #{classStructureMan},</if>
            <if test="oils != null">oils = #{oils},</if>
            <if test="receivableAmt != null">receivable_amt = #{receivableAmt},</if>
            <if test="receivedAmt != null">received_amt = #{receivedAmt},</if>
            <if test="discountAmt != null">discount_amt = #{discountAmt},</if>
            <if test="discountCouponAmt != null">discount_coupon_amt = #{discountCouponAmt},</if>
            <if test="discountCoupon != null">discount_coupon = #{discountCoupon},</if>
            <if test="wxAmt != null">wx_amt = #{wxAmt},</if>
            <if test="zfbAmt != null">zfb_amt = #{zfbAmt},</if>
            <if test="posAmt != null">pos_amt = #{posAmt},</if>
            <if test="xjAmt != null">xj_amt = #{xjAmt},</if>
            <if test="didiAppAmt != null">didi_app_amt = #{didiAppAmt},</if>
            <if test="tyAppAmt != null">ty_app_amt = #{tyAppAmt},</if>
            <if test="otherAmt != null">other_amt = #{otherAmt},</if>
            <if test="dzkAmt != null">dzk_amt = #{dzkAmt},</if>
            <if test="score != null">score = #{score},</if>
            <if test="memberNo != null">member_no = #{memberNo},</if>
            <if test="memberAmt != null">member_amt = #{memberAmt},</if>
            <if test="carNo != null">car_no = #{carNo},</if>
            <if test="customerPhone != null">customer_phone = #{customerPhone},</if>
            <if test="customerGrade != null">customer_grade = #{customerGrade},</if>
        </trim>
        where id = #{id}
    </update>

</mapper>
