mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?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.panzhihua.service_community.dao.ConvenientConsultationStatisticsDAO">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ConvenientConsultationStatisticsDO">
                <id column="id" property="id" />
                <id column="merchant_id" property="merchantId" />
                <id column="statistic_date" property="statisticDate" />
                <id column="consultation_volume" property="consultationVolume" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,merchant_id,statistic_date,consultation_volume
    </sql>
    <insert id="createTodayStatistic">
        INSERT INTO com_convenient_consultation_statistics (merchant_id, statistic_date) VALUES (#{merchantId}, NOW())
    </insert>
    <update id="incrConsultationNum">
        UPDATE com_convenient_consultation_statistics SET consultation_volume = consultation_volume + 1
        WHERE merchant_id = #{merchantId} AND statistic_date = #{nowDate}
    </update>
    <select id="selectMonthConsultationVolume" resultType="java.lang.Integer">
        SELECT IF(SUM(consultation_volume) IS NULL,0,SUM(consultation_volume))
        FROM com_convenient_consultation_statistics
        WHERE merchant_id = #{merchantId} AND (statistic_date LIKE CONCAT(#{moth}, '%') OR statistic_date IS NULL)
    </select>
    <select id="selectDayConsultationVolume" resultType="java.lang.Integer">
        SELECT IF(SUM(consultation_volume) IS NULL,0,SUM(consultation_volume))
        FROM com_convenient_consultation_statistics
        WHERE merchant_id = #{merchantId} AND (statistic_date = #{day} OR statistic_date IS NULL)
    </select>
    <select id="selectSumForConsultationNum" resultType="com.panzhihua.common.model.vos.community.convenient.ConvenientConsultationStatisticsVO">
        SELECT merchant_id, SUM(consultation_volume) AS totalConsultationNum
        FROM com_convenient_consultation_statistics GROUP BY merchant_id
    </select>
    <select id="selectTotalConsultationVolume" resultType="java.lang.Integer">
        SELECT IF(SUM(consultation_volume) IS NULL,0,SUM(consultation_volume))
        FROM com_convenient_consultation_statistics
        WHERE merchant_id = #{merchantId}
    </select>
 
</mapper>