|
- <?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.simple.mapper.WxCouponOrderMapper">
- <resultMap id="BaseResultMap" type="com.simple.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.simple.domain.po.WxCouponOrder" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_coupon_order
- <include refid="dynamicWhereConditions" />
- </select>
-
- <select id="countList" parameterType="com.simple.domain.po.WxCouponOrder" resultType="java.lang.Integer">
- select count(*) from wx_coupon_order
- <include refid="dynamicWhereConditions" />
- </select>
-
-
-
- <resultMap id="BVoResultMap" type="com.simple.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="startDate != null">
- AND co.create_date < #{endDate,jdbcType=TIMESTAMP}
- </if>
- AND (co.coupon_order_status = '0' or co.coupon_order_status = '1')
- 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="startDate != 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.simple.domain.po.WxCouponOrder" 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 co.coupon_id = c.id
- and cu.id = co.c_user_id
- and bu.id = co.b_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="startDate != null">
- AND co.create_date < #{endDate,jdbcType=TIMESTAMP}
- </if>
- AND (co.coupon_order_status = '0' or co.coupon_order_status = '1')
-
- </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="startDate != 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.simple.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.simple.domain.po.WxCouponOrder" 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="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
- 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="sceneMarkingMap" resultType="hashmap" parameterType="hashmap">
- select count(c.id) carcount,c.create_date from (
- select id,DATE_FORMAT(create_date,'%Y-%m-%d') create_date
- from wx_car_cmd_log where tenant_id = #{tenantId} and cmd_type=#{cmdType}
- and create_date BETWEEN #{startdate} and #{enddate}
- ) c
- group by c.create_date
- </select>
-
- <select id="couponDataMap" resultType="com.simple.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>
-
-
- </mapper>
|