gongzuming
2024-10-22 4138fbb0a67b070beda2d13b27ff213ccf2a24de
src/main/resources/mapper/payment/DeliveryOrderMapper.xml
@@ -101,8 +101,12 @@
        <if test="condition.orderNo != null and condition.orderNo != ''">
            AND q.order_no LIKE concat('%', #{condition.orderNo},'%')
        </if>
        <if test="condition.status != null and condition.status != ''">
            AND q.status = #{condition.status}
        <if test="condition.statusList != null and condition.statusList.size > 0">
            AND q.status in
            <foreach collection="condition.statusList" item="status" open="(" separator="," close=")">
                #{status}
            </foreach>
        </if>
        <if test="condition.supplierId != null">
@@ -151,8 +155,12 @@
        <if test="condition.orderNo != null and condition.orderNo != ''">
            AND q.order_no LIKE concat('%', #{condition.orderNo},'%')
        </if>
        <if test="condition.status != null and condition.status != ''">
            AND q.status = #{condition.status}
        <if test="condition.statusList != null and condition.statusList.size > 0">
            AND q.status in
            <foreach collection="condition.statusList" item="status" open="(" separator="," close=")">
                #{status}
            </foreach>
        </if>
        <if test="condition.warehouseId != null">
@@ -180,6 +188,83 @@
    </select>
    <select id="statisticStationList" resultType="com.mzl.flower.dto.response.flower.StationStatisticDTO">
        select tt.*,
        (SELECT
        SUM( oi.num )
        FROM
        t_delivery_order o
        LEFT JOIN t_delivery_order_item i ON o.id = i.delivery_id
        LEFT JOIN t_order_item oi ON oi.id = i.order_item_id
        LEFT JOIN t_supplier_info s ON s.id = o.supplier_id
        LEFT JOIN t_station st ON st.id = s.station_id
        LEFT JOIN t_order t ON t.id = i.order_id
        WHERE o.deleted = 0 AND s.station_id = tt.stationId
        AND o.`status` IN ( 'CHECKED' )
        <if test="userId !=null and userId !=''">
            AND st.user_ids LIKE concat('%', #{userId},'%')
        </if>
        <if test="name !=null and name !=''">
            AND ( s.id LIKE concat('%', #{name},'%')  OR
            s.contact_tel LIKE concat('%', #{name},'%') OR
            s.`name` LIKE concat('%', #{name},'%') OR
            st.`name` LIKE concat('%', #{name},'%') OR
            t.warehouse_location_code LIKE concat('%', #{name},'%')
            )
        </if>
        <if test="startDate != null">
            AND o.create_time &gt; #{startDate}
        </if>
        <if test="endDate != null">
            AND o.create_time &lt;= #{endDate}
        </if>
        <if test="statusList != null and statusList.size > 0">
            AND o.status in
            <foreach collection="statusList" item="status" open="(" separator="," close=")">
                #{status}
            </foreach>
        </if>
        GROUP BY s.station_id, st.`name`) checkedSupplierCount,
            (
        SELECT
        s.station_id AS stationId,
        st.`name`,
        SUM( oi.num ) AS totalNum
        FROM
        t_delivery_order o
        LEFT JOIN t_delivery_order_item i ON o.id = i.delivery_id
        LEFT JOIN t_order_item oi ON oi.id = i.order_item_id
        LEFT JOIN t_supplier_info s ON s.id = o.supplier_id
        LEFT JOIN t_station st ON st.id = s.station_id
        LEFT JOIN t_order t ON t.id = i.order_id
        WHERE o.deleted = 0 AND s.station_id = tt.stationId
        AND o.`status` IN ( 'PENDING', 'ARRIVED')
        <if test="userId !=null and userId !=''">
            AND st.user_ids LIKE concat('%', #{userId},'%')
        </if>
        <if test="name !=null and name !=''">
            AND ( s.id LIKE concat('%', #{name},'%')  OR
            s.contact_tel LIKE concat('%', #{name},'%') OR
            s.`name` LIKE concat('%', #{name},'%') OR
            st.`name` LIKE concat('%', #{name},'%') OR
            t.warehouse_location_code LIKE concat('%', #{name},'%')
            )
        </if>
        <if test="startDate != null">
            AND o.create_time &gt; #{startDate}
        </if>
        <if test="endDate != null">
            AND o.create_time &lt;= #{endDate}
        </if>
        <if test="statusList != null and statusList.size > 0">
            AND o.status in
            <foreach collection="statusList" item="status" open="(" separator="," close=")">
                #{status}
            </foreach>
        </if>
        GROUP BY s.station_id, st.`name`) uncheckedSupplierCount
        from (
            SELECT
                s.station_id AS stationId,
                st.`name`,
@@ -210,10 +295,15 @@
            <if test="endDate != null">
                AND o.create_time &lt;= #{endDate}
            </if>
            GROUP BY
            s.station_id,
            st.`name`;
            <if test="statusList != null and statusList.size > 0">
                AND o.status in
                <foreach collection="statusList" item="status" open="(" separator="," close=")">
                    #{status}
                </foreach>
            </if>
            GROUP BY s.station_id, st.`name`
        ) tt
    </select>
    <update id="setDeliveryOrderPending">
@@ -228,9 +318,13 @@
        SELECT q.*
        FROM t_delivery_order q
        WHERE q.deleted = 0
        and q.status in ('PENDING', 'ARRIVED', 'CHECKED')
        AND q.status in ('PENDING', 'ARRIVED')
        AND q.supplier_id = #{supplierId}
        AND q.create_time &gt; #{startDate}
        AND q.create_time &lt;= #{endDate}
        <if test="startDate != null">
            AND q.create_time &gt; #{startDate}
        </if>
        <if test="endDate != null">
            AND q.create_time &lt;= #{endDate}
        </if>
    </select>
</mapper>