1
zj
2024-06-13 a4662cc65a02f258062bf6cc392ceb1017db9292
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yami.trading.dao.contract.ContractOrderMapper">
 
    <sql id="contractOrderColumns">
        a.uuid AS "uuid",
        a.party_id AS "partyId",
        a.symbol AS "symbol",
        a.order_no AS "orderNo",
        a.direction AS "direction",
        a.unit_amount AS "unitAmount",
        a.amount_close AS "amountClose",
        a.fee AS "fee",
        a.deposit AS "deposit",
        a.deposit_open AS "depositOpen",
        a.profit AS "profit",
        a.trade_avg_price AS "tradeAvgPrice",
        a.stop_price_profit AS "stopPriceProfit",
        a.stop_price_loss AS "stopPriceLoss",
        a.pips AS "pips",
        a.pips_amount AS "pipsAmount",
        a.state AS "state",
        a.lever_rate AS "leverRate",
        a.volume AS "volume",
        a.volume_open AS "volumeOpen",
        a.close_time AS "closeTime",
        a.close_avg_price AS "closeAvgPrice",
        a.create_by AS "createBy",
        a.create_time AS "createTime",
        a.update_by AS "updateBy",
        a.update_time AS "updateTime",
        a.remarks AS "remarks",
        a.del_flag AS "delFlag",
        a.create_time_ts AS "createTimeTs",
        a.update_time_ts AS "updateTimeTs"
    </sql>
 
    <sql id="contractOrderJoins">
 
    </sql>
 
 
    <select id="listRecordCur" resultType="com.yami.trading.bean.contract.dto.ContractOrderDTO">
        select *,b.role_name AS "roleName",b.user_code AS "userCode",c.money,item.name AS "symbolName" from t_contract_order a
        left join tz_user b on a.party_id = b.user_id
        left join tz_wallet c ON a.party_id = c.user_id
        left join t_item item on a.symbol = item.symbol
        <where>
            <if test="query.type!=null and query.type!=''">
                and item.type=#{query.type}
            </if>
            <if test="query.orderNo!=null and query.orderNo!=''">
                and a.order_no=#{query.orderNo}
            </if>
            <if test="query.children != null and query.children.size() >0">
                AND a.party_id in
                <foreach collection="query.children" item="item" index="index" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="query.state!=null and query.state!=''">
                and a.state=#{query.state}
            </if>
            <if test="query.startTimeStr != null and query.startTimeStr != ''">
                and a.create_time &gt;= #{query.startTimeStr}
            </if>
 
            <if test="query.endTimeStr != null and query.endTimeStr != ''">
                and a.create_time &lt;= #{query.endTimeStr}
            </if>
            <if test="query.userId!=null and query.userId!=''">
                and b.user_id=#{query.userId}
            </if>
            <if test="query.userCode!=null and query.userCode!=''">
                and b.user_code=#{query.userCode}
            </if>
            <if test="query.roleName!=null and query.roleName!=''">
                and b.role_name=#{query.roleName}
            </if>
            <if test="query.ip!=null and query.ip!=''">
                and b.user_lastip like CONCAT('%', #{query.ip}, '%')
            </if>
 
            <if test="query.userName!=null and query.userName!=''">
                AND (b.user_name like CONCAT('%', #{query.userName}, '%') or b.user_code like CONCAT('%',
                #{query.userName}, '%'))
            </if>
        </where>
        order by a.create_time desc
    </select>
 
 
    <select id="listRecordHistory" resultType="com.yami.trading.bean.contract.dto.ContractOrderDTO">
        select *,b.role_name AS "roleName",b.user_code AS "userCode",c.money,item.name AS "symbolName" from t_contract_order a
        left join tz_user b on a.party_id = b.user_id
        left join tz_wallet c ON c.user_id = b.user_id
        left join t_item item on a.symbol = item.symbol
        <where>
            <if test="query.type!=null and query.type!=''">
                and item.type=#{query.type}
            </if>
            <if test="query.orderNo!=null and query.orderNo!=''">
                and a.order_no=#{query.orderNo}
            </if>
            <if test="query.children != null and query.children.size() >0">
                AND a.party_id in
                <foreach collection="query.children" item="item" index="index" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
            <if test="query.state!=null and query.state!=''">
                and a.state=#{query.state}
            </if>
            <if test="query.startTimeStr != null and query.startTimeStr!=''">
                and a.create_time &gt;= #{query.startTimeStr}
            </if>
 
            <if test="query.endTimeStr != null and query.endTimeStr != ''">
                and a.create_time &lt;= #{query.endTimeStr}
            </if>
            <if test="query.userId!=null and query.userId!=''">
                and b.user_id=#{query.userId}
            </if>
            <if test="query.userCode!=null and query.userCode!=''">
                and b.user_code=#{query.userCode}
            </if>
            <if test="query.roleName!=null and query.roleName!=''">
                and b.role_name=#{query.roleName}
            </if>
            <if test="query.ip!=null and query.ip!=''">
                and b.user_lastip like CONCAT('%', #{query.ip}, '%')
            </if>
 
            <if test="query.userName!=null and query.userName!=''">
                AND (b.user_name like CONCAT('%', #{query.userName}, '%') or b.user_code like CONCAT('%',
                #{query.userName}, '%'))
            </if>
        </where>
        order by a.close_time_ts desc
    </select>
 
 
    <select id="findById" resultType="com.yami.trading.bean.contract.dto.ContractOrderDTO">
        SELECT
        <include refid="contractOrderColumns"/>
        FROM t_contract_order a
        <include refid="contractOrderJoins"/>
        WHERE a.uuid = #{id} and a.del_flag = 0
    </select>
 
    <select id="findList" resultType="com.yami.trading.bean.contract.dto.ContractOrderDTO">
        SELECT
        <include refid="contractOrderColumns"/>
        FROM t_contract_order a
        <include refid="contractOrderJoins"/>
        ${ew.customSqlSegment}
    </select>
 
    <update id="batchUpdateBuffer">
        <foreach collection="list" item="item" index="index" open="" separator=";" close="">
            UPDATE t_contract_order
            SET force_close_price =#{item.forceClosePrice}
            WHERE uuid = #{item.uuid} and state = 'submitted'
        </foreach>
    </update>
 
 
 
</mapper>