TInsuranceDetailMapper.xml 42.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
<?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">
<mapper namespace="com.yifu.cloud.plus.v1.yifu.insurances.mapper.TInsuranceDetailMapper">

    <resultMap id="BaseResultMap" type="com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceDetail">
            <id property="id" column="ID" jdbcType="VARCHAR"/>
            <result property="empName" column="EMP_NAME" jdbcType="VARCHAR"/>
            <result property="empIdcardNo" column="EMP_IDCARD_NO" jdbcType="VARCHAR"/>
            <result property="deptNo" column="DEPT_NO" jdbcType="VARCHAR"/>
李灿灿's avatar
李灿灿 committed
12
            <result property="post" column="POST" jdbcType="VARCHAR"/>
13
            <result property="insuranceCompanyName" column="INSURANCE_COMPANY_NAME" jdbcType="VARCHAR"/>
李灿灿's avatar
李灿灿 committed
14 15
            <result property="insuranceTypeName" column="INSURANCE_TYPE_NAME" jdbcType="VARCHAR"/>
            <result property="insuranceTypeId" column="INSURANCE_TYPE_ID" jdbcType="BIGINT"/>
16
            <result property="buyStandard" column="BUY_STANDARD" jdbcType="VARCHAR"/>
17 18
            <result property="rate" column="RATE" jdbcType="DECIMAL"/>
            <result property="billingType" column="BILLING_TYPE" jdbcType="TINYINT"/>
李灿灿's avatar
李灿灿 committed
19 20
            <result property="medicalQuota" column="MEDICAL_QUOTA" jdbcType="VARCHAR"/>
            <result property="dieDisableQuota" column="DIE_DISABLE_QUOTA" jdbcType="VARCHAR"/>
21 22 23 24 25
            <result property="policyNo" column="POLICY_NO" jdbcType="VARCHAR"/>
            <result property="policyStart" column="POLICY_START" jdbcType="DATE"/>
            <result property="policyEnd" column="POLICY_END" jdbcType="DATE"/>
            <result property="policyEffect" column="POLICY_EFFECT" jdbcType="DATE"/>
            <result property="batchDate" column="BATCH_DATE" jdbcType="TIMESTAMP"/>
李灿灿's avatar
李灿灿 committed
26
			<result property="settleMonth" column="SETTLE_MONTH" jdbcType="VARCHAR"/>
27 28
            <result property="invoiceNo" column="INVOICE_NO" jdbcType="VARCHAR"/>
            <result property="buyType" column="BUY_TYPE" jdbcType="TINYINT"/>
李灿灿's avatar
李灿灿 committed
29
            <result property="insuranceProvince" column="INSURANCE_PROVINCE" jdbcType="TINYINT"/>
李灿灿's avatar
李灿灿 committed
30
            <result property="insuranceProvinceName" column="INSURANCE_PROVINCE_NAME" jdbcType="VARCHAR"/>
李灿灿's avatar
李灿灿 committed
31
            <result property="insuranceCity" column="INSURANCE_CITY" jdbcType="TINYINT"/>
李灿灿's avatar
李灿灿 committed
32
            <result property="insuranceCityName" column="INSURANCE_CITY_NAME" jdbcType="VARCHAR"/>
李灿灿's avatar
李灿灿 committed
33
            <result property="insuranceHandleProvince" column="INSURANCE_HANDLE_PROVINCE" jdbcType="TINYINT"/>
李灿灿's avatar
李灿灿 committed
34
            <result property="insuranceHandleProvinceName" column="INSURANCE_HANDLE_PROVINCE_NAME" jdbcType="VARCHAR"/>
李灿灿's avatar
李灿灿 committed
35
            <result property="insuranceHandleCity" column="INSURANCE_HANDLE_CITY" jdbcType="TINYINT"/>
李灿灿's avatar
李灿灿 committed
36 37
            <result property="insuranceHandleCityName" column="INSURANCE_HANDLE_CITY_NAME" jdbcType="VARCHAR"/>
            <result property="settleType" column="SETTLE_TYPE" jdbcType="TINYINT"/>
38 39
            <result property="actualPremium" column="ACTUAL_PREMIUM" jdbcType="DECIMAL"/>
            <result property="estimatePremium" column="ESTIMATE_PREMIUM" jdbcType="DECIMAL"/>
40
            <result property="signFlag" column="SIGN_FLAG" jdbcType="TINYINT"/>
41
            <result property="buyHandleStatus" column="BUY_HANDLE_STATUS" jdbcType="TINYINT"/>
李灿灿's avatar
李灿灿 committed
42
            <result property="defaultSettleId" column="DEFAULT_SETTLE_ID" jdbcType="VARCHAR"/>
43 44 45 46
            <result property="reduceHandleStatus" column="REDUCE_HANDLE_STATUS" jdbcType="TINYINT"/>
            <result property="isUse" column="IS_USE" jdbcType="TINYINT"/>
            <result property="isEffect" column="IS_EFFECT" jdbcType="TINYINT"/>
            <result property="isOverdue" column="IS_OVERDUE" jdbcType="TINYINT"/>
李灿灿's avatar
李灿灿 committed
47
            <result property="remark" column="REMARK" jdbcType="VARCHAR"/>
48 49 50 51 52 53
            <result property="createBy" column="CREATE_BY" jdbcType="VARCHAR"/>
            <result property="createName" column="CREATE_NAME" jdbcType="VARCHAR"/>
            <result property="createTime" column="CREATE_TIME" jdbcType="TIMESTAMP"/>
            <result property="updateBy" column="UPDATE_BY" jdbcType="VARCHAR"/>
            <result property="updateTime" column="UPDATE_TIME" jdbcType="TIMESTAMP"/>
            <result property="deleteFlag" column="DELETE_FLAG" jdbcType="TINYINT"/>
54 55 56
			<result property="handledBy" column="HANDLED_BY" jdbcType="VARCHAR"/>
			<result property="handledTime" column="HANDLED_TIME" jdbcType="TIMESTAMP"/>
	</resultMap>
57 58

    <sql id="Base_Column_List">
李灿灿's avatar
李灿灿 committed
59
        ID,EMP_NAME,
李灿灿's avatar
李灿灿 committed
60
        EMP_IDCARD_NO,DEPT_NO,POST,INSURANCE_COMPANY_NAME,INSURANCE_TYPE_NAME,
61
        INSURANCE_TYPE_ID,BUY_STANDARD,RATE,BILLING_TYPE,MEDICAL_QUOTA,DIE_DISABLE_QUOTA,POLICY_NO,
62 63
        POLICY_START,POLICY_END,POLICY_EFFECT,
        BATCH_DATE,SETTLE_MONTH,INVOICE_NO,
李灿灿's avatar
李灿灿 committed
64 65
        BUY_TYPE,INSURANCE_PROVINCE,INSURANCE_PROVINCE_NAME,INSURANCE_CITY,INSURANCE_CITY_NAME,
        INSURANCE_HANDLE_PROVINCE,INSURANCE_HANDLE_PROVINCE_NAME,INSURANCE_HANDLE_CITY,INSURANCE_HANDLE_CITY_NAME,SETTLE_TYPE,
66
        ACTUAL_PREMIUM,ESTIMATE_PREMIUM,SIGN_FLAG,
李灿灿's avatar
李灿灿 committed
67
        BUY_HANDLE_STATUS,DEFAULT_SETTLE_ID,REDUCE_HANDLE_STATUS,
李灿灿's avatar
李灿灿 committed
68
        IS_USE,IS_EFFECT,IS_OVERDUE,REMARK,
69
        CREATE_BY,CREATE_NAME,CREATE_TIME,
70 71
        UPDATE_BY,UPDATE_TIME,DELETE_FLAG,DEFAULT_SETTLE_ID,HANDLED_BY,HANDLED_TIME
	</sql>
李灿灿's avatar
李灿灿 committed
72
	<!--投保分页查询-->
李灿灿's avatar
李灿灿 committed
73 74 75 76 77 78 79 80 81 82 83 84
	<select id="getInsuranceListPage" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceListVO">
		select detail.id as id,
		detail.EMP_NAME as empName,
		detail.EMP_IDCARD_NO as empIdcardNo,
		detail.BUY_TYPE as buyType,
		detail.POST as post,
		detail.DEPT_NO as deptNo,
		detail.POLICY_START as policyStart,
		detail.POLICY_END as policyEnd,
		detail.INSURANCE_COMPANY_NAME as insuranceCompanyName,
		detail.INSURANCE_TYPE_NAME as insuranceTypeName,
	    detail.BUY_STANDARD as buyStandard,
85
		detail.CREATE_BY as createBy,
李灿灿's avatar
李灿灿 committed
86 87 88
		detail.CREATE_NAME as createName,
		detail.BUY_HANDLE_STATUS as buyHandleStatus,
		detail.SETTLE_TYPE as settleType,
李灿灿's avatar
李灿灿 committed
89 90 91 92
		detail.SETTLE_MONTH as settleMonth
		from t_insurance_detail detail
		where detail.DELETE_FLAG = 0
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
93 94 95 96 97 98 99
			and detail.DEPT_NO = #{param.deptNo}
		</if>
		<if test="param.deptNo == null or param.deptNo.trim() == ''">
			and detail.DEPT_NO in
			<foreach collection="param.deptNoList" index="index" item="item" open="(" separator="," close=")">
				#{item}
			</foreach>
李灿灿's avatar
李灿灿 committed
100 101 102 103 104 105 106 107 108 109 110
		</if>
		<if test="param.buyHandleStatus != null">
			and detail.BUY_HANDLE_STATUS = #{param.buyHandleStatus}
		</if>
		<if test="param.empName != null and param.empName.trim() != ''">
			and detail.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
			and detail.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
111
			and detail.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
李灿灿's avatar
李灿灿 committed
112
		</if>
113 114 115
		<if test="param.insuranceTypeName != null and param.insuranceTypeName.trim() != ''">
			and detail.INSURANCE_TYPE_NAME like concat('%',replace(replace(#{param.insuranceTypeName},'_','\_'),'%','\%'),'%')
		</if>
李灿灿's avatar
李灿灿 committed
116
		<if test="param.buyHandleStatusList != null and param.buyHandleStatusList.size > 0">
117 118 119 120 121
			and detail.BUY_HANDLE_STATUS in
			<foreach collection="param.buyHandleStatusList" index="index" item="item" open="(" separator="," close=")">
				 #{item}
			</foreach>
		</if>
李灿灿's avatar
李灿灿 committed
122 123 124 125 126 127 128 129 130
		<if test="param.buyType != null">
			and detail.BUY_TYPE = #{param.buyType}
		</if>
		<if test="param.createName != null and param.createName.trim() != ''">
			and detail.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.startDate != null and param.startDate.trim() != '' and param.endDate != null and param.endDate.trim() != ''">
			and detail.CREATE_TIME <![CDATA[ >= ]]>  concat(#{param.startDate}, ' 00:00:00') and detail.CREATE_TIME <![CDATA[ <= ]]> concat(#{param.endDate}, ' 23:59:59')
		</if>
131
		ORDER BY detail.BUY_HANDLE_STATUS,detail.CREATE_TIME DESC
李灿灿's avatar
李灿灿 committed
132 133
	</select>

134 135
	<!--投保不分页查询-->
	<select id="getInsuranceList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceListVO">
136 137 138 139 140 141 142 143 144 145 146
		select detail.id as id,
		detail.EMP_NAME as empName,
		detail.EMP_IDCARD_NO as empIdcardNo,
		detail.BUY_TYPE as buyType,
		detail.POST as post,
		detail.DEPT_NO as deptNo,
		detail.POLICY_START as policyStart,
		detail.POLICY_END as policyEnd,
		detail.INSURANCE_COMPANY_NAME as insuranceCompanyName,
		detail.INSURANCE_TYPE_NAME as insuranceTypeName,
		detail.BUY_STANDARD as buyStandard,
147
		detail.CREATE_BY as createBy,
148 149 150 151 152 153 154 155 156
		detail.CREATE_NAME as createName,
		detail.BUY_HANDLE_STATUS as buyHandleStatus,
		detail.SETTLE_TYPE as settleType,
		detail.SETTLE_MONTH as settleMonth
		from t_insurance_detail detail
		where detail.DELETE_FLAG = 0
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
			and detail.DEPT_NO = #{param.deptNo}
		</if>
157 158 159 160 161 162
		<if test="param.deptNo == null or param.deptNo.trim() == ''">
			and detail.DEPT_NO in
			<foreach collection="param.deptNoList" index="index" item="item" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
		<if test="param.buyHandleStatus != null">
			and detail.BUY_HANDLE_STATUS = #{param.buyHandleStatus}
		</if>
		<if test="param.empName != null and param.empName.trim() != ''">
			and detail.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
			and detail.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
			and detail.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
		</if>
		<if test="param.insuranceTypeName != null and param.insuranceTypeName.trim() != ''">
			and detail.INSURANCE_TYPE_NAME like concat('%',replace(replace(#{param.insuranceTypeName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.buyHandleStatusList != null and param.buyHandleStatusList.size > 0">
			and detail.BUY_HANDLE_STATUS in
			<foreach collection="param.buyHandleStatusList" index="index" item="item" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
李灿灿's avatar
李灿灿 committed
184 185 186 187 188 189 190 191 192
		<if test="param.buyType != null">
			and detail.BUY_TYPE = #{param.buyType}
		</if>
		<if test="param.createName != null and param.createName.trim() != ''">
			and detail.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.startDate != null and param.startDate.trim() != '' and param.endDate != null and param.endDate.trim() != ''">
			and detail.CREATE_TIME <![CDATA[ >= ]]>  concat(#{param.startDate}, ' 00:00:00') and detail.CREATE_TIME <![CDATA[ <= ]]> concat(#{param.endDate}, ' 23:59:59')
		</if>
193 194 195
		ORDER BY detail.BUY_HANDLE_STATUS,detail.CREATE_TIME DESC
	</select>

196 197
	<!--投保办理分页查询-->
	<select id="getInsuranceHandleListPage" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceListVO">
李灿灿's avatar
李灿灿 committed
198 199 200 201 202 203 204 205 206 207 208 209 210 211
		select detail.id as id,
		detail.EMP_NAME as empName,
		detail.EMP_IDCARD_NO as empIdcardNo,
		detail.BUY_TYPE as buyType,
		detail.POST as post,
		detail.DEPT_NO as deptNo,
		detail.POLICY_START as policyStart,
		detail.POLICY_END as policyEnd,
		detail.INSURANCE_COMPANY_NAME as insuranceCompanyName,
		detail.INSURANCE_TYPE_NAME as insuranceTypeName,
		detail.BUY_STANDARD as buyStandard,
		detail.CREATE_NAME as createName,
		detail.BUY_HANDLE_STATUS as buyHandleStatus,
		detail.SETTLE_TYPE as settleType,
李灿灿's avatar
李灿灿 committed
212 213 214 215
		detail.SETTLE_MONTH as settleMonth
		from t_insurance_detail detail
		where detail.DELETE_FLAG = 0
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
216 217
			and detail.DEPT_NO = #{param.deptNo}
		</if>
李灿灿's avatar
李灿灿 committed
218 219 220 221 222 223 224 225 226 227
		<if test="param.buyHandleStatus != null">
			and detail.BUY_HANDLE_STATUS = #{param.buyHandleStatus}
		</if>
		<if test="param.empName != null and param.empName.trim() != ''">
			and detail.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
			and detail.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
228
			and detail.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
李灿灿's avatar
李灿灿 committed
229
		</if>
230 231 232
		<if test="param.insuranceTypeName != null and param.insuranceTypeName.trim() != ''">
			and detail.INSURANCE_TYPE_NAME like concat('%',replace(replace(#{param.insuranceTypeName},'_','\_'),'%','\%'),'%')
		</if>
李灿灿's avatar
李灿灿 committed
233
		<if test="param.buyHandleStatusList != null and param.buyHandleStatusList.size > 0">
234 235 236 237 238
			and detail.BUY_HANDLE_STATUS in
			<foreach collection="param.buyHandleStatusList" index="index" item="item" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
239 240 241 242 243 244
		<if test="param.regionSql != null and param.regionSql.trim() != ''">
			and  ${param.regionSql}
		</if>
		<if test="param.updateBy != null and param.updateBy.trim() != ''">
			and detail.HANDLED_BY = #{param.updateBy}
		</if>
李灿灿's avatar
李灿灿 committed
245 246 247 248 249 250 251 252 253
		<if test="param.buyType != null">
			and detail.BUY_TYPE = #{param.buyType}
		</if>
		<if test="param.createName != null and param.createName.trim() != ''">
			and detail.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.startDate != null and param.startDate.trim() != '' and param.endDate != null and param.endDate.trim() != ''">
			and detail.CREATE_TIME <![CDATA[ >= ]]>  concat(#{param.startDate}, ' 00:00:00') and detail.CREATE_TIME <![CDATA[ <= ]]> concat(#{param.endDate}, ' 23:59:59')
		</if>
254
		ORDER BY detail.BUY_HANDLE_STATUS,detail.CREATE_TIME DESC
李灿灿's avatar
李灿灿 committed
255
	</select>
李灿灿's avatar
李灿灿 committed
256 257 258

	<select id="getInsuranceDetailById" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceDetailVO">
		select
李灿灿's avatar
李灿灿 committed
259
		detail.id as id,
李灿灿's avatar
李灿灿 committed
260 261 262 263 264 265 266 267 268 269
		detail.EMP_NAME as empName,
		detail.EMP_IDCARD_NO as empIdcardNo,
		detail.BUY_TYPE as buyType,
		detail.DEPT_NO as deptNo,
		detail.POST as post,
		detail.POLICY_START as policyStart,
		detail.POLICY_END as policyEnd,
		detail.POLICY_EFFECT as policyEffect,
		detail.POLICY_NO as policyNo,
		detail.INSURANCE_TYPE_NAME as insuranceTypeName,
270
		detail.INSURANCE_TYPE_ID as insuranceTypeId,
李灿灿's avatar
李灿灿 committed
271 272 273 274 275 276 277 278 279 280 281 282
		detail.BUY_STANDARD as buyStandard,
		detail.MEDICAL_QUOTA as medicalQuota,
		detail.DIE_DISABLE_QUOTA as dieDisableQuota,
		detail.INSURANCE_COMPANY_NAME as insuranceCompanyName,
		detail.SETTLE_TYPE as premiumType,
		detail.ESTIMATE_PREMIUM as estimatePremium,
		detail.ACTUAL_PREMIUM as actualPremium,
		detail.INVOICE_NO as invoiceNo,
		detail.SETTLE_TYPE as settleType,
		detail.SETTLE_MONTH as settleMonth,
		detail.BUY_HANDLE_STATUS as buyHandleStatus,
		detail.REDUCE_HANDLE_STATUS as reduceHandleStatus,
李灿灿's avatar
李灿灿 committed
283
		tis.SETTLE_HANDLE_STATUS as settleHandleStatus,
李灿灿's avatar
李灿灿 committed
284 285 286 287
		detail.IS_USE as isUse,
		detail.IS_EFFECT as isEffect,
		detail.IS_OVERDUE as isOverdue,
		detail.INSURANCE_PROVINCE_NAME as insuranceProvinceName,
李灿灿's avatar
李灿灿 committed
288
		detail.INSURANCE_PROVINCE as insuranceProvince,
李灿灿's avatar
李灿灿 committed
289
		detail.INSURANCE_CITY_NAME as insuranceCityName,
李灿灿's avatar
李灿灿 committed
290
		detail.INSURANCE_CITY as insuranceCity,
李灿灿's avatar
李灿灿 committed
291
		detail.INSURANCE_HANDLE_PROVINCE_NAME as insuranceHandleProvinceName,
李灿灿's avatar
李灿灿 committed
292
		detail.INSURANCE_HANDLE_PROVINCE as insuranceHandleProvince,
李灿灿's avatar
李灿灿 committed
293
		detail.INSURANCE_HANDLE_CITY_NAME as insuranceHandleCityName,
李灿灿's avatar
李灿灿 committed
294
		detail.INSURANCE_HANDLE_CITY as insuranceHandleCity,
李灿灿's avatar
李灿灿 committed
295
		detail.CREATE_NAME as createName,
李灿灿's avatar
李灿灿 committed
296 297 298 299
		detail.CREATE_TIME as createTime,
		detail.REMARK as remark,
		detail.BILLING_TYPE as billingType,
		detail.RATE as  rate
李灿灿's avatar
李灿灿 committed
300
		from t_insurance_detail detail
李灿灿's avatar
李灿灿 committed
301
		left join t_insurance_settle tis on detail.DEFAULT_SETTLE_ID = tis.ID
李灿灿's avatar
李灿灿 committed
302 303
		where detail.ID = #{id}
	</select>
304
	<!-- 导出办理勾选查询结果-->
李灿灿's avatar
李灿灿 committed
305 306 307
	<select id="getInsuranceExportListBySelect" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceExportListVO">
		select detail.id as id,
		detail.DEPT_NO as deptNo,
308 309 310
		detail.EMP_NAME as empName,
		detail.EMP_IDCARD_NO as empIdcardNo,
		detail.BUY_TYPE as buyType,
311
		detail.BUY_HANDLE_STATUS as buyHandleStatus,
312
		detail.POST as post,
李灿灿's avatar
李灿灿 committed
313 314 315 316
		detail.INSURANCE_PROVINCE_NAME as insuranceProvinceName,
		detail.INSURANCE_CITY_NAME as insuranceCityName,
		detail.INSURANCE_HANDLE_PROVINCE_NAME as insuranceHandleProvinceName,
		detail.INSURANCE_HANDLE_CITY_NAME as insuranceHandleCityName,
317 318 319 320 321
		detail.POLICY_START as policyStart,
		detail.POLICY_END as policyEnd,
		detail.INSURANCE_COMPANY_NAME as insuranceCompanyName,
		detail.INSURANCE_TYPE_NAME as insuranceTypeName,
		detail.BUY_STANDARD as buyStandard,
李灿灿's avatar
李灿灿 committed
322 323 324
		detail.MEDICAL_QUOTA as medicalQuota,
		detail.DIE_DISABLE_QUOTA as dieDisableQuota,
		detail.SETTLE_MONTH as settleMonth,
325
		detail.SETTLE_TYPE as settleType,
李灿灿's avatar
李灿灿 committed
326
		detail.CREATE_NAME as createName,
327
		detail.POLICY_NO as policyNo,
李灿灿's avatar
李灿灿 committed
328
		detail.REMARK as remark
329
		from t_insurance_detail detail
330
		where detail.DELETE_FLAG = 0 and detail.id in
李灿灿's avatar
李灿灿 committed
331 332 333 334 335
		<foreach collection="idList" index="index" item="item" open="(" separator="," close=")">
			#{item}
		</foreach>
		ORDER BY detail.CREATE_TIME DESC
	</select>
336
	<!--出办理非勾选查询结果-->
李灿灿's avatar
李灿灿 committed
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
	<select id="getInsuranceExportList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceExportListVO">
		select detail.id as id,
			detail.DEPT_NO as deptNo,
			detail.EMP_NAME as empName,
			detail.EMP_IDCARD_NO as empIdcardNo,
			detail.BUY_TYPE as buyType,
			detail.POST as post,
			detail.INSURANCE_PROVINCE_NAME as insuranceProvinceName,
			detail.INSURANCE_CITY_NAME as insuranceCityName,
			detail.INSURANCE_HANDLE_PROVINCE_NAME as insuranceHandleProvinceName,
			detail.INSURANCE_HANDLE_CITY_NAME as insuranceHandleCityName,
			detail.POLICY_START as policyStart,
			detail.POLICY_END as policyEnd,
			detail.INSURANCE_COMPANY_NAME as insuranceCompanyName,
			detail.INSURANCE_TYPE_NAME as insuranceTypeName,
			detail.BUY_STANDARD as buyStandard,
			detail.MEDICAL_QUOTA as medicalQuota,
			detail.DIE_DISABLE_QUOTA as dieDisableQuota,
			detail.SETTLE_MONTH as settleMonth,
			detail.SETTLE_TYPE as settleType,
			detail.CREATE_NAME as createName,
358
			detail.POLICY_NO as policyNo,
李灿灿's avatar
李灿灿 committed
359 360 361
			detail.REMARK as remark
		from t_insurance_detail detail
		where detail.DELETE_FLAG = 0 and detail.BUY_HANDLE_STATUS = 1
362 363 364 365 366 367
		<if test="param.empName != null and param.empName.trim() != ''">
			and detail.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
			and detail.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
		</if>
李灿灿's avatar
李灿灿 committed
368
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
369
			and detail.DEPT_NO like concat('%',replace(replace(#{param.deptNo},'_','\_'),'%','\%'),'%')
李灿灿's avatar
李灿灿 committed
370
		</if>
371 372 373
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
			and detail.INSURANCE_COMPANY_NAME like concat('%',replace(replace(#{param.insuranceCompanyName},'_','\_'),'%','\%'),'%')
		</if>
374 375 376
		<if test="param.regionSql != null and param.regionSql.trim() != ''">
			and  ${param.regionSql}
		</if>
377 378 379 380 381 382 383 384 385
		<if test="param.buyType != null">
			and detail.BUY_TYPE = #{param.buyType}
		</if>
		<if test="param.createName != null and param.createName.trim() != ''">
			and detail.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.startDate != null and param.startDate.trim() != '' and param.endDate != null and param.endDate.trim() != ''">
			and detail.CREATE_TIME <![CDATA[ >= ]]>  concat(#{param.startDate}, ' 00:00:00') and detail.CREATE_TIME <![CDATA[ <= ]]> concat(#{param.endDate}, ' 23:59:59')
		</if>
386 387
		ORDER BY detail.CREATE_TIME DESC
	</select>
李灿灿's avatar
李灿灿 committed
388 389

	<!-- ***********************减员办理******************************** -->
390
	<!-- 已投保列表分页查询-->
李灿灿's avatar
李灿灿 committed
391
	<select id="getInsuredListPage" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuredListVo">
392 393 394 395 396 397 398 399 400 401 402 403
		select
			detail.id as id,
			detail.REDUCE_HANDLE_STATUS as reduceHandleStatus,
			detail.EMP_NAME as empName,
			detail.EMP_IDCARD_NO as empIdcardNo,
			detail.BUY_TYPE as buyType,
			detail.DEPT_NO as deptNo,
			detail.POST as post,
			detail.POLICY_START as policyStart,
			detail.POLICY_END as policyEnd,
			detail.POLICY_EFFECT as policyEffect,
			detail.IS_USE as isUse,
404 405
			detail.IS_EFFECT as isEffect,
			detail.IS_OVERDUE as isOverdue,
406 407 408
			detail.INSURANCE_COMPANY_NAME as insuranceCompanyName,
			detail.INSURANCE_TYPE_NAME as insuranceTypeName,
			detail.BUY_STANDARD as buyStandard
409 410
		from
		     t_insurance_detail detail
411 412 413 414 415 416 417 418 419 420 421
		where
			detail.DELETE_FLAG = 0
		and
			detail.BUY_HANDLE_STATUS = 3
		<if test="param.empName != null and param.empName.trim() != ''">
			and detail.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
			and detail.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
422
			and detail.DEPT_NO = #{param.deptNo}
423
		</if>
424
		<if test="param.deptNo == null or param.deptNo.trim() == ''">
425 426 427 428
			and detail.DEPT_NO in
			<foreach collection="param.deptNoList" index="index" item="item" open="(" separator="," close=")">
				#{item}
			</foreach>
429
		</if>
430
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
431
			and detail.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
432 433 434 435
		</if>
		<if test="param.policyNo != null and param.policyNo.trim() != ''">
			and detail.POLICY_NO like concat('%',replace(replace(#{param.policyNo},'_','\_'),'%','\%'),'%')
		</if>
436 437
		<if test="param.policyStart != null and param.policyStart.trim() != '' and param.policyEnd == null and param.policyEnd.trim() == ''">
			AND detail.POLICY_END   <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00')
438
		</if>
439 440 441 442 443 444 445 446 447
		<if test="param.policyEnd != null and param.policyEnd.trim() != '' and param.policyStart == null and param.policyStart.trim() == ''">
			AND detail.POLICY_START <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59')
		</if>
		<if test="param.policyStart != null and param.policyStart.trim() != '' and param.policyEnd != null and param.policyEnd.trim() != ''">
			and (
			(detail.POLICY_START <![CDATA[ <= ]]>  concat(#{param.policyStart}, ' 00:00:00') and detail.POLICY_END <![CDATA[ >= ]]> concat(#{param.policyEnd}, ' 23:59:59')) OR
			(detail.POLICY_START <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00') and detail.POLICY_START <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59')) OR
			(detail.POLICY_END <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00') and detail.POLICY_END <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59'))
				)
448 449 450 451 452 453 454
		</if>
		<if test="param.invoiceNo != null and param.invoiceNo.trim() != ''">
			and detail.INVOICE_NO like concat('%',replace(replace(#{param.invoiceNo},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.isUse != null">
			and detail.IS_USE = #{param.isUse}
		</if>
455
		<if test="param.isOverdue != null">
456 457
			and detail.IS_OVERDUE = #{param.isOverdue}
		</if>
458 459 460 461 462
		<if test="param.createStartTime != null and param.createStartTime.trim() != ''">
			AND detail.CREATE_TIME  <![CDATA[ >= ]]>  concat(#{param.createStartTime}, ' 00:00:00')
		</if>
		<if test="param.createEndTime != null and param.createEndTime.trim() != ''">
			AND detail.CREATE_TIME  <![CDATA[ <= ]]> concat(#{param.createEndTime}, ' 23:59:59')
463
		</if>
464
		ORDER BY detail.CREATE_TIME DESC ,detail.ID ASC
465
	</select>
466
	<!-- 已投保列表不分页查询-->
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508
	<select id="getInsuredList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuredListVo">
		select
			detail.id as id,
			detail.EMP_NAME as empName,
			detail.EMP_IDCARD_NO as empIdcardNo,
			detail.BUY_TYPE as buyType,
			detail.DEPT_NO as deptNo,
			detail.POST as post,
			detail.POLICY_START as policyStart,
			detail.POLICY_END as policyEnd,
			detail.INSURANCE_COMPANY_NAME as insuranceCompanyName,
			detail.INSURANCE_TYPE_NAME as insuranceTypeName,
			detail.BUY_STANDARD as buyStandard,
			detail.MEDICAL_QUOTA as medicalQuota,
			detail.DIE_DISABLE_QUOTA as dieDisableQuota,
			detail.ESTIMATE_PREMIUM as estimatePremium,
			detail.ACTUAL_PREMIUM as actualPremium,
			detail.POLICY_NO as policyNo,
			detail.INVOICE_NO as invoiceNo,
			detail.POLICY_EFFECT as policyEffect,
			detail.INSURANCE_PROVINCE_NAME as insuranceProvinceName,
			detail.INSURANCE_CITY_NAME as insuranceCityName,
			detail.INSURANCE_HANDLE_PROVINCE_NAME as insuranceHandleProvinceName,
			detail.INSURANCE_HANDLE_CITY_NAME as insuranceHandleCityName,
			detail.IS_USE as isUse,
			detail.IS_EFFECT as isEffect,
			detail.IS_OVERDUE as isOverdue,
			detail.CREATE_TIME as createTime,
			detail.CREATE_NAME as createName
		from
		    t_insurance_detail detail
		where
		    detail.DELETE_FLAG = 0
		and
			detail.BUY_HANDLE_STATUS = 3
		<if test="param.empName != null and param.empName.trim() != ''">
			and detail.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
			and detail.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
509
			and detail.DEPT_NO = #{param.deptNo}
510
		</if>
511
		<if test="param.deptNo == null or param.deptNo.trim() == ''">
512 513 514 515
			and detail.DEPT_NO in
			<foreach collection="param.deptNoList" index="index" item="item" open="(" separator="," close=")">
				#{item}
			</foreach>
516
		</if>
517
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
518
			and detail.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
519 520 521 522
		</if>
		<if test="param.policyNo != null and param.policyNo.trim() != ''">
			and detail.POLICY_NO like concat('%',replace(replace(#{param.policyNo},'_','\_'),'%','\%'),'%')
		</if>
523 524 525 526 527
		<if test="param.policyStart != null and param.policyStart.trim() != '' and param.policyEnd == null and param.policyEnd.trim() == ''">
			AND detail.POLICY_END   <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00')
		</if>
		<if test="param.policyEnd != null and param.policyEnd.trim() != '' and param.policyStart == null and param.policyStart.trim() == ''">
			AND detail.POLICY_START <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59')
528
		</if>
529 530 531 532 533 534
		<if test="param.policyStart != null and param.policyStart.trim() != '' and param.policyEnd != null and param.policyEnd.trim() != ''">
			and (
			(detail.POLICY_START <![CDATA[ <= ]]>  concat(#{param.policyStart}, ' 00:00:00') and detail.POLICY_END <![CDATA[ >= ]]> concat(#{param.policyEnd}, ' 23:59:59')) OR
			(detail.POLICY_START <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00') and detail.POLICY_START <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59')) OR
			(detail.POLICY_END <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00') and detail.POLICY_END <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59'))
			)
535 536 537 538 539 540 541
		</if>
		<if test="param.invoiceNo != null and param.invoiceNo.trim() != ''">
			and detail.INVOICE_NO like concat('%',replace(replace(#{param.invoiceNo},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.isUse != null">
			and detail.IS_USE = #{param.isUse}
		</if>
542
		<if test="param.isOverdue != null ">
543 544
			and detail.IS_OVERDUE = #{param.isOverdue}
		</if>
545 546 547 548 549
		<if test="param.createStartTime != null and param.createStartTime.trim() != ''">
			AND detail.CREATE_TIME  <![CDATA[ >= ]]>  concat(#{param.createStartTime}, ' 00:00:00')
		</if>
		<if test="param.createEndTime != null and param.createEndTime.trim() != ''">
			AND detail.CREATE_TIME  <![CDATA[ <= ]]> concat(#{param.createEndTime}, ' 23:59:59')
550 551 552
		</if>
		ORDER BY detail.CREATE_TIME DESC
	</select>
553
	<!-- 已减员列表分页查询-->
554 555 556 557 558 559 560 561 562 563 564
	<select id="getInsuranceRefundPageList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceRefundListVo">
		select
		    detail.id as id,
			detail.EMP_NAME as empName,
			detail.EMP_IDCARD_NO as empIdcardNo,
			detail.POST as post,
			detail.DEPT_NO as deptNo,
			detail.INSURANCE_COMPANY_NAME as insuranceCompanyName,
			detail.POLICY_START as policyStart,
			detail.POLICY_END as policyEnd,
			detail.POLICY_NO as policyNo,
565
			refund.CREATE_TIME as refundCreateTime
566
		from
567 568
			t_insurance_detail detail,
			t_insurance_refund refund
569 570
		where
		    detail.DELETE_FLAG = 0
571 572
		and
			detail.ID = refund.INS_DETAIL_ID
573 574 575 576 577 578 579 580 581
		and
			detail.REDUCE_HANDLE_STATUS = 4
		<if test="param.empName != null and param.empName.trim() != ''">
			and detail.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
			and detail.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
582
			and detail.DEPT_NO = #{param.deptNo}
583
		</if>
584
		<if test="param.deptNo == null or param.deptNo.trim() == ''">
585 586 587 588
			and detail.DEPT_NO in
			<foreach collection="param.deptNoList" index="index" item="item" open="(" separator="," close=")">
				#{item}
			</foreach>
589
		</if>
590
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
591
			and detail.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
592 593 594 595
		</if>
		<if test="param.policyNo != null and param.policyNo.trim() != ''">
			and detail.POLICY_NO like concat('%',replace(replace(#{param.policyNo},'_','\_'),'%','\%'),'%')
		</if>
596 597
		<if test="param.policyStart != null and param.policyStart.trim() != '' and param.policyEnd == null and param.policyEnd.trim() == ''">
			AND detail.POLICY_END   <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00')
598
		</if>
599 600 601 602 603 604 605 606 607
		<if test="param.policyEnd != null and param.policyEnd.trim() != '' and param.policyStart == null and param.policyStart.trim() == ''">
			AND detail.POLICY_START <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59')
		</if>
		<if test="param.policyStart != null and param.policyStart.trim() != '' and param.policyEnd != null and param.policyEnd.trim() != ''">
			and (
			(detail.POLICY_START <![CDATA[ <= ]]>  concat(#{param.policyStart}, ' 00:00:00') and detail.POLICY_END <![CDATA[ >= ]]> concat(#{param.policyEnd}, ' 23:59:59')) OR
			(detail.POLICY_START <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00') and detail.POLICY_START <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59')) OR
			(detail.POLICY_END <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00') and detail.POLICY_END <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59'))
			)
608
		</if>
609
		ORDER BY refund.CREATE_TIME DESC,detail.ID ASC
610
	</select>
611
	<!-- 已减员列表不分页查询-->
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630
	<select id="getInsuranceRefundList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceRefundListVo">
		select
			detail.id as id,
			detail.DEPT_NO as deptNo,
			detail.EMP_NAME as empName,
			detail.EMP_IDCARD_NO as empIdcardNo,
			detail.BUY_TYPE as buyType,
			detail.POST as post,
			detail.INSURANCE_PROVINCE_NAME as insuranceProvinceName,
			detail.INSURANCE_CITY_NAME as insuranceCityName,
			detail.INSURANCE_HANDLE_PROVINCE_NAME as insuranceHandleProvinceName,
			detail.INSURANCE_HANDLE_CITY_NAME as insuranceHandleCityName,
			detail.POLICY_START as policyStart,
			detail.POLICY_END as policyEnd,
			detail.INSURANCE_COMPANY_NAME as insuranceCompanyName,
			detail.INSURANCE_TYPE_NAME as insuranceTypeName,
			detail.BUY_STANDARD as buyStandard,
			detail.MEDICAL_QUOTA as medicalQuota,
			detail.DIE_DISABLE_QUOTA as dieDisableQuota,
631
			refund.CREATE_TIME as refundCreateTime
632
		from
633 634
			t_insurance_detail detail,
			t_insurance_refund refund
635
		where
636 637
			detail.ID = refund.INS_DETAIL_ID
		and
638 639 640 641 642 643 644 645 646 647
			detail.DELETE_FLAG = 0
		and
			detail.REDUCE_HANDLE_STATUS = 4
		<if test="param.empName != null and param.empName.trim() != ''">
			and detail.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
			and detail.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
648
			and detail.DEPT_NO = #{param.deptNo}
649
		</if>
650
		<if test="param.deptNo == null or param.deptNo.trim() == ''">
651 652 653 654
			and detail.DEPT_NO in
			<foreach collection="param.deptNoList" index="index" item="item" open="(" separator="," close=")">
				#{item}
			</foreach>
655
		</if>
656
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
657
			and detail.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
658 659 660 661
		</if>
		<if test="param.policyNo != null and param.policyNo.trim() != ''">
			and detail.POLICY_NO like concat('%',replace(replace(#{param.policyNo},'_','\_'),'%','\%'),'%')
		</if>
662 663 664 665 666
		<if test="param.policyStart != null and param.policyStart.trim() != '' and param.policyEnd == null and param.policyEnd.trim() == ''">
			AND detail.POLICY_END   <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00')
		</if>
		<if test="param.policyEnd != null and param.policyEnd.trim() != '' and param.policyStart == null and param.policyStart.trim() == ''">
			AND detail.POLICY_START <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59')
667
		</if>
668 669 670 671 672 673
		<if test="param.policyStart != null and param.policyStart.trim() != '' and param.policyEnd != null and param.policyEnd.trim() != ''">
			and (
			(detail.POLICY_START <![CDATA[ <= ]]>  concat(#{param.policyStart}, ' 00:00:00') and detail.POLICY_END <![CDATA[ >= ]]> concat(#{param.policyEnd}, ' 23:59:59')) OR
			(detail.POLICY_START <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00') and detail.POLICY_START <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59')) OR
			(detail.POLICY_END <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00') and detail.POLICY_END <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59'))
			)
674
		</if>
675
		ORDER BY refund.CREATE_TIME DESC
676
	</select>
677 678
	<!-- 减员办理列表分页查询-->
	<select id="getInsuranceRefundHandlingPageList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.RefundExportListVo">
李灿灿's avatar
李灿灿 committed
679
		select
680
		DISTINCT
李灿灿's avatar
李灿灿 committed
681
		detail.id as id,
682 683 684 685
		detail.EMP_NAME as empName,
		detail.EMP_IDCARD_NO as empIdcardNo,
		detail.BUY_TYPE as buyType,
		detail.DEPT_NO as deptNo,
686 687 688 689 690
		detail.POST as post,
		detail.INSURANCE_PROVINCE_NAME as insuranceProvinceName,
		detail.INSURANCE_CITY_NAME as insuranceCityName,
		detail.INSURANCE_HANDLE_PROVINCE_NAME as insuranceHandleProvinceName,
		detail.INSURANCE_HANDLE_CITY_NAME as insuranceHandleCityName,
691 692 693 694 695
		detail.POLICY_START as policyStart,
		detail.POLICY_END as policyEnd,
		detail.INSURANCE_COMPANY_NAME as insuranceCompanyName,
		detail.INSURANCE_TYPE_NAME as insuranceTypeName,
		detail.BUY_STANDARD as buyStandard,
696 697
		detail.MEDICAL_QUOTA as medicalQuota,
		detail.DIE_DISABLE_QUOTA as dieDisableQuota,
698
		refund.CREATE_NAME as createName,
699 700
		detail.REDUCE_HANDLE_STATUS as reduceHandleStatus
		from
701 702
			t_insurance_detail detail,
			t_insurance_refund refund
703
		where
704
			detail.ID = refund.INS_DETAIL_ID
705 706 707 708 709 710
		<if test="param.empName != null and param.empName.trim() != ''">
			and detail.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
			and detail.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
		</if>
711
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
712
			and detail.DEPT_NO = #{param.deptNo}
713
		</if>
714 715
		<if test="param.reduceHandleStatus != null">
			and detail.REDUCE_HANDLE_STATUS = #{param.reduceHandleStatus}
716
		</if>
717 718
		<if test="param.insuranceTypeName != null and param.insuranceTypeName.trim() != ''">
			and detail.INSURANCE_TYPE_NAME like concat('%',replace(replace(#{param.insuranceTypeName},'_','\_'),'%','\%'),'%')
719
		</if>
720 721 722
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
			and detail.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
		</if>
723 724
		<if test="param.regionSql != null and param.regionSql.trim() != ''">
			and  ${param.regionSql}
725
		</if>
726 727
		<if test="param.updateBy != null and param.updateBy.trim() != ''">
			and  refund.UPDATE_BY = #{param.updateBy}
728
		</if>
729 730 731 732 733 734 735 736 737
		<if test="param.createName != null and param.createName.trim() != ''">
			and refund.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.createStartTime != null and param.createStartTime.trim() != ''">
			AND refund.CREATE_TIME   <![CDATA[ >= ]]>  concat(#{param.createStartTime}, ' 00:00:00')
		</if>
		<if test="param.createEndTime != null and param.createEndTime.trim() != ''">
			AND refund.CREATE_TIME <![CDATA[ <= ]]> concat(#{param.createEndTime}, ' 23:59:59')
		</if>
738
		ORDER BY refund.CREATE_TIME DESC,detail.ID ASC
李灿灿's avatar
李灿灿 committed
739
	</select>
740
	<!-- 查询保单列表-->
741 742 743 744 745 746 747 748 749 750 751 752
	<select id="selectDetailListByIds"
			resultType="com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceDetail">
		select
			<include refid="Base_Column_List"></include>
		from
				t_insurance_detail
		where
			ID in
			<foreach collection="param.idList" index="index" item="item" open="(" separator="," close=")">
				#{item}
			</foreach>
	</select>
753
	<!-- 查询保单减员退费信息-->
754
	<select id="selectRefundDetail" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.TInsuranceRefundDetail">
755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782
		select
			detail.DEPT_NO as deptNo,
			detail.EMP_NAME as empName,
			detail.EMP_IDCARD_NO as empIdcardNo,
			refund.ID as id,
			refund.INS_DETAIL_ID as insDetailId,
			refund.REFUND_MONEY as refundMoney
		from
			t_insurance_detail detail,
			t_insurance_refund refund
		where
			detail.DELETE_FLAG = 0
		and
			detail.ID = refund.INS_DETAIL_ID
		and
			detail.BUY_HANDLE_STATUS = 5
		and
			detail.REDUCE_HANDLE_STATUS = 4
		<if test="param.empName != null and param.empName.trim() != ''">
			and detail.EMP_NAME = #{param.empName}
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
			and detail.EMP_IDCARD_NO = #{param.empIdcardNo}
		</if>
		<if test="param.policyNo!= null and param.policyNo.trim() != ''">
			and detail.POLICY_NO = #{param.policyNo}
		</if>
	</select>
783
	<!-- 根据ID导出减员办理列表-->
784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805
	<select id="getRefundExportListBySelect" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.RefundExportListVo">
		select
			detail.id as id,
			detail.DEPT_NO as deptNo,
			detail.EMP_NAME as empName,
			detail.EMP_IDCARD_NO as empIdcardNo,
			detail.BUY_TYPE as buyType,
			detail.POST as post,
			detail.INSURANCE_PROVINCE_NAME as insuranceProvinceName,
			detail.INSURANCE_CITY_NAME as insuranceCityName,
			detail.INSURANCE_HANDLE_PROVINCE_NAME as insuranceHandleProvinceName,
			detail.INSURANCE_HANDLE_CITY_NAME as insuranceHandleCityName,
			detail.POLICY_START as policyStart,
			detail.POLICY_END as policyEnd,
			detail.INSURANCE_COMPANY_NAME as insuranceCompanyName,
			detail.INSURANCE_TYPE_NAME as insuranceTypeName,
			detail.BUY_STANDARD as buyStandard,
			detail.MEDICAL_QUOTA as medicalQuota,
			detail.DIE_DISABLE_QUOTA as dieDisableQuota,
			detail.SETTLE_MONTH as settleMonth,
			detail.SETTLE_TYPE as settleType,
			detail.CREATE_NAME as createName,
806
			detail.REDUCE_HANDLE_STATUS as reduceHandleStatus,
807 808 809 810 811 812 813 814 815 816
			detail.REMARK as remark
		from
		    t_insurance_detail detail
		where
		    detail.id in
		<foreach collection="idList" index="index" item="item" open="(" separator="," close=")">
			#{item}
		</foreach>
		ORDER BY detail.CREATE_TIME DESC
	</select>
817
	<!-- 根据查询参数导出减员办理列表-->
818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851
	<select id="getRefundExportList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.RefundExportListVo">
		select
		    detail.id as id,
			detail.DEPT_NO as deptNo,
			detail.EMP_NAME as empName,
			detail.EMP_IDCARD_NO as empIdcardNo,
			detail.BUY_TYPE as buyType,
			detail.POST as post,
			detail.INSURANCE_PROVINCE_NAME as insuranceProvinceName,
			detail.INSURANCE_CITY_NAME as insuranceCityName,
			detail.INSURANCE_HANDLE_PROVINCE_NAME as insuranceHandleProvinceName,
			detail.INSURANCE_HANDLE_CITY_NAME as insuranceHandleCityName,
			detail.POLICY_START as policyStart,
			detail.POLICY_END as policyEnd,
			detail.INSURANCE_COMPANY_NAME as insuranceCompanyName,
			detail.INSURANCE_TYPE_NAME as insuranceTypeName,
			detail.BUY_STANDARD as buyStandard,
			detail.MEDICAL_QUOTA as medicalQuota,
			detail.DIE_DISABLE_QUOTA as dieDisableQuota,
			detail.SETTLE_MONTH as settleMonth,
			detail.SETTLE_TYPE as settleType,
			detail.CREATE_NAME as createName,
			detail.REMARK as remark
		from
			t_insurance_detail detail
		where
		    detail.DELETE_FLAG = 0 and detail.REDUCE_HANDLE_STATUS = 1
		<if test="param.empName != null and param.empName.trim() != ''">
			and detail.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
			and detail.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
852
			and detail.DEPT_NO = #{param.deptNo}
853
		</if>
854 855
		<if test="param.insuranceTypeName != null and param.insuranceTypeName.trim() != ''">
			and detail.INSURANCE_TYPE_NAME like concat('%',replace(replace(#{param.insuranceTypeName},'_','\_'),'%','\%'),'%')
856
		</if>
857 858 859
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
			and detail.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
		</if>
860 861 862
		<if test="param.regionSql != null and param.regionSql.trim() != ''">
			and  ${param.regionSql}
		</if>
863 864
		ORDER BY detail.CREATE_TIME DESC
	</select>
865
	<!-- 减员办理-->
866 867 868 869 870 871 872 873
	<update id="updateInsuranceRefund">
		update
			t_insurance_detail detail
		set
			UPDATE_BY = #{param.updateBy},
			REDUCE_HANDLE_STATUS = #{param.refundType},
			UPDATE_TIME = #{param.refundCreateTime}
		where
874
		      detail.ID in
875 876 877 878
		<foreach collection="param.idList" index="index" item="item" open="(" separator="," close=")">
			#{item}
		</foreach>
	</update>
879
	<!--根据身份证查询商险信息-->
880
	<select id="getInsuranceListByIdCard" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceListByIdCardVo">
huyuchen's avatar
huyuchen committed
881 882 883 884 885 886
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_insurance_detail
		<where>
			1=1
			AND EMP_IDCARD_NO = #{idCard}
887
			and DEPT_NO = #{deptNo}
huyuchen's avatar
huyuchen committed
888 889 890
		</where>
		ORDER BY CREATE_TIME desc
	</select>
891 892
    <select id="selectListByempIdcardNo" resultType="com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceDetail">
		SELECT
893 894 895
			<include refid="Base_Column_List"/>
		FROM
		  t_insurance_detail
896 897 898 899 900 901 902 903 904 905 906
		<where>
		    EMP_IDCARD_NO = #{empIdcardNo}
			AND IS_EFFECT = 0
			AND IS_USE =0
			and IS_OVERDUE = 0
			and DELETE_FLAG = 0
			and BUY_HANDLE_STATUS =3
			and (REDUCE_HANDLE_STATUS is null or REDUCE_HANDLE_STATUS = 3)
		</where>
		ORDER BY CREATE_TIME desc
	</select>
907 908 909 910 911 912 913 914 915 916 917 918 919
	<select id="selectByregionSQL" resultType="com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceDetail">
		SELECT
		<include refid="Base_Column_List"/>
		FROM
		t_insurance_detail detail
		<where>
			detail.ID = #{id}
			<if test="regionSql != null and regionSql.trim() != ''">
				and  ${regionSql}
			</if>
		</where>
		ORDER BY CREATE_TIME desc
	</select>
920
</mapper>