|
- <?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="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" property="qrCode"/>
- </resultMap>
-
- <sql id="allColumns">
- distinct 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
- </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 != 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>
-
- <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>
-
- <sql id="CouponChannelVoColumns">
- <include refid="allColumns" />,
- c.remain_inventory,c.inventory,c.cover_img,c.sub_title,c.sale_price,c.detail,
- c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.use_limit_rule,c.use_limit_quantity,c.send_type,c.support_transfer,c.press_limit_num,c.auto_refund,c.conditions,
- c.valid_type,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date,c.valid_days,c.credit_price,c.content_type,c.source_type
- </sql>
-
- <resultMap id="CouponChannelVoMap" type="com.iformall.domain.vo.WxCouponChannelVo">
- <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="VARCHAR" property="business" />
- <result column="show_begin_time" jdbcType="TIMESTAMP" property="showBeginTime" />
- <result column="sub_business" jdbcType="INTEGER" property="subBusiness" />
- <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="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
- <result column="inventory" jdbcType="INTEGER" property="inventory"/>
- <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
- <result column="title" jdbcType="VARCHAR" property="title"/>
- <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
- <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
- <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
- <result column="price" jdbcType="INTEGER" property="price"/>
- <result column="tail_price" jdbcType="INTEGER" property="tailPrice"/>
- <result column="orig_price" jdbcType="INTEGER" property="origPrice"/>
- <result column="unit" jdbcType="INTEGER" property="unit"/>
- <result column="detail" jdbcType="VARCHAR" property="detail"/>
- <result column="use_limit_rule" jdbcType="INTEGER" property="useLimitRule" />
- <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
- <result column="send_type" jdbcType="INTEGER" property="sendType"/>
- <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
- <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
- <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/>
- <result column="valid_type" jdbcType="INTEGER" property="validType"/>
- <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
- <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
- <result column="pick_start_date" jdbcType="TIMESTAMP" property="pickStartDate"/>
- <result column="pick_end_date" jdbcType="TIMESTAMP" property="pickEndDate"/>
- <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
- <result column="qr_code" property="qrCode"/>
- <result column="conditions" jdbcType="VARCHAR" property="conditions" />
- <result column="content_type" jdbcType="INTEGER" property="contentType"/>
- <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
-
-
- <collection column="{productId=coupon_id,tenantId=tenant_id}" property="merchantVoList"
- ofType="com.iformall.domain.vo.WxMerchantVo"
- javaType="java.util.List"
- select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantNameList" >
- </collection>
-
- </resultMap>
-
- <select id="findVoList" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="CouponChannelVoMap">
- select <include refid="CouponChannelVoColumns" />
- from wx_coupon_channel cc
- left join wx_coupon c on cc.coupon_id = c.id
- left join wx_coupon_merchant cm on c.id = cm.product_id and cm.status = 0
- <include refid="dynamicWhereConditions" />
- </select>
-
- <select id="findVoListByMerchant" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="CouponChannelVoMap">
- select <include refid="CouponChannelVoColumns" />
- from wx_coupon_channel cc
- join wx_coupon_merchant cm
- on cm.product_id = cc.coupon_id
- and cm.status = 0
- <if test="merchantId != null">
- and cm.merchant_id=#{merchantId}
- </if>
- <if test=" null != merchantIds ">
- and cm.merchant_id in
- <foreach collection="merchantIds" index="index" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- left join wx_coupon c on cc.coupon_id = c.id
- left join wx_merchant mer on cm.merchant_id = mer.id
- where cc.`target_ad` in (1,2,5,6,7)
- <if test="status != null">
- and cc.status=#{status}
- </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 != showBeginTime ">
- and cc.`show_begin_time` <= #{showBeginTime}
- </if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </select>
-
- <sql id="WxCouponCVoColumn">
- cc.id,cc.coupon_id,cc.target_ad,cc.begin_time,cc.end_time,
- c.tenant_id,c.parent_tenant_id,c.type,c.cover_img,c.cover_picture,c.detail_picture,c.title,c.sub_title,c.sale_price,c.use_price,
- c.use_limit_rule,c.use_limit_quantity,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date,
- c.valid_days,c.detail,c.price,c.tail_price,c.orig_price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,
- c.create_date,c.update_date,c.business,c.sub_business,c.support_transfer,c.press_limit_num, c.auto_refund,c.credit_price,c.conditions,c.content_type,
- cc.qr_code
- </sql>
-
- <sql id="CVoStatusColumn">
- cc.id,cc.coupon_id,c.remain_inventory,c.status
- </sql>
-
- <resultMap id="WxCouponCVoMap" type="com.iformall.domain.vo.WxCouponCVo">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
- <result column="type" jdbcType="INTEGER" property="type" />
- <result column="target_ad" jdbcType="INTEGER" property="targetAd" />
- <result column="begin_time" jdbcType="TIMESTAMP" property="beginTime"/>
- <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
-
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="type" jdbcType="INTEGER" property="type"/>
- <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
- <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
- <result column="detail_picture" jdbcType="VARCHAR" property="detailPicture"/>
- <result column="title" jdbcType="VARCHAR" property="title"/>
- <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
- <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
- <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
- <result column="use_limit_rule" jdbcType="INTEGER" property="useLimitRule" />
- <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
- <result column="send_type" jdbcType="INTEGER" property="sendType"/>
- <result column="valid_type" jdbcType="INTEGER" property="validType"/>
- <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
- <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
- <result column="pick_start_date" jdbcType="TIMESTAMP" property="pickStartDate"/>
- <result column="pick_end_date" jdbcType="TIMESTAMP" property="pickEndDate"/>
- <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
- <result column="detail" jdbcType="VARCHAR" property="detail"/>
- <result column="price" jdbcType="INTEGER" property="price"/>
- <result column="tail_price" jdbcType="INTEGER" property="tailPrice"/>
- <result column="orig_price" jdbcType="INTEGER" property="origPrice"/>
- <result column="unit" jdbcType="INTEGER" property="unit"/>
- <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
- <result column="inventory" jdbcType="INTEGER" property="inventory"/>
- <result column="remark" jdbcType="VARCHAR" property="remark"/>
- <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="business" jdbcType="INTEGER" property="business"/>
- <result column="subBusiness" jdbcType="INTEGER" property="subBusiness"/>
- <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
- <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
- <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/>
- <result column="qr_code" property="qrCode"/>
- <result column="conditions" jdbcType="VARCHAR" property="conditions" />
- <result column="content_type" jdbcType="INTEGER" property="contentType"/>
-
- <collection column="{productId=coupon_id,tenantId=tenant_id}" property="merchantVoList"
- ofType="com.iformall.domain.vo.WxMerchantVo"
- javaType="java.util.List"
- select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" >
- </collection>
- </resultMap>
-
- <resultMap id="WxCouponCVoMapL" type="com.iformall.domain.vo.WxCouponCVo">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
- <result column="type" jdbcType="INTEGER" property="type" />
- <result column="target_ad" jdbcType="INTEGER" property="targetAd" />
- <result column="begin_time" jdbcType="TIMESTAMP" property="beginTime"/>
- <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
-
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
- <result column="type" jdbcType="INTEGER" property="type"/>
- <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
- <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
- <result column="detail_picture" jdbcType="VARCHAR" property="detailPicture"/>
- <result column="title" jdbcType="VARCHAR" property="title"/>
- <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
- <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
- <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
- <result column="use_limit_rule" jdbcType="INTEGER" property="useLimitRule" />
- <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
- <result column="send_type" jdbcType="INTEGER" property="sendType"/>
- <result column="valid_type" jdbcType="INTEGER" property="validType"/>
- <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
- <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
- <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
- <result column="detail" jdbcType="VARCHAR" property="detail"/>
- <result column="price" jdbcType="INTEGER" property="price"/>
- <result column="unit" jdbcType="INTEGER" property="unit"/>
- <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
- <result column="inventory" jdbcType="INTEGER" property="inventory"/>
- <result column="remark" jdbcType="VARCHAR" property="remark"/>
- <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="business" jdbcType="INTEGER" property="business"/>
- <result column="subBusiness" jdbcType="INTEGER" property="subBusiness"/>
- <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
- <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
- <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/>
- <result column="qr_code" property="qrCode"/>
- <result column="conditions" jdbcType="VARCHAR" property="conditions" />
- <result column="content_type" jdbcType="INTEGER" property="contentType"/>
- </resultMap>
-
- <select id="findVoDetail" parameterType="java.util.HashMap" resultMap="WxCouponCVoMap">
- select
- <include refid="WxCouponCVoColumn"/>
- from wx_coupon_channel cc
- left join wx_coupon c on cc.coupon_id = c.id
- where cc.id = #{id} and cc.tenant_id = #{tenantId}
- </select>
-
- <select id="findVoStatusDetail" parameterType="java.util.HashMap" resultMap="WxCouponCVoMapL">
- select
- <include refid="CVoStatusColumn"/>
- from wx_coupon c, wx_coupon_channel cc
- where cc.coupon_id = c.id and 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(*) from wx_coupon_channel cc
- <include refid="dynamicWhereConditions" />
- </select>
-
- <update id="offExpiriedCouponChannelByEndTime" parameterType="String">
- update wx_coupon_channel SET status = 1, update_date = now()
- where status = 0 and tenant_id = #{tenantId} and end_time < now()
- </update>
-
- <update id="offExpiriedCouponChannelByValidDate">
- update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now()
- where cc.status = 0 and cc.tenant_id = #{tenantId} and cc.coupon_id = c.id and c.valid_type = 1 and c.valid_end_date < now()
- </update>
-
- <update id="offExpiriedCouponChannelByCouponStatus">
- update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now()
- where cc.status = 0 and cc.tenant_id = #{tenantId} and cc.coupon_id = c.id and c.status = 1
- </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
- </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>
-
-
- </mapper>
|