1
dd
2026-01-28 95a52a6087a7587c89253c099f3d76213f8318ab
src/main/resources/mapper/UserPositionMapper.xml
@@ -384,11 +384,10 @@
      <if test="stockSpell != null and stockSpell != '' ">
        and stock_spell like CONCAT('%','${stockSpell}','%')
      </if>
<!--      <if test="stockType != null and stockType!= ''">-->
<!--        and stock_gid = #{stockType}-->
<!--      </if>-->
      <if test="stockType != null and stockType!= ''">
        and stock_gid = #{stockType}
      </if>
      and position_type != 1
    </where>
    ORDER BY id DESC
  </select>
@@ -542,6 +541,86 @@
    limit 1
  </select>
  <select id="findMyPositionByParam" parameterType="map" resultType="com.nq.vo.position.UserPositionVO">
    SELECT a.* FROM (SELECT
    *
    FROM user_position
    WHERE
    user_id = #{uid}
    <if test="state != null ">
      <if test="state == 0">
        and sell_order_id is null
      </if>
      <if test="state == 1">
        and sell_order_id is not null
      </if>
    </if>
    UNION ALL
    SELECT
    p.id,
    4 position_type,
    null position_sn,
    null user_id,
    null nick_name,
    null agent_id,
    s.stock_name,
    s.stock_code,
    s.stock_type stock_gid,
    s.stock_spell,
    p.stock_ai_order_id buy_order_id,
    p.creat_date buy_order_time,
    p.stock_price buy_order_price,
    null sell_order_id,
    null sell_order_time,
    p.cover_price sell_order_price,
    null profit_target_price,
    null stop_target_price,
    null order_direction,
    p.stock_num order_num,
    null order_lever,
    p.stock_num*p.stock_price order_total_price,
    0 order_fee,
    0 order_spread,
    0 order_stay_fee,
    null order_stay_days,
    p.earnings profit_and_lose,
    p.earnings all_profit_and_lose,
    0 is_lock,
    null lock_msg,
    null stock_plate,
    0 spread_rate_price,
    0 margin_add,
    null dz_id,
    null new_id,
    0 amount_to_be_covered
    FROM stock_ai_order_position p
    LEFT JOIN stock s ON s.id = p.stock_id
    WHERE p.stock_ai_order_id IN (SELECT id FROM stock_ai_order WHERE
    user_id = #{uid} and status='passed' )
    <if test="state != null ">
      <if test="state == 0">
        and p.status = 0
      </if>
      <if test="state == 1">
        and p.status = 1
      </if>
    </if>
    ) a
    WHERE a.position_type != 1
    <if test="stockCode != null and stockCode != '' ">
      and a.stock_code like CONCAT('%','${stockCode}','%')
    </if>
    <if test="stockSpell != null and stockSpell != '' ">
      and a.stock_spell like CONCAT('%','${stockSpell}','%')
    </if>
    <if test="positionType != null">
      and a.position_type = #{positionType}
    </if>
    <if test="stockType != null and stockType != '' ">
      and a.stock_gid = #{stockType}
    </if>
    ORDER BY a.buy_order_time DESC
  </select>
</mapper>