|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <?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.WxCouponPasswordMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCouponPassword">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
- <result column="coupon_short" jdbcType="VARCHAR" property="couponShort" />
- <result column="password" jdbcType="VARCHAR" property="password" />
- <result column="status" jdbcType="INTEGER" property="status" />
- <result column="sended_phone" jdbcType="VARCHAR" property="sendedPhone" />
- <result column="card_id" jdbcType="BIGINT" property="cardId" />
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
- <result column="expire_date" jdbcType="TIMESTAMP" property="expireDate" />
- <result column="present_id" jdbcType="TIMESTAMP" property="presentId"/>
-
- </resultMap>
-
- <sql id="allColumns">
- `id`,`tenant_id`,`parent_tenant_id`,`coupon_id`,`coupon_short`,`password`,`status`,`sended_phone`,`card_id`,`create_date`,`update_date`,`expire_date`,`present_id`
- </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 != couponId ">
- and `coupon_id` = #{couponId}
- </if>
- <if test=" null != couponShort ">
- and `coupon_short` = #{couponShort}
- </if>
- <if test=" null != password ">
- and `password` = #{password}
- </if>
- <if test=" null != status ">
- and `status` = #{status}
- </if>
- <if test=" null != sendedPhone ">
- and `sended_phone` = #{sendedPhone}
- </if>
- <if test=" null != cardId ">
- and `card_id` = #{cardId}
- </if>
- <if test=" null != createDate ">
- and `create_date` = #{createDate}
- </if>
- <if test=" null != updateDate ">
- and `update_date` = #{updateDate}
- </if>
- <if test=" null != expireDate ">
- and `expire_date` > #{expireDate}
- </if>
-
- <if test=" null != presentId ">
- and `present_id` = #{presentId}
- </if>
-
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
-
- <if test=" null != statusStr and ''!=statusStr">
- and status in (${statusStr})
- </if>
-
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </sql>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxCouponPassword" resultMap="BaseResultMap">
- select <include refid="allColumns" />
- from wx_coupon_password
- <include refid="dynamicWhereConditions" />
- </select>
-
- <select id="findAvaPasswordListByCouponId" parameterType="com.iformall.domain.po.WxCouponPassword" resultMap="BaseResultMap">
- select <include refid="allColumns" />
- from wx_coupon_password
- <where>
- <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 != couponId ">
- and `coupon_id` = #{couponId}
- </if>
- <if test=" null != expireDate ">
- and `expire_date` > #{expireDate}
- </if>
- </where>
- </select>
-
- <insert id="insertCouponPasswds" parameterType="java.util.List">
- INSERT INTO wx_coupon_password (`id`,`tenant_id`,`parent_tenant_id`,`coupon_id`,`coupon_short`,`password`,`status`,`create_date`,`update_date`)
- VALUES
- <foreach collection="list" item="item" index="index" separator=",">
- (
- #{item.id},#{item.tenantId},#{item.parentTenantId},#{item.couponId},#{item.couponShort},#{item.password},#{item.status},
- #{item.createDate},#{item.updateDate}
- )
- </foreach>
- </insert>
-
- <update id="disableByCouponId" parameterType="Long">
- update wx_coupon_password
- set status=4, update_date=now()
- where status != 3 and coupon_id=#{couponId}
- </update>
-
- <update id="downloadByCouponId" parameterType="Long">
- update wx_coupon_password
- set status=1, update_date=now(), expire_date=date_add(now(),interval 365 DAY)
- where status=0 and coupon_id=#{couponId}
- </update>
-
- <select id="findCouponGroupList" parameterType="com.iformall.domain.po.WxCouponPassword" resultMap="BaseResultMap">
- select `coupon_id`,`coupon_short`
- from wx_coupon_password
- where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- group by `coupon_id`,`coupon_short`
- </select>
-
-
- <resultMap id="CouponCountInfoMap" type="com.iformall.domain.vo.WxCouponPasswordCountInfoVO">
- <result column="coupon_count" jdbcType="BIGINT" property="couponCount"/>
- <result column="title" jdbcType="VARCHAR" property="couponName"/>
- <result column="coupon_id" jdbcType="BIGINT" property="couponId"/>
- <result column="price" jdbcType="VARCHAR" property="price"/>
- </resultMap>
-
- <select id="findCouponCountInfo" parameterType="com.iformall.domain.po.WxCouponPassword"
- resultMap="CouponCountInfoMap">
- select cp.coupon_id,c.title,c.price,cp.coupon_count from
- (select count(*) as coupon_count,coupon_id from wx_coupon_password
- where status=0
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- group by coupon_id) cp
- inner join wx_coupon c on cp.coupon_id = c.id
- where c.status=0 and c.put_apply_status in(0,2)
- <if test=" null != tenantId and '' != tenantId">
- and c.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and c.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != couponId ">
- and cp.`coupon_id` = #{couponId}
- </if>
- group by cp.coupon_id
- order by c.create_date desc
- </select>
-
- <update id="updateStatus" parameterType="java.util.List">
- <foreach collection="list" item="item" index="index" open="" close="" separator=";">
- update wx_coupon_password set
- status=1,sended_phone=#{item.sendedPhone},update_date=now(),expire_date=date_add(now(),interval 30 DAY),
- present_id=#{item.presentId}
- where id = #{item.id}
- </foreach>
- </update>
-
- <update id="updatePostpone">
- update wx_coupon_password
- set expire_date=#{expireDate}
- where coupon_id=#{couponId} and status=1
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- </update>
-
- <update id="updateExpiredTime" parameterType="map">
- update wx_coupon_password set expire_date = #{expiredTime} , update_date = now() where coupon_id = #{couponId}
- </update>
-
- </mapper>
|