|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- <?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.WxCouponMerchantMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCouponMerchant">
- <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="product_id" jdbcType="BIGINT" property="productId" />
- <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
- <result column="parameter" jdbcType="VARCHAR" property="parameter" />
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
- <result column="status" jdbcType="INTEGER" property="status" />
- </resultMap>
-
- <sql id="allColumns">
- `id`,`tenant_id`,`parent_tenant_id`,`product_id`,`merchant_id`,`parameter`,`create_date`,`update_date`,`status`
- </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 != productId ">
- and `product_id` = #{productId}
-
- </if>
-
- <if test=" null != merchantId ">
- and `merchant_id` = #{merchantId}
-
- </if>
-
- <if test=" null != createDate ">
- and `create_date` = #{createDate}
-
- </if>
-
- <if test=" null != updateDate ">
- and `update_date` = #{updateDate}
-
- </if>
-
- <if test=" null != status ">
- and `status` = #{status}
-
- </if>
-
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <if test=" null != merchantIds ">
- and merchant_id in
- <foreach collection="merchantIds" index="index" item="merchantIdItem" open="(" separator="," close=")">
- #{merchantIdItem}
- </foreach>
- </if>
- <if test=" null != productIds ">
- and product_id in
- <foreach collection="productIds" index="index" item="productIdItem" open="(" separator="," close=")">
- #{productIdItem}
- </foreach>
- </if>
-
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </sql>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxCouponMerchant" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_coupon_merchant
- <include refid="dynamicWhereConditions" />
- </select>
-
- <select id="findMerchantIdListByProduct" parameterType="java.util.Map" resultType="Long">
- select distinct cm.merchant_id
- from wx_coupon_merchant cm
- where cm.status = 0
- and cm.product_id = #{productId} and cm.tenant_id = #{tenantId}
- </select>
-
- <select id="findMerchantListByProduct" parameterType="java.util.Map" resultMap="BaseResultMap">
- select
- cm.parameter,cm.merchant_id
- from wx_coupon_merchant cm
- where cm.status = 0
- and cm.product_id = #{productId} and cm.tenant_id = #{tenantId}
- </select>
-
- <resultMap id="MerchantProductVoResultMap" type="com.iformall.domain.vo.WxMerchantProductVo">
- <result column="product_id" jdbcType="BIGINT" property="productId"/>
- <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
- <result column="mc" jdbcType="INTEGER" property="mc"/>
- </resultMap>
-
- <select id = "findMerchantProduct" parameterType="java.util.Map" resultMap="MerchantProductVoResultMap">
- SELECT wcm.product_id,wcm.merchant_id,COUNT(1) AS mc
- FROM wx_coupon_merchant wcm
- WHERE wcm.STATUS = 0
- <if test=" null != tenantId and '' != tenantId">
- and wcm.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != productIds">
- and wcm.product_id in
- <foreach collection="productIds" index="index" item="productIdItem" open="(" separator="," close=")">
- #{productIdItem}
- </foreach>
- </if>
- <!--<if test=" null != merchantIdList">
- and wcm.merchant_id in
- <foreach collection="merchantIdList" index="index" item="merchantIdItem" open="(" separator="," close=")">
- #{merchantIdItem}
- </foreach>
- </if>-->
- GROUP BY product_id
- </select>
-
- <select id = "findMerchantProductIds" parameterType="java.util.Map" resultType="Long">
- SELECT distinct wcm.product_id
- FROM wx_coupon_merchant wcm
- WHERE wcm.`tenant_id` = #{tenantId}
- <if test=" null != status">
- and wcm.STATUS = #{status}
- </if>
- <if test=" null != merchantIdList">
- and wcm.merchant_id in
- <foreach collection="merchantIdList" index="index" item="merchantIdItem" open="(" separator="," close=")">
- #{merchantIdItem}
- </foreach>
- </if>
- </select>
-
- <select id = "findMerchantByProductIds" parameterType="java.util.Map" resultType="Long">
- SELECT distinct wcm.merchant_id
- FROM wx_coupon_merchant wcm
- WHERE wcm.STATUS = 0
- <if test=" null != tenantId and '' != tenantId">
- and wcm.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != productIds">
- and wcm.product_id in
- <foreach collection="productIds" index="index" item="productIdItem" open="(" separator="," close=")">
- #{productIdItem}
- </foreach>
- </if>
- </select>
-
- <select id = "findOnlyMerchantProduct" parameterType="java.util.Map" resultMap="MerchantProductVoResultMap">
- SELECT wcm.product_id,wcm.merchant_id,COUNT(1) AS mc
- FROM wx_coupon_merchant wcm
- WHERE wcm.STATUS = 0
- <if test=" null != tenantId and '' != tenantId">
- and wcm.`tenant_id` = #{tenantId}
- </if>
- GROUP BY product_id
- HAVING mc = 1
- <if test=" null != merchantIdList">
- and wcm.merchant_id in
- <foreach collection="merchantIdList" index="index" item="merchantIdItem" open="(" separator="," close=")">
- #{merchantIdItem}
- </foreach>
- </if>
-
- </select>
-
- <select id = "findOnlyMerchantByProductIds" parameterType="java.util.Map" resultType="Long">
- SELECT distinct wcm.merchant_id
- FROM wx_coupon_merchant wcm
- WHERE wcm.STATUS = 0
- <if test=" null != tenantId and '' != tenantId">
- and wcm.`tenant_id` = #{tenantId}
- </if>
- GROUP BY product_id
- HAVING COUNT(merchant_id) = 1
- <if test=" null != productIds">
- and wcm.product_id in
- <foreach collection="productIds" index="index" item="productIdItem" open="(" separator="," close=")">
- #{productIdItem}
- </foreach>
- </if>
- </select>
-
- </mapper>
|