OrderBackDetailSMapper.xml 12 KB
<?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.zteits.order.mapper.smapper.OrderBackDetailSMapper">
    <resultMap id="BaseResultMap" type="com.zteits.order.domain.OrderBackDetail">
        <id column="id" jdbcType="BIGINT" property="id" />
        <result column="detail_order_id" jdbcType="VARCHAR" property="detailOrderId" />
        <result column="order_big_type" jdbcType="INTEGER" property="orderBigType" />
        <result column="terminal_source" jdbcType="INTEGER" property="terminalSource" />
        <result column="order_id" jdbcType="VARCHAR" property="orderId" />
        <result column="rlt_order_id" jdbcType="VARCHAR" property="rltOrderId" />
        <result column="pre_pl_no" jdbcType="VARCHAR" property="prePlNo" />
        <result column="pre_pl_name" jdbcType="VARCHAR" property="prePlName" />
        <result column="back_dicount_fee" jdbcType="BIGINT" property="backDicountFee" />
        <result column="back_act_fee" jdbcType="BIGINT" property="backActFee" />
        <result column="back_total_fee" jdbcType="BIGINT" property="backTotalFee" />
        <result column="car_number" jdbcType="VARCHAR" property="carNumber" />
        <result column="car_number_color" jdbcType="INTEGER" property="carNumberColor" />
        <result column="car_type" jdbcType="INTEGER" property="carType" />
        <result column="park_in_time" jdbcType="TIMESTAMP" property="parkInTime" />
        <result column="park_out_time" jdbcType="TIMESTAMP" property="parkOutTime" />
        <result column="parking_duration" jdbcType="BIGINT" property="parkingDuration" />
        <result column="data_state" jdbcType="INTEGER" property="dataState" />
        <result column="back_emp_id" jdbcType="VARCHAR" property="backEmpId" />
        <result column="back_emp_name" jdbcType="VARCHAR" property="backEmpName" />
        <result column="create_emp_id" jdbcType="VARCHAR" property="createEmpId" />
        <result column="create_emp_name" jdbcType="VARCHAR" property="createEmpName" />
        <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
        <result column="modfiy_emp_id" jdbcType="VARCHAR" property="modfiyEmpId" />
        <result column="modfiy_date" jdbcType="TIMESTAMP" property="modfiyDate" />
        <result column="remark" jdbcType="VARCHAR" property="remark" />
        <result column="back_pl_no" jdbcType="VARCHAR" property="backPlNo" />
        <result column="back_pl_name" jdbcType="VARCHAR" property="backPlName" />
        <result column="back_pay_type" jdbcType="INTEGER" property="backPayType" />
        <result column="back_terminal_source" jdbcType="INTEGER" property="backTerminalSource" />
        <result column="pay_finish_time" jdbcType="TIMESTAMP" property="payFinishTime" />
        <result column="pay_order_id" jdbcType="VARCHAR" property="payOrderId" />
        <result column="third_disc_fee" jdbcType="BIGINT" property="thirdDiscFee" />
    </resultMap>
    <sql id="Base_Column_List">
        id, detail_order_id, order_big_type, terminal_source, order_id, rlt_order_id, pre_pl_no,
    pre_pl_name, back_dicount_fee, back_act_fee, back_total_fee, car_number, car_number_color,
    car_type, park_in_time, park_out_time, parking_duration, data_state, back_emp_id,
    back_emp_name, create_emp_id, create_emp_name, create_date, modfiy_emp_id, modfiy_date,
    remark, back_pl_no, back_pl_name, back_pay_type, back_terminal_source, pay_finish_time,
    pay_order_id, third_disc_fee
    </sql>

    <select id="pageQueryBackOrderDetailByCondition"
            parameterType="com.zteits.clouds.api.dto.order.backorder.param.BackOrderDetailPageQueryByContidionReq"
            resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM order_back_detail
        <where>
            data_state = 1
            <if test="carNumber != null">
                AND car_number LIKE contact ('%',#{carNumber},'%')
            </if>
            <if test="carNumberColor != null">
                AND car_number_color = #{carNumberColor}
            </if>
            <if test="orderId != null">
                AND order_id =#{orderId}
            </if>
            <if test="rltOrderId != null">
                AND rlt_order_id =#{rltOrderId}
            </if>
            <if test="prePlNos != null and prePlNos.size >0">
                AND pre_pl_no IN
                <foreach collection="prePlNos" open="(" close=")" item="prePlNo" separator=",">
                    #{prePlNo}
                </foreach>
            </if>
            <if test="orderIds != null and orderIds.size >0">
                AND order_id IN
                <foreach collection="orderIds" open="(" close=")" item="orderId" separator=",">
                    #{orderId}
                </foreach>
            </if>
        </where>
        order by create_date  desc
    </select>

    <!-- -->
    <select id="queryCurrentOrderBackByTimeForFinanceBill" resultType="com.zteits.order.domain.IncomeFinanceBill">

       SELECT

                    /**当天补缴实收*/
                    IFNULL(sum( IFNULL(a.back_act_fee, 0)),0)  as currentBackActFeeTotal,
                    /**当天补缴优惠*/
                    IFNULL(sum(IFNULL(a.back_dicount_fee, 0)),0)  as currentBackDicountFeeTotal,
                    /**当天第三方补缴优惠*/
                    IFNULL(sum(CASE WHEN  a.back_pay_type = 34 THEN  IFNULL(a.third_disc_fee, 0)ELSE 0 END),0) currentBackThirdDiscFee,
                    /**当天补缴支付宝实收*/
                    IFNULL(sum(CASE WHEN  a.back_pay_type = 1 THEN  IFNULL(a.back_act_fee, 0)ELSE 0 END),0) currentBackAliFee,
                    /**当天补缴支付宝次数*/
                    IFNULL(sum(CASE WHEN  a.back_pay_type = 1 THEN 1 ELSE 0 END),0) currentBackAliChargeNum,
                     /**当天补缴etc实收*/
                    IFNULL(sum(CASE WHEN  a.back_pay_type = 32 THEN  IFNULL(a.back_act_fee, 0)ELSE 0 END),0) currentBackEtcFee,
                    /**当天补缴etc次数*/
                    IFNULL(sum(CASE WHEN  a.back_pay_type = 32 THEN 1 ELSE 0 END),0) currentBackEtcChargeNum,
                     /**当天补缴农行实收*/
                    IFNULL(sum(CASE WHEN  a.back_pay_type = 34 THEN  IFNULL(a.back_act_fee, 0)ELSE 0 END),0) currentBackAbcFee,
                    /**当天补缴农行次数*/
                    IFNULL(sum(CASE WHEN  a.back_pay_type = 34 THEN 1 ELSE 0 END),0) currentBackAbcChargeNum,
                    /**当天补缴微信收入*/
                    IFNULL(sum(CASE WHEN  a.back_pay_type IN (2, 4) THEN IFNULL(a.back_act_fee, 0) ELSE 0 END),0) currentBackWxFee,
                    /**当天补缴微信次数*/
                    IFNULL(sum(CASE WHEN  a.back_pay_type IN (2, 4) THEN 1 ELSE 0 END),0) currentBackWxChargeNum,
                    /**当天补缴余额收入*/
                    IFNULL(sum(CASE WHEN  a.back_pay_type = 5 THEN IFNULL(a.back_act_fee, 0)  ELSE 0 END),0) currentBackBalanceFee,
                    /**当天补缴余额次数*/
                     IFNULL(sum(CASE WHEN  a.back_pay_type=5 THEN 1 ELSE 0 END),0) currentBackBalanceChargeNum,
                    /**当天补缴现金收入*/
                    IFNULL(sum(CASE WHEN  a.back_pay_type = 6 THEN IFNULL(a.back_act_fee, 0) ELSE 0 END),0) currentBackCashFee,
                    /**当天补缴现金次数*/
                    IFNULL(sum(CASE WHEN  a.back_pay_type=6 THEN 1 ELSE 0 END),0) currentBackCashChargeNum
            FROM  order_back_detail a
            where 1=1
                and a.park_out_time BETWEEN #{startTime} AND #{endTime}
                AND a.pay_finish_time BETWEEN #{startTime} AND #{endTime}
                AND a.back_pay_type IN (1,2,4,5,6,32,34)
                AND a.back_pl_no=#{plNo}
    </select>
    <select id="queryCurrentOrderBackByTimeAndChargerCodeForFinanceBill"
            resultType="com.zteits.order.domain.IncomeFinanceBill">
        SELECT
            a.terminal_source as terminalSource,
            /**当天补缴实收*/
            IFNULL(sum( IFNULL(a.back_act_fee, 0)),0)  as currentBackActFeeTotal,
            /**当天补缴优惠*/
            IFNULL(sum(IFNULL(a.back_dicount_fee, 0)),0)  as currentBackDicountFeeTotal,
            /**当天第三方补缴优惠*/
            IFNULL(sum(CASE WHEN  a.back_pay_type = 34 THEN  IFNULL(a.third_disc_fee, 0)ELSE 0 END),0) currentBackThirdDiscFee,
            /**当天补缴支付宝实收*/
            IFNULL(sum(CASE WHEN  a.back_pay_type = 1 THEN  IFNULL(a.back_act_fee, 0)ELSE 0 END),0) currentBackAliFee,
            /**当天补缴支付宝次数*/
            IFNULL(sum(CASE WHEN  a.back_pay_type = 1 THEN 1 ELSE 0 END),0) currentBackAliChargeNum,
            /**当天补缴etc实收*/
            IFNULL(sum(CASE WHEN  a.back_pay_type = 32 THEN  IFNULL(a.back_act_fee, 0)ELSE 0 END),0) currentBackEtcFee,
            /**当天补缴etc次数*/
            IFNULL(sum(CASE WHEN  a.back_pay_type = 32 THEN 1 ELSE 0 END),0) currentBackEtcChargeNum,
            /**当天补缴农行实收*/
            IFNULL(sum(CASE WHEN  a.back_pay_type = 34 THEN  IFNULL(a.back_act_fee, 0)ELSE 0 END),0) currentBackAbcFee,
            /**当天补缴农行次数*/
            IFNULL(sum(CASE WHEN  a.back_pay_type = 34 THEN 1 ELSE 0 END),0) currentBackAbcChargeNum,
            /**当天补缴微信收入*/
            IFNULL(sum(CASE WHEN  a.back_pay_type = 2  THEN IFNULL(a.back_act_fee, 0) ELSE 0 END),0) currentBackWxFee,
            /**当天补缴微信次数*/
            IFNULL(sum(CASE WHEN  a.back_pay_type = 2 THEN 1 ELSE 0 END),0) currentBackWxChargeNum,
             /**当天补缴微信收入*/
            IFNULL(sum(CASE WHEN  a.back_pay_type = 4 THEN IFNULL(a.back_act_fee, 0) ELSE 0 END),0) currentBackWxPubFee,
            /**当天补缴微信次数*/
            IFNULL(sum(CASE WHEN  a.back_pay_type = 4 THEN 1 ELSE 0 END),0) currentBackWxPubChargeNum,
            /**当天补缴余额收入*/
            IFNULL(sum(CASE WHEN  a.back_pay_type = 5 THEN IFNULL(a.back_act_fee, 0)  ELSE 0 END),0) currentBackBalanceFee,
            /**当天补缴余额次数*/
            IFNULL(sum(CASE WHEN  a.back_pay_type=5 THEN 1 ELSE 0 END),0) currentBackBalanceChargeNum,
            /**当天补缴现金收入*/
            IFNULL(sum(CASE WHEN  a.back_pay_type = 6 THEN IFNULL(a.back_act_fee, 0) ELSE 0 END),0) currentBackCashFee,
            /**当天补缴现金次数*/
            IFNULL(sum(CASE WHEN  a.back_pay_type=6 THEN 1 ELSE 0 END),0) currentBackCashChargeNum
        FROM  order_back_detail a
        where 1=1
          AND a.pay_finish_time BETWEEN #{startTime} AND #{endTime}
          AND a.back_emp_id=#{chargerCode}
          GROUP BY a.terminal_source
    </select>
    <select id="queryOrderBackDetailCurrentFeeInfoByChargerCode"
            resultType="com.zteits.clouds.api.dto.order.backorder.dto.OrderBackDetailCurrentFeeInfoDTO">

        select

            ifnull(sum(t.back_total_fee), 0)                                                           backTotalFee,
            ifnull(sum(t.back_act_fee), 0)                                                             backActFee,
            ifnull(sum(t.third_disc_fee), 0)                                                           thirdDiscFee,
            ifnull(sum(t.back_dicount_fee), 0)                                                         backDicountFee,
            ifnull(sum(IF(date(t.park_out_time) = date(t.pay_finish_time), t.back_total_fee, 0)), 0)   currentBackTotalFee,
            ifnull(sum(IF(date(t.park_out_time) = date(t.pay_finish_time), t.back_act_fee, 0)), 0)     currentBackActFee,
            ifnull(sum(IF(date(t.park_out_time) = date(t.pay_finish_time), t.third_disc_fee, 0)), 0)   currentThirdDiscFee,
            ifnull(sum(IF(date(t.park_out_time) = date(t.pay_finish_time), t.back_dicount_fee, 0)), 0) currentBackDicountFee


        from order_back_detail t
        where t.data_state = 1
          and t.back_emp_id = #{chargerCode}
          and t.pay_finish_time between #{startTime} and #{endTime}


    </select>


</mapper>