TdBCheckDaySMapper.xml 16 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.TdBCheckDaySMapper">
    <resultMap id="BaseResultMap" type="com.zteits.order.domain.TdBCheckDay">
        <id column="id" jdbcType="BIGINT" property="id" />
        <result column="check_date" jdbcType="DATE" property="checkDate" />
        <result column="pl_no" jdbcType="VARCHAR" property="plNo" />
        <result column="pl_name" jdbcType="VARCHAR" property="plName" />
        <result column="area_id" jdbcType="VARCHAR" property="areaId" />
        <result column="area_name" jdbcType="VARCHAR" property="areaName" />
        <result column="check_fee_type" jdbcType="INTEGER" property="checkFeeType" />
        <result column="dicount_fee" jdbcType="BIGINT" property="dicountFee" />
        <result column="act_fee" jdbcType="BIGINT" property="actFee" />
        <result column="total_fee" jdbcType="BIGINT" property="totalFee" />
        <result column="arrearage_fee" jdbcType="BIGINT" property="arrearageFee" />
        <result column="ali_fee" jdbcType="BIGINT" property="aliFee" />
        <result column="ali_charge_num" jdbcType="INTEGER" property="aliChargeNum" />
        <result column="wx_fee" jdbcType="BIGINT" property="wxFee" />
        <result column="wx_charge_num" jdbcType="INTEGER" property="wxChargeNum" />
        <result column="cash_fee" jdbcType="BIGINT" property="cashFee" />
        <result column="cash_charge_num" jdbcType="INTEGER" property="cashChargeNum" />
        <result column="balance_fee" jdbcType="BIGINT" property="balanceFee" />
        <result column="balance_charge_num" jdbcType="INTEGER" property="balanceChargeNum" />
        <result column="data_state" jdbcType="INTEGER" property="dataState" />
        <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_emp_name" jdbcType="VARCHAR" property="modfiyEmpName" />
        <result column="modfiy_date" jdbcType="TIMESTAMP" property="modfiyDate" />
        <result column="remark" jdbcType="VARCHAR" property="remark" />
    </resultMap>
    <sql id="Base_Column_List">
        id, check_date, pl_no, pl_name, area_id, area_name, check_fee_type, dicount_fee,
        act_fee, total_fee, arrearage_fee, ali_fee, ali_charge_num, wx_fee, wx_charge_num,
        cash_fee, cash_charge_num, balance_fee, balance_charge_num, data_state, create_emp_id,
        create_emp_name, create_date, modfiy_emp_id, modfiy_emp_name, modfiy_date, remark
    </sql>
    <select id="querySummaryFeeByType" parameterType="com.zteits.clouds.api.dto.clouds.param.CheckDayRequest"
            resultType="com.zteits.clouds.api.dto.clouds.dto.CheckDayForSummaryDTO">
        select
        /**100 停车收入 **/
        sum( CASE  when check_fee_type=100 THEN dicount_fee ELSE 0 END) as dicountFee,
        sum(CASE  when check_fee_type=100 THEN act_fee ELSE 0 END) as actFee,
        sum(CASE  when check_fee_type=100 THEN total_fee ELSE 0 END) as totalFee,
        sum(CASE  when check_fee_type=100 THEN arrearage_fee ELSE 0 END) as arrearageFee,
        /**200 充值收入 **/
        sum( CASE  when check_fee_type=200 THEN dicount_fee ELSE 0 END) as dicountFeeForRecharge,
        sum(CASE  when check_fee_type=200 THEN act_fee ELSE 0 END) as actFeeForRecharge,
        sum(CASE  when check_fee_type=200 THEN total_fee ELSE 0 END) as totalFeeForRecharge,
        sum(CASE  when check_fee_type=200 THEN arrearage_fee ELSE 0 END) as arrearageFeeForRecharge,
        /**300 301  会员卡收入 **/
        sum( CASE  when check_fee_type in(300,301) THEN dicount_fee ELSE 0 END) as dicountFeeForVIP,
        sum(CASE  when check_fee_type in(300,301) THEN act_fee ELSE 0 END) as actFeeForVIP,
        sum(CASE  when check_fee_type in(300,301) THEN total_fee ELSE 0 END) as totalFeeForVIP,
        sum(CASE  when check_fee_type in(300,301) THEN arrearage_fee ELSE 0 END) as arrearageFeeForVIP,
        /**103  补缴收入 **/
        sum( CASE  when check_fee_type=103 THEN dicount_fee ELSE 0 END) as dicountFeeForBack,
        sum(CASE  when check_fee_type=103 THEN act_fee ELSE 0 END) as actFeeForBack,
        sum(CASE  when check_fee_type=103 THEN total_fee ELSE 0 END) as totalFeeForBack,
        sum(CASE  when check_fee_type=103 THEN arrearage_fee ELSE 0 END) as arrearageFeeForBack,
        /**-100 -200 -300  退费收入 **/
        sum(CASE  when check_fee_type=-100 THEN act_fee ELSE 0 END) as orderRefund,
        sum(CASE  when check_fee_type=-200 THEN act_fee ELSE 0 END) as rechargeRefund,
        sum(CASE  when check_fee_type=-300 THEN act_fee ELSE 0 END) as vipRefund
        from td_b_check_day
        where data_state = 1
        <if test="plNos != null and plNos.size >0">
            and pl_no in
            <foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
                #{plNo}
            </foreach>
        </if>
        <if test="beginTime != null ">
            <![CDATA[ and check_date >= #{beginTime}  ]]>
        </if>
        <if test="endTime != null ">
            <![CDATA[ and check_date <= #{endTime}  ]]>
        </if>


    </select>



    <select id="queryDetailForAreaByType" parameterType="com.zteits.clouds.api.dto.clouds.param.CheckDayRequest"
            resultType="com.zteits.clouds.api.dto.clouds.dto.CheckDayForDetailDTO">
        select

        <if test="timeType == 1">
            DATE_FORMAT(check_date,'%Y-%m-%d') as checkDate,
        </if>
        <if test="timeType == 2">
            DATE_FORMAT(check_date,'%Y-%m') as checkDate,
        </if>
        area_id as areaId,
        area_name as areaName,
        sum(IFNULL(ali_fee,0)) as aliFee,
        sum(IFNULL(ali_charge_num,0)) as aliChargeNum,
        sum(IFNULL(wx_fee,0)) as wxFee,
        sum(IFNULL(wx_charge_num,0)) as wxChargeNum,
        sum(IFNULL(cash_fee,0)) as cashFee,
        sum(IFNULL(cash_charge_num,0)) as cashChargeNum,
        sum(IFNULL(balance_fee,0)) as balanceFee,
        sum(IFNULL(balance_charge_num,0)) as balanceChargeNum,

        sum(IFNULL(dicount_fee,0)) as dicountFee,
        sum(IFNULL(act_fee,0)) as actFee,
        sum(IFNULL(total_fee,0)) as totalFee,
        sum(IFNULL(arrearage_fee,0)) as arrearageFee
        from td_b_check_day
        where data_state = 1
        <if test="plNos != null and plNos.size >0">
            and pl_no in
            <foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
                #{plNo}
            </foreach>
        </if>
        <if test="areaId != null and areaId !=''">
            and area_id = #{areaId}
        </if>
        <if test="beginTime != null ">
            <![CDATA[ and check_date >= #{beginTime}  ]]>
        </if>
        <if test="endTime != null ">
            <![CDATA[ and check_date <= #{endTime}  ]]>
        </if>
        <if test="checkFeeTypes != null and checkFeeTypes.size >0">
            and check_fee_type in
            <foreach collection="checkFeeTypes" open="(" close=")" item="checkFeeType" separator=",">
                #{checkFeeType}
            </foreach>
        </if>

        GROUP BY checkDate,areaId,areaName
        ORDER BY checkDate DESC

    </select>


    <select id="queryDetailForParkByType" parameterType="com.zteits.clouds.api.dto.clouds.param.CheckDayRequest"
            resultType="com.zteits.clouds.api.dto.clouds.dto.CheckDayForDetailDTO">
        select

        <if test="timeType == 1">
            DATE_FORMAT(check_date,'%Y-%m-%d') as checkDate,
        </if>
        <if test="timeType == 2">
            DATE_FORMAT(check_date,'%Y-%m') as checkDate,
        </if>
        area_id as areaId,
        area_name as areaName,
        pl_no as plNo,
        pl_name as plName,
        sum(IFNULL(ali_fee,0)) as aliFee,
        sum(IFNULL(ali_charge_num,0)) as aliChargeNum,
        sum(IFNULL(wx_fee,0)) as wxFee,
        sum(IFNULL(wx_charge_num,0)) as wxChargeNum,
        sum(IFNULL(cash_fee,0)) as cashFee,
        sum(IFNULL(cash_charge_num,0)) as cashChargeNum,
        sum(IFNULL(balance_fee,0)) as balanceFee,
        sum(IFNULL(balance_charge_num,0)) as balanceChargeNum,

        sum(IFNULL(dicount_fee,0)) as dicountFee,
        sum(IFNULL(act_fee,0)) as actFee,
        sum(IFNULL(total_fee,0)) as totalFee,
        sum(IFNULL(arrearage_fee,0)) as arrearageFee
        from td_b_check_day
        where data_state = 1
        <if test="plNos != null and plNos.size >0">
            and pl_no in
            <foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
                #{plNo}
            </foreach>
        </if>
        <if test="areaId != null and areaId !=''">
            and area_id = #{areaId}
        </if>
        <if test="beginTime != null ">
            <![CDATA[ and check_date >= #{beginTime}  ]]>
        </if>
        <if test="endTime != null ">
            <![CDATA[ and check_date <= #{endTime}  ]]>
        </if>
        <if test="checkFeeTypes != null and checkFeeTypes.size >0">
            and check_fee_type in
            <foreach collection="checkFeeTypes" open="(" close=")" item="checkFeeType" separator=",">
                #{checkFeeType}
            </foreach>
        </if>

        GROUP BY checkDate,plNo,plName,areaId,areaName
        ORDER BY checkDate DESC

    </select>


    <select id="queryDetailForAreaSummaryByType" parameterType="com.zteits.clouds.api.dto.clouds.param.CheckDayRequest"
            resultType="com.zteits.clouds.api.dto.clouds.dto.CheckDayForDetailDTO">
        select
        sum(IFNULL(ali_fee,0)) as aliFee,
        sum(IFNULL(ali_charge_num,0)) as aliChargeNum,
        sum(IFNULL(wx_fee,0)) as wxFee,
        sum(IFNULL(wx_charge_num,0)) as wxChargeNum,
        sum(IFNULL(cash_fee,0)) as cashFee,
        sum(IFNULL(cash_charge_num,0)) as cashChargeNum,
        sum(IFNULL(balance_fee,0)) as balanceFee,
        sum(IFNULL(balance_charge_num,0)) as balanceChargeNum,

        sum(IFNULL(dicount_fee,0)) as dicountFee,
        sum(IFNULL(act_fee,0)) as actFee,
        sum(IFNULL(total_fee,0)) as totalFee,
        sum(IFNULL(arrearage_fee,0)) as arrearageFee
        from td_b_check_day
        where data_state = 1
        <if test="plNos != null and plNos.size >0">
            and pl_no in
            <foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
                #{plNo}
            </foreach>
        </if>
        <if test="areaId != null and areaId !=''">
            and area_id = #{areaId}
        </if>
        <if test="beginTime != null ">
            <![CDATA[ and check_date >= #{beginTime}  ]]>
        </if>
        <if test="endTime != null ">
            <![CDATA[ and check_date <= #{endTime}  ]]>
        </if>
        <if test="checkFeeTypes != null and checkFeeTypes.size >0">
            and check_fee_type in
            <foreach collection="checkFeeTypes" open="(" close=")" item="checkFeeType" separator=",">
                #{checkFeeType}
            </foreach>
        </if>



    </select>


    <select id="queryDetailForParkSummaryByType" parameterType="com.zteits.clouds.api.dto.clouds.param.CheckDayRequest"
            resultType="com.zteits.clouds.api.dto.clouds.dto.CheckDayForDetailDTO">
        select
        sum(IFNULL(ali_fee,0)) as aliFee,
        sum(IFNULL(ali_charge_num,0)) as aliChargeNum,
        sum(IFNULL(wx_fee,0)) as wxFee,
        sum(IFNULL(wx_charge_num,0)) as wxChargeNum,
        sum(IFNULL(cash_fee,0)) as cashFee,
        sum(IFNULL(cash_charge_num,0)) as cashChargeNum,
        sum(IFNULL(balance_fee,0)) as balanceFee,
        sum(IFNULL(balance_charge_num,0)) as balanceChargeNum,

        sum(IFNULL(dicount_fee,0)) as dicountFee,
        sum(IFNULL(act_fee,0)) as actFee,
        sum(IFNULL(total_fee,0)) as totalFee,
        sum(IFNULL(arrearage_fee,0)) as arrearageFee
        from td_b_check_day
        where data_state = 1
        <if test="plNos != null and plNos.size >0">
            and pl_no in
            <foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
                #{plNo}
            </foreach>
        </if>
        <if test="areaId != null and areaId !=''">
            and area_id = #{areaId}
        </if>
        <if test="beginTime != null ">
            <![CDATA[ and check_date >= #{beginTime}  ]]>
        </if>
        <if test="endTime != null ">
            <![CDATA[ and check_date <= #{endTime}  ]]>
        </if>
        <if test="checkFeeTypes != null and checkFeeTypes.size >0">
            and check_fee_type in
            <foreach collection="checkFeeTypes" open="(" close=")" item="checkFeeType" separator=",">
                #{checkFeeType}
            </foreach>
        </if>


    </select>



    <select id="queryDetailForParkRefundByType"
            resultType="com.zteits.clouds.api.dto.clouds.dto.CheckDayForDetailDTO">
        select

        sum(IFNULL(ali_fee,0)) as aliFeeForRefund,
        sum(IFNULL(ali_charge_num,0)) as aliChargeNumForRefund,
        sum(IFNULL(wx_fee,0)) as wxFeeForRefund,
        sum(IFNULL(wx_charge_num,0)) as wxChargeNumForRefund,
        sum(IFNULL(cash_fee,0)) as cashFeeForRefund,
        sum(IFNULL(cash_charge_num,0)) as cashChargeNumForRefund,
        sum(IFNULL(balance_fee,0)) as balanceFeeForRefund,
        sum(IFNULL(balance_charge_num,0)) as balanceChargeNumForRefund,

        sum(IFNULL(act_fee,0)) as actFeeForRefund

        from td_b_check_day
        where data_state = 1
        <if test="plNo != null ">
            and pl_no =#{plNo}
        </if>
        <if test="areaId != null ">
            and area_id =#{areaId}
        </if>

        <if test="timeType == 1">
            and DATE_FORMAT(check_date,'%Y-%m-%d') = #{checkDate}
        </if>
        <if test="timeType == 2">
            and DATE_FORMAT(check_date,'%Y-%m')  = #{checkDate}
        </if>

        <if test="checkFeeTypes != null and checkFeeTypes.size >0">
            and check_fee_type in
            <foreach collection="checkFeeTypes" open="(" close=")" item="checkFeeType" separator=",">
                #{checkFeeType}
            </foreach>
        </if>


    </select>
    
    <!-- 根据制定日期删除表数据 -->
  <delete id="deleteCheckDayByDateTime" >
    delete from td_b_check_day
    where 1=1
     <![CDATA[and check_date >= #{beginTime}]]>
    <![CDATA[and check_date <= #{endTime}]]>
  </delete>
  
  <!-- 批量插入数据 -->
  <insert id="batchInsertCheckDay"  >
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into td_b_check_day (check_date, pl_no, pl_name,
      area_id, area_name, check_fee_type, 
      dicount_fee, act_fee, total_fee, 
      arrearage_fee, ali_fee, ali_charge_num, 
      wx_fee, wx_charge_num, cash_fee, 
      cash_charge_num, balance_fee, balance_charge_num, 
      data_state, create_emp_id, create_emp_name, 
      create_date, modfiy_emp_id, modfiy_emp_name, 
      modfiy_date, remark
      )
    values <foreach collection="list"  item="item"  separator=",">
        (#{item.checkDate,jdbcType=DATE}, #{item.plNo,jdbcType=VARCHAR}, #{item.plName,jdbcType=VARCHAR},
        #{item.areaId,jdbcType=VARCHAR}, #{item.areaName,jdbcType=VARCHAR}, #{item.checkFeeType,jdbcType=INTEGER},
        #{item.dicountFee,jdbcType=BIGINT}, #{item.actFee,jdbcType=BIGINT}, #{item.totalFee,jdbcType=BIGINT},
        #{item.arrearageFee,jdbcType=BIGINT}, #{item.aliFee,jdbcType=BIGINT}, #{item.aliChargeNum,jdbcType=INTEGER},
        #{item.wxFee,jdbcType=BIGINT}, #{item.wxChargeNum,jdbcType=INTEGER}, #{item.cashFee,jdbcType=BIGINT},
        #{item.cashChargeNum,jdbcType=INTEGER}, #{item.balanceFee,jdbcType=BIGINT}, #{item.balanceChargeNum,jdbcType=INTEGER},
        1, #{item.createEmpId,jdbcType=VARCHAR}, #{item.createEmpName,jdbcType=VARCHAR},
        #{item.createDate,jdbcType=TIMESTAMP}, #{item.modfiyEmpId,jdbcType=VARCHAR}, #{item.modfiyEmpName,jdbcType=VARCHAR},
        #{item.modfiyDate,jdbcType=TIMESTAMP}, #{item.remark,jdbcType=VARCHAR}
        )
     </foreach>
  </insert>


</mapper>