292 lines
11 KiB
XML
292 lines
11 KiB
XML
<?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.suisung.mall.shop.analytics.mapper.AnalyticsOrderDao">
|
|
<select id="getOrderNum" resultType="com.suisung.mall.common.pojo.vo.OrderNumVo">
|
|
SELECT
|
|
COUNT( * ) AS orderNum
|
|
FROM
|
|
shop_order_info
|
|
<where>
|
|
<if test="startTime!=null and endTime!=null">
|
|
AND order_time BETWEEN #{startTime} AND #{endTime}
|
|
</if>
|
|
<if test="order_state_id!=null ">
|
|
AND order_state_id IN
|
|
<foreach item="id" collection="order_state_id" separator="," open="(" close=")" index="i">#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="user_id!=null ">
|
|
AND buyer_user_id=#{user_id}
|
|
</if>
|
|
<if test="kind_id!=null ">
|
|
AND kind_id=#{kind_id}
|
|
</if>
|
|
<if test="order_is_paid!=null">
|
|
AND order_is_paid IN
|
|
<foreach item="id" collection="order_is_paid" separator="," open="(" close=")" index="i">#{id}</foreach>
|
|
</if>
|
|
<if test="subsiteId != null">
|
|
AND subsite_id = #{subsiteId}
|
|
</if>
|
|
<if test="storeId != null">
|
|
AND store_id = #{storeId}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
|
|
<select id="getOrderAmount" resultType="com.suisung.mall.common.pojo.vo.CommonNumVo">
|
|
SELECT
|
|
sum(shop_order_base.order_payment_amount) AS num
|
|
FROM
|
|
shop_order_info left join shop_order_base ON shop_order_info.order_id = shop_order_base.order_id
|
|
<where>
|
|
<if test="startTime!=null and endTime!=null">
|
|
AND shop_order_info.order_time BETWEEN #{startTime} AND #{endTime}
|
|
</if>
|
|
AND shop_order_info.order_is_paid IN (3012, 3013)
|
|
<if test="subsiteId != null">
|
|
AND shop_order_info.subsite_id = #{subsiteId}
|
|
</if>
|
|
<if test="storeId != null">
|
|
AND shop_order_info.store_id = #{storeId}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="getSaleOrderAmount" resultType="com.suisung.mall.common.pojo.output.TimelineOutput">
|
|
SELECT
|
|
FROM_UNIXTIME( shop_order_info.order_time / 1000, '%m-%d' ) AS time,
|
|
sum(shop_order_base.order_payment_amount) AS num
|
|
FROM
|
|
shop_order_info left join shop_order_base ON shop_order_info.order_id = shop_order_base.order_id
|
|
<where>
|
|
<if test="startTime!=null and endTime!=null">
|
|
AND shop_order_info.order_time BETWEEN #{startTime} AND #{endTime}
|
|
</if>
|
|
AND shop_order_info.order_is_paid IN (3012, 3013)
|
|
<if test="subsiteId != null">
|
|
AND shop_order_info.subsite_id = #{subsiteId}
|
|
</if>
|
|
<if test="storeId != null">
|
|
AND shop_order_info.store_id = #{storeId}
|
|
</if>
|
|
</where>
|
|
GROUP BY time
|
|
ORDER BY shop_order_info.order_time
|
|
</select>
|
|
|
|
<select id="getOrderTimeLine" resultType="com.suisung.mall.common.pojo.output.TimelineOutput">
|
|
SELECT
|
|
FROM_UNIXTIME( order_time / 1000, '%m-%d' ) AS time,
|
|
count(*) AS num
|
|
FROM
|
|
shop_order_info
|
|
<where>
|
|
<if test="startTime!=null and endTime!=null">
|
|
AND order_time BETWEEN #{startTime} AND #{endTime}
|
|
</if>
|
|
<if test="subsiteId != null">
|
|
AND subsite_id = #{subsiteId}
|
|
</if>
|
|
<if test="storeId != null">
|
|
AND store_id = #{storeId}
|
|
</if>
|
|
</where>
|
|
GROUP BY time
|
|
ORDER BY order_time
|
|
</select>
|
|
|
|
<select id="getOrderCustomerNumTimeline" resultType="com.suisung.mall.common.pojo.output.TimelineOutput">
|
|
SELECT
|
|
FROM_UNIXTIME( order_time / 1000, '%m-%d' ) AS time,
|
|
count( DISTINCT ( buyer_user_id ) ) AS num
|
|
FROM
|
|
shop_order_info
|
|
<where>
|
|
<if test="startTime!=null and endTime!=null">
|
|
AND order_time BETWEEN #{startTime} AND #{endTime}
|
|
</if>
|
|
<if test="subsiteId != null">
|
|
AND subsite_id = #{subsiteId}
|
|
</if>
|
|
<if test="storeId != null">
|
|
AND store_id = #{storeId}
|
|
</if>
|
|
</where>
|
|
GROUP BY time
|
|
ORDER BY order_time
|
|
</select>
|
|
|
|
<select id="getOrderItemNumTimeLine" resultType="com.suisung.mall.common.pojo.output.TimelineOutput">
|
|
SELECT
|
|
FROM_UNIXTIME( b.order_time / 1000, '%m-%d' ) AS time,
|
|
count(*) AS num
|
|
FROM shop_order_item i
|
|
LEFT JOIN
|
|
shop_order_info b ON i.order_id = b.order_id
|
|
<where>
|
|
<if test="params.stime!=null and params.etime!=null">
|
|
AND b.order_time BETWEEN #{params.stime} AND #{params.etime}
|
|
</if>
|
|
|
|
<if test="params.storeId != null ">
|
|
i.store_id = #{params.storeId}
|
|
</if>
|
|
<if test="params.productId != null">
|
|
AND i.product_id = #{params.productId}
|
|
</if>
|
|
<if test="params.itemId != null">
|
|
AND i.item_id in
|
|
<foreach collection="params.itemId" item="item_id" index="index" open="(" close=")" separator=",">
|
|
#{item_id}
|
|
</foreach>
|
|
</if>
|
|
<if test="params.categoryId != null ">
|
|
AND i.category_id IN
|
|
<foreach item="id" collection="params.categoryId" separator="," open="(" close=")" index="i">#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="params.productName != null and params.productName !=''">
|
|
AND i.product_name like concat('%', #{params.productName}, '%')
|
|
</if>
|
|
<if test="params.storeType != null">
|
|
AND b.store_type = #{params.storeType}
|
|
</if>
|
|
<if test="params.kindId != null">
|
|
AND b.kind_id = #{params.kindId}
|
|
</if>
|
|
<if test="subsiteId != null">
|
|
AND b.subsite_id = #{subsiteId}
|
|
</if>
|
|
<if test="storeId != null">
|
|
AND b.store_id = #{storeId}
|
|
</if>
|
|
</where>
|
|
GROUP BY time
|
|
ORDER BY b.order_time
|
|
</select>
|
|
|
|
|
|
<select id="getOrderItemNum" resultType="com.suisung.mall.common.pojo.vo.CommonNumVo">
|
|
SELECT
|
|
count(*) AS num
|
|
FROM shop_order_item i
|
|
LEFT JOIN
|
|
shop_order_info b ON i.order_id = b.order_id
|
|
<where>
|
|
<if test="params.stime!=null and params.etime!=null">
|
|
AND b.order_time BETWEEN #{params.stime} AND #{params.etime}
|
|
</if>
|
|
|
|
<if test="params.storeId != null ">
|
|
i.store_id = #{params.storeId}
|
|
</if>
|
|
<if test="params.productId != null">
|
|
AND i.product_id = #{params.productId}
|
|
</if>
|
|
<if test="params.itemId != null">
|
|
AND i.item_id in
|
|
<foreach collection="params.itemId" item="item_id" index="index" open="(" close=")" separator=",">
|
|
#{item_id}
|
|
</foreach>
|
|
</if>
|
|
<if test="params.categoryId != null ">
|
|
AND i.category_id IN
|
|
<foreach item="id" collection="params.categoryId" separator="," open="(" close=")" index="i">#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="params.productName != null and params.productName !=''">
|
|
AND i.product_name like concat('%', #{params.productName}, '%')
|
|
</if>
|
|
<if test="params.storeType != null">
|
|
AND b.store_type = #{params.storeType}
|
|
</if>
|
|
<if test="params.kindId != null">
|
|
AND b.kind_id = #{params.kindId}
|
|
</if>
|
|
<if test="subsiteId != null">
|
|
AND b.subsite_id = #{subsiteId}
|
|
</if>
|
|
<if test="storeId != null">
|
|
AND b.store_id = #{storeId}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
|
|
<select id="listOrderItemNum" resultType="com.suisung.mall.common.pojo.output.AnalyticsOrderItemNumOutput">
|
|
SELECT
|
|
i.product_id,
|
|
i.item_id,
|
|
i.order_item_image,
|
|
i.product_name,
|
|
i.item_name,
|
|
sum(i.order_item_quantity) AS num,
|
|
sum(i.order_item_amount) AS order_item_amount_sum
|
|
FROM shop_order_item i
|
|
LEFT JOIN
|
|
shop_order_info b ON i.order_id = b.order_id
|
|
<where>
|
|
<if test="params.stime!=null and params.etime!=null">
|
|
AND b.order_time BETWEEN #{params.stime} AND #{params.etime}
|
|
</if>
|
|
|
|
<if test="params.storeId != null ">
|
|
i.store_id = #{params.storeId}
|
|
</if>
|
|
<if test="params.productId != null">
|
|
AND i.product_id = #{params.productId}
|
|
</if>
|
|
<if test="params.itemId != null">
|
|
AND i.item_id in
|
|
<foreach collection="params.itemId" item="item_id" index="index" open="(" close=")" separator=",">
|
|
#{item_id}
|
|
</foreach>
|
|
</if>
|
|
<if test="params.categoryId != null ">
|
|
AND i.category_id IN
|
|
<foreach item="id" collection="params.categoryId" separator="," open="(" close=")" index="i">#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="params.productName != null and params.productName !=''">
|
|
AND i.product_name like concat('%', #{params.productName}, '%')
|
|
</if>
|
|
<if test="params.storeType != null">
|
|
AND b.store_type = #{params.storeType}
|
|
</if>
|
|
<if test="params.kindId != null">
|
|
AND b.kind_id = #{params.kindId}
|
|
</if>
|
|
|
|
<if test="subsiteId != null">
|
|
AND b.subsite_id = #{subsiteId}
|
|
</if>
|
|
<if test="storeId != null">
|
|
AND b.store_id = #{storeId}
|
|
</if>
|
|
</where>
|
|
GROUP BY i.item_id
|
|
ORDER BY num DESC
|
|
LIMIT 0, 100
|
|
</select>
|
|
|
|
<select id="getVoucherActiveNum" resultType="com.suisung.mall.common.pojo.vo.CommonNumVo">
|
|
SELECT
|
|
COUNT( * ) AS num
|
|
FROM
|
|
shop_user_voucher
|
|
<where>
|
|
<if test="startTime!=null and endTime!=null">
|
|
AND user_voucher_activetime BETWEEN #{startTime} AND #{endTime}
|
|
</if>
|
|
<if test="user_id!=null ">
|
|
AND user_id=#{user_id}
|
|
</if>
|
|
<if test="store_id!=null ">
|
|
AND store_id=#{store_id}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
</mapper>
|