<?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.yijia.station.mapper.StationClassStructureMapper">

    <resultMap type="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="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>

    <sql id="selectStationClassStructureVo">
        select id, order_no, station_id, d.dept_name as station_name, oil_gun, oil_name, oil_pirce, oil_type,
        consumer_id, consumer, amt, order_liters, pay_type, pay_way, pay_date, oil_personnel, 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 s join sys_dept d on s.station_id = d.dept_id
    </sql>

    <select id="selectStationClassStructureList" parameterType="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="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 like concat('%', #{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="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="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>
            <if test="orderType != null  and orderType != ''"> and order_type = #{orderType}</if>
        </where>
        GROUP BY a.oil_personnel
    </select>

    <select id="listOilStructure" parameterType="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(a.received_amt),2) as received_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="StationClassStructure" resultMap="StationClassStructureResult">
        select id, station_id, order_no, oil_gun, oil_name, consumer_id, consumer, amt,d.dept_name as 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 s join sys_dept d on s.station_id = d.dept_id
        where id = (
        SELECT MAX(id) from station_class_structure
        <where>
            <if test="stationId != null "> and station_id = #{stationId}</if>
            <if test="orderType != null  and orderType != ''"> and order_type = #{orderType}</if>
        </where>
        )
    </select>

    <select id="selectStationClassStructureById" parameterType="Long" resultMap="StationClassStructureResult">
        <include refid="selectStationClassStructureVo"/>
        where id = #{id}
    </select>
    <select id="selectDistnctClassStructure" parameterType="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>
            <if test="orderType != null  and orderType != ''"> and order_type = #{orderType}</if>
        </where>
    </select>
    <!--根据班次号汇总班结数据-->
    <select id="selectSummyClassStructure" parameterType="StationClassStructure" resultMap="StationClassStructureResult">
        select  class_structure_no,class_start_date,class_structure_date,station_id,d.dept_name as station_name,count(order_no) as num,
        sum(order_liters) as order_liters,sum(receivable_amt) as receivable_amt,sum(amt) as amt,class_structure_man,
        sum(print_num) as print_num,sum(wx_amt) as wx_amt,sum(zfb_amt) as zfb_amt,
        sum(dzk_amt) as dzk_amt,sum(discount_amt) as discount_amt,SUM(pos_amt) as pos_amt,sum(xj_amt) as xj_amt
        from station_class_structure s join sys_dept d on s.station_id = d.dept_id
        <where>
            <if test="stationId != null and stationId != ''"> and station_id = #{stationId}</if>
            <if test="classStructureNo != null and classStructureNo != ''"> and class_structure_no = #{classStructureNo}</if>
            <if test="orderType != null  and orderType != ''"> and order_type = #{orderType}</if>
        </where>
        GROUP BY class_structure_no,class_start_date,station_id,d.dept_name,class_structure_date,class_structure_man
    </select>
    <!--按员工/支付方式汇总数据-->
    <!--    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>-->
    <!--        <if test="orderType != null  and orderType != ''"> and order_type = #{orderType}</if>-->
    <!--    </where>-->
    <!--    GROUP BY oil_personnel-->
    <select id="listPersonnelPayStructure" parameterType="StationClassStructure" resultMap="StationClassStructureResult">
        SELECT   oil_personnel,GROUP_CONCAT(DISTINCT oil_gun) oil_gun,
        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,
        sum(e.xj_num)	xj_num,sum(e.zfb_num)	zfb_num,sum(e.wx_num)	wx_num
        from (
        SELECT station_id,class_structure_no, order_type,oil_personnel,oil_gun,discount_amt,discount_coupon_amt,wx_amt,zfb_amt,xj_amt,member_amt,
        (SELECT COUNT(b.order_no) from station_class_structure b where 1=1 and a.id = b.id and b.pay_type="xj" ) xj_num,
        (SELECT COUNT(c.order_no) from station_class_structure c where 1=1 and a.id = c.id and c.pay_type="zfb" ) zfb_num,
        (SELECT COUNT(d.order_no) from station_class_structure d where 1=1 and a.id = d.id and d.pay_type="wx" ) wx_num
        from station_class_structure  a
        <where>
            <if test="stationId != null and stationId != ''"> and a.station_id = #{stationId}</if>
            <if test="classStructureNo != null and classStructureNo != ''"> and a.class_structure_no = #{classStructureNo}</if>
            <if test="orderType != null  and orderType != ''"> and a.order_type = #{orderType}</if>
        </where>
        ) e
        <where>
            <if test="stationId != null and stationId != ''"> and e.station_id = #{stationId}</if>
            <if test="classStructureNo != null and classStructureNo != ''"> and e.class_structure_no = #{classStructureNo}</if>
            <if test="orderType != null  and orderType != ''"> and e.order_type = #{orderType}</if>
        </where>
        GROUP BY e.oil_personnel
    </select>

    <select id="listClass" parameterType="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>
            <if test="orderType != null  and orderType != ''"> and order_type = #{orderType}</if>
        </where>
        )
    </select>
    <!--根据支付方式汇总数据-->
    <select id="listPayStructure" parameterType="StationClassStructure" resultMap="StationClassStructureResult">
        SELECT dict_label as pay_type,sum(order_liters) as order_liters,sum(discount_amt) as discount_amt,count(order_no) order_no,sum(amt) as amt,sum(receivable_amt) as receivable_amt,sum(received_amt) as received_amt
        from   station_class_structure left JOIN sys_dict_data on dict_value = pay_type and dict_type ='pay_type'
        <where>
            <if test="stationId != null and stationId != ''"> and station_id = #{stationId}</if>
            <if test="classStructureNo != null and classStructureNo != ''"> and class_structure_no = #{classStructureNo}</if>
            <if test="orderType != null  and orderType != ''"> and order_type = #{orderType}</if>
        </where>
        GROUP BY pay_type,dict_label
    </select>
    <!--  根据支付方式汇总数据-->
    <select id="listOilStructureSum" parameterType="StationClassStructure" resultMap="StationClassStructureResult">
        SELECT SUM(amt) as amt,SUM(amt) as amt,SUM(order_liters)  as order_liters,sum(order_no) as order_no
        from (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(a.received_amt),2) as received_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 a.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) c
    </select>

    <!--按员工/支付方式汇总数据-->
    <select id="listPersonnelPayStructureSum" parameterType="StationClassStructure" resultMap="StationClassStructureResult">
        SELECT GROUP_CONCAT(DISTINCT oil_gun) oil_gun,
        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,
        sum(e.xj_num)	xj_num,sum(e.zfb_num)	zfb_num,sum(e.wx_num)	wx_num
        from (SELECT  station_id,class_structure_no, order_type,oil_personnel,oil_gun,discount_amt,discount_coupon_amt,wx_amt,zfb_amt,xj_amt,member_amt,
        (SELECT COUNT(b.order_no) from station_class_structure b where 1=1 and a.id = b.id and b.pay_type="xj" ) xj_num,
        (SELECT COUNT(c.order_no) from station_class_structure c where 1=1 and a.id = c.id and c.pay_type="zfb" ) zfb_num,
        (SELECT COUNT(d.order_no) from station_class_structure d where 1=1 and a.id = d.id and d.pay_type="wx" ) wx_num
        from station_class_structure  a
        <where>
            <if test="stationId != null "> and a.station_id = #{stationId}</if>
            <if test="classStructureNo != null and classStructureNo != ''"> and a.class_structure_no = #{classStructureNo}</if>
            <if test="orderType != null  and orderType != ''"> and a.order_type = #{orderType}</if>
        </where>
        ) e
        <where>
            <if test="stationId != null "> and e.station_id = #{stationId}</if>
            <if test="classStructureNo != null and classStructureNo != ''"> and e.class_structure_no = #{classStructureNo}</if>
            <if test="orderType != null  and orderType != ''"> and e.order_type = #{orderType}</if>
        </where>
    </select>

    <select id="listPersonnelStructureSum" parameterType="StationClassStructure" resultMap="StationClassStructureResult">
        SELECT SUM(amt) as amt,SUM(order_liters) as order_liters,SUM(order_no) as order_no
        from ( 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>
            <if test="orderType != null  and orderType != ''"> and order_type = #{orderType}</if>
        </where>
        GROUP BY a.oil_personnel ) b
    </select>
    <select id="selectStationClassStructureExport" parameterType="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="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="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>
        </where>
        order by  id desc
    </select>

    <insert id="insertStationClassStructure" parameterType="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="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="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="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="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="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="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="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>

    <delete id="deleteStationClassStructureById" parameterType="Long">
        delete from station_class_structure where id = #{id}
    </delete>

    <delete id="deleteStationClassStructureByIds" parameterType="String">
        delete from station_class_structure where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

</mapper>
