<?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.order.mapper.order.OrderMapper">
|
|
<resultMap type="com.ruoyi.order.domain.pojo.order.Order" id="OrderResult">
|
<result property="orderId" column="order_id" />
|
<result property="delFlag" column="del_flag" />
|
<result property="orderStatus" column="order_status" />
|
<result property="orderNo" column="order_no" />
|
<result property="orderFrom" column="order_from" />
|
<result property="shopId" column="shop_id" />
|
<result property="userId" column="user_id" />
|
<result property="orderMoney" column="order_money" />
|
<result property="couponMoney" column="coupon_money" />
|
<result property="discountMoney" column="discount_money" />
|
<result property="receivableMoney" column="receivable_money" />
|
<result property="payType" column="pay_type" />
|
<result property="payMoney" column="pay_money" />
|
<result property="onlinePayMoney" column="online_pay_money" />
|
<result property="offlinePayMoney" column="offline_pay_money" />
|
<result property="orderRemark" column="order_remark" />
|
<result property="goodsInfo" column="goods_info" />
|
<result property="createTime" column="create_time" />
|
<result property="payTime" column="pay_time" />
|
<result property="useTime" column="use_time" />
|
<result property="cancelTime" column="cancel_time" />
|
<result property="useUserId" column="use_user_id" />
|
</resultMap>
|
|
<resultMap id="orderResultMap" type="com.ruoyi.order.domain.vo.AppUserOrderPageVo">
|
<result column="orderId" property="orderId"/>
|
<result column="orderStatus" property="orderStatus"/>
|
<result column="orderNo" property="orderNo"/>
|
<result column="receivableMoney" property="receivableMoney"/>
|
<result column="goodsNum" property="goodsNum"/>
|
<result column="shopId" property="shopId" />
|
<result column="orderFrom" property="orderFrom" />
|
<result column="createTime" property="createTime" />
|
<collection property="appUserOrderGoodsPageVoList"
|
ofType="com.ruoyi.order.domain.vo.AppUserOrderGoodsPageVo"
|
select="listOrderGoodsByOrderId"
|
column="{orderId=orderId}">
|
<id column="orderGoodsId" property="orderGoodsId"/>
|
<result column="goodsId" property="goodsId"/>
|
<result column="goodsName" property="goodsName"/>
|
<result column="goodsIntroduction" property="goodsIntroduction"/>
|
<result column="goodsPicture" property="goodsPicture"/>
|
<result column="goodsType" property="goodsType"/>
|
<result column="buyNum" property="buyNum"/>
|
<result column="goodsPrice" property="goodsPrice"/>
|
<result column="goodsRealPrice" property="goodsRealPrice" />
|
<result column="cycleNumFlag" property="cycleNumFlag" />
|
<result column="serviceNum" property="serviceNum" />
|
</collection>
|
</resultMap>
|
|
<!--<resultMap id="orderGoodsResultMap" type="com.ruoyi.order.domain.vo.AppUserOrderGoodsPageVo">
|
<result column="orderGoodsId" property="orderGoodsId"/>
|
<result column="goodsId" property="goodsId"/>
|
<result column="goodsName" property="goodsName"/>
|
<result column="goodsIntroduction" property="goodsIntroduction"/>
|
<result column="goodsPicture" property="goodsPicture"/>
|
<result column="goodsType" property="goodsType"/>
|
<result column="buyNum" property="buyNum"/>
|
<result column="goodsPrice" property="goodsPrice"/>
|
<result column="goodsRealPrice" property="goodsRealPrice" />
|
<result column="cycleNumFlag" property="cycleNumFlag" />
|
<result column="serviceNum" property="serviceNum" />
|
</resultMap>-->
|
|
|
|
<resultMap id="merOrderResultMap" type="com.ruoyi.order.domain.vo.MerOrderPageVo">
|
<result column="userId" property="userId"/>
|
<result column="orderId" property="orderId"/>
|
<result column="orderStatus" property="orderStatus"/>
|
<result column="payType" property="payType"/>
|
<result column="orderNo" property="orderNo"/>
|
<result column="orderGoodsMoney" property="orderGoodsMoney"/>
|
<result column="couponDiscount" property="couponDiscount"/>
|
<result column="receivableMoney" property="receivableMoney"/>
|
<result column="receivableDeposit" property="receivableDeposit"/>
|
<result column="relReceiveMoney" property="relReceiveMoney"/>
|
<result column="payMoney" property="payMoney"/>
|
<result column="receiveMoney" property="receiveMoney"/>
|
<result column="unPaidMoney" property="unPaidMoney"/>
|
<result column="orderRemark" property="orderRemark" />
|
<result column="orderFrom" property="orderFrom" />
|
<result column="createTime" property="createTime" />
|
<collection property="merOrderGoodsVoList"
|
ofType="com.ruoyi.order.domain.vo.MerOrderGoodsPageVo"
|
select="listSimpleOrderGoodsByOrderId"
|
column="{orderId=orderId}">
|
<result column="goodsName" property="goodsName"/>
|
<result column="goodsType" property="goodsType"/>
|
<result column="buyNum" property="buyNum"/>
|
</collection>
|
</resultMap>
|
|
<resultMap id="mgtOrderResultMap" type="com.ruoyi.order.domain.vo.MgtMemberOrderPageVo">
|
<result column="orderId" property="orderId"/>
|
<result column="orderStatus" property="orderStatus"/>
|
<result column="orderNo" property="orderNo"/>
|
<result column="shopId" property="shopId"/>
|
<result column="orderMoney" property="orderMoney"/>
|
<result column="discountMoney" property="discountMoney"/>
|
<result column="receivableMoney" property="receivableMoney"/>
|
<result column="payMoney" property="payMoney"/>
|
<result column="receiveMoney" property="receiveMoney"/>
|
<result column="orderFrom" property="orderFrom" />
|
<result column="orderFromDesc" property="orderFromDesc" />
|
<result column="createTime" property="createTime" />
|
<collection property="mgtOrderGoodsVoList"
|
ofType="com.ruoyi.order.domain.vo.MgtOrderGoodsPageVo"
|
select="listMgtSimpleOrderGoodsByOrderId"
|
column="{orderId=orderId}">
|
<result column="goodsName" property="goodsName"/>
|
<result column="buyNum" property="buyNum"/>
|
</collection>
|
</resultMap>
|
|
|
<resultMap id="mgtShopOrderResultMap" type="com.ruoyi.order.domain.vo.MgtShopOrderPageVo">
|
<result column="orderId" property="orderId"/>
|
<result column="orderNo" property="orderNo"/>
|
<result column="outTradeNo" property="outTradeNo"/>
|
<result column="userId" property="userId"/>
|
<result column="orderMoney" property="orderMoney"/>
|
<result column="createTime" property="createTime"/>
|
<result column="receivableMoney" property="receivableMoney"/>
|
<result column="discountMoney" property="discountMoney"/>
|
<result column="payMoney" property="payMoney"/>
|
<result column="orderFrom" property="orderFrom"/>
|
<result column="shopId" property="shopId"/>
|
<result column="verifyTime" property="verifyTime"/>
|
<collection property="mgtOrderGoodsPageVoList"
|
ofType="com.ruoyi.order.domain.vo.MgtOrderGoodsPageVo"
|
select="listAllSimpleOrderGoodsByOrderId"
|
column="{orderId=orderId}">
|
<result column="goodsName" property="goodsName"/>
|
<result column="buyNum" property="buyNum"/>
|
</collection>
|
</resultMap>
|
|
<resultMap id="mgtShopAllOrderResultMap" type="com.ruoyi.order.domain.vo.MgtShopAllOrderPageVo">
|
<result column="orderId" property="orderId"/>
|
<result column="orderNo" property="orderNo"/>
|
<result column="userId" property="userId"/>
|
<result column="orderMoney" property="orderMoney"/>
|
<result column="receivableMoney" property="receivableMoney"/>
|
<result column="discountMoney" property="discountMoney"/>
|
<result column="payMoney" property="payMoney"/>
|
<result column="orderFrom" property="orderFrom"/>
|
<result column="orderStatus" property="orderStatus"/>
|
<collection property="mgtOrderGoodsPageVoList"
|
ofType="com.ruoyi.order.domain.vo.MgtOrderGoodsPageVo"
|
select="listAllSimpleOrderGoodsByOrderId"
|
column="{orderId=orderId}">
|
<result column="goodsName" property="goodsName"/>
|
<result column="buyNum" property="buyNum"/>
|
</collection>
|
</resultMap>
|
|
<sql id="selectOrderVo">
|
select order_id, del_flag, order_status, order_no, order_from, shop_id, user_id, order_money, coupon_money, discount_money, receivable_money, pay_type, pay_money, online_pay_money, offline_pay_money, order_remark, goods_info, create_time, pay_time, use_time, cancel_time, use_user_id from t_order
|
</sql>
|
|
<select id="selectOrderList" parameterType="com.ruoyi.order.domain.pojo.order.Order" resultMap="OrderResult">
|
<include refid="selectOrderVo"/>
|
<where>
|
<if test="orderStatus != null "> and order_status = #{orderStatus}</if>
|
<if test="orderNo != null and orderNo != ''"> and order_no = #{orderNo}</if>
|
<if test="orderFrom != null "> and order_from = #{orderFrom}</if>
|
<if test="shopId != null "> and shop_id = #{shopId}</if>
|
<if test="userId != null "> and user_id = #{userId}</if>
|
<if test="orderMoney != null "> and order_money = #{orderMoney}</if>
|
<if test="couponMoney != null "> and coupon_money = #{couponMoney}</if>
|
<if test="discountMoney != null "> and discount_money = #{discountMoney}</if>
|
<if test="receivableMoney != null "> and receivable_money = #{receivableMoney}</if>
|
<if test="payType != null "> and pay_type = #{payType}</if>
|
<if test="payMoney != null "> and pay_money = #{payMoney}</if>
|
<if test="onlinePayMoney != null "> and online_pay_money = #{onlinePayMoney}</if>
|
<if test="offlinePayMoney != null "> and offline_pay_money = #{offlinePayMoney}</if>
|
<if test="orderRemark != null and orderRemark != ''"> and order_remark = #{orderRemark}</if>
|
<if test="goodsInfo != null and goodsInfo != ''"> and goods_info = #{goodsInfo}</if>
|
<if test="payTime != null "> and pay_time = #{payTime}</if>
|
<if test="useTime != null "> and use_time = #{useTime}</if>
|
<if test="cancelTime != null "> and cancel_time = #{cancelTime}</if>
|
<if test="useUserId != null "> and use_user_id = #{useUserId}</if>
|
</where>
|
</select>
|
|
<select id="selectOrderByOrderId" parameterType="String" resultMap="OrderResult">
|
<include refid="selectOrderVo"/>
|
where order_id = #{orderId}
|
</select>
|
|
<insert id="insertOrder" parameterType="com.ruoyi.order.domain.pojo.order.Order">
|
insert into t_order
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="orderId != null">order_id,</if>
|
<if test="delFlag != null">del_flag,</if>
|
<if test="orderStatus != null">order_status,</if>
|
<if test="orderNo != null">order_no,</if>
|
<if test="orderFrom != null">order_from,</if>
|
<if test="shopId != null">shop_id,</if>
|
<if test="userId != null">user_id,</if>
|
<if test="orderMoney != null">order_money,</if>
|
<if test="couponMoney != null">coupon_money,</if>
|
<if test="discountMoney != null">discount_money,</if>
|
<if test="receivableMoney != null">receivable_money,</if>
|
<if test="payType != null">pay_type,</if>
|
<if test="payMoney != null">pay_money,</if>
|
<if test="onlinePayMoney != null">online_pay_money,</if>
|
<if test="offlinePayMoney != null">offline_pay_money,</if>
|
<if test="orderRemark != null">order_remark,</if>
|
<if test="goodsInfo != null">goods_info,</if>
|
<if test="createTime != null">create_time,</if>
|
<if test="payTime != null">pay_time,</if>
|
<if test="useTime != null">use_time,</if>
|
<if test="cancelTime != null">cancel_time,</if>
|
<if test="useUserId != null">use_user_id,</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="orderId != null">#{orderId},</if>
|
<if test="delFlag != null">#{delFlag},</if>
|
<if test="orderStatus != null">#{orderStatus},</if>
|
<if test="orderNo != null">#{orderNo},</if>
|
<if test="orderFrom != null">#{orderFrom},</if>
|
<if test="shopId != null">#{shopId},</if>
|
<if test="userId != null">#{userId},</if>
|
<if test="orderMoney != null">#{orderMoney},</if>
|
<if test="couponMoney != null">#{couponMoney},</if>
|
<if test="discountMoney != null">#{discountMoney},</if>
|
<if test="receivableMoney != null">#{receivableMoney},</if>
|
<if test="payType != null">#{payType},</if>
|
<if test="payMoney != null">#{payMoney},</if>
|
<if test="onlinePayMoney != null">#{onlinePayMoney},</if>
|
<if test="offlinePayMoney != null">#{offlinePayMoney},</if>
|
<if test="orderRemark != null">#{orderRemark},</if>
|
<if test="goodsInfo != null">#{goodsInfo},</if>
|
<if test="createTime != null">#{createTime},</if>
|
<if test="payTime != null">#{payTime},</if>
|
<if test="useTime != null">#{useTime},</if>
|
<if test="cancelTime != null">#{cancelTime},</if>
|
<if test="useUserId != null">#{useUserId},</if>
|
</trim>
|
</insert>
|
|
<update id="updateOrder" parameterType="com.ruoyi.order.domain.pojo.order.Order">
|
update t_order
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
<if test="orderStatus != null">order_status = #{orderStatus},</if>
|
<if test="orderNo != null">order_no = #{orderNo},</if>
|
<if test="orderFrom != null">order_from = #{orderFrom},</if>
|
<if test="shopId != null">shop_id = #{shopId},</if>
|
<if test="userId != null">user_id = #{userId},</if>
|
<if test="orderMoney != null">order_money = #{orderMoney},</if>
|
<if test="couponMoney != null">coupon_money = #{couponMoney},</if>
|
<if test="discountMoney != null">discount_money = #{discountMoney},</if>
|
<if test="receivableMoney != null">receivable_money = #{receivableMoney},</if>
|
<if test="payType != null">pay_type = #{payType},</if>
|
<if test="payMoney != null">pay_money = #{payMoney},</if>
|
<if test="onlinePayMoney != null">online_pay_money = #{onlinePayMoney},</if>
|
<if test="offlinePayMoney != null">offline_pay_money = #{offlinePayMoney},</if>
|
<if test="orderRemark != null">order_remark = #{orderRemark},</if>
|
<if test="goodsInfo != null">goods_info = #{goodsInfo},</if>
|
<if test="createTime != null">create_time = #{createTime},</if>
|
<if test="payTime != null">pay_time = #{payTime},</if>
|
<if test="useTime != null">use_time = #{useTime},</if>
|
<if test="cancelTime != null">cancel_time = #{cancelTime},</if>
|
<if test="useUserId != null">use_user_id = #{useUserId},</if>
|
</trim>
|
where order_id = #{orderId}
|
</update>
|
|
<delete id="deleteOrderByOrderId" parameterType="String">
|
delete from t_order where order_id = #{orderId}
|
</delete>
|
|
<delete id="deleteOrderByOrderIds" parameterType="String">
|
delete from t_order where order_id in
|
<foreach item="orderId" collection="array" open="(" separator="," close=")">
|
#{orderId}
|
</foreach>
|
</delete>
|
|
<select id="pageUserOrder" resultMap="orderResultMap">
|
SELECT
|
toc.order_id orderId,
|
toc.order_no orderNo,
|
toc.order_status orderStatus,
|
toc.order_from orderFrom,
|
toc.activity_id activityId,
|
toc.receivable_money receivableMoney,
|
toc.goods_num goodsNum,
|
toc.shop_id shopId,
|
toc.create_time createTime
|
FROM t_order toc
|
WHERE toc.del_flag = 0
|
<if test="param.userId != null">
|
AND toc.user_id = #{param.userId}
|
</if>
|
<if test="param.orderStatus != null">
|
AND toc.order_status = #{param.orderStatus}
|
</if>
|
<if test="param.keyword != null and param.keyword != ''">
|
AND (toc.order_no LIKE CONCAT('%',#{param.keyword},'%') OR
|
EXISTS( SELECT 1 FROM t_order_goods tog WHERE tog.order_id = toc.order_id AND tog.goods_name LIKE CONCAT('%',#{param.keyword},'%')) )
|
</if>
|
ORDER BY toc.create_time DESC
|
</select>
|
|
<select id="listOrderGoodsByOrderId" resultType="com.ruoyi.order.domain.vo.AppUserOrderGoodsPageVo">
|
SELECT
|
tog.goods_id goodsId,
|
tog.goods_name goodsName,
|
tog.goods_introduction goodsIntroduction,
|
tog.goods_picture goodsPicture,
|
tog.order_goods_id orderGoodsId,
|
tog.goods_type goodsType,
|
tog.buy_num buyNum,
|
tog.goods_price goodsPrice,
|
tog.goods_total_money goodsRealPrice,
|
tog.cycle_num_flag cycleNumFlag,
|
tog.service_num serviceNum
|
FROM t_order_goods tog
|
WHERE tog.order_id = #{orderId}
|
<if test="keyword != null and keyword != ''">
|
AND tog.goods_name LIKE CONCAT('%',#{keyword},'%')
|
</if>
|
</select>
|
|
<select id="pageMerMemberNoClearOrder" resultType="com.ruoyi.order.domain.vo.MerMemberNoClearOrderVo">
|
SELECT
|
toc.order_id orderId,
|
toc.order_no orderNo,
|
toc.order_status orderStatus,
|
toc.order_money orderGoodsMoney,
|
toc.coupon_money couponDiscount,
|
toc.pay_type payType,
|
CASE toc.pay_type WHEN 1 THEN toc.order_money-toc.coupon_money WHEN 2 THEN toc.order_money-toc.coupon_money-toc.online_pay_money END receivableMoney,
|
toc.receivable_deposit receivableDeposit,
|
toc.pay_money payMoney,
|
(CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) relReceiveMoney,
|
CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END receiveMoney,
|
(CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) - (CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END) unPaidMoney,
|
toc.create_time createTime,
|
toc.close_flag closeFlag
|
FROM t_order toc
|
WHERE toc.del_flag = 0 AND toc.user_id = #{param.memberUserId} AND toc.order_status = 3
|
<if test="param.closeFlag != null">
|
AND toc.close_flag = #{param.closeFlag}
|
</if>
|
ORDER BY toc.create_time DESC
|
</select>
|
|
<select id="pageMerOrder" resultMap="merOrderResultMap">
|
SELECT
|
toc.user_id userId,
|
toc.order_id orderId,
|
toc.order_no orderNo,
|
toc.pay_type payType,
|
toc.order_status orderStatus,
|
toc.order_money orderGoodsMoney,
|
toc.coupon_money couponDiscount,
|
CASE toc.pay_type WHEN 1 THEN toc.order_money-toc.coupon_money WHEN 2 THEN toc.order_money-toc.coupon_money-toc.online_pay_money END receivableMoney,
|
toc.receivable_deposit receivableDeposit,
|
toc.pay_money payMoney,
|
(CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) relReceiveMoney,
|
CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END receiveMoney,
|
(CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) - (CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END) unPaidMoney,
|
toc.order_remark orderRemark,
|
toc.create_time createTime,
|
toc.order_from orderFrom,
|
CASE toc.order_from WHEN 1 THEN '商城订单' WHEN 2 THEN CONCAT('平台秒杀活动(',toc.activity_name,')') WHEN 3 THEN '线下创建' END orderFromDesc,
|
toc.activity_name activityName
|
FROM t_order toc
|
WHERE toc.del_flag = 0 AND toc.shop_id = #{param.shopId} and if(toc.order_from = 1, 1 = 1, toc.order_status = 3)<!--临时增加过滤-->
|
<if test="param.memberUserId != null and param.memberUserId != ''">
|
AND toc.user_id = #{param.memberUserId}
|
</if>
|
<if test="param.type != null and param.type ==1 ">
|
AND (toc.order_status = 2 OR toc.order_status = 3)
|
</if>
|
<if test="param.type != null and param.type ==2 ">
|
AND toc.order_status = 2
|
</if>
|
<if test="param.type != null and param.type ==3 ">
|
AND toc.order_status = 3
|
</if>
|
<if test="param.orderFrom != null and param.orderFrom != '' ">
|
AND toc.order_from = #{param.orderFrom}
|
</if>
|
<if test="param.startOrderDate != null and param.startOrderDate != '' ">
|
AND Date(toc.create_time) >= #{param.startOrderDate}
|
</if>
|
<if test="param.endOrderDate != null and param.endOrderDate != '' ">
|
AND Date(toc.create_time) <= #{param.endOrderDate}
|
</if>
|
<if test="param.keyword != null and param.keyword != ''">
|
AND (toc.order_no LIKE CONCAT('%',#{param.keyword},'%') OR EXISTS( SELECT 1 FROM t_order_goods tog WHERE tog.order_id = toc.order_id AND tog.goods_name LIKE CONCAT('%',#{param.keyword},'%'))
|
<if test="param.memberUserIdList != null and param.memberUserIdList.size()>0">
|
OR toc.user_id IN
|
<foreach collection="param.memberUserIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
)
|
</if>
|
ORDER BY toc.create_time DESC
|
</select>
|
|
<select id="listSimpleOrderGoodsByOrderId" resultType="com.ruoyi.order.domain.vo.AppUserOrderGoodsPageVo">
|
SELECT
|
tog.goods_name goodsName,
|
tog.goods_type goodsType,
|
tog.buy_num buyNum
|
FROM t_order_goods tog
|
WHERE tog.order_id = #{orderId}
|
</select>
|
|
<select id="getMgtMemberOrderTotal" resultType="com.ruoyi.order.domain.vo.MgtMemberOrderTotalVo">
|
SELECT
|
COUNT(toc.order_id) orderTotal,
|
IFNULL(SUM(IFNULL(toc.order_money,0)),0) totalOrderMoney,
|
IFNULL(SUM(IFNULL(toc.receivable_money,0)),0) totalReceivableMoney,
|
IFNULL(SUM(IFNULL(toc.discount_money,0)),0) totalDiscountMoney,
|
IFNULL(SUM(IFNULL(toc.pay_money,0)),0) totalPayMoney,
|
IFNULL(SUM((CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END)),0) totalReceiveMoney
|
FROM t_order toc
|
WHERE toc.del_flag = 0 AND toc.user_id = #{param.memberUserId}
|
<if test="param.orderStatus != null">
|
AND toc.order_status = #{param.orderStatus}
|
</if>
|
<if test="param.startOrderDate != null and param.startOrderDate != '' ">
|
AND Date(toc.create_time) >= #{param.startOrderDate}
|
</if>
|
<if test="param.endOrderDate != null and param.endOrderDate != '' ">
|
AND Date(toc.create_time) <= #{param.endOrderDate}
|
</if>
|
<if test="param.keyword != null and param.keyword != ''">
|
AND toc.order_no LIKE CONCAT('%',#{param.keyword},'%')
|
</if>
|
ORDER BY toc.create_time DESC
|
</select>
|
|
<select id="pageMgtMemberOrder" resultMap="mgtOrderResultMap">
|
SELECT
|
toc.order_id orderId,
|
toc.order_no orderNo,
|
CASE toc.order_status
|
WHEN 0 THEN "已取消"
|
WHEN 1 THEN "待支付"
|
WHEN 2 THEN "待核销"
|
WHEN 3 THEN "已完成"
|
END orderStatus,
|
CASE WHEN toc.unbinding_flag = 0 THEN toc.shop_id WHEN toc.unbinding_flag = 1 AND toc.order_from = 1 THEN toc.shop_id WHEN toc.order_status = 3 THEN toc.shop_id ELSE NULL END shopId,
|
toc.order_money orderGoodsMoney,
|
toc.discount_money discountMoney,
|
toc.receivable_money receivableMoney,
|
toc.pay_money payMoney,
|
(CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) receiveMoney,
|
toc.create_time createTime,
|
toc.order_from orderFrom,
|
CASE toc.order_from
|
WHEN 1 THEN "商城订单"
|
WHEN 2 THEN "秒杀订单"
|
WHEN 3 THEN "线下订单"
|
END orderFromDesc,
|
#{param.keyword} AS keyword
|
FROM t_order toc
|
WHERE toc.del_flag = 0 AND toc.user_id = #{param.memberUserId}
|
<if test="param.orderStatus != null">
|
AND toc.order_status = #{param.orderStatus}
|
</if>
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId} AND (toc.unbinding_flag = 0 OR (toc.unbinding_flag = 1 AND toc.order_from = 1) OR (toc.unbinding_flag = 1 AND toc.order_from = 2 AND toc.order_status = 3))
|
</if>
|
<if test="param.orderFrom != null and param.orderFrom != ''">
|
AND toc.order_from = #{param.orderFrom}
|
</if>
|
<if test="param.startOrderDate != null and param.startOrderDate != ''">
|
AND Date(toc.create_time) >= #{param.startOrderDate}
|
</if>
|
<if test="param.endOrderDate != null and param.endOrderDate != ''">
|
AND Date(toc.create_time) <= #{param.endOrderDate}
|
</if>
|
<if test="param.keyword != null and param.keyword != ''">
|
AND (toc.order_no LIKE CONCAT('%',#{param.keyword},'%') EXISTS( SELECT 1 FROM t_order_goods tog WHERE tog.order_id = toc.order_id AND tog.goods_name LIKE CONCAT('%',#{param.keyword},'%')))
|
</if>
|
ORDER BY toc.create_time DESC
|
</select>
|
|
<select id="listMgtSimpleOrderGoodsByOrderId" resultType="com.ruoyi.order.domain.vo.MgtOrderGoodsPageVo">
|
SELECT
|
tog.goods_name goodsName,
|
tog.buy_num buyNum
|
FROM t_order_goods tog
|
WHERE tog.order_id = #{orderId}
|
<if test="keyword != null and keyword != ''">
|
AND tog.goods_name LIKE CONCAT('%',#{keyword},'%')
|
</if>
|
</select>
|
|
<select id="listAllSimpleOrderGoodsByOrderId" resultType="com.ruoyi.order.domain.vo.MgtOrderGoodsPageVo">
|
SELECT
|
tog.goods_name goodsName,
|
tog.buy_num buyNum
|
FROM t_order_goods tog
|
WHERE tog.order_id = #{orderId}
|
</select>
|
|
<select id="pageMgtActivityOrder" resultType="com.ruoyi.order.domain.vo.MgtActivityOrderPageVo">
|
SELECT
|
toc.order_id orderId,
|
toc.order_no orderNo,
|
toc.out_trade_no as outTradeNo,
|
toc.user_id userId,
|
toc.activity_name activityName,
|
tog.goods_name goodsName,
|
tog.buy_num buyNum,
|
toc.order_money orderMoney,
|
toc.discount_money discountMoney,
|
toc.receivable_money receivableMoney,
|
toc.create_time createTime,
|
tog.goods_price activityPrice,
|
toc.pay_money payMoney,
|
CASE WHEN toc.order_status = 3 THEN toc.shop_id ELSE NULL END shopId,
|
toc.use_time verifyTime
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND toc.order_from = 2
|
<if test="param.orderStatus != null">
|
AND toc.order_status = #{param.orderStatus}
|
</if>
|
<if test="param.goodsType != null and param.goodsType !=''">
|
AND tog.goods_type = #{param.goodsType}
|
</if>
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId} AND (toc.unbinding_flag = 0 OR (toc.unbinding_flag = 1 AND toc.order_from = 1) OR (toc.unbinding_flag = 1 AND toc.order_from = 2 AND toc.order_status = 3))
|
</if>
|
<if test="param.shopIds != null and param.shopIds != ''">
|
AND FIND_IN_SET(toc.shop_id, #{param.shopIds})
|
</if>
|
<if test="param.keyword != null and param.keyword != ''">
|
AND (toc.order_no LIKE CONCAT('%',#{param.keyword},'%') OR toc.activity_name LIKE CONCAT('%',#{param.keyword},'%') OR FIND_IN_SET(toc.user_id, #{param.userIds}) > 0)
|
</if>
|
<if test="param.verifyStartTime != null and param.verifyStartTime != ''">
|
AND Date(toc.use_time) >= #{param.verifyStartTime}
|
</if>
|
<if test="param.verifyEndTime != null and param.verifyEndTime != ''">
|
AND Date(toc.use_time) <= #{param.verifyEndTime}
|
</if>
|
ORDER BY toc.create_time DESC
|
</select>
|
|
<select id="totalOrderFirst" resultType="com.ruoyi.order.domain.vo.MgtOrderTotal">
|
SELECT
|
COUNT(temp.order_id) orderTotal,
|
IFNULL(SUM(CASE WHEN null = temp.change_receivable_money or temp.change_receivable_money = 0 THEN temp.receivable_money ELSE temp.change_receivable_money END),0) orderMoneyTotal
|
FROM
|
(SELECT toc.order_id,toc.change_receivable_money,toc.receivable_money,toc.pay_money
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND (toc.order_from = 1 OR toc.order_from = 3)
|
<if test="param.orderStatus != null">
|
AND toc.order_status = #{param.orderStatus}
|
</if>
|
<if test="param.goodsType != null and param.goodsType !=''">
|
AND tog.goods_type = #{param.goodsType}
|
</if>
|
<!--<if test="param.shopId != null and param.shopId != ''">-->
|
<!--AND toc.shop_id = #{param.shopId}-->
|
<!--</if>-->
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId} AND (toc.unbinding_flag = 0 OR (toc.unbinding_flag = 1 AND toc.order_from = 1) OR (toc.unbinding_flag = 1 AND toc.order_from = 2 AND toc.order_status = 3))
|
</if>
|
<if test="param.shopIds != null and param.shopIds != ''">
|
AND FIND_IN_SET(toc.shop_id, #{param.shopIds}) > 0
|
</if>
|
<if test="param.keyword != null and param.keyword != ''">
|
AND (toc.order_no LIKE CONCAT('%',#{param.keyword},'%') OR toc.activity_name LIKE CONCAT('%',#{param.keyword},'%') OR FIND_IN_SET(toc.user_id, #{param.userIds}) > 0)
|
</if>
|
<if test="param.verifyStartTime != null and param.verifyStartTime != ''">
|
AND Date(toc.use_time) >= #{param.verifyStartTime}
|
</if>
|
<if test="param.verifyEndTime != null and param.verifyEndTime != ''">
|
AND Date(toc.use_time) <= #{param.verifyEndTime}
|
</if>
|
GROUP BY toc.order_id) AS temp
|
</select>
|
|
<select id="totalOrderSecond" resultType="com.ruoyi.order.domain.vo.MgtOrderTotal">
|
SELECT
|
COUNT(temp.order_id) shopOrderTotal,
|
IFNULL(SUM(CASE WHEN null = temp.change_receivable_money or temp.change_receivable_money = 0 THEN temp.receivable_money ELSE temp.change_receivable_money END),0) shopOrderMoneyTotal,
|
IFNULL(SUM(temp.pay_money),0) shopPayMoneyTotal,
|
IFNULL(SUM(CASE WHEN (CASE WHEN null = temp.change_receivable_money or temp.change_receivable_money = 0 THEN temp.receivable_money ELSE temp.change_receivable_money END) > temp.pay_money THEN (CASE WHEN null = temp.change_receivable_money or temp.change_receivable_money = 0 THEN temp.receivable_money ELSE temp.change_receivable_money END) - temp.pay_money ELSE 0 END),0) shopUnPayMoneyTotal
|
FROM
|
(SELECT toc.order_id,toc.change_receivable_money,toc.receivable_money,toc.pay_money
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND (toc.order_from = 1 OR toc.order_from = 3)
|
<if test="param.orderStatus != null">
|
AND toc.order_status = #{param.orderStatus}
|
</if>
|
<if test="param.goodsType != null and param.goodsType !=''">
|
AND tog.goods_type = #{param.goodsType}
|
</if>
|
<!--<if test="param.shopId != null and param.shopId != ''">-->
|
<!--AND toc.shop_id = #{param.shopId}-->
|
<!--</if>-->
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId} AND (toc.unbinding_flag = 0 OR (toc.unbinding_flag = 1 AND toc.order_from = 1) OR (toc.unbinding_flag = 1 AND toc.order_from = 2 AND toc.order_status = 3))
|
</if>
|
<if test="param.shopIds != null and param.shopIds != ''">
|
AND FIND_IN_SET(toc.shop_id, #{param.shopIds}) > 0
|
</if>
|
<if test="param.keyword != null and param.keyword != ''">
|
AND (toc.order_no LIKE CONCAT('%',#{param.keyword},'%') OR toc.activity_name LIKE CONCAT('%',#{param.keyword},'%') OR FIND_IN_SET(toc.user_id, #{param.userIds}) > 0)
|
</if>
|
<if test="param.verifyStartTime != null and param.verifyStartTime != ''">
|
AND Date(toc.use_time) >= #{param.verifyStartTime}
|
</if>
|
<if test="param.verifyEndTime != null and param.verifyEndTime != ''">
|
AND Date(toc.use_time) <= #{param.verifyEndTime}
|
</if>
|
GROUP BY toc.order_id) AS temp
|
</select>
|
|
<select id="totalOrderThird" resultType="com.ruoyi.order.domain.vo.MgtOrderTotal">
|
SELECT
|
COUNT(temp.order_id) activityOrderTotal,
|
IFNULL(SUM(CASE WHEN null = temp.change_receivable_money or temp.change_receivable_money = 0 THEN temp.receivable_money ELSE temp.change_receivable_money END),0) activityOrderMoneyTotal,
|
IFNULL(SUM(temp.pay_money),0) activityPayMoneyTotal,
|
IFNULL(SUM(CASE WHEN (CASE WHEN null = temp.change_receivable_money or temp.change_receivable_money = 0 THEN temp.receivable_money ELSE temp.change_receivable_money END) > temp.pay_money THEN (CASE WHEN null = temp.change_receivable_money or temp.change_receivable_money = 0 THEN temp.receivable_money ELSE temp.change_receivable_money END) - temp.pay_money ELSE 0 END),0)activityUnPayMoneyTotal
|
FROM
|
(SELECT toc.order_id,toc.change_receivable_money,toc.receivable_money,toc.pay_money
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND toc.order_from = 2
|
<if test="param.orderStatus != null">
|
AND toc.order_status = #{param.orderStatus}
|
</if>
|
<if test="param.goodsType != null and param.goodsType !=''">
|
AND tog.goods_type = #{param.goodsType}
|
</if>
|
<!--<if test="param.shopId != null and param.shopId != ''">-->
|
<!--AND toc.shop_id = #{param.shopId}-->
|
<!--</if>-->
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId} AND (toc.unbinding_flag = 0 OR (toc.unbinding_flag = 1 AND toc.order_from = 1) OR (toc.unbinding_flag = 1 AND toc.order_from = 2 AND toc.order_status = 3))
|
</if>
|
<if test="param.shopIds != null and param.shopIds != ''">
|
and toc.order_status = 3 AND FIND_IN_SET(toc.shop_id, #{param.shopIds}) > 0
|
</if>
|
<if test="param.keyword != null and param.keyword != ''">
|
AND (toc.order_no LIKE CONCAT('%',#{param.keyword},'%') OR toc.activity_name LIKE CONCAT('%',#{param.keyword},'%') OR FIND_IN_SET(toc.user_id, #{param.userIds}) > 0)
|
</if>
|
<if test="param.verifyStartTime != null and param.verifyStartTime != ''">
|
AND Date(toc.use_time) >= #{param.verifyStartTime}
|
</if>
|
<if test="param.verifyEndTime != null and param.verifyEndTime != ''">
|
AND Date(toc.use_time) <= #{param.verifyEndTime}
|
</if>
|
GROUP BY toc.order_id) AS temp
|
</select>
|
|
<select id="totalOrder" resultType="com.ruoyi.order.domain.vo.MgtOrderTotal">
|
SELECT
|
COUNT(order_id) AS orderTotal,
|
IFNULL(SUM(order_money), 0) AS orderMoneyTotal,
|
COUNT(CASE WHEN (order_from = 1 OR order_from = 3) THEN order_id ELSE NULL END) AS shopOrderTotal,
|
IFNULL(SUM(CASE WHEN (order_from = 1 OR order_from = 3) THEN order_money ELSE 0 END), 0) AS shopOrderMoneyTotal,
|
IFNULL(SUM(CASE WHEN (order_from = 1 OR order_from = 3) THEN pay_money ELSE 0 END), 0) AS shopPayMoneyTotal,
|
COUNT(CASE WHEN order_from = 2 THEN order_id ELSE NULL END) AS activityOrderTotal,
|
IFNULL(SUM(CASE WHEN order_from = 2 THEN order_money ELSE 0 END), 0) AS activityOrderMoneyTotal,
|
IFNULL(SUM(CASE WHEN order_from = 2 THEN pay_money ELSE 0 END), 0) AS activityPayMoneyTotal
|
FROM
|
(SELECT toc.order_id, toc.order_money, toc.pay_money, toc.order_from
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0
|
<if test="param.orderStatus != null">
|
AND toc.order_status = #{param.orderStatus}
|
</if>
|
<if test="param.goodsType != null and param.goodsType !=''">
|
AND tog.goods_type = #{param.goodsType}
|
</if>
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIds != null and param.shopIds != ''">
|
AND FIND_IN_SET(toc.shop_id, #{param.shopIds}) > 0
|
</if>
|
<if test="param.keyword != null and param.keyword != ''">
|
AND (toc.order_no LIKE CONCAT('%',#{param.keyword},'%') OR toc.activity_name LIKE CONCAT('%',#{param.keyword},'%') OR FIND_IN_SET(toc.user_id, #{param.userIds}) > 0)
|
</if>
|
<if test="param.verifyStartTime != null and param.verifyStartTime != ''">
|
AND Date(toc.use_time) >= #{param.verifyStartTime}
|
</if>
|
<if test="param.verifyEndTime != null and param.verifyEndTime != ''">
|
AND Date(toc.use_time) <= #{param.verifyEndTime}
|
</if>
|
GROUP BY toc.order_id) AS temp
|
</select>
|
|
<select id="pageMgtShopOrder" resultMap="mgtShopOrderResultMap">
|
SELECT
|
toc.order_id orderId,
|
toc.order_no orderNo,
|
toc.out_trade_no as outTradeNo,
|
toc.user_id userId,
|
toc.order_money orderMoney,
|
toc.discount_money discountMoney,
|
toc.receivable_money receivableMoney,
|
toc.create_time createTime,
|
toc.pay_money payMoney,
|
CASE WHEN toc.unbinding_flag = 0 THEN toc.shop_id WHEN toc.unbinding_flag = 1 AND toc.order_from = 1 THEN toc.shop_id WHEN toc.order_status = 3 THEN toc.shop_id ELSE NULL END shopId,
|
toc.use_time verifyTime,
|
CASE toc.order_from WHEN 1 THEN '小程序' WHEN 2 THEN '秒杀活动' WHEN 3 THEN '线下创建' END orderFrom,
|
#{param.keyword} AS keyword
|
FROM t_order toc
|
WHERE toc.del_flag = 0 AND (toc.order_from = 1 OR toc.order_from = 3)
|
<if test="param.orderStatus != null">
|
AND toc.order_status = #{param.orderStatus}
|
</if>
|
<if test="param.goodsType != null and param.goodsType !=''">
|
AND tog.goods_type = #{param.goodsType}
|
</if>
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId} AND (toc.unbinding_flag = 0 OR (toc.unbinding_flag = 1 AND toc.order_from = 1) OR (toc.unbinding_flag = 1 AND toc.order_from = 2 AND toc.order_status = 3))
|
</if>
|
<if test="param.shopIds != null and param.shopIds != ''">
|
AND FIND_IN_SET(toc.shop_id, #{param.shopIds}) > 0
|
</if>
|
<if test="param.keyword != null and param.keyword != ''">
|
AND (toc.order_no LIKE CONCAT('%',#{param.keyword},'%') OR toc.activity_name LIKE CONCAT('%',#{param.keyword},'%') OR FIND_IN_SET(toc.user_id, #{param.userIds}) > 0)
|
</if>
|
<if test="param.verifyStartTime != null and param.verifyStartTime != ''">
|
AND Date(toc.use_time) >= #{param.verifyStartTime}
|
</if>
|
<if test="param.verifyEndTime != null and param.verifyEndTime != ''">
|
AND Date(toc.use_time) <= #{param.verifyEndTime}
|
</if>
|
ORDER BY toc.create_time DESC
|
</select>
|
|
|
<select id="boardOrderTotal" resultType="com.ruoyi.system.api.domain.vo.MgtBulletinBoardVo">
|
SELECT
|
IFNULL(SUM(CASE WHEN order_status = 3 THEN (CASE WHEN null = change_receivable_money or 0 = change_receivable_money THEN receivable_money ELSE change_receivable_money END) ELSE 0 END),0) salesTotal,
|
IFNULL(SUM(CASE WHEN order_status = 2 THEN 1 ELSE 0 END),0) UnUseOrderTotal,
|
IFNULL(SUM(CASE WHEN order_from = 2 THEN 1 ELSE 0 END),0) activityOrderTotal
|
FROM t_order
|
WHERE del_flag = 0 AND order_status IN (2,3)
|
<if test="null != shopIds and shopIds.size() > 0">
|
and (
|
order_from = 2 and order_status = 3 and shop_id in
|
<foreach collection="shopIds" index="index" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
) or (
|
order_from != 2 and shop_id in
|
<foreach collection="shopIds" index="index" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
)
|
</if>
|
</select>
|
|
<select id="activityUserTotal" resultType="java.lang.Integer">
|
SELECT
|
COUNT(DISTINCT user_id)
|
FROM t_order
|
WHERE del_flag = 0 AND order_from = 2 AND order_status IN (2,3)
|
<if test="null != shopIds and shopIds.size() > 0">
|
AND order_status = 3 and shop_id in
|
<foreach collection="shopIds" index="index" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
</select>
|
|
<select id="getTotalOrderTotalOrderFrom" resultType="com.ruoyi.order.domain.vo.MgtTotalOrderTotalVo">
|
SELECT
|
COUNT(order_id) orderTotal,
|
IFNULL(SUM(CASE WHEN order_from = 1 THEN 1 ELSE 0 END),0) onlineTotal,
|
IFNULL(SUM(CASE WHEN order_from = 3 THEN 1 ELSE 0 END),0) offlineTotal,
|
IFNULL(SUM(CASE WHEN order_from = 2 THEN 1 ELSE 0 END),0) activityTotal,
|
IFNULL(SUM(CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END),0) orderMoney,
|
IFNULL(SUM(CASE WHEN order_from = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) ELSE 0 END),0) onlineMoney,
|
IFNULL(SUM(CASE WHEN order_from = 3 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) ELSE 0 END),0) offlineMoney,
|
IFNULL(SUM(CASE WHEN order_from = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) ELSE 0 END),0) activityMoney
|
FROM t_order WHERE del_flag = 0 AND order_status = 3
|
<if test="param.shopId != null and param.shopId != ''">
|
AND shop_id = #{param.shopId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
</select>
|
|
<select id="getMerTotalOrderTotalGoodsType" resultType="com.ruoyi.order.domain.vo.MerOrderTotalVo">
|
SELECT
|
IFNULL(SUM(CASE WHEN tog.goods_type = 1 THEN 1 ELSE 0 END),0) cycleTotal,
|
IFNULL(SUM(CASE WHEN tog.goods_type = 3 THEN 1 ELSE 0 END),0) experienceTotal,
|
IFNULL(SUM(CASE WHEN tog.goods_type = 2 THEN 1 ELSE 0 END),0) serviceTotal,
|
IFNULL(SUM(CASE WHEN tog.goods_type = 1 THEN tog.goods_receivable_money ELSE 0 END),0) cycleMoney,
|
IFNULL(SUM(CASE WHEN tog.goods_type = 3 THEN tog.goods_receivable_money ELSE 0 END),0) experienceMoney,
|
IFNULL(SUM(CASE WHEN tog.goods_type = 2 THEN tog.goods_receivable_money ELSE 0 END),0) serviceMoney
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND order_status = 3
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND toc.shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
</select>
|
|
<select id="getTotalOrderTotalGoodsType" resultType="com.ruoyi.order.domain.vo.MgtTotalOrderTotalVo">
|
SELECT
|
IFNULL(SUM(CASE WHEN tog.goods_type = 1 THEN 1 ELSE 0 END),0) cycleTotal,
|
IFNULL(SUM(CASE WHEN tog.goods_type = 3 THEN 1 ELSE 0 END),0) experienceTotal,
|
IFNULL(SUM(CASE WHEN tog.goods_type = 2 THEN 1 ELSE 0 END),0) serviceTotal,
|
IFNULL(SUM(CASE WHEN tog.goods_type = 1 THEN tog.goods_total_money ELSE 0 END),0) cycleMoney,
|
IFNULL(SUM(CASE WHEN tog.goods_type = 3 THEN tog.goods_total_money ELSE 0 END),0) experienceMoney,
|
IFNULL(SUM(CASE WHEN tog.goods_type = 2 THEN tog.goods_total_money ELSE 0 END),0) serviceMoney
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
</select>
|
|
<select id="listTotalOrderTotal" resultType="com.ruoyi.order.domain.vo.MgtMapTotalPlusVo">
|
SELECT
|
DATE_FORMAT(create_time, '%Y-%m-%d') AS mapKey,
|
COUNT(order_id) AS mapValueFirst,
|
IFNULL(SUM(CASE WHEN pay_type = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN pay_type = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) + online_pay_money ELSE 0 END),0) AS mapValueSecond
|
FROM t_order
|
WHERE del_flag = 0 AND order_status = 3
|
<if test="param.shopId != null and param.shopId != ''">
|
AND shop_id = #{param.shopId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
GROUP BY mapKey
|
ORDER BY mapKey ASC
|
</select>
|
|
<select id="listTotalOrderTotalGoodsType" resultType="com.ruoyi.order.domain.vo.MgtMapTotalPlusVo">
|
SELECT
|
tog.goods_type mapKey,
|
COUNT(DISTINCT toc.order_id) AS mapValueFirst,
|
IFNULL(SUM(tog.goods_receivable_money),0) AS mapValueSecond
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND toc.order_status = 3
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY mapKey
|
</select>
|
|
<select id="listTotalOrderTotalGoodsRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapBigTotalVo">
|
SELECT
|
tog.goods_name mapKey,
|
IFNULL(SUM(tog.goods_receivable_money),0) mapValue
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND toc.order_status = 3
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY tog.goods_name
|
ORDER BY SUM(tog.goods_receivable_money) DESC LIMIT 15
|
</select>
|
|
<select id="listTotalOrderTotalOrderFrom" resultType="com.ruoyi.system.api.domain.vo.MgtMapBigTotalVo">
|
SELECT
|
CASE toc.order_from
|
WHEN 1 THEN "商城订单"
|
WHEN 2 THEN "秒杀订单"
|
WHEN 3 THEN "线下订单"
|
END mapKey,
|
IFNULL(SUM(CASE WHEN toc.pay_type = 1 THEN (CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) WHEN toc.pay_type = 2 THEN (CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) + toc.online_pay_money ELSE 0 END),0) mapValue
|
FROM t_order toc
|
WHERE toc.del_flag = 0 AND toc.order_status = 3
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY toc.order_from
|
ORDER BY SUM(toc.order_money) DESC LIMIT 15
|
</select>
|
|
<select id="getTotalActivityTotal" resultType="com.ruoyi.order.domain.vo.MgtTotalActivityTotalVo">
|
SELECT
|
COUNT(CASE WHEN order_status = 3 THEN order_id ELSE NULL END) orderTotal,
|
IFNULL(SUM(CASE WHEN order_status = 3 AND pay_type = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN order_status = 3 AND pay_type = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) + online_pay_money ELSE 0 END),0) orderMoney,
|
COUNT(DISTINCT user_id) orderJoinPerson
|
FROM t_order WHERE del_flag = 0 AND order_from = 2 AND order_status =3 AND shop_id = #{param.shopId}
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
</select>
|
|
<select id="listTotalActivityTotalGoodsType" resultType="com.ruoyi.order.domain.vo.MgtMapTotalPlusVo">
|
SELECT
|
tog.goods_type mapKey,
|
COUNT(DISTINCT toc.order_id) AS mapValueFirst,
|
IFNULL(SUM(tog.goods_receivable_money),0) AS mapValueSecond,
|
COUNT(DISTINCT toc.user_id) AS mapValueThird
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND order_from = 2 AND order_status = 3 AND shop_id = #{param.shopId}
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY tog.goods_type
|
</select>
|
|
<select id="listTotalActivityTotal" resultType="com.ruoyi.order.domain.vo.MgtMapTotalPlusVo">
|
SELECT
|
DATE_FORMAT(create_time, '%Y-%m-%d') AS mapKey,
|
COUNT(DISTINCT order_id) AS mapValueFirst,
|
IFNULL(SUM(CASE WHEN pay_type = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN pay_type = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) + online_pay_money ELSE 0 END),0) AS mapValueSecond
|
FROM t_order
|
WHERE del_flag = 0 AND order_from = 2 AND order_status = 3 AND shop_id = #{param.shopId}
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
GROUP BY
|
mapKey
|
ORDER BY
|
mapKey ASC
|
</select>
|
|
<select id="getUserIdAgeRank" resultType="java.lang.Long">
|
SELECT
|
DISTINCT user_id
|
FROM
|
t_order
|
WHERE
|
del_flag = 0 AND order_from = 2
|
AND Date(create_time) >= DATE_SUB(CURDATE(), INTERVAL 6 DAY)
|
<if test="param.shopId != null and param.shopId != ''">
|
AND shop_id = #{param.shopId}
|
</if>
|
</select>
|
|
<select id="getTotalActivityAgeRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT
|
DATE_FORMAT(create_time, '%Y-%m-%d') AS mapKey,
|
COUNT(DISTINCT user_id) AS mapValue
|
FROM
|
t_order
|
WHERE
|
del_flag = 0 AND order_from = 2
|
AND Date(create_time) >= DATE_SUB(CURDATE(), INTERVAL 6 DAY)
|
<if test="param.shopId != null and param.shopId != ''">
|
AND shop_id = #{param.shopId}
|
</if>
|
<if test="param.userIds != null">
|
AND user_id IN
|
<foreach collection="param.userIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
GROUP BY
|
DATE_FORMAT(create_time, '%Y-%m-%d')
|
ORDER BY
|
DATE_FORMAT(create_time, '%Y-%m-%d') ASC
|
</select>
|
|
<select id="getTotalDataTotal" resultType="com.ruoyi.order.domain.vo.MgtTotalDataTotalVo">
|
SELECT
|
COUNT(DISTINCT CASE WHEN tog.goods_type = 1 THEN toc.user_id ELSE NULL END) cyclePerson,
|
COUNT(DISTINCT CASE WHEN tog.goods_type = 4 THEN toc.user_id ELSE NULL END) goodsPerson,
|
COUNT(DISTINCT CASE WHEN tog.goods_type = 4 THEN toc.order_id ELSE NULL END) goodsNumber
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON toc.order_id = tog.order_id AND toc.order_status = 3
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
</select>
|
|
<select id="getTotalDataMemberTotal" resultType="com.ruoyi.order.domain.vo.MgtTotalDataTotalVo">
|
SELECT
|
COUNT(DISTINCT CASE WHEN goods_type_1_count > 0 AND goods_type_3_count = 0 THEN user_id ELSE NULL END) AS onlyCyclePerson,
|
COUNT(DISTINCT CASE WHEN goods_type_1_count = 0 AND goods_type_3_count > 0 THEN user_id ELSE NULL END) AS onlyExperiencePerson,
|
COUNT(DISTINCT CASE WHEN goods_type_1_count > 0 AND goods_type_3_count > 0 THEN user_id ELSE NULL END) AS experienceCyclePerson,
|
COUNT(DISTINCT CASE WHEN goods_type_1_count > 0 OR goods_type_2_count > 0 OR goods_type_3_count > 0 OR goods_type_4_count > 0 THEN user_id ELSE NULL END) AS orderPerson
|
FROM (
|
SELECT
|
o.user_id,
|
COUNT(DISTINCT CASE WHEN og.goods_type = 1 THEN og.goods_id ELSE NULL END) AS goods_type_1_count,
|
COUNT(DISTINCT CASE WHEN og.goods_type = 2 THEN og.goods_id ELSE NULL END) AS goods_type_2_count,
|
COUNT(DISTINCT CASE WHEN og.goods_type = 3 THEN og.goods_id ELSE NULL END) AS goods_type_3_count,
|
COUNT(DISTINCT CASE WHEN og.goods_type = 4 THEN og.goods_id ELSE NULL END) AS goods_type_4_count
|
FROM t_order o
|
JOIN t_order_goods og ON o.order_id = og.order_id
|
WHERE o.del_flag = 0 AND og.del_flag = 0 AND o.order_status = 3
|
<if test="param.shopId != null and param.shopId != ''">
|
AND o.shop_id = #{param.shopId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(o.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(o.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY o.user_id
|
) AS user_goods_type_counts
|
</select>
|
|
<select id="shopSalesTotal" resultType="java.math.BigDecimal">
|
SELECT IFNULL(SUM(CASE pay_type WHEN 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END)+online_pay_money ELSE 0 END),0)
|
FROM t_order
|
WHERE del_flag = 0 AND order_status = 3
|
<if test="param.shopId != null and param.shopId != ''">
|
AND shop_id = #{param.shopId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
</select>
|
|
<select id="getReorderPerson" resultType="java.lang.Integer">
|
SELECT COUNT(temp.userId) FROM
|
(SELECT toc.user_id userId,
|
COUNT(DISTINCT toc.order_id) orderCount
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON toc.order_id = tog.order_id
|
WHERE toc.del_flag = 0 AND tog.goods_type = 1 AND toc.order_status = 3
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY toc.user_id) AS temp
|
WHERE temp.orderCount > 1
|
<!--SELECT COUNT(DISTINCT user_id)
|
FROM (SELECT t1.user_id, t1.pay_time, t2.pay_time as last_pay_time
|
FROM t_order t1
|
INNER JOIN (SELECT toc.user_id, toc.pay_time
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON toc.order_id = tog.order_id
|
WHERE toc.del_flag = 0 AND tog.goods_type = 1
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
ORDER BY toc.pay_time DESC LIMIT 2) t2
|
ON t1.user_id = t2.user_id AND t1.pay_time < t2.pay_time
|
WHERE t1.del_flag = 0
|
HAVING DATEDIFF(t2.pay_time, t1.pay_time) <= 30) AS temp-->
|
</select>
|
|
<select id="getReturnedPerson" resultType="java.lang.Integer">
|
SELECT COUNT(DISTINCT user_id)
|
FROM (SELECT t1.user_id, t1.pay_time, t2.pay_time as last_pay_time
|
FROM t_order t1
|
INNER JOIN (SELECT toc.user_id, toc.pay_time
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON toc.order_id = tog.order_id
|
WHERE toc.del_flag = 0 AND tog.goods_type = 1 AND toc.order_status = 3
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId}
|
</if>
|
ORDER BY toc.pay_time DESC LIMIT 2) t2
|
ON t1.user_id = t2.user_id AND t1.pay_time < t2.pay_time
|
INNER JOIN t_order_goods tog1 ON t1.order_id = tog1.order_id
|
WHERE t1.del_flag = 0 AND tog1.goods_type = 1 AND t1.shop_id = 32
|
HAVING DATEDIFF(t2.pay_time, t1.pay_time) > 30) AS temp
|
</select>
|
|
<select id="listMemberGoodsRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT
|
tog.goods_name mapKey,
|
COUNT(DISTINCT toc.user_id) mapValue
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND toc.shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY tog.goods_name
|
ORDER BY COUNT(DISTINCT toc.user_id) DESC LIMIT 15
|
</select>
|
|
|
<select id="getPlTotalOrderTotalOrderFrom" resultType="com.ruoyi.order.domain.vo.MgtTotalOrderTotalVo">
|
SELECT
|
COUNT(order_id) orderTotal,
|
IFNULL(SUM(CASE WHEN order_from = 1 THEN 1 ELSE 0 END),0) onlineTotal,
|
IFNULL(SUM(CASE WHEN order_from = 3 THEN 1 ELSE 0 END),0) offlineTotal,
|
IFNULL(SUM(CASE WHEN order_from = 2 THEN 1 ELSE 0 END),0) activityTotal,
|
IFNULL(SUM(CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END),0) orderMoney,
|
IFNULL(SUM(CASE WHEN order_from = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) ELSE 0 END),0) onlineMoney,
|
IFNULL(SUM(CASE WHEN order_from = 3 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) ELSE 0 END),0) offlineMoney,
|
IFNULL(SUM(CASE WHEN order_from = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) ELSE 0 END),0) activityMoney
|
FROM t_order WHERE del_flag = 0 AND order_status = 3
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
</select>
|
|
<select id="getPlTotalOrderTotalGoodsType" resultType="com.ruoyi.order.domain.vo.MgtTotalOrderTotalVo">
|
SELECT
|
IFNULL(SUM(CASE WHEN tog.goods_type = 1 THEN 1 ELSE 0 END),0) cycleTotal,
|
IFNULL(SUM(CASE WHEN tog.goods_type = 3 THEN 1 ELSE 0 END),0) experienceTotal,
|
IFNULL(SUM(CASE WHEN tog.goods_type = 2 THEN 1 ELSE 0 END),0) serviceTotal,
|
IFNULL(SUM(CASE WHEN tog.goods_type = 1 THEN tog.goods_receivable_money ELSE 0 END),0) cycleMoney,
|
IFNULL(SUM(CASE WHEN tog.goods_type = 3 THEN tog.goods_receivable_money ELSE 0 END),0) experienceMoney,
|
IFNULL(SUM(CASE WHEN tog.goods_type = 2 THEN tog.goods_receivable_money ELSE 0 END),0) serviceMoney
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND toc.shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
</select>
|
|
<select id="listPlTotalOrderTotal" resultType="com.ruoyi.order.domain.vo.MgtMapTotalPlusVo">
|
SELECT
|
DATE_FORMAT(create_time, '%Y-%m-%d') AS mapKey,
|
COUNT(order_id) AS mapValueFirst,
|
IFNULL(SUM(CASE WHEN pay_type = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN pay_type = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) + online_pay_money ELSE 0 END),0) AS mapValueSecond
|
FROM
|
t_order
|
WHERE del_flag = 0 AND order_status = 3
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
GROUP BY mapKey
|
ORDER BY mapKey ASC
|
</select>
|
|
<select id="listPlTotalOrderTotalGoodsType" resultType="com.ruoyi.order.domain.vo.MgtMapTotalPlusVo">
|
SELECT
|
tog.goods_type mapKey,
|
COUNT(DISTINCT toc.order_id) AS mapValueFirst,
|
IFNULL(SUM(tog.goods_receivable_money),0) AS mapValueSecond
|
FROM
|
t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND toc.order_status = 3
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND toc.shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY tog.goods_type
|
</select>
|
|
<select id="listPlTotalOrderTotalGoodsRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapBigTotalVo">
|
SELECT
|
tog.goods_name mapKey,
|
IFNULL(SUM(tog.goods_receivable_money),0) mapValue
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND order_status = 3
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND toc.shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY mapKey
|
ORDER BY mapValue DESC LIMIT 15
|
</select>
|
|
<select id="listPlTotalOrderTotalOrderFrom" resultType="com.ruoyi.system.api.domain.vo.MgtMapBigTotalVo">
|
SELECT
|
CASE toc.order_from
|
WHEN 1 THEN "商城订单"
|
WHEN 2 THEN "秒杀订单"
|
WHEN 3 THEN "线下订单"
|
END mapKey,
|
IFNULL(SUM(CASE WHEN pay_type = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN pay_type = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) + online_pay_money ELSE 0 END),0) mapValue
|
FROM t_order toc
|
WHERE toc.del_flag = 0 AND order_status = 3
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND toc.shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY toc.order_from
|
ORDER BY SUM(toc.order_money) DESC LIMIT 15
|
</select>
|
|
<select id="getPlTotalActivityTotal" resultType="com.ruoyi.order.domain.vo.MgtPlTotalActivityTotalVo">
|
SELECT
|
COUNT(CASE WHEN order_status = 3 THEN order_id ELSE NULL END) orderTotal,
|
IFNULL(SUM(CASE WHEN order_status = 3 AND pay_type = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN order_status = 3 AND pay_type = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) + online_pay_money ELSE 0 END),0) orderMoney,
|
COUNT(DISTINCT user_id) orderJoinPerson
|
FROM t_order WHERE del_flag = 0 AND order_from = 2
|
<if test="param.shopId != null and param.shopId != ''">
|
AND order_status = 3 AND shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND order_status = 3 AND shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.activityId!=null and param.activityId!=''">
|
AND activity_id = #{param.activityId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
</select>
|
|
<select id="getPlTotalActivityMemberTotal" resultType="com.ruoyi.order.domain.vo.MgtPlTotalActivityTotalVo">
|
SELECT
|
COUNT(DISTINCT toc.user_id) orderPerson,
|
COUNT(DISTINCT CASE WHEN tog.goods_type = 1 THEN toc.user_id ELSE NULL END) cyclePerson,
|
COUNT(DISTINCT CASE WHEN tog.goods_type = 3 THEN toc.user_id ELSE NULL END) experiencePerson,
|
COUNT(DISTINCT CASE WHEN tog.goods_type = 2 THEN toc.user_id ELSE NULL END) servicePerson
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND toc.order_from = 2 AND toc.new_member_flag = 1
|
<if test="param.activityId!=null and param.activityId!=''">
|
AND toc.activity_id = #{param.activityId}
|
</if>
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.order_status = 3 AND toc.shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND toc.order_status = 3 AND toc.shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
</select>
|
|
<select id="getTotalActivityMemberTotal" resultType="com.ruoyi.order.domain.vo.MgtTotalActivityTotalVo">
|
SELECT
|
COUNT(DISTINCT toc.user_id) orderPerson,
|
COUNT(DISTINCT CASE WHEN tog.goods_type = 1 THEN toc.user_id ELSE NULL END) cyclePerson,
|
COUNT(DISTINCT CASE WHEN tog.goods_type = 3 THEN toc.user_id ELSE NULL END) experiencePerson,
|
COUNT(DISTINCT CASE WHEN tog.goods_type = 2 THEN toc.user_id ELSE NULL END) servicePerson
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND toc.order_from = 2 AND toc.order_status = 3 AND toc.new_member_flag = 1 AND toc.shop_id = #{param.shopId}
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
</select>
|
|
<select id="listPlTotalActivityTotalGoodsType" resultType="com.ruoyi.order.domain.vo.MgtMapTotalPlusVo">
|
SELECT
|
tog.goods_type mapKey,
|
COUNT(DISTINCT toc.order_id) AS mapValueFirst,
|
IFNULL(SUM(tog.goods_receivable_money),0) AS mapValueSecond,
|
COUNT(DISTINCT toc.user_id) AS mapValueThird
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND toc.order_from = 2
|
<if test="param.activityId!=null and param.activityId!=''">
|
AND toc.activity_id = #{param.activityId}
|
</if>
|
<if test="param.shopId != null and param.shopId != ''">
|
AND order_status = 3 AND toc.shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND order_status = 3 AND toc.shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY tog.goods_type
|
</select>
|
|
<select id="listPlTotalActivityTotal" resultType="com.ruoyi.order.domain.vo.MgtMapTotalPlusVo">
|
SELECT
|
DATE_FORMAT(create_time, '%Y-%m-%d') AS mapKey,
|
COUNT(DISTINCT order_id) AS mapValueFirst,
|
IFNULL(SUM(CASE WHEN pay_type = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN pay_type = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) + online_pay_money ELSE 0 END),0) AS mapValueSecond
|
FROM t_order
|
WHERE del_flag = 0 AND order_from = 2 AND order_status = 3
|
<if test="param.activityId!=null and param.activityId!=''">
|
AND activity_id = #{param.activityId}
|
</if>
|
<if test="param.shopId != null and param.shopId != ''">
|
AND shop_id = #{param.shopId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
GROUP BY mapKey
|
ORDER BY mapKey ASC
|
</select>
|
|
<select id="getPlUserIdAgeRank" resultType="java.lang.Long">
|
SELECT
|
DISTINCT user_id
|
FROM t_order
|
WHERE del_flag = 0 AND order_from = 2
|
AND Date(create_time) >= DATE_SUB(CURDATE(), INTERVAL 6 DAY)
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
</select>
|
|
<select id="getPlTotalActivityAgeRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT
|
DATE_FORMAT(create_time, '%Y-%m-%d') AS mapKey,
|
COUNT(DISTINCT user_id) AS mapValue
|
FROM t_order
|
WHERE del_flag = 0 AND order_from = 2
|
AND Date(create_time) >= DATE_SUB(CURDATE(), INTERVAL 6 DAY)
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.userIds != null">
|
AND user_id IN
|
<foreach collection="param.userIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
GROUP BY
|
mapKey
|
ORDER BY
|
mapValue ASC
|
</select>
|
|
<select id="listPlTotalShopActivityRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT
|
shop_id AS mapKey,
|
COUNT(DISTINCT activity_id) AS mapValue
|
FROM t_order
|
WHERE del_flag = 0 AND order_from = 2 AND order_status = 3
|
<if test="param.activityId!=null and param.activityId!=''">
|
AND activity_id = #{param.activityId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
GROUP BY mapKey
|
ORDER BY mapValue DESC LIMIT 15
|
</select>
|
|
<select id="listPlTotalShopActivitySalesRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapBigTotalVo">
|
SELECT
|
shop_id AS mapKey,
|
IFNULL(SUM(CASE WHEN pay_type = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN pay_type = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END)+online_pay_money ELSE 0 END),0) AS mapValue
|
FROM t_order
|
WHERE del_flag = 0 AND order_from = 2 AND order_status = 3
|
<if test="param.activityId!=null and param.activityId!=''">
|
AND activity_id = #{param.activityId}
|
</if>
|
<if test="param.shopId != null and param.shopId != ''">
|
AND shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
GROUP BY mapKey
|
ORDER BY mapValue DESC LIMIT 15
|
</select>
|
|
<select id="listPlTotalActivitySalesRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapBigTotalVo">
|
SELECT
|
activity_name AS mapKey,
|
IFNULL(SUM(CASE WHEN pay_type = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN pay_type = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END)+online_pay_money ELSE 0 END),0) AS mapValue
|
FROM t_order
|
WHERE del_flag = 0 AND order_from = 2 AND order_status = 3
|
<if test="param.activityId!=null and param.activityId!=''">
|
AND activity_id = #{param.activityId}
|
</if>
|
<if test="param.shopId != null and param.shopId != ''">
|
AND shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
GROUP BY mapKey
|
ORDER BY mapValue DESC LIMIT 15
|
</select>
|
|
<select id="getMerHomeShopTotalVo" resultType="com.ruoyi.system.api.domain.vo.MerHomeShopTotalVo">
|
SELECT
|
IFNULL(SUM(CASE WHEN order_status = 2 AND order_from = 1 THEN 1 ELSE 0 END),0) unHandleOrder,
|
IFNULL(SUM(CASE WHEN order_status = 3 AND pay_type = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN order_status = 3 AND pay_type = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END)+online_pay_money ELSE 0 END),0) shopTurnover
|
FROM t_order
|
WHERE del_flag = 0 AND shop_id = #{shopId} AND order_status IN (2,3)
|
</select>
|
|
<select id="getMerHomeShopServiceTotalVo" resultType="com.ruoyi.system.api.domain.vo.MerHomeShopTotalVo">
|
SELECT
|
COUNT(DISTINCT CASE WHEN goods_type = 1 THEN user_id END) cycleSurp,
|
COUNT(DISTINCT CASE WHEN goods_type = 3 THEN user_id END) explorationSurp
|
FROM t_consumer_goods
|
WHERE del_flag = 0 AND shop_id = #{shopId} AND cycle_num_flag = 1 AND service_status = 1
|
</select>
|
|
<select id="getMerHomeShopsTotalVo" resultType="com.ruoyi.system.api.domain.vo.MerHomeShopTotalVo">
|
SELECT
|
IFNULL(SUM(CASE WHEN order_status = 2 THEN 1 ELSE 0 END),0) unHandleOrder,
|
IFNULL(SUM(pay_money),0) shopTurnover
|
FROM t_order
|
WHERE del_flag = 0
|
<if test="list != null and list.size() > 0">
|
AND shop_id IN
|
<foreach collection="list" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
</select>
|
|
<select id="getMemberUnpaidOrder" resultType="java.math.BigDecimal">
|
SELECT IFNULL(SUM((CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END)-IFNULL(CASE toc.pay_type WHEN 1 THEN toc.online_pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END,0)),0)
|
FROM t_order toc
|
WHERE toc.del_flag = 0 AND toc.user_id = #{param.userId} AND toc.shop_id = #{param.shopId} AND toc.order_status IN (2,3) AND toc.close_flag = 0
|
</select>
|
|
|
<select id="getMerOrderTotalOrderFrom" resultType="com.ruoyi.order.domain.vo.MerOrderTotalVo">
|
SELECT
|
COUNT(order_id) orderTotal,
|
IFNULL(SUM(CASE WHEN order_from = 1 THEN 1 ELSE 0 END),0) onlineTotal,
|
IFNULL(SUM(CASE WHEN order_from = 3 THEN 1 ELSE 0 END),0) offlineTotal,
|
IFNULL(SUM(CASE WHEN order_from = 2 THEN 1 ELSE 0 END),0) activityTotal,
|
IFNULL(SUM(CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END),0) orderMoney,
|
IFNULL(SUM(CASE WHEN order_from = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) ELSE 0 END),0) onlineMoney,
|
IFNULL(SUM(CASE WHEN order_from = 3 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) ELSE 0 END),0) offlineMoney,
|
IFNULL(SUM(CASE WHEN order_from = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) ELSE 0 END),0) activityMoney
|
FROM t_order WHERE del_flag = 0 AND order_status = 3
|
<if test="param.shopId != null and param.shopId != ''">
|
AND shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
</select>
|
|
|
<select id="listMerOrderDistributionTotal" resultType="com.ruoyi.order.domain.vo.MgtMapTotalPlusVo">
|
SELECT
|
DATE(toc.create_time) AS mapKey,
|
COUNT(DISTINCT tog.order_id) AS mapValueFirst,
|
SUM(tog.goods_receivable_money) AS mapValueSecond
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON toc.order_id = tog.order_id
|
WHERE toc.del_flag = 0 AND toc.order_status = 3 AND tog.del_flag = 0
|
<if test="param.goodsType != null and param.goodsType != ''">
|
AND tog.goods_type = #{param.goodsType}
|
</if>
|
<if test="param.shopId != null and param.shopId != ''">
|
AND shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
AND toc.create_time >= DATE_SUB(CURDATE(), INTERVAL 4 DAY)
|
GROUP BY mapKey
|
</select>
|
|
<select id="listMerOrderTotalGoodsType" resultType="com.ruoyi.order.domain.vo.MgtMapTotalPlusVo">
|
SELECT
|
tog.goods_type mapKey,
|
COUNT(DISTINCT toc.order_id) AS mapValueFirst,
|
IFNULL(SUM(tog.goods_receivable_money),0) AS mapValueSecond
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND toc.order_status = 3
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND toc.shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY tog.goods_type
|
</select>
|
|
<select id="listMerOrderTotalGoodsRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapBigTotalVo">
|
SELECT
|
tog.goods_name mapKey,
|
IFNULL(SUM(tog.goods_receivable_money),0) mapValue
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND toc.order_status = 3
|
<if test="param.goodsType != null and param.goodsType != ''">
|
AND tog.goods_type = #{param.goodsType}
|
</if>
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND toc.shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY mapKey
|
ORDER BY mapValue DESC LIMIT 15
|
</select>
|
|
<select id="listMerOrderTotalOrderFrom" resultType="com.ruoyi.system.api.domain.vo.MgtMapBigTotalVo">
|
SELECT
|
CASE toc.order_from
|
WHEN 1 THEN "商城订单"
|
WHEN 2 THEN "秒杀订单"
|
WHEN 3 THEN "线下订单"
|
END mapKey,
|
IFNULL(SUM(tog.goods_receivable_money),0) mapValue
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND toc.order_status = 3
|
<if test="param.goodsType != null and param.goodsType != ''">
|
AND tog.goods_type = #{param.goodsType}
|
</if>
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND toc.shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY mapKey
|
ORDER BY mapValue DESC LIMIT 15
|
</select>
|
|
<select id="totalMerOrder" resultType="com.ruoyi.order.domain.vo.MerTotalOrderVo">
|
SELECT
|
COUNT(toc.order_id) orderTotal,
|
IFNULL(SUM(CASE toc.pay_type WHEN 1 THEN toc.receivable_money WHEN 2 THEN order_money-coupon_money-online_pay_money END),0) receivableMoney,
|
IFNULL(SUM(CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END),0) relReceiveMoney,
|
IFNULL(SUM(IF(toc.order_from = 3, toc.offline_pay_money, IF(toc.order_from != 3 AND toc.pay_type = 1, toc.online_pay_money, IFNULL(toc.offline_pay_money,0)))),0) relPayMoney,
|
IFNULL(SUM((CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END)-IFNULL(IF(toc.order_from = 3, toc.offline_pay_money, IF(toc.order_from != 3 AND toc.pay_type = 1, toc.online_pay_money, IFNULL(toc.offline_pay_money,0))),0)),0) unpaidMoney,
|
IFNULL(SUM(CASE toc.pay_type WHEN 2 THEN toc.online_pay_money ELSE 0 END),0) receivableDeposit
|
FROM t_order toc
|
WHERE toc.del_flag = 0 AND toc.shop_id = #{param.shopId} and if(toc.order_from = 1, 1 = 1, toc.order_status = 3)<!--临时增加过滤-->
|
<if test="param.memberUserId != null and param.memberUserId != ''">
|
AND toc.user_id = #{param.memberUserId}
|
</if>
|
<if test="param.type != null and param.type ==1 ">
|
AND (toc.order_status = 2 OR toc.order_status = 3)
|
</if>
|
<if test="param.type != null and param.type ==2 ">
|
AND toc.order_status = 2
|
</if>
|
<if test="param.type != null and param.type ==3 ">
|
AND toc.order_status = 3
|
</if>
|
<if test="param.orderFrom != null and param.orderFrom != '' ">
|
AND toc.order_from = #{param.orderFrom}
|
</if>
|
<if test="param.startOrderDate != null and param.startOrderDate != '' ">
|
AND Date(toc.create_time) >= #{param.startOrderDate}
|
</if>
|
<if test="param.endOrderDate != null and param.endOrderDate != '' ">
|
AND Date(toc.create_time) <= #{param.endOrderDate}
|
</if>
|
<if test="param.keyword != null and param.keyword != ''">
|
AND (toc.order_no LIKE CONCAT('%',#{param.keyword},'%') OR
|
toc.order_id IN (SELECT DISTINCT tog.order_id FROM t_order_goods tog WHERE tog.goods_name LIKE CONCAT('%',#{param.keyword},'%'))
|
<if test="param.memberUserIdList != null and param.memberUserIdList.size()>0">
|
OR toc.user_id IN
|
<foreach collection="param.memberUserIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
)
|
</if>
|
ORDER BY toc.create_time DESC
|
</select>
|
|
<select id="pageMgtShopAllOrder" resultMap="mgtShopAllOrderResultMap">
|
SELECT
|
toc.order_id orderId,
|
toc.order_no orderNo,
|
toc.user_id userId,
|
toc.order_money orderMoney,
|
toc.discount_money discountMoney,
|
CASE toc.pay_type WHEN 1 THEN toc.order_money-toc.coupon_money WHEN 2 THEN toc.order_money-toc.coupon_money-toc.online_pay_money END receivableMoney,
|
(CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) payMoney,
|
CASE toc.order_from WHEN 1 THEN '小程序' WHEN 2 THEN CONCAT('秒杀活动(',toc.activity_name,')') WHEN 3 THEN '线下创建' END orderFrom,
|
CASE toc.order_status
|
WHEN 0 THEN "已取消"
|
WHEN 1 THEN "待支付"
|
WHEN 2 THEN "待核销"
|
WHEN 3 THEN "已完成"
|
END orderStatus
|
FROM t_order toc
|
WHERE toc.del_flag = 0
|
<if test="param.orderFrom != null">
|
AND toc.order_from = #{param.orderFrom}
|
</if>
|
<if test="param.orderStatus != null">
|
AND toc.order_status = #{param.orderStatus}
|
</if>
|
<if test="param.orderNo != null and param.orderNo !=''">
|
AND toc.order_no LIKE CONCAT('%',#{param.orderNo},'%')
|
</if>
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId}
|
</if>
|
<if test="param.startOrderDate != null and param.startOrderDate != '' ">
|
AND Date(toc.create_time) >= #{param.startOrderDate}
|
</if>
|
<if test="param.endOrderDate != null and param.endOrderDate != '' ">
|
AND Date(toc.create_time) <= #{param.endOrderDate}
|
</if>
|
ORDER BY toc.create_time DESC
|
</select>
|
|
|
<select id="countUserActivityByActivity" resultType="java.lang.Integer">
|
SELECT COUNT(order_id)
|
FROM t_order
|
WHERE del_flag = 0 AND order_from =2 AND user_id = #{userId} AND activity_id = #{activityId} AND order_status > 1
|
</select>
|
|
<select id="getStaffActivityOrderTotal" resultType="com.ruoyi.order.domain.vo.StaffActivityOrderTotalVo">
|
SELECT
|
COUNT(DISTINCT toc.order_id) orderTotal,
|
IFNULL(SUM(CASE WHEN toc.pay_type = 1 THEN (CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) WHEN toc.pay_type = 2 THEN (CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) + toc.online_pay_money ELSE 0 END),0) orderMoney,
|
COUNT(DISTINCT toc.user_id) memberTotal
|
FROM t_order toc
|
WHERE toc.del_flag = 0 AND toc.shop_id = #{param.shopId} AND toc.order_from = 2 AND toc.order_status = 3
|
<if test="param.activityId !=null and param.activityId != ''">
|
AND toc.activity_id = #{param.activityId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
</select>
|
|
<select id="getStaffActivityOrderGoodsTotal" resultType="com.ruoyi.order.domain.vo.StaffActivityOrderTotalVo">
|
SELECT
|
IFNULL(SUM(CASE WHEN tog.goods_type = 1 THEN 1 ELSE 0 END),0) cycleTotal,
|
IFNULL(SUM(CASE WHEN tog.goods_type = 3 THEN 1 ELSE 0 END),0) experienceTotal,
|
IFNULL(SUM(CASE WHEN tog.goods_type = 2 THEN 1 ELSE 0 END),0) serviceTotal
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND toc.shop_id = #{param.shopId} AND toc.order_from = 2 AND toc.order_status = 3
|
<if test="param.activityId !=null and param.activityId != ''">
|
AND toc.activity_id = #{param.activityId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
</select>
|
|
<select id="getStaffActivityTotal" resultType="com.ruoyi.order.domain.vo.StaffActivityTotalVo">
|
SELECT
|
COUNT(toa.user_id) memberTotal,
|
IFNULL(SUM(CASE WHEN tog.goods_type = 1 THEN 1 ELSE 0 END),0) cycleTotal,
|
IFNULL(SUM(CASE WHEN tog.goods_type = 3 THEN 1 ELSE 0 END),0) experienceTotal,
|
IFNULL(SUM(CASE WHEN tog.goods_type = 2 THEN 1 ELSE 0 END),0) serviceTotal
|
FROM t_order toa
|
INNER JOIN t_order_goods tog ON tog.order_id = toa.order_id
|
WHERE toa.order_from = 2 AND toa.shop_id = #{param.shopId} AND toa.order_status = 3 AND toa.new_member_flag = 1
|
<if test="param.activityId !=null and param.activityId != ''">
|
AND toa.activity_id = #{param.activityId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toa.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toa.create_time) <= #{param.endDate}
|
</if>
|
</select>
|
|
<select id="listStaffActivityOrderDistributionTotal" resultType="com.ruoyi.order.domain.vo.MgtMapTotalPlusVo">
|
SELECT
|
DATE(toc.create_time) AS mapKey,
|
COUNT(DISTINCT tog.order_id) AS mapValueFirst,
|
SUM(tog.goods_receivable_money) AS mapValueSecond
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON toc.order_id = tog.order_id
|
WHERE toc.del_flag = 0 AND toc.shop_id = #{param.shopId} AND toc.order_from = 2 AND toc.order_status = 3
|
<if test="param.goodsType !=null and param.goodsType != ''">
|
AND tog.goods_type = #{param.goodsType}
|
</if>
|
<if test="param.activityId !=null and param.activityId != ''">
|
AND toc.activity_id = #{param.activityId}
|
</if>
|
AND toc.create_time >= DATE_SUB(CURDATE(), INTERVAL 4 DAY)
|
GROUP BY mapKey
|
</select>
|
|
<select id="listStaffOrderTotalGoodsType" resultType="com.ruoyi.order.domain.vo.MgtMapTotalPlusVo">
|
SELECT
|
tog.goods_type mapKey,
|
COUNT(DISTINCT toc.order_id) AS mapValueFirst,
|
IFNULL(SUM(tog.goods_receivable_money),0) AS mapValueSecond
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND toc.shop_id = #{param.shopId} AND toc.order_from = 2 AND toc.order_status = 3
|
<if test="param.activityId !=null and param.activityId != ''">
|
AND toc.activity_id = #{param.activityId}
|
</if>
|
GROUP BY tog.goods_type
|
</select>
|
|
<select id="getStaffActivityGetMemberTotal" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT
|
DATE(toc.create_time) AS mapKey,
|
COUNT(DISTINCT toc.user_id) AS mapValue
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.order_from = 2 AND toc.new_member_flag = 1 AND toc.order_status = 3 AND toc.shop_id = #{param.shopId}
|
<if test="param.activityId !=null and param.activityId != ''">
|
AND toc.activity_id = #{param.activityId}
|
</if>
|
<if test="param.goodsType !=null and param.goodsType != ''">
|
AND tog.goods_type = #{param.goodsType}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY mapKey
|
</select>
|
|
<select id="getMgtActivityGetMemberTotal" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT
|
DATE(toc.create_time) AS mapKey,
|
COUNT(DISTINCT toc.user_id) AS mapValue
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.order_from = 2 AND toc.new_member_flag = 1 AND toc.order_status = 3
|
<if test="param.activityId!=null and param.activityId!=''">
|
AND toc.activity_id = #{param.activityId}
|
</if>
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND toc.shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.userIdList !=null and param.userIdList.size()>0">
|
AND toc.user_id IN
|
<foreach collection="param.userIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY mapKey
|
</select>
|
|
<select id="getStaffActivityMemberTotal" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT
|
DATE(toc.create_time) AS mapKey,
|
COUNT(DISTINCT toc.user_id) AS mapValue
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND toc.shop_id = #{param.shopId} AND toc.order_from = 2 AND toc.order_status IN (2,3)
|
<if test="param.activityId !=null and param.activityId != ''">
|
AND toc.activity_id = #{param.activityId}
|
</if>
|
<if test="param.userIdList !=null and param.userIdList.size()>0">
|
AND toc.user_id IN
|
<foreach collection="param.userIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY mapKey
|
</select>
|
|
|
<select id="getMgtActivityMemberTotal" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT
|
DATE(toc.create_time) AS mapKey,
|
COUNT(DISTINCT toc.user_id) AS mapValue
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND toc.order_from = 2 AND toc.order_status IN (2,3)
|
<if test="param.activityId!=null and param.activityId!=''">
|
AND toc.activity_id = #{param.activityId}
|
</if>
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND toc.shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.userIdList !=null and param.userIdList.size()>0">
|
AND toc.user_id IN
|
<foreach collection="param.userIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY mapKey
|
</select>
|
|
<select id="getActivityMemberTotal" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT
|
DATE(toc.create_time) AS mapKey,
|
COUNT(DISTINCT toc.user_id) AS mapValue
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND toc.order_from = 2 AND toc.order_status IN (2,3)
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId}
|
</if>
|
<if test="param.userIdList !=null and param.userIdList.size()>0">
|
AND toc.user_id IN
|
<foreach collection="param.userIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(toc.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(toc.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY mapKey
|
</select>
|
|
<select id="countUserBuyGoodsNum" resultType="java.lang.Integer">
|
select count(1) from (SELECT toc.user_id
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND toc.order_status > 1 AND tog.goods_id = #{goodsId} group by toc.user_id) as aa
|
</select>
|
|
<select id="getMgtShopAllOrderTotal" resultType="com.ruoyi.order.domain.vo.MgtShopAllOrderTotal">
|
SELECT
|
COUNT(DISTINCT toc.order_id) orderTotal,
|
IFNULL(SUM(toc.order_money),0) totalOrderMoney,
|
IFNULL(SUM(CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END),0) totalReceiveMoney,
|
IFNULL(SUM(CASE WHEN toc.pay_type = 2 THEN toc.online_pay_money ELSE 0 END),0) totalDepositMoney
|
FROM t_order toc
|
WHERE toc.del_flag = 0
|
<if test="param.orderFrom != null">
|
AND toc.order_from = #{param.orderFrom}
|
</if>
|
<if test="param.orderStatus != null">
|
AND toc.order_status = #{param.orderStatus}
|
</if>
|
<if test="param.orderNo != null and param.orderNo !=''">
|
AND toc.order_no LIKE CONCAT('%',#{param.orderNo},'%')
|
</if>
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId}
|
</if>
|
<if test="param.startOrderDate != null and param.startOrderDate != '' ">
|
AND Date(toc.create_time) >= #{param.startOrderDate}
|
</if>
|
<if test="param.endOrderDate != null and param.endOrderDate != '' ">
|
AND Date(toc.create_time) <= #{param.endOrderDate}
|
</if>
|
ORDER BY toc.create_time DESC
|
</select>
|
|
|
<select id="pageMerMemberOrder" resultType="com.ruoyi.order.domain.vo.MerMemberOrderVo">
|
SELECT
|
toc.order_id orderId,
|
toc.order_no orderNo,
|
toc.pay_type payType,
|
toc.order_status orderStatus,
|
toc.order_money orderGoodsMoney,
|
toc.coupon_money couponDiscount,
|
CASE toc.pay_type WHEN 1 THEN toc.order_money-toc.coupon_money WHEN 2 THEN toc.order_money-toc.coupon_money-toc.online_pay_money END receivableMoney,
|
toc.receivable_deposit receivableDeposit,
|
toc.pay_money payMoney,
|
(CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) relReceiveMoney,
|
CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END receiveMoney,
|
(CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) - (CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END) unPaidMoney,
|
tpr.pay_time receiveMoneyTime,
|
tpr.pay_money thisReceiveMoney,
|
CASE tpr.pay_type WHEN 1 THEN "微信" WHEN 2 THEN "现金" WHEN 3 THEN "支付宝" END thisReceiveType
|
FROM t_pay_record tpr
|
INNER JOIN t_order toc ON tpr.order_id = toc.order_id
|
WHERE toc.del_flag = 0 AND toc.user_id = #{userId} AND toc.shop_id = #{shopId} AND (toc.order_status = 2 OR toc.order_status = 3)
|
ORDER BY toc.create_time DESC
|
</select>
|
|
<select id="pageMerMemberPayOrder" resultMap="merOrderResultMap">
|
SELECT
|
toc.user_id userId,
|
toc.order_id orderId,
|
toc.order_no orderNo,
|
toc.pay_type payType,
|
toc.order_status orderStatus,
|
toc.order_money orderGoodsMoney,
|
toc.coupon_money couponDiscount,
|
CASE toc.pay_type WHEN 1 THEN toc.order_money-toc.coupon_money WHEN 2 THEN toc.order_money-toc.coupon_money-toc.online_pay_money END receivableMoney,
|
toc.receivable_deposit receivableDeposit,
|
toc.pay_money payMoney,
|
(CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) relReceiveMoney,
|
CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END receiveMoney,
|
(CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) - (CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END) unPaidMoney,
|
toc.order_remark orderRemark,
|
toc.create_time createTime,
|
toc.order_from orderFrom,
|
CASE toc.order_from WHEN 1 THEN '商城订单' WHEN 2 THEN CONCAT('平台秒杀活动(',toc.activity_name,')') WHEN 3 THEN '线下创建' END orderFromDesc
|
FROM t_order toc
|
WHERE toc.del_flag = 0 AND (toc.order_status = 2 OR toc.order_status = 3) AND toc.shop_id = #{param.shopId} AND toc.user_id = #{param.memberUserId}
|
ORDER BY toc.create_time DESC
|
</select>
|
|
<select id="shopSalesRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapBigTotalVo">
|
SELECT
|
shop_id mapKey,
|
SUM(CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) mapValue
|
FROM t_order
|
WHERE del_flag = 0 AND order_status = 3 AND shop_id IN
|
<foreach collection="shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
GROUP BY shop_id
|
ORDER BY mapValue DESC LIMIT 15
|
</select>
|
|
<select id="getAgencyTotalVo" resultType="com.ruoyi.system.api.domain.vo.AgencyTotalVo">
|
SELECT
|
IFNULL(SUM(CASE pay_type WHEN 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END)+online_pay_money ELSE 0 END),0) areaTurnover
|
FROM t_order
|
WHERE del_flag = 0 AND order_status = 3 AND shop_id IN
|
<foreach collection="shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</select>
|
|
<select id="getMerMemberSimpleTotalVo" resultType="com.ruoyi.system.api.domain.vo.MerMemberSimpleTotalVo">
|
SELECT
|
COUNT(DISTINCT toc.order_id) userNumber,
|
IFNULL(SUM(CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END),0) payMoney,
|
IFNULL(SUM(CASE WHEN toc.close_flag = 0 THEN (CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) - (CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END) ELSE 0 END),0) unpaidMoney
|
FROM t_order toc
|
WHERE toc.del_flag = 0 AND toc.user_id = #{param.userId} AND toc.shop_id = #{param.shopId} AND toc.order_status IN (2,3)
|
</select>
|
</mapper>
|