ration-old-config-mapper.xml
5.73 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
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
<?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.RationOldConfigDao">
<sql id="ration_old_config_field">
T.ID, T.OTC_CODE, T.OTC_NAME, T.PRICE, T.RATION_AMOUNT, T.REMAIN_AMOUNT, T.MAX_APPLY_AMOUNT, T.USER_PERCENT,
T.NOTICE_URL, T.CONFIRM_START_DATE, T.CONFIRM_END_DATE, T.RATION_STATUS,
T.RATION_RESULT, T.CREATE_AT, T.CREATE_BY
</sql>
<resultMap id="queryAll" type="RationOldConfigInfo">
<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="userPercent" column="user_percent"/>
<result property="rationAmount" column="ration_amount"/>
<result property="remainAmount" column="remain_amount"/>
<result property="maxApplyAmount" column="max_apply_amount"/>
<result property="noticeUrl" column="notice_url"/>
<result property="confirmStartDate" column="confirm_start_date"/>
<result property="confirmEndDate" column="confirm_end_date"/>
<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="RationOldUserInfo">
<id property="rationOldConfigId" column="ration_old_config_id"/>
<result property="id" column="u_id"/>
<result property="userId" column="user_id"/>
<result property="otcAccount" column="otc_account"/>
<result property="percent" column="percent"/>
</collection>
</resultMap>
<!-- 获取配售规则信息及对应的新品配售用户信息 -->
<select id="queryAllById" parameterType="int" resultMap="queryAll">
select <include refid="ration_old_config_field" />, r.id as u_id, r.user_id, r.otc_account, r.percent
from ration_old_config t left join ration_old_user r on t.id = r.ration_old_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 instr(#{rationStatus}, ration_status) > 0
</if>
<if test="confirmStartDate != null and confirmStartDate != ''">
<![CDATA[and confirm_start_date >= #{confirmStartDate} ]]>
</if>
<if test="confirmEndDate != null and confirmEndDate != ''">
<![CDATA[and confirm_end_date <= #{confirmEndDate} ]]>
</if>
</sql>
<!-- 查询配售规则 -->
<select id="search" parameterType="map" resultType="RationOldConfigInfo">
select <include refid="ration_old_config_field" />
from ration_old_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_old_config t
<include refid="searchCondition" />
</select>
<!-- 新增规则 -->
<insert id="insert" parameterType="RationOldConfigInfo" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
insert into ration_old_config(otc_code, otc_name, price, user_percent, ration_amount, remain_amount, max_apply_amount,
notice_url, confirm_start_date, confirm_end_date, ration_status, ration_result,
create_at, create_by)
values(#{otcCode}, #{otcName}, #{price}, #{userPercent}, #{rationAmount}, #{rationAmount}, #{maxApplyAmount}, #{noticeUrl},
#{confirmStartDate}, #{confirmEndDate}, '1', #{rationResult}, CURRENT_TIMESTAMP, #{createBy})
</insert>
<!-- 修改规则 -->
<update id="update" parameterType="RationOldConfigInfo">
update ration_old_config set otc_code = #{otcCode}, otc_name = #{otcName}, price = #{price}, user_percent = #{userPercent}, ration_amount = #{rationAmount}, remain_amount = #{remainAmount},
max_apply_amount = #{maxApplyAmount}, notice_url = #{noticeUrl}, confirm_start_date = #{confirmStartDate},
confirm_end_date = #{confirmEndDate}, ration_status = #{rationStatus}, ration_result = #{rationResult}
where id = #{id}
</update>
<select id="queryById" parameterType="int" resultType="RationOldConfigInfo">
select <include refid="ration_old_config_field" />
from ration_old_config t
where t.id = #{id}
</select>
<!-- 作废规则 -->
<update id="updateStatus" parameterType="map">
update ration_old_config set ration_status = #{rationStatus}, ration_result = #{rationResult}
where id = #{id}
</update>
<!-- 修改配售结果备注 -->
<update id="updateRemark" parameterType="map">
update ration_old_config set ration_result = #{rationResult} where id = #{id}
</update>
<!-- 修改剩余数量 -->
<update id="updateRemainAmount" parameterType="RationOldConfigInfo">
update ration_old_config set remain_amount=#{remainAmount} where
id=#{id}
</update>
<!-- 根据藏品数量查询 -->
<select id="queryByCode" parameterType="String" resultType="RationOldConfigInfo">
select <include refid="ration_old_config_field" />
from ration_old_config t
where t.otc_code = #{otcCode} and t.ration_status='1'
and now() between confirm_start_date
and confirm_end_date
</select>
<!-- 查询没有作废规则的藏品代码 -->
<select id="queryAllCode" resultType="String" parameterType="map">
select otc_code from ration_old_config
where ration_status>0
<if test="otcCode != null and otcCode != ''">
and otc_code = #{otcCode}
</if>
<if test="otcName != null and otcName != ''">
and instr(otc_name, #{otcName}) > 0
</if>
</select>
</mapper>