From cd969de1f50903ca87deda67bff2d6fcc35b4107 Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Sun, 07 Jun 2026 02:42:32 +0800
Subject: [PATCH] 1

---
 src/main/resources/mapper/UserPositionMapper.xml |   32 +++++++++++++++++++++++++++++---
 1 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/src/main/resources/mapper/UserPositionMapper.xml b/src/main/resources/mapper/UserPositionMapper.xml
index 6a99a68..50034eb 100644
--- a/src/main/resources/mapper/UserPositionMapper.xml
+++ b/src/main/resources/mapper/UserPositionMapper.xml
@@ -465,7 +465,16 @@
     FROM user_position
     <where>
       user_id = #{uid}
-      <if test="state != null">
+      <if test="state == 1">
+        and sell_order_id is null and (status = 1 or status is null)
+      </if>
+      <if test="state == 2">
+        and status = 2
+      </if>
+      <if test="state == 0">
+        and status = 0
+      </if>
+      <if test="state != null and state != 0 and state != 1 and state != 2">
         and status = #{state, jdbcType=INTEGER}
       </if>
       <if test="stockCode != null and stockCode != '' ">
@@ -475,7 +484,14 @@
         and stock_spell like CONCAT('%','${stockSpell}','%')
       </if>
     </where>
-    ORDER BY id DESC
+    <choose>
+      <when test="state == 2">
+        ORDER BY sell_order_time DESC, id DESC
+      </when>
+      <otherwise>
+        ORDER BY id DESC
+      </otherwise>
+    </choose>
   </select>
 
   <select id="findPositionByUserIdAndSellIdIsNull" parameterType="integer" resultMap="BaseResultMap">
@@ -503,7 +519,17 @@
         and agent_id = #{searchId}
       </if>
       <if test="state != null">
-        and status = #{state, jdbcType=INTEGER}
+        <choose>
+          <when test="state == 0">
+            and status = 1
+          </when>
+          <when test="state == 1">
+            and status = 2
+          </when>
+          <otherwise>
+            and status = #{state, jdbcType=INTEGER}
+          </otherwise>
+        </choose>
       </if>
       <if test="userId != null and userId != '' ">
         and user_id = #{userId}

--
Gitblit v1.9.3