TInsuranceDetailMapper.xml 42.6 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>
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>
122
		ORDER BY detail.BUY_HANDLE_STATUS,detail.CREATE_TIME DESC
李灿灿's avatar
李灿灿 committed
123 124
	</select>

125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
	<!--投保办理分页查询-->
	<select id="getInsuranceHandleListPage" 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,
		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>
		<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>
168 169 170
		<if test="param.regionSql != null and param.regionSql.trim() != ''">
			and  ${param.regionSql}
		</if>
171
		<if test="param.updateBy != null and param.updateBy.trim() != ''">
172
			and detail.HANDLED_BY = #{param.updateBy}
173
		</if>
174 175 176 177
		ORDER BY detail.BUY_HANDLE_STATUS,detail.CREATE_TIME DESC
	</select>

	<!--投保办理不分页查询-->
李灿灿's avatar
李灿灿 committed
178 179 180 181 182 183 184 185 186 187 188 189
	<select id="getInsuranceList" 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,
190
		detail.CREATE_BY as createBy,
李灿灿's avatar
李灿灿 committed
191 192 193
		detail.CREATE_NAME as createName,
		detail.BUY_HANDLE_STATUS as buyHandleStatus,
		detail.SETTLE_TYPE as settleType,
李灿灿's avatar
李灿灿 committed
194 195 196 197
		detail.SETTLE_MONTH as settleMonth
		from t_insurance_detail detail
		where detail.DELETE_FLAG = 0
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
198 199 200 201 202 203 204
			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
205 206 207 208 209 210 211 212 213 214 215
		</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() != ''">
216
			and detail.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
李灿灿's avatar
李灿灿 committed
217
		</if>
218 219 220
		<if test="param.insuranceTypeName != null and param.insuranceTypeName.trim() != ''">
			and detail.INSURANCE_TYPE_NAME like concat('%',replace(replace(#{param.insuranceTypeName},'_','\_'),'%','\%'),'%')
		</if>
李灿灿's avatar
李灿灿 committed
221
		<if test="param.buyHandleStatusList != null and param.buyHandleStatusList.size > 0">
222 223 224 225 226
			and detail.BUY_HANDLE_STATUS in
			<foreach collection="param.buyHandleStatusList" index="index" item="item" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
227
		ORDER BY detail.BUY_HANDLE_STATUS,detail.CREATE_TIME DESC
李灿灿's avatar
李灿灿 committed
228
	</select>
李灿灿's avatar
李灿灿 committed
229

230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
	<!--投保办理不分页查询-->
	<select id="getInsuranceHandleList" 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,
		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>
		<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>
		<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>
279

280 281
		ORDER BY detail.BUY_HANDLE_STATUS,detail.CREATE_TIME DESC
	</select>
李灿灿's avatar
李灿灿 committed
282 283
	<select id="getInsuranceDetailById" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceDetailVO">
		select
李灿灿's avatar
李灿灿 committed
284
		detail.id as id,
李灿灿's avatar
李灿灿 committed
285 286 287 288 289 290 291 292 293 294
		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,
295
		detail.INSURANCE_TYPE_ID as insuranceTypeId,
李灿灿's avatar
李灿灿 committed
296 297 298 299 300 301 302 303 304 305 306 307
		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
308
		tis.SETTLE_HANDLE_STATUS as settleHandleStatus,
李灿灿's avatar
李灿灿 committed
309 310 311 312
		detail.IS_USE as isUse,
		detail.IS_EFFECT as isEffect,
		detail.IS_OVERDUE as isOverdue,
		detail.INSURANCE_PROVINCE_NAME as insuranceProvinceName,
李灿灿's avatar
李灿灿 committed
313
		detail.INSURANCE_PROVINCE as insuranceProvince,
李灿灿's avatar
李灿灿 committed
314
		detail.INSURANCE_CITY_NAME as insuranceCityName,
李灿灿's avatar
李灿灿 committed
315
		detail.INSURANCE_CITY as insuranceCity,
李灿灿's avatar
李灿灿 committed
316
		detail.INSURANCE_HANDLE_PROVINCE_NAME as insuranceHandleProvinceName,
李灿灿's avatar
李灿灿 committed
317
		detail.INSURANCE_HANDLE_PROVINCE as insuranceHandleProvince,
李灿灿's avatar
李灿灿 committed
318
		detail.INSURANCE_HANDLE_CITY_NAME as insuranceHandleCityName,
李灿灿's avatar
李灿灿 committed
319
		detail.INSURANCE_HANDLE_CITY as insuranceHandleCity,
李灿灿's avatar
李灿灿 committed
320 321 322
		detail.CREATE_NAME as createName,
		detail.CREATE_TIME as createTime
		from t_insurance_detail detail
李灿灿's avatar
李灿灿 committed
323
		left join t_insurance_settle tis on detail.DEFAULT_SETTLE_ID = tis.ID
李灿灿's avatar
李灿灿 committed
324 325
		where detail.ID = #{id}
	</select>
326
	<!-- 导出办理勾选查询结果-->
李灿灿's avatar
李灿灿 committed
327 328 329
	<select id="getInsuranceExportListBySelect" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceExportListVO">
		select detail.id as id,
		detail.DEPT_NO as deptNo,
330 331 332
		detail.EMP_NAME as empName,
		detail.EMP_IDCARD_NO as empIdcardNo,
		detail.BUY_TYPE as buyType,
333
		detail.BUY_HANDLE_STATUS as buyHandleStatus,
334
		detail.POST as post,
李灿灿's avatar
李灿灿 committed
335 336 337 338
		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,
339 340 341 342 343
		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
344 345 346
		detail.MEDICAL_QUOTA as medicalQuota,
		detail.DIE_DISABLE_QUOTA as dieDisableQuota,
		detail.SETTLE_MONTH as settleMonth,
347
		detail.SETTLE_TYPE as settleType,
李灿灿's avatar
李灿灿 committed
348
		detail.CREATE_NAME as createName,
349
		detail.POLICY_NO as policyNo,
李灿灿's avatar
李灿灿 committed
350
		detail.REMARK as remark
351
		from t_insurance_detail detail
352
		where detail.DELETE_FLAG = 0 and detail.id in
李灿灿's avatar
李灿灿 committed
353 354 355 356 357
		<foreach collection="idList" index="index" item="item" open="(" separator="," close=")">
			#{item}
		</foreach>
		ORDER BY detail.CREATE_TIME DESC
	</select>
358
	<!--出办理非勾选查询结果-->
李灿灿's avatar
李灿灿 committed
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
	<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,
380
			detail.POLICY_NO as policyNo,
李灿灿's avatar
李灿灿 committed
381 382 383
			detail.REMARK as remark
		from t_insurance_detail detail
		where detail.DELETE_FLAG = 0 and detail.BUY_HANDLE_STATUS = 1
384 385 386 387 388 389
		<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
390
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
391
			and detail.DEPT_NO like concat('%',replace(replace(#{param.deptNo},'_','\_'),'%','\%'),'%')
李灿灿's avatar
李灿灿 committed
392
		</if>
393 394 395
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
			and detail.INSURANCE_COMPANY_NAME like concat('%',replace(replace(#{param.insuranceCompanyName},'_','\_'),'%','\%'),'%')
		</if>
396 397 398
		<if test="param.regionSql != null and param.regionSql.trim() != ''">
			and  ${param.regionSql}
		</if>
399 400
		ORDER BY detail.CREATE_TIME DESC
	</select>
李灿灿's avatar
李灿灿 committed
401 402

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