|
- <?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.WxCouponOrderMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCouponOrder">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
- <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
- <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
- <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
- <result column="order_id" jdbcType="BIGINT" property="orderId" />
- <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" />
- <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" />
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
- <result column="coupon_price" jdbcType="INTEGER" property="couponPrice" />
- </resultMap>
-
- <sql id="allColumns">
- `id`,`tenant_id`,`coupon_id`,`c_user_id`,`b_user_id`,`order_id`,`expired_time`,`coupon_order_status`,`create_date`,`update_date`,`coupon_price`
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1 = 1
-
- <if test=" null != id ">
- and `id` = #{id}
-
- </if>
-
- <if test=" null != tenantId ">
- and `tenant_id` = #{tenantId}
-
- </if>
-
- <if test=" null != couponId ">
- and `coupon_id` = #{couponId}
-
- </if>
-
- <if test=" null != cUserId ">
- and `c_user_id` = #{cUserId}
-
- </if>
-
- <if test=" null != bUserId ">
- and `b_user_id` = #{bUserId}
-
- </if>
-
- <if test=" null != orderId ">
- and `order_id` = #{orderId}
-
- </if>
-
- <if test=" null != expiredTime ">
- and `expired_time` = #{expiredTime}
-
- </if>
-
- <if test=" null != couponOrderStatus ">
- and `coupon_order_status` = #{couponOrderStatus}
-
- </if>
-
- <if test=" null != createDate ">
- and `create_date` = #{createDate}
-
- </if>
-
- <if test=" null != updateDate ">
- and `update_date` = #{updateDate}
-
- </if>
-
- <if test=" null != couponPrice ">
- and `coupon_price` = #{couponPrice}
-
- </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="findList" parameterType="com.iformall.domain.po.WxCouponOrder" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_coupon_order
- <include refid="dynamicWhereConditions" />
- </select>
-
- <select id="countList" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="java.lang.Integer">
- select count(*) from wx_coupon_order
- <include refid="dynamicWhereConditions" />
- </select>
-
-
-
- <resultMap id="BVoResultMap" type="com.iformall.domain.vo.WxCouponOrderBVo">
-
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
- <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
- <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
- <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
- <result column="order_id" jdbcType="BIGINT" property="orderId" />
- <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" />
- <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" />
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
- <result column="coupon_price" jdbcType="INTEGER" property="couponPrice" />
-
- <result column="type" jdbcType="INTEGER" property="type" />
- <result column="title" jdbcType="VARCHAR" property="title" />
- <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="name" jdbcType="VARCHAR" property="bUserName" />
- <result column="phone" jdbcType="VARCHAR" property="cUserPhone" />
- </resultMap>
-
-
- <sql id="allBUserVerifiedCouponOrderColumns">
- co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
- c.type,c.title,c.sale_price,c.use_price,c.price,
- bu.name,cu.phone
- </sql>
-
- <sql id="allBUserOrderedCouponOrderColumns">
- co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
- c.type,c.title,c.sale_price,c.use_price,c.price,
- cu.phone
- </sql>
-
- <sql id="allCouponOrderColumns">
- co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price
- </sql>
-
- <select id="findListOfOrderedByDateForBUser" parameterType="map" resultMap="BVoResultMap">
- select <include refid="allBUserOrderedCouponOrderColumns" />
- from wx_coupon_order co,wx_order o,wx_coupon c,wx_c_user cu
- where o.id = co.order_id
- and o.merchant_id = #{merchantID}
- and co.coupon_id = c.id
- and cu.id = co.c_user_id
- <if test="startDate != null">
- AND co.create_date > #{startDate,jdbcType=TIMESTAMP}
- </if>
- <if test="endDate != null">
- AND co.create_date < #{endDate,jdbcType=TIMESTAMP}
- </if>
- order by co.create_date desc
-
- </select>
-
- <select id="findListOfVerifiedByDateForBUser" parameterType="map" resultMap="BVoResultMap">
- select <include refid="allBUserVerifiedCouponOrderColumns" />
- from wx_coupon_order co,wx_order o,wx_coupon c,wx_c_user cu,wx_merchant_b_user bu
- where o.id = co.order_id
- and o.merchant_id = #{merchantID}
- and co.coupon_id = c.id
- and cu.id = co.c_user_id
- and bu.id = co.b_user_id
- <if test="startDate != null">
- AND co.update_date > #{startDate,jdbcType=TIMESTAMP}
- </if>
- <if test="endDate != null">
- AND co.update_date < #{endDate,jdbcType=TIMESTAMP}
- </if>
- AND co.coupon_order_status = '1'
- order by co.update_date desc
- </select>
-
- <select id="findListOfAdmin" parameterType="com.iformall.domain.po.WxCouponOrder" resultMap="BVoResultMap">
- select <include refid="allBUserOrderedCouponOrderColumns" />
- from wx_coupon_order co,wx_order o,wx_coupon c,wx_c_user cu
- where o.id = co.order_id
- and co.coupon_id = c.id
- and cu.id = co.c_user_id
- <if test=" null != id ">
- and co.id = #{id}
- </if>
-
- <if test=" null != tenantId ">
- and co.tenant_id = #{tenantId}
- </if>
-
- <if test=" null != couponId ">
- and co.coupon_id = #{couponId}
- </if>
-
- <if test=" null != cUserId ">
- and co.c_user_id = #{cUserId}
-
- </if>
-
- <if test=" null != bUserId ">
- and co.b_user_id = #{bUserId}
-
- </if>
-
- <if test=" null != orderId ">
- and co.order_id = #{orderId}
-
- </if>
-
- <if test=" null != expiredTime ">
- and co.expired_time = #{expiredTime}
-
- </if>
-
- <if test=" null != couponOrderStatus ">
- and co.coupon_order_status = #{couponOrderStatus}
-
- </if>
-
- <if test=" null != createDate ">
- and co.create_date = #{createDate}
-
- </if>
-
- <if test=" null != updateDate ">
- and co.update_date = #{updateDate}
-
- </if>
-
- <if test=" null != couponPrice ">
- and co.coupon_price = #{couponPrice}
-
- </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>
-
-
- </select>
-
- <select id="findListOfOrderedByDate" parameterType="map" resultMap="BaseResultMap">
- select <include refid="allCouponOrderColumns" />
- from wx_coupon_order co,wx_order o
- where o.id = co.order_id
- and o.merchant_id = #{merchantID}
- <if test="startDate != null">
- AND co.create_date > #{startDate,jdbcType=TIMESTAMP}
- </if>
- <if test="endDate != null">
- AND co.create_date < #{endDate,jdbcType=TIMESTAMP}
- </if>
-
- </select>
-
- <select id="findListOfVerifiedByDate" parameterType="map" resultMap="BaseResultMap">
- select <include refid="allCouponOrderColumns" />
- from wx_coupon_order co,wx_order o
- where o.id = co.order_id
- and o.merchant_id = #{merchantID}
- <if test="startDate != null">
- AND co.update_date > #{startDate,jdbcType=TIMESTAMP}
- </if>
- <if test="endDate != null">
- AND co.update_date < #{endDate,jdbcType=TIMESTAMP}
- </if>
- AND co.coupon_order_status = '1'
- </select>
-
-
-
- <sql id="allCUserCouponOrderListColumns">
- c.id,c.expired_time,c.coupon_order_status,c.create_date,c.update_date,c.coupon_price,
- co.cover_img,co.title,co.sub_title,co.sale_price,co.use_price,co.price,
- m.name
- </sql>
-
- <sql id="allCUserCouponOrderDetailColumns">
- c.id,c.tenant_id,c.coupon_id,c.c_user_id,c.b_user_id,c.order_id,c.expired_time,c.coupon_order_status,c.create_date,c.update_date,c.coupon_price,
- co.merchant_id,co.type,co.cover_img,co.title,co.sub_title,co.sale_price,co.use_price,co.price,co.detail,co.remark,
- m.img_url,m.name,m.link_phone,m.status,
- s.addr,s.shop_number,s.baidu_poi,
- mb.building_name,mf.floor_name
- </sql>
-
- <resultMap id="CVoResultMap" type="com.iformall.domain.vo.WxCouponOrderCVo">
-
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
- <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
- <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
- <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
- <result column="order_id" jdbcType="BIGINT" property="orderId" />
- <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" />
- <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" />
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
- <result column="coupon_price" jdbcType="INTEGER" property="couponPrice" />
-
-
- <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
- <result column="type" jdbcType="INTEGER" property="type" />
- <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="detail" jdbcType="VARCHAR" property="detail" />
- <result column="price" jdbcType="INTEGER" property="price" />
- <result column="remark" jdbcType="VARCHAR" property="remark" />
-
-
- <result column="img_url" jdbcType="VARCHAR" property="merchantImgUrl" />
- <result column="name" jdbcType="VARCHAR" property="merchantName" />
- <result column="link_phone" jdbcType="VARCHAR" property="merchantLinkPhone" />
- <result column="status" jdbcType="VARCHAR" property="merchantStatus" />
-
-
- <result column="addr" jdbcType="VARCHAR" property="addr"/>
- <result column="shop_number" jdbcType="VARCHAR" property="shopNumber"/>
- <result column="building_name" jdbcType="VARCHAR" property="buildingName" />
- <result column="floor_name" jdbcType="VARCHAR" property="floorName" />
- <result column="baidu_poi" jdbcType="VARCHAR" property="baiduPoi"/>
- </resultMap>
-
-
- <select id="findListOfCUser" parameterType="com.iformall.domain.vo.WxCouponOrderCVo" resultMap="CVoResultMap">
- select <include refid="allCUserCouponOrderListColumns" />
- from wx_coupon_order c,wx_coupon co,wx_merchant m
- where 1=1
- and c.coupon_id = co.id
- and co.merchant_id = m.id
- <if test="cUserId != null">
- and c.c_user_id = #{cUserId}
- </if>
- <if test="tenantId != null">
- and c.tenant_id = #{tenantId}
- </if>
- <if test="type != null">
- and co.type = #{type}
- </if>
- <if test="type == null">
- and co.type < 5
- </if>
- <if test="couponOrderStatus != null">
- AND c.coupon_order_status = #{couponOrderStatus}
- </if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </select>
-
- <select id="selectDetailOfUser" parameterType="map" resultMap="CVoResultMap">
- select <include refid="allCUserCouponOrderDetailColumns" />
- from wx_coupon_order c,wx_coupon co,wx_merchant m
- left join wx_merchant_shop ms on ms.merchant_id = m.id and ms.is_del = 0
- left join wx_shop s on ms.shop_id = s.id
- left join wx_mall_building mb on s.building = mb.id
- left join wx_mall_floor mf on s.floor = mf.id
- where c.coupon_id = co.id
- and co.merchant_id = m.id
- <if test="cUserId != null">
- and c.c_user_id = #{cUserId}
- </if>
- <if test="merchantId != null">
- and co.merchant_id = #{merchantId}
- </if>
- <if test="tenantId != null">
- and c.tenant_id = #{tenantId}
- </if>
- <if test="couponOrderId != null">
- and c.id = #{couponOrderId}
- </if>
-
- </select>
-
- <select id="findCountByDateLimit" resultType="java.lang.Integer">
- select COUNT(*) FROM wx_coupon_order where tenant_id = #{tenantId} and create_date >= #{startTime} and create_date <= #{endTime}
- </select>
-
- <select id="couponDataMap" resultType="com.iformall.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap">
- SELECT DATE_FORMAT(create_date,'%m/%d') as createTime
- ,COUNT(DISTINCT c_user_id) as couponUserCount,count(*) as couponCount
- ,(select Count(*) from wx_coupon_order c where coupon_order_status=1 AND DATE_FORMAT(create_date,'%m/%d')=createTime and tenant_id=#{tenantId} AND c.update_date >= #{startTime} and c.update_date <= #{endTime}) as verifyCount
- ,(select Count(DISTINCT c_user_id) from wx_coupon_order d where coupon_order_status=1 AND DATE_FORMAT(create_date,'%m/%d')=createTime and tenant_id=#{tenantId} AND d.update_date >= #{startTime} and d.update_date <= #{endTime}) as verifyUserCount
- from wx_coupon_order where tenant_id=#{tenantId} AND create_date >= #{startTime} and create_date <= #{endTime} GROUP BY createTime
- </select>
-
- <select id="couponDataList" resultType="com.iformall.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap">
- SELECT DATE_FORMAT(wx_coupon_order.create_date,'%Y-%m-%d') as createTime,wx_coupon_order.coupon_id as couponId
- ,COUNT(DISTINCT c_user_id) as couponUserCount,count(*) as couponCount
- ,(select Count(coupon_id) from wx_coupon_order c where coupon_order_status=1 AND DATE_FORMAT(create_date,'%Y-%m-%d')=createTime and tenant_id=#{tenantId} and c.coupon_id=couponId AND c.update_date >= #{startTime} and c.update_date <= #{endTime}) as verifyCount
- ,(select Count(DISTINCT c_user_id) from wx_coupon_order d where coupon_order_status=1 AND d.coupon_id=couponId AND DATE_FORMAT(create_date,'%Y-%m-%d')=createTime and tenant_id=#{tenantId} and d.coupon_id=couponId AND d.update_date >= #{startTime} and d.update_date <= #{endTime}) as verifyUserCount
- from wx_coupon_order join wx_coupon on wx_coupon_order.coupon_id=wx_coupon.id where wx_coupon_order.tenant_id=#{tenantId} AND wx_coupon_order.create_date >= #{startTime} and wx_coupon_order.create_date <= #{endTime}
-
- <if test="couponType != null">
- AND wx_coupon.type = #{couponType}
- </if>
-
- GROUP BY createTime,couponId
- order by createTime desc
- </select>
-
- <select id="touchUsersReportList" resultType="com.iformall.domain.vo.TouchUsersReportVo" parameterType="hashmap">
- SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime
- ,COUNT(DISTINCT c_user_id) as userCount,count(*) as couponCount
- ,(select Count(*) from wx_coupon_order c where coupon_order_status=1 AND DATE_FORMAT(create_date,'%Y-%m-%d')=xTime and tenant_id=#{tenantId}
- <if test="startTime != null">
- AND c.update_date >= #{startTime}
- </if>
- <if test="endTime != null">
- and c.update_date <= #{endTime}
- </if>
- ) as verifyCount
- ,(select Count(DISTINCT c_user_id) from wx_coupon_order d where coupon_order_status=1 AND DATE_FORMAT(create_date,'%Y-%m-%d')=xTime and tenant_id=#{tenantId} AND d.update_date >= #{startTime} and d.update_date <= #{endTime}) as verifyUserCount
- from wx_coupon_order where tenant_id=#{tenantId}
- <if test="startTime != null">
- AND create_date >= #{startTime}
- </if>
- <if test="endTime != null">
- and create_date <= #{endTime}
- </if>
-
-
- GROUP BY xTime
- </select>
-
- <select id="queryPriceTotalGroup" resultType="com.iformall.domain.vo.CUserDateAmountVo" >
- SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime,SUM(coupon_price) as price from wx_coupon_order
- where tenant_id=#{tenantId} AND create_date >= #{startTime} and create_date < #{endTime} GROUP BY xTime
- </select>
-
- <select id="queryPriceTotal" resultType="java.lang.Integer" >
- SELECT SUM(coupon_price) from wx_coupon_order
- where tenant_id=#{tenantId} AND create_date >= #{startTime} and create_date < #{endTime}
- </select>
-
-
-
- <update id="offExpiredCouponOrderByValidDate">
- update wx_coupon_order SET coupon_order_status = 2, update_date = now()
- where expired_time < now() and coupon_price = 0 and coupon_order_status = 0
- </update>
-
- <select id="findExpiredCouponOrderByValidDate" parameterType="com.iformall.domain.po.WxCouponOrder" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_coupon_order
- where expired_time < now() and coupon_price > 0 and coupon_order_status = 0
- </select>
-
- <sql id="allCUserCouponOrderCarListColumns">
- c.id,c.expired_time,c.coupon_order_status,c.create_date,c.update_date,c.coupon_price,
- co.cover_img,co.title,co.sub_title,co.sale_price,co.use_price,co.price,m.id as merchant_id,
- m.name,json_extract(car.vendor_params,'$.id') as coupon_free_id
- </sql>
-
- <resultMap id="CCarVoResultMap" type="com.iformall.domain.vo.WxCouponOrderCarCVo">
-
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
- <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
- <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
- <result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
- <result column="order_id" jdbcType="BIGINT" property="orderId" />
- <result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" />
- <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" />
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
- <result column="coupon_price" jdbcType="INTEGER" property="couponPrice" />
-
-
- <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
- <result column="type" jdbcType="INTEGER" property="type" />
- <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="detail" jdbcType="VARCHAR" property="detail" />
- <result column="price" jdbcType="INTEGER" property="price" />
- <result column="remark" jdbcType="VARCHAR" property="remark" />
-
- <result column="img_url" jdbcType="VARCHAR" property="merchantImgUrl" />
- <result column="name" jdbcType="VARCHAR" property="merchantName" />
- <result column="link_phone" jdbcType="VARCHAR" property="merchantLinkPhone" />
- <result column="status" jdbcType="VARCHAR" property="merchantStatus" />
-
-
- <result column="addr" jdbcType="VARCHAR" property="addr"/>
- <result column="shop_number" jdbcType="VARCHAR" property="shopNumber"/>
- <result column="building_name" jdbcType="VARCHAR" property="buildingName" />
- <result column="floor_name" jdbcType="VARCHAR" property="floorName" />
- <result column="baidu_poi" jdbcType="VARCHAR" property="baiduPoi"/>
-
- <result column="coupon_free_id" jdbcType="INTEGER" property="couponFreeId"/>
- </resultMap>
-
- <select id="findCarListOfCUser" parameterType="com.iformall.domain.vo.WxCouponOrderCarCVo" resultMap="CCarVoResultMap">
- select <include refid="allCUserCouponOrderCarListColumns" />
- from wx_coupon_order c,wx_coupon co,wx_merchant m, wx_coupon_car car
- where 1=1
- and c.coupon_id = co.id
- and c.coupon_id = car.id
- and co.merchant_id = m.id
- <if test="cUserId != null">
- and c.c_user_id = #{cUserId}
- </if>
- <if test="tenantId != null">
- and c.tenant_id = #{tenantId}
- </if>
- <if test="type != null">
- and co.type = #{type}
- </if>
- <if test="couponOrderStatus != null">
- AND c.coupon_order_status = #{couponOrderStatus}
- </if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </select>
-
- </mapper>
|