<?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="org.linlinjava.litemall.db.dao.StatMapper">
    <select id="statUser" resultType="map">
        select
        substr(add_time,1,10) as day,
        count(distinct id) as users
        from litemall_user
        group by substr(add_time,1,10)
    </select>
    <select id="statOrder" resultType="map">
        select
        substr(add_time,1,10) as day,
        count(id) as orders,
        count(distinct user_id) as customers,
        sum(actual_price) as amount,
        round(sum(actual_price)/count(distinct user_id),2) as pcr
        from litemall_order
        where order_status in(401,402)
        group by substr(add_time,1,10)
    </select>
    <select id="statGoods" resultType="map">
        select
        substr(add_time,1, 10) as day,
        count(distinct order_id) as orders,
        sum(number) as products,
        sum(number*price) as amount
        from litemall_order_goods
        group by substr(add_time,1, 10)
    </select>
</mapper>
