<?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.TSocialSoldierShenBaoTaskMapper">

	<resultMap id="tSocialSoldierShenBaoTaskMap" type="com.yifu.cloud.plus.v1.yifu.social.entity.TSocialSoldierShenBaoTask">
		<id property="id" column="ID"/>
		<result property="addId" column="ADD_ID"/>
		<result property="type" column="TYPE"/>
		<result property="dataStatus" column="DATA_STATUS"/>
		<result property="createBy" column="CREATE_BY"/>
		<result property="updateBy" column="UPDATE_BY"/>
		<result property="createName" column="CREATE_NAME"/>
		<result property="updateTime" column="UPDATE_TIME"/>
		<result property="createTime" column="CREATE_TIME"/>
	</resultMap>
	<sql id="Base_Column_List">
		a.ID,
		a.ADD_ID,
		a.TYPE,
		a.DATA_STATUS,
		a.CREATE_BY,
		a.UPDATE_BY,
		a.CREATE_NAME,
		a.UPDATE_TIME,
		a.CREATE_TIME
	</sql>
	<sql id="tSocialSoldierShenBaoTask_where">
		<if test="tSocialSoldierShenBaoTask != null">
			<if test="tSocialSoldierShenBaoTask.id != null and tSocialSoldierShenBaoTask.id.trim() != ''">
				AND a.ID = #{tSocialSoldierShenBaoTask.id}
			</if>
			<if test="tSocialSoldierShenBaoTask.addId != null and tSocialSoldierShenBaoTask.addId.trim() != ''">
				AND a.ADD_ID = #{tSocialSoldierShenBaoTask.addId}
			</if>
			<if test="tSocialSoldierShenBaoTask.type != null and tSocialSoldierShenBaoTask.type.trim() != ''">
				AND a.TYPE = #{tSocialSoldierShenBaoTask.type}
			</if>
			<if test="tSocialSoldierShenBaoTask.dataStatus != null and tSocialSoldierShenBaoTask.dataStatus.trim() != ''">
				AND a.DATA_STATUS = #{tSocialSoldierShenBaoTask.dataStatus}
			</if>
			<if test="tSocialSoldierShenBaoTask.createBy != null and tSocialSoldierShenBaoTask.createBy.trim() != ''">
				AND a.CREATE_BY = #{tSocialSoldierShenBaoTask.createBy}
			</if>
			<if test="tSocialSoldierShenBaoTask.updateBy != null and tSocialSoldierShenBaoTask.updateBy.trim() != ''">
				AND a.UPDATE_BY = #{tSocialSoldierShenBaoTask.updateBy}
			</if>
			<if test="tSocialSoldierShenBaoTask.createName != null and tSocialSoldierShenBaoTask.createName.trim() != ''">
				AND a.CREATE_NAME = #{tSocialSoldierShenBaoTask.createName}
			</if>
			<if test="tSocialSoldierShenBaoTask.updateTime != null">
				AND a.UPDATE_TIME = #{tSocialSoldierShenBaoTask.updateTime}
			</if>
			<if test="tSocialSoldierShenBaoTask.createTime != null">
				AND a.CREATE_TIME = #{tSocialSoldierShenBaoTask.createTime}
			</if>
		</if>
	</sql>
	<!--list-->
	<select id="getTSocialSoldierShenBaoTaskList" resultMap="tSocialSoldierShenBaoTaskMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_social_soldier_shen_bao_task a
		<where>
			1=1
			<include refid="tSocialSoldierShenBaoTask_where"/>
		</where>
	</select>
	<!--获取任务id-->
	<select id="getSoldierTaskAddIdByType" resultMap="tSocialSoldierShenBaoTaskMap">
		SELECT
			<include refid="Base_Column_List"/>
		FROM t_social_soldier_shen_bao_task a
		where a.TYPE = #{type} and a.DATA_STATUS = '0'
		ORDER BY a.CREATE_TIME desc limit 1
	</select>


	<!--list-->
	<select id="getTSocialSoldierTaskListByRe" resultMap="tSocialSoldierShenBaoTaskMap">
		SELECT
			<include refid="Base_Column_List"/>
		FROM t_social_soldier_shen_bao_task a
		where TYPE in ('7','8','9','10')
	</select>

	<delete id="deleteByPayment">
		delete FROM t_social_soldier_shen_bao_task where TYPE in ('3','4','5','6')
	</delete>

	<delete id="deleteByRePayment">
		delete FROM t_social_soldier_shen_bao_task where TYPE in ('7','8','9','10')
	</delete>
</mapper>