<?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.ylx.massage.mapper.TTxRecordMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ylx.massage.domain.TTxRecord">
        <id column="c_id" property="cId" />
        <result column="c_open_id" property="cOpenId" />
        <result column="d_price" property="dPrice" />
        <result column="c_time" property="cTime" />
        <result column="dept_id" property="deptId" />
        <result column="dept_name" property="deptName" />
        <result column="c_phone" property="cPhone" />
        <result column="c_name" property="cName" />
        <result column="c_image" property="cImage" />
        <result column="n_status" property="nStatus" />
        <result column="dt_create_time" property="dtCreateTime" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        c_id, c_open_id, d_price, c_time, c_phone, c_name, c_image, n_status, dt_create_time
    </sql>

    <select id="getBlockGetAmount" resultType="com.ylx.massage.domain.vo.HomeBlock">

        SELECT
            Date_format( dt_create_time, '%Y-%m' ) AS MONTH,
            sum( d_price ) getAmount
        FROM
            t_tx_record
        WHERE
            is_delete = 0
        <if test="deptId != null and deptId != 100 and deptId != ''">
            AND dept_id = #{deptId}
        </if>
        AND dt_create_time BETWEEN #{start} AND #{end}
        GROUP BY
            MONTH
        ORDER BY
            MONTH
    </select>

</mapper>
