<?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.countrygarden.bi.main.dao.twerp.hm.TbHsprFeesdetailMapper">
  <resultMap id="TbHsprFeesdetailResultMap" type="cn.com.countrygarden.bi.main.model.twerp.hm.TbHsprFeesdetail">
    <id column="RecdID" jdbcType="BIGINT" property="recdid" />
    <result column="CommID" jdbcType="INTEGER" property="commid" />
    <result column="CostID" jdbcType="BIGINT" property="costid" />
    <result column="CustID" jdbcType="BIGINT" property="custid" />
    <result column="RoomID" jdbcType="BIGINT" property="roomid" />
    <result column="FeesID" jdbcType="BIGINT" property="feesid" />
    <result column="ReceID" jdbcType="BIGINT" property="receid" />
    <result column="ChargeMode" jdbcType="NVARCHAR" property="chargemode" />
    <result column="AccountWay" jdbcType="SMALLINT" property="accountway" />
    <result column="ChargeAmount" jdbcType="NUMERIC" property="chargeamount" />
    <result column="LateFeeAmount" jdbcType="NUMERIC" property="latefeeamount" />
    <result column="ChargeDate" jdbcType="NCHAR" property="chargedate" />
    <result column="FeesMemo" jdbcType="NVARCHAR" property="feesmemo" />
    <result column="IsDelete" jdbcType="SMALLINT" property="isdelete" />
    <result column="OldCostID" jdbcType="BIGINT" property="oldcostid" />
    <result column="SynchFlag" jdbcType="SMALLINT" property="synchflag" />
  </resultMap>
  
  <select id="getfirstFeesOfDay"
          fetchSize="1"
          resultMap="TbHsprFeesdetailResultMap"
          parameterType="cn.com.countrygarden.bi.main.model.twerp.hm.TbHsprFeesdetail">
SELECT TOP
	1 o.OrganName,
	m.CommName,
	c.CustName,
	c.MobilePhone,
	d.ChargeMode,
	d.ChargeAmount,
	d.LateFeeAmount,
	d.ChargeDate
FROM
	HM_wygl_new_1853.dbo.Tb_HSPR_FeesDetail d WITH ( NOLOCK )
	INNER JOIN HM_wygl_new_1853.dbo.Tb_HSPR_Customer c WITH ( NOLOCK ) ON c.CustID = d.CustID
	AND c.IsDelete = 0
	AND d.IsDelete = 0
	INNER JOIN HM_wygl_new_1853.dbo.Tb_HSPR_Community m WITH ( NOLOCK ) ON m.CommID = d.CommID
	AND m.IsDelete = 0
	INNER JOIN HM_wygl_new_1853.dbo.Tb_Sys_Organ o WITH ( NOLOCK ) ON o.OrganCode = m.OrganCode
	AND o.IsDelete = 0
WHERE
	ChargeDate > DATEADD(
	HOUR,
	4,
	CAST ( CAST ( GETDATE() AS DATE ) AS datetime ))
ORDER BY
	ChargeDate
</select>

</mapper>