quota-convert-mapper.xml 2.8 KB
<?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.quota.QuotaConvertDao">

	<sql id="quota_convert_field">
		id,otc_code,otc_name,user_id,otc_account,quota,post_quota,type,export_status,create_at,create_by,update_at,update_by 
	</sql>
	
	<select id="search" parameterType="java.util.Map" resultType="QuotaConvertInfo">
		select <include refid="quota_convert_field" />
		from quota_convert where export_status = #{exportStatus} 
		<include refid="searchCondition"/> 
		order by id desc 
		<include refid="common.pageLimit" />
	</select>
	
	<select id="searchTotal" parameterType="java.util.Map" resultType="java.lang.Integer">
		select count(1) from quota_convert where export_status = #{exportStatus} 
		<include refid="searchCondition"/>
	</select>
	
	<sql id="searchCondition">
		<if test="id != null and id != ''">
			and id = #{id} 
		</if>
		<if test="userId != null and userId != ''">
			and user_id = #{userId} 
		</if>
		<if test="otcCode != null and otcCode != ''">
			and otc_code = #{otcCode} 
		</if>
		<if test="otcName != null and otcName != ''">
			<![CDATA[and instr(otc_name, #{otcName}) > 0 ]]>
		</if>
		<if test="type != null and type != ''">
			and type = #{type} 
		</if>
		<if test="startDate != null and startDate != ''">
			<![CDATA[and create_at >= #{startDate} ]]>
		</if>
		<if test="endDate != null and endDate != ''">
			<![CDATA[and create_at <= #{endDate} ]]>
		</if>
	</sql>
	
	<update id="updateExportStatusExport" parameterType="map">
		update quota_convert set post_quota = #{postQuota}, export_status = 1, update_by = #{updateBy}, update_at = CURRENT_TIMESTAMP 
		where export_status = 0 
		<include refid="searchCondition"/>
	</update>
	
	<update id="updateEnsure" parameterType="map">
		update quota_convert set export_status = 2, update_by = #{updateBy}, update_at = CURRENT_TIMESTAMP 
		where export_status = 1 
		<include refid="searchCondition"/>
	</update>
	
	<select id="searchQuota" parameterType="map" resultType="map">
		select id,otc_code,otc_name,user_id,quota,type,post_quota,type 
		from quota_convert where export_status = #{exportStatus} 
		<include refid="searchCondition"/> 
		order by user_id asc,create_at asc 
	</select>
	
	<select id="searchExport" parameterType="map" resultType="map">
		select otc_code,otc_account,post_quota 
		from quota_convert where export_status = #{exportStatus} 
		<include refid="searchCondition"/> 
		order by id desc 
	</select>
	
	<select id="querySum" resultType="String" parameterType="map">
		select sum(quota) from quota_convert 
		where otc_code = #{otcCode} and user_id = #{userId} and type = 1 and export_status != 1 
		and create_at between #{startDate} and #{endDate}
	</select>
	
</mapper>