ration-broker-config-mapper.xml
3.92 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
97
98
99
100
101
<?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.RationBrokerConfigDao">
<sql id="ration_broker_config_field">
t.id, t.otc_code, t.otc_name, t.price, t.ration_status,
t.ration_result, t.create_at, t.create_by
</sql>
<resultMap id="queryAll" type="RationBrokerConfigInfo">
<id property="otcCode" column="otc_code"/>
<result property="id" column="id"/>
<result property="otcCode" column="otc_code"/>
<result property="otcName" column="otc_name"/>
<result property="price" column="price"/>
<result property="rationStatus" column="ration_status"/>
<result property="rationResult" column="ration_result"/>
<result property="createAt" column="create_at"/>
<result property="createBy" column="create_by"/>
<collection property="users" ofType="RationBrokerUserInfo">
<id property="rationBrokerConfigId" column="ration_broker_config_id"/>
<result property="id" column="u_id"/>
<result property="userId" column="user_id"/>
<result property="otcAccount" column="otc_account"/>
<result property="totalAmount" column="total_amount"/>
<result property="enableAmount" column="enable_amount"/>
</collection>
</resultMap>
<!-- 获取配售规则信息及对应的新品配售用户信息 -->
<select id="queryAllById" parameterType="int" resultMap="queryAll">
select <include refid="ration_broker_config_field" />, r.id as u_id, r.user_id, r.otc_account, r.total_amount, r.enable_amount
from ration_broker_config t left join ration_broker_user r on t.id = r.ration_broker_config_id
where t.id = #{id}
</select>
<sql id="searchCondition">
where 1=1
<if test="otcCode != null and otcCode != ''">
and otc_code = #{otcCode}
</if>
<if test="otcName != null and otcName != ''">
and instr(otc_name, #{otcName}) > 0
</if>
<if test="rationStatus != null and rationStatus != ''">
and ration_status = #{rationStatus}
</if>
<if test="confirmStartDate != null and confirmStartDate != ''">
<![CDATA[and create_at >= #{confirmStartDate} ]]>
</if>
<if test="confirmEndDate != null and confirmEndDate != ''">
<![CDATA[and create_at <= #{confirmEndDate} ]]>
</if>
</sql>
<!-- 查询配售规则 -->
<select id="search" parameterType="map" resultType="RationBrokerConfigInfo">
select <include refid="ration_broker_config_field" />
from ration_broker_config t
<include refid="searchCondition" />
order by id desc
<include refid="common.pageLimit" />
</select>
<select id="searchTotal" parameterType="map" resultType="int">
select count(1) from ration_broker_config t
<include refid="searchCondition" />
</select>
<!-- 新增规则 -->
<insert id="save" parameterType="RationBrokerConfigInfo" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
insert into ration_broker_config(otc_code, otc_name, price, ration_status, ration_result, create_at, create_by)
values(#{otcCode}, #{otcName}, #{price}, '1', #{rationResult}, CURRENT_TIMESTAMP, #{createBy})
</insert>
<!-- 修改规则 -->
<update id="update" parameterType="RationBrokerConfigInfo">
update ration_broker_config set otc_code = #{otcCode}, otc_name = #{otcName}, price = #{price}, ration_status = #{rationStatus}, ration_result = #{rationResult}
where id = #{id}
</update>
<select id="queryById" parameterType="int" resultType="RationBrokerConfigInfo">
select <include refid="ration_broker_config_field" />
from ration_broker_config t
where t.id = #{id}
</select>
<update id="updateStatus" parameterType="RationBrokerConfigInfo">
update ration_broker_config set ration_status = ${rationStatus}
where id = #{id}
</update>
<!-- 作废规则 -->
<update id="cancelStatus" parameterType="RationBrokerConfigInfo">
update ration_broker_config set ration_status = '0'
where id = #{id}
</update>
</mapper>