|
- <?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">
- <mapper namespace="com.iformall.mapper.WxOfflineActivityMapper">
-
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxOfflineActivity">
- <id property="id" column="id" jdbcType="BIGINT"/>
- <result property="tenantId" column="tenant_id" jdbcType="VARCHAR"/>
- <result property="parentTenantId" column="parent_tenant_id" jdbcType="VARCHAR"/>
- <result property="name" column="name" jdbcType="VARCHAR"/>
- <result property="startTime" column="start_time" jdbcType="TIMESTAMP"/>
- <result property="endTime" column="end_time" jdbcType="TIMESTAMP"/>
- <result property="creditOnOff" column="credit_on_off" jdbcType="SMALLINT"/>
- <result property="creditConfig" column="credit_config" jdbcType="VARCHAR"/>
- <result property="status" column="status" jdbcType="SMALLINT"/>
- <result property="createDate" column="create_date" jdbcType="TIMESTAMP"/>
- <result property="updateDate" column="update_date" jdbcType="TIMESTAMP"/>
- <result property="allMerchant" column="all_merchant" jdbcType="SMALLINT"/>
- </resultMap>
-
- <sql id="allColumns">
- id,tenant_id,parent_tenant_id,
- `name`,start_time,end_time,
- credit_on_off,credit_config,
- status,create_date,update_date,
- all_merchant
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1 = 1
-
- <if test=" null != id ">
- and `id` = #{id}
- </if>
-
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
-
- <if test=" null != begin">
- and `start_time` >= #{begin}
- </if>
-
- <if test=" null != end">
- and `end_time` <= #{end}
- </if>
-
- <if test=" null != allMerchant">
- and `all_merchant` = #{allMerchant}
- </if>
-
- <!-- 未过期 -->
- <if test=" 0 == validStatus">
- and end_time >= now()
- </if>
-
- <!-- 已过期 -->
- <if test=" 1 == validStatus">
- and end_time <= now()
- </if>
-
- <if test=" null != name and name != '' ">
- and `name` like concat('%', #{name},'%')
- </if>
-
- <if test=" null != status ">
- and `status` = #{status}
- </if>
-
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </sql>
-
- <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_offline_activity where id = #{id} and tenant_id=#{tenantId}
- </select>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxOfflineActivity" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_offline_activity
- <include refid="dynamicWhereConditions" />
- </select>
-
- <select id="findIds" parameterType="com.iformall.domain.po.WxOfflineActivity" resultType="Long">
- select id from wx_offline_activity
- <include refid="dynamicWhereConditions" />
- </select>
-
- <update id="updateStatus" parameterType="com.iformall.domain.po.WxOfflineActivity">
- update wx_offline_activity
- set `status` = #{status},
- `update_date` = #{updateDate}
- where id=#{id}
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- </update>
-
- <select id="getCountWidthCredit" parameterType="com.iformall.domain.po.WxOfflineActivity" resultType="integer">
- select count(1) from wx_offline_activity
- where credit_on_off = #{creditOnOff}
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != id">
- and `id` != #{id}
- </if>
- and ((`start_time` <= #{startTime} and `end_time` >= #{startTime})
- or (`start_time` <= #{endTime} and `end_time` >= #{endTime}))
- </select>
- <select id="selectCreditActivityOne" parameterType="com.iformall.domain.po.WxOfflineActivity" resultType="com.iformall.domain.po.WxOfflineActivity">
- select <include refid="allColumns" /> from wx_offline_activity
- where credit_on_off = #{creditOnOff}
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- and `start_time` <= #{orderDate}
- and `end_time` >= #{orderDate}
- limit 1
- </select>
-
- </mapper>
|