TInsuranceDetailMapper.xml 81.2 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
		a.REDUCE_HANDLE_STATUS as reduceHandleStatus,
117 118
		a.CREATE_TIME as createTime,
		a.UNIT_NAME as unitName,
119 120
		a.UNIT_NO as unitNo,
		a.IS_EFFECT as isEffect
huyuchen's avatar
huyuchen committed
121 122
		from t_insurance_detail a
		where a.DELETE_FLAG = 0
123 124 125
		<if test="param.isEffect != null">
			and a.IS_EFFECT = #{param.isEffect}
		</if>
126 127 128 129 130 131
		<if test="param.unitName != null and param.unitName.trim() != ''">
			and a.UNIT_NAME like concat(replace(replace(#{param.unitName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.unitNo != null and param.unitNo.trim() != ''">
			and a.UNIT_NO like concat(replace(replace(#{param.unitNo},'_','\_'),'%','\%'),'%')
		</if>
李灿灿's avatar
李灿灿 committed
132
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
huyuchen's avatar
huyuchen committed
133
			and a.DEPT_NO = #{param.deptNo}
134
		</if>
135
		<if test="param.orderNo != null and param.orderNo.trim() != ''">
hongguangwu's avatar
hongguangwu committed
136
			and a.ORDER_NO = #{param.orderNo}
137
		</if>
李灿灿's avatar
李灿灿 committed
138
		<if test="param.buyHandleStatus != null">
huyuchen's avatar
huyuchen committed
139
			and a.BUY_HANDLE_STATUS = #{param.buyHandleStatus}
李灿灿's avatar
李灿灿 committed
140 141
		</if>
		<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
142
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
李灿灿's avatar
李灿灿 committed
143 144
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
145
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
李灿灿's avatar
李灿灿 committed
146 147
		</if>
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
huyuchen's avatar
huyuchen committed
148
			and a.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
李灿灿's avatar
李灿灿 committed
149
		</if>
150
		<if test="param.insuranceTypeName != null and param.insuranceTypeName.trim() != ''">
huyuchen's avatar
huyuchen committed
151
			and a.INSURANCE_TYPE_NAME like concat('%',replace(replace(#{param.insuranceTypeName},'_','\_'),'%','\%'),'%')
152
		</if>
李灿灿's avatar
李灿灿 committed
153
		<if test="param.buyHandleStatusList != null and param.buyHandleStatusList.size > 0">
huyuchen's avatar
huyuchen committed
154
			and a.BUY_HANDLE_STATUS in
155 156 157 158
			<foreach collection="param.buyHandleStatusList" index="index" item="item" open="(" separator="," close=")">
				 #{item}
			</foreach>
		</if>
李灿灿's avatar
李灿灿 committed
159
		<if test="param.buyType != null">
huyuchen's avatar
huyuchen committed
160
			and a.BUY_TYPE = #{param.buyType}
李灿灿's avatar
李灿灿 committed
161 162
		</if>
		<if test="param.createName != null and param.createName.trim() != ''">
hongguangwu's avatar
hongguangwu committed
163
			and a.CREATE_NAME like concat('%',#{param.createName},'%')
李灿灿's avatar
李灿灿 committed
164 165
		</if>
		<if test="param.startDate != null and param.startDate.trim() != '' and param.endDate != null and param.endDate.trim() != ''">
huyuchen's avatar
huyuchen committed
166
			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
167
		</if>
hongguangwu's avatar
hongguangwu committed
168 169 170
		<if test="param.reduceHandleStatus != null">
			and a.REDUCE_HANDLE_STATUS = #{param.reduceHandleStatus}
		</if>
huyuchen's avatar
huyuchen committed
171 172 173
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
huyuchen's avatar
huyuchen committed
174
		ORDER BY a.BUY_HANDLE_STATUS,a.CREATE_TIME DESC
李灿灿's avatar
李灿灿 committed
175
	</select>
176 177
	<!--投保不分页查询-->
	<select id="getInsuranceList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceListVO">
huyuchen's avatar
huyuchen committed
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
		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
193
		a.SETTLE_MONTH as settleMonth,
hongguangwu's avatar
hongguangwu committed
194
		a.DEPT_NAME as projectName,
hongguangwu's avatar
hongguangwu committed
195
		a.REDUCE_HANDLE_STATUS as reduceHandleStatus,
hongguangwu's avatar
hongguangwu committed
196
		if(a.BUY_HANDLE_STATUS=4,a.BACK_REMARK,'') as backRemark,
197 198
		a.CREATE_TIME as createTime,
		a.IS_EFFECT as isEffect
huyuchen's avatar
huyuchen committed
199 200
		from t_insurance_detail a
		where a.DELETE_FLAG = 0
201 202 203
		<if test="param.isEffect != null">
			and a.IS_EFFECT = #{param.isEffect}
		</if>
204
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
huyuchen's avatar
huyuchen committed
205
			and a.DEPT_NO = #{param.deptNo}
206 207
		</if>
		<if test="param.buyHandleStatus != null">
huyuchen's avatar
huyuchen committed
208
			and a.BUY_HANDLE_STATUS = #{param.buyHandleStatus}
209 210
		</if>
		<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
211
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
212 213
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
214
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
215 216
		</if>
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
huyuchen's avatar
huyuchen committed
217
			and a.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
218 219
		</if>
		<if test="param.insuranceTypeName != null and param.insuranceTypeName.trim() != ''">
huyuchen's avatar
huyuchen committed
220
			and a.INSURANCE_TYPE_NAME like concat('%',replace(replace(#{param.insuranceTypeName},'_','\_'),'%','\%'),'%')
221 222
		</if>
		<if test="param.buyHandleStatusList != null and param.buyHandleStatusList.size > 0">
huyuchen's avatar
huyuchen committed
223
			and a.BUY_HANDLE_STATUS in
224 225 226 227
			<foreach collection="param.buyHandleStatusList" index="index" item="item" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
李灿灿's avatar
李灿灿 committed
228
		<if test="param.buyType != null">
huyuchen's avatar
huyuchen committed
229
			and a.BUY_TYPE = #{param.buyType}
李灿灿's avatar
李灿灿 committed
230 231
		</if>
		<if test="param.createName != null and param.createName.trim() != ''">
huyuchen's avatar
huyuchen committed
232
			and a.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
李灿灿's avatar
李灿灿 committed
233 234
		</if>
		<if test="param.startDate != null and param.startDate.trim() != '' and param.endDate != null and param.endDate.trim() != ''">
huyuchen's avatar
huyuchen committed
235
			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
236
		</if>
hongguangwu's avatar
hongguangwu committed
237 238 239
		<if test="param.reduceHandleStatus != null">
			and a.REDUCE_HANDLE_STATUS = #{param.reduceHandleStatus}
		</if>
huyuchen's avatar
huyuchen committed
240 241 242
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
huyuchen's avatar
huyuchen committed
243
		ORDER BY a.BUY_HANDLE_STATUS,a.CREATE_TIME DESC
244
	</select>
245 246
	<!--投保办理分页查询-->
	<select id="getInsuranceHandleListPage" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceListVO">
huyuchen's avatar
huyuchen committed
247 248 249 250 251 252 253 254 255 256 257
		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,
258
	    a.CREATE_TIME as createTime,
huyuchen's avatar
huyuchen committed
259 260 261
		a.CREATE_NAME as createName,
		a.BUY_HANDLE_STATUS as buyHandleStatus,
		a.SETTLE_TYPE as settleType,
hongguangwu's avatar
hongguangwu committed
262 263
		a.SETTLE_MONTH as settleMonth,
		a.DEPT_NAME as projectName
huyuchen's avatar
huyuchen committed
264 265
		from t_insurance_detail a
		where a.DELETE_FLAG = 0
李灿灿's avatar
李灿灿 committed
266
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
huyuchen's avatar
huyuchen committed
267
			and a.DEPT_NO = #{param.deptNo}
268
		</if>
李灿灿's avatar
李灿灿 committed
269
		<if test="param.buyHandleStatus != null">
huyuchen's avatar
huyuchen committed
270
			and a.BUY_HANDLE_STATUS = #{param.buyHandleStatus}
李灿灿's avatar
李灿灿 committed
271 272
		</if>
		<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
273
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
李灿灿's avatar
李灿灿 committed
274 275
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
276
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
李灿灿's avatar
李灿灿 committed
277 278
		</if>
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
huyuchen's avatar
huyuchen committed
279
			and a.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
李灿灿's avatar
李灿灿 committed
280
		</if>
281
		<if test="param.insuranceTypeName != null and param.insuranceTypeName.trim() != ''">
huyuchen's avatar
huyuchen committed
282
			and a.INSURANCE_TYPE_NAME like concat('%',replace(replace(#{param.insuranceTypeName},'_','\_'),'%','\%'),'%')
283
		</if>
李灿灿's avatar
李灿灿 committed
284
		<if test="param.buyHandleStatusList != null and param.buyHandleStatusList.size > 0">
huyuchen's avatar
huyuchen committed
285
			and a.BUY_HANDLE_STATUS in
286 287 288 289
			<foreach collection="param.buyHandleStatusList" index="index" item="item" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>
290
		<if test="param.updateBy != null and param.updateBy.trim() != ''">
huyuchen's avatar
huyuchen committed
291
			and a.HANDLED_BY = #{param.updateBy}
292
		</if>
李灿灿's avatar
李灿灿 committed
293
		<if test="param.buyType != null">
huyuchen's avatar
huyuchen committed
294
			and a.BUY_TYPE = #{param.buyType}
李灿灿's avatar
李灿灿 committed
295 296
		</if>
		<if test="param.createName != null and param.createName.trim() != ''">
huyuchen's avatar
huyuchen committed
297
			and a.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
李灿灿's avatar
李灿灿 committed
298 299
		</if>
		<if test="param.startDate != null and param.startDate.trim() != '' and param.endDate != null and param.endDate.trim() != ''">
huyuchen's avatar
huyuchen committed
300
			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
301
		</if>
huyuchen's avatar
huyuchen committed
302 303 304
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
305 306
		<if test="param.buyStandardMin != null">
			AND a.BUY_STANDARD <![CDATA[ >= ]]> #{param.buyStandardMin}
307
		</if>
308
		<if test="param.buyStandardMax != null">
309 310
			AND a.BUY_STANDARD <![CDATA[ <= ]]> #{param.buyStandardMax}
		</if>
huyuchen's avatar
huyuchen committed
311
		ORDER BY a.BUY_HANDLE_STATUS,a.CREATE_TIME DESC
李灿灿's avatar
李灿灿 committed
312
	</select>
313
	<!--通过id查询商险信息-->
李灿灿's avatar
李灿灿 committed
314 315
	<select id="getInsuranceDetailById" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceDetailVO">
		select
huyuchen's avatar
huyuchen committed
316 317 318 319 320
		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
321
		a.DEPT_NAME as projectName,
huyuchen's avatar
huyuchen committed
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
		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,
357
		a.RATE as  rate,
fangxinjiang's avatar
fangxinjiang committed
358 359 360
	    a.REFUND_ID as  refundId,
		a.EXPIRE_REMARK,
		a.EXPIRE_IGNORE_FLAG
huyuchen's avatar
huyuchen committed
361 362 363
		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
364
	</select>
365
	<!--导出办理勾选查询结果-->
李灿灿's avatar
李灿灿 committed
366
	<select id="getInsuranceExportListBySelect" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceExportListVO">
huyuchen's avatar
huyuchen committed
367 368
		select a.id as id,
		a.DEPT_NO as deptNo,
hongguangwu's avatar
hongguangwu committed
369
		a.DEPT_NAME as projectName,
huyuchen's avatar
huyuchen committed
370 371 372 373 374 375 376 377 378 379 380
		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,
381
		a.POLICY_EFFECT as policyEffect,
huyuchen's avatar
huyuchen committed
382 383 384 385 386
		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,
387
		a.ACTUAL_PREMIUM as actualPremium,
huyuchen's avatar
huyuchen committed
388 389 390 391 392 393 394
		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
395 396 397
		<foreach collection="idList" index="index" item="item" open="(" separator="," close=")">
			#{item}
		</foreach>
huyuchen's avatar
huyuchen committed
398
		ORDER BY a.CREATE_TIME DESC
李灿灿's avatar
李灿灿 committed
399
	</select>
400
	<!--出办理非勾选查询结果-->
李灿灿's avatar
李灿灿 committed
401
	<select id="getInsuranceExportList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceExportListVO">
huyuchen's avatar
huyuchen committed
402 403
		select a.id as id,
			a.DEPT_NO as deptNo,
hongguangwu's avatar
hongguangwu committed
404
			a.DEPT_NAME as projectName,
huyuchen's avatar
huyuchen committed
405 406 407 408 409 410 411 412 413 414
			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,
415
			a.POLICY_EFFECT as policyEffect,
huyuchen's avatar
huyuchen committed
416 417 418 419 420
			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,
421
			a.ACTUAL_PREMIUM as actualPremium,
huyuchen's avatar
huyuchen committed
422 423 424 425 426 427
			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
428
		where a.DELETE_FLAG = 0 and a.BUY_HANDLE_STATUS = #{param.buyHandleStatus}
429
		<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
430
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
431 432
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
433
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
434
		</if>
李灿灿's avatar
李灿灿 committed
435
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
huyuchen's avatar
huyuchen committed
436
			and a.DEPT_NO like concat('%',replace(replace(#{param.deptNo},'_','\_'),'%','\%'),'%')
李灿灿's avatar
李灿灿 committed
437
		</if>
438
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
huyuchen's avatar
huyuchen committed
439
			and a.INSURANCE_COMPANY_NAME like concat('%',replace(replace(#{param.insuranceCompanyName},'_','\_'),'%','\%'),'%')
440
		</if>
441
		<if test="param.buyType != null">
huyuchen's avatar
huyuchen committed
442
			and a.BUY_TYPE = #{param.buyType}
443 444
		</if>
		<if test="param.createName != null and param.createName.trim() != ''">
huyuchen's avatar
huyuchen committed
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530
			and a.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.startDate != null and param.startDate.trim() != '' and param.endDate != null and param.endDate.trim() != ''">
			and a.CREATE_TIME <![CDATA[ >= ]]>  concat(#{param.startDate}, ' 00:00:00') and a.CREATE_TIME <![CDATA[ <= ]]> concat(#{param.endDate}, ' 23:59:59')
		</if>
		<if test="param.updateBy != null and param.updateBy.trim() != ''">
			and a.HANDLED_BY = #{param.updateBy}
		</if>
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
		<if test="param.buyStandardMin != null">
			AND a.BUY_STANDARD <![CDATA[ >= ]]> #{param.buyStandardMin}
		</if>
		<if test="param.buyStandardMax != null">
			AND a.BUY_STANDARD <![CDATA[ <= ]]> #{param.buyStandardMax}
		</if>
		ORDER BY a.CREATE_TIME DESC
	</select>
	<!--导出办理勾选查询结果-->
	<select id="getInsuranceExportOneListBySelect" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceExportListOneVO">
		select a.id as id,
		a.DEPT_NO as deptNo,
		a.DEPT_NAME as projectName,
		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.POLICY_START as policyStart,
		a.POLICY_END as policyEnd,
		a.POLICY_EFFECT as policyEffect,
		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.ACTUAL_PREMIUM as actualPremium,
		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
		<foreach collection="idList" index="index" item="item" open="(" separator="," close=")">
			#{item}
		</foreach>
		ORDER BY a.CREATE_TIME DESC
	</select>
	<!--出办理非勾选查询结果-->
	<select id="getInsuranceExportOnetList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceExportListOneVO">
		select a.id as id,
		a.DEPT_NO as deptNo,
		a.DEPT_NAME as projectName,
		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.POLICY_START as policyStart,
		a.POLICY_END as policyEnd,
		a.POLICY_EFFECT as policyEffect,
		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.ACTUAL_PREMIUM as actualPremium,
		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.BUY_HANDLE_STATUS = #{param.buyHandleStatus}
		<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() != ''">
huyuchen's avatar
huyuchen committed
531
			and a.DEPT_NO like concat('%',replace(replace(#{param.deptNo},'_','\_'),'%','\%'),'%')
李灿灿's avatar
李灿灿 committed
532
		</if>
533
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
huyuchen's avatar
huyuchen committed
534
			and a.INSURANCE_COMPANY_NAME like concat('%',replace(replace(#{param.insuranceCompanyName},'_','\_'),'%','\%'),'%')
535
		</if>
536
		<if test="param.buyType != null">
huyuchen's avatar
huyuchen committed
537
			and a.BUY_TYPE = #{param.buyType}
538 539
		</if>
		<if test="param.createName != null and param.createName.trim() != ''">
huyuchen's avatar
huyuchen committed
540
			and a.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
541 542
		</if>
		<if test="param.startDate != null and param.startDate.trim() != '' and param.endDate != null and param.endDate.trim() != ''">
huyuchen's avatar
huyuchen committed
543
			and a.CREATE_TIME <![CDATA[ >= ]]>  concat(#{param.startDate}, ' 00:00:00') and a.CREATE_TIME <![CDATA[ <= ]]> concat(#{param.endDate}, ' 23:59:59')
544
		</if>
545 546
		<if test="param.updateBy != null and param.updateBy.trim() != ''">
			and a.HANDLED_BY = #{param.updateBy}
547
		</if>
huyuchen's avatar
huyuchen committed
548 549 550
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
551 552
		<if test="param.buyStandardMin != null">
			AND a.BUY_STANDARD <![CDATA[ >= ]]> #{param.buyStandardMin}
553
		</if>
554
		<if test="param.buyStandardMax != null">
555 556
			AND a.BUY_STANDARD <![CDATA[ <= ]]> #{param.buyStandardMax}
		</if>
huyuchen's avatar
huyuchen committed
557
		ORDER BY a.CREATE_TIME DESC
558
	</select>
559
	<!--批量更新保单号-->
560 561 562 563 564
	<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>
565
	<!--批量更新发票号-->
566 567 568 569 570 571
	<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
572
	<!-- ***********************减员办理******************************** -->
573
	<!-- 已投保列表分页查询-->
李灿灿's avatar
李灿灿 committed
574
	<select id="getInsuredListPage" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuredListVo">
575
		select
huyuchen's avatar
huyuchen committed
576 577 578 579 580 581
			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
582
			a.DEPT_NAME as projectName,
huyuchen's avatar
huyuchen committed
583 584 585 586 587 588 589 590 591 592
			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
593 594
			a.BUY_STANDARD as buyStandard,
			a.CREATE_TIME as createTime,
595 596 597
			a.CREATE_NAME as createName,
			a.UNIT_NAME as unitName,
			a.UNIT_NO as unitNo
598
		from
huyuchen's avatar
huyuchen committed
599
		     t_insurance_detail a
600
		where
huyuchen's avatar
huyuchen committed
601
			a.DELETE_FLAG = 0
602
		and
huyuchen's avatar
huyuchen committed
603
			a.BUY_HANDLE_STATUS = 3
604 605 606
		<if test="param.isEffect != null">
			and a.IS_EFFECT = #{param.isEffect}
		</if>
607 608 609 610 611 612
		<if test="param.unitName != null and param.unitName.trim() != ''">
			and a.UNIT_NAME like concat(replace(replace(#{param.unitName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.unitNo != null and param.unitNo.trim() != ''">
			and a.UNIT_NO like concat(replace(replace(#{param.unitNo},'_','\_'),'%','\%'),'%')
		</if>
hongguangwu's avatar
hongguangwu committed
613 614 615 616 617 618 619 620 621
		<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>
622
		<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
623
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
624 625
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
626
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
627 628
		</if>
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
huyuchen's avatar
huyuchen committed
629
			and a.DEPT_NO = #{param.deptNo}
630 631
		</if>
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
huyuchen's avatar
huyuchen committed
632
			and a.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
633 634
		</if>
		<if test="param.policyNo != null and param.policyNo.trim() != ''">
huyuchen's avatar
huyuchen committed
635
			and a.POLICY_NO like concat('%',replace(replace(#{param.policyNo},'_','\_'),'%','\%'),'%')
636
		</if>
fangxinjiang's avatar
fangxinjiang committed
637 638
		<if test="param.policyJingQueStart != null and param.policyJingQueStart.trim() != ''">
			AND  DATE_FORMAT(a.POLICY_START,"%Y-%m-%d")  = #{param.policyJingQueStart}
639
		</if>
fangxinjiang's avatar
fangxinjiang committed
640 641
		<if test="param.policyJingQueEnd != null and param.policyJingQueEnd.trim() != ''">
			AND   DATE_FORMAT(a.POLICY_END,"%Y-%m-%d") = #{param.policyJingQueEnd}
642
		</if>
fangxinjiang's avatar
fangxinjiang committed
643

644 645
		<if test="param.policyStart != null and param.policyStart.trim() != '' and param.policyEnd != null and param.policyEnd.trim() != ''">
			and (
huyuchen's avatar
huyuchen committed
646 647 648
			(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'))
649
				)
650 651
		</if>
		<if test="param.invoiceNo != null and param.invoiceNo.trim() != ''">
huyuchen's avatar
huyuchen committed
652
			and a.INVOICE_NO like concat('%',replace(replace(#{param.invoiceNo},'_','\_'),'%','\%'),'%')
653 654
		</if>
		<if test="param.isUse != null">
huyuchen's avatar
huyuchen committed
655
			and a.IS_USE = #{param.isUse}
656
		</if>
657
		<if test="param.isOverdue != null">
huyuchen's avatar
huyuchen committed
658
			and a.IS_OVERDUE = #{param.isOverdue}
659
		</if>
660
		<if test="param.createStartTime != null and param.createStartTime.trim() != ''">
huyuchen's avatar
huyuchen committed
661
			AND a.CREATE_TIME  <![CDATA[ >= ]]>  concat(#{param.createStartTime}, ' 00:00:00')
662 663
		</if>
		<if test="param.createEndTime != null and param.createEndTime.trim() != ''">
huyuchen's avatar
huyuchen committed
664
			AND a.CREATE_TIME  <![CDATA[ <= ]]> concat(#{param.createEndTime}, ' 23:59:59')
665
		</if>
huyuchen's avatar
huyuchen committed
666 667 668
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
huyuchen's avatar
huyuchen committed
669
		ORDER BY a.CREATE_TIME DESC ,a.ID ASC
670
	</select>
671
	<!-- 已投保列表不分页查询-->
672 673
	<select id="getInsuredList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuredListVo">
		select
huyuchen's avatar
huyuchen committed
674 675 676 677 678
			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
679
			a.DEPT_NAME as projectName,
huyuchen's avatar
huyuchen committed
680 681 682 683 684 685 686 687 688 689 690 691 692 693
			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,
694
			CONCAT(a.INSURANCE_PROVINCE_NAME,'/',a.INSURANCE_CITY_NAME) as insuranceCityName,
huyuchen's avatar
huyuchen committed
695
			a.INSURANCE_HANDLE_PROVINCE_NAME as insuranceHandleProvinceName,
696
			CONCAT(a.INSURANCE_HANDLE_PROVINCE_NAME,'/',a.INSURANCE_HANDLE_CITY_NAME) as insuranceHandleCityName,
huyuchen's avatar
huyuchen committed
697 698 699 700
			a.IS_USE as isUse,
			a.IS_EFFECT as isEffect,
			a.IS_OVERDUE as isOverdue,
			a.CREATE_TIME as createTime,
701 702 703
			a.CREATE_NAME as createName,
			a.UNIT_NAME as unitName,
			a.UNIT_NO as unitNo
704
		from
huyuchen's avatar
huyuchen committed
705
		    t_insurance_detail a
706
		where
huyuchen's avatar
huyuchen committed
707
		    a.DELETE_FLAG = 0
708
		and
huyuchen's avatar
huyuchen committed
709
			a.BUY_HANDLE_STATUS = 3
710 711 712
		<if test="param.isEffect != null">
			and a.IS_EFFECT = #{param.isEffect}
		</if>
713 714 715 716 717 718
		<if test="param.unitName != null and param.unitName.trim() != ''">
			and a.UNIT_NAME like concat(replace(replace(#{param.unitName},'_','\_'),'%','\%'),'%')
		</if>
		<if test="param.unitNo != null and param.unitNo.trim() != ''">
			and a.UNIT_NO like concat(replace(replace(#{param.unitNo},'_','\_'),'%','\%'),'%')
		</if>
hongguangwu's avatar
hongguangwu committed
719 720
		<if test="param.createName != null and param.createName.trim() != ''">
			and a.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742
		</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>
743
		<if test="param.policyStart != null and param.policyStart.trim() != '' and (param.policyEnd == null or param.policyEnd.trim() == '')">
744 745
			AND a.POLICY_END   <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00')
		</if>
746
		<if test="param.policyEnd != null and param.policyEnd.trim() != '' and (param.policyStart == null or param.policyStart.trim() == '')">
747 748
			AND a.POLICY_START <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59')
		</if>
fangxinjiang's avatar
fangxinjiang committed
749 750 751 752 753 754
		<if test="param.policyJingQueStart != null and param.policyJingQueStart.trim() != ''">
			AND  DATE_FORMAT(a.POLICY_START,"%Y-%m-%d")  = #{param.policyJingQueStart}
		</if>
		<if test="param.policyJingQueEnd != null and param.policyJingQueEnd.trim() != ''">
			AND   DATE_FORMAT(a.POLICY_END,"%Y-%m-%d") = #{param.policyJingQueEnd}
		</if>
755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795
		<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
796 797 798
		<if test="param.isEffect != null">
			and a.IS_EFFECT = #{param.isEffect}
		</if>
799 800
		<if test="param.createName != null and param.createName.trim() != ''">
			and a.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
hongguangwu's avatar
hongguangwu committed
801 802 803 804 805 806 807
		</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>
808
		<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
809
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
810 811
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
812
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
813 814
		</if>
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
huyuchen's avatar
huyuchen committed
815
			and a.DEPT_NO = #{param.deptNo}
816 817
		</if>
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
huyuchen's avatar
huyuchen committed
818
			and a.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
819 820
		</if>
		<if test="param.policyNo != null and param.policyNo.trim() != ''">
huyuchen's avatar
huyuchen committed
821
			and a.POLICY_NO like concat('%',replace(replace(#{param.policyNo},'_','\_'),'%','\%'),'%')
822
		</if>
823
		<if test="param.policyStart != null and param.policyStart.trim() != '' and (param.policyEnd == null or param.policyEnd.trim() == '')">
huyuchen's avatar
huyuchen committed
824
			AND a.POLICY_END   <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00')
825
		</if>
826
		<if test="param.policyEnd != null and param.policyEnd.trim() != '' and (param.policyStart == null or param.policyStart.trim() == '')">
huyuchen's avatar
huyuchen committed
827
			AND a.POLICY_START <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59')
828
		</if>
fangxinjiang's avatar
fangxinjiang committed
829 830 831 832 833 834
		<if test="param.policyJingQueStart != null and param.policyJingQueStart.trim() != ''">
			AND  DATE_FORMAT(a.POLICY_START,"%Y-%m-%d")  = #{param.policyJingQueStart}
		</if>
		<if test="param.policyJingQueEnd != null and param.policyJingQueEnd.trim() != ''">
			AND   DATE_FORMAT(a.POLICY_END,"%Y-%m-%d") = #{param.policyJingQueEnd}
		</if>
835 836
		<if test="param.policyStart != null and param.policyStart.trim() != '' and param.policyEnd != null and param.policyEnd.trim() != ''">
			and (
huyuchen's avatar
huyuchen committed
837 838 839
			(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'))
840
			)
841
		</if>
hongguangwu's avatar
hongguangwu committed
842 843 844 845 846 847
		<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>
848
		<if test="param.invoiceNo != null and param.invoiceNo.trim() != ''">
huyuchen's avatar
huyuchen committed
849
			and a.INVOICE_NO like concat('%',replace(replace(#{param.invoiceNo},'_','\_'),'%','\%'),'%')
850 851
		</if>
		<if test="param.isUse != null">
huyuchen's avatar
huyuchen committed
852
			and a.IS_USE = #{param.isUse}
853
		</if>
854
		<if test="param.isOverdue != null ">
huyuchen's avatar
huyuchen committed
855
			and a.IS_OVERDUE = #{param.isOverdue}
856
		</if>
huyuchen's avatar
huyuchen committed
857 858 859
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
huyuchen's avatar
huyuchen committed
860
		ORDER BY a.CREATE_TIME DESC
861
	</select>
862
	<!-- 已减员列表分页查询-->
863 864
	<select id="getInsuranceRefundPageList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceRefundListVo">
		select
huyuchen's avatar
huyuchen committed
865 866 867 868 869
		    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
870
			a.DEPT_NAME as projectName,
huyuchen's avatar
huyuchen committed
871
			a.INSURANCE_COMPANY_NAME as insuranceCompanyName,
872 873
		    a.INSURANCE_TYPE_NAME as insuranceTypeName,
		    a.BUY_STANDARD as buyStandard,
huyuchen's avatar
huyuchen committed
874 875 876
			a.POLICY_START as policyStart,
			a.POLICY_END as policyEnd,
			a.POLICY_NO as policyNo,
hongguangwu's avatar
hongguangwu committed
877
			a.CREATE_NAME as createName,
878
			a.BUY_TYPE as buyType,
879
			refund.CREATE_USER_DEPT_NAME as createUserDeptName,
hongguangwu's avatar
hongguangwu committed
880
			refund.CREATE_TIME as refundCreateTime,
881 882
			a.CREATE_TIME as createTime,
		       a.IS_EFFECT as isEffect
883
		from
huyuchen's avatar
huyuchen committed
884 885
			t_insurance_detail a,
			t_insurance_refund refund
886
		where
huyuchen's avatar
huyuchen committed
887
		    a.DELETE_FLAG = 0
888
		and
huyuchen's avatar
huyuchen committed
889
			a.REFUND_ID = refund.ID
890
		and
huyuchen's avatar
huyuchen committed
891
			a.REDUCE_HANDLE_STATUS = 4
892 893 894
		<if test="param.isEffect != null">
			and a.IS_EFFECT = #{param.isEffect}
		</if>
hongguangwu's avatar
hongguangwu committed
895 896 897
		<if test="param.createName != null and param.createName.trim() != ''">
			and a.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
		</if>
898
		<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
899
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
900 901
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
902
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
903 904
		</if>
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
huyuchen's avatar
huyuchen committed
905
			and a.DEPT_NO = #{param.deptNo}
906 907
		</if>
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
huyuchen's avatar
huyuchen committed
908
			and a.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
909 910
		</if>
		<if test="param.policyNo != null and param.policyNo.trim() != ''">
huyuchen's avatar
huyuchen committed
911
			and a.POLICY_NO like concat('%',replace(replace(#{param.policyNo},'_','\_'),'%','\%'),'%')
912
		</if>
913
		<if test="param.policyStart != null and param.policyStart.trim() != '' and ( param.policyEnd == null or param.policyEnd.trim() == '' )">
huyuchen's avatar
huyuchen committed
914
			AND a.POLICY_END   <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00')
915
		</if>
916
		<if test="param.policyEnd != null and param.policyEnd.trim() != '' and (param.policyStart == null or param.policyStart.trim() == '')">
huyuchen's avatar
huyuchen committed
917
			AND a.POLICY_START <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59')
918
		</if>
fangxinjiang's avatar
fangxinjiang committed
919 920 921 922 923 924
		<if test="param.policyJingQueStart != null and param.policyJingQueStart.trim() != ''">
			AND  DATE_FORMAT(a.POLICY_START,"%Y-%m-%d")  = #{param.policyJingQueStart}
		</if>
		<if test="param.policyJingQueEnd != null and param.policyJingQueEnd.trim() != ''">
			AND   DATE_FORMAT(a.POLICY_END,"%Y-%m-%d") = #{param.policyJingQueEnd}
		</if>
925 926
		<if test="param.policyStart != null and param.policyStart.trim() != '' and param.policyEnd != null and param.policyEnd.trim() != ''">
			and (
huyuchen's avatar
huyuchen committed
927 928 929
			(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'))
930
			)
931
		</if>
hongguangwu's avatar
hongguangwu committed
932 933 934 935 936 937
		<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
938 939 940
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
huyuchen's avatar
huyuchen committed
941
		ORDER BY refund.CREATE_TIME DESC,a.ID ASC
942
	</select>
943
	<!-- 已减员列表不分页查询-->
944 945
	<select id="getInsuranceRefundList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceRefundListVo">
		select
huyuchen's avatar
huyuchen committed
946 947
			a.id as id,
			a.DEPT_NO as deptNo,
hongguangwu's avatar
hongguangwu committed
948
			a.DEPT_NAME as projectName,
huyuchen's avatar
huyuchen committed
949 950 951 952 953 954 955 956 957 958
			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,
959 960
		    a.POLICY_NO as policyNo,
		    a.ACTUAL_PREMIUM as actualPremium,
huyuchen's avatar
huyuchen committed
961 962 963 964 965
			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
966
			a.CREATE_NAME as createName,
967 968
			refund.CREATE_TIME as refundCreateTime,
			a.IS_EFFECT as isEffect
969
		from
huyuchen's avatar
huyuchen committed
970 971
			t_insurance_detail a,
			t_insurance_refund refund
972
		where
huyuchen's avatar
huyuchen committed
973
			a.REFUND_ID = refund.ID
974
		and
huyuchen's avatar
huyuchen committed
975
			a.DELETE_FLAG = 0
976
		and
huyuchen's avatar
huyuchen committed
977
			a.REDUCE_HANDLE_STATUS = 4
978 979 980
		<if test="param.isEffect != null">
			and a.IS_EFFECT = #{param.isEffect}
		</if>
hongguangwu's avatar
hongguangwu committed
981 982 983
		<if test="param.createName != null and param.createName.trim() != ''">
			and a.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
		</if>
984
		<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
985
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
986 987
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
988
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
989 990
		</if>
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
huyuchen's avatar
huyuchen committed
991
			and a.DEPT_NO = #{param.deptNo}
992 993
		</if>
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
huyuchen's avatar
huyuchen committed
994
			and a.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
995 996
		</if>
		<if test="param.policyNo != null and param.policyNo.trim() != ''">
huyuchen's avatar
huyuchen committed
997
			and a.POLICY_NO like concat('%',replace(replace(#{param.policyNo},'_','\_'),'%','\%'),'%')
998
		</if>
999
		<if test="param.policyStart != null and param.policyStart.trim() != '' and (param.policyEnd == null or param.policyEnd.trim() == '')">
huyuchen's avatar
huyuchen committed
1000
			AND a.POLICY_END   <![CDATA[ >= ]]>  concat(#{param.policyStart}, ' 00:00:00')
1001
		</if>
1002
		<if test="param.policyEnd != null and param.policyEnd.trim() != '' and (param.policyStart == null or param.policyStart.trim() == '')">
huyuchen's avatar
huyuchen committed
1003
			AND a.POLICY_START <![CDATA[ <= ]]> concat(#{param.policyEnd}, ' 23:59:59')
1004
		</if>
fangxinjiang's avatar
fangxinjiang committed
1005 1006 1007 1008 1009 1010
		<if test="param.policyJingQueStart != null and param.policyJingQueStart.trim() != ''">
			AND  DATE_FORMAT(a.POLICY_START,"%Y-%m-%d")  = #{param.policyJingQueStart}
		</if>
		<if test="param.policyJingQueEnd != null and param.policyJingQueEnd.trim() != ''">
			AND   DATE_FORMAT(a.POLICY_END,"%Y-%m-%d") = #{param.policyJingQueEnd}
		</if>
1011 1012
		<if test="param.policyStart != null and param.policyStart.trim() != '' and param.policyEnd != null and param.policyEnd.trim() != ''">
			and (
huyuchen's avatar
huyuchen committed
1013 1014 1015
			(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'))
1016
			)
1017
		</if>
hongguangwu's avatar
hongguangwu committed
1018 1019 1020 1021 1022 1023
		<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
1024 1025 1026
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
1027
		ORDER BY refund.CREATE_TIME DESC
1028
	</select>
1029 1030
	<!-- 减员办理列表分页查询-->
	<select id="getInsuranceRefundHandlingPageList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.RefundExportListVo">
李灿灿's avatar
李灿灿 committed
1031
		select
1032
		DISTINCT
huyuchen's avatar
huyuchen committed
1033 1034 1035 1036 1037
		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
1038
		a.DEPT_NAME as projectName,
huyuchen's avatar
huyuchen committed
1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050
		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,
1051
		refund.CREATE_TIME as createTime,
1052
		refund.CREATE_NAME as createName,
huyuchen's avatar
huyuchen committed
1053
		a.REDUCE_HANDLE_STATUS as reduceHandleStatus
1054
		from
huyuchen's avatar
huyuchen committed
1055
			t_insurance_detail a,
1056
			t_insurance_refund refund
1057
		where
huyuchen's avatar
huyuchen committed
1058
			a.REFUND_ID = refund.ID
1059
		<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
1060
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
1061 1062
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
1063
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
1064
		</if>
1065
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
huyuchen's avatar
huyuchen committed
1066
			and a.DEPT_NO = #{param.deptNo}
1067
		</if>
1068
		<if test="param.reduceHandleStatus != null">
huyuchen's avatar
huyuchen committed
1069
			and a.REDUCE_HANDLE_STATUS = #{param.reduceHandleStatus}
1070
		</if>
1071
		<if test="param.insuranceTypeName != null and param.insuranceTypeName.trim() != ''">
huyuchen's avatar
huyuchen committed
1072
			and a.INSURANCE_TYPE_NAME like concat('%',replace(replace(#{param.insuranceTypeName},'_','\_'),'%','\%'),'%')
1073
		</if>
1074
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
huyuchen's avatar
huyuchen committed
1075
			and a.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
1076
		</if>
1077 1078
		<if test="param.updateBy != null and param.updateBy.trim() != ''">
			and  refund.UPDATE_BY = #{param.updateBy}
1079
		</if>
1080 1081 1082
		<if test="param.createName != null and param.createName.trim() != ''">
			and refund.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
		</if>
1083
		<if test="param.startDate != null and param.startDate.trim() != ''">
1084
			AND refund.CREATE_TIME   <![CDATA[ >= ]]>  concat(#{param.startDate}, ' 00:00:00')
1085
		</if>
1086
		<if test="param.endDate != null and param.endDate.trim() != ''">
1087
			AND refund.CREATE_TIME <![CDATA[ <= ]]> concat(#{param.endDate}, ' 23:59:59')
1088
		</if>
1089 1090
		<if test="param.buyStandardMin != null and param.buyStandardMin.trim() != ''">
			AND a.BUY_STANDARD   <![CDATA[ >= ]]>  #{param.buyStandardMin}
1091
		</if>
1092 1093
		<if test="param.buyStandardMax != null and param.buyStandardMax.trim() != ''">
			AND a.BUY_STANDARD <![CDATA[ <= ]]> #{param.buyStandardMax}
1094
		</if>
huyuchen's avatar
huyuchen committed
1095 1096 1097
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
huyuchen's avatar
huyuchen committed
1098
		ORDER BY refund.CREATE_TIME DESC,a.ID ASC
李灿灿's avatar
李灿灿 committed
1099
	</select>
1100
	<!-- 查询保单列表-->
1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112
	<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>
1113

1114
	<!-- 查询保单减员退费信息-->
1115
	<select id="selectRefundDetailId" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceRefundVo">
1116
		select
1117
			refund.ID as id,
1118
			refund.INS_DETAIL_ID as insDetailId,
1119 1120 1121
			refund.REFUND_MONEY as refundMoney,
		    a.INSURANCE_HANDLE_PROVINCE as insuranceHandleProvince,
		    a.INSURANCE_HANDLE_CITY as insuranceHandleCity
1122
		from
huyuchen's avatar
huyuchen committed
1123
			t_insurance_detail a,
1124 1125
			t_insurance_refund refund
		where
1126 1127 1128 1129
	  		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
1130 1131
			and a.EMP_NAME = #{param.empName}
			and a.EMP_IDCARD_NO = #{param.empIdcardNo}
1132 1133 1134 1135 1136 1137
			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
1138
			a.CREATE_TIME DESC
1139
		limit 1;
1140
	</select>
1141
	<!-- 根据ID导出减员办理列表-->
1142 1143
	<select id="getRefundExportListBySelect" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.RefundExportListVo">
		select
huyuchen's avatar
huyuchen committed
1144 1145
			a.id as id,
			a.DEPT_NO as deptNo,
hongguangwu's avatar
hongguangwu committed
1146
			a.DEPT_NAME as projectName,
huyuchen's avatar
huyuchen committed
1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163
			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
1164 1165
			a.POLICY_NO as policyNo,
			refund.CREATE_NAME as createName,
huyuchen's avatar
huyuchen committed
1166
			a.REDUCE_HANDLE_STATUS as reduceHandleStatus,
huyuchen's avatar
huyuchen committed
1167
			refund.REMARK as remark
1168
		from
huyuchen's avatar
huyuchen committed
1169 1170
		    t_insurance_detail a,
			t_insurance_refund refund
1171
		where
huyuchen's avatar
huyuchen committed
1172
			a.REFUND_ID = refund.ID AND
huyuchen's avatar
huyuchen committed
1173
		    a.id in
1174 1175 1176
		<foreach collection="idList" index="index" item="item" open="(" separator="," close=")">
			#{item}
		</foreach>
huyuchen's avatar
huyuchen committed
1177
		ORDER BY a.CREATE_TIME DESC
1178
	</select>
1179
	<!-- 根据查询参数导出减员办理列表-->
1180 1181
	<select id="getRefundExportList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.RefundExportListVo">
		select
huyuchen's avatar
huyuchen committed
1182 1183
		    a.id as id,
			a.DEPT_NO as deptNo,
hongguangwu's avatar
hongguangwu committed
1184
			a.DEPT_NAME as projectName,
huyuchen's avatar
huyuchen committed
1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201
			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
1202 1203 1204
			refund.CREATE_NAME as createName,
			a.POLICY_NO as policyNo,
			refund.REMARK as remark
1205
		from
huyuchen's avatar
huyuchen committed
1206 1207
			t_insurance_detail a,
			t_insurance_refund refund
1208
		where
huyuchen's avatar
huyuchen committed
1209
			a.REFUND_ID = refund.ID and
1210
		    a.DELETE_FLAG = 0 and a.REDUCE_HANDLE_STATUS = #{param.reduceHandleStatus}
1211
		<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
1212
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
1213 1214
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
1215
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
1216 1217
		</if>
		<if test="param.deptNo != null and param.deptNo.trim() != ''">
huyuchen's avatar
huyuchen committed
1218
			and a.DEPT_NO = #{param.deptNo}
1219
		</if>
1220
		<if test="param.insuranceTypeName != null and param.insuranceTypeName.trim() != ''">
huyuchen's avatar
huyuchen committed
1221
			and a.INSURANCE_TYPE_NAME like concat('%',replace(replace(#{param.insuranceTypeName},'_','\_'),'%','\%'),'%')
1222
		</if>
1223
		<if test="param.insuranceCompanyName != null and param.insuranceCompanyName.trim() != ''">
huyuchen's avatar
huyuchen committed
1224
			and a.INSURANCE_COMPANY_NAME = #{param.insuranceCompanyName}
1225
		</if>
1226 1227
		<if test="param.buyStandardMin != null and param.buyStandardMin.trim() != ''">
			AND a.BUY_STANDARD   <![CDATA[ >= ]]>  #{param.buyStandardMin}
1228
		</if>
1229 1230
		<if test="param.buyStandardMax != null and param.buyStandardMax.trim() != ''">
			AND a.BUY_STANDARD <![CDATA[ <= ]]> #{param.buyStandardMax}
1231
		</if>
1232 1233
		<if test="param.updateBy != null and param.updateBy.trim() != ''">
			and  refund.UPDATE_BY = #{param.updateBy}
1234
		</if>
huyuchen's avatar
huyuchen committed
1235 1236
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
1237
		</if>
huyuchen's avatar
huyuchen committed
1238
		ORDER BY a.CREATE_TIME DESC
1239
	</select>
1240
	<!-- 减员办理-->
1241 1242
	<update id="updateInsuranceRefund">
		update
huyuchen's avatar
huyuchen committed
1243
			t_insurance_detail a
1244 1245 1246 1247 1248
		set
			UPDATE_BY = #{param.updateBy},
			REDUCE_HANDLE_STATUS = #{param.refundType},
			UPDATE_TIME = #{param.refundCreateTime}
		where
huyuchen's avatar
huyuchen committed
1249
		      a.ID in
1250 1251 1252 1253
		<foreach collection="param.idList" index="index" item="item" open="(" separator="," close=")">
			#{item}
		</foreach>
	</update>
1254
	<!--根据身份证查询商险信息-->
1255
	<select id="getInsuranceListByIdCard" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceListByIdCardVo">
huyuchen's avatar
huyuchen committed
1256 1257 1258 1259 1260 1261
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_insurance_detail
		<where>
			1=1
			AND EMP_IDCARD_NO = #{idCard}
1262
			and DEPT_NO = #{deptNo}
huyuchen's avatar
huyuchen committed
1263 1264 1265
		</where>
		ORDER BY CREATE_TIME desc
	</select>
1266
	<!--查询所有在保,未出险,未过期,未失效,未减员的保单信息-->
1267
    <select id="selectListByEmpIdcardNo" resultType="com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceDetail">
1268
		SELECT
1269 1270 1271
			<include refid="Base_Column_List"/>
		FROM
		  t_insurance_detail
1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282
		<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>
1283 1284
	<!--商险订单列表查询-->
	<select id="getOrderInsuredListPage" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuredOrderListVo">
1285 1286
		(
		select
huyuchen's avatar
huyuchen committed
1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302
			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
1303
		from
huyuchen's avatar
huyuchen committed
1304
			t_insurance_detail a
1305
		where
huyuchen's avatar
huyuchen committed
1306
			a.DELETE_FLAG = 0
1307
		and
huyuchen's avatar
huyuchen committed
1308
			a.ORDER_NO = #{param.orderNo}
1309
		<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
1310
			and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
1311 1312
		</if>
		<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
1313
			and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
1314
		</if>
1315
		<if test="param.startDate != null ">
huyuchen's avatar
huyuchen committed
1316
			AND a.CREATE_TIME  <![CDATA[ >= ]]>  concat(#{param.startDate}, ' 00:00:00')
1317
		</if>
1318
		<if test="param.endDate != null ">
huyuchen's avatar
huyuchen committed
1319
			AND a.CREATE_TIME  <![CDATA[ <= ]]> concat(#{param.endDate}, ' 23:59:59')
1320
		</if>
huyuchen's avatar
huyuchen committed
1321 1322 1323
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
1324
		<if test="param.deptNoList != null">
huyuchen's avatar
huyuchen committed
1325
			and a.DEPT_NO in
1326 1327 1328 1329 1330 1331
			<foreach collection="param.deptNoList" index="index" item="item" open="(" separator="," close=")">
				#{item}
			</foreach>
		</if>)
		union all(
		select
huyuchen's avatar
huyuchen committed
1332
			a.id as id,
1333
			refund.id as onlyId,
1334
			refund.BUY_TYPE as buyType,
1335
			refund.CREATE_BY as createBy,
huyuchen's avatar
huyuchen committed
1336 1337 1338 1339 1340 1341 1342
			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,
1343 1344 1345
			refund.CREATE_NAME as createName,
			refund.CREATE_USER_DEPT_NAME as createUserDeptName,
			refund.CREATE_TIME as createTime,
huyuchen's avatar
huyuchen committed
1346
			a.BUY_HANDLE_STATUS as buyHandleStatus,
1347 1348
			refund.REDUCE_HANDLE_STATUS as reduceHandleStatus
			from
huyuchen's avatar
huyuchen committed
1349
				t_insurance_detail a,
1350 1351
				t_insurance_refund refund
			where
huyuchen's avatar
huyuchen committed
1352
				a.DELETE_FLAG = 0
1353
			and
huyuchen's avatar
huyuchen committed
1354
			    a.ID = refund.INS_DETAIL_ID
1355 1356 1357
			and
				refund.ORDER_NO = #{param.orderNo}
			<if test="param.empName != null and param.empName.trim() != ''">
huyuchen's avatar
huyuchen committed
1358
				and a.EMP_NAME like concat('%',replace(replace(#{param.empName},'_','\_'),'%','\%'),'%')
1359 1360
			</if>
			<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
huyuchen's avatar
huyuchen committed
1361
				and a.EMP_IDCARD_NO like concat('%',replace(replace(#{param.empIdcardNo},'_','\_'),'%','\%'),'%')
1362
			</if>
1363 1364
			<if test="param.startDate != null">
				AND refund.CREATE_TIME  <![CDATA[ >= ]]>  concat(#{param.startDate}, ' 00:00:00')
1365
			</if>
1366 1367
			<if test="param.endDate != null ">
				AND refund.CREATE_TIME  <![CDATA[ <= ]]> concat(#{param.endDate}, ' 23:59:59')
1368
			</if>
huyuchen's avatar
huyuchen committed
1369 1370 1371
			<if test="param.authSql != null and param.authSql.trim() != ''">
				${param.authSql}
			</if>
1372
			<if test="param.deptNoList != null">
huyuchen's avatar
huyuchen committed
1373
				and a.DEPT_NO in
1374 1375 1376 1377
				<foreach collection="param.deptNoList" index="index" item="item" open="(" separator="," close=")">
					#{item}
				</foreach>
			</if>
huyuchen's avatar
huyuchen committed
1378 1379
		)
		order by createTime desc
1380 1381
	</select>

1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397
	<!-- 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>

1398 1399 1400 1401 1402 1403 1404 1405

	<!--查询所有商险,如果idList 不为空,则不含被替换的本身。 用来改变档案状态-->
	<select id="selectByIdCardList" resultMap="BaseResultMap">
		SELECT
			<include refid="Base_Column_List"/>
		FROM
		t_insurance_detail
		where
1406 1407 1408
			DELETE_FLAG = 0
		<if test="idCardList != null and idCardList.size > 0">
			AND EMP_IDCARD_NO in
1409 1410 1411
			<foreach item="item" index="index" collection="idCardList" open="(" separator="," close=")">
				#{item}
			</foreach>
1412 1413
		</if>
			<if test="idList != null and idList.size > 0">
1414 1415 1416 1417 1418 1419 1420
				AND id not in
				<foreach item="item" index="index" collection="idList" open="(" separator="," close=")">
					#{item}
				</foreach>
			</if>
	</select>

huyuchen's avatar
huyuchen committed
1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434
	<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>

1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505

	<!--	退保退费分页查询-->
	<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>
1506 1507 1508 1509 1510 1511
		<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>
1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586
		<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>
1587 1588 1589 1590 1591 1592
		<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>
1593 1594 1595 1596 1597
		<if test="param.authSql != null and param.authSql.trim() != ''">
			${param.authSql}
		</if>
		ORDER BY refund.CREATE_TIME DESC,a.ID ASC
	</select>
huyuchen's avatar
huyuchen committed
1598

fangxinjiang's avatar
fangxinjiang committed
1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658
	<sql id="selectParamsVo">
		t.ID id,
        t.EMP_ID empId,
        t.EMP_NO empNo,
        t.EMP_NAME empName,
        t.EMP_IDCARD_NO empIdcardNo,
        t.INSURANCE_COMPANY insuranceCompany,
        t.INSURANCE_TYPE insuranceType,
        t.POLICY_START policyStart,
        t.POLICY_END policyEnd,
        t.BUY_PAY buyPay,
        t.IS_AT_SALARY isAtSalary,
        t.REMARK,
        t.CREATE_USER createUser,
        t.CREATE_TIME createTime,
        t.STATUS,
        t.POLICY_NO policyNo,
        t.MEDICAL_MONEY medicalMoney,
        t.DEATH_DISABILITY_MONEY deathDisabilityMoney,
        t.SETTLEMENT_DEPART settlementDepart,
        t.SETTLEMENT_ORGAN settlementOrgan,
        t.REPLACE_DATE replaceDate,
        t.REPLACE_STATUS replaceStatus,
        t.BUSINESS_INSURANCE_ADDR businessInsuranceAddr,
        t.SETTLE_TYPE settleType,
        t.BUY_STANDARD buyStandard,
        t.BATCH_DATE batchDate,
        t.IS_NOTICE isNotice,
        t.SETTLE_MONTH settleMonth,
        t.INVOICE_NO invoiceNo,
        t.BUY_TYPE buyType,
        t.LAST_UPDATE_USER lastUpdateUser,
        t.LAST_UPDATE_TIME lastUpdateTime,
        t.OLD_ID oldId,
        t.SETTLEMENT_FORM_ID settlementFormId,
        t.IS_SUBMIT,
        t.CUSTOMER_NAME customerName,
        t.CUSTOMER_ID customerId,
        t.SETTLEMENT_ORGAN_NAME settlementOrganName,
        t.SETTLEMENT_ORGAN_NO settlementOrganNo,
        t.SETTLE_FORM_TYPE settleFormType,
        t.POLICY_EFFECT policyEffect,
        t.SETTLE_FORM_ID settleFormId,
        p.NAME insuranceTypeName,
        tic.COMPANY_NAME insuranceCompanyName,
        t.BUSINESS_INSURANCE_PROV_ID businessInsuranceProvId,
        t.BUSINESS_INSURANCE_ADDR_ID businessInsuranceAddrId,
        t.BUSINESS_INSURANCE_PROV businessInsuranceProv,t.VALID_FLAG  validFlag,
        t.FORECAST_BUY_PAY,
        t.SETTLE_BUY_PAY_TYPE
        ,case  when t.POLICY_END &lt; date(now()) then '1' else 0  end  'expireFlag',
        t.post,
        t.BUY_MONTH,
        t.REFUND_RECORD_ID,
        t.REFUND_MONEY,
        t.REFUND_CREATE_TIME,
        t.REFUND_CREATE_USER,
        t.USER_DEPT_NAME
	</sql>
	<sql id="expire_sql_param">
fangxinjiang's avatar
fangxinjiang committed
1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681
		select
			a.id,
			a.EMP_NAME,
			a.EMP_IDCARD_NO,
			a.DEPT_NAME,
			a.DEPT_NO,
			a.INSURANCE_COMPANY_NAME,
			a.INSURANCE_TYPE_NAME,
			a.POLICY_START,
			a.POLICY_END,
			a.BUY_STANDARD,
			a.ACTUAL_PREMIUM,
			a.CREATE_NAME,
			a.CREATE_TIME,
			a.BUY_HANDLE_STATUS,
			a.POLICY_NO,
			a.MEDICAL_QUOTA,
			a.DIE_DISABLE_QUOTA,
			a.SETTLE_TYPE,
			a.SETTLE_MONTH,
			a.INVOICE_NO,
			r2.REPLACE_TIME,
			a.POLICY_EFFECT,
fangxinjiang's avatar
fangxinjiang committed
1682
			a.UNIT_NAME as "customerName",
fangxinjiang's avatar
fangxinjiang committed
1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696
			a.UNIT_NO,
			a.REMARK,
			a.INSURANCE_PROVINCE_NAME,
			a.INSURANCE_CITY_NAME,
			a.IS_EFFECT,
			a.POST,
			r.fromEmpName,
			r.toEmpName,
			r.REPLACE_TIME as "toReplaceTime",
			a.IS_OVERDUE,
			a.ESTIMATE_PREMIUM,
			rf.REFUND_MONEY,
			rf.CREATE_TIME as "refundCreateTime",
			rf.CREATE_NAME as "refundCreateUser",
fangxinjiang's avatar
fangxinjiang committed
1697
			a.CREATE_USER_DEPT_NAME,
1698 1699
			a.EXPIRE_REMARK,
			a.EXPIRE_IGNORE_FLAG
fangxinjiang's avatar
fangxinjiang committed
1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715
	</sql>
	<sql id="expire_export_sql_param">
		select
			a.id,
			a.EMP_NAME,
			a.EMP_IDCARD_NO,
			a.DEPT_NAME,
			a.DEPT_NO,
			a.INSURANCE_COMPANY_NAME,
			a.INSURANCE_TYPE_NAME,
			a.POLICY_START,
			a.POLICY_END,
			a.BUY_STANDARD,
			a.ACTUAL_PREMIUM,
			a.CREATE_NAME,
			a.CREATE_TIME,
fangxinjiang's avatar
fangxinjiang committed
1716
			"已投保" as "BUY_HANDLE_STATUS",
fangxinjiang's avatar
fangxinjiang committed
1717 1718 1719
			a.POLICY_NO,
			a.MEDICAL_QUOTA,
			a.DIE_DISABLE_QUOTA,
fangxinjiang's avatar
fangxinjiang committed
1720 1721 1722
			case when a.SETTLE_TYPE = 0 then "与薪资结算"
				 when a.SETTLE_TYPE = 1 then "单独结算"
				 else null  end  as  "SETTLE_TYPE" ,
fangxinjiang's avatar
fangxinjiang committed
1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737
			a.SETTLE_MONTH,
			a.INVOICE_NO,
			r2.REPLACE_TIME,
			a.POLICY_EFFECT,
			a.UNIT_NAME as "customerName",
			a.UNIT_NO,
			a.REMARK,
			a.INSURANCE_CITY_NAME,
			case when a.IS_EFFECT = 0 then "有效"
				 when a.IS_EFFECT = 1 then "无效"
				 else null  end  as  "IS_EFFECT" ,
			a.POST,
			r.fromEmpName,
			r.toEmpName,
			r.REPLACE_TIME as "toReplaceTime",
1738 1739
			case when a.IS_OVERDUE = 0 then "临期"
				 when a.IS_OVERDUE = 1 then "过期"
fangxinjiang's avatar
fangxinjiang committed
1740 1741 1742 1743 1744 1745
				 else null  end  as  "IS_OVERDUE" ,
			a.ESTIMATE_PREMIUM,
			rf.REFUND_MONEY,
			rf.CREATE_TIME as "refundCreateTime",
			rf.CREATE_NAME as "refundCreateUser",
			a.CREATE_USER_DEPT_NAME,
1746 1747 1748 1749
			a.EXPIRE_REMARK,
			case when a.EXPIRE_IGNORE_FLAG = 0 then "是"
				 when a.EXPIRE_IGNORE_FLAG = 1 then "否"
				 else null  end  as  "EXPIRE_IGNORE_FLAG"
fangxinjiang's avatar
fangxinjiang committed
1750 1751 1752
	</sql>
	<sql id="expire_sql_where">
		<where>
fangxinjiang's avatar
fangxinjiang committed
1753 1754 1755 1756 1757 1758 1759
			<if test="param != null">
				<if test="param.empName != null and param.empName.trim() != ''">
					AND a.EMP_NAME like CONCAT('%' , #{param.empName},'%')
				</if>
				<if test="param.empIdcardNo != null and param.empIdcardNo.trim() != ''">
					AND a.EMP_IDCARD_NO like CONCAT('%' ,#{param.empIdcardNo},'%')
				</if>
fangxinjiang's avatar
fangxinjiang committed
1760 1761 1762 1763 1764 1765
				<if test="param.insuranceCityName != null and param.insuranceCityName.trim() != ''">
					AND a.INSURANCE_CITY_NAME  like CONCAT(#{param.insuranceCityName},'%')
				</if>
				<if test="param.insuranceHandleCityName != null and param.insuranceHandleCityName.trim() != ''">
					AND a.INSURANCE_HANDLE_CITY_NAME  like CONCAT(#{param.insuranceHandleCityName},'%')
				</if>
1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777
				<if test="param.createName != null and param.createName.trim() != ''">
					AND a.CREATE_NAME = #{param.createName}
				</if>
				<if test="param.expireIgnoreFlag != null and param.expireIgnoreFlag.trim() != ''">
					AND a.EXPIRE_IGNORE_FLAG = #{param.expireIgnoreFlag}
				</if>
				<if test="param.isOverdue != null and param.isOverdue.trim() != ''">
					AND a.IS_OVERDUE = #{param.isOverdue}
				</if>
				<if test="param.createBy != null and param.createBy.trim() != ''">
					and a.CREATE_BY = #{param.createBy}
				</if>
fangxinjiang's avatar
fangxinjiang committed
1778 1779 1780 1781 1782 1783 1784
				<if test="param.idList != null and param.idList.size() > 0">
					and a.id in
					<foreach collection="param.idList" item="param" index="index" open="(" close=")"
							 separator=",">
						#{param}
					</foreach>
				</if>
fangxinjiang's avatar
fangxinjiang committed
1785
			</if>
fangxinjiang's avatar
fangxinjiang committed
1786

fangxinjiang's avatar
fangxinjiang committed
1787 1788
		</where>
	</sql>
1789
	<select id="getInsuranceExpireWarnVoPageHistory" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.TBusinessInsuranceVo">
fangxinjiang's avatar
fangxinjiang committed
1790 1791
		<include refid="expire_sql_param"/>,a.INSURANCE_HANDLE_CITY_NAME
		from
fangxinjiang's avatar
fangxinjiang committed
1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839
		(select  * from
			(select * from t_insurance_detail a
			where
				<!--   info.AUDIT_STATUS='0'  and t.STATUS = 5  状态 0.待提交 1.待办理  2.已提交保险公司  3.已办理  4.办理失败 5:待结算(已输入保单号)-->
				<!--一个月内的,没有再续买商险的数据-->
				a.BUY_HANDLE_STATUS ='3'
				and a.EXPIRE_IGNORE_FLAG='1'
				and (
				date_add(curdate() - day(curdate()) + 1, interval 3 month) >
				a.POLICY_END
				)
				<if test="param != null">
					<if test="param.insuranceProvinces == null and param.insuranceCitys == null and domains == null">
						and a.CREATE_BY = #{param.createBy}
					</if>
					and (1 = 2
					<if test="param.insuranceProvinces != null">
						<if test="param.insuranceProvinces.size() > 0">
							or a.INSURANCE_HANDLE_PROVINCE in
							<foreach collection="param.insuranceProvinces" item="param" index="index" open="(" close=")"
									 separator=",">
								#{param}
							</foreach>

						</if>
					</if>
					<if test="param.insuranceCitys != null">
						<if test="param.insuranceCitys.size() > 0">
							or a.INSURANCE_HANDLE_CITY in
							<foreach collection="param.insuranceCitys" item="param" index="index" open="(" close=")"
									 separator=",">
								#{param}
							</foreach>
						</if>
					</if>
					<!--数据权限判断-->
					or a.CREATE_BY = #{param.createBy}
					<if test="domains != null">
						<if test="domains.size() > 0">
							or a.DEPT_ID in
							<foreach collection="domains" item="param" index="index" open="(" close=")" separator=",">
								#{param}
							</foreach>
						</if>
					</if>
					)
				</if>
			) a
fangxinjiang's avatar
fangxinjiang committed
1840 1841
		<include refid="expire_sql_where"/>
		)   a
fangxinjiang's avatar
fangxinjiang committed
1842 1843 1844
		LEFT JOIN view_insurance_replace r on a.id=r.TO_INSURANCE_DETAIL_ID
		LEFT JOIN view_insurance_replace r2 on a.id=r2.FROM_INSURANCE_DETAIL_ID
		LEFT JOIN t_insurance_refund rf on rf.INS_DETAIL_ID=a.id
fangxinjiang's avatar
fangxinjiang committed
1845
		<include refid="expire_sql_where"/>
fangxinjiang's avatar
fangxinjiang committed
1846 1847
		order by a.CREATE_TIME desc
	</select>
1848 1849 1850 1851 1852 1853 1854 1855 1856 1857

	<select id="getInsuranceExpireWarnVoPage" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.TBusinessInsuranceVo">
		<include refid="expire_sql_param"/>
		,a.INSURANCE_HANDLE_CITY_NAME
		from
		 t_insurance_alert a
		LEFT JOIN view_insurance_replace r on a.id=r.TO_INSURANCE_DETAIL_ID
		LEFT JOIN view_insurance_replace r2 on a.id=r2.FROM_INSURANCE_DETAIL_ID
		LEFT JOIN t_insurance_refund rf on rf.INS_DETAIL_ID=a.id
		<include refid="expire_sql_where"/>
huyuchen's avatar
huyuchen committed
1858
		order by a.POLICY_END asc
1859 1860 1861
	</select>

	<select id="pageDiyHistory" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.TBusinessInsuranceVo">
fangxinjiang's avatar
fangxinjiang committed
1862 1863
		<include refid="expire_sql_param"/>,a.INSURANCE_HANDLE_CITY_NAME
		from
fangxinjiang's avatar
fangxinjiang committed
1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910
		(select  * from (select * from t_insurance_detail a
		where
		<!--   info.AUDIT_STATUS='0'  and t.STATUS = 5  状态 0.待提交 1.待办理  2.已提交保险公司  3.已办理  4.办理失败 5:待结算(已输入保单号)-->
		<!--一个月内的,没有再续买商险的数据-->
		a.BUY_HANDLE_STATUS ='3'
		and a.EXPIRE_IGNORE_FLAG='1'
		and (
		date_add(curdate() - day(curdate()) + 1, interval 3 month) >
		a.POLICY_END
		)
		<if test="param != null">
			<if test="param.insuranceProvinces == null and param.insuranceCitys == null and domains == null">
				and a.CREATE_BY = #{param.createBy}
			</if>
			and (1 = 2
			<if test="param.insuranceProvinces != null">
				<if test="param.insuranceProvinces.size() > 0">
					or a.INSURANCE_HANDLE_PROVINCE in
					<foreach collection="param.insuranceProvinces" item="param" index="index" open="(" close=")"
							 separator=",">
						#{param}
					</foreach>

				</if>
			</if>
			<if test="param.insuranceCitys != null">
				<if test="param.insuranceCitys.size() > 0">
					or a.INSURANCE_HANDLE_CITY in
					<foreach collection="param.insuranceCitys" item="param" index="index" open="(" close=")"
							 separator=",">
						#{param}
					</foreach>
				</if>
			</if>
			<!--数据权限判断-->
			or a.CREATE_BY = #{param.createBy}
			<if test="domains != null">
				<if test="domains.size() > 0">
					or a.DEPT_ID in
					<foreach collection="domains" item="param" index="index" open="(" close=")" separator=",">
						#{param}
					</foreach>
				</if>
			</if>
			)
		</if>
		)  a
fangxinjiang's avatar
fangxinjiang committed
1911 1912 1913 1914 1915 1916
		<include refid="expire_sql_where"/>
		order by a.CREATE_TIME desc
		<if test="param != null and param.limitStart != null">
			limit #{param.limitStart},#{param.limitEnd}
		</if>
		) a
fangxinjiang's avatar
fangxinjiang committed
1917 1918 1919
		LEFT JOIN view_insurance_replace r on a.id=r.TO_INSURANCE_DETAIL_ID
		LEFT JOIN view_insurance_replace r2 on a.id=r2.FROM_INSURANCE_DETAIL_ID
		LEFT JOIN t_insurance_refund rf on rf.INS_DETAIL_ID=a.id
fangxinjiang's avatar
fangxinjiang committed
1920
	</select>
fangxinjiang's avatar
fangxinjiang committed
1921

1922 1923 1924 1925 1926 1927 1928 1929
	<select id="pageDiy" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.TBusinessInsuranceVo">
		<include refid="expire_sql_param"/>
		,a.INSURANCE_HANDLE_CITY_NAME
		from
		t_insurance_alert a
		LEFT JOIN view_insurance_replace r on a.id=r.TO_INSURANCE_DETAIL_ID
		LEFT JOIN view_insurance_replace r2 on a.id=r2.FROM_INSURANCE_DETAIL_ID
		LEFT JOIN t_insurance_refund rf on rf.INS_DETAIL_ID=a.id
fangxinjiang's avatar
fangxinjiang committed
1930
		<include refid="expire_sql_where"/>
huyuchen's avatar
huyuchen committed
1931
		order by a.POLICY_END asc
fangxinjiang's avatar
fangxinjiang committed
1932 1933 1934
		<if test="param != null and param.limitStart != null">
			limit #{param.limitStart},#{param.limitEnd}
		</if>
1935 1936 1937 1938 1939 1940 1941
	</select>

	<select id="noPageDiy" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceWarnExportVo">
		<include refid="expire_export_sql_param"/>
		,a.INSURANCE_HANDLE_CITY_NAME
		from
		t_insurance_alert a
fangxinjiang's avatar
fangxinjiang committed
1942 1943 1944
		LEFT JOIN view_insurance_replace r on a.id=r.TO_INSURANCE_DETAIL_ID
		LEFT JOIN view_insurance_replace r2 on a.id=r2.FROM_INSURANCE_DETAIL_ID
		LEFT JOIN t_insurance_refund rf on rf.INS_DETAIL_ID=a.id
1945
		<include refid="expire_sql_where"/>
fangxinjiang's avatar
fangxinjiang committed
1946
		group by a.id
huyuchen's avatar
huyuchen committed
1947
		order by a.POLICY_END asc
1948 1949 1950
		<if test="param != null and param.limitStart != null">
			limit #{param.limitStart},#{param.limitEnd}
		</if>
fangxinjiang's avatar
fangxinjiang committed
1951 1952 1953 1954
	</select>
	<select id="noPageCountDiy" resultType="java.lang.Integer">
		select
		count(1)
1955 1956
		from
		t_insurance_alert a
fangxinjiang's avatar
fangxinjiang committed
1957
		<include refid="expire_sql_where"/>
fangxinjiang's avatar
fangxinjiang committed
1958
	</select>
1959

fangxinjiang's avatar
fangxinjiang committed
1960 1961
	<update id="batchexpireIgnore">
		<if test="idList != null and idList.size() > 0">
1962
			update t_insurance_detail  a
fangxinjiang's avatar
fangxinjiang committed
1963 1964
			set a.EXPIRE_IGNORE_FLAG = '0'
			where
fangxinjiang's avatar
fangxinjiang committed
1965 1966 1967 1968 1969 1970
			a.id in
			<foreach collection="idList" item="param" index="index" open="(" close=")" separator=",">
				#{param}
			</foreach>
		</if>
	</update>
huyuchen's avatar
huyuchen committed
1971

1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992
	<update id="batchexpireAlertIgnore">
		<if test="idList != null and idList.size() > 0">
			update t_insurance_alert  a
			set a.EXPIRE_IGNORE_FLAG = '0'
			where
			a.id in
			<foreach collection="idList" item="param" index="index" open="(" close=")" separator=",">
				#{param}
			</foreach>
		</if>
	</update>

	<update id="updateExpireAlert">
		update t_insurance_alert
		<trim prefix="set" suffixOverrides=",">
			<if test="expireFlag != null">EXPIRE_IGNORE_FLAG=#{expireFlag},</if>
			<if test="remark != null">EXPIRE_REMARK=#{remark},</if>
		</trim>
		where id = #{id}
	</update>

huyuchen's avatar
huyuchen committed
1993 1994 1995 1996 1997 1998 1999
	<select id="selectPushList" resultType="com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceDetail">
		SELECT
			*
		FROM
			t_insurance_detail
		WHERE ERROR_STATUS = '1'
	</select>
2000
</mapper>