|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567 |
- <?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.WxCouponChannelMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCouponChannel">
- <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="make_merchant_id" jdbcType="BIGINT" property="makeMerchantId" />
- <result column="type" jdbcType="INTEGER" property="type" />
- <result column="title" jdbcType="VARCHAR" property="title" />
- <result column="target_ad" jdbcType="INTEGER" property="targetAd" />
- <result column="business" jdbcType="INTEGER" property="business" />
- <result column="sub_business" jdbcType="INTEGER" property="subBusiness" />
- <result column="show_begin_time" jdbcType="TIMESTAMP" property="showBeginTime" />
- <result column="begin_time" jdbcType="TIMESTAMP" property="beginTime" />
- <result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
- <result column="status" jdbcType="INTEGER" property="status" />
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
- <result column="sub_target_id" jdbcType="BIGINT" property="subTargetId" />
- <result column="qr_code" jdbcType="VARCHAR" property="qrCode"/>
- <result column="tt_qr_code" jdbcType="VARCHAR" property="ttQrCode"/>
- <result column="tt_spu_id" jdbcType="VARCHAR" property="ttSpuId"/>
- <result column="channel_price" jdbcType="INTEGER" property="channelPrice"/>
- <result column="channel_stock" jdbcType="INTEGER" property="channelStock"/>
- </resultMap>
-
- <sql id="allColumns">
- distinct cc.`id`,cc.`tenant_id`,cc.`parent_tenant_id`,cc.`coupon_id`,cc.`make_merchant_id`,cc.`coupon_status`,cc.`type`,cc.`title`,cc.`target_ad`,cc.`business`,cc.`sub_business`,cc.`show_begin_time`,cc.`begin_time`,cc.`end_time`,cc.`status`,cc.`create_date`,cc.`update_date`,cc.`sub_target_id`,cc.`qr_code`,
- cc.`tt_qr_code`,cc.`tt_spu_id`,cc.`channel_price`,cc.`channel_stock`
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1=1
- <if test="null != couponStatus">
- and c.status = #{couponStatus}
- </if>
- <if test="null != status ">
- and cc.status = #{status}
- </if>
- <if test="null == status ">
- and cc.status = 0
- </if>
-
- <if test=" null != id ">
- and cc.`id` = #{id}
- </if>
-
- <if test=" null != tenantId and '' != tenantId">
- and cc.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and cc.`parent_tenant_id` = #{parentTenantId}
- </if>
-
- <if test=" null != couponId ">
- and cc.`coupon_id` = #{couponId}
- </if>
-
- <if test=" null != type ">
- and cc.`type` = #{type}
- </if>
-
- <if test=" null != title and ''!= title">
- and cc.`title` like concat('%', #{title},'%')
- </if>
-
- <if test=" null != targetAd ">
- and cc.`target_ad` = #{targetAd}
- </if>
-
- <if test=" null != business ">
- and cc.`business` = #{business}
- </if>
-
- <if test=" null != subBusiness ">
- and cc.`sub_business` = #{subBusiness}
- </if>
-
- <if test=" null != showBeginTime ">
- and cc.`show_begin_time` <= #{showBeginTime}
- </if>
-
- <if test=" null != startdate and null!=enddate">
- and cc.`create_date` between #{startdate} and #{enddate}
- </if>
-
- <if test=" null != status ">
- and cc.`status` = #{status}
- </if>
-
- <if test=" null != createDate ">
- and cc.`create_date` = #{createDate}
- </if>
-
- <if test=" null != updateDate ">
- and cc.`update_date` = #{updateDate}
- </if>
-
- <if test=" null != subTargetId ">
- and cc.`sub_target_id` = #{subTargetId}
- </if>
-
- <if test=" null != ttSpuId and ''!= ttSpuId">
- and cc.`tt_spu_id` = #{ttSpuId}
- </if>
-
- <if test=" null != supportTransfer ">
- and c.`support_transfer` = #{supportTransfer}
- </if>
-
- <if test=" null != userCredit ">
- and c.`credit_price` <= #{userCredit}
- </if>
-
- <if test=" null != sourceType ">
- and c.`source_type` = #{sourceType}
- </if>
- <if test=" null != merchantId ">
- and cm.`merchant_id` = #{merchantId}
- </if>
-
- <if test=" null != ids ">
- and cc.id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <if test=" null != couponIds ">
- and cc.coupon_id in
- <foreach collection="couponIds" index="index" item="couponIdsItem" open="(" separator="," close=")">
- #{couponIdsItem}
- </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_coupon_channel cc where id = #{id} and tenant_id = #{tenantId}
- </select>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_coupon_channel cc
- <include refid="dynamicWhereConditions" />
- </select>
-
- <select id="findCouponIdList" parameterType="com.iformall.domain.po.WxCouponChannel" resultType="Long">
- select distinct coupon_id from wx_coupon_channel cc
- <include refid="dynamicWhereConditions" />
- </select>
-
- <update id="updateStatusByCouponId" parameterType="com.iformall.domain.po.WxCouponChannel">
- update wx_coupon_channel
- set status=#{status}, update_date=#{updateDate}
- where coupon_id=#{couponId}
- <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="updateEndTimeByCouponId" parameterType="com.iformall.domain.po.WxCouponChannel">
- update wx_coupon_channel
- set end_time = #{endTime}
- where coupon_id=#{couponId}
- <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="findVoDetail" parameterType="java.util.HashMap" resultMap="BaseResultMap">
- select
- cc.id,cc.coupon_id,cc.make_merchant_id,cc.target_ad,cc.begin_time,cc.end_time,cc.tenant_id,cc.parent_tenant_id,cc.qr_code,cc.tt_qr_code,
- cc.channel_price,cc.channel_stock
- from wx_coupon_channel cc where cc.id = #{id} and cc.tenant_id = #{tenantId}
- </select>
-
- <select id="findVoStatusDetail" parameterType="java.util.HashMap" resultMap="BaseResultMap">
- select cc.id,cc.coupon_id
- from wx_coupon_channel cc
- where cc.id = #{id} and cc.tenant_id = #{tenantId}
- </select>
-
-
- <select id="countCoupon" parameterType="com.iformall.domain.po.WxCouponChannel" resultType="java.lang.Integer">
- select count(distinct coupon_id) from wx_coupon_channel cc
- <include refid="dynamicWhereConditions" />
- </select>
-
- <select id="countCouponChannel" parameterType="com.iformall.domain.po.WxCouponChannel" resultType="java.lang.Integer">
- select count(1) from wx_coupon_channel cc
- <include refid="dynamicWhereConditions" />
- </select>
-
- <select id="getExpiriedCouponIdsByEndTime" resultType="Long">
- select distinct coupon_id from wx_coupon_channel
- where status in (0,-1) and tenant_id = #{tenantId} and end_time < now()
- </select>
-
- <update id="offExpiriedCouponChannelByEndTime">
- update wx_coupon_channel SET status = 1, update_date = now()
- where status in (0,-1) and tenant_id = #{tenantId} and end_time < now()
- </update>
-
- <select id="getExpiriedCouponIdsByValidDate" resultType="Long">
- select distinct cc.coupon_id from wx_coupon_channel cc, wx_coupon c
- where cc.coupon_id = c.id and c.valid_type = 1 and c.valid_end_date < now()
- and cc.status in (0,-1) and cc.tenant_id = #{tenantId}
- </select>
-
- <update id="offExpiriedCouponChannelByValidDate">
- update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now()
- where cc.coupon_id = c.id and c.valid_type = 1 and c.valid_end_date < now()
- and cc.status in (0,-1) and cc.tenant_id = #{tenantId}
- </update>
-
- <select id="getExpiriedCouponIdsByCouponStatus" resultType="Long">
- select distinct cc.coupon_id from wx_coupon_channel cc, wx_coupon c
- where cc.coupon_id = c.id and c.status = 1
- and cc.status in (0,-1) and cc.tenant_id = #{tenantId}
- </select>
-
- <update id="offExpiriedCouponChannelByCouponStatus">
- update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now()
- where cc.coupon_id = c.id and c.status = 1
- and cc.status in (0,-1) and cc.tenant_id = #{tenantId}
- </update>
-
- <update id="offExpiriedCouponChannel2ByEndTime">
- update wx_coupon_channel SET status = 1, update_date = now()
- where status = 0 and tenant_id = #{tenantId} and target_ad = 2 and end_time < now()
- </update>
-
- <delete id="delByTopic" parameterType="com.iformall.domain.po.WxTopic">
- update wx_coupon_channel set status = 1 where sub_target_id = #{id}
- </delete>
-
- <select id="findQrcodeEmptyList" resultType="com.iformall.domain.po.WxCouponChannel">
- select * from wx_coupon_channel where (qr_code is null or tt_qr_code is null)
- </select>
-
- <update id="cardDefer">
- update wx_coupon_channel set end_time = #{endTime} where coupon_id = #{couponId} and tenant_id = #{tenantId} and target_ad = 5 and type = 100
- </update>
-
-
- <select id="newfindCList" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="BaseResultMap">
- select cc.`id`,cc.`tenant_id`,cc.`parent_tenant_id`,cc.`coupon_id`,cc.`coupon_status`,cc.`type`,cc.`title`,
- cc.`target_ad`,cc.`business`,cc.`sub_business`,cc.`show_begin_time`,cc.`begin_time`,cc.`end_time`,cc.`status`,
- cc.`create_date`,cc.`update_date`,cc.`sub_target_id`,cc.qr_code,cc.tt_spu_id,cc.channel_price,cc.channel_stock
- from wx_coupon_channel cc
- where cc.`tenant_id` = #{tenantId}
-
- <if test=" null != id ">
- and cc.`id` = #{id}
- </if>
-
- <if test=" null != parentTenantId and '' != parentTenantId">
- and cc.`parent_tenant_id` = #{parentTenantId}
- </if>
-
- <if test=" null != couponId ">
- and cc.`coupon_id` = #{couponId}
- </if>
-
- <if test=" null != type ">
- and cc.`type` = #{type}
- </if>
-
- <if test=" null != title and ''!= title">
- and cc.`title` like concat('%', #{title},'%')
- </if>
-
- <if test=" null != targetAd ">
- and cc.`target_ad` = #{targetAd}
- </if>
-
- <if test=" null != business ">
- and cc.`business` = #{business}
- </if>
-
- <if test=" null != subBusiness ">
- and cc.`sub_business` = #{subBusiness}
- </if>
-
- <if test=" null != showBeginTime ">
- and cc.`show_begin_time` <= #{showBeginTime}
- </if>
-
- <if test=" null != startdate and null!=enddate">
- and cc.`create_date` between #{startdate} and #{enddate}
- </if>
-
- <if test=" null != status ">
- and cc.`status` = #{status}
- </if>
-
- <if test=" null != createDate ">
- and cc.`create_date` = #{createDate}
- </if>
-
- <if test=" null != updateDate ">
- and cc.`update_date` = #{updateDate}
- </if>
-
- <if test=" null != subTargetId ">
- and cc.`sub_target_id` = #{subTargetId}
- </if>
-
- <if test=" null != ids ">
- and cc.id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <if test=" null != couponIds ">
- and cc.coupon_id in
- <foreach collection="couponIds" index="index" item="couponIdsItem" open="(" separator="," close=")">
- #{couponIdsItem}
- </foreach>
- </if>
- <if test=" null != targetAds ">
- and cc.target_ad in
- <foreach collection="targetAds" index="index" item="targetAdsItem" open="(" separator="," close=")">
- #{targetAdsItem}
- </foreach>
- </if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </select>
-
- <select id="liveHomeList" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="BaseResultMap">
- select cc.`id`,cc.`coupon_id`
- from wx_coupon_channel cc
- where cc.`tenant_id` = #{tenantId} and cc.`target_ad` = #{targetAd}
-
- <if test=" null != parentTenantId and '' != parentTenantId">
- and cc.`parent_tenant_id` = #{parentTenantId}
- </if>
-
- <if test=" null != business ">
- and cc.`business` = #{business}
- </if>
-
- <if test=" null != subBusiness ">
- and cc.`sub_business` = #{subBusiness}
- </if>
-
- <if test=" null != showBeginTime ">
- and cc.`show_begin_time` <= #{showBeginTime}
- </if>
-
- <if test=" null != status ">
- and cc.`status` = #{status}
- </if>
-
- <if test=" null != subTargetId ">
- and cc.`sub_target_id` = #{subTargetId}
- </if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </select>
-
- <update id="reduceChannelStock">
- update wx_coupon_channel SET channel_stock = channel_stock - #{number} where id = #{id} and tenant_id =#{tenantId} and channel_stock is not null and channel_stock - #{number} >= 0
- </update>
-
- <update id="backChannelStock">
- update wx_coupon_channel SET channel_stock = channel_stock + #{number} where id = #{id} and tenant_id =#{tenantId} and channel_stock is not null
- </update>
-
- <update id="setChannelStock">
- update wx_coupon_channel SET channel_stock = #{number} where id = #{id} and tenant_id =#{tenantId} and (channel_stock is null or channel_stock = 0)
- </update>
-
- <update id="clearChannelStock">
- update wx_coupon_channel SET channel_stock = null where id = #{id} and tenant_id =#{tenantId}
- </update>
-
- <update id="setChannelPrice">
- update wx_coupon_channel SET channel_price = #{price} where id = #{id} and tenant_id =#{tenantId}
- </update>
-
- <select id="getPriceAndStock" parameterType="java.util.HashMap" resultMap="BaseResultMap">
- select id,coupon_id,channel_stock,channel_price from wx_coupon_channel where `id` = #{id} and `tenant_id` = #{tenantId}
- </select>
-
- <select id="batGetPriceAndStock" parameterType="java.util.HashMap" resultMap="BaseResultMap">
- select id,coupon_id,channel_stock,channel_price from wx_coupon_channel where `tenant_id` = #{tenantId}
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </select>
-
-
- <resultMap id="ttChannelResultMap" type="com.iformall.domain.vo.TtCouponChannelVo">
- <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="type" jdbcType="INTEGER" property="type" />
- <result column="title" jdbcType="VARCHAR" property="title" />
- <result column="target_ad" jdbcType="INTEGER" property="targetAd" />
- <result column="business" jdbcType="INTEGER" property="business" />
- <result column="sub_business" jdbcType="INTEGER" property="subBusiness" />
- <result column="show_begin_time" jdbcType="TIMESTAMP" property="showBeginTime" />
- <result column="begin_time" jdbcType="TIMESTAMP" property="beginTime" />
- <result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
- <result column="status" jdbcType="INTEGER" property="status" />
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
- <result column="sub_target_id" jdbcType="BIGINT" property="subTargetId" />
- <result column="qr_code" jdbcType="VARCHAR" property="qrCode"/>
- <result column="tt_qr_code" jdbcType="VARCHAR" property="ttQrCode"/>
- <result column="tt_spu_id" jdbcType="VARCHAR" property="ttSpuId"/>
- <result column="channel_price" jdbcType="INTEGER" property="channelPrice"/>
- <result column="channel_stock" jdbcType="INTEGER" property="channelStock"/>
-
- <result column="spu_id" jdbcType="VARCHAR" property="spuId"/>
- <result column="poi_status" jdbcType="INTEGER" property="poiStatus"/>
- <result column="status_desc" jdbcType="VARCHAR" property="statusDesc"/>
- <result column="last_status" jdbcType="INTEGER" property="lastStatus"/>
- <result column="last_status_desc" jdbcType="VARCHAR" property="lastStatusDesc"/>
- </resultMap>
-
-
- <select id="ttChannelList" parameterType="com.iformall.domain.vo.TtCouponChannelVo" resultMap="ttChannelResultMap">
- select cc.`id`,cc.`tenant_id`,cc.`parent_tenant_id`,cc.`coupon_id`,cc.`coupon_status`,cc.`type`,cc.`title`,
- cc.`target_ad`,cc.`business`,cc.`sub_business`,cc.`show_begin_time`,cc.`begin_time`,cc.`end_time`,cc.`status`,
- cc.`create_date`,cc.`update_date`,cc.`sub_target_id`,cc.qr_code,cc.tt_spu_id,cc.channel_price,cc.channel_stock,
- poi.coupon_channel_id,poi.spu_id,poi.status poi_status,poi.status_desc,poi.last_status,poi.last_status_desc
- from wx_coupon_channel cc
- left join tt_coupon_channel_poi poi on poi.coupon_channel_id = cc.id and poi.id = cc.`coupon_id`
- where cc.`tenant_id` = #{tenantId}
-
- <if test=" null != id ">
- and cc.`id` = #{id}
- </if>
-
- <if test=" null != parentTenantId and '' != parentTenantId">
- and cc.`parent_tenant_id` = #{parentTenantId}
- </if>
-
- <if test=" null != couponId ">
- and cc.`coupon_id` = #{couponId}
- </if>
-
- <if test=" null != type ">
- and cc.`type` = #{type}
- </if>
-
- <if test=" null != title and ''!= title">
- and cc.`title` like concat('%', #{title},'%')
- </if>
-
- <if test=" null != targetAd ">
- and cc.`target_ad` = #{targetAd}
- </if>
-
- <if test=" null != business ">
- and cc.`business` = #{business}
- </if>
-
- <if test=" null != subBusiness ">
- and cc.`sub_business` = #{subBusiness}
- </if>
-
- <if test=" null != showBeginTime ">
- and cc.`show_begin_time` <= #{showBeginTime}
- </if>
-
- <if test=" null != startdate and null!=enddate">
- and cc.`create_date` between #{startdate} and #{enddate}
- </if>
-
- <if test=" null != status ">
- and cc.`status` = #{status}
- </if>
-
- <if test=" null != createDate ">
- and cc.`create_date` = #{createDate}
- </if>
-
- <if test=" null != updateDate ">
- and cc.`update_date` = #{updateDate}
- </if>
-
- <if test=" null != subTargetId ">
- and cc.`sub_target_id` = #{subTargetId}
- </if>
-
-
- <if test=" null != spuId and '' != spuId">
- and poi.`spu_id` = #{spuId}
- </if>
-
- <if test=" null != poiStatus">
- and poi.`status` = #{poiStatus}
- </if>
-
- <if test=" null != lastStatus">
- and poi.`last_status` = #{lastStatus}
- </if>
-
- <if test=" null != ids ">
- and cc.id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <if test=" null != couponIds ">
- and cc.coupon_id in
- <foreach collection="couponIds" index="index" item="couponIdsItem" open="(" separator="," close=")">
- #{couponIdsItem}
- </foreach>
- </if>
- <if test=" null != targetAds ">
- and cc.target_ad in
- <foreach collection="targetAds" index="index" item="targetAdsItem" open="(" separator="," close=")">
- #{targetAdsItem}
- </foreach>
- </if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </select>
-
-
- <select id="findCouponIdById" parameterType="java.util.HashMap" resultType="long">
- select coupon_id from wx_coupon_channel
- where `tenant_id` = #{tenantId}
- and id = #{id}
- </select>
-
- <update id="updateStatusByTargetAd" parameterType="com.iformall.domain.po.WxCouponChannel">
- update wx_coupon_channel
- set status=#{status}, update_date=#{updateDate}
- where status != #{status}
- and coupon_id = #{couponId}
- and target_ad = #{targetAd}
- <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="selectCountExclude" parameterType="com.iformall.domain.po.WxCouponChannel" resultType="Integer">
- select count(1) from wx_coupon_channel
- where status = #{status}
- and coupon_id = #{couponId}
- and id != #{id}
- and target_ad != #{targetAd}
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- </select>
-
-
- </mapper>
|