From 1b5faa64dbb22935de1ff33a2bd01a41446f857b Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Tue, 02 Jun 2026 11:22:52 +0800
Subject: [PATCH] 1
---
src/main/resources/mapper/UserPositionMapper.xml | 88 +++++++++++++++++++++++++++++++++----------
1 files changed, 67 insertions(+), 21 deletions(-)
diff --git a/src/main/resources/mapper/UserPositionMapper.xml b/src/main/resources/mapper/UserPositionMapper.xml
index 4053f52..20db7a5 100644
--- a/src/main/resources/mapper/UserPositionMapper.xml
+++ b/src/main/resources/mapper/UserPositionMapper.xml
@@ -38,6 +38,9 @@
<arg column="stock_plate" jdbcType="VARCHAR" javaType="java.lang.String" />
<arg column="spread_rate_price" jdbcType="DECIMAL" javaType="java.math.BigDecimal" />
<arg column="margin_add" jdbcType="DECIMAL" javaType="java.math.BigDecimal" />
+ <arg column="status" jdbcType="INTEGER" javaType="java.lang.Integer" />
+ <arg column="lock_days" jdbcType="INTEGER" javaType="java.lang.Integer" />
+
</constructor>
</resultMap>
<sql id="Base_Column_List" >
@@ -45,7 +48,7 @@
stock_gid, stock_spell, buy_order_id, buy_order_time, buy_order_price, sell_order_id,
sell_order_time, sell_order_price, profit_target_price, stop_target_price, order_direction,
order_num, order_lever, order_total_price, order_fee, order_spread, order_stay_fee,
- order_stay_days, profit_and_lose, all_profit_and_lose,is_lock,lock_msg,stock_plate,spread_rate_price,margin_add
+ order_stay_days, profit_and_lose, all_profit_and_lose,is_lock,lock_msg,stock_plate,spread_rate_price,margin_add,buy_order_id_index,status,lock_days
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
@@ -67,7 +70,7 @@
order_direction, order_num, order_lever,
order_total_price, order_fee, order_spread,
order_stay_fee, order_stay_days, profit_and_lose,
- all_profit_and_lose, is_lock, lock_msg,stock_plate,spread_rate_price)
+ all_profit_and_lose, is_lock, lock_msg,stock_plate,spread_rate_price,status,lock_days)
values (#{id,jdbcType=INTEGER}, #{positionType,jdbcType=INTEGER}, #{positionSn,jdbcType=VARCHAR},
#{userId,jdbcType=INTEGER}, #{nickName,jdbcType=VARCHAR}, #{agentId,jdbcType=INTEGER},
#{stockName,jdbcType=VARCHAR}, #{stockCode,jdbcType=VARCHAR}, #{stockGid,jdbcType=VARCHAR},
@@ -78,7 +81,7 @@
#{orderTotalPrice,jdbcType=DECIMAL}, #{orderFee,jdbcType=DECIMAL}, #{orderSpread,jdbcType=DECIMAL},
#{orderStayFee,jdbcType=DECIMAL}, #{orderStayDays,jdbcType=INTEGER}, #{profitAndLose,jdbcType=DECIMAL},
#{allProfitAndLose,jdbcType=DECIMAL}, #{isLock,jdbcType=INTEGER}, #{lockMsg,jdbcType=VARCHAR},
- #{stockPlate,jdbcType=VARCHAR},#{spreadRatePrice,jdbcType=DECIMAL}
+ #{stockPlate,jdbcType=VARCHAR},#{spreadRatePrice,jdbcType=DECIMAL}, #{status,jdbcType=INTEGER},#{lockDays,jdbcType=INTEGER}
)
</insert>
@@ -182,6 +185,12 @@
<if test="spreadRatePrice != null" >
spread_rate_price,
</if>
+ <if test="status != null" >
+ status,
+ </if>
+ <if test="lockDays != null" >
+ lock_days,
+ </if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
@@ -282,6 +291,12 @@
</if>
<if test="spreadRatePrice != null" >
#{spreadRatePrice,jdbcType=DECIMAL},
+ </if>
+ <if test="status != null" >
+ #{status,jdbcType=INTEGER},
+ </if>
+ <if test="lockDays != null" >
+ #{lockDays,jdbcType=INTEGER},
</if>
</trim>
@@ -386,6 +401,13 @@
<if test="marginAdd != null" >
margin_add = #{marginAdd,jdbcType=DECIMAL},
</if>
+ <if test="status != null" >
+ status = #{status,jdbcType=INTEGER},
+ </if>
+ <if test="lockDays != null" >
+ lock_days = #{lockDays,jdbcType=INTEGER},
+ </if>
+
</set>
where id = #{id,jdbcType=INTEGER}
</update>
@@ -423,7 +445,9 @@
lock_msg = #{lockMsg,jdbcType=VARCHAR},
stock_plate = #{stockPlate,jdbcType=VARCHAR},
buy_order_id_index = #{buyOrderIdIndex,jdbcType=DECIMAL},
- spread_rate_price = #{spreadRatePrice,jdbcType=DECIMAL}
+ spread_rate_price = #{spreadRatePrice,jdbcType=DECIMAL},
+ status = #{status,jdbcType=INTEGER},
+ lock_days = #{lockDays,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
@@ -441,13 +465,17 @@
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 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 != '' ">
and stock_code like CONCAT('%','${stockCode}','%')
@@ -456,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">
@@ -483,13 +518,8 @@
<if test="searchId != null ">
and agent_id = #{searchId}
</if>
- <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 test="state != null">
+ and status = #{state, jdbcType=INTEGER}
</if>
<if test="userId != null and userId != '' ">
and user_id = #{userId}
@@ -597,8 +627,24 @@
ORDER BY id ASC
limit 1
</select>
-
-
+ <select id="getDailyProfitByMonth" parameterType="map" resultType="java.util.Map">
+ SELECT
+ DATE_FORMAT(buy_order_time, '%Y-%m-%d') AS recordDate,
+ CAST(
+ SUM(
+ (
+ COALESCE (sell_order_price, 0) - COALESCE (buy_order_price, 0)
+ ) * COALESCE (order_num, 1) - COALESCE (order_fee, 0) - COALESCE (order_spread, 0)
+ ) AS CHAR
+ ) AS profit
+ FROM
+ user_position
+ WHERE
+ DATE_FORMAT(buy_order_time, '%Y-%m') = #{yearMonth}
+ AND status = 2
+ AND user_id = #{userId}
+ GROUP BY DATE_FORMAT(buy_order_time, '%Y-%m-%d')
+ </select>
</mapper>
--
Gitblit v1.9.3