From b82ea69a5ee885f0a24ae92be482fb63da92d859 Mon Sep 17 00:00:00 2001
From: peter <14100000001@qq.com>
Date: Thu, 08 Jan 2026 13:58:13 +0800
Subject: [PATCH] 修改
---
src/main/resources/mapper/UserPositionMapper.xml | 70 +++++++++++++++++++++++++----------
1 files changed, 50 insertions(+), 20 deletions(-)
diff --git a/src/main/resources/mapper/UserPositionMapper.xml b/src/main/resources/mapper/UserPositionMapper.xml
index 67df1d3..6a99a68 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,buy_order_id_index
+ 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,8 @@
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 != null">
+ and status = #{state, jdbcType=INTEGER}
</if>
<if test="stockCode != null and stockCode != '' ">
and stock_code like CONCAT('%','${stockCode}','%')
@@ -483,13 +502,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 +611,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