<?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="cn.com.ty.lift.batch.applet.dao.mapper.PaymentDataMapper">

    <!-- 获取时间段内的收款数据 -->
    <select id="getPaymentDataList" parameterType="cn.com.ty.lift.batch.applet.dao.model.request.PaymentDataRequest"
            resultType="cn.com.ty.lift.batch.applet.dao.model.PaymentDataModel">
           select
              c.mt_company_id as mtCompanyId,
              pay.plan_date as planDate,
              pay.work_date as workDate,
              pay.plan_money as planMoney,
              pay.work_money as workMoney,
              pro.project_name as projectName,
              r.area_name as regionName,
              c.type as paymentType,
              c.moneys as contractMoney
           from
              payment pay
           left join
              contracts c
           on
              pay.contracts_id = c.id
           left join
              project pro
           on
              c.project_id = pro.id
           left join
              region r
           on
              pro.region_id = r.id
        where
            true
        <if test = "mtCompanyId !=  null">
            and c.mt_company_id = #{mtCompanyId}
        </if>
    </select>
</mapper>