hjl
2024-07-01 03c6572c7918beaa20365e69c9694a11f0d9948a
ruoyi-service/ruoyi-admin/src/main/resources/mapper/admin/OrderMapper.xml
@@ -21,6 +21,7 @@
        <result column="createTime" property="createTime"/>
        <result column="updateTime" property="updateTime"/>
        <result column="is_delete" property="isDelete"/>
        <result column="apply_reason" property="applyReason"/>
    </resultMap>
@@ -29,12 +30,12 @@
        FROM t_order
        <where>
            YEAR(createTime) = YEAR(NOW())
            <!--<if test="ids != null and ids.size() != 0">
                and city_id in
                <foreach collection="ids" item="id" open="(" separator="," close=")">
        #{id}
            </foreach>
            </if>-->
            <if test="cityList != null and cityList.size() != 0">
                and city in
                <foreach collection="cityList" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
            <if test="orderState != null and orderState != ''">
                and state = #{orderState}
            </if>
@@ -54,12 +55,12 @@
        FROM t_order
        <where>
            YEARWEEK(DATE_FORMAT(createTime, '%Y-%m-%d')) = YEARWEEK(NOW())
            <!--<if test="ids != null and ids.size() != 0">
                and city_id in
                <foreach collection="ids" item="id" open="(" separator="," close=")">
        #{id}
            </foreach>
            </if>-->
            <if test="cityList != null and cityList.size() != 0">
                and city in
                <foreach collection="cityList" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
            <if test="orderState != null and orderState != ''">
                and state = #{orderState}
            </if>
@@ -80,12 +81,12 @@
        <where>
            MONTH(createTime) = MONTH(NOW())
              AND YEAR(createTime) = YEAR(NOW())
            <!--<if test="ids != null and ids.size() != 0">
                and city_id in
                <foreach collection="ids" item="id" open="(" separator="," close=")">
        #{id}
            </foreach>
            </if>-->
            <if test="cityList != null and cityList.size() != 0">
                and city in
                <foreach collection="cityList" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
            <if test="orderState != null and orderState != ''">
                and state = #{orderState}
            </if>
@@ -105,12 +106,12 @@
        FROM t_order
        <where>
            DATE(createTime) = CURDATE()
            <!--<if test="ids != null and ids.size() != 0">
                and city_id in
                <foreach collection="ids" item="id" open="(" separator="," close=")">
        #{id}
            </foreach>
            </if>-->
            <if test="cityList != null and cityList.size() != 0">
                and city in
                <foreach collection="cityList" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
            <if test="orderState != null and orderState != ''">
                and state = #{orderState}
            </if>
@@ -131,6 +132,12 @@
        <where>
            is_delete = 0
              and state = 4
            <if test="cityList != null and cityList.size() != 0">
                and city in
                <foreach collection="cityList" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
            <if test="start != null and start != ''">
                and createTime <![CDATA[ >= ]]> #{start}
            </if>
@@ -146,6 +153,12 @@
        where YEAR(createTime) = YEAR(NOW())
          and is_delete = 0
          and state = 4
        <if test="cityList != null and cityList.size() != 0">
            and city in
            <foreach collection="cityList" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
    </select>
    <select id="totalMoneyByMonth" resultType="java.math.BigDecimal">
@@ -155,14 +168,20 @@
          AND YEAR(createTime) = YEAR(NOW())
          and is_delete = 0
          and state = 4
        <if test="cityList != null and cityList.size() != 0">
            and city in
            <foreach collection="cityList" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
    </select>
    <select id="orderCount" resultType="com.ruoyi.admin.vo.OrderCountVO">
        SELECT w.real_name                                  AS realName,
               w.profile_picture                            as profilePicture,
               SUM(CASE WHEN o.state = 3 THEN 1 ELSE 0 END) AS toBeCompletedNumber,
               SUM(CASE WHEN o.state = 4 THEN 1 ELSE 0 END) AS completedNumber,
        SUM(CASE WHEN o.state = 5 THEN 1 ELSE 0 END) AS reInvestment
               SUM(CASE WHEN o.state = 2 THEN 1 ELSE 0 END) AS toBeCompletedNumber,
               SUM(CASE WHEN o.state = 3 THEN 1 ELSE 0 END) AS completedNumber,
               SUM(CASE WHEN o.state = 4 THEN 1 ELSE 0 END) AS reInvestment
        FROM t_order o
                 LEFT JOIN sys_master_worker w ON o.server_id = w.id
        WHERE w.is_delete = 0
@@ -175,4 +194,96 @@
        </if>
        GROUP BY w.real_name, w.profile_picture
    </select>
    <select id="queryPage" resultMap="BaseResultMap">
        select o.*, c.apply_reason
        from t_order o
                 left join sys_change_dispatch c on o.id = c.order_id
        <where>
            o.is_delete = 0
              AND (c.is_delete = 0 OR c.is_delete IS NULL)
            <if test="data.orderNumber != null and data.orderNumber != ''">
                and o.order_number like concat('%', #{data.orderNumber}, '%')
            </if>
            <if test="data.cityName != null and data.cityName != ''">
                and o.city like concat('%', #{data.cityName}, '%')
            </if>
            <if test="data.reservationName != null and data.reservationName != ''">
                and o.reservation_name like concat('%', #{data.reservationName}, '%')
            </if>
            <if test="data.reservationPhone != null and data.reservationPhone != ''">
                and o.reservation_phone like concat('%', #{data.reservationPhone}, '%')
            </if>
            <if test="data.state != null">
                and o.state = #{data.state}
            </if>
            <if test="data.workerName != null and data.workerName != ''">
                and o.server_name like concat('%', #{data.workerName}, '%')
            </if>
            <if test="data.workerPhone != null and data.workerPhone != ''">
                and o.server_phone like concat('%', #{data.workerPhone}, '%')
            </if>
            <if test="data.serveName != null and data.serveName != ''">
                and o.serve_name like concat('%', #{data.serveName}, '%')
            </if>
            <if test="data.orderTimeStart != null and data.orderTimeStart != ''">
                and DATE(o.createTime) <![CDATA[ >= ]]> #{data.orderTimeStart}
            </if>
            <if test="data.orderTimeEnd != null and data.orderTimeEnd != ''">
                and DATE(o.createTime) <![CDATA[ <= ]]> #{data.orderTimeEnd}
            </if>
            <if test="data.startTime != null and data.startTime != ''">
                and DATE(o.time) <![CDATA[ >= ]]> #{data.startTime}
            </if>
            <if test="data.endTime != null and data.endTime != ''">
                and DATE(o.time) <![CDATA[ <= ]]> #{data.endTime}
            </if>
        </where>
    </select>
    <select id="orderPageCount" resultMap="BaseResultMap">
        select o.*, c.apply_reason
        from t_order o
        left join sys_change_dispatch c on o.id = c.order_id
        <where>
            o.is_delete = 0
            AND (c.is_delete = 0 OR c.is_delete IS NULL)
            <if test="data.orderNumber != null and data.orderNumber != ''">
                and o.order_number like concat('%', #{data.orderNumber}, '%')
            </if>
            <if test="data.cityName != null and data.cityName != ''">
                and o.city like concat('%', #{data.cityName}, '%')
            </if>
            <if test="data.reservationName != null and data.reservationName != ''">
                and o.reservation_name like concat('%', #{data.reservationName}, '%')
            </if>
            <if test="data.reservationPhone != null and data.reservationPhone != ''">
                and o.reservation_phone like concat('%', #{data.reservationPhone}, '%')
            </if>
            <if test="data.state != null">
                and o.state = #{data.state}
            </if>
            <if test="data.workerName != null and data.workerName != ''">
                and o.server_name like concat('%', #{data.workerName}, '%')
            </if>
            <if test="data.workerPhone != null and data.workerPhone != ''">
                and o.server_phone like concat('%', #{data.workerPhone}, '%')
            </if>
            <if test="data.serveName != null and data.serveName != ''">
                and o.serve_name like concat('%', #{data.serveName}, '%')
            </if>
            <if test="data.orderTimeStart != null and data.orderTimeStart != ''">
                and DATE(o.createTime) <![CDATA[ >= ]]> #{data.orderTimeStart}
            </if>
            <if test="data.orderTimeEnd != null and data.orderTimeEnd != ''">
                and DATE(o.createTime) <![CDATA[ <= ]]> #{data.orderTimeEnd}
            </if>
            <if test="data.startTime != null and data.startTime != ''">
                and DATE(o.time) <![CDATA[ >= ]]> #{data.startTime}
            </if>
            <if test="data.endTime != null and data.endTime != ''">
                and DATE(o.time) <![CDATA[ <= ]]> #{data.endTime}
            </if>
        </where>
    </select>
</mapper>