<?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.ruoyi.system.mapper.TSysOrderMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.ruoyi.system.model.TSysOrder">
|
<id column="id" property="id" />
|
<result column="app_user_id" property="appUserId" />
|
<result column="inspection_id" property="inspectionId" />
|
<result column="order_number" property="orderNumber" />
|
<result column="total_money" property="totalMoney" />
|
<result column="check_time" property="checkTime" />
|
<result column="create_time" property="createTime" />
|
<result column="update_time" property="updateTime" />
|
<result column="create_by" property="createBy" />
|
<result column="update_by" property="updateBy" />
|
<result column="disabled" property="disabled" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, app_user_id, inspection_id, order_number, total_money, check_time, create_time, update_time, create_by, update_by, disabled
|
</sql>
|
<select id="queryListByAppUserId" resultType="com.ruoyi.system.vo.TSysOrderVO">
|
select
|
<include refid="Base_Column_List"/>
|
from t_sys_order
|
where app_user_id = #{appUserId} and disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
|
order by create_time desc
|
</select>
|
|
|
<select id="pageList" resultType="com.ruoyi.system.vo.TSysOrderPageVo">
|
select t1.id,t1.create_time,t1.total_money,t2.nick_name as userName,t2.phone from t_sys_order t1
|
left join t_sys_app_user t2 on t1.app_user_id = t2.id
|
where t1.disabled = 0 and t1.clinic_id =#{query.clinicId}
|
<if test="query.userName != null and query.userName != ''">
|
and t2.nick_name like concat('%',#{query.userName},'%')
|
</if>
|
<if test="query.phone != null and query.phone != ''">
|
and t2.phone like concat('%',#{query.phone},'%')
|
</if>
|
<if test="sTime != null and eTime != ''">
|
and t1.create_time between #{sTime} and #{eTime}
|
</if>
|
order by t1.create_time desc
|
|
</select>
|
<select id="clinicSalesStatisticsCount" resultType="java.lang.Integer">
|
select count(1)
|
from t_sys_order tso
|
left join t_sys_order_goods tsog on tso.id = tsog.order_id
|
left join t_erp_goods teg on tsog.goods_id = teg.id
|
where tso.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
|
and tso.clinic_id in <foreach collection="clinicIds" open="(" separator="," item="id" close=")">#{id}</foreach>
|
</select>
|
<select id="clinicSalesStatisticsTypeCount" resultType="java.lang.Integer">
|
select count(1)
|
from t_sys_order tso
|
left join t_sys_order_goods tsog on tso.id = tsog.order_id
|
left join t_erp_goods teg on tsog.goods_id = teg.id
|
where tso.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
|
and tso.clinic_id in <foreach collection="clinicIds" open="(" separator="," item="id" close=")">#{id}</foreach>
|
group by teg.type_id
|
</select>
|
<select id="clinicSalesStatisticsMoney" resultType="java.math.BigDecimal">
|
select sum(total_money) from t_sys_order
|
where disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
|
and pay_time between #{startTime} and #{endTime}
|
and clinic_id = #{clinicId}
|
</select>
|
<select id="clinicSalesStatisticsGoodsType"
|
resultType="com.ruoyi.system.vo.ClinicSalesStatisticsGoodsTypeVO">
|
select count(1), tegt.type_name
|
from t_sys_order tso
|
left join t_sys_order_goods tsog on tso.id = tsog.order_id
|
left join t_erp_goods teg on tsog.goods_id = teg.id
|
left join t_erp_goods_type tegt on teg.type_id = tegt.id
|
where tso.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
|
and tso.pay_time between #{startTime} and #{endTime}
|
and tso.clinic_id = #{clinicId}
|
group by teg.type_id
|
order by count(1) desc
|
</select>
|
<select id="clinicSalesStatisticsGoodsCount"
|
resultType="com.ruoyi.system.vo.ClinicSalesStatisticsGoodsCountVO">
|
select
|
date_format(t1.pay_time, '%m.%d') as `time`,
|
date_format(t1.pay_time, '%Y-%m-%d') as payTime,
|
sum(t2.sale_count) as goodsCount
|
from t_sys_order t1
|
left join t_sys_order_goods t2 on t1.id = t2.order_id
|
where t1.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
|
and t1.pay_time between #{startTime} and #{endTime}
|
and t1.clinic_id = #{clinicId}
|
<if test="goodsName != null and goodsName != ''">
|
and t2.goods_name like concat('%',#{goodsName},'%')
|
</if>
|
group by date_format(t1.pay_time, '%m.%d')
|
</select>
|
<select id="clinicSalesStatisticsGoodsCountMonth"
|
resultType="com.ruoyi.system.vo.ClinicSalesStatisticsGoodsCountVO">
|
select
|
date_format(t1.pay_time, '%Y.%m') as `time`,
|
sum(t2.sale_count) as goodsCount
|
from t_sys_order t1
|
left join t_sys_order_goods t2 on t1.id = t2.order_id
|
where t1.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
|
and t1.pay_time between #{startTime} and #{endTime}
|
and t1.clinic_id = #{clinicId}
|
<if test="goodsName != null and goodsName != ''">
|
and t2.goods_name like concat('%',#{goodsName},'%')
|
</if>
|
group by date_format(t1.pay_time, '%Y.%m')
|
</select>
|
|
</mapper>
|