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

    <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
			<result property="handledBy" column="HANDLED_BY" jdbcType="VARCHAR"/>
			<result property="handledTime" column="HANDLED_TIME" jdbcType="TIMESTAMP"/>
56 57 58
			<result property="orderNo" column="ORDER_NO" jdbcType="VARCHAR"/>
			<result property="createUserDeptId" column="CREATE_USER_DEPT_ID" jdbcType="VARCHAR"/>
			<result property="createUserDeptName" column="CREATE_USER_DEPT_NAME" jdbcType="VARCHAR"/>
huyuchen's avatar
huyuchen committed
59
			<result property="deptId" column="DEPT_ID" jdbcType="VARCHAR"/>
60
			<result property="bpoFlag" column="BPO_FLAG" jdbcType="VARCHAR"/>
hongguangwu's avatar
hongguangwu committed
61 62 63 64
			<result property="deptName" column="DEPT_NAME" jdbcType="VARCHAR"/>
			<result property="unitId" column="UNIT_ID" jdbcType="VARCHAR"/>
			<result property="unitName" column="UNIT_NAME" jdbcType="VARCHAR"/>
			<result property="unitNo" column="UNIT_NO" jdbcType="VARCHAR"/>
huyuchen's avatar
huyuchen committed
65 66 67 68
			<result property="incomeSettleFlag" column="INCOME_SETTLE_FLAG"/>
			<result property="incomeCollectFlag" column="INCOME_COLLECT_FLAG"/>
			<result property="paySettleFlag" column="PAY_COLLECT_FLAG"/>
			<result property="payCollectFlag" column="PAY_SETTLE_FLAG"/>
huyuchen's avatar
huyuchen committed
69 70 71 72
			<result property="sincomeSettleFlag" column="SINCOME_SETTLE_FLAG"/>
			<result property="sincomeCollectFlag" column="SINCOME_COLLECT_FLAG"/>
			<result property="spaySettleFlag" column="SPAY_COLLECT_FLAG"/>
			<result property="spayCollectFlag" column="SPAY_SETTLE_FLAG"/>
73
	</resultMap>
huyuchen's avatar
huyuchen committed
74 75 76 77 78
	<resultMap id="UpdateMap" type="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceUpdateVO">
		<id property="id" column="ID" jdbcType="VARCHAR"/>
		<result property="invoiceNo" column="INVOICE_NO" jdbcType="VARCHAR"/>
		<result property="policyNo" column="POLICY_NO" jdbcType="VARCHAR"/>
	</resultMap>
79
    <sql id="Base_Column_List">
李灿灿's avatar
李灿灿 committed
80
        ID,EMP_NAME,
李灿灿's avatar
李灿灿 committed
81
        EMP_IDCARD_NO,DEPT_NO,POST,INSURANCE_COMPANY_NAME,INSURANCE_TYPE_NAME,
82
        INSURANCE_TYPE_ID,BUY_STANDARD,RATE,BILLING_TYPE,MEDICAL_QUOTA,DIE_DISABLE_QUOTA,POLICY_NO,
83 84
        POLICY_START,POLICY_END,POLICY_EFFECT,
        BATCH_DATE,SETTLE_MONTH,INVOICE_NO,
李灿灿's avatar
李灿灿 committed
85 86
        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,
87
        ACTUAL_PREMIUM,ESTIMATE_PREMIUM,SIGN_FLAG,
李灿灿's avatar
李灿灿 committed
88
        BUY_HANDLE_STATUS,DEFAULT_SETTLE_ID,REDUCE_HANDLE_STATUS,
李灿灿's avatar
李灿灿 committed
89
        IS_USE,IS_EFFECT,IS_OVERDUE,REMARK,
90
        CREATE_BY,CREATE_NAME,CREATE_TIME,BPO_FLAG,
hongguangwu's avatar
hongguangwu committed
91 92 93
        UPDATE_BY,UPDATE_TIME,DELETE_FLAG,DEFAULT_SETTLE_ID,HANDLED_BY,HANDLED_TIME,ORDER_NO,CREATE_USER_DEPT_ID,CREATE_USER_DEPT_NAME,
		DEPT_NAME,UNIT_ID,UNIT_NAME,UNIT_NO

94

95
	</sql>
李灿灿's avatar
李灿灿 committed
96
	<!--投保分页查询-->
李灿灿's avatar
李灿灿 committed
97
	<select id="getInsuranceListPage" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceListVO">
huyuchen's avatar
huyuchen committed
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
		select a.id as id,
		a.EMP_NAME as empName,
		a.EMP_IDCARD_NO as empIdcardNo,
		a.BUY_TYPE as buyType,
		a.POST as post,
		a.DEPT_NO as deptNo,
		a.POLICY_START as policyStart,
		a.POLICY_END as policyEnd,
		a.INSURANCE_COMPANY_NAME as insuranceCompanyName,
		a.INSURANCE_TYPE_NAME as insuranceTypeName,
	    a.BUY_STANDARD as buyStandard,
		a.CREATE_BY as createBy,
		a.CREATE_NAME as createName,
		a.BUY_HANDLE_STATUS as buyHandleStatus,
		a.SETTLE_TYPE as settleType,
		a.CREATE_USER_DEPT_NAME as createUserDeptName,
hongguangwu's avatar
hongguangwu committed
114
		a.SETTLE_MONTH as settleMonth,
hongguangwu's avatar
hongguangwu committed
115
		a.DEPT_NAME as projectName,
hongguangwu's avatar
hongguangwu committed
116 117
		a.REDUCE_HANDLE_STATUS as reduceHandleStatus,
		a.CREATE_TIME as createTime
huyuchen's avatar
huyuchen committed
118 119
		from t_insurance_detail a
		where a.DELETE_FLAG = 0
李灿灿's avatar
李灿灿 committed
120
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
huyuchen's avatar
huyuchen committed
121
			and a.DEPT_NO = #{param.deptNo}
122
		</if>
123
		<if test="param.orderNo != null and param.orderNo.trim() != ''">
hongguangwu's avatar
hongguangwu committed
124
			and a.ORDER_NO = #{param.orderNo}
125
		</if>
李灿灿's avatar
李灿灿 committed
126
		<if test="param.buyHandleStatus != null">
huyuchen's avatar
huyuchen committed
127
			and a.BUY_HANDLE_STATUS = #{param.buyHandleStatus}
李灿灿's avatar
李灿灿 committed
128 129
		</if>
		<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
130
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
李灿灿's avatar
李灿灿 committed
131 132
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
133
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
李灿灿's avatar
李灿灿 committed
134 135
		</if>
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
huyuchen's avatar
huyuchen committed
136
			and a.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
李灿灿's avatar
李灿灿 committed
137
		</if>
138
		<if test="param.insuranceTypeName != null and param.insuranceTypeName.trim() != ''">
huyuchen's avatar
huyuchen committed
139
			and a.INSURANCE_TYPE_NAME like concat('%',replace(replace(#{param.insuranceTypeName},'_','\_'),'%','\%'),'%')
140
		</if>
李灿灿's avatar
李灿灿 committed
141
		<if test="param.buyHandleStatusList != null and param.buyHandleStatusList.size > 0">
huyuchen's avatar
huyuchen committed
142
			and a.BUY_HANDLE_STATUS in
143 144 145 146
			<foreach collection="param.buyHandleStatusList" index="index" item="item" open="(" separator="," close=")">
				 #{item}
			</foreach>
		</if>
李灿灿's avatar
李灿灿 committed
147
		<if test="param.buyType != null">
huyuchen's avatar
huyuchen committed
148
			and a.BUY_TYPE = #{param.buyType}
李灿灿's avatar
李灿灿 committed
149 150
		</if>
		<if test="param.createName != null and param.createName.trim() != ''">
hongguangwu's avatar
hongguangwu committed
151
			and a.CREATE_NAME like concat('%',#{param.createName},'%')
李灿灿's avatar
李灿灿 committed
152 153
		</if>
		<if test="param.startDate != null and param.startDate.trim() != '' and param.endDate != null and param.endDate.trim() != ''">
huyuchen's avatar
huyuchen committed
154
			and a.CREATE_TIME <![CDATA[ >= ]]>  concat(#{param.startDate}, ' 00:00:00') and a.CREATE_TIME <![CDATA[ <= ]]> concat(#{param.endDate}, ' 23:59:59')
李灿灿's avatar
李灿灿 committed
155
		</if>
hongguangwu's avatar
hongguangwu committed
156 157 158
		<if test="param.reduceHandleStatus != null">
			and a.REDUCE_HANDLE_STATUS = #{param.reduceHandleStatus}
		</if>
huyuchen's avatar
huyuchen committed
159 160 161
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
huyuchen's avatar
huyuchen committed
162
		ORDER BY a.BUY_HANDLE_STATUS,a.CREATE_TIME DESC
李灿灿's avatar
李灿灿 committed
163
	</select>
164 165
	<!--投保不分页查询-->
	<select id="getInsuranceList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceListVO">
huyuchen's avatar
huyuchen committed
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
		select a.id as id,
		a.EMP_NAME as empName,
		a.EMP_IDCARD_NO as empIdcardNo,
		a.BUY_TYPE as buyType,
		a.POST as post,
		a.DEPT_NO as deptNo,
		a.POLICY_START as policyStart,
		a.POLICY_END as policyEnd,
		a.INSURANCE_COMPANY_NAME as insuranceCompanyName,
		a.INSURANCE_TYPE_NAME as insuranceTypeName,
		a.BUY_STANDARD as buyStandard,
		a.CREATE_BY as createBy,
		a.CREATE_NAME as createName,
		a.BUY_HANDLE_STATUS as buyHandleStatus,
		a.SETTLE_TYPE as settleType,
hongguangwu's avatar
hongguangwu committed
181
		a.SETTLE_MONTH as settleMonth,
hongguangwu's avatar
hongguangwu committed
182
		a.DEPT_NAME as projectName,
hongguangwu's avatar
hongguangwu committed
183
		a.REDUCE_HANDLE_STATUS as reduceHandleStatus,
hongguangwu's avatar
hongguangwu committed
184 185
		if(a.BUY_HANDLE_STATUS=4,a.BACK_REMARK,'') as backRemark,
		a.CREATE_TIME as createTime
huyuchen's avatar
huyuchen committed
186 187
		from t_insurance_detail a
		where a.DELETE_FLAG = 0
188
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
huyuchen's avatar
huyuchen committed
189
			and a.DEPT_NO = #{param.deptNo}
190 191
		</if>
		<if test="param.buyHandleStatus != null">
huyuchen's avatar
huyuchen committed
192
			and a.BUY_HANDLE_STATUS = #{param.buyHandleStatus}
193 194
		</if>
		<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
195
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
196 197
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
198
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
199 200
		</if>
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
huyuchen's avatar
huyuchen committed
201
			and a.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
202 203
		</if>
		<if test="param.insuranceTypeName != null and param.insuranceTypeName.trim() != ''">
huyuchen's avatar
huyuchen committed
204
			and a.INSURANCE_TYPE_NAME like concat('%',replace(replace(#{param.insuranceTypeName},'_','\_'),'%','\%'),'%')
205 206
		</if>
		<if test="param.buyHandleStatusList != null and param.buyHandleStatusList.size > 0">
huyuchen's avatar
huyuchen committed
207
			and a.BUY_HANDLE_STATUS in
208 209 210 211
			<foreach collection="param.buyHandleStatusList" index="index" item="item" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
李灿灿's avatar
李灿灿 committed
212
		<if test="param.buyType != null">
huyuchen's avatar
huyuchen committed
213
			and a.BUY_TYPE = #{param.buyType}
李灿灿's avatar
李灿灿 committed
214 215
		</if>
		<if test="param.createName != null and param.createName.trim() != ''">
huyuchen's avatar
huyuchen committed
216
			and a.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
李灿灿's avatar
李灿灿 committed
217 218
		</if>
		<if test="param.startDate != null and param.startDate.trim() != '' and param.endDate != null and param.endDate.trim() != ''">
huyuchen's avatar
huyuchen committed
219
			and a.CREATE_TIME <![CDATA[ >= ]]>  concat(#{param.startDate}, ' 00:00:00') and a.CREATE_TIME <![CDATA[ <= ]]> concat(#{param.endDate}, ' 23:59:59')
李灿灿's avatar
李灿灿 committed
220
		</if>
hongguangwu's avatar
hongguangwu committed
221 222 223
		<if test="param.reduceHandleStatus != null">
			and a.REDUCE_HANDLE_STATUS = #{param.reduceHandleStatus}
		</if>
huyuchen's avatar
huyuchen committed
224 225 226
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
huyuchen's avatar
huyuchen committed
227
		ORDER BY a.BUY_HANDLE_STATUS,a.CREATE_TIME DESC
228
	</select>
229 230
	<!--投保办理分页查询-->
	<select id="getInsuranceHandleListPage" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceListVO">
huyuchen's avatar
huyuchen committed
231 232 233 234 235 236 237 238 239 240 241
		select a.id as id,
		a.EMP_NAME as empName,
		a.EMP_IDCARD_NO as empIdcardNo,
		a.BUY_TYPE as buyType,
		a.POST as post,
		a.DEPT_NO as deptNo,
		a.POLICY_START as policyStart,
		a.POLICY_END as policyEnd,
		a.INSURANCE_COMPANY_NAME as insuranceCompanyName,
		a.INSURANCE_TYPE_NAME as insuranceTypeName,
		a.BUY_STANDARD as buyStandard,
242
	    a.CREATE_TIME as createTime,
huyuchen's avatar
huyuchen committed
243 244 245
		a.CREATE_NAME as createName,
		a.BUY_HANDLE_STATUS as buyHandleStatus,
		a.SETTLE_TYPE as settleType,
hongguangwu's avatar
hongguangwu committed
246 247
		a.SETTLE_MONTH as settleMonth,
		a.DEPT_NAME as projectName
huyuchen's avatar
huyuchen committed
248 249
		from t_insurance_detail a
		where a.DELETE_FLAG = 0
李灿灿's avatar
李灿灿 committed
250
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
huyuchen's avatar
huyuchen committed
251
			and a.DEPT_NO = #{param.deptNo}
252
		</if>
李灿灿's avatar
李灿灿 committed
253
		<if test="param.buyHandleStatus != null">
huyuchen's avatar
huyuchen committed
254
			and a.BUY_HANDLE_STATUS = #{param.buyHandleStatus}
李灿灿's avatar
李灿灿 committed
255 256
		</if>
		<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
257
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
李灿灿's avatar
李灿灿 committed
258 259
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
260
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
李灿灿's avatar
李灿灿 committed
261 262
		</if>
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
huyuchen's avatar
huyuchen committed
263
			and a.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
李灿灿's avatar
李灿灿 committed
264
		</if>
265
		<if test="param.insuranceTypeName != null and param.insuranceTypeName.trim() != ''">
huyuchen's avatar
huyuchen committed
266
			and a.INSURANCE_TYPE_NAME like concat('%',replace(replace(#{param.insuranceTypeName},'_','\_'),'%','\%'),'%')
267
		</if>
李灿灿's avatar
李灿灿 committed
268
		<if test="param.buyHandleStatusList != null and param.buyHandleStatusList.size > 0">
huyuchen's avatar
huyuchen committed
269
			and a.BUY_HANDLE_STATUS in
270 271 272 273
			<foreach collection="param.buyHandleStatusList" index="index" item="item" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
274
		<if test="param.updateBy != null and param.updateBy.trim() != ''">
huyuchen's avatar
huyuchen committed
275
			and a.HANDLED_BY = #{param.updateBy}
276
		</if>
李灿灿's avatar
李灿灿 committed
277
		<if test="param.buyType != null">
huyuchen's avatar
huyuchen committed
278
			and a.BUY_TYPE = #{param.buyType}
李灿灿's avatar
李灿灿 committed
279 280
		</if>
		<if test="param.createName != null and param.createName.trim() != ''">
huyuchen's avatar
huyuchen committed
281
			and a.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
李灿灿's avatar
李灿灿 committed
282 283
		</if>
		<if test="param.startDate != null and param.startDate.trim() != '' and param.endDate != null and param.endDate.trim() != ''">
huyuchen's avatar
huyuchen committed
284
			and a.CREATE_TIME <![CDATA[ >= ]]>  concat(#{param.startDate}, ' 00:00:00') and a.CREATE_TIME <![CDATA[ <= ]]> concat(#{param.endDate}, ' 23:59:59')
李灿灿's avatar
李灿灿 committed
285
		</if>
huyuchen's avatar
huyuchen committed
286 287 288
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
289 290
		<if test="param.buyStandardMin != null">
			AND a.BUY_STANDARD <![CDATA[ >= ]]> #{param.buyStandardMin}
291
		</if>
292
		<if test="param.buyStandardMax != null">
293 294
			AND a.BUY_STANDARD <![CDATA[ <= ]]> #{param.buyStandardMax}
		</if>
huyuchen's avatar
huyuchen committed
295
		ORDER BY a.BUY_HANDLE_STATUS,a.CREATE_TIME DESC
李灿灿's avatar
李灿灿 committed
296
	</select>
297
	<!--通过id查询商险信息-->
李灿灿's avatar
李灿灿 committed
298 299
	<select id="getInsuranceDetailById" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceDetailVO">
		select
huyuchen's avatar
huyuchen committed
300 301 302 303 304
		a.id as id,
		a.EMP_NAME as empName,
		a.EMP_IDCARD_NO as empIdcardNo,
		a.BUY_TYPE as buyType,
		a.DEPT_NO as deptNo,
hongguangwu's avatar
hongguangwu committed
305
		a.DEPT_NAME as projectName,
huyuchen's avatar
huyuchen committed
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
		a.POST as post,
		a.POLICY_START as policyStart,
		a.POLICY_END as policyEnd,
		a.POLICY_EFFECT as policyEffect,
		a.POLICY_NO as policyNo,
		a.INSURANCE_TYPE_NAME as insuranceTypeName,
		a.INSURANCE_TYPE_ID as insuranceTypeId,
		a.BUY_STANDARD as buyStandard,
		a.MEDICAL_QUOTA as medicalQuota,
		a.DIE_DISABLE_QUOTA as dieDisableQuota,
		a.INSURANCE_COMPANY_NAME as insuranceCompanyName,
		a.SETTLE_TYPE as premiumType,
		a.ESTIMATE_PREMIUM as estimatePremium,
		a.ACTUAL_PREMIUM as actualPremium,
		a.INVOICE_NO as invoiceNo,
		a.SETTLE_TYPE as settleType,
		a.SETTLE_MONTH as settleMonth,
		a.BUY_HANDLE_STATUS as buyHandleStatus,
		a.REDUCE_HANDLE_STATUS as reduceHandleStatus,
		a.IS_USE as isUse,
		a.IS_EFFECT as isEffect,
		a.IS_OVERDUE as isOverdue,
		a.INSURANCE_PROVINCE_NAME as insuranceProvinceName,
		a.INSURANCE_PROVINCE as insuranceProvince,
		a.INSURANCE_CITY_NAME as insuranceCityName,
		a.INSURANCE_CITY as insuranceCity,
		a.INSURANCE_HANDLE_PROVINCE_NAME as insuranceHandleProvinceName,
		a.INSURANCE_HANDLE_PROVINCE as insuranceHandleProvince,
		a.INSURANCE_HANDLE_CITY_NAME as insuranceHandleCityName,
		a.INSURANCE_HANDLE_CITY as insuranceHandleCity,
		a.CREATE_NAME as createName,
		a.CREATE_TIME as createTime,
		a.REMARK as remark,
		a.BILLING_TYPE as billingType,
		a.DEFAULT_SETTLE_ID as defaultSettleId,
341 342
		a.RATE as  rate,
	    a.REFUND_ID as  refundId
huyuchen's avatar
huyuchen committed
343 344 345
		from t_insurance_detail a
		left join t_insurance_settle tis on a.DEFAULT_SETTLE_ID = tis.ID
		where a.ID = #{id}
李灿灿's avatar
李灿灿 committed
346
	</select>
347
	<!--导出办理勾选查询结果-->
李灿灿's avatar
李灿灿 committed
348
	<select id="getInsuranceExportListBySelect" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceExportListVO">
huyuchen's avatar
huyuchen committed
349 350
		select a.id as id,
		a.DEPT_NO as deptNo,
hongguangwu's avatar
hongguangwu committed
351
		a.DEPT_NAME as projectName,
huyuchen's avatar
huyuchen committed
352 353 354 355 356 357 358 359 360 361 362
		a.EMP_NAME as empName,
		a.EMP_IDCARD_NO as empIdcardNo,
		a.BUY_TYPE as buyType,
		a.BUY_HANDLE_STATUS as buyHandleStatus,
		a.POST as post,
		a.INSURANCE_PROVINCE_NAME as insuranceProvinceName,
		a.INSURANCE_CITY_NAME as insuranceCityName,
		a.INSURANCE_HANDLE_PROVINCE_NAME as insuranceHandleProvinceName,
		a.INSURANCE_HANDLE_CITY_NAME as insuranceHandleCityName,
		a.POLICY_START as policyStart,
		a.POLICY_END as policyEnd,
363
		a.POLICY_EFFECT as policyEffect,
huyuchen's avatar
huyuchen committed
364 365 366 367 368
		a.INSURANCE_COMPANY_NAME as insuranceCompanyName,
		a.INSURANCE_TYPE_NAME as insuranceTypeName,
		a.BUY_STANDARD as buyStandard,
		a.MEDICAL_QUOTA as medicalQuota,
		a.DIE_DISABLE_QUOTA as dieDisableQuota,
369
		a.ACTUAL_PREMIUM as actualPremium,
huyuchen's avatar
huyuchen committed
370 371 372 373 374 375 376
		a.SETTLE_MONTH as settleMonth,
		a.SETTLE_TYPE as settleType,
		a.CREATE_NAME as createName,
		a.POLICY_NO as policyNo,
		a.REMARK as remark
		from t_insurance_detail a
		where a.DELETE_FLAG = 0 and a.id in
李灿灿's avatar
李灿灿 committed
377 378 379
		<foreach collection="idList" index="index" item="item" open="(" separator="," close=")">
			#{item}
		</foreach>
huyuchen's avatar
huyuchen committed
380
		ORDER BY a.CREATE_TIME DESC
李灿灿's avatar
李灿灿 committed
381
	</select>
382
	<!--出办理非勾选查询结果-->
李灿灿's avatar
李灿灿 committed
383
	<select id="getInsuranceExportList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceExportListVO">
huyuchen's avatar
huyuchen committed
384 385
		select a.id as id,
			a.DEPT_NO as deptNo,
hongguangwu's avatar
hongguangwu committed
386
			a.DEPT_NAME as projectName,
huyuchen's avatar
huyuchen committed
387 388 389 390 391 392 393 394 395 396
			a.EMP_NAME as empName,
			a.EMP_IDCARD_NO as empIdcardNo,
			a.BUY_TYPE as buyType,
			a.POST as post,
			a.INSURANCE_PROVINCE_NAME as insuranceProvinceName,
			a.INSURANCE_CITY_NAME as insuranceCityName,
			a.INSURANCE_HANDLE_PROVINCE_NAME as insuranceHandleProvinceName,
			a.INSURANCE_HANDLE_CITY_NAME as insuranceHandleCityName,
			a.POLICY_START as policyStart,
			a.POLICY_END as policyEnd,
397
			a.POLICY_EFFECT as policyEffect,
huyuchen's avatar
huyuchen committed
398 399 400 401 402
			a.INSURANCE_COMPANY_NAME as insuranceCompanyName,
			a.INSURANCE_TYPE_NAME as insuranceTypeName,
			a.BUY_STANDARD as buyStandard,
			a.MEDICAL_QUOTA as medicalQuota,
			a.DIE_DISABLE_QUOTA as dieDisableQuota,
403
			a.ACTUAL_PREMIUM as actualPremium,
huyuchen's avatar
huyuchen committed
404 405 406 407 408 409
			a.SETTLE_MONTH as settleMonth,
			a.SETTLE_TYPE as settleType,
			a.CREATE_NAME as createName,
			a.POLICY_NO as policyNo,
			a.REMARK as remark
		from t_insurance_detail a
410
		where a.DELETE_FLAG = 0 and a.BUY_HANDLE_STATUS = #{param.buyHandleStatus}
411
		<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
412
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
413 414
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
415
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
416
		</if>
李灿灿's avatar
李灿灿 committed
417
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
huyuchen's avatar
huyuchen committed
418
			and a.DEPT_NO like concat('%',replace(replace(#{param.deptNo},'_','\_'),'%','\%'),'%')
李灿灿's avatar
李灿灿 committed
419
		</if>
420
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
huyuchen's avatar
huyuchen committed
421
			and a.INSURANCE_COMPANY_NAME like concat('%',replace(replace(#{param.insuranceCompanyName},'_','\_'),'%','\%'),'%')
422
		</if>
423
		<if test="param.buyType != null">
huyuchen's avatar
huyuchen committed
424
			and a.BUY_TYPE = #{param.buyType}
425 426
		</if>
		<if test="param.createName != null and param.createName.trim() != ''">
huyuchen's avatar
huyuchen committed
427
			and a.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
428 429
		</if>
		<if test="param.startDate != null and param.startDate.trim() != '' and param.endDate != null and param.endDate.trim() != ''">
huyuchen's avatar
huyuchen committed
430
			and a.CREATE_TIME <![CDATA[ >= ]]>  concat(#{param.startDate}, ' 00:00:00') and a.CREATE_TIME <![CDATA[ <= ]]> concat(#{param.endDate}, ' 23:59:59')
431
		</if>
432 433
		<if test="param.updateBy != null and param.updateBy.trim() != ''">
			and a.HANDLED_BY = #{param.updateBy}
434
		</if>
huyuchen's avatar
huyuchen committed
435 436 437
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
438 439
		<if test="param.buyStandardMin != null">
			AND a.BUY_STANDARD <![CDATA[ >= ]]> #{param.buyStandardMin}
440
		</if>
441
		<if test="param.buyStandardMax != null">
442 443
			AND a.BUY_STANDARD <![CDATA[ <= ]]> #{param.buyStandardMax}
		</if>
huyuchen's avatar
huyuchen committed
444
		ORDER BY a.CREATE_TIME DESC
445
	</select>
446
	<!--批量更新保单号-->
447 448 449 450 451
	<update id="updatePolicyNoBatch">
		<foreach collection="details" index="index" item="item" separator=";">
				update t_insurance_detail set POLICY_NO = #{item.policyNo} where ID = #{item.id}
		</foreach>
	</update>
452
	<!--批量更新发票号-->
453 454 455 456 457 458
	<update id="updateInvoiceNoBatch">
		<foreach collection="details" index="index" item="item" separator=";">
			update t_insurance_detail set INVOICE_NO = #{item.invoiceNo} where ID = #{item.id}
		</foreach>
	</update>

李灿灿's avatar
李灿灿 committed
459
	<!-- ***********************减员办理******************************** -->
460
	<!-- 已投保列表分页查询-->
李灿灿's avatar
李灿灿 committed
461
	<select id="getInsuredListPage" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuredListVo">
462
		select
huyuchen's avatar
huyuchen committed
463 464 465 466 467 468
			a.id as id,
			a.REDUCE_HANDLE_STATUS as reduceHandleStatus,
			a.EMP_NAME as empName,
			a.EMP_IDCARD_NO as empIdcardNo,
			a.BUY_TYPE as buyType,
			a.DEPT_NO as deptNo,
hongguangwu's avatar
hongguangwu committed
469
			a.DEPT_NAME as projectName,
huyuchen's avatar
huyuchen committed
470 471 472 473 474 475 476 477 478 479
			a.POST as post,
			a.POLICY_START as policyStart,
			a.POLICY_END as policyEnd,
			a.POLICY_EFFECT as policyEffect,
			a.IS_USE as isUse,
			a.IS_EFFECT as isEffect,
			a.IS_OVERDUE as isOverdue,
			a.INSURANCE_COMPANY_NAME as insuranceCompanyName,
			a.INSURANCE_TYPE_NAME as insuranceTypeName,
			a.CREATE_USER_DEPT_NAME as createUserDeptName,
hongguangwu's avatar
hongguangwu committed
480 481 482
			a.BUY_STANDARD as buyStandard,
			a.CREATE_TIME as createTime,
			a.CREATE_NAME as createName
483
		from
huyuchen's avatar
huyuchen committed
484
		     t_insurance_detail a
485
		where
huyuchen's avatar
huyuchen committed
486
			a.DELETE_FLAG = 0
487
		and
huyuchen's avatar
huyuchen committed
488
			a.BUY_HANDLE_STATUS = 3
hongguangwu's avatar
hongguangwu committed
489 490 491 492 493 494 495 496 497
		<if test="param.createName != null and param.createName.trim() != ''">
			and a.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.buyType != null">
			and a.BUY_TYPE = #{param.buyType}
		</if>
		<if test="param.reduceHandleStatus != null">
			and a.REDUCE_HANDLE_STATUS = #{param.reduceHandleStatus}
		</if>
498
		<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
499
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
500 501
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
502
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
503 504
		</if>
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
huyuchen's avatar
huyuchen committed
505
			and a.DEPT_NO = #{param.deptNo}
506 507
		</if>
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
huyuchen's avatar
huyuchen committed
508
			and a.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
509 510
		</if>
		<if test="param.policyNo != null and param.policyNo.trim() != ''">
huyuchen's avatar
huyuchen committed
511
			and a.POLICY_NO like concat('%',replace(replace(#{param.policyNo},'_','\_'),'%','\%'),'%')
512
		</if>
513
		<if test="param.policyStart != null and param.policyStart.trim() != '' and (param.policyEnd == null or param.policyEnd.trim() == '')">
huyuchen's avatar
huyuchen committed
514
			AND a.POLICY_END   <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00')
515
		</if>
516
		<if test="param.policyEnd != null and param.policyEnd.trim() != '' and (param.policyStart == null or param.policyStart.trim() == '')">
huyuchen's avatar
huyuchen committed
517
			AND a.POLICY_START <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59')
518 519 520
		</if>
		<if test="param.policyStart != null and param.policyStart.trim() != '' and param.policyEnd != null and param.policyEnd.trim() != ''">
			and (
huyuchen's avatar
huyuchen committed
521 522 523
			(a.POLICY_START <![CDATA[ <= ]]>  concat(#{param.policyStart}, ' 00:00:00') and a.POLICY_END <![CDATA[ >= ]]> concat(#{param.policyEnd}, ' 23:59:59')) OR
			(a.POLICY_START <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00') and a.POLICY_START <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59')) OR
			(a.POLICY_END <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00') and a.POLICY_END <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59'))
524
				)
525 526
		</if>
		<if test="param.invoiceNo != null and param.invoiceNo.trim() != ''">
huyuchen's avatar
huyuchen committed
527
			and a.INVOICE_NO like concat('%',replace(replace(#{param.invoiceNo},'_','\_'),'%','\%'),'%')
528 529
		</if>
		<if test="param.isUse != null">
huyuchen's avatar
huyuchen committed
530
			and a.IS_USE = #{param.isUse}
531
		</if>
532
		<if test="param.isOverdue != null">
huyuchen's avatar
huyuchen committed
533
			and a.IS_OVERDUE = #{param.isOverdue}
534
		</if>
535
		<if test="param.createStartTime != null and param.createStartTime.trim() != ''">
huyuchen's avatar
huyuchen committed
536
			AND a.CREATE_TIME  <![CDATA[ >= ]]>  concat(#{param.createStartTime}, ' 00:00:00')
537 538
		</if>
		<if test="param.createEndTime != null and param.createEndTime.trim() != ''">
huyuchen's avatar
huyuchen committed
539
			AND a.CREATE_TIME  <![CDATA[ <= ]]> concat(#{param.createEndTime}, ' 23:59:59')
540
		</if>
huyuchen's avatar
huyuchen committed
541 542 543
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
huyuchen's avatar
huyuchen committed
544
		ORDER BY a.CREATE_TIME DESC ,a.ID ASC
545
	</select>
546
	<!-- 已投保列表不分页查询-->
547 548
	<select id="getInsuredList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuredListVo">
		select
huyuchen's avatar
huyuchen committed
549 550 551 552 553
			a.id as id,
			a.EMP_NAME as empName,
			a.EMP_IDCARD_NO as empIdcardNo,
			a.BUY_TYPE as buyType,
			a.DEPT_NO as deptNo,
hongguangwu's avatar
hongguangwu committed
554
			a.DEPT_NAME as projectName,
huyuchen's avatar
huyuchen committed
555 556 557 558 559 560 561 562 563 564 565 566 567 568
			a.POST as post,
			a.POLICY_START as policyStart,
			a.POLICY_END as policyEnd,
			a.INSURANCE_COMPANY_NAME as insuranceCompanyName,
			a.INSURANCE_TYPE_NAME as insuranceTypeName,
			a.BUY_STANDARD as buyStandard,
			a.MEDICAL_QUOTA as medicalQuota,
			a.DIE_DISABLE_QUOTA as dieDisableQuota,
			a.ESTIMATE_PREMIUM as estimatePremium,
			a.ACTUAL_PREMIUM as actualPremium,
			a.POLICY_NO as policyNo,
			a.INVOICE_NO as invoiceNo,
			a.POLICY_EFFECT as policyEffect,
			a.INSURANCE_PROVINCE_NAME as insuranceProvinceName,
569
			CONCAT(a.INSURANCE_PROVINCE_NAME,'/',a.INSURANCE_CITY_NAME) as insuranceCityName,
huyuchen's avatar
huyuchen committed
570
			a.INSURANCE_HANDLE_PROVINCE_NAME as insuranceHandleProvinceName,
571
			CONCAT(a.INSURANCE_HANDLE_PROVINCE_NAME,'/',a.INSURANCE_HANDLE_CITY_NAME) as insuranceHandleCityName,
huyuchen's avatar
huyuchen committed
572 573 574 575 576
			a.IS_USE as isUse,
			a.IS_EFFECT as isEffect,
			a.IS_OVERDUE as isOverdue,
			a.CREATE_TIME as createTime,
			a.CREATE_NAME as createName
577
		from
huyuchen's avatar
huyuchen committed
578
		    t_insurance_detail a
579
		where
huyuchen's avatar
huyuchen committed
580
		    a.DELETE_FLAG = 0
581
		and
huyuchen's avatar
huyuchen committed
582
			a.BUY_HANDLE_STATUS = 3
hongguangwu's avatar
hongguangwu committed
583 584
		<if test="param.createName != null and param.createName.trim() != ''">
			and a.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606
		</if>
		<if test="param.buyType != null">
			and a.BUY_TYPE = #{param.buyType}
		</if>
		<if test="param.reduceHandleStatus != null">
			and a.REDUCE_HANDLE_STATUS = #{param.reduceHandleStatus}
		</if>
		<if test="param.empName != null and param.empName.trim() != ''">
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
			and a.DEPT_NO = #{param.deptNo}
		</if>
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
			and a.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
		</if>
		<if test="param.policyNo != null and param.policyNo.trim() != ''">
			and a.POLICY_NO like concat('%',replace(replace(#{param.policyNo},'_','\_'),'%','\%'),'%')
		</if>
607
		<if test="param.policyStart != null and param.policyStart.trim() != '' and (param.policyEnd == null or param.policyEnd.trim() == '')">
608 609
			AND a.POLICY_END   <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00')
		</if>
610
		<if test="param.policyEnd != null and param.policyEnd.trim() != '' and (param.policyStart == null or param.policyStart.trim() == '')">
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655
			AND a.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 (
			(a.POLICY_START <![CDATA[ <= ]]>  concat(#{param.policyStart}, ' 00:00:00') and a.POLICY_END <![CDATA[ >= ]]> concat(#{param.policyEnd}, ' 23:59:59')) OR
			(a.POLICY_START <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00') and a.POLICY_START <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59')) OR
			(a.POLICY_END <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00') and a.POLICY_END <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59'))
			)
		</if>
		<if test="param.createStartTime != null and param.createStartTime.trim() != ''">
			AND a.CREATE_TIME  <![CDATA[ >= ]]>  concat(#{param.createStartTime}, ' 00:00:00')
		</if>
		<if test="param.createEndTime != null and param.createEndTime.trim() != ''">
			AND a.CREATE_TIME  <![CDATA[ <= ]]> concat(#{param.createEndTime}, ' 23:59:59')
		</if>
		<if test="param.invoiceNo != null and param.invoiceNo.trim() != ''">
			and a.INVOICE_NO like concat('%',replace(replace(#{param.invoiceNo},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.isUse != null">
			and a.IS_USE = #{param.isUse}
		</if>
		<if test="param.isOverdue != null ">
			and a.IS_OVERDUE = #{param.isOverdue}
		</if>
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
		ORDER BY a.CREATE_TIME DESC
		<if test="param != null">
			<if test="param.limitStart != null">
				limit #{param.limitStart},#{param.limitEnd}
			</if>
		</if>
	</select>
	<select id="getInsuredListCount" resultType="java.lang.Long">
		select
		count(1)
		from
		t_insurance_detail a
		where
		a.DELETE_FLAG = 0
		and
		a.BUY_HANDLE_STATUS = 3
		<if test="param.createName != null and param.createName.trim() != ''">
			and a.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
hongguangwu's avatar
hongguangwu committed
656 657 658 659 660 661 662
		</if>
		<if test="param.buyType != null">
			and a.BUY_TYPE = #{param.buyType}
		</if>
		<if test="param.reduceHandleStatus != null">
			and a.REDUCE_HANDLE_STATUS = #{param.reduceHandleStatus}
		</if>
663
		<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
664
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
665 666
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
667
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
668 669
		</if>
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
huyuchen's avatar
huyuchen committed
670
			and a.DEPT_NO = #{param.deptNo}
671 672
		</if>
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
huyuchen's avatar
huyuchen committed
673
			and a.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
674 675
		</if>
		<if test="param.policyNo != null and param.policyNo.trim() != ''">
huyuchen's avatar
huyuchen committed
676
			and a.POLICY_NO like concat('%',replace(replace(#{param.policyNo},'_','\_'),'%','\%'),'%')
677
		</if>
678
		<if test="param.policyStart != null and param.policyStart.trim() != '' and (param.policyEnd == null or param.policyEnd.trim() == '')">
huyuchen's avatar
huyuchen committed
679
			AND a.POLICY_END   <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00')
680
		</if>
681
		<if test="param.policyEnd != null and param.policyEnd.trim() != '' and (param.policyStart == null or param.policyStart.trim() == '')">
huyuchen's avatar
huyuchen committed
682
			AND a.POLICY_START <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59')
683
		</if>
684 685
		<if test="param.policyStart != null and param.policyStart.trim() != '' and param.policyEnd != null and param.policyEnd.trim() != ''">
			and (
huyuchen's avatar
huyuchen committed
686 687 688
			(a.POLICY_START <![CDATA[ <= ]]>  concat(#{param.policyStart}, ' 00:00:00') and a.POLICY_END <![CDATA[ >= ]]> concat(#{param.policyEnd}, ' 23:59:59')) OR
			(a.POLICY_START <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00') and a.POLICY_START <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59')) OR
			(a.POLICY_END <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00') and a.POLICY_END <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59'))
689
			)
690
		</if>
hongguangwu's avatar
hongguangwu committed
691 692 693 694 695 696
		<if test="param.createStartTime != null and param.createStartTime.trim() != ''">
			AND a.CREATE_TIME  <![CDATA[ >= ]]>  concat(#{param.createStartTime}, ' 00:00:00')
		</if>
		<if test="param.createEndTime != null and param.createEndTime.trim() != ''">
			AND a.CREATE_TIME  <![CDATA[ <= ]]> concat(#{param.createEndTime}, ' 23:59:59')
		</if>
697
		<if test="param.invoiceNo != null and param.invoiceNo.trim() != ''">
huyuchen's avatar
huyuchen committed
698
			and a.INVOICE_NO like concat('%',replace(replace(#{param.invoiceNo},'_','\_'),'%','\%'),'%')
699 700
		</if>
		<if test="param.isUse != null">
huyuchen's avatar
huyuchen committed
701
			and a.IS_USE = #{param.isUse}
702
		</if>
703
		<if test="param.isOverdue != null ">
huyuchen's avatar
huyuchen committed
704
			and a.IS_OVERDUE = #{param.isOverdue}
705
		</if>
huyuchen's avatar
huyuchen committed
706 707 708
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
huyuchen's avatar
huyuchen committed
709
		ORDER BY a.CREATE_TIME DESC
710
	</select>
711
	<!-- 已减员列表分页查询-->
712 713
	<select id="getInsuranceRefundPageList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceRefundListVo">
		select
huyuchen's avatar
huyuchen committed
714 715 716 717 718
		    a.id as id,
			a.EMP_NAME as empName,
			a.EMP_IDCARD_NO as empIdcardNo,
			a.POST as post,
			a.DEPT_NO as deptNo,
hongguangwu's avatar
hongguangwu committed
719
			a.DEPT_NAME as projectName,
huyuchen's avatar
huyuchen committed
720
			a.INSURANCE_COMPANY_NAME as insuranceCompanyName,
721 722
		    a.INSURANCE_TYPE_NAME as insuranceTypeName,
		    a.BUY_STANDARD as buyStandard,
huyuchen's avatar
huyuchen committed
723 724 725
			a.POLICY_START as policyStart,
			a.POLICY_END as policyEnd,
			a.POLICY_NO as policyNo,
hongguangwu's avatar
hongguangwu committed
726
			a.CREATE_NAME as createName,
727
			a.BUY_TYPE as buyType,
728
			refund.CREATE_USER_DEPT_NAME as createUserDeptName,
hongguangwu's avatar
hongguangwu committed
729 730
			refund.CREATE_TIME as refundCreateTime,
			a.CREATE_TIME as createTime
731
		from
huyuchen's avatar
huyuchen committed
732 733
			t_insurance_detail a,
			t_insurance_refund refund
734
		where
huyuchen's avatar
huyuchen committed
735
		    a.DELETE_FLAG = 0
736
		and
huyuchen's avatar
huyuchen committed
737
			a.REFUND_ID = refund.ID
738
		and
huyuchen's avatar
huyuchen committed
739
			a.REDUCE_HANDLE_STATUS = 4
hongguangwu's avatar
hongguangwu committed
740 741 742
		<if test="param.createName != null and param.createName.trim() != ''">
			and a.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
		</if>
743
		<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
744
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
745 746
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
747
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
748 749
		</if>
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
huyuchen's avatar
huyuchen committed
750
			and a.DEPT_NO = #{param.deptNo}
751 752
		</if>
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
huyuchen's avatar
huyuchen committed
753
			and a.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
754 755
		</if>
		<if test="param.policyNo != null and param.policyNo.trim() != ''">
huyuchen's avatar
huyuchen committed
756
			and a.POLICY_NO like concat('%',replace(replace(#{param.policyNo},'_','\_'),'%','\%'),'%')
757
		</if>
758
		<if test="param.policyStart != null and param.policyStart.trim() != '' and ( param.policyEnd == null or param.policyEnd.trim() == '' )">
huyuchen's avatar
huyuchen committed
759
			AND a.POLICY_END   <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00')
760
		</if>
761
		<if test="param.policyEnd != null and param.policyEnd.trim() != '' and (param.policyStart == null or param.policyStart.trim() == '')">
huyuchen's avatar
huyuchen committed
762
			AND a.POLICY_START <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59')
763 764 765
		</if>
		<if test="param.policyStart != null and param.policyStart.trim() != '' and param.policyEnd != null and param.policyEnd.trim() != ''">
			and (
huyuchen's avatar
huyuchen committed
766 767 768
			(a.POLICY_START <![CDATA[ <= ]]>  concat(#{param.policyStart}, ' 00:00:00') and a.POLICY_END <![CDATA[ >= ]]> concat(#{param.policyEnd}, ' 23:59:59')) OR
			(a.POLICY_START <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00') and a.POLICY_START <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59')) OR
			(a.POLICY_END <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00') and a.POLICY_END <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59'))
769
			)
770
		</if>
hongguangwu's avatar
hongguangwu committed
771 772 773 774 775 776
		<if test="param.startDate != null and param.startDate.trim() != ''">
			AND a.CREATE_TIME  <![CDATA[ >= ]]>  concat(#{param.startDate}, ' 00:00:00')
		</if>
		<if test="param.endDate != null and param.endDate.trim() != ''">
			AND a.CREATE_TIME  <![CDATA[ <= ]]> concat(#{param.endDate}, ' 23:59:59')
		</if>
huyuchen's avatar
huyuchen committed
777 778 779
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
huyuchen's avatar
huyuchen committed
780
		ORDER BY refund.CREATE_TIME DESC,a.ID ASC
781
	</select>
782
	<!-- 已减员列表不分页查询-->
783 784
	<select id="getInsuranceRefundList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceRefundListVo">
		select
huyuchen's avatar
huyuchen committed
785 786
			a.id as id,
			a.DEPT_NO as deptNo,
hongguangwu's avatar
hongguangwu committed
787
			a.DEPT_NAME as projectName,
huyuchen's avatar
huyuchen committed
788 789 790 791 792 793 794 795 796 797
			a.EMP_NAME as empName,
			a.EMP_IDCARD_NO as empIdcardNo,
			a.BUY_TYPE as buyType,
			a.POST as post,
			a.INSURANCE_PROVINCE_NAME as insuranceProvinceName,
			a.INSURANCE_CITY_NAME as insuranceCityName,
			a.INSURANCE_HANDLE_PROVINCE_NAME as insuranceHandleProvinceName,
			a.INSURANCE_HANDLE_CITY_NAME as insuranceHandleCityName,
			a.POLICY_START as policyStart,
			a.POLICY_END as policyEnd,
798 799
		    a.POLICY_NO as policyNo,
		    a.ACTUAL_PREMIUM as actualPremium,
huyuchen's avatar
huyuchen committed
800 801 802 803 804
			a.INSURANCE_COMPANY_NAME as insuranceCompanyName,
			a.INSURANCE_TYPE_NAME as insuranceTypeName,
			a.BUY_STANDARD as buyStandard,
			a.MEDICAL_QUOTA as medicalQuota,
			a.DIE_DISABLE_QUOTA as dieDisableQuota,
hongguangwu's avatar
hongguangwu committed
805
			a.CREATE_NAME as createName,
806
			refund.CREATE_TIME as refundCreateTime
807
		from
huyuchen's avatar
huyuchen committed
808 809
			t_insurance_detail a,
			t_insurance_refund refund
810
		where
huyuchen's avatar
huyuchen committed
811
			a.REFUND_ID = refund.ID
812
		and
huyuchen's avatar
huyuchen committed
813
			a.DELETE_FLAG = 0
814
		and
huyuchen's avatar
huyuchen committed
815
			a.REDUCE_HANDLE_STATUS = 4
hongguangwu's avatar
hongguangwu committed
816 817 818
		<if test="param.createName != null and param.createName.trim() != ''">
			and a.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
		</if>
819
		<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
820
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
821 822
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
823
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
824 825
		</if>
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
huyuchen's avatar
huyuchen committed
826
			and a.DEPT_NO = #{param.deptNo}
827 828
		</if>
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
huyuchen's avatar
huyuchen committed
829
			and a.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
830 831
		</if>
		<if test="param.policyNo != null and param.policyNo.trim() != ''">
huyuchen's avatar
huyuchen committed
832
			and a.POLICY_NO like concat('%',replace(replace(#{param.policyNo},'_','\_'),'%','\%'),'%')
833
		</if>
834
		<if test="param.policyStart != null and param.policyStart.trim() != '' and (param.policyEnd == null or param.policyEnd.trim() == '')">
huyuchen's avatar
huyuchen committed
835
			AND a.POLICY_END   <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00')
836
		</if>
837
		<if test="param.policyEnd != null and param.policyEnd.trim() != '' and (param.policyStart == null or param.policyStart.trim() == '')">
huyuchen's avatar
huyuchen committed
838
			AND a.POLICY_START <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59')
839
		</if>
840 841
		<if test="param.policyStart != null and param.policyStart.trim() != '' and param.policyEnd != null and param.policyEnd.trim() != ''">
			and (
huyuchen's avatar
huyuchen committed
842 843 844
			(a.POLICY_START <![CDATA[ <= ]]>  concat(#{param.policyStart}, ' 00:00:00') and a.POLICY_END <![CDATA[ >= ]]> concat(#{param.policyEnd}, ' 23:59:59')) OR
			(a.POLICY_START <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00') and a.POLICY_START <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59')) OR
			(a.POLICY_END <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00') and a.POLICY_END <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59'))
845
			)
846
		</if>
hongguangwu's avatar
hongguangwu committed
847 848 849 850 851 852
		<if test="param.startDate != null and param.startDate.trim() != ''">
			AND a.CREATE_TIME  <![CDATA[ >= ]]>  concat(#{param.startDate}, ' 00:00:00')
		</if>
		<if test="param.endDate != null and param.endDate.trim() != ''">
			AND a.CREATE_TIME  <![CDATA[ <= ]]> concat(#{param.endDate}, ' 23:59:59')
		</if>
huyuchen's avatar
huyuchen committed
853 854 855
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
856
		ORDER BY refund.CREATE_TIME DESC
857
	</select>
858 859
	<!-- 减员办理列表分页查询-->
	<select id="getInsuranceRefundHandlingPageList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.RefundExportListVo">
李灿灿's avatar
李灿灿 committed
860
		select
861
		DISTINCT
huyuchen's avatar
huyuchen committed
862 863 864 865 866
		a.id as id,
		a.EMP_NAME as empName,
		a.EMP_IDCARD_NO as empIdcardNo,
		a.BUY_TYPE as buyType,
		a.DEPT_NO as deptNo,
hongguangwu's avatar
hongguangwu committed
867
		a.DEPT_NAME as projectName,
huyuchen's avatar
huyuchen committed
868 869 870 871 872 873 874 875 876 877 878 879
		a.POST as post,
		a.INSURANCE_PROVINCE_NAME as insuranceProvinceName,
		a.INSURANCE_CITY_NAME as insuranceCityName,
		a.INSURANCE_HANDLE_PROVINCE_NAME as insuranceHandleProvinceName,
		a.INSURANCE_HANDLE_CITY_NAME as insuranceHandleCityName,
		a.POLICY_START as policyStart,
		a.POLICY_END as policyEnd,
		a.INSURANCE_COMPANY_NAME as insuranceCompanyName,
		a.INSURANCE_TYPE_NAME as insuranceTypeName,
		a.BUY_STANDARD as buyStandard,
		a.MEDICAL_QUOTA as medicalQuota,
		a.DIE_DISABLE_QUOTA as dieDisableQuota,
880
		refund.CREATE_TIME as createTime,
881
		refund.CREATE_NAME as createName,
huyuchen's avatar
huyuchen committed
882
		a.REDUCE_HANDLE_STATUS as reduceHandleStatus
883
		from
huyuchen's avatar
huyuchen committed
884
			t_insurance_detail a,
885
			t_insurance_refund refund
886
		where
huyuchen's avatar
huyuchen committed
887
			a.REFUND_ID = refund.ID
888
		<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
889
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
890 891
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
892
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
893
		</if>
894
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
huyuchen's avatar
huyuchen committed
895
			and a.DEPT_NO = #{param.deptNo}
896
		</if>
897
		<if test="param.reduceHandleStatus != null">
huyuchen's avatar
huyuchen committed
898
			and a.REDUCE_HANDLE_STATUS = #{param.reduceHandleStatus}
899
		</if>
900
		<if test="param.insuranceTypeName != null and param.insuranceTypeName.trim() != ''">
huyuchen's avatar
huyuchen committed
901
			and a.INSURANCE_TYPE_NAME like concat('%',replace(replace(#{param.insuranceTypeName},'_','\_'),'%','\%'),'%')
902
		</if>
903
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
huyuchen's avatar
huyuchen committed
904
			and a.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
905
		</if>
906 907
		<if test="param.updateBy != null and param.updateBy.trim() != ''">
			and  refund.UPDATE_BY = #{param.updateBy}
908
		</if>
909 910 911
		<if test="param.createName != null and param.createName.trim() != ''">
			and refund.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
		</if>
912
		<if test="param.startDate != null and param.startDate.trim() != ''">
913
			AND refund.CREATE_TIME   <![CDATA[ >= ]]>  concat(#{param.startDate}, ' 00:00:00')
914
		</if>
915
		<if test="param.endDate != null and param.endDate.trim() != ''">
916
			AND refund.CREATE_TIME <![CDATA[ <= ]]> concat(#{param.endDate}, ' 23:59:59')
917
		</if>
918 919
		<if test="param.buyStandardMin != null and param.buyStandardMin.trim() != ''">
			AND a.BUY_STANDARD   <![CDATA[ >= ]]>  #{param.buyStandardMin}
920
		</if>
921 922
		<if test="param.buyStandardMax != null and param.buyStandardMax.trim() != ''">
			AND a.BUY_STANDARD <![CDATA[ <= ]]> #{param.buyStandardMax}
923
		</if>
huyuchen's avatar
huyuchen committed
924 925 926
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
huyuchen's avatar
huyuchen committed
927
		ORDER BY refund.CREATE_TIME DESC,a.ID ASC
李灿灿's avatar
李灿灿 committed
928
	</select>
929
	<!-- 查询保单列表-->
930 931 932 933 934 935 936 937 938 939 940 941
	<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>
942

943
	<!-- 查询保单减员退费信息-->
944
	<select id="selectRefundDetailId" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceRefundVo">
945
		select
946
			refund.ID as id,
947
			refund.INS_DETAIL_ID as insDetailId,
948 949 950
			refund.REFUND_MONEY as refundMoney,
		    a.INSURANCE_HANDLE_PROVINCE as insuranceHandleProvince,
		    a.INSURANCE_HANDLE_CITY as insuranceHandleCity
951
		from
huyuchen's avatar
huyuchen committed
952
			t_insurance_detail a,
953 954
			t_insurance_refund refund
		where
955 956 957 958
	  		a.DELETE_FLAG = 0
			and a.REFUND_ID = refund.ID
			and a.BUY_HANDLE_STATUS = 5
			and a.REDUCE_HANDLE_STATUS = 4
huyuchen's avatar
huyuchen committed
959 960
			and a.EMP_NAME = #{param.empName}
			and a.EMP_IDCARD_NO = #{param.empIdcardNo}
961 962 963 964 965 966
			and a.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
			and a.INSURANCE_TYPE_NAME = #{param.insuranceTypeName}
			and a.POLICY_START = #{param.policyStart}
			and a.POLICY_END = #{param.policyEnd}
			and a.BUY_STANDARD = #{param.buyStandard}
		order by
967
			a.CREATE_TIME DESC
968
		limit 1;
969
	</select>
970
	<!-- 根据ID导出减员办理列表-->
971 972
	<select id="getRefundExportListBySelect" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.RefundExportListVo">
		select
huyuchen's avatar
huyuchen committed
973 974
			a.id as id,
			a.DEPT_NO as deptNo,
hongguangwu's avatar
hongguangwu committed
975
			a.DEPT_NAME as projectName,
huyuchen's avatar
huyuchen committed
976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992
			a.EMP_NAME as empName,
			a.EMP_IDCARD_NO as empIdcardNo,
			a.BUY_TYPE as buyType,
			a.POST as post,
			a.INSURANCE_PROVINCE_NAME as insuranceProvinceName,
			a.INSURANCE_CITY_NAME as insuranceCityName,
			a.INSURANCE_HANDLE_PROVINCE_NAME as insuranceHandleProvinceName,
			a.INSURANCE_HANDLE_CITY_NAME as insuranceHandleCityName,
			a.POLICY_START as policyStart,
			a.POLICY_END as policyEnd,
			a.INSURANCE_COMPANY_NAME as insuranceCompanyName,
			a.INSURANCE_TYPE_NAME as insuranceTypeName,
			a.BUY_STANDARD as buyStandard,
			a.MEDICAL_QUOTA as medicalQuota,
			a.DIE_DISABLE_QUOTA as dieDisableQuota,
			a.SETTLE_MONTH as settleMonth,
			a.SETTLE_TYPE as settleType,
huyuchen's avatar
huyuchen committed
993 994
			a.POLICY_NO as policyNo,
			refund.CREATE_NAME as createName,
huyuchen's avatar
huyuchen committed
995
			a.REDUCE_HANDLE_STATUS as reduceHandleStatus,
huyuchen's avatar
huyuchen committed
996
			refund.REMARK as remark
997
		from
huyuchen's avatar
huyuchen committed
998 999
		    t_insurance_detail a,
			t_insurance_refund refund
1000
		where
huyuchen's avatar
huyuchen committed
1001
			a.REFUND_ID = refund.ID AND
huyuchen's avatar
huyuchen committed
1002
		    a.id in
1003 1004 1005
		<foreach collection="idList" index="index" item="item" open="(" separator="," close=")">
			#{item}
		</foreach>
huyuchen's avatar
huyuchen committed
1006
		ORDER BY a.CREATE_TIME DESC
1007
	</select>
1008
	<!-- 根据查询参数导出减员办理列表-->
1009 1010
	<select id="getRefundExportList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.RefundExportListVo">
		select
huyuchen's avatar
huyuchen committed
1011 1012
		    a.id as id,
			a.DEPT_NO as deptNo,
hongguangwu's avatar
hongguangwu committed
1013
			a.DEPT_NAME as projectName,
huyuchen's avatar
huyuchen committed
1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030
			a.EMP_NAME as empName,
			a.EMP_IDCARD_NO as empIdcardNo,
			a.BUY_TYPE as buyType,
			a.POST as post,
			a.INSURANCE_PROVINCE_NAME as insuranceProvinceName,
			a.INSURANCE_CITY_NAME as insuranceCityName,
			a.INSURANCE_HANDLE_PROVINCE_NAME as insuranceHandleProvinceName,
			a.INSURANCE_HANDLE_CITY_NAME as insuranceHandleCityName,
			a.POLICY_START as policyStart,
			a.POLICY_END as policyEnd,
			a.INSURANCE_COMPANY_NAME as insuranceCompanyName,
			a.INSURANCE_TYPE_NAME as insuranceTypeName,
			a.BUY_STANDARD as buyStandard,
			a.MEDICAL_QUOTA as medicalQuota,
			a.DIE_DISABLE_QUOTA as dieDisableQuota,
			a.SETTLE_MONTH as settleMonth,
			a.SETTLE_TYPE as settleType,
huyuchen's avatar
huyuchen committed
1031 1032 1033
			refund.CREATE_NAME as createName,
			a.POLICY_NO as policyNo,
			refund.REMARK as remark
1034
		from
huyuchen's avatar
huyuchen committed
1035 1036
			t_insurance_detail a,
			t_insurance_refund refund
1037
		where
huyuchen's avatar
huyuchen committed
1038
			a.REFUND_ID = refund.ID and
1039
		    a.DELETE_FLAG = 0 and a.REDUCE_HANDLE_STATUS = #{param.reduceHandleStatus}
1040
		<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
1041
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
1042 1043
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
1044
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
1045 1046
		</if>
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
huyuchen's avatar
huyuchen committed
1047
			and a.DEPT_NO = #{param.deptNo}
1048
		</if>
1049
		<if test="param.insuranceTypeName != null and param.insuranceTypeName.trim() != ''">
huyuchen's avatar
huyuchen committed
1050
			and a.INSURANCE_TYPE_NAME like concat('%',replace(replace(#{param.insuranceTypeName},'_','\_'),'%','\%'),'%')
1051
		</if>
1052
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
huyuchen's avatar
huyuchen committed
1053
			and a.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
1054
		</if>
1055 1056
		<if test="param.buyStandardMin != null and param.buyStandardMin.trim() != ''">
			AND a.BUY_STANDARD   <![CDATA[ >= ]]>  #{param.buyStandardMin}
1057
		</if>
1058 1059
		<if test="param.buyStandardMax != null and param.buyStandardMax.trim() != ''">
			AND a.BUY_STANDARD <![CDATA[ <= ]]> #{param.buyStandardMax}
1060
		</if>
1061 1062
		<if test="param.updateBy != null and param.updateBy.trim() != ''">
			and  refund.UPDATE_BY = #{param.updateBy}
1063
		</if>
huyuchen's avatar
huyuchen committed
1064 1065
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
1066
		</if>
huyuchen's avatar
huyuchen committed
1067
		ORDER BY a.CREATE_TIME DESC
1068
	</select>
1069
	<!-- 减员办理-->
1070 1071
	<update id="updateInsuranceRefund">
		update
huyuchen's avatar
huyuchen committed
1072
			t_insurance_detail a
1073 1074 1075 1076 1077
		set
			UPDATE_BY = #{param.updateBy},
			REDUCE_HANDLE_STATUS = #{param.refundType},
			UPDATE_TIME = #{param.refundCreateTime}
		where
huyuchen's avatar
huyuchen committed
1078
		      a.ID in
1079 1080 1081 1082
		<foreach collection="param.idList" index="index" item="item" open="(" separator="," close=")">
			#{item}
		</foreach>
	</update>
1083
	<!--根据身份证查询商险信息-->
1084
	<select id="getInsuranceListByIdCard" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceListByIdCardVo">
huyuchen's avatar
huyuchen committed
1085 1086 1087 1088 1089 1090
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_insurance_detail
		<where>
			1=1
			AND EMP_IDCARD_NO = #{idCard}
1091
			and DEPT_NO = #{deptNo}
huyuchen's avatar
huyuchen committed
1092 1093 1094
		</where>
		ORDER BY CREATE_TIME desc
	</select>
1095
	<!--查询所有在保,未出险,未过期,未失效,未减员的保单信息-->
1096
    <select id="selectListByEmpIdcardNo" resultType="com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceDetail">
1097
		SELECT
1098 1099 1100
			<include refid="Base_Column_List"/>
		FROM
		  t_insurance_detail
1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111
		<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>
1112 1113
	<!--商险订单列表查询-->
	<select id="getOrderInsuredListPage" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuredOrderListVo">
1114 1115
		(
		select
huyuchen's avatar
huyuchen committed
1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131
			a.id as id,
			a.id as onlyId,
			a.BUY_TYPE as buyType,
			a.CREATE_BY as createBy,
			a.EMP_NAME as empName,
			a.EMP_IDCARD_NO as empIdcardNo,
			a.INSURANCE_COMPANY_NAME as insuranceCompanyName,
			a.INSURANCE_TYPE_NAME as insuranceTypeName,
			a.BUY_STANDARD as buyStandard,
			a.MEDICAL_QUOTA as medicalQuota,
			a.DIE_DISABLE_QUOTA as dieDisableQuota,
			a.CREATE_NAME as createName,
			a.CREATE_USER_DEPT_NAME as createUserDeptName,
			a.CREATE_TIME as createTime,
			a.BUY_HANDLE_STATUS as buyHandleStatus,
			a.REDUCE_HANDLE_STATUS as reduceHandleStatus
1132
		from
huyuchen's avatar
huyuchen committed
1133
			t_insurance_detail a
1134
		where
huyuchen's avatar
huyuchen committed
1135
			a.DELETE_FLAG = 0
1136
		and
huyuchen's avatar
huyuchen committed
1137
			a.ORDER_NO = #{param.orderNo}
1138
		<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
1139
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
1140 1141
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
1142
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
1143
		</if>
1144
		<if test="param.startDate != null ">
huyuchen's avatar
huyuchen committed
1145
			AND a.CREATE_TIME  <![CDATA[ >= ]]>  concat(#{param.startDate}, ' 00:00:00')
1146
		</if>
1147
		<if test="param.endDate != null ">
huyuchen's avatar
huyuchen committed
1148
			AND a.CREATE_TIME  <![CDATA[ <= ]]> concat(#{param.endDate}, ' 23:59:59')
1149
		</if>
huyuchen's avatar
huyuchen committed
1150 1151 1152
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
1153
		<if test="param.deptNoList != null">
huyuchen's avatar
huyuchen committed
1154
			and a.DEPT_NO in
1155 1156 1157 1158 1159 1160
			<foreach collection="param.deptNoList" index="index" item="item" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>)
		union all(
		select
huyuchen's avatar
huyuchen committed
1161
			a.id as id,
1162
			refund.id as onlyId,
1163
			refund.BUY_TYPE as buyType,
1164
			refund.CREATE_BY as createBy,
huyuchen's avatar
huyuchen committed
1165 1166 1167 1168 1169 1170 1171
			a.EMP_NAME as empName,
			a.EMP_IDCARD_NO as empIdcardNo,
			a.INSURANCE_COMPANY_NAME as insuranceCompanyName,
			a.INSURANCE_TYPE_NAME as insuranceTypeName,
			a.BUY_STANDARD as buyStandard,
			a.MEDICAL_QUOTA as medicalQuota,
			a.DIE_DISABLE_QUOTA as dieDisableQuota,
1172 1173 1174
			refund.CREATE_NAME as createName,
			refund.CREATE_USER_DEPT_NAME as createUserDeptName,
			refund.CREATE_TIME as createTime,
huyuchen's avatar
huyuchen committed
1175
			a.BUY_HANDLE_STATUS as buyHandleStatus,
1176 1177
			refund.REDUCE_HANDLE_STATUS as reduceHandleStatus
			from
huyuchen's avatar
huyuchen committed
1178
				t_insurance_detail a,
1179 1180
				t_insurance_refund refund
			where
huyuchen's avatar
huyuchen committed
1181
				a.DELETE_FLAG = 0
1182
			and
huyuchen's avatar
huyuchen committed
1183
			    a.ID = refund.INS_DETAIL_ID
1184 1185 1186
			and
				refund.ORDER_NO = #{param.orderNo}
			<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
1187
				and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
1188 1189
			</if>
			<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
1190
				and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
1191
			</if>
1192 1193
			<if test="param.startDate != null">
				AND refund.CREATE_TIME  <![CDATA[ >= ]]>  concat(#{param.startDate}, ' 00:00:00')
1194
			</if>
1195 1196
			<if test="param.endDate != null ">
				AND refund.CREATE_TIME  <![CDATA[ <= ]]> concat(#{param.endDate}, ' 23:59:59')
1197
			</if>
huyuchen's avatar
huyuchen committed
1198 1199 1200
			<if test="param.authSql != null and param.authSql.trim() != ''">
				${param.authSql}
			</if>
1201
			<if test="param.deptNoList != null">
huyuchen's avatar
huyuchen committed
1202
				and a.DEPT_NO in
1203 1204 1205 1206
				<foreach collection="param.deptNoList" index="index" item="item" open="(" separator="," close=")">
					#{item}
				</foreach>
			</if>
huyuchen's avatar
huyuchen committed
1207 1208
		)
		order by createTime desc
1209 1210
	</select>

1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226
	<!-- ekp费用划转-商险-->
	<update id="ekpUpdateInsuranceDept">
		update t_insurance_detail p
		set
		p.DEPT_ID = #{dept.id}
		,p.DEPT_NAME = #{dept.departName}
		,p.DEPT_NO = #{dept.departNo}
		,p.UNIT_ID = #{dept.customerId}
		,p.UNIT_NAME = #{dept.customerName}
		,p.UNIT_NO = #{dept.customerCode}
		where p.id in
		<foreach item="item" index="index" collection="idSet" open="(" separator="," close=")">
			#{item}
		</foreach>
	</update>

1227 1228 1229 1230 1231 1232 1233 1234

	<!--查询所有商险,如果idList 不为空,则不含被替换的本身。 用来改变档案状态-->
	<select id="selectByIdCardList" resultMap="BaseResultMap">
		SELECT
			<include refid="Base_Column_List"/>
		FROM
		t_insurance_detail
		where
1235 1236 1237
			DELETE_FLAG = 0
		<if test="idCardList != null and idCardList.size > 0">
			AND EMP_IDCARD_NO in
1238 1239 1240
			<foreach item="item" index="index" collection="idCardList" open="(" separator="," close=")">
				#{item}
			</foreach>
1241 1242
		</if>
			<if test="idList != null and idList.size > 0">
1243 1244 1245 1246 1247 1248 1249
				AND id not in
				<foreach item="item" index="index" collection="idList" open="(" separator="," close=")">
					#{item}
				</foreach>
			</if>
	</select>

huyuchen's avatar
huyuchen committed
1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263
	<select id="selectByIds" resultMap="UpdateMap">
		SELECT
		a.ID,
		a.INVOICE_NO,
		a.POLICY_NO
		FROM
		t_insurance_detail a
		where
		a.ID in
		<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
			#{item}
		</foreach>
	</select>

1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334

	<!--	退保退费分页查询-->
	<select id="getInsuranceRefundMoneyPageList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.RefundListVo">
		SELECT
			a.ID AS id,
			a.DEPT_NAME AS projectName,
			a.EMP_NAME AS empName,
			a.EMP_IDCARD_NO AS empIdcardNo,
			a.BUY_TYPE AS buyType,
			a.POLICY_START AS policyStart,
			a.POLICY_END AS policyEnd,
			a.INSURANCE_COMPANY_NAME AS insuranceCompanyName,
			a.INSURANCE_TYPE_NAME AS insuranceTypeName,
			a.BUY_STANDARD AS buyStandard,
			refund.REFUND_MONEY AS refundMoney,
			IF
				( a.BUY_TYPE = 4, `replace`.empName, a.EMP_NAME ) AS returnEmpName,
			IF
				( a.BUY_TYPE = 4, `replace`.empIdcardNo, a.EMP_IDCARD_NO ) AS returnEmpIdcardNo,
			IF
				( a.BUY_TYPE = 4, `replace`.projectName, a.DEPT_NAME ) AS returnProjectName
		FROM
			t_insurance_detail a
				LEFT JOIN t_insurance_refund refund ON a.REFUND_ID = refund.ID
				LEFT JOIN (
				SELECT
					`replace`.FROM_INSURANCE_DETAIL_ID AS fromDetailId,
					`replace`.TO_INSURANCE_DETAIL_ID AS toDetailId,
					`replace`.ORIGIN_INSURANCE_DETAIL_ID AS originDetailId,
					detail.DEPT_NAME AS projectName,
					detail.EMP_NAME AS empName,
					detail.EMP_IDCARD_NO AS empIdcardNo
				FROM
					t_insurance_replace `replace`
						LEFT JOIN t_insurance_detail detail ON `replace`.ORIGIN_INSURANCE_DETAIL_ID = detail.ID
			) `replace` ON a.ID = `replace`.toDetailId
				AND a.BUY_TYPE = 4
		WHERE
			a.DELETE_FLAG = 0
		  AND a.REDUCE_HANDLE_STATUS = 4
		  and refund.REFUND_MONEY IS NOT NULL
		<if test="param.empName != null and param.empName.trim() != ''">
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
			and a.DEPT_NO = #{param.deptNo}
		</if>
		<if test="param.reduceHandleStatus != null">
			and a.REDUCE_HANDLE_STATUS = #{param.reduceHandleStatus}
		</if>
		<if test="param.insuranceTypeName != null and param.insuranceTypeName.trim() != ''">
			and a.INSURANCE_TYPE_NAME like concat('%',replace(replace(#{param.insuranceTypeName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
			and a.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
		</if>
		<if test="param.updateBy != null and param.updateBy.trim() != ''">
			and  refund.UPDATE_BY = #{param.updateBy}
		</if>
		<if test="param.createName != null and param.createName.trim() != ''">
			and refund.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.startDate != null and param.startDate.trim() != ''">
			AND refund.CREATE_TIME   <![CDATA[ >= ]]>  concat(#{param.startDate}, ' 00:00:00')
		</if>
		<if test="param.endDate != null and param.endDate.trim() != ''">
			AND refund.CREATE_TIME <![CDATA[ <= ]]> concat(#{param.endDate}, ' 23:59:59')
		</if>
1335 1336 1337 1338 1339 1340
		<if test="param.buyStandardMin != null and param.buyStandardMin.trim() != ''">
			AND a.BUY_STANDARD   <![CDATA[ >= ]]>  #{param.buyStandardMin}
		</if>
		<if test="param.buyStandardMax != null and param.buyStandardMax.trim() != ''">
			AND a.BUY_STANDARD <![CDATA[ <= ]]> #{param.buyStandardMax}
		</if>
1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
		ORDER BY refund.CREATE_TIME DESC,a.ID ASC
	</select>

	<select id="getInsuranceRefundMoneyList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.RefundListVo">
		SELECT
		a.ID AS id,
		a.DEPT_NAME AS projectName,
		a.EMP_NAME AS empName,
		a.EMP_IDCARD_NO AS empIdcardNo,
		a.BUY_TYPE AS buyType,
		a.POLICY_START AS policyStart,
		a.POLICY_END AS policyEnd,
		a.INSURANCE_COMPANY_NAME AS insuranceCompanyName,
		a.INSURANCE_TYPE_NAME AS insuranceTypeName,
		a.BUY_STANDARD AS buyStandard,
		refund.REFUND_MONEY AS refundMoney,
		IF
		( a.BUY_TYPE = 4, `replace`.empName, a.EMP_NAME ) AS returnEmpName,
		IF
		( a.BUY_TYPE = 4, `replace`.empIdcardNo, a.EMP_IDCARD_NO ) AS returnEmpIdcardNo,
		IF
		( a.BUY_TYPE = 4, `replace`.projectName, a.DEPT_NAME ) AS returnProjectName
		FROM
		t_insurance_detail a
		LEFT JOIN t_insurance_refund refund ON a.REFUND_ID = refund.ID
		LEFT JOIN (
		SELECT
		`replace`.FROM_INSURANCE_DETAIL_ID AS fromDetailId,
		`replace`.TO_INSURANCE_DETAIL_ID AS toDetailId,
		`replace`.ORIGIN_INSURANCE_DETAIL_ID AS originDetailId,
		detail.DEPT_NAME AS projectName,
		detail.EMP_NAME AS empName,
		detail.EMP_IDCARD_NO AS empIdcardNo
		FROM
		t_insurance_replace `replace`
		LEFT JOIN t_insurance_detail detail ON `replace`.ORIGIN_INSURANCE_DETAIL_ID = detail.ID
		) `replace` ON a.ID = `replace`.toDetailId
		AND a.BUY_TYPE = 4
		WHERE
		a.DELETE_FLAG = 0
		AND a.REDUCE_HANDLE_STATUS = 4
		and refund.REFUND_MONEY IS NOT NULL
		<if test="param.empName != null and param.empName.trim() != ''">
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
			and a.DEPT_NO = #{param.deptNo}
		</if>
		<if test="param.reduceHandleStatus != null">
			and a.REDUCE_HANDLE_STATUS = #{param.reduceHandleStatus}
		</if>
		<if test="param.insuranceTypeName != null and param.insuranceTypeName.trim() != ''">
			and a.INSURANCE_TYPE_NAME like concat('%',replace(replace(#{param.insuranceTypeName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
			and a.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
		</if>
		<if test="param.updateBy != null and param.updateBy.trim() != ''">
			and  refund.UPDATE_BY = #{param.updateBy}
		</if>
		<if test="param.createName != null and param.createName.trim() != ''">
			and refund.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.startDate != null and param.startDate.trim() != ''">
			AND refund.CREATE_TIME   <![CDATA[ >= ]]>  concat(#{param.startDate}, ' 00:00:00')
		</if>
		<if test="param.endDate != null and param.endDate.trim() != ''">
			AND refund.CREATE_TIME <![CDATA[ <= ]]> concat(#{param.endDate}, ' 23:59:59')
		</if>
1416 1417 1418 1419 1420 1421
		<if test="param.buyStandardMin != null and param.buyStandardMin.trim() != ''">
			AND a.BUY_STANDARD   <![CDATA[ >= ]]>  #{param.buyStandardMin}
		</if>
		<if test="param.buyStandardMax != null and param.buyStandardMax.trim() != ''">
			AND a.BUY_STANDARD <![CDATA[ <= ]]> #{param.buyStandardMax}
		</if>
1422 1423 1424 1425 1426
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
		ORDER BY refund.CREATE_TIME DESC,a.ID ASC
	</select>
1427
</mapper>