|
- <?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.WxCouponActionLogMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCouponActionLog">
- <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_order_id" jdbcType="BIGINT" property="couponOrderId" />
- <result column="channel_type" jdbcType="INTEGER" property="channelType" />
- <result column="channel_id" jdbcType="BIGINT" property="channelId" />
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
- </resultMap>
-
- <sql id="allColumns">
- `id`,`tenant_id`,`parent_tenant_id`,`coupon_id`,`coupon_order_id`,`channel_type`,`channel_id`,`create_time`
- </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 != couponOrderId ">
- and `coupon_order_id` = #{couponOrderId}
-
- </if>
-
- <if test=" null != channelType ">
- and `channel_type` = #{channelType}
-
- </if>
-
- <if test=" null != channelId ">
- and `channel_id` = #{channelId}
-
- </if>
-
- <if test=" null != createTime ">
- and `create_time` = #{createTime}
- </if>
- <if test=" null != startTime ">
- and `create_time` >= #{startTime}
- </if>
- <if test=" null != endTime ">
- and `create_time` <= #{endTime}
- </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_coupon_action_log where id = #{id} and tenant_id = #{tenantId}
- </select>
-
- <delete id="deleteById" parameterType="java.util.HashMap">
- delete from wx_coupon_action_log where id = #{id} and tenant_id = #{tenantId}
- </delete>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxCouponActionLog" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_coupon_action_log
- <include refid="dynamicWhereConditions" />
- </select>
-
- <select id="sceneDataMap" resultType="com.iformall.domain.vo.MarkingSceneDataReportVo" parameterType="hashmap">
- select DATE_FORMAT(create_time,'%m/%d') as xTime,
- (select Count(*) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_action_log${tenantEntity.shardTableSuffix}
- </foreach>) c
- where DATE_FORMAT(create_time,'%m/%d')=xTime
- and c.channel_type=2
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- ) as parkSendCount,
- (select Count(*) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_action_log${tenantEntity.shardTableSuffix}
- </foreach>) c
- where DATE_FORMAT(create_time,'%m/%d')=xTime
- and c.channel_type=3
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- ) as verifySendCount,
- (select Count(*) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_action_log${tenantEntity.shardTableSuffix}
- </foreach>) c
- where DATE_FORMAT(create_time,'%m/%d')=xTime
- and c.channel_type=4
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- ) as microPaySendCount,
- (select Count(*) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_action_log${tenantEntity.shardTableSuffix}
- </foreach>) c
- where DATE_FORMAT(create_time,'%m/%d')=xTime
- and c.channel_type=5
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- ) as orderSendCount,
- (select Count(*) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_action_log${tenantEntity.shardTableSuffix}
- </foreach>) c
- where DATE_FORMAT(create_time,'%m/%d')=xTime
- and c.channel_type=7
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- ) as merchantSendCount
- from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_action_log${tenantEntity.shardTableSuffix}
- </foreach>) wx_coupon_action_log
- where channel_type in (2,3,4,5,7)
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- and create_time >= #{startTime}
- and create_time <= #{endTime}
- group by xTime
- order by xTime desc
- </select>
-
- <select id="getSceneDataMap" resultType="com.iformall.domain.vo.MarkingSceneDataReportTVo" parameterType="hashmap">
- select create_time_md as xTime, channel_type, count(create_time_md + '' + channel_type) as count
- from wx_coupon_action_log
- where channel_type in (2,3,4,5,7)
- and `tenant_id` = #{tenantId}
- and create_time >= #{startTime}
- and create_time <= #{endTime}
- group by create_time_md, channel_type
- order by create_time_md desc
- </select>
-
- <update id="updateCreateTimeMd" parameterType="hashmap">
- update wx_coupon_action_log
- set create_time_md = DATE_FORMAT(create_time,'%m/%d')
- where `tenant_id` = #{tenantId}
- </update>
-
- <select id="sceneDataMapJoinCouponOrder" resultType="com.iformall.domain.vo.MarkingSceneDataReportVo" parameterType="hashmap">
- select DATE_FORMAT(create_time,'%m/%d') AS xTime,
- COUNT(wx_coupon_order.id) as tempCount
- from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_action_log${tenantEntity.shardTableSuffix}
- </foreach>) wx_coupon_action_log
- left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) wx_coupon_order on wx_coupon_action_log.coupon_order_id=wx_coupon_order.id
- where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and wx_coupon_action_log.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and wx_coupon_action_log.`parent_tenant_id` = #{parentTenantId}
- </if>
- and wx_coupon_action_log.create_time >= #{startTime}
- and wx_coupon_action_log.create_time <= #{endTime}
- and wx_coupon_action_log.channel_type = #{channelType}
- group by xTime
- order by xTime desc
- </select>
-
- <select id="sceneDataList" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="com.iformall.domain.dto.MarkingCouponDataReportDto">
- select DATE_FORMAT(create_time,'%Y-%m-%d') as xtime,
- Count(*) as sendCount
- from wx_coupon_action_log
- where channel_type=#{channelType}
- <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 != startTime ">
- and create_time >= #{startTime}
- </if>
- <if test=" null != endTime ">
- and create_time <= #{endTime}
- </if>
- group by xtime
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- <if test=" null == sortColumns">order by xtime desc</if>
- </select>
-
- <select id="sceneDataJoinCouponOrderList" resultType="com.iformall.domain.vo.MarkingSceneDataReportVo"
- parameterType="hashmap">
- select DATE_FORMAT(cal.create_time,'%Y-%m-%d') AS xTime,
- COUNT(co.id) as tempCount
- from wx_coupon_action_log cal
- left join wx_coupon_order co on cal.coupon_order_id=co.id
- where co.coupon_order_status = 1
- <if test=" null != tenantId and '' != tenantId">
- and cal.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and cal.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != startTime ">
- and cal.create_time >= #{startTime}
- </if>
- <if test=" null != endTime ">
- and cal.create_time <= #{endTime}
- </if>
- and cal.channel_type = #{channelType}
- group by xTime
- order by xTime desc
- </select>
-
-
- <select id="getCountByDateLimit" resultType="java.lang.Integer">
- select COUNT(*) FROM wx_coupon_action_log
- where channel_type in (2,3,4,5,7)
- and `tenant_id` = #{tenantId}
- and `create_time` >= #{startTime}
- and `create_time` <= #{endTime}
- </select>
-
- <select id="getCountByChannelId" resultType="java.lang.Integer">
- select COUNT(1) FROM wx_coupon_action_log
- where channel_type = #{channelType}
- and channel_id = #{channelId}
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- </select>
-
- <select id="getCountByUser" resultType="java.lang.Integer" parameterType="hashmap">
- select COUNT(*)
- FROM wx_coupon_action_log a, wx_coupon_order o
- WHERE a.coupon_order_id = o.id
- <if test=" null != tenantId and '' != tenantId">
- and a.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and a.`parent_tenant_id` = #{parentTenantId}
- </if>
- AND o.c_user_id = #{cUserId}
- AND date(a.create_time) = curdate()
- </select>
-
- <select id="getCountByUserAndCoupon" resultType="java.lang.Integer" parameterType="hashmap">
- select COUNT(*)
- FROM wx_coupon_action_log a, wx_coupon_order o
- WHERE a.coupon_order_id = o.id
- <if test=" null != tenantId and '' != tenantId">
- and a.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and a.`parent_tenant_id` = #{parentTenantId}
- </if>
- AND o.c_user_id = #{cUserId}
- AND a.coupon_id = #{couponId}
- AND date(a.create_time) between #{beginDate} and #{endDate}
- </select>
-
- <select id="getCountByUserAndCouponAndDate" resultType="java.lang.Integer" parameterType="hashmap">
- select COUNT(*)
- FROM wx_coupon_action_log a, wx_coupon_order o
- WHERE a.coupon_order_id = o.id
- <if test=" null != tenantId and '' != tenantId">
- and a.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and a.`parent_tenant_id` = #{parentTenantId}
- </if>
- AND o.c_user_id = #{cUserId}
- <if test=" null != couponId ">
- AND a.coupon_id = #{couponId}
- </if>
- AND a.channel_type = #{channelType}
- and a.create_time >= #{startTime}
- and a.create_time <= #{endTime}
- </select>
- <select id="getActionLog" resultType="com.iformall.domain.vo.WxCouponActionLogVo">
- SELECT cal.id AS actionId,
- cal.coupon_id AS couponId,
- cal.create_time AS createDate,
- cs.id AS couponSendId,
- c.title,
- cu.nick_name AS userName,
- cu.phone,
- mbu.NAME AS operator
- FROM wx_coupon_action_log cal
- LEFT JOIN wx_coupon_send cs ON cal.channel_id = cs.id
- LEFT JOIN wx_coupon_order co ON cal.coupon_order_id = co.id
- LEFT JOIN wx_coupon c ON cal.coupon_id = c.id
- LEFT JOIN wx_c_user_basic_info cu ON cu.id = co.c_user_id
- LEFT JOIN wx_merchant_b_user mbu ON mbu.id = cal.operator_id
- <!-- and concat(mbu.merchant_id,'') = JSON_EXTRACT(cs.conditions , '$.id') -->
- WHERE cal.channel_type = #{channelType}
- AND cs.conditions -> '$.id' = concat(#{merchantId},'')
- <if test=" null != beginDate ">
- AND cal.create_time >= #{beginDate}
- </if>
- <if test=" null != endDate ">
- AND cal.create_time < #{endDate}
- </if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </select>
-
- </mapper>
|