TIncomeMapper.xml 10.3 KB
Newer Older
hongguangwu's avatar
hongguangwu committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~
  ~      Copyright (c) 2018-2025, lengleng All rights reserved.
  ~
  ~  Redistribution and use in source and binary forms, with or without
  ~  modification, are permitted provided that the following conditions are met:
  ~
  ~ Redistributions of source code must retain the above copyright notice,
  ~  this list of conditions and the following disclaimer.
  ~  Redistributions in binary form must reproduce the above copyright
  ~  notice, this list of conditions and the following disclaimer in the
  ~  documentation and/or other materials provided with the distribution.
  ~  Neither the name of the yifu4cloud.com developer nor the names of its
  ~  contributors may be used to endorse or promote products derived from
  ~  this software without specific prior written permission.
  ~  Author: lengleng (wangiegie@gmail.com)
  ~
  -->

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.yifu.cloud.plus.v1.yifu.social.mapper.TIncomeMapper">

	<resultMap id="tIncomeMap" type="com.yifu.cloud.plus.v1.yifu.social.entity.TIncome">
		<id property="id" column="ID"/>
		<result property="empName" column="EMP_NAME"/>
		<result property="empIdcard" column="EMP_IDCARD"/>
		<result property="unitId" column="UNIT_ID"/>
		<result property="unitName" column="UNIT_NAME"/>
		<result property="unitNo" column="UNIT_NO"/>
		<result property="deptId" column="DEPT_ID"/>
		<result property="deptName" column="DEPT_NAME"/>
		<result property="deptNo" column="DEPT_NO"/>
		<result property="feeType" column="FEE_TYPE"/>
		<result property="feeMode" column="FEE_MODE"/>
		<result property="charges" column="CHARGES"/>
		<result property="sourceType" column="SOURCE_TYPE"/>
		<result property="money" column="MONEY"/>
		<result property="createMonth" column="CREATE_MONTH"/>
		<result property="payMonth" column="PAY_MONTH"/>
		<result property="createTime" column="CREATE_TIME"/>
		<result property="dataCreateMonth" column="DATA_CREATE_MONTH"/>
hongguangwu's avatar
hongguangwu committed
45
		<result property="sendStatus" column="SEND_STATUS"/>
hongguangwu's avatar
hongguangwu committed
46
		<result property="redData" column="RED_DATA"/>
hongguangwu's avatar
hongguangwu committed
47 48 49
		<result property="sendStatus" column="SEND_STATUS"/>
		<result property="sendTime" column="SEND_TIME"/>
		<result property="sendMonth" column="SEND_MONTH"/>
huyuchen's avatar
huyuchen committed
50
		<result property="ekpId" column="EKP_ID"/>
51
		<result property="applyNo" column="APPLY_NO"/>
huyuchen's avatar
huyuchen committed
52 53
		<result property="incomeSettleFlag" column="INCOME_SETTLE_FLAG"/>
		<result property="incomeCollectFlag" column="INCOME_COLLECT_FLAG"/>
hongguangwu's avatar
hongguangwu committed
54
	</resultMap>
55 56 57 58 59 60 61 62 63 64 65 66 67 68
	<resultMap id="incomeExportMap" type="com.yifu.cloud.plus.v1.yifu.social.vo.IncomeExportVo">
		<result property="empName" column="EMP_NAME"/>
		<result property="empIdcard" column="EMP_IDCARD"/>
		<result property="unitName" column="UNIT_NAME"/>
		<result property="deptName" column="DEPT_NAME"/>
		<result property="deptNo" column="DEPT_NO"/>
		<result property="feeType" column="FEE_TYPE"/>
		<result property="feeMode" column="FEE_MODE"/>
		<result property="charges" column="CHARGES"/>
		<result property="sourceType" column="SOURCE_TYPE"/>
		<result property="money" column="MONEY"/>
		<result property="createMonth" column="CREATE_MONTH"/>
		<result property="payMonth" column="PAY_MONTH"/>
		<result property="createTime" column="CREATE_TIME"/>
hongguangwu's avatar
hongguangwu committed
69
		<result property="sendStatus" column="SEND_STATUS"/>
70
	</resultMap>
hongguangwu's avatar
hongguangwu committed
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
	<sql id="Base_Column_List">
		a.ID,
		a.EMP_NAME,
		a.EMP_IDCARD,
		a.UNIT_ID,
		a.UNIT_NAME,
		a.UNIT_NO,
		a.DEPT_ID,
		a.DEPT_NAME,
		a.DEPT_NO,
		a.FEE_TYPE,
		a.FEE_MODE,
		a.CHARGES,
		a.SOURCE_TYPE,
		a.MONEY,
		a.CREATE_MONTH,
		a.PAY_MONTH,
		a.CREATE_TIME,
		a.DATA_CREATE_MONTH,
hongguangwu's avatar
hongguangwu committed
90 91 92
		a.RED_DATA,
		a.SEND_STATUS,
		a.SEND_TIME,
93 94
		a.SEND_MONTH,
		a.APPLY_NO
hongguangwu's avatar
hongguangwu committed
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
	</sql>
	<sql id="tIncome_where">
		<if test="tIncome != null">
			<if test="tIncome.id != null and tIncome.id.trim() != ''">
				AND a.ID = #{tIncome.id}
			</if>
			<if test="tIncome.empName != null and tIncome.empName.trim() != ''">
				AND a.EMP_NAME = #{tIncome.empName}
			</if>
			<if test="tIncome.empIdcard != null and tIncome.empIdcard.trim() != ''">
				AND a.EMP_IDCARD = #{tIncome.empIdcard}
			</if>
			<if test="tIncome.unitId != null and tIncome.unitId.trim() != ''">
				AND a.UNIT_ID = #{tIncome.unitId}
			</if>
			<if test="tIncome.unitName != null and tIncome.unitName.trim() != ''">
				AND a.UNIT_NAME = #{tIncome.unitName}
			</if>
			<if test="tIncome.unitNo != null and tIncome.unitNo.trim() != ''">
				AND a.UNIT_NO = #{tIncome.unitNo}
			</if>
			<if test="tIncome.deptId != null and tIncome.deptId.trim() != ''">
				AND a.DEPT_ID = #{tIncome.deptId}
			</if>
			<if test="tIncome.deptName != null and tIncome.deptName.trim() != ''">
				AND a.DEPT_NAME = #{tIncome.deptName}
			</if>
			<if test="tIncome.deptNo != null and tIncome.deptNo.trim() != ''">
				AND a.DEPT_NO = #{tIncome.deptNo}
			</if>
			<if test="tIncome.feeType != null and tIncome.feeType.trim() != ''">
				AND a.FEE_TYPE = #{tIncome.feeType}
			</if>
			<if test="tIncome.feeMode != null and tIncome.feeMode.trim() != ''">
				AND a.FEE_MODE = #{tIncome.feeMode}
			</if>
			<if test="tIncome.charges != null and tIncome.charges.trim() != ''">
				AND a.CHARGES = #{tIncome.charges}
			</if>
			<if test="tIncome.sourceType != null and tIncome.sourceType.trim() != ''">
				AND a.SOURCE_TYPE = #{tIncome.sourceType}
			</if>
			<if test="tIncome.money != null">
				AND a.MONEY = #{tIncome.money}
			</if>
			<if test="tIncome.createMonth != null and tIncome.createMonth.trim() != ''">
				AND a.CREATE_MONTH = #{tIncome.createMonth}
			</if>
			<if test="tIncome.payMonth != null and tIncome.payMonth.trim() != ''">
				AND a.PAY_MONTH = #{tIncome.payMonth}
			</if>
			<if test="tIncome.dataCreateMonth != null and tIncome.dataCreateMonth.trim() != ''">
				AND a.DATA_CREATE_MONTH = #{tIncome.dataCreateMonth}
			</if>
hongguangwu's avatar
hongguangwu committed
149 150
			<if test="tIncome.sendStatus != null and tIncome.sendStatus.trim() != ''">
				AND a.SEND_STATUS = #{tIncome.sendStatus}
hongguangwu's avatar
hongguangwu committed
151
			</if>
hongguangwu's avatar
hongguangwu committed
152 153 154
			<if test="tIncome.redData != null and tIncome.redData.trim() != ''">
				AND a.RED_DATA = #{tIncome.redData}
			</if>
155 156 157
			<if test="tIncome.applyNo != null and tIncome.applyNo.trim() != ''">
				AND a.APPLY_NO = #{tIncome.applyNo}
			</if>
huyuchen's avatar
huyuchen committed
158 159 160
			<if test="tIncome.authSql != null and tIncome.authSql.trim() != ''">
				${tIncome.authSql}
			</if>
hongguangwu's avatar
hongguangwu committed
161 162 163 164 165 166 167 168 169 170
		</if>
	</sql>
	<!--tIncome简单分页查询-->
	<select id="getTIncomePage" resultMap="tIncomeMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_income a
		<where>
			1=1
			<include refid="tIncome_where"/>
171
			order by a.CREATE_TIME DESC
hongguangwu's avatar
hongguangwu committed
172 173
		</where>
	</select>
174 175 176 177

	<!--noPageDiy查询-->
	<select id="noPageDiy" resultMap="incomeExportMap">
		SELECT
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
			a.ID,
			a.EMP_NAME,
			a.EMP_IDCARD,
			a.UNIT_NAME,
			a.UNIT_NO,
			a.DEPT_NAME,
			a.DEPT_NO,
			if(a.FEE_TYPE=1,'管理费','风险金') FEE_TYPE,
			if(a.FEE_MODE=1,'按比例',if(a.FEE_MODE=2,'金额-人数','金额-人次')) FEE_MODE,
			a.CHARGES,
			case a.SOURCE_TYPE when 1 then '社保'  when 2 then '公积金'  when 3 then '商险' else '薪资' end SOURCE_TYPE,
			a.MONEY,
			a.CREATE_MONTH,
			a.PAY_MONTH,
			a.CREATE_TIME,
			a.DATA_CREATE_MONTH,
			if(a.SEND_STATUS=0,'未推送','已推送') SEND_STATUS,
			a.SEND_TIME,
			a.SEND_MONTH,
			a.APPLY_NO
198 199 200 201
		FROM t_income a
		<where>
			1=1
			<include refid="export_sql"/>
fangxinjiang's avatar
fangxinjiang committed
202
			order by a.CREATE_TIME DESC
203 204 205 206 207 208 209 210 211 212 213
			<if test="tIncome != null">
				<if test="tIncome.limitStart != null">
					limit #{tIncome.limitStart},#{tIncome.limitEnd}
				</if>
			</if>
		</where>
	</select>

	<!--noPageCountDiy查询-->
	<select id="noPageCountDiy" resultType="java.lang.Integer">
		SELECT
huyuchen's avatar
huyuchen committed
214 215 216
		count(1) from(
		SELECT
		a.id
217 218 219 220
		FROM t_income a
		<where>
			1=1
			<include refid="export_sql"/>
huyuchen's avatar
huyuchen committed
221
			group by a.id
222
		</where>
huyuchen's avatar
huyuchen committed
223
		) b
224
	</select>
hongguangwu's avatar
hongguangwu committed
225 226 227 228 229 230 231 232 233 234 235

	<!-- 列表 -->
	<select id="getTIncomeList" resultMap="tIncomeMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_income a
		<where>
			1=1
			<include refid="tIncome_where"/>
		</where>
	</select>
236 237 238 239 240 241 242 243 244
	<sql id="export_sql">
		<include refid="tIncome_where"/>
		<if test="idsStr != null and idsStr.size > 0">
			AND a.ID in
			<foreach item="items" index="index" collection="idsStr" open="(" separator="," close=")">
				#{items}
			</foreach>
		</if>
	</sql>
huyuchen's avatar
huyuchen committed
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282

	<update id="updateIncomeById" parameterType="java.util.List">
		update t_income
		<trim prefix="set" suffixOverrides=",">
			<trim prefix="SEND_STATUS =case" suffix="end,">
				<foreach collection="list" item="i" index="index">
					<if test="i.sendStatus!=null">
						when ID=#{i.id} then #{i.sendStatus}
					</if>
				</foreach>
			</trim>
			<trim prefix="SEND_TIME =case" suffix="end,">
				<foreach collection="list" item="i" index="index">
					<if test="i.sendTime!=null">
						when ID=#{i.id} then #{i.sendTime}
					</if>
				</foreach>
			</trim>
			<trim prefix="SEND_MONTH =case" suffix="end,">
				<foreach collection="list" item="i" index="index">
					<if test="i.sendMonth!=null">
						when ID=#{i.id} then #{i.sendMonth}
					</if>
				</foreach>
			</trim>
			<trim prefix="EKP_ID =case" suffix="end,">
				<foreach collection="list" item="i" index="index">
					<if test="i.ekpId!=null">
						when ID=#{i.id} then #{i.ekpId}
					</if>
				</foreach>
			</trim>
		</trim>
		where
		<foreach collection="list" separator="or" item="i" index="index" >
			ID=#{i.id}
		</foreach>
	</update>
283 284 285 286 287 288 289

	<delete id="deleteIncomeByApplyNo">
		delete from t_income_detail where APPLY_NO = #{applyNo}
	</delete>
	<delete id="deleteIncomeDetailByApplyNo">
		delete from t_income where APPLY_NO = #{applyNo}
	</delete>
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320

	<!-- ekp费用划转-收入 -->
	<update id="changeIncomeDept">
		update t_income 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>

	<!-- ekp费用划转-明细 -->
	<update id="changeIncomeDetailDept">
		update t_income_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>

hongguangwu's avatar
hongguangwu committed
321
</mapper>