|
- <?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.WxOrderGroupMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxOrderGroup">
- <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="order_id" jdbcType="BIGINT" property="orderId"/>
- <result column="coupon_id" jdbcType="BIGINT" property="couponId"/>
- <result column="remain_people" jdbcType="INTEGER" property="remainPeople"/>
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
- <result column="expired_date" jdbcType="TIMESTAMP" property="expiredDate"/>
- <result column="status" jdbcType="SMALLINT" property="status"/>
- <result column="user_id" jdbcType="BIGINT" property="userId"/>
-
- </resultMap>
-
- <sql id="allColumns">
- `id`,`tenant_id`,`parent_tenant_id`,`order_id`,`coupon_id`,`remain_people`,`create_date`,`update_date`,`expired_date`,`status`,`user_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 != orderId ">
- and `order_id` = #{orderId}
- </if>
- <if test=" null != userId ">
- and `coupon_id` = #{couponId}
- </if>
- <if test=" null != pressValue ">
- and `remain_people` = #{remainPeople}
- </if>
- <if test=" null != createDate ">
- and `create_date` = #{createDate}
- </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_order_group where id = #{id} and tenant_id = #{tenantId}
- </select>
-
- <select id="queryRemainOne" parameterType="com.iformall.domain.po.WxOrderGroup" resultType="hashmap">
- select o.press_end_date expiredDate,o.order_group_id orderGroupId,o.id orderId,o.product_id couponId,o.c_user_id cUserId
- from wx_order o
- where o.id=#{orderId}
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
-
- </select>
-
- <select id="queryOrderGroup" parameterType="com.iformall.domain.po.WxOrder" resultType="hashmap">
-
- select o.id orderId,o.order_status orderStatus,o.order_group_id orderGroupId,o.compose_order_id composeOrderId,c.title,c.sub_title subTitle,
- c.sale_price salePrice,c.cover_img coverImg,g.remain_people remainPeople,c.id couponId,g.expired_date
- expiredDate,g.status,g.user_id firstUser,u.nick_name nickName,u.avatar_url avatarUrl,o.tenant_id tenantId,o.parent_tenant_id parentTenantId,
- o.coupon_channel_id couponChannelId,c.press_limit_num pressLimitNum,
- (select status from wx_coupon_channel where id=o.coupon_channel_id) couponStatus,
- o.compose_order_type composeOrderType
- from wx_order o
- left join wx_coupon c on o.product_id=c.id
- left join wx_order_group g on o.order_group_id=g.id
- left join wx_c_user_basic_info u on o.c_user_id=u.id
- where c.type=9
- <if test=" null != tenantId and '' != tenantId">
- and o.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and o.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != cUserId ">
- and o.c_user_id=#{cUserId}
- </if>
- <if test=" null != id ">
- and o.id=#{id}
- </if>
- <if test=" null != orderGroupId ">
- and o.order_group_id=#{orderGroupId}
- </if>
- and o.order_status in(10,11,12,13,14,15,16,98,99)
- order by o.id desc,o.order_status
-
- </select>
-
- <update id="updateOrderGroup" parameterType="com.iformall.domain.po.WxOrderGroup">
- update wx_order_group set remain_people=remain_people-1,status=#{status},update_date=#{updateDate} where id=#{id} and remain_people>0
- </update>
-
-
- <select id="queryOrderGroupMarketingList"
- resultType="com.iformall.domain.vo.WxOrderGroupMarketing">
- SELECT c.tenant_id,c.parent_tenant_id, c.id, c.cover_img, c.title,
- IFNULL(og.group_total_count,0) as group_total_count,
- IFNULL(og2.group_success_count,0) as group_success_count,
- IFNULL(o.success_people,0) as success_people,
- IFNULL(co.verify_count,0) as verify_count,
- IFNULL(o2.total_people,0) as total_people,
- ROUND(IFNULL((og2.group_success_count / og.group_total_count), 0) * 100) group_transfer_ratio,
- ROUND(IFNULL((co.verify_count / o.success_people), 0) * 100) verify_ratio,
- ROUND(c.price / 100, 2) price,
- ROUND(c.sale_price / 100, 2) sale_price
- FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
- </foreach>) c
- left join (SELECT count(*) group_total_count, coupon_id FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order_group${tenantEntity.shardTableSuffix}
- </foreach>) wx_order_group group by coupon_id) og on og.coupon_id = c.id
- left join (SELECT count(*) group_success_count, coupon_id FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order_group${tenantEntity.shardTableSuffix}
- </foreach>) wx_order_group WHERE status = 11 group by coupon_id) og2 on og2.coupon_id = c.id
- left join (SELECT count(*) success_people, product_id FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order${tenantEntity.shardTableSuffix}
- </foreach>) wx_order WHERE order_status = 11 group by product_id ) o on o.product_id = c.id
- left join (SELECT count(*) verify_count, coupon_id FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) wx_coupon_order WHERE coupon_type = 9 AND coupon_order_status = 1 group by coupon_id ) co on co.coupon_id = c.id
- left join (SELECT count(*) total_people, product_id FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order${tenantEntity.shardTableSuffix}
- </foreach>) wx_order WHERE order_group_id != 0 group by product_id ) o2 on o2.product_id = c.id
- WHERE type = 9
- <if test=" null != marketing.tenantId and '' != marketing.tenantId">
- and c.`tenant_id` = #{marketing.tenantId}
- </if>
- <if test=" null != marketing.parentTenantId and '' != marketing.parentTenantId">
- and c.`parent_tenant_id` = #{marketing.parentTenantId}
- </if>
- <if test=" null != marketing.couponId and '' != marketing.couponId">
- and c.coupon_id=#{marketing.couponId}
- </if>
- <if test=" null != marketing.title and '' != marketing.title">
- and c.title like concat('%',#{marketing.title},'%')
- </if>
- <if test=" null != marketing.sortColumns"> order by ${marketing.sortColumns} </if>
- <if test=" null == marketing.sortColumns">order by c.status asc,c.create_date desc</if>
- </select>
-
- <select id="queryOrderGroupSuccessCountAndTime" parameterType="hashmap" resultType="hashmap">
- select count(1) total,DATE_FORMAT(create_date,'%Y-%m-%d') time from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) wx_coupon_order
- where coupon_type=9
- <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 != startdate and null!=enddate ">
- and create_date BETWEEN #{startdate} and #{enddate}
- </if>
- <if test=" null != couponId ">
- and coupon_id=#{couponId}
- </if>
- group by time
- </select>
-
- <select id="queryOrderGroupVerifyCountAndTime" parameterType="hashmap" resultType="hashmap">
- select count(1) total,DATE_FORMAT(create_date,'%Y-%m-%d') time
- from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) wx_coupon_order where coupon_type=9 and coupon_order_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>
- <if test=" null != startdate and null!=enddate ">
- and create_date BETWEEN #{startdate} and #{enddate}
- </if>
- <if test=" null != couponId ">
- and coupon_id=#{couponId}
- </if>
- group by time
- </select>
-
- <select id="queryOrderGroupCount" parameterType="hashmap" resultType="long">
- select count(1) total from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order_group${tenantEntity.shardTableSuffix}
- </foreach>) wx_order_group
- <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 != startdate and null!=enddate ">
- and create_date BETWEEN #{startdate} and #{enddate}
- </if>
- </where>
- </select>
-
- <select id="queryOrderGroupCountHistory" resultType="com.iformall.domain.vo.WxCouponStatisVo">
- select DATE_FORMAT(create_date,'%Y-%m-%d') xtime,count(*) xcount
- from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order_group${tenantEntity.shardTableSuffix}
- </foreach>) wx_order_group
- <where>
-
- <if test=" null != wxCoupon.startdate and null!= wxCoupon.enddate ">
- and create_date BETWEEN #{wxCoupon.startdate} and #{wxCoupon.enddate}
- </if>
- </where>
- group by xtime
- </select>
-
- <select id="queryOrderGroupSuccessCount" parameterType="hashmap" resultType="long">
- select count(1) total from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order_group${tenantEntity.shardTableSuffix}
- </foreach>) wx_order_group where status=11
- <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 != startdate and null!=enddate ">
- and create_date BETWEEN #{startdate} and #{enddate}
- </if>
- </select>
-
- <select id="queryOrderGroupPeopleCount" parameterType="hashmap" resultType="long">
- select count(1) from (select id from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order${tenantEntity.shardTableSuffix}
- </foreach>) wx_order where order_group_id!=0
- <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 != startdate and null!=enddate ">
- and create_date BETWEEN #{startdate} and #{enddate}
- </if>
- ) g
- </select>
-
- <select id="queryOrderGroupVerifyCount" parameterType="hashmap" resultType="long">
- select count(1) total from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) wx_coupon_order where coupon_type=9 and coupon_order_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>
- <if test=" null != startdate and null!=enddate ">
- and create_date BETWEEN #{startdate} and #{enddate}
- </if>
- <if test=" null != couponId ">
- and coupon_id=#{couponId}
- </if>
- </select>
-
- <select id="queryOrderGroupSuccessPeopleCount" parameterType="hashmap" resultType="long">
- select count(1) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_order${tenantEntity.shardTableSuffix}
- </foreach>) wx_order where order_status=11
- <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 != startdate and null!=enddate ">
- and create_date BETWEEN #{startdate} and #{enddate}
- </if>
- </select>
-
-
- </mapper>
|