<?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.mzl.flower.mapper.statisticsAnalysis.SalesStatisticsAnalysisMapper">
|
|
<select id="getFlowerSaleStatistics"
|
resultType="com.mzl.flower.dto.response.statisticAnalysis.FlowerSaleStatisticVO">
|
select sum(t.total) as saleAmount,
|
sum(t.num) as saleNum,
|
count(t.flower_id) as goodsNum,
|
sum(t.lackNum) as lackNum,
|
sum(t.replaceNum) as replaceNum,
|
sum(t.reduceNum) as reduceNum
|
from ( <include refid="flowerSalePageSql"></include>) t
|
</select>
|
|
<select id="getFlowerSalePage" resultType="com.mzl.flower.dto.response.statisticAnalysis.FlowerSaleVO">
|
<include refid="flowerSalePageSql"></include>
|
</select>
|
|
<select id="getFlowerSaleSList" resultType="com.mzl.flower.dto.response.statisticAnalysis.FlowerSaleVO">
|
<include refid="flowerSalePageSql"></include>
|
</select>
|
<sql id="flowerSalePageSql">
|
SELECT
|
oi.*,
|
s.NAME stationName,
|
si.contact_tel registerTel,
|
si.contact_tel customerTel,
|
si.id supplierId,
|
si.name supplierName,
|
o.id orderId,
|
o.order_no,
|
o.payment_time,
|
c.parent_name flowerCategoryName,
|
CONCAT(o.customer_province, ' ', o.customer_city, ' ', o.customer_region, ' ', o.customer_address) AS address,
|
COALESCE((SELECT oic.num FROM t_order_item_check oic WHERE oic.order_item_id = oi.id AND oic.type = 'replace'),
|
0) replaceNum,
|
COALESCE((SELECT oic.num FROM t_order_item_check oic WHERE oic.order_item_id = oi.id AND oic.type = 'reduce'),
|
0) reduceNum,
|
COALESCE((SELECT oic.num FROM t_order_item_check oic WHERE oic.order_item_id = oi.id AND oic.type = 'lack'), 0)
|
lackNum
|
FROM
|
t_order_item oi
|
LEFT JOIN t_station s ON s.id = oi.station_id
|
LEFT JOIN t_supplier_info si ON si.id = oi.supplier_id
|
LEFT JOIN t_order o ON oi.order_id = o.id
|
LEFT JOIN t_flower f on oi.flower_id = f.id
|
LEFT JOIN t_flower_category c on c.id = f.category
|
<include refid="flowerSaleWhere"></include>
|
</sql>
|
|
<sql id="flowerSaleWhere">
|
WHERE oi.deleted = 0
|
and o.payment_time is not null
|
and o.status_backend not in ('PENDING','CANCEL','REFUND')
|
<if test="dto.supplierId != null">
|
and si.id = #{dto.supplierId}
|
</if>
|
<if test="dto.supplierName != null and dto.supplierName != ''">
|
AND si.name LIKE concat('%', #{dto.supplierName},'%')
|
</if>
|
<if test="dto.registerTel!=null and dto.registerTel!=''">
|
AND si.contact_tel LIKE CONCAT('%',#{dto.registerTel}, '%')
|
</if>
|
<if test="dto.contactTel!=null and dto.contactTel!=''">
|
AND si.contact_tel LIKE CONCAT('%',#{dto.contactTel}, '%')
|
</if>
|
<if test="dto.stationId != null">
|
AND oi.station_id = #{dto.stationId}
|
</if>
|
<if test="dto.flowerCategory != null">
|
AND ( f.category = #{dto.flowerCategory} or f.category in (
|
select id from t_flower_category where parent_id = #{dto.flowerCategory}
|
))
|
</if>
|
<if test="dto.flowerLevel != null and dto.flowerLevel != ''">
|
AND oi.flower_level = #{dto.flowerLevel}
|
</if>
|
<if test="dto.customerProvince!=null and dto.customerProvince!=''">
|
AND o.customer_province like CONCAT('%',#{dto.customerProvince}, '%')
|
</if>
|
<if test="dto.customerCity!=null and dto.customerCity!=''">
|
AND o.customer_city like CONCAT('%',#{dto.customerCity}, '%')
|
</if>
|
<if test="dto.customerRegion!=null and dto.customerRegion!=''">
|
AND o.customer_region like CONCAT('%',#{dto.customerRegion}, '%')
|
</if>
|
<if test="dto.orderNo != null and dto.orderNo != ''">
|
AND o.order_no LIKE concat('%', #{dto.orderNo},'%')
|
</if>
|
<!-- 修改查询日期对应的的创建时间为支付时间 2024-10-12-->
|
<if test="dto.createStartDate != null">
|
AND o.payment_time >= #{dto.createStartDate}
|
</if>
|
<if test="dto.createEndDate != null">
|
AND o.payment_time < #{dto.createEndDate}
|
</if>
|
<if test="dto.orderField !=null and dto.orderField !=''">
|
order by ${dto.orderField} ${dto.orderType}
|
</if>
|
</sql>
|
|
|
</mapper>
|