ration-broker-record-mapper.xml
3.79 KB
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
<?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">
<!-- 经纪人配售记录 @author tongxiaochuan -->
<mapper namespace="com.cjs.cms.dao.ration.RationBrokerRecordDao">
<sql id="ration_broker_record_field">
t.id, ration_broker_config_id, ration_broker_user_id, matched, sell_user_id, sell_otc_account,
buy_user_id, buy_otc_account, fund, stock_amount, t.ration_status, cost_price_status, remark, t.create_at, t.create_by
</sql>
<insert id="save" parameterType="RationBrokerRecordInfo" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
insert into ration_broker_record(ration_broker_config_id, ration_broker_user_id, matched, sell_user_id, sell_otc_account,
buy_user_id, buy_otc_account, fund, stock_amount, ration_status, cost_price_status, remark, create_at, create_by)
values(#{rationBrokerConfigId}, #{rationBrokerUserId}, #{matched}, #{sellUserId}, #{sellOtcAccount}, #{buyUserId},
#{buyOtcAccount}, #{fund}, #{stockAmount}, #{rationStatus}, '0', #{remark}, now(), #{createBy})
</insert>
<sql id="searchCondition">
where 1 = 1
<if test="rationBrokerConfigId != null and rationBrokerConfigId != ''">
and ration_broker_config_id = #{rationBrokerConfigId}
</if>
<if test="sellUserId != null and sellUserId != ''">
and sell_user_id = #{sellUserId}
</if>
<if test="buyUserId != null and buyUserId != ''">
and buy_user_id = #{buyUserId}
</if>
<if test="rationStatus != null and rationStatus != ''">
and t.ration_status = #{rationStatus}
</if>
<if test="matched != null and matched != ''">
and matched = #{matched}
</if>
<if test="confirmStartDate != null and confirmStartDate != ''">
<![CDATA[and t.create_at >= #{confirmStartDate} ]]>
</if>
<if test="confirmEndDate != null and confirmEndDate != ''">
<![CDATA[and t.create_at <= #{confirmEndDate} ]]>
</if>
</sql>
<select id="search" parameterType="map" resultType="map">
select <include refid="ration_broker_record_field" />, r.otc_code, r.otc_name
from ration_broker_record t
inner join ration_broker_config r
on r.id = t.ration_broker_config_id
<include refid="searchCondition" />
<if test="otcCode != null and otcCode != ''">
and r.otc_code = #{otcCode}
</if>
order by t.id desc
<include refid="common.pageLimit" />
</select>
<select id="searchTotal" parameterType="map" resultType="int">
select count(1) from ration_broker_record t
<include refid="searchCondition" />
</select>
<select id="searchFooter" parameterType="map" resultType="map">
select sum(fund) fund, sum(stock_amount) stock_amount
from ration_broker_record t
<include refid="searchCondition" />
</select>
<update id="updateStatus" parameterType="RationBrokerRecordInfo">
update ration_broker_record set ration_status = #{rationStatus}
where id = #{id}
</update>
<select id="queryFailed" parameterType="int" resultType="int">
select count(1) from ration_broker_record
where ration_broker_config_id = #{rationBrokerRecordId} and remark = '可用资金不足'
</select>
<update id="updateRemark" parameterType="RationBrokerRecordInfo">
update ration_broker_record set remark = #{remark}
where id = #{id}
</update>
<select id="queryForCostPrice" parameterType="int" resultType="map">
select t.id,r.otc_code otcCode,r.price,t.buy_user_id userId,t.stock_amount stockAmount
from ration_broker_record t
inner join ration_broker_config r
on t.ration_broker_config_id = r.id
where cost_price_status = '0'
and t.ration_status = '1' and t.ration_broker_config_id = #{rationBrokerConfigId}
</select>
<update id="updateCostPriceStatus" parameterType="int">
update ration_broker_record set cost_price_status = '1'
where id = #{id} and cost_price_status = '0'
</update>
</mapper>