<?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" />
|
<collection property="appUserOrderGoodsPageVoList" ofType="com.ruoyi.order.domain.vo.AppUserOrderGoodsPageVo">
|
<result column="orderGoodsId" property="orderGoodsId"/>
|
<result column="goodsId" property="goodsId"/>
|
<result column="goodsName" property="goodsName"/>
|
<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="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="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="payMoney" property="payMoney"/>
|
<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">
|
<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="orderFrom" property="orderFrom" />
|
<result column="createTime" property="createTime" />
|
<collection property="mgtOrderGoodsVoList" ofType="com.ruoyi.order.domain.vo.MerOrderGoodsPageVo">
|
<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="userId" property="userId"/>
|
<result column="orderMoney" property="orderMoney"/>
|
<result column="createTime" property="createTime"/>
|
<result column="receivableMoney" property="receivableMoney"/>
|
<result column="payMoney" property="payMoney"/>
|
<result column="unPaidMoney" property="unPaidMoney"/>
|
<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">
|
<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.receivable_money receivableMoney,
|
toc.goods_num goodsNum,
|
toc.shop_id shopId,
|
tog.goods_id goodsId,
|
tog.goods_name goodsName,
|
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 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.keyword != null and param.keyword != ''">
|
AND (toc.order_no LIKE CONCAT('%',#{param.keyword},'%') OR tog.goods_name LIKE CONCAT('%',#{param.keyword},'%'))
|
</if>
|
ORDER BY toc.create_time DESC
|
</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.receivable_money receivableMoney,
|
toc.receivable_deposit receivableDeposit,
|
toc.pay_money payMoney,
|
toc.create_time createTime
|
FROM t_order toc
|
WHERE toc.del_flag = 0 AND toc.user_id = #{userId} AND toc.order_status = 2 AND toc.close_flag = 0
|
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.order_status orderStatus,
|
toc.order_money orderGoodsMoney,
|
toc.coupon_money couponDiscount,
|
toc.receivable_money receivableMoney,
|
toc.receivable_deposit receivableDeposit,
|
toc.pay_money payMoney,
|
toc.order_remark orderRemark,
|
tog.goods_name goodsName,
|
tog.goods_type goodsType,
|
tog.buy_num buyNum,
|
toc.create_time createTime,
|
toc.order_from orderFrom
|
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.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 toc.create_time >= #{param.startOrderDate}
|
</if>
|
<if test="param.endOrderDate != null and param.endOrderDate != '' ">
|
AND toc.create_time <= #{param.endOrderDate}
|
</if>
|
<if test="param.keyword != null and param.keyword != ''">
|
AND (toc.order_no LIKE CONCAT('%',#{param.keyword},'%') OR tog.goods_name LIKE CONCAT('%',#{param.keyword},'%'))
|
</if>
|
ORDER BY toc.create_time DESC
|
</select>
|
|
<select id="pageMerMemberOrder" 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.receivable_money receivableMoney,
|
toc.receivable_deposit receivableDeposit,
|
toc.pay_money payMoney
|
FROM t_order toc
|
WHERE toc.del_flag = 0 AND toc.user_id = #{userId} AND (toc.order_status = 2 OR toc.order_status = 3)
|
ORDER BY toc.create_time DESC
|
</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
|
FROM t_order toc
|
WHERE toc.del_flag = 0 AND toc.user_id = #{param.userId}
|
<if test="param.orderStatus != null">
|
AND toc.order_status = #{param.orderStatus}
|
</if>
|
<if test="param.startOrderDate != null and param.startOrderDate != '' ">
|
AND toc.create_time >= #{param.startOrderDate}
|
</if>
|
<if test="param.endOrderDate != null and param.endOrderDate != '' ">
|
AND 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,
|
toc.shop_id shopId,
|
toc.order_money orderGoodsMoney,
|
toc.discount_money discountMoney,
|
toc.receivable_money receivableMoney,
|
toc.pay_money payMoney,
|
tog.goods_name goodsName,
|
tog.buy_num buyNum,
|
toc.create_time createTime,
|
toc.order_from orderFrom,
|
CASE toc.order_from
|
WHEN 1 THEN "商城订单"
|
WHEN 2 THEN "秒杀活动订单"
|
WHEN 3 THEN "线下创建订单"
|
END orderFromDesc
|
FROM t_order toc
|
INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
|
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}
|
</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 toc.create_time >= #{param.startOrderDate}
|
</if>
|
<if test="param.endOrderDate != null and param.endOrderDate != ''">
|
AND 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="pageMgtActivityOrder" resultType="com.ruoyi.order.domain.vo.MgtActivityOrderPageVo">
|
SELECT
|
toc.order_id orderId,
|
toc.order_no orderNo,
|
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,
|
toc.pay_money payMoney,
|
toc.shop_id 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}
|
</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 toc.use_time >= #{param.verifyStartTime}
|
</if>
|
<if test="param.verifyEndTime != null and param.verifyEndTime != ''">
|
AND 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(order_id) orderTotal,
|
IFNULL(SUM(order_money),0) orderMoneyTotal
|
FROM t_order toc.create_time DESC
|
</select>
|
|
<select id="totalOrderSecond" resultType="com.ruoyi.order.domain.vo.MgtOrderTotal">
|
SELECT
|
COUNT(temp.order_id) shopOrderTotal,
|
IFNULL(SUM(temp.order_money),0) shopOrderMoneyTotal,
|
IFNULL(SUM(temp.pay_money),0) shopPayMoneyTotal FROM
|
(SELECT toc.order_id,toc.order_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.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 toc.use_time >= #{param.verifyStartTime}
|
</if>
|
<if test="param.verifyEndTime != null and param.verifyEndTime != ''">
|
AND 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) shopOrderTotal,
|
IFNULL(SUM(temp.order_money),0) shopOrderMoneyTotal,
|
IFNULL(SUM(temp.pay_money),0) shopPayMoneyTotal FROM
|
(SELECT toc.order_id,toc.order_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.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 toc.use_time >= #{param.verifyStartTime}
|
</if>
|
<if test="param.verifyEndTime != null and param.verifyEndTime != ''">
|
AND 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 toc.use_time >= #{param.verifyStartTime}
|
</if>
|
<if test="param.verifyEndTime != null and param.verifyEndTime != ''">
|
AND 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.user_id userId,
|
tog.goods_name goodsName,
|
tog.buy_num buyNum,
|
toc.order_money orderMoney,
|
toc.discount_money discountMoney,
|
toc.receivable_money receivableMoney,
|
toc.create_time createTime,
|
toc.pay_money payMoney,
|
toc.shop_id shopId,
|
toc.use_time verifyTime,
|
CASE toc.order_from WHEN 1 THEN '小程序' WHEN 3 THEN '线下创建' END orderFrom
|
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.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 toc.use_time >= #{param.verifyStartTime}
|
</if>
|
<if test="param.verifyEndTime != null and param.verifyEndTime != ''">
|
AND 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
|
SUM(CASE WHEN order_status = 3 THEN pay_money ELSE 0 END) salesTotal,
|
SUM(CASE WHEN order_status = 2 THEN 1 ELSE 0 END) UnUseOrderTotal,
|
SUM(CASE WHEN order_from = 2 THEN 1 ELSE 0 END) activityOrderTotal
|
FROM t_order
|
WHERE del_flag = 0
|
</select>
|
|
<select id="getTotalOrderTotalOrderFrom" resultType="com.ruoyi.order.domain.vo.MgtTotalOrderTotalVo">
|
SELECT
|
COUNT(order_id) orderTotal,
|
SUM(CASE WHEN order_from = 1 THEN 1 ELSE 0 END) onlineTotal,
|
SUM(CASE WHEN order_from = 3 THEN 1 ELSE 0 END) offlineTotal,
|
SUM(CASE WHEN order_from = 2 THEN 1 ELSE 0 END) activityTotal,
|
IFNULL(SUM(order_money),0) orderMoney,
|
SUM(CASE WHEN order_from = 1 THEN order_money ELSE 0 END) onlineMoney,
|
SUM(CASE WHEN order_from = 3 THEN order_money ELSE 0 END) offlineMoney,
|
SUM(CASE WHEN order_from = 2 THEN order_money ELSE 0 END) activityMoney
|
FROM t_order WHERE del_flag = 0
|
<if test="param.shopId != null and param.shopId != ''">
|
AND shop_id = #{param.shopId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND create_time >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND create_time <= #{param.endDate}
|
</if>
|
</select>
|
|
<select id="getTotalOrderTotalGoodsType" resultType="com.ruoyi.order.domain.vo.MgtTotalOrderTotalVo">
|
SELECT
|
SUM(CASE WHEN tog.goods_type = 1 THEN 1 ELSE 0 END) cycleTotal,
|
SUM(CASE WHEN tog.goods_type = 3 THEN 1 ELSE 0 END) experienceTotal,
|
SUM(CASE WHEN tog.goods_type = 2 THEN 1 ELSE 0 END) serviceTotal,
|
SUM(CASE WHEN tog.goods_type = 1 THEN tog.goods_total_money ELSE 0 END) cycleMoney,
|
SUM(CASE WHEN tog.goods_type = 3 THEN tog.goods_total_money ELSE 0 END) experienceMoney,
|
SUM(CASE WHEN tog.goods_type = 2 THEN tog.goods_total_money ELSE 0 END) 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 toc.create_time >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND 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(order_money),0) AS mapValueSecond
|
FROM
|
t_order
|
WHERE
|
del_flag = 0
|
AND create_time >= DATE_SUB(CURDATE(), INTERVAL 6 DAY)
|
<if test="param.shopId != null and param.shopId != ''">
|
AND shop_id = #{param.shopId}
|
</if>
|
GROUP BY
|
order_date
|
ORDER BY
|
order_date 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_total_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
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId}
|
</if>
|
GROUP BY tog.goods_type
|
</select>
|
|
<select id="listTotalOrderTotalGoodsRank" resultType="com.ruoyi.order.domain.vo.MgtMapTotalPlusVo">
|
SELECT
|
tog.goods_name mapKey,
|
IFNULL(SUM(tog.goods_total_money),0) mapValueSecond
|
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 toc.create_time >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND toc.create_time <= #{param.endDate}
|
</if>
|
GROUP BY tog.goods_name
|
ORDER BY SUM(tog.goods_total_money) DESC LIMIT 10
|
</select>
|
|
<select id="listTotalOrderTotalOrderFrom" resultType="com.ruoyi.order.domain.vo.MgtMapTotalPlusVo">
|
SELECT
|
CASE toc.order_from
|
WHEN 1 THEN "商城订单"
|
WHEN 2 THEN "秒杀活动订单"
|
WHEN 3 THEN "线下创建订单"
|
END mapKey,
|
IFNULL(SUM(toc.order_money),0) mapValueSecond
|
FROM t_order toc
|
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 toc.create_time >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND toc.create_time <= #{param.endDate}
|
</if>
|
GROUP BY toc.order_from
|
ORDER BY SUM(toc.order_money) DESC LIMIT 10
|
</select>
|
|
<select id="getTotalActivityTotal" resultType="com.ruoyi.order.domain.vo.MgtTotalActivityTotalVo">
|
SELECT
|
COUNT(order_id) orderTotal,
|
IFNULL(SUM(order_money),0) orderMoney,
|
COUNT(DISTINCT user_id) orderPerson
|
FROM t_order WHERE del_flag = 0 AND order_from = 2
|
<if test="param.shopId != null and param.shopId != ''">
|
AND shop_id = #{param.shopId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND create_time >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND 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_total_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
|
<if test="param.shopId != null and param.shopId != ''">
|
AND toc.shop_id = #{param.shopId}
|
</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 toc.order_id) AS mapValueFirst,
|
SUM(toc.order_money) AS mapValueSecond,
|
FROM
|
t_order
|
WHERE
|
del_flag = 0 AND order_from = 2
|
AND create_time >= DATE_SUB(CURDATE(), INTERVAL 6 DAY)
|
<if test="param.shopId != null and param.shopId != ''">
|
AND shop_id = #{param.shopId}
|
</if>
|
GROUP BY
|
order_date
|
ORDER BY
|
order_date 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 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.order.domain.vo.MgtMapTotalPlusVo">
|
SELECT
|
DATE_FORMAT(create_time, '%Y-%m-%d') AS mapKey,
|
COUNT(DISTINCT toc.user_id) AS mapValueFirst
|
FROM
|
t_order
|
WHERE
|
del_flag = 0 AND order_from = 2
|
AND 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
|
order_date
|
ORDER BY
|
order_date ASC
|
</select>
|
|
<select id="getTotalDataTotal" 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 THEN user_id ELSE NULL END) AS cyclePerson,
|
COUNT(DISTINCT CASE WHEN goods_type_4_count > 0 THEN user_id ELSE NULL END) AS goodsPerson,
|
SUM(goods_type_4_count) AS goodsNumber,
|
COUNT(DISTINCT CASE WHEN goods_type_1_count > 0 AND goods_type_2_count > 0 AND goods_type_3_count > 0 AND 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
|
<if test="param.shopId != null and param.shopId != ''">
|
AND o.shop_id = #{param.shopId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND o.create_time >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND o.create_time <= #{param.endDate}
|
</if>
|
GROUP BY o.user_id
|
) AS user_goods_type_counts
|
</select>
|
|
<select id="getReorderPerson" 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
|
<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
|
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
|
<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
|
WHERE t1.del_flag = 0
|
HAVING DATEDIFF(t2.pay_time, t1.pay_time) > 30) AS temp
|
</select>
|
|
<select id="listMemberGoodsRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapTotalVo">
|
SELECT
|
tog.goods_name mapKey,
|
COUNT(DISTINCT toc.userId) 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="shopIdList != null and shopIdList != ''">
|
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 toc.create_time >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND toc.create_time <= #{param.endDate}
|
</if>
|
GROUP BY tog.goods_name
|
ORDER BY COUNT(DISTINCT toc.userId) DESC LIMIT 15
|
</select>
|
|
|
<select id="getPlTotalOrderTotalOrderFrom" resultType="com.ruoyi.order.domain.vo.MgtTotalOrderTotalVo">
|
SELECT
|
COUNT(order_id) orderTotal,
|
SUM(CASE WHEN order_from = 1 THEN 1 ELSE 0 END) onlineTotal,
|
SUM(CASE WHEN order_from = 3 THEN 1 ELSE 0 END) offlineTotal,
|
SUM(CASE WHEN order_from = 2 THEN 1 ELSE 0 END) activityTotal,
|
IFNULL(SUM(order_money),0) orderMoney,
|
SUM(CASE WHEN order_from = 1 THEN order_money ELSE 0 END) onlineMoney,
|
SUM(CASE WHEN order_from = 3 THEN order_money ELSE 0 END) offlineMoney,
|
SUM(CASE WHEN order_from = 2 THEN order_money ELSE 0 END) activityMoney
|
FROM t_order WHERE del_flag = 0
|
<if test="param.shopIdList != null and param.shopIdList != ''">
|
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 create_time >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND create_time <= #{param.endDate}
|
</if>
|
</select>
|
|
<select id="getPlTotalOrderTotalGoodsType" resultType="com.ruoyi.order.domain.vo.MgtTotalOrderTotalVo">
|
SELECT
|
SUM(CASE WHEN tog.goods_type = 1 THEN 1 ELSE 0 END) cycleTotal,
|
SUM(CASE WHEN tog.goods_type = 3 THEN 1 ELSE 0 END) experienceTotal,
|
SUM(CASE WHEN tog.goods_type = 2 THEN 1 ELSE 0 END) serviceTotal,
|
SUM(CASE WHEN tog.goods_type = 1 THEN tog.goods_total_money ELSE 0 END) cycleMoney,
|
SUM(CASE WHEN tog.goods_type = 3 THEN tog.goods_total_money ELSE 0 END) experienceMoney,
|
SUM(CASE WHEN tog.goods_type = 2 THEN tog.goods_total_money ELSE 0 END) 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 != ''">
|
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 toc.create_time >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND 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(order_money),0) AS mapValueSecond
|
FROM
|
t_order
|
WHERE
|
del_flag = 0
|
AND create_time >= DATE_SUB(CURDATE(), INTERVAL 6 DAY)
|
<if test="param.shopIdList != null and param.shopIdList != ''">
|
AND toc.shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
GROUP BY
|
order_date
|
ORDER BY
|
order_date 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_total_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
|
<if test="param.shopIdList != null and param.shopIdList != ''">
|
AND toc.shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
GROUP BY tog.goods_type
|
</select>
|
|
<select id="listPlTotalOrderTotalGoodsRank" resultType="com.ruoyi.order.domain.vo.MgtMapTotalPlusVo">
|
SELECT
|
tog.goods_name mapKey,
|
IFNULL(SUM(tog.goods_total_money),0) mapValueSecond
|
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 != ''">
|
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 toc.create_time >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND toc.create_time <= #{param.endDate}
|
</if>
|
GROUP BY tog.goods_name
|
ORDER BY SUM(tog.goods_total_money) DESC LIMIT 10
|
</select>
|
|
<select id="listPlTotalOrderTotalOrderFrom" resultType="com.ruoyi.order.domain.vo.MgtMapTotalPlusVo">
|
SELECT
|
CASE toc.order_from
|
WHEN 1 THEN "商城订单"
|
WHEN 2 THEN "秒杀活动订单"
|
WHEN 3 THEN "线下创建订单"
|
END mapKey,
|
IFNULL(SUM(toc.order_money),0) mapValueSecond
|
FROM t_order toc
|
WHERE toc.del_flag = 0
|
<if test="param.shopIdList != null and param.shopIdList != ''">
|
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 toc.create_time >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND toc.create_time <= #{param.endDate}
|
</if>
|
GROUP BY toc.order_from
|
ORDER BY SUM(toc.order_money) DESC LIMIT 10
|
</select>
|
|
<select id="getPlTotalActivityTotal" resultType="com.ruoyi.order.domain.vo.MgtPlTotalActivityTotalVo">
|
SELECT
|
COUNT(order_id) orderTotal,
|
IFNULL(SUM(order_money),0) orderMoney,
|
COUNT(DISTINCT user_id) orderPerson
|
FROM t_order WHERE del_flag = 0 AND order_from = 2
|
<if test="param.shopIdList != null and param.shopIdList != ''">
|
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 create_time >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND 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_total_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
|
<if test="param.shopIdList != null and param.shopIdList != ''">
|
AND toc.shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</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 toc.order_id) AS mapValueFirst,
|
IFNULL(SUM(toc.order_money),0) AS mapValueSecond,
|
FROM t_order
|
WHERE del_flag = 0 AND order_from = 2
|
AND create_time >= DATE_SUB(CURDATE(), INTERVAL 6 DAY)
|
<if test="param.shopIdList != null and param.shopIdList != ''">
|
AND toc.shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
GROUP BY
|
order_date
|
ORDER BY
|
order_date 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 create_time >= DATE_SUB(CURDATE(), INTERVAL 6 DAY)
|
<if test="param.shopIdList != null and param.shopIdList != ''">
|
AND toc.shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
</select>
|
|
<select id="getPlTotalActivityAgeRank" resultType="com.ruoyi.order.domain.vo.MgtMapTotalPlusVo">
|
SELECT
|
DATE_FORMAT(create_time, '%Y-%m-%d') AS mapKey,
|
COUNT(DISTINCT toc.user_id) AS mapValueFirst
|
FROM t_order
|
WHERE del_flag = 0 AND order_from = 2
|
AND create_time >= DATE_SUB(CURDATE(), INTERVAL 6 DAY)
|
<if test="param.shopIdList != null and param.shopIdList != ''">
|
AND toc.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 rder_date
|
ORDER BY order_date ASC
|
</select>
|
|
<select id="listPlTotalShopActivityRank" resultType="com.ruoyi.order.domain.vo.MgtMapTotalPlusVo">
|
SELECT
|
shop_id AS mapKey,
|
COUNT(order_id) AS mapValueFirst
|
FROM t_order
|
WHERE del_flag = 0 AND order_from = 2
|
<if test="param.shopIdList != null and param.shopIdList != ''">
|
AND shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
GROUP BY shop_id
|
ORDER BY COUNT(toc.order_id) DESC LIMIT 15
|
</select>
|
|
<select id="listPlTotalShopActivitySalesRank" resultType="com.ruoyi.order.domain.vo.MgtMapTotalPlusVo">
|
SELECT
|
shop_id AS mapKey,
|
IFNULL(SUM(order_money),0) AS mapValueSecond
|
FROM t_order
|
WHERE del_flag = 0 AND order_from = 2
|
<if test="param.shopIdList != null and param.shopIdList != ''">
|
AND shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
GROUP BY shop_id
|
ORDER BY SUM(order_money) DESC LIMIT 15
|
</select>
|
|
<select id="listPlTotalActivitySalesRank" resultType="com.ruoyi.order.domain.vo.MgtMapTotalPlusVo">
|
SELECT
|
activity_name AS mapKey,
|
IFNULL(SUM(order_money),0) AS mapValueSecond
|
FROM t_order
|
WHERE del_flag = 0 AND order_from = 2
|
<if test="param.shopIdList != null and param.shopIdList != ''">
|
AND shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
GROUP BY activity_name
|
ORDER BY SUM(order_money) DESC LIMIT 15
|
</select>
|
|
<select id="getMerHomeShopTotalVo" resultType="com.ruoyi.system.api.domain.vo.MerHomeShopTotalVo">
|
SELECT
|
SUM(CASE WHEN order_status = 2 THEN 1 ELSE 0 END) unHandleOrder,
|
SUM(pay_money) shopTurnover
|
FROM t.order
|
WHERE del_flag = 0 AND shopId = #{shopId}
|
</select>
|
</mapper>
|