ration-new-record-mapper.xml
5.15 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
<?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.RationNewRecordDao">
<insert id="save" parameterType="RationNewRecordInfo" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
insert into ration_new_record
(ration_new_config_id, ration_new_user_id, sell_user_id, sell_otc_account, buy_user_id,
buy_otc_account, apply_no, pre_in_status, approval_count, fund, stock_amount,
registration, ration_status, cost_price_status, remark, create_at, create_by)
values (#{rationNewConfigId}, #{rationNewUserId}, #{sellUserId}, #{sellOtcAccount}, #{buyUserId},
#{buyOtcAccount}, #{applyNo}, #{preInStatus}, #{approvalAcount}, #{fund}, #{stockAmount},
#{registration}, #{rationStatus}, '0', #{remark}, now(), #{createBy})
</insert>
<update id="updateById" parameterType="RationNewRecordInfo">
update ration_new_record set
<if test="preInStatus != null and preInStatus != ''"> pre_in_status = #{preInStatus}, </if>
<if test="rationStatus != null and rationStatus != ''"> ration_status = #{rationStatus}, </if>
<if test="remark != null and remark != ''"> remark = #{remark}, </if>
create_by = create_by
where id = #{id}
</update>
<!-- 修改-->
<update id="updateByApplyNo" parameterType="RationNewRecordInfo">
update ration_new_record set
<if test="preInStatus != null and preInStatus != ''"> pre_in_status = #{preInStatus}, </if>
<if test="rationStatus != null and rationStatus != ''"> ration_status = #{rationStatus}, </if>
<if test="remark != null and remark != ''"> remark = #{remark}, </if>
create_by = create_by
where apply_no = #{applyNo}
</update>
<!-- 配售记录数量 -->
<select id="queryRecordCount" resultType="int">
select count(*)
from ration_new_record
where ration_new_config_id = #{rationNewConfigId}
<if test="rationStatus != null and rationStatus != ''">
and ration_status = #{rationStatus}
</if>
</select>
<!-- 查询导出配售记录 -->
<select id="queryRecord" resultType="map">
select apply_no, buy_user_id, stock_amount
from ration_new_record
where ration_new_config_id = #{rationNewConfigId}
and pre_in_status = #{preInStatus}
and registration = #{registration}
and ration_status = #{rationStatus}
</select>
<!-- 导出状态更新 -->
<update id="updateExport" parameterType="map">
update ration_new_record set registration = 1, export_at = CURRENT_TIMESTAMP
where ration_new_config_id = #{rationNewConfigId}
and pre_in_status = #{preInStatus}
and registration = #{registration}
and ration_status = #{rationStatus}
</update>
<!-- 配售详情查询 -->
<select id="queryRationDetail" parameterType="map" resultType="map">
select t.id,t.apply_no,r.otc_code,r.otc_name,t.sell_user_id,t.ration_status,
t.buy_user_id,t.registration,t.approval_count,t.stock_amount,t.fund,t.create_at,t.create_by,t.remark
from ration_new_record t inner join ration_new_config r
on t.ration_new_config_id = r.id
<include refid="queryCondition" />
order by t.apply_no, t.id
<include refid="common.pageLimit" />
</select>
<select id="queryRationDetailTotal" parameterType="map" resultType="int">
select count(1)
from ration_new_record t
inner join ration_new_config r on t.ration_new_config_id = r.id
<include refid="queryCondition" />
</select>
<select id="queryRationDetailSum" parameterType="map" resultType="map">
select '汇总' buy_user_id, sum(approval_count) approval_count, sum(fund) fund, sum(stock_amount) stock_amount
from ration_new_record t
inner join ration_new_config r on t.ration_new_config_id = r.id
<include refid="queryCondition" />
</select>
<sql id="queryCondition">
where 1=1
<if test="otcCode != null and otcCode != ''">
and r.otc_code = #{otcCode}
</if>
<if test="otcName != null and otcName != ''">
and r.otc_name = #{otcName}
</if>
<if test="sellUserId != null and sellUserId != ''">
and t.sell_user_id = #{sellUserId}
</if>
<if test="buyUserId != null and buyUserId != ''">
and t.buy_user_id = #{buyUserId}
</if>
<if test="startDate != null and startDate != ''">
<![CDATA[and t.create_at >= #{startDate} ]]>
</if>
<if test="endDate != null and endDate != ''">
<![CDATA[and t.create_at <= #{endDate} ]]>
</if>
<if test="rationStatus != null and rationStatus != ''">
and t.ration_status = #{rationStatus}
</if>
<if test="applyNo != null and applyNo != ''">
and t.apply_no = #{applyNo}
</if>
</sql>
<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_new_record t
inner join ration_new_config r
on t.ration_new_config_id = r.id
where t.pre_in_status = '1' and t.registration = '1' and cost_price_status = '0'
and t.ration_status = '1' and t.ration_new_config_id = #{rationNewConfigId}
</select>
<update id="updateCostPriceStatus" parameterType="int">
update ration_new_record set cost_price_status = '1'
where id = #{id} and cost_price_status = '0'
</update>
</mapper>