|
- <?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="VARCHAR" property="tenantId" />
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
- <result column="coupon_type" jdbcType="INTEGER" property="couponType" />
- <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
- <result column="owner_id" jdbcType="BIGINT" property="ownerId" />
- <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="auto_refund" jdbcType="INTEGER" property="autoRefund" />
- <result column="verify_type" jdbcType="INTEGER" property="verifyType" />
- <result column="verify_remark" jdbcType="VARCHAR" property="verifyRemark" />
- <result column="pay_vendor" jdbcType="INTEGER" property="payVendor" />
- <result column="send_merchant_id" jdbcType="INTEGER" property="sendMerchantId" />
- <result column="send_merchant_user_id" jdbcType="INTEGER" property="sendMerchantUserId" />
- <result column="compose_order_type" jdbcType="INTEGER" property="composeOrderType" />
- <result column="compose_order_id" jdbcType="BIGINT" property="composeOrderId" />
- <result column="parent_coupon_order_id" jdbcType="BIGINT" property="parentCouponOrderId" />
- <result column="coupon_number" jdbcType="BIGINT" property="couponNumber" />
-
- <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
- <result column="shipping_type" jdbcType="INTEGER" property="shippingType"/>
- <result column="shipping_address" jdbcType="VARCHAR" property="shippingAddress"/>
- <result column="shipping_status" jdbcType="INTEGER" property="shippingStatus"/>
- <result column="delivery_info" jdbcType="VARCHAR" property="deliveryInfo"/>
- </resultMap>
-
- <sql id="allColumns">
- `id`,`tenant_id`,`parent_tenant_id`,`coupon_id`,`coupon_type`,`c_user_id`,`owner_id`,`b_user_id`,`order_id`,`expired_time`,`coupon_order_status`,`create_date`,`update_date`,`coupon_price`, `auto_refund`,
- `verify_type`,`verify_remark`,`pay_vendor`,`send_merchant_id`,`send_merchant_user_id`,`compose_order_type`,`compose_order_id`,`parent_coupon_order_id`,`coupon_number`,
- `freight_price`,`shipping_type`,`shipping_address`,`shipping_status`,`delivery_info`
- </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 != couponType ">
- and `coupon_type` = #{couponType}
- </if>
-
- <if test=" null != cUserId ">
- and `c_user_id` = #{cUserId}
- </if>
-
- <if test=" null != ownerId ">
- and `owner_id` = #{ownerId}
- </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 != autoRefund ">
- and `auto_refund` = #{autoRefund}
- </if>
-
- <if test=" null != payVendor ">
- and `pay_vendor` = #{payVendor}
- </if>
-
- <if test=" null != sendMerchantId ">
- and `send_merchant_id` = #{sendMerchantId}
- </if>
-
- <if test=" null != sendMerchantUserId ">
- and `send_merchant_user_id` = #{sendMerchantUserId}
- </if>
-
- <if test=" null != composeOrderType ">
- and `compose_order_type` = #{composeOrderType}
- </if>
-
- <if test=" null != composeOrderId ">
- and `compose_order_id` = #{composeOrderId}
- </if>
-
- <if test=" null != parentCouponOrderId ">
- and `parent_coupon_order_id` = #{parentCouponOrderId}
- </if>
-
- <if test=" null != shippingType ">
- and `shipping_type` = #{shippingType}
- </if>
-
- <if test=" null != shippingStatus ">
- and `shipping_status` = #{shippingStatus}
- </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_order where id = #{id} and tenant_id=#{tenantId}
- </select>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxCouponOrder" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_coupon_order
- <include refid="dynamicWhereConditions" />
- </select>
-
- <update id="updateVerifyCouponOrder" parameterType="com.iformall.domain.po.WxCouponOrder">
- update wx_coupon_order
- set `coupon_order_status` = #{couponOrderStatus},
- `b_user_id` = #{bUserId},
- `update_date` = #{updateDate},
- `verify_type` = #{verifyType}
- <if test=" null != verifyRemark">
- ,`verify_remark` = #{verifyRemark}
- </if>
- <if test=" null != shippingStatus">
- ,`shipping_status` = #{shippingStatus}
- </if>
- where id=#{id} and `b_user_id` is null
- <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="updateVerifyCouponOrderStatus" parameterType="com.iformall.domain.po.WxCouponOrder">
- update wx_coupon_order
- set `coupon_order_status` = #{couponOrderStatus},
- `b_user_id` = #{bUserId},
- `update_date` = #{updateDate},
- `verify_type` = #{verifyType}
- <if test=" null != verifyRemark">
- ,`verify_remark` = #{verifyRemark}
- </if>
- <if test=" null != shippingStatus">
- ,`shipping_status` = #{shippingStatus}
- </if>
- where id=#{id}
- <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 == #{bUserId} ">
- and `b_user_id` is null
- </if>
- <if test=" null != #{bUserId} ">
- and `b_user_id` = #{bUserId}
- </if>
- </update>
-
- <update id="updateVerifyCouponOrderStatusForMicroPay" parameterType="com.iformall.domain.po.WxCouponOrder">
- update wx_coupon_order
- set `coupon_order_status` = #{couponOrderStatus},
- `b_user_id` = #{bUserId},
- `update_date` = #{updateDate},
- `verify_type` = #{verifyType}
- <if test=" null != verifyRemark">
- ,`verify_remark` = #{verifyRemark}
- </if>
- <if test=" null != shippingStatus">
- ,`shipping_status` = #{shippingStatus}
- </if>
- where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- and id=#{id}
- </update>
-
- <update id="cancelVerifyCouponOrder" parameterType="com.iformall.domain.po.WxCouponOrder">
- update wx_coupon_order
- set `coupon_order_status` = #{couponOrderStatus},
- `b_user_id` = null,
- `update_date` = #{updateDate},
- `verify_type` = null
- where id=#{id}
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- </update>
-
- <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 (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) c
- where coupon_order_status=1
- AND DATE_FORMAT(create_date,'%m/%d')=createTime
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- AND c.update_date >= #{startTime}
- AND c.update_date <= #{endTime}) as verifyCount,
- (select Count(DISTINCT c_user_id)
- from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) d
- where coupon_order_status=1
- AND DATE_FORMAT(create_date,'%m/%d')=createTime
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- AND d.update_date >= #{startTime}
- AND d.update_date <= #{endTime}) as verifyUserCount
- from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) wx_coupon_order
- where 1=1
- <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_date >= #{startTime}
- AND create_date <= #{endTime}
- GROUP BY createTime
- </select>
-
- <select id="couponDataList" resultType="com.iformall.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap">
- SELECT createTime,couponId,sum(couponCount) couponCount,sum(couponUserCount) couponUserCount,sum(verifyCount) verifyCount,sum(verifyUserCount) verifyUserCount
- from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from view_coupon_data${tenantEntity.shardTableSuffix} WHERE `tenant_id` = #{tenantEntity.tenantId}
- </foreach>) view_coupon_data
- where 1=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="startTime != null">
- and createTime >= DATE_FORMAT(#{startTime},'%Y-%m-%d')
- </if>
- <if test="endTime != null">
- and view_coupon_data.createTime <= DATE_FORMAT(#{endTime},'%Y-%m-%d')
- </if>
- <if test="couponType != null">
- and couponType = #{couponType}
- </if>
- <if test="couponTitle != null">
- and couponTitle like concat('%', #{couponTitle},'%')
- </if>
- GROUP BY createTime,couponId
- order by createTime desc
-
- </select>
-
- <select id="touchUsersReportList" resultType="com.iformall.domain.vo.TouchUsersReportVo" parameterType="com.iformall.domain.dto.MarkingCouponDataReportDto">
- SELECT xTime, sum(pv) pv, sum(uv) uv, sum(couponCount) couponCount, sum(userCount) userCount, sum(verifyCount) verifyCount, sum(verifyUserCount) verifyUserCount
- FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from view_touch_user${tenantEntity.shardTableSuffix} WHERE `tenant_id` = #{tenantEntity.tenantId}
- </foreach>) view_touch_user
- WHERE 1=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="startTime != null">
- and xTime >= DATE_FORMAT(#{startTime},'%Y-%m-%d')
- </if>
- <if test="endTime != null">
- and xTime <= DATE_FORMAT(#{endTime},'%Y-%m-%d')
- </if>
- GROUP BY xTime
- order by xTime desc
- </select>
-
-
- <select id="queryForSceneRepotyHistoryVerified" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="hashmap">
- select DATE_FORMAT(update_date,'%Y-%m-%d') xTime, count(c.id) triggerCount
- from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) c
- where c.coupon_order_status = 1
- <if test=" null != tenantId and '' != tenantId">
- and c.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and c.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != startTime and null != endTime">
- and c.update_date BETWEEN #{startTime} and #{endTime}
- </if>
- group by xTime
- </select>
-
- <select id="queryForSceneRepotyHistoryOrdered" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="hashmap">
- select DATE_FORMAT(update_date,'%Y-%m-%d') xTime, count(c.id) triggerCount
- from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) c
- where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and c.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and c.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != startTime and null != endTime">
- and c.create_date BETWEEN #{startTime} and #{endTime}
- </if>
- group by xTime
- </select>
-
- <select id="queryForSceneRepotyMechantHistoryOrdered" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="hashmap">
- select DATE_FORMAT(update_date,'%Y-%m-%d') xTime, count(c.id) triggerCount
- from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) c left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_action_log${tenantEntity.shardTableSuffix}
- </foreach>) cal on cal.tenant_id = c.tenant_id
- where cal.coupon_order_id=c.id
- <if test=" null != tenantId and '' != tenantId">
- and c.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and c.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != channelType and null != channelType">
- and cal.channel_type=#{channelType}
- </if>
- <if test=" null != startTime and null != endTime">
- and c.create_date BETWEEN #{startTime} and #{endTime}
- </if>
- group by xTime
- </select>
-
- <select id="queryPriceTotal" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="java.lang.Integer" >
- SELECT IFNULL(SUM(coupon_price),0) from wx_coupon_order
- where 1=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 != couponOrderStatus">
- and coupon_order_status = #{couponOrderStatus}
- </if>
- <if test=" null != cUserId">
- and c_user_id = #{cUserId}
- </if>
- <if test=" null != couponId ">
- and coupon_id = #{couponId}
- </if>
- <if test=" null != couponType ">
- and coupon_type = #{couponType}
- </if>
- <if test=" null != startTime">
- and create_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and create_date <= #{endTime}
- </if>
- </select>
-
- <select id="findCount" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="java.lang.Integer">
- select COUNT(*) FROM wx_coupon_order co
- <if test=" null != businessId ">
- inner join wx_coupon c
- on c.id = co.coupon_id
- and c.business = #{businessId}
- <if test=" null != subBusinessId ">
- and c.sub_business = #{subBusinessId}
- </if>
- </if>
- where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and co.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != couponOrderStatus">
- and co.coupon_order_status = #{couponOrderStatus}
- </if>
- <if test=" null != cUserId">
- and co.c_user_id = #{cUserId}
- </if>
- <if test=" null != couponId ">
- and co.coupon_id = #{couponId}
- </if>
- <if test=" null != couponType ">
- and co.coupon_type = #{couponType}
- </if>
-
- <if test=" null != sendMerchantId ">
- and co.send_merchant_id = #{sendMerchantId}
- </if>
-
- <if test=" 1 == couponOrderStatus">
- <if test=" null != startTime">
- and co.update_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and co.update_date <= #{endTime}
- </if>
- <if test=" 0 == timeSlot">
- and date_format(co.update_date,'%H:%m') >= '06:00'
- and date_format(co.update_date,'%H:%m') < '18:00'
- and date_format(co.update_date,'%w') in (1,2,3,4,5)
- </if>
- <if test=" 1 == timeSlot">
- and ((date_format(co.update_date,'%H:%m') >= '18:00'
- and date_format(co.update_date,'%w') in (1,2,3,4))
- or
- ((date_format(co.update_date,'%H:%m') < '06:00')
- and date_format(co.update_date,'%w') in (1,2,3,4,5)))
- </if>
- <if test=" 2 == timeSlot">
- and date_format(co.update_date,'%H:%m') >= '06:00'
- and date_format(co.update_date,'%H:%m') < '18:00'
- and date_format(co.update_date,'%w') in (0,6)
- </if>
- <if test=" 3 == timeSlot">
- and ((date_format(co.update_date,'%H:%m') >= '18:00'
- and date_format(co.update_date,'%w') in (5,6,0))
- or
- ((date_format(co.update_date,'%H:%m') < '06:00')
- and date_format(co.update_date,'%w') in (6,0)))
- </if>
- </if>
-
- <if test=" 1 != couponOrderStatus">
- <if test=" null != startTime">
- and co.create_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and co.create_date <= #{endTime}
- </if>
- <if test=" 0 == timeSlot">
- and date_format(co.create_date,'%H:%m') >= '06:00'
- and date_format(co.create_date,'%H:%m') < '18:00'
- and date_format(co.create_date,'%w') in (1,2,3,4,5)
- </if>
- <if test=" 1 == timeSlot">
- and ((date_format(co.create_date,'%H:%m') >= '18:00'
- and date_format(co.create_date,'%w') in (1,2,3,4))
- or
- ((date_format(co.create_date,'%H:%m') < '06:00')
- and date_format(co.create_date,'%w') in (1,2,3,4,5)))
- </if>
- <if test=" 2 == timeSlot">
- and date_format(co.create_date,'%H:%m') >= '06:00'
- and date_format(co.create_date,'%H:%m') < '18:00'
- and date_format(co.create_date,'%w') in (0,6)
- </if>
- <if test=" 3 == timeSlot">
- and ((date_format(co.create_date,'%H:%m') >= '18:00'
- and date_format(co.create_date,'%w') in (5,6,0))
- or
- ((date_format(co.create_date,'%H:%m') < '06:00')
- and date_format(co.create_date,'%w') in (6,0)))
- </if>
- </if>
- </select>
-
- <select id="findProductCount" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="java.lang.Integer">
- select COALESCE(sum(coupon_number),0) FROM wx_coupon_order co
- where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and co.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != couponOrderStatus">
- and co.coupon_order_status = #{couponOrderStatus}
- </if>
- <if test=" null != cUserId">
- and co.c_user_id = #{cUserId}
- </if>
- <if test=" null != couponId ">
- and co.coupon_id = #{couponId}
- </if>
- <if test=" null != couponType ">
- and co.coupon_type = #{couponType}
- </if>
- </select>
-
- <select id="getCountByBusinessId" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="hashmap">
- select c.business, COUNT(c.business) bu_count
- FROM wx_coupon_order co
- inner join wx_coupon c on c.id = co.coupon_id
- where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and co.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != couponOrderStatus">
- and co.coupon_order_status = #{couponOrderStatus}
- </if>
- <if test=" null != cUserId">
- and co.c_user_id = #{cUserId}
- </if>
- <if test=" null != couponId ">
- and co.coupon_id = #{couponId}
- </if>
- <if test=" null != couponType ">
- and co.coupon_type = #{couponType}
- </if>
-
- <if test=" 1 == couponOrderStatus">
- <if test=" null != startTime">
- and co.update_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and co.update_date <= #{endTime}
- </if>
- <if test=" 0 == timeSlot">
- and date_format(co.update_date,'%H:%m') >= '06:00'
- and date_format(co.update_date,'%H:%m') < '18:00'
- and date_format(co.update_date,'%w') in (1,2,3,4,5)
- </if>
- <if test=" 1 == timeSlot">
- and ((date_format(co.update_date,'%H:%m') >= '18:00'
- and date_format(co.update_date,'%w') in (1,2,3,4))
- or
- ((date_format(co.update_date,'%H:%m') < '06:00')
- and date_format(co.update_date,'%w') in (1,2,3,4,5)))
- </if>
- <if test=" 2 == timeSlot">
- and date_format(co.update_date,'%H:%m') >= '06:00'
- and date_format(co.update_date,'%H:%m') < '18:00'
- and date_format(co.update_date,'%w') in (0,6)
- </if>
- <if test=" 3 == timeSlot">
- and ((date_format(co.update_date,'%H:%m') >= '18:00'
- and date_format(co.update_date,'%w') in (5,6,0))
- or
- ((date_format(co.update_date,'%H:%m') < '06:00')
- and date_format(co.update_date,'%w') in (6,0)))
- </if>
- </if>
-
- <if test=" 1 != couponOrderStatus">
- <if test=" null != startTime">
- and co.create_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and co.create_date <= #{endTime}
- </if>
- <if test=" 0 == timeSlot">
- and date_format(co.create_date,'%H:%m') >= '06:00'
- and date_format(co.create_date,'%H:%m') < '18:00'
- and date_format(co.create_date,'%w') in (1,2,3,4,5)
- </if>
- <if test=" 1 == timeSlot">
- and ((date_format(co.create_date,'%H:%m') >= '18:00'
- and date_format(co.create_date,'%w') in (1,2,3,4))
- or
- ((date_format(co.create_date,'%H:%m') < '06:00')
- and date_format(co.create_date,'%w') in (1,2,3,4,5)))
- </if>
- <if test=" 2 == timeSlot">
- and date_format(co.create_date,'%H:%m') >= '06:00'
- and date_format(co.create_date,'%H:%m') < '18:00'
- and date_format(co.create_date,'%w') in (0,6)
- </if>
- <if test=" 3 == timeSlot">
- and ((date_format(co.create_date,'%H:%m') >= '18:00'
- and date_format(co.create_date,'%w') in (5,6,0))
- or
- ((date_format(co.create_date,'%H:%m') < '06:00')
- and date_format(co.create_date,'%w') in (6,0)))
- </if>
- </if>
- group by c.business
- </select>
-
- <select id="getCountBySubBusinessId" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="hashmap">
- select c.sub_business, COUNT(c.sub_business) bu_count
- FROM wx_coupon_order co
- <if test=" null != businessId ">
- inner join wx_coupon c on c.id = co.coupon_id and c.business = #{businessId}
- </if>
- where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and co.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != couponOrderStatus">
- and co.coupon_order_status = #{couponOrderStatus}
- </if>
- <if test=" null != cUserId">
- and co.c_user_id = #{cUserId}
- </if>
- <if test=" null != couponId ">
- and co.coupon_id = #{couponId}
- </if>
- <if test=" null != couponType ">
- and co.coupon_type = #{couponType}
- </if>
-
- <if test=" 1 == couponOrderStatus">
- <if test=" null != startTime">
- and co.update_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and co.update_date <= #{endTime}
- </if>
- <if test=" 0 == timeSlot">
- and date_format(co.update_date,'%H:%m') >= '06:00'
- and date_format(co.update_date,'%H:%m') < '18:00'
- and date_format(co.update_date,'%w') in (1,2,3,4,5)
- </if>
- <if test=" 1 == timeSlot">
- and ((date_format(co.update_date,'%H:%m') >= '18:00'
- and date_format(co.update_date,'%w') in (1,2,3,4))
- or
- ((date_format(co.update_date,'%H:%m') < '06:00')
- and date_format(co.update_date,'%w') in (1,2,3,4,5)))
- </if>
- <if test=" 2 == timeSlot">
- and date_format(co.update_date,'%H:%m') >= '06:00'
- and date_format(co.update_date,'%H:%m') < '18:00'
- and date_format(co.update_date,'%w') in (0,6)
- </if>
- <if test=" 3 == timeSlot">
- and ((date_format(co.update_date,'%H:%m') >= '18:00'
- and date_format(co.update_date,'%w') in (5,6,0))
- or
- ((date_format(co.update_date,'%H:%m') < '06:00')
- and date_format(co.update_date,'%w') in (6,0)))
- </if>
- </if>
-
- <if test=" 1 != couponOrderStatus">
- <if test=" null != startTime">
- and co.create_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and co.create_date <= #{endTime}
- </if>
- <if test=" 0 == timeSlot">
- and date_format(co.create_date,'%H:%m') >= '06:00'
- and date_format(co.create_date,'%H:%m') < '18:00'
- and date_format(co.create_date,'%w') in (1,2,3,4,5)
- </if>
- <if test=" 1 == timeSlot">
- and ((date_format(co.create_date,'%H:%m') >= '18:00'
- and date_format(co.create_date,'%w') in (1,2,3,4))
- or
- ((date_format(co.create_date,'%H:%m') < '06:00')
- and date_format(co.create_date,'%w') in (1,2,3,4,5)))
- </if>
- <if test=" 2 == timeSlot">
- and date_format(co.create_date,'%H:%m') >= '06:00'
- and date_format(co.create_date,'%H:%m') < '18:00'
- and date_format(co.create_date,'%w') in (0,6)
- </if>
- <if test=" 3 == timeSlot">
- and ((date_format(co.create_date,'%H:%m') >= '18:00'
- and date_format(co.create_date,'%w') in (5,6,0))
- or
- ((date_format(co.create_date,'%H:%m') < '06:00')
- and date_format(co.create_date,'%w') in (6,0)))
- </if>
- </if>
- group by c.sub_business
- </select>
-
- <select id="queryPriceTotalGroup" resultType="com.iformall.domain.vo.CUserDateAmountVo" >
- SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime,IFNULL(SUM(coupon_price),0) as price
- from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
- SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
- </foreach>) wx_coupon_order
- where 1=1
- <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_date >= #{startTime} and create_date < #{endTime} GROUP BY xTime
- </select>
-
-
- <select id="findExpiredFreeCouponOrderByValidDate" parameterType="String" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_coupon_order
- where tenant_id = #{tenantId} and expired_time >= date_sub(curdate(),interval 360 day) and expired_time < now() and coupon_price = 0 and coupon_order_status in (0, 4)
- </select>
-
- <select id="findExpiredCouponOrderByValidDate" parameterType="String" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_coupon_order
- where tenant_id = #{tenantId} and expired_time >= date_sub(curdate(),interval 360 day) and expired_time < now() and coupon_price > 0 and coupon_order_status in (0, 4)
- </select>
-
- <select id="findExpiredCouponOrderGoodsVerify" parameterType="String" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_coupon_order
- where tenant_id = #{tenantId} and coupon_type = 11
- and update_date < DATE_ADD(curdate(),interval 14 day)
- and shipping_type = 2 and shipping_status = 24 and coupon_order_status = 0
- </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="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
- <result column="coupon_type" jdbcType="INTEGER" property="couponType" />
- <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
- <result column="owner_id" jdbcType="BIGINT" property="ownerId" />
- <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="pay_vendor" jdbcType="INTEGER" property="payVendor" />
- <result column="verify_type" jdbcType="INTEGER" property="verifyType" />
- <result column="verify_remark" jdbcType="VARCHAR" property="verifyRemark" />
-
- <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
- <result column="shipping_type" jdbcType="INTEGER" property="shippingType"/>
- <result column="shipping_address" jdbcType="VARCHAR" property="shippingAddress"/>
- <result column="shipping_status" jdbcType="INTEGER" property="shippingStatus"/>
- <result column="delivery_info" jdbcType="VARCHAR" property="deliveryInfo"/>
-
- <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
-
- <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="auto_refund" jdbcType="INTEGER" property="autoRefund" />
- <result column="business" jdbcType="INTEGER" property="business"/>
- <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
- <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
-
- <result column="name" jdbcType="VARCHAR" property="bUserName" />
- <result column="bphone" jdbcType="VARCHAR" property="bUserPhone" />
- <result column="phone" jdbcType="VARCHAR" property="cUserPhone" />
- <result column="merchant_name" jdbcType="VARCHAR" property="merchantName" />
-
- <result column="verify_merchant_name" jdbcType="VARCHAR" property="verifyMerchantName"/>
-
- <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>
-
- <resultMap id="AdminBVoResultMap" type="com.iformall.domain.vo.WxCouponOrderBVo">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
- <result column="coupon_type" jdbcType="INTEGER" property="couponType" />
- <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
- <result column="owner_id" jdbcType="BIGINT" property="ownerId" />
- <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="pay_vendor" jdbcType="INTEGER" property="payVendor" />
- <result column="verify_type" jdbcType="INTEGER" property="verifyType" />
- <result column="verify_remark" jdbcType="VARCHAR" property="verifyRemark" />
-
- <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
- <result column="shipping_type" jdbcType="INTEGER" property="shippingType"/>
- <result column="shipping_address" jdbcType="VARCHAR" property="shippingAddress"/>
- <result column="shipping_status" jdbcType="INTEGER" property="shippingStatus"/>
- <result column="delivery_info" jdbcType="VARCHAR" property="deliveryInfo"/>
-
- <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
-
- <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="auto_refund" jdbcType="INTEGER" property="autoRefund" />
- <result column="business" jdbcType="INTEGER" property="business"/>
- <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
- <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
- <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
-
- <result column="name" jdbcType="VARCHAR" property="bUserName" />
- <result column="bphone" jdbcType="VARCHAR" property="bUserPhone" />
- <result column="phone" jdbcType="VARCHAR" property="cUserPhone" />
- <result column="merchant_name" jdbcType="VARCHAR" property="merchantName" />
-
- <result column="verify_merchant_name" jdbcType="VARCHAR" property="verifyMerchantName"/>
-
- <result column="send_merchant_id" jdbcType="INTEGER" property="sendMerchantId" />
- </resultMap>
-
- <sql id="allAdminCouponOrderListColumns">
- <!--
- co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
- c.title,c.sale_price,c.use_price,c.price,c.unit,c.auto_refund,c.business,c.subsidy_type,ms.subsidy subsidy_num,
-
- (case when com.mc=1 then
- (select m.name from wx_merchant m, wx_coupon_merchant cm
- where m.id = cm.merchant_id and cm.product_id=co.coupon_id and cm.status = 0) else '[多商户通用]' end) as merchant_name,
- (case when com.mc = 1 then (select m.id from wx_merchant m,
- wx_coupon_merchant cm where m.id = cm.merchant_id and cm.product_id = co.coupon_id
- and cm.status = 0) else 0 end) as merchant_id,
- cu.phone,bu.verify_merchant_name,cal.channel_type
-
- (case when couc.mc = 1 then m1.name else '[多商户通用]' end) as merchant_name,
- (case when couc.mc = 1 then m1.id else 0 end) as merchant_id,
- cu.phone,m2.name as verify_merchant_name,cal.channel_type
- -->
-
- co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.order_id,
- co.create_date,co.update_date,co.coupon_price, co.verify_type, co.verify_remark,co.pay_vendor,
- co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`,
- c.title,c.sale_price,c.use_price,c.price,
- co.send_merchant_id,c.unit,c.auto_refund,c.business,c.subsidy_type,c.source_type,ms.subsidy subsidy_num,
- (CASE WHEN couc.mc = 1 THEN m1.name ELSE '[多商户通用]' END) AS merchant_name,
- (CASE WHEN couc.mc = 1 THEN m1.id ELSE 0 END) AS merchant_id,
- cu.phone,m2.name AS verify_merchant_name,cal.channel_type
- </sql>
-
- <sql id="allAdminCouponOrderDetailColumns">
- co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,
- co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.verify_remark, co.pay_vendor,
- co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`,
- c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,c.auto_refund,c.business,c.subsidy_type,ms.subsidy subsidy_num,
- bu.name, bu.phone as bphone,
- cu.phone,
- m.name as merchant_name,m.id as merchant_id
- </sql>
-
- <select id="findListOfAdmin" parameterType="com.iformall.domain.vo.WxCouponOrderBVo" resultMap="AdminBVoResultMap">
- select <include refid="allAdminCouponOrderListColumns" />
-
- FROM (
- SELECT wcm.product_id,wcm.merchant_id,COUNT(1) AS mc
- FROM wx_coupon_merchant wcm
- WHERE STATUS = 0
- <if test=" null != tenantId and '' != tenantId">
- and wcm.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and wcm.`parent_tenant_id` = #{parentTenantId}
- </if>
- GROUP BY product_id) couc
- RIGHT JOIN (
- SELECT co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.coupon_type,
- co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.auto_refund,co.verify_type,co.verify_remark,co.pay_vendor
- ,co.send_merchant_id,co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`
- FROM wx_coupon_order co WHERE 1=1
- <if test=" null != tenantId and '' != tenantId">
- and co.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
- ) co
- ON co.coupon_id = couc.product_id
- LEFT JOIN wx_c_user_basic_info cu ON cu.id=co.c_user_id
- LEFT JOIN wx_coupon c ON c.id = co.coupon_id
- LEFT JOIN wx_merchant m1 ON m1.id = couc.merchant_id
- LEFT JOIN wx_merchant_subsidy ms ON co.id = ms.coupon_order_id AND ms.type = 1
- LEFT JOIN wx_merchant_b_user mbu ON mbu.id = co.b_user_id LEFT JOIN wx_merchant m2 ON m2.id = mbu.merchant_id
- LEFT JOIN wx_coupon_action_log cal ON cal.coupon_order_id = co.id AND cal.coupon_id = co.coupon_id
- where 1=1
- <choose>
- <when test=" null != couponType">
- and co.coupon_type = #{couponType}
- </when>
- <otherwise>
- <!-- and co.coupon_type != 5 -->
- and co.coupon_type != 11
- <!-- and co.coupon_type != 12 -->
- <!-- and co.coupon_type != 51 -->
- and co.coupon_type < 100
- </otherwise>
- </choose>
- <if test=" null != tenantId and '' != tenantId">
- and co.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != cUserPhone and '' != cUserPhone">
- and cu.`phone` = #{cUserPhone}
- </if>
-
- <if test=" null != couponOrderStatus ">
- and co.coupon_order_status = #{couponOrderStatus}
- </if>
-
- <if test=" null != shippingType ">
- and co.`shipping_type` = #{shippingType}
- </if>
-
- <if test=" null != merchantName and merchantName!=''">
-
- and (case when couc.mc=1
- then
- m1.name
- <!--(select m.name from wx_merchant m, wx_coupon_merchant cm
- where m.id = cm.merchant_id
- and cm.product_id=co.coupon_id
- and cm.status = 0)-->
- else'[多商户通用]' end)
- like concat('%', #{merchantName},'%')
- </if>
-
- <if test="startDate != null">
- AND co.create_date > #{startDate,jdbcType=TIMESTAMP}
- </if>
-
- <if test="endDate != null">
- AND co.create_date < #{endDate,jdbcType=TIMESTAMP}
- </if>
-
- <if test="verifyStartDate != null">
- AND co.update_date > #{verifyStartDate,jdbcType=TIMESTAMP}
- </if>
-
- <if test="verifyEndDate != null">
- AND co.update_date < #{verifyEndDate,jdbcType=TIMESTAMP}
- </if>
-
- <if test=" null != id ">
- and co.id = #{id}
- </if>
- <if test=" null != orderId ">
- and co.order_id = #{orderId}
- </if>
- <if test=" null != couponId ">
- and c.id = #{couponId}
- </if>
- <if test=" null != title ">
- and c.title like concat('%', #{title},'%')
- </if>
- <if test=" null != type ">
- and c.`type` = #{type}
- </if>
- <if test=" null != business ">
- and c.business = #{business}
- </if>
- <if test=" null != sourceType ">
- and c.`source_type` = #{sourceType}
- </if>
- <if test=" null != verifyMerchantName and ''!= verifyMerchantName ">
- and bu.verify_merchant_name = #{verifyMerchantName}
- </if>
-
- <if test="null!=building">
- and co.coupon_id in(
- select cm.product_id from wx_merchant_shop ms left join wx_merchant m on ms.merchant_id=m.id
- left join wx_shop s on ms.shop_id=s.id
- left join wx_coupon_merchant cm on ms.merchant_id=cm.merchant_id
- where ms.is_del=0 and s.building=#{building}
- <if test=" null != tenantId and '' != tenantId">
- and ms.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and ms.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="null!=floor">
- and s.floor=#{floor}
- </if>
- )
- </if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- <if test=" null == sortColumns">order by co.create_date desc,co.id desc</if>
-
- </select>
-
- <select id="findGoodsList" parameterType="com.iformall.domain.vo.WxCouponOrderBVo" resultMap="AdminBVoResultMap">
- select
- co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,
- co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.verify_remark, co.pay_vendor,
- co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`,
- c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,c.auto_refund,c.business,c.subsidy_type,
- cu.phone
- FROM wx_coupon_order co
- left join wx_coupon_merchant wcm on co.coupon_id = wcm.product_id and wcm.merchant_id = #{merchantId}
- LEFT JOIN wx_c_user_basic_info cu ON cu.id=co.c_user_id
- LEFT JOIN wx_coupon c ON c.id = co.coupon_id
- where wcm.merchant_id = #{merchantId}
- <choose>
- <when test=" null != couponType">
- and co.coupon_type = #{couponType}
- </when>
- <otherwise>
- <!-- and co.coupon_type != 5 -->
- and co.coupon_type != 11
- <!-- and co.coupon_type != 12 -->
- <!-- and co.coupon_type != 51 -->
- and co.coupon_type < 100
- </otherwise>
- </choose>
- <if test=" null != tenantId and '' != tenantId">
- and co.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != cUserPhone and '' != cUserPhone">
- and cu.`phone` = #{cUserPhone}
- </if>
-
- <if test=" null != couponOrderStatus ">
- and co.coupon_order_status = #{couponOrderStatus}
- </if>
- <if test=" null != shippingStatuss ">
- and co.`shipping_status` in
- <foreach collection="shippingStatuss" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
-
- <if test="startDate != null">
- AND co.create_date > #{startDate,jdbcType=TIMESTAMP}
- </if>
-
- <if test="endDate != null">
- AND co.create_date < #{endDate,jdbcType=TIMESTAMP}
- </if>
-
- <if test="verifyStartDate != null">
- AND co.update_date > #{verifyStartDate,jdbcType=TIMESTAMP}
- </if>
-
- <if test="verifyEndDate != null">
- AND co.update_date < #{verifyEndDate,jdbcType=TIMESTAMP}
- </if>
-
- <if test=" null != id ">
- and co.id = #{id}
- </if>
- <if test=" null != orderId ">
- and co.order_id = #{orderId}
- </if>
- <if test=" null != couponId ">
- and c.id = #{couponId}
- </if>
- <if test=" null != title ">
- and c.title like concat('%', #{title},'%')
- </if>
- <if test=" null != type ">
- and c.`type` = #{type}
- </if>
- <if test=" null != business ">
- and c.business = #{business}
- </if>
- <if test=" null != sourceType ">
- and c.`source_type` = #{sourceType}
- </if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- <if test=" null == sortColumns">order by co.create_date desc,co.id desc</if>
-
- </select>
-
-
- <select id="findDetailOfAdmin" parameterType="java.util.HashMap" resultMap="BVoResultMap">
- select <include refid="allAdminCouponOrderDetailColumns" />
- from wx_coupon c, wx_coupon_order co
- left join wx_c_user_basic_info cu on cu.id = co.c_user_id
- left join wx_merchant_b_user bu on co.b_user_id = bu.id
- left join wx_merchant m on m.id = bu.merchant_id
- left join wx_merchant_subsidy ms on co.id = ms.coupon_order_id and ms.type = 1
- where co.id = #{id} and co.tenant_id = #{tenantId} and cu.final_tenant_id = #{finalTenantId}
- and c.id = co.coupon_id
- </select>
-
- <sql id="allBUserVerifiedCouponOrderColumns">
- co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.verify_remark,co.pay_vendor,
- co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`,
- c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,
- bu.name,
- cu.phone
- </sql>
-
- <sql id="allBUserOrderedCouponOrderColumns">
- co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.verify_remark,co.pay_vendor,
- co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`,
- c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,
- cu.phone
- </sql>
-
-
- <select id="findListOfOrderedByDateForBUser" parameterType="map" resultMap="BVoResultMap">
- select <include refid="allBUserOrderedCouponOrderColumns" />
- from wx_coupon_order co,wx_coupon c,wx_c_user_basic_info cu,wx_coupon_merchant cm,
- (select tco.id as tcoid,
- (select count(*) from wx_coupon_merchant tcm
- where tcm.product_id = tco.coupon_id
- and tcm.status = 0) as mc
- from wx_coupon_order tco) com
- where com.mc = 1
- and com.tcoid = co.id
- and cm.merchant_id = #{merchantId}
- and co.tenant_id = #{tenantId}
- and cm.product_id = c.id
- and cm.status = 0
- 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_coupon c,wx_c_user_basic_info cu,wx_merchant_b_user bu
- where co.coupon_id = c.id
- and co.tenant_id = #{tenantId}
- and cu.id = co.c_user_id
- and bu.id = co.b_user_id
- and bu.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'
- order by co.update_date desc
- </select>
-
- <sql id="allCouponOrderColumns">
- co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,
- co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.verify_remark,co.pay_vendor,
- co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`
- </sql>
-
- <select id="findListOfOrderedByDate" parameterType="map" resultMap="BaseResultMap">
- select <include refid="allCouponOrderColumns" />
- from wx_coupon_order co,wx_coupon_merchant cm,
- (select tco.id as tcoid,
- (select count(*) from wx_coupon_merchant tcm
- where tcm.product_id = tco.coupon_id
- and tcm.status = 0)
- as mc
- from wx_coupon_order tco) com
- where com.mc = 1
- and co.tenant_id = #{tenantId}
- and com.tcoid = co.id
- and cm.status = 0
- and cm.merchant_id = #{merchantId}
- and cm.product_id = co.coupon_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>
- </select>
-
- <select id="findListOfVerifiedByDate" parameterType="map" resultMap="BaseResultMap">
- select <include refid="allCouponOrderColumns" />
- from wx_coupon_order co, wx_merchant_b_user mbu
- where mbu.id = co.b_user_id
- and co.tenant_id = #{tenantId}
- <if test="merchantId != null">
- and mbu.merchant_id = #{merchantId}
- </if>
- <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="allCUserCouponOrderDetailColumns">
- co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.verify_remark,co.pay_vendor,
- co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`,
- c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.detail,c.remark,c.valid_type,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date,c.auto_refund
- </sql>
-
- <sql id="simpleCUserCouponOrderDetailColumns">
- co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.verify_remark,co.pay_vendor,
- co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`
- </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="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
- <result column="coupon_type" jdbcType="INTEGER" property="couponType" />
- <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
- <result column="owner_id" jdbcType="BIGINT" property="ownerId" />
- <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="verify_type" jdbcType="INTEGER" property="verifyType" />
- <result column="verify_remark" jdbcType="VARCHAR" property="verifyRemark" />
- <result column="pay_vendor" jdbcType="INTEGER" property="payVendor" />
-
- <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
- <result column="shipping_type" jdbcType="INTEGER" property="shippingType"/>
- <result column="shipping_address" jdbcType="VARCHAR" property="shippingAddress"/>
- <result column="shipping_status" jdbcType="INTEGER" property="shippingStatus"/>
- <result column="delivery_info" jdbcType="VARCHAR" property="deliveryInfo"/>
-
- <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="tail_price" jdbcType="INTEGER" property="tailPrice"/>
- <result column="orig_price" jdbcType="INTEGER" property="origPrice"/>
-
- <result column="unit" jdbcType="INTEGER" property="unit" />
- <result column="remark" jdbcType="VARCHAR" property="remark" />
- <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="auto_refund" jdbcType="INTEGER" property="autoRefund" />
-
- <result column="pick_start_date" jdbcType="TIMESTAMP" property="pickStartDate"/>
- <result column="pick_end_date" jdbcType="TIMESTAMP" property="pickEndDate"/>
-
- <result column="send_channel_type" jdbcType="INTEGER" property="sendChannelType" />
-
- <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="CVoResultMapOptimize" type="com.iformall.domain.vo.WxCouponOrderCVo">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
- <result column="coupon_type" jdbcType="INTEGER" property="couponType" />
- <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
- <result column="owner_id" jdbcType="BIGINT" property="ownerId" />
- <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="verify_type" jdbcType="INTEGER" property="verifyType" />
- <result column="verify_remark" jdbcType="VARCHAR" property="verifyRemark" />
- <result column="pay_vendor" jdbcType="INTEGER" property="payVendor" />
-
- <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
- <result column="shipping_type" jdbcType="INTEGER" property="shippingType"/>
- <result column="shipping_address" jdbcType="VARCHAR" property="shippingAddress"/>
- <result column="shipping_status" jdbcType="INTEGER" property="shippingStatus"/>
- <result column="delivery_info" jdbcType="VARCHAR" property="deliveryInfo"/>
-
- <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="unit" jdbcType="INTEGER" property="unit" />
- <result column="remark" jdbcType="VARCHAR" property="remark" />
- <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="auto_refund" jdbcType="INTEGER" property="autoRefund" />
-
- <result column="send_channel_type" jdbcType="INTEGER" property="sendChannelType" />
- </resultMap>
-
-
- <!-- <select id="findListOfCUser" parameterType="com.iformall.domain.vo.WxCouponOrderCVo" resultMap="CVoResultMap">
- select <include refid="allCUserCouponOrderListColumns" />
- from wx_coupon c,wx_coupon_order co
- left join wx_coupon_action_log cal on cal.coupon_order_id = co.id
- where 1=1
- and co.coupon_id = c.id
- and co.coupon_type != 5
- and co.coupon_type != 51
- and co.coupon_type < 100
- <if test="cUserId != null">
- and co.c_user_id = #{cUserId}
- </if>
- <if test="ownerId != null">
- and co.owner_id = #{ownerId}
- </if>
- <if test="tenantId != null">
- and co.tenant_id = #{tenantId}
- </if>
- <if test="couponOrderStatus != null and 0 == couponOrderStatus">
- AND (co.coupon_order_status = #{couponOrderStatus} OR co.coupon_order_status = 100 )
- </if>
- <if test="couponOrderStatus != null and 0 != couponOrderStatus">
- AND co.coupon_order_status = #{couponOrderStatus}
- </if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </select> -->
-
- <!-- <sql id="allCUserCouponOrderListColumns">
- co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,
- c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.valid_type,c.valid_start_date,c.valid_end_date,c.auto_refund,
- cal.channel_type as send_channel_type
- </sql> -->
- <sql id="allCUserCouponOrderListColumns">
- co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.verify_remark,co.pay_vendor,
- co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`,
- c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.valid_type,c.valid_start_date,c.valid_end_date,c.auto_refund
- </sql>
-
- <select id="findListOfCUserOptimize" parameterType="com.iformall.domain.vo.WxCouponOrderCVo" resultMap="CVoResultMapOptimize">
- select <include refid="allCUserCouponOrderListColumns" />
- from wx_coupon c,wx_coupon_order co
- <!-- left join wx_coupon_action_log cal on cal.coupon_order_id = co.id -->
- where 1=1
- and co.coupon_id = c.id
- <choose>
- <when test=" null != couponType">
- and co.coupon_type = #{couponType}
- </when>
- <otherwise>
- and co.coupon_type != 5
- and co.coupon_type != 11
- and co.coupon_type != 12
- and co.coupon_type != 51
- and co.coupon_type < 100
- </otherwise>
- </choose>
-
- <if test="cUserId != null">
- and co.c_user_id = #{cUserId}
- </if>
- <if test="ownerId != null">
- and co.owner_id = #{ownerId}
- </if>
- <if test=" null != tenantId and '' != tenantId">
- and co.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="couponOrderStatus != null and 0 == couponOrderStatus">
- AND (co.coupon_order_status = #{couponOrderStatus} OR co.coupon_order_status = 100 )
- </if>
- <if test="couponOrderStatus != null and 0 != couponOrderStatus">
- AND co.coupon_order_status = #{couponOrderStatus}
- </if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </select>
-
-
-
-
- <select id="findDetailOfCUser" parameterType="java.util.HashMap" resultMap="CVoResultMap">
- select <include refid="allCUserCouponOrderDetailColumns" />
- from wx_coupon_order co, wx_coupon c
- where co.coupon_id = c.id
- and co.id = #{id} and co.tenant_id = #{tenantId}
- </select>
-
- <select id="findSimpleDetailOfCUser" parameterType="java.util.HashMap" resultMap="CVoResultMap">
- select <include refid="simpleCUserCouponOrderDetailColumns" />
- from wx_coupon_order co
- where co.id = #{id} and co.tenant_id = #{tenantId}
- </select>
-
- <select id="findAvailCouponOrder" parameterType="java.util.Map" resultMap="CVoResultMap">
- select <include refid="allCUserCouponOrderDetailColumns" />
- from wx_coupon_order co
- inner join wx_coupon c on c.id = co.coupon_id
- inner join wx_coupon_merchant cm on cm.product_id = co.coupon_id
- where co.c_user_id = #{cUserId}
- and co.coupon_order_status = 0
- <if test=" null != tenantId and '' != tenantId">
- and co.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
- and cm.merchant_id = #{merchantId}
- and co.expired_time > now()
- and c.type in (1, 2, 6)
- union
- select <include refid="allCUserCouponOrderDetailColumns" />
- from wx_coupon_order co
- inner join wx_coupon c on c.id = co.coupon_id
- inner join wx_coupon_merchant cm on cm.product_id = co.coupon_id
- inner join pos_coupon_order_verify pco on pco.coupon_order_id = co.id
- where co.c_user_id = #{cUserId}
- and co.coupon_order_status = 100
- <if test=" null != tenantId and '' != tenantId">
- and co.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
- and cm.merchant_id = #{merchantId}
- and co.expired_time > now()
- and c.type in (1, 2, 6)
- <if test="posOrderId != null">
- and pco.pos_order_id = #{posOrderId}
- </if>
- </select>
-
- <sql id="allCUserCouponOrderCarListColumns">
- co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.verify_remark,co.pay_vendor,
- c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,
- json_extract(car.vendor_params,'$.id') as coupon_free_id,car.vendor_params
- </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="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
- <result column="coupon_type" jdbcType="INTEGER" property="couponType" />
- <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
- <result column="owner_id" jdbcType="BIGINT" property="ownerId" />
- <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="verify_type" jdbcType="INTEGER" property="verifyType" />
- <result column="verify_remark" jdbcType="VARCHAR" property="verifyRemark" />
- <result column="pay_vendor" jdbcType="INTEGER" property="payVendor" />
-
- <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="vendor_params" jdbcType="VARCHAR" property="vendorParams" />
-
- <result column="coupon_free_id" jdbcType="INTEGER" property="couponFreeId"/>
-
- <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>
-
-
- <select id="findCarListOfCUser" parameterType="com.iformall.domain.vo.WxCouponOrderCarCVo" resultMap="CCarVoResultMap">
- select <include refid="allCUserCouponOrderCarListColumns" />
- from wx_coupon_order co, wx_coupon c, wx_coupon_car car
- where co.coupon_id = c.id
- and co.coupon_id = car.id
- and c.type in (5,51)
- <if test="cUserId != null">
- and co.c_user_id = #{cUserId}
- </if>
- <if test=" null != tenantId and '' != tenantId">
- and co.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="id != null">
- and co.id = #{id}
- </if>
- <if test="couponOrderStatus != null and 0 == couponOrderStatus ">
- AND ( co.coupon_order_status = #{couponOrderStatus} OR co.coupon_order_status = 100 )
- </if>
- <if test="couponOrderStatus != null and 0 != couponOrderStatus ">
- AND co.coupon_order_status = #{couponOrderStatus}
- </if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </select>
-
- <resultMap id="CCardVoResultMap" type="com.iformall.domain.vo.WxCardCVo">
- <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="coupon_type" jdbcType="INTEGER" property="couponType" />
- <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
- <result column="owner_id" jdbcType="BIGINT" property="ownerId" />
- <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="cover_img" jdbcType="VARCHAR" property="coverImg" />
- <result column="title" jdbcType="VARCHAR" property="title" />
- <result column="sub_title" jdbcType="VARCHAR" property="subTitle" />
- <result column="detail" jdbcType="VARCHAR" property="detail" />
- <result column="unit" jdbcType="INTEGER" property="unit" />
- <result column="remark" jdbcType="VARCHAR" property="remark" />
-
- <result column="amount" jdbcType="INTEGER" property="amount" />
- <result column="remaining_amount" jdbcType="INTEGER" property="remainingAmount" />
- <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
-
- <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>
- <collection column="{cardId=id,tenantId=tenant_id}" property="cardSpendList"
- ofType="com.iformall.domain.vo.WxCardSpendVo"
- javaType="java.util.List"
- select="com.iformall.mapper.WxCardSpendMapper.findCardSpendVoList" >
- </collection>
- </resultMap>
-
- <sql id="allCUserCardListColumns">
- co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,
- c.cover_img,c.title,c.sub_title,c.detail,c.unit,c.remark,
- a.amount,a.remaining_amount,a.support_transfer
- </sql>
-
- <sql id="allCUserCardDetailColumns">
- co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_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.cover_img,c.title,c.sub_title,c.sale_price,c.price,c.unit,c.detail,c.remark,
- a.amount,a.remaining_amount,a.support_transfer
- </sql>
-
-
- <select id="findCardListOfCUser" parameterType="com.iformall.domain.vo.WxCardCVo" resultMap="CCardVoResultMap">
-
- select c.* from (
- select id,tenant_id,parent_tenant_id,0 coupon_id,0 coupon_type,expired_time,`status`as
- coupon_order_status,create_date,update_date,'' cover_img,title,'' sub_title,'' detail,0 unit,
- '' remark,amount,remain_amount as remaining_amount,0 support_transfer
- from wx_card_transfer_info where 1=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="ownerId != null">
- and from_user = #{ownerId}
- </if>
- <choose>
- <when test="couponOrderStatus != null">
- and status = #{couponOrderStatus}
- </when>
- <otherwise>
- and status=8
- </otherwise>
- </choose>
- union
- select
- <include refid="allCUserCardListColumns"/>
- from wx_coupon_order co
- inner join wx_coupon c on co.coupon_id = c.id
- inner join wx_card_info a on co.id=a.id
- where 1=1
- and co.coupon_type = 100
- <if test=" null != tenantId and '' != tenantId">
- and co.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
-
- <if test="cUserId != null">
- and co.c_user_id = #{cUserId}
- </if>
- <if test="ownerId != null">
- and co.owner_id = #{ownerId}
- </if>
- <if test="couponOrderStatus != null">
- and co.coupon_order_status = #{couponOrderStatus}
- </if>
- <if test=" null != statusS ">
- and co.coupon_order_status in
- <foreach collection="statusS" index="index" item="sItem" open="(" separator="," close=")">
- #{sItem}
- </foreach>
- </if>
- ) c
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </select>
-
- <select id="findCardDetailOfCUser" parameterType="java.util.HashMap" resultMap="CCardVoResultMap">
- select <include refid="allCUserCardDetailColumns" />
- from wx_coupon_order co,wx_coupon c, wx_card_info a
- where co.coupon_id = c.id and co.id = a.id
- and co.id = #{id} and co.tenant_id = #{tenantId}
- </select>
-
- <update id="cardDefer" parameterType="map">
- update wx_coupon_order set coupon_order_status = 4,update_date = now(), expired_time= #{expireTime} where coupon_id = #{couponId} and tenant_id = #{tenantId} and coupon_order_status in (4, 5)
- </update>
-
- <select id="cardDeferCouponOrderId" parameterType="java.util.HashMap" resultType="java.lang.Long">
- select id from wx_coupon_order where coupon_id = #{couponId} and tenant_id = #{tenantId} and coupon_order_status in (4, 5)
- </select>
-
-
- <select id="findWriteOffCount" parameterType="com.iformall.domain.po.WxCouponOrder" resultType="java.lang.Integer">
- select count(co.id)
- from wx_coupon_order co
- left join wx_merchant_b_user mbu on co.b_user_id = mbu.id
- where 1 = 1
-
- <if test=" null != tenantId and '' != tenantId">
- and co.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and co.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != merchantId ">
- and mbu.`merchant_id` = #{merchantId}
- </if>
- <if test=" null != couponType ">
- and co.`coupon_type` = #{couponType}
- </if>
- <if test=" null != couponOrderStatus ">
- and co.`coupon_order_status` = #{couponOrderStatus}
- </if>
- <if test=" null != sendMerchantId ">
- and co.`send_merchant_id` = #{sendMerchantId}
- </if>
- <if test=" null != startTime ">
- AND co.update_date >= #{startTime}
- </if>
- <if test=" null != endTime ">
- AND co.update_date <= #{endTime}
- </if>
-
- </select>
-
- </mapper>
|