<?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.archives.mapper.TGzOfferInfoMapper">

	<resultMap id="tGzOfferInfoMap" type="com.yifu.cloud.plus.v1.yifu.archives.vo.TGzOfferInfoVo">
		<id property="id" column="id"/>
		<result property="bizId" column="biz_id"/>
		<result property="offerStatus" column="offer_status"/>
		<result property="offerSendStatus" column="offer_send_status"/>
		<result property="updateBy" column="update_by"/>
		<result property="updateTime" column="update_time"/>
		<result property="emplType" column="empl_type"/>
		<result property="emplTypeDescr" column="empl_type_descr"/>
		<result property="outSginType" column="out_sgin_type"/>
		<result property="company" column="company"/>
		<result property="name" column="name"/>
		<result property="nameAc" column="name_ac"/>
		<result property="lastNameAc" column="last_name_ac"/>
		<result property="firstNameAc" column="first_name_ac"/>
		<result property="country" column="country"/>
		<result property="countryDescr" column="country_descr"/>
		<result property="nationalIdType" column="national_id_type"/>
		<result property="nationalIdTypeDescr" column="national_id_type_descr"/>
		<result property="nationalId" column="national_id"/>
		<result property="sex" column="sex"/>
		<result property="phone" column="phone"/>
		<result property="email" column="email"/>
		<result property="supervisorName" column="supervisor_name"/>
		<result property="jobcodeDescr" column="jobcode_descr"/>
		<result property="workLocation" column="work_location"/>
		<result property="workLocationDescr" column="work_location_descr"/>
		<result property="expEntryDate" column="exp_entry_date"/>
		<result property="deptName" column="dept_name"/>
		<result property="basePay" column="base_pay"/>
		<result property="perfomPay" column="perfom_pay"/>
		<result property="yearBonusMonth" column="year_bonus_month"/>
		<result property="socialInsuranceLocation" column="social_insurance_location"/>
		<result property="socialInsuranceLocationDescr" column="social_insurance_location_descr"/>
		<result property="socialInsuranceBase" column="social_insurance_base"/>
		<result property="houseAccFundBaseMax" column="house_acc_fund_base_max"/>
		<result property="beRegularEmpPay" column="be_regular_emp_pay"/>
		<result property="applyUserEmail" column="apply_user_email"/>
		<result property="delFlag" column="del_flag"/>
		<result property="createTime" column="create_time"/>
		<result property="createBy" column="create_by"/>
		<result property="createName" column="create_name"/>
		<result property="updateBy" column="update_by"/>
		<result property="updateTime" column="update_time"/>
	</resultMap>
	<sql id="Base_Column_List">
                a.id,
                a.biz_id,
                a.offer_status,
                a.offer_send_status,
                a.update_by,
                a.update_time,
                a.empl_type,
                a.empl_type_descr,
                a.out_sgin_type,
                a.company,
                a.name,
                a.name_ac,
                a.last_name_ac,
                a.first_name_ac,
                a.country,
                a.country_descr,
                a.national_id_type,
                a.national_id_type_descr,
                a.national_id,
                a.sex,
                a.phone,
                a.email,
                a.supervisor_name,
                a.jobcode_descr,
                a.work_location,
                a.work_location_descr,
                a.exp_entry_date,
                a.dept_name,
                a.base_pay,
                a.perfom_pay,
                a.year_bonus_month,
                a.social_insurance_location,
                a.social_insurance_location_descr,
                a.social_insurance_base,
                a.house_acc_fund_base_max,
                a.be_regular_emp_pay,
                a.apply_user_email,
                a.del_flag,
                a.create_time,
                a.create_by,
                a.create_name,
                a.update_by,
                a.update_time
    </sql>
	<sql id="tGzOfferInfo_where">
		<if test="tGzOfferInfo != null">
			<if test="tGzOfferInfo.id != null">
				AND a.id = #{tGzOfferInfo.id}
			</if>
			<if test="tGzOfferInfo.bizId != null and tGzOfferInfo.bizId.trim() != ''">
				AND a.biz_id = #{tGzOfferInfo.bizId}
			</if>
			<if test="tGzOfferInfo.createTime != null">
				AND a.create_time = #{tGzOfferInfo.receiveTime}
			</if>
			<!--查询接收时间-->
			<if test="tGzOfferInfo.createTimeStart != null ">
				AND a.create_time &gt;= #{tGzOfferInfo.createTimeStart}
			</if>
			<if test="tGzOfferInfo.createTimeEnd != null ">
				AND a.create_time &lt;= #{tGzOfferInfo.createTimeEnd}
			</if>
			<if test="tGzOfferInfo.offerStatus != null and tGzOfferInfo.offerStatus.trim() != ''">
				AND a.offer_status = #{tGzOfferInfo.offerStatus}
			</if>
			<if test="tGzOfferInfo.offerSendStatus != null and tGzOfferInfo.offerSendStatus.trim() != ''">
				AND a.offer_send_status = #{tGzOfferInfo.offerSendStatus}
			</if>
			<if test="tGzOfferInfo.offerStatusArray != null and tGzOfferInfo.offerStatusArray.length > 0">
				AND a.offer_status in
				<foreach item="item" index="index" collection="tGzOfferInfo.offerStatusArray" open="(" separator="," close=")">
					'${item}'
				</foreach>
			</if>
			<if test="tGzOfferInfo.statusList != null and tGzOfferInfo.statusList.size() > 0">
				AND a.offer_status in
				<foreach item="item" index="index" collection="tGzOfferInfo.statusList" open="(" separator="," close=")">
					'${item}'
				</foreach>
			</if>
			<if test="tGzOfferInfo.updateBy != null and tGzOfferInfo.updateBy.trim() != ''">
				AND a.update_by = #{tGzOfferInfo.updateBy}
			</if>
			<if test="tGzOfferInfo.updateTime != null">
				AND a.update_time = #{tGzOfferInfo.updateTime}
			</if>
			<if test="tGzOfferInfo.outSginType != null and tGzOfferInfo.outSginType.trim() != ''">
				AND a.out_sgin_type = #{tGzOfferInfo.outSginType}
			</if>
			<if test="tGzOfferInfo.company != null and tGzOfferInfo.company.trim() != ''">
				AND a.company = #{tGzOfferInfo.company}
			</if>
			<if test="tGzOfferInfo.name != null and tGzOfferInfo.name.trim() != ''">
				AND a.name like concat('%',#{tGzOfferInfo.name},'%')
			</if>
			<if test="tGzOfferInfo.nameAc != null and tGzOfferInfo.nameAc.trim() != ''">
				AND a.name_ac = #{tGzOfferInfo.nameAc}
			</if>
			<if test="tGzOfferInfo.lastNameAc != null and tGzOfferInfo.lastNameAc.trim() != ''">
				AND a.last_name_ac = #{tGzOfferInfo.lastNameAc}
			</if>
			<if test="tGzOfferInfo.firstNameAc != null and tGzOfferInfo.firstNameAc.trim() != ''">
				AND a.first_name_ac = #{tGzOfferInfo.firstNameAc}
			</if>
			<if test="tGzOfferInfo.country != null and tGzOfferInfo.country.trim() != ''">
				AND a.country = #{tGzOfferInfo.country}
			</if>
			<if test="tGzOfferInfo.countryDescr != null and tGzOfferInfo.countryDescr.trim() != ''">
				AND a.country_descr = #{tGzOfferInfo.countryDescr}
			</if>
			<if test="tGzOfferInfo.nationalIdType != null and tGzOfferInfo.nationalIdType.trim() != ''">
				AND a.national_id_type = #{tGzOfferInfo.nationalIdType}
			</if>
			<if test="tGzOfferInfo.nationalIdTypeDescr != null and tGzOfferInfo.nationalIdTypeDescr.trim() != ''">
				AND a.national_id_type_descr = #{tGzOfferInfo.nationalIdTypeDescr}
			</if>
			<if test="tGzOfferInfo.nationalId != null and tGzOfferInfo.nationalId.trim() != ''">
				AND a.national_id like concat('%',#{tGzOfferInfo.nationalId},'%')
			</if>
			<if test="tGzOfferInfo.sex != null and tGzOfferInfo.sex.trim() != ''">
				AND a.sex = #{tGzOfferInfo.sex}
			</if>
			<if test="tGzOfferInfo.phone != null and tGzOfferInfo.phone.trim() != ''">
				AND a.phone = #{tGzOfferInfo.phone}
			</if>
			<if test="tGzOfferInfo.email != null and tGzOfferInfo.email.trim() != ''">
				AND a.email = #{tGzOfferInfo.email}
			</if>
			<if test="tGzOfferInfo.supervisorName != null and tGzOfferInfo.supervisorName.trim() != ''">
				AND a.supervisor_name = #{tGzOfferInfo.supervisorName}
			</if>
			<if test="tGzOfferInfo.jobcodeDescr != null and tGzOfferInfo.jobcodeDescr.trim() != ''">
				AND a.jobcode_descr = #{tGzOfferInfo.jobcodeDescr}
			</if>
			<if test="tGzOfferInfo.workLocation != null and tGzOfferInfo.workLocation.trim() != ''">
				AND a.work_location = #{tGzOfferInfo.workLocation}
			</if>
			<if test="tGzOfferInfo.workLocationDescr != null and tGzOfferInfo.workLocationDescr.trim() != ''">
				AND a.work_location_descr = #{tGzOfferInfo.workLocationDescr}
			</if>
			<if test="tGzOfferInfo.expEntryDate != null">
				AND a.exp_entry_date = #{tGzOfferInfo.expEntryDate}
			</if>
			<if test="tGzOfferInfo.deptName != null and tGzOfferInfo.deptName.trim() != ''">
				AND a.dept_name = #{tGzOfferInfo.deptName}
			</if>
			<if test="tGzOfferInfo.basePay != null">
				AND a.base_pay = #{tGzOfferInfo.basePay}
			</if>
			<if test="tGzOfferInfo.perfomPay != null">
				AND a.perfom_pay = #{tGzOfferInfo.perfomPay}
			</if>
			<if test="tGzOfferInfo.yearBonusMonth != null">
				AND a.year_bonus_month = #{tGzOfferInfo.yearBonusMonth}
			</if>
			<if test="tGzOfferInfo.socialInsuranceLocation != null and tGzOfferInfo.socialInsuranceLocation.trim() != ''">
				AND a.social_insurance_location = #{tGzOfferInfo.socialInsuranceLocation}
			</if>
			<if test="tGzOfferInfo.socialInsuranceLocationDescr != null and tGzOfferInfo.socialInsuranceLocationDescr.trim() != ''">
				AND a.social_insurance_location_descr = #{tGzOfferInfo.socialInsuranceLocationDescr}
			</if>
			<if test="tGzOfferInfo.socialInsuranceBase != null">
				AND a.social_insurance_base = #{tGzOfferInfo.socialInsuranceBase}
			</if>
			<if test="tGzOfferInfo.houseAccFundBaseMax != null">
				AND a.house_acc_fund_base_max = #{tGzOfferInfo.houseAccFundBaseMax}
			</if>
			<if test="tGzOfferInfo.beRegularEmpPay != null and tGzOfferInfo.beRegularEmpPay.trim() != ''">
				AND a.be_regular_emp_pay = #{tGzOfferInfo.beRegularEmpPay}
			</if>
			<if test="tGzOfferInfo.applyUserEmail != null and tGzOfferInfo.applyUserEmail.trim() != ''">
				AND a.apply_user_email = #{tGzOfferInfo.applyUserEmail}
			</if>
			<if test="tGzOfferInfo.delFlag != null and tGzOfferInfo.delFlag.trim() != ''">
				AND a.del_flag = #{tGzOfferInfo.delFlag}
			</if>
		</if>
	</sql>
	<!--根据ID获取信息-->
	<select id="getInfoById" resultMap="tGzOfferInfoMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_gz_offer_info a
		where a.del_flag = '0' AND a.id = #{id} limit 1
	</select>

	<!--tGzOfferInfo简单分页查询-->
	<select id="getTGzOfferInfoPage" resultMap="tGzOfferInfoMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_gz_offer_info a
		<where>
			a.del_flag = '0'
			<include refid="tGzOfferInfo_where"/>
		</where>
		ORDER by a.create_time desc,a.id desc
	</select>

	<!--tGzOfferInfo待发送短信数据查询-->
	<select id="getTGzOfferInfoSendAlertList" resultMap="tGzOfferInfoMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_gz_offer_info a
		<where>
			a.del_flag = '0'
			<include refid="tGzOfferInfo_where"/>
		</where>
	</select>

	<!--根据条件获取指定条数限制的列表-->
	<select id="getTGzOfferInfoListHaveLimit" resultMap="tGzOfferInfoMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_gz_offer_info a
		<where>
			a.del_flag = '0'
			<include refid="tGzOfferInfo_where"/>
		</where>
		ORDER by a.create_time desc,a.id desc limit #{limitCount}
	</select>

	<!--根据条件获取数量-->
	<select id="getTGzOfferInfoCount" resultType="integer">
		SELECT count(1) FROM t_gz_offer_info a
		<where>
			a.del_flag = '0'
			<include refid="tGzOfferInfo_where"/>
		</where>
	</select>

	<!--导出先查条数-->
	<select id="getTGzOfferCount" resultType="java.lang.Integer">
		SELECT
			count(1)
		FROM t_gz_offer_info a
		where a.del_flag = '0'
		<include refid="tGzOfferInfo_where"/>
	</select>

	<!-- 导出ORRER字段 -->
	<sql id="Export_Column_List">
		a.biz_id,
		a.offer_status,
		a.offer_send_status,
		a.update_by,
		a.update_time,
		a.empl_type,
		a.empl_type_descr,
		a.out_sgin_type,
		a.company,
		a.name,
		a.name_ac,
		a.last_name_ac,
		a.first_name_ac,
		a.country,
		a.country_descr,
		a.national_id_type,
		a.national_id_type_descr,
		a.national_id,
		a.sex,
		a.phone,
		a.email,
		a.supervisor_name,
		a.jobcode_descr,
		a.work_location,
		a.work_location_descr,
		date_format(a.exp_entry_date, '%Y-%m-%d') exp_entry_date,
		a.dept_name,
		a.base_pay,
		a.perfom_pay,
		a.year_bonus_month,
		a.social_insurance_location,
		a.social_insurance_location_descr,
		a.social_insurance_base,
		a.house_acc_fund_base_max,
		a.be_regular_emp_pay,
		a.apply_user_email,
		date_format(a.create_time, '%Y-%m-%d %H:%i:%s') create_time
	</sql>

	<!--导出主表-->
	<select id="getTGzOfferMainList" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TGzOfferInfoExportMainVo">
		SELECT
			<include refid="Export_Column_List"/>
		FROM t_gz_offer_info a
		where a.del_flag = '0'
		<include refid="tGzOfferInfo_where"/>
		ORDER by a.create_time desc,a.id desc
		<if test="tGzOfferInfo.limitStart != null">
			limit #{tGzOfferInfo.limitStart},#{tGzOfferInfo.limitEnd}
		</if>
	</select>
	<!--导出详情-->
	<select id="getTGzOfferDetailList" resultType="com.yifu.cloud.plus.v1.yifu.archives.vo.TGzOfferInfoExportDetailVo">
		SELECT
		<include refid="Export_Column_List"/>
		FROM t_gz_offer_info a
		where a.del_flag = '0'
		<include refid="tGzOfferInfo_where"/>
		ORDER by a.create_time desc,a.id desc
		<if test="tGzOfferInfo.limitStart != null">
			limit #{tGzOfferInfo.limitStart},#{tGzOfferInfo.limitEnd}
		</if>
	</select>

</mapper>
