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

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

1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372
	<!-- 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>

1373 1374 1375 1376 1377 1378 1379 1380

	<!--查询所有商险,如果idList 不为空,则不含被替换的本身。 用来改变档案状态-->
	<select id="selectByIdCardList" resultMap="BaseResultMap">
		SELECT
			<include refid="Base_Column_List"/>
		FROM
		t_insurance_detail
		where
1381 1382 1383
			DELETE_FLAG = 0
		<if test="idCardList != null and idCardList.size > 0">
			AND EMP_IDCARD_NO in
1384 1385 1386
			<foreach item="item" index="index" collection="idCardList" open="(" separator="," close=")">
				#{item}
			</foreach>
1387 1388
		</if>
			<if test="idList != null and idList.size > 0">
1389 1390 1391 1392 1393 1394 1395
				AND id not in
				<foreach item="item" index="index" collection="idList" open="(" separator="," close=")">
					#{item}
				</foreach>
			</if>
	</select>

huyuchen's avatar
huyuchen committed
1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409
	<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>

1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 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

	<!--	退保退费分页查询-->
	<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>
1481 1482 1483 1484 1485 1486
		<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>
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 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
		<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>
1562 1563 1564 1565 1566 1567
		<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>
1568 1569 1570 1571 1572
		<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
1573

fangxinjiang's avatar
fangxinjiang committed
1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 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
	<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
1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656
		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
1657
			a.UNIT_NAME as "customerName",
fangxinjiang's avatar
fangxinjiang committed
1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671
			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
1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689
			a.CREATE_USER_DEPT_NAME,
			a.EXPIRE_REMARK
	</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
1690
			"已投保" as "BUY_HANDLE_STATUS",
fangxinjiang's avatar
fangxinjiang committed
1691 1692 1693
			a.POLICY_NO,
			a.MEDICAL_QUOTA,
			a.DIE_DISABLE_QUOTA,
fangxinjiang's avatar
fangxinjiang committed
1694 1695 1696
			case when a.SETTLE_TYPE = 0 then "与薪资结算"
				 when a.SETTLE_TYPE = 1 then "单独结算"
				 else null  end  as  "SETTLE_TYPE" ,
fangxinjiang's avatar
fangxinjiang committed
1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720
			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",
			case when a.IS_OVERDUE = 0 then "未过期"
				 when a.IS_OVERDUE = 1 then "已过期"
				 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,
			a.EXPIRE_REMARK
fangxinjiang's avatar
fangxinjiang committed
1721 1722 1723
	</sql>
	<sql id="expire_sql_where">
		<where>
fangxinjiang's avatar
fangxinjiang committed
1724

fangxinjiang's avatar
fangxinjiang committed
1725 1726 1727 1728 1729 1730 1731
			<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
1732 1733 1734 1735 1736 1737
				<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>
fangxinjiang's avatar
fangxinjiang committed
1738 1739 1740 1741 1742 1743 1744
				<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
1745
			</if>
fangxinjiang's avatar
fangxinjiang committed
1746

fangxinjiang's avatar
fangxinjiang committed
1747 1748
		</where>
	</sql>
fangxinjiang's avatar
fangxinjiang committed
1749
	<select id="getInsuranceExpireWarnVoPage" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.TBusinessInsuranceVo">
fangxinjiang's avatar
fangxinjiang committed
1750 1751
		<include refid="expire_sql_param"/>,a.INSURANCE_HANDLE_CITY_NAME
		from
fangxinjiang's avatar
fangxinjiang committed
1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799
		(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
1800 1801
		<include refid="expire_sql_where"/>
		)   a
fangxinjiang's avatar
fangxinjiang committed
1802 1803 1804
		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
1805
		<include refid="expire_sql_where"/>
fangxinjiang's avatar
fangxinjiang committed
1806 1807
		order by a.CREATE_TIME desc
	</select>
fangxinjiang's avatar
fangxinjiang committed
1808 1809 1810
	<select id="pageDiy" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.TBusinessInsuranceVo">
		<include refid="expire_sql_param"/>,a.INSURANCE_HANDLE_CITY_NAME
		from
fangxinjiang's avatar
fangxinjiang committed
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 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857
		(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
1858 1859 1860 1861 1862 1863
		<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
1864 1865 1866
		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
1867 1868
	</select>
	<select id="noPageDiy" resultType="com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceWarnExportVo">
fangxinjiang's avatar
fangxinjiang committed
1869
		<include refid="expire_export_sql_param"/>,a.INSURANCE_HANDLE_CITY_NAME
fangxinjiang's avatar
fangxinjiang committed
1870
		from
fangxinjiang's avatar
fangxinjiang committed
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 1911 1912 1913 1914 1915 1916 1917
		(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
1918 1919 1920 1921 1922
		<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>
fangxinjiang's avatar
fangxinjiang committed
1923 1924 1925 1926 1927 1928
		)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
		group by a.id

fangxinjiang's avatar
fangxinjiang committed
1929 1930 1931 1932
	</select>
	<select id="noPageCountDiy" resultType="java.lang.Integer">
		select
		count(1)
fangxinjiang's avatar
fangxinjiang committed
1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979
		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
1980
		<!--LEFT JOIN view_insurance_replace r on a.id=r.TO_INSURANCE_DETAIL_ID
fangxinjiang's avatar
fangxinjiang committed
1981
		LEFT JOIN view_insurance_replace r2 on a.id=r2.FROM_INSURANCE_DETAIL_ID
fangxinjiang's avatar
fangxinjiang committed
1982
		LEFT JOIN t_insurance_refund rf on rf.INS_DETAIL_ID=a.id-->
fangxinjiang's avatar
fangxinjiang committed
1983
		<include refid="expire_sql_where"/>
fangxinjiang's avatar
fangxinjiang committed
1984
	</select>
fangxinjiang's avatar
fangxinjiang committed
1985 1986
	<update id="batchexpireIgnore">
		<if test="idList != null and idList.size() > 0">
fangxinjiang's avatar
fangxinjiang committed
1987 1988 1989
			update  t_insurance_detail  a
			set a.EXPIRE_IGNORE_FLAG = '0'
			where
fangxinjiang's avatar
fangxinjiang committed
1990 1991 1992 1993 1994 1995
			a.id in
			<foreach collection="idList" item="param" index="index" open="(" close=")" separator=",">
				#{param}
			</foreach>
		</if>
	</update>
huyuchen's avatar
huyuchen committed
1996

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