jiangqs
2023-08-06 431dde90aa20f7652092fc0bfa9e6a1a28b06b9f
ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
@@ -82,7 +82,9 @@
        <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">
            <result column="goodsName" property="goodsName"/>
@@ -294,10 +296,12 @@
        toc.coupon_money couponDiscount,
        toc.receivable_money receivableMoney,
        toc.receivable_deposit receivableDeposit,
        toc.pay_money payMoney,
        toc.change_receivable_money receiveMoney,
        IFNULL(toc.offline_pay_money,0) payMoney,
        toc.change_receivable_money-IFNULL(toc.offline_pay_money,0) unPaidMoney,
        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
        WHERE toc.del_flag = 0 AND toc.user_id = #{userId} AND toc.order_status &gt;= 2 AND toc.close_flag = 0
        ORDER BY toc.create_time DESC
    </select>
@@ -319,7 +323,8 @@
        tog.goods_type goodsType,
        tog.buy_num buyNum,
        toc.create_time createTime,
        toc.order_from orderFrom
        toc.order_from orderFrom,
        toc.activity_name activityName
        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}
@@ -363,10 +368,16 @@
        toc.order_status orderStatus,
        toc.order_money orderGoodsMoney,
        toc.coupon_money couponDiscount,
        toc.receivable_money receivableMoney,
        toc.receivable_money-toc.online_pay_money receivableMoney,
        toc.receivable_deposit receivableDeposit,
        toc.pay_money payMoney
        FROM t_order toc
        toc.change_receivable_money payMoney,
        IFNULL(toc.offline_pay_money,0) receiveMoney,
        IFNULL(toc.receivable_money-IFNULL(CASE toc.pay_type WHEN 1 THEN toc.online_pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END,0),0) 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.order_status = 2 OR toc.order_status = 3)
        ORDER BY toc.create_time DESC
    </select>
@@ -377,9 +388,10 @@
        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(IFNULL(toc.pay_money,0)),0) totalPayMoney,
        IFNULL(SUM(IFNULL(toc.change_receivable_money,0)),0) totalReceiveMoney
        FROM t_order toc
        WHERE toc.del_flag = 0 AND toc.user_id = #{param.userId}
        WHERE toc.del_flag = 0 AND toc.user_id = #{param.memberUserId}
        <if test="param.orderStatus != null">
            AND toc.order_status = #{param.orderStatus}
        </if>
@@ -410,6 +422,7 @@
        toc.discount_money discountMoney,
        toc.receivable_money receivableMoney,
        toc.pay_money payMoney,
        toc.change_receivable_money receiveMoney,
        tog.goods_name goodsName,
        tog.buy_num buyNum,
        toc.create_time createTime,
@@ -438,7 +451,7 @@
            AND Date(toc.create_time) &lt;= #{param.endOrderDate}
        </if>
        <if test="param.keyword != null and param.keyword != ''">
            AND toc.order_no LIKE CONCAT('%',#{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>
@@ -487,9 +500,35 @@
    <select id="totalOrderFirst" resultType="com.ruoyi.order.domain.vo.MgtOrderTotal">
        SELECT
            COUNT(order_id) orderTotal,
            IFNULL(SUM(order_money),0) orderMoneyTotal
        FROM t_order ORDER BY create_time DESC
        COUNT(temp.order_id) orderTotal,
        IFNULL(SUM(temp.order_money),0) orderMoneyTotal
        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}) &gt; 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}) &gt; 0)
        </if>
        <if test="param.verifyStartTime != null and param.verifyStartTime != ''">
            AND Date(toc.use_time) &gt;= #{param.verifyStartTime}
        </if>
        <if test="param.verifyEndTime != null and param.verifyEndTime != ''">
            AND Date(toc.use_time) &lt;= #{param.verifyEndTime}
        </if>
        GROUP BY toc.order_id) AS temp
    </select>
    <select id="totalOrderSecond" resultType="com.ruoyi.order.domain.vo.MgtOrderTotal">
@@ -647,6 +686,13 @@
            IFNULL(SUM(CASE WHEN order_from = 2 THEN 1 ELSE 0 END),0) activityOrderTotal
        FROM t_order
        WHERE del_flag = 0
    </select>
    <select id="activityUserTotal" resultType="java.lang.Integer">
        SELECT
            COUNT(DISTINCT user_id)
        FROM t_order
        WHERE del_flag = 0 AND order_from = 2
    </select>
    <select id="getTotalOrderTotalOrderFrom" resultType="com.ruoyi.order.domain.vo.MgtTotalOrderTotalVo">
@@ -1344,7 +1390,7 @@
        SELECT
            DATE(toc.create_time) AS mapKey,
            COUNT(DISTINCT tog.order_id) AS mapValueFirst,
            SUM(tog.order_money) AS mapValueSecond
            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 tog.del_flag = 0 AND tog.goods_type = #{param.goodsType}
@@ -1454,28 +1500,28 @@
        FROM t_order
        WHERE del_flag = 0 AND shop_id = #{param.shopId}
        <if test="param.memberUserId != null and param.memberUserId != ''">
            AND toc.user_id = #{param.memberUserId}
            AND user_id = #{param.memberUserId}
        </if>
        <if test="param.type != null and param.type ==1 ">
            AND (toc.order_status = 2 OR toc.order_status = 3)
            AND (order_status = 2 OR order_status = 3)
        </if>
        <if test="param.type != null and param.type ==2 ">
            AND toc.order_status = 2
            AND order_status = 2
        </if>
        <if test="param.type != null and param.type ==3 ">
            AND toc.order_status = 3
            AND order_status = 3
        </if>
        <if test="param.orderFrom != null and param.orderFrom != '' ">
            AND toc.order_from = #{param.orderFrom}
            AND order_from = #{param.orderFrom}
        </if>
        <if test="param.startOrderDate != null and param.startOrderDate != '' ">
            AND Date(toc.create_time) &gt;= #{param.startOrderDate}
            AND Date(create_time) &gt;= #{param.startOrderDate}
        </if>
        <if test="param.endOrderDate != null and param.endOrderDate != '' ">
            AND Date(toc.create_time) &lt;= #{param.endOrderDate}
            AND Date(create_time) &lt;= #{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},'%'))
            AND order_no LIKE CONCAT('%',#{param.keyword},'%')
        </if>
    </select>
@@ -1632,4 +1678,57 @@
        INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
        WHERE toc.del_flag = 0 AND toc.order_status &gt; 1 AND toc.user_id = #{userId} AND tog.goods_id = #{goodsId}
    </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(toc.change_receivable_money),0) totalReceiveMoney
        FROM t_order toc
        WHERE toc.del_flag = 0 AND (toc.order_from = 1 OR toc.order_from = 3)
        <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) &gt;= #{param.startOrderDate}
        </if>
        <if test="param.endOrderDate != null and param.endOrderDate != '' ">
            AND Date(toc.create_time) &lt;= #{param.endOrderDate}
        </if>
        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,
        toc.receivable_money-toc.online_pay_money receivableMoney,
        toc.receivable_deposit receivableDeposit,
        toc.change_receivable_money payMoney,
        IFNULL(toc.offline_pay_money,0) receiveMoney,
        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 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>
</mapper>