ration-single-config-mapper.xml
5.42 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
<?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 仝玉甫 -->
<mapper namespace="com.cjs.cms.dao.ration.PlacingRuleDao">
<sql id="ration_new_config_field">
t.id, t.otc_code, t.otc_name, t.price,t.user_id,t.otc_account,t.forzen_percent,t.transaction_fee,notice_url,
t.confirm_start_date, t.confirm_end_date, t.ration_status,
t.ration_type, t.ration_result, t.create_at, t.create_by
</sql>
<update id="update" parameterType="RationNewConfigInfo">
update ration_new_config set
otc_code = #{otcCode}, otc_name = #{otcName}, price = #{price}, transaction_fee = #{transactionFee},
need_confirm = #{needConfirm}, notice_url = #{noticeUrl}, inner_account = #{innerAccount},
confirm_start_date = #{confirmStartDate}, confirm_end_date = #{confirmEndDate}, ration_status = #{rationStatus},
ration_type = #{rationType}, ration_result = #{rationResult}
where id = #{id}
</update>
<resultMap id="queryAll" type="RationNewConfigInfo">
<id property="otcCode" column="otc_code"/>
<result property="id" column="id"/>
<result property="otcName" column="otc_name"/>
<result property="price" column="price"/>
<result property="transactionFee" column="transaction_fee"/>
<result property="needConfirm" column="need_confirm"/>
<result property="noticeUrl" column="notice_url"/>
<result property="innerAccount" column="inner_account"/>
<result property="confirmStartDate" column="confirm_start_date"/>
<result property="confirmEndDate" column="confirm_end_date"/>
<result property="rationStatus" column="ration_status"/>
<result property="rationType" column="ration_type"/>
<result property="rationResult" column="ration_result"/>
<result property="createAt" column="create_at"/>
<result property="createBy" column="create_by"/>
<collection property="users" ofType="RationNewUserInfo">
<id property="rationNewConfigId" column="ration_new_config_id"/>
<result property="id" column="u_id"/>
<result property="userId" column="user_id"/>
<result property="percent" column="percent"/>
</collection>
</resultMap>
<!-- 查询指定编号配置 -->
<select id="queryById" parameterType="int" resultType="RationNewConfigInfo">
select <include refid="ration_new_config_field" />
from ration_new_config t
where t.id = #{value}
</select>
<insert id="insert" parameterType="PlacingRuleInfo" useGeneratedKeys="true" keyProperty="id">
insert into ration_single_config(otc_code, otc_name, price,user_id,otc_account,forzen_percent, transaction_fee, notice_url,
confirm_start_date, confirm_end_date, ration_status, ration_type, create_at, create_by)
values(#{otcCode}, #{otcName}, #{price},#{userId},#{otcAccount},#{forzenPercent}, #{transactionFee}, #{noticeUrl},
#{confirmStartDate}, #{confirmEndDate}, #{rationStatus}, #{rationType}, CURRENT_TIMESTAMP, #{createBy})
</insert>
<!-- 根据藏品编号查询配售规则(非作废和失败状态) -->
<select id="queryByOtcCode" parameterType="map" resultType="RationNewConfigInfo">
select <include refid="ration_new_config_field" />
from ration_new_config t
where t.otc_code = #{otcCode} and
(t.ration_status is null or
t.ration_status not in (#{rationStatus}))
</select>
<select id="search" parameterType="map" resultType="PlacingRuleInfo">
select <include refid="ration_new_config_field" />
from ration_single_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_new_config <include refid="searchCondition" />
</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 confirm_start_date >= #{confirmStartDate} ]]>
</if>
<if test="confirmEndDate != null and confirmEndDate != ''">
<![CDATA[and confirm_end_date <= #{confirmEndDate} ]]>
</if>
<if test="userId != null and userId != ''">
and id in (select ration_new_config_id from ration_new_user
where user_id = #{userId})
</if>
</sql>
<!-- 获取配售规则信息及对应的新品配售用户信息 -->
<select id="queryAllById" parameterType="int" resultMap="queryAll">
select <include refid="ration_new_config_field" />, r.id as u_id, r.user_id, r.otc_account, r.percent
from ration_new_config t left join ration_new_user r on t.id = r.ration_new_config_id
where t.id = #{id}
</select>
<!-- 配售规则作废 -->
<update id="updateCancel">
update ration_new_config set ration_status = '0'
where id = #{id} and ration_status = '1'
</update>
<select id="queryByRationType" parameterType="string" resultType="RationNewConfigInfo">
select <include refid="ration_new_config_field" />
from ration_new_config t
where t.ration_type = #{value}
</select>
<select id="queryRationConfigByCode" resultType="RationNewConfigInfo">
select <include refid="ration_new_config_field" />
from ration_new_config t
where otc_code =#{value}and now() between confirm_start_date
and confirm_end_date
and ration_status='1'
</select>
</mapper>