Browse Source

no message

FengChaoYu 1 week ago
parent
commit
9b4c184108
1 changed files with 39 additions and 14 deletions
  1. 39 14
      mall-server-api/src/main/resources/mapper/CommonMapper.xml

+ 39 - 14
mall-server-api/src/main/resources/mapper/CommonMapper.xml

@@ -1764,26 +1764,51 @@
     </select>
     <select id="selectLastOrderOperatorLog"
             resultType="com.gree.mall.manager.bean.listvo.workorder.OperatorLogBean">
+<!-- mysql8.0语法 -->
+<!--        SELECT-->
+<!--            order_base_id,-->
+<!--            content-->
+<!--        FROM-->
+<!--            (-->
+<!--                SELECT-->
+<!--                    order_base_id, content, ROW_NUMBER() OVER ( PARTITION BY order_base_id ORDER BY create_time DESC ) AS rn-->
+<!--                FROM-->
+<!--                    pg_order_operator_log${year}-->
+<!--                <where>-->
+<!--                    <if test="ids != null and ids.size > 0">-->
+<!--                        AND order_base_id IN-->
+<!--                        <foreach item="item" index="index" collection="ids" open="(" separator="," close=")">-->
+<!--                            #{item}-->
+<!--                        </foreach>-->
+<!--                    </if>-->
+<!--                </where>-->
+<!--            ) AS ranked-->
+<!--        WHERE-->
+<!--            rn = 1;-->
         SELECT
             order_base_id,
             content
         FROM
-            (
+            pg_order_operator_log
+        WHERE
+            order_base_id IN
+            <foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+            AND (order_base_id, create_time) IN (
                 SELECT
-                    order_base_id, content, ROW_NUMBER() OVER ( PARTITION BY order_base_id ORDER BY create_time DESC ) AS rn
+                    order_base_id,
+                    MAX(create_time)
                 FROM
-                    pg_order_operator_log${year}
-                <where>
-                    <if test="ids != null and ids.size > 0">
-                        AND order_base_id IN
-                        <foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
-                            #{item}
-                        </foreach>
-                    </if>
-                </where>
-            ) AS ranked
-        WHERE
-            rn = 1;
+                    pg_order_operator_log
+                WHERE
+                    order_base_id IN
+                    <foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                    GROUP BY
+                    order_base_id
+            );
     </select>