<?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.xxfc.platform.order.mapper.DailyMembersOrderStatisticsMapper">
    <!--    获取会员订单成交金-->
    <select id="getTravelGmv" resultType="HashMap">
        select
        date(DATE_SUB(now(),interval #{day} day)) as oneDay,
        IFNULL(SUM(real_amount),0) as gmv
        from
        base_order
        where
        type=3
        AND
        date(FROM_UNIXTIME(pay_time/1000))=date(DATE_SUB(now(),interval #{day} day))
    </select>

    <select id="monthOrderTotal" resultType="com.xxfc.platform.order.entity.OrderStatistics">
 SELECT
        IFNULL(sum(gmv),0) as totalGmv
        FROM
        (
				SELECT
				 ANY_VALUE(id) AS id ,
				 ANY_VALUE(branch_company_id) AS branch_company_id,
				 ANY_VALUE(one_day) AS one_day,
				 ANY_VALUE(gmv) AS gmv,
				 ANY_VALUE(crt_time) AS crt_time
				 FROM
				 daily_members_order_statistics
				 GROUP BY
				 one_day,branch_company_id
		) m
        WHERE
        branch_company_id =#{companyId}
    </select>
<!--    <select id="updateByExampleSelective">-->
<!--                SELECT-->
<!--        IFNULL(sum(gmv),0) as totalGmv-->
<!--        FROM-->
<!--        daily_members_order_statistics-->
<!--        WHERE-->
<!--        branch_company_id =#{companyId}-->
<!--        and-->
<!--        DATE_FORMAT(one_day,'%Y-%c')=DATE_FORMAT(DATE_SUB(NOW(),interval 1 day),'%Y-%c')-->

<!--    </select>-->
</mapper>