No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 

190 líneas
6.1 KiB

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.iformall.mapper.WxCouponMerchantMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCouponMerchant">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  7. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
  8. <result column="product_id" jdbcType="BIGINT" property="productId" />
  9. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  10. <result column="parameter" jdbcType="VARCHAR" property="parameter" />
  11. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  12. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  13. <result column="status" jdbcType="INTEGER" property="status" />
  14. </resultMap>
  15. <sql id="allColumns">
  16. `id`,`product_id`,`merchant_id`,`parameter`,`create_date`,`update_date`,`status`
  17. </sql>
  18. <sql id="dynamicWhereConditions">
  19. where 1 = 1
  20. <if test=" null != id ">
  21. and `id` = #{id}
  22. </if>
  23. <if test=" null != tenantId and '' != tenantId">
  24. and `tenant_id` = #{tenantId}
  25. </if>
  26. <if test=" null != parentTenantId and '' != parentTenantId">
  27. and `parent_tenant_id` = #{parentTenantId}
  28. </if>
  29. <if test=" null != productId ">
  30. and `product_id` = #{productId}
  31. </if>
  32. <if test=" null != merchantId ">
  33. and `merchant_id` = #{merchantId}
  34. </if>
  35. <if test=" null != createDate ">
  36. and `create_date` = #{createDate}
  37. </if>
  38. <if test=" null != updateDate ">
  39. and `update_date` = #{updateDate}
  40. </if>
  41. <if test=" null != status ">
  42. and `status` = #{status}
  43. </if>
  44. <if test=" null != ids ">
  45. and id in
  46. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  47. #{idItem}
  48. </foreach>
  49. </if>
  50. <if test=" null != merchantIds ">
  51. and merchant_id in
  52. <foreach collection="merchantIds" index="index" item="merchantIdItem" open="(" separator="," close=")">
  53. #{merchantIdItem}
  54. </foreach>
  55. </if>
  56. <if test=" null != productIds ">
  57. and product_id in
  58. <foreach collection="productIds" index="index" item="productIdItem" open="(" separator="," close=")">
  59. #{productIdItem}
  60. </foreach>
  61. </if>
  62. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  63. </sql>
  64. <select id="findList" parameterType="com.iformall.domain.po.WxCouponMerchant" resultMap="BaseResultMap">
  65. select
  66. <include refid="allColumns"/>
  67. from wx_coupon_merchant
  68. <include refid="dynamicWhereConditions" />
  69. </select>
  70. <select id="findMerchantIdListByProduct" parameterType="java.util.Map" resultMap="BaseResultMap">
  71. select distinct cm.merchant_id
  72. from wx_coupon_merchant cm
  73. where cm.status = 0
  74. and cm.product_id = #{productId} and cm.tenant_id = #{tenantId}
  75. </select>
  76. <select id="findMerchantListByProduct" parameterType="java.util.Map" resultMap="BaseResultMap">
  77. select
  78. cm.parameter,cm.merchant_id
  79. from wx_coupon_merchant cm
  80. where cm.status = 0
  81. and cm.product_id = #{productId} and cm.tenant_id = #{tenantId}
  82. </select>
  83. <resultMap id="MerchantProductVoResultMap" type="com.iformall.domain.vo.WxMerchantProductVo">
  84. <result column="product_id" jdbcType="BIGINT" property="productId"/>
  85. <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
  86. <result column="mc" jdbcType="INTEGER" property="mc"/>
  87. </resultMap>
  88. <select id = "findMerchantProduct" parameterType="java.util.Map" resultMap="MerchantProductVoResultMap">
  89. SELECT wcm.product_id,wcm.merchant_id,COUNT(1) AS mc
  90. FROM wx_coupon_merchant wcm
  91. WHERE wcm.STATUS = 0
  92. <if test=" null != tenantId and '' != tenantId">
  93. and wcm.`tenant_id` = #{tenantId}
  94. </if>
  95. <if test=" null != merchantIdList">
  96. and wcm.merchant_id in
  97. <foreach collection="merchantIdList" index="index" item="merchantIdItem" open="(" separator="," close=")">
  98. #{merchantIdItem}
  99. </foreach>
  100. </if>
  101. GROUP BY product_id
  102. </select>
  103. <select id = "findMerchantProductIds" parameterType="java.util.Map" resultType="Long">
  104. SELECT distinct wcm.product_id
  105. FROM wx_coupon_merchant wcm
  106. WHERE wcm.`tenant_id` = #{tenantId}
  107. <if test=" null != status">
  108. and wcm.STATUS = #{status}
  109. </if>
  110. <if test=" null != merchantIdList">
  111. and wcm.merchant_id in
  112. <foreach collection="merchantIdList" index="index" item="merchantIdItem" open="(" separator="," close=")">
  113. #{merchantIdItem}
  114. </foreach>
  115. </if>
  116. </select>
  117. <select id = "findMerchantByProductIds" parameterType="java.util.Map" resultType="Long">
  118. SELECT distinct wcm.merchant_id
  119. FROM wx_coupon_merchant wcm
  120. WHERE wcm.STATUS = 0
  121. <if test=" null != tenantId and '' != tenantId">
  122. and wcm.`tenant_id` = #{tenantId}
  123. </if>
  124. <if test=" null != productIds">
  125. and wcm.product_id in
  126. <foreach collection="productIds" index="index" item="productIdItem" open="(" separator="," close=")">
  127. #{productIdItem}
  128. </foreach>
  129. </if>
  130. </select>
  131. <select id = "findOnlyMerchantProduct" parameterType="java.util.Map" resultMap="MerchantProductVoResultMap">
  132. SELECT wcm.product_id,wcm.merchant_id,COUNT(1) AS mc
  133. FROM wx_coupon_merchant wcm
  134. WHERE wcm.STATUS = 0
  135. <if test=" null != tenantId and '' != tenantId">
  136. and wcm.`tenant_id` = #{tenantId}
  137. </if>
  138. GROUP BY product_id
  139. HAVING mc = 1
  140. <if test=" null != merchantIdList">
  141. and wcm.merchant_id in
  142. <foreach collection="merchantIdList" index="index" item="merchantIdItem" open="(" separator="," close=")">
  143. #{merchantIdItem}
  144. </foreach>
  145. </if>
  146. </select>
  147. <select id = "findOnlyMerchantByProductIds" parameterType="java.util.Map" resultType="Long">
  148. SELECT distinct wcm.merchant_id
  149. FROM wx_coupon_merchant wcm
  150. WHERE wcm.STATUS = 0
  151. <if test=" null != tenantId and '' != tenantId">
  152. and wcm.`tenant_id` = #{tenantId}
  153. </if>
  154. GROUP BY product_id
  155. HAVING COUNT(merchant_id) = 1
  156. <if test=" null != productIds">
  157. and wcm.product_id in
  158. <foreach collection="productIds" index="index" item="productIdItem" open="(" separator="," close=")">
  159. #{productIdItem}
  160. </foreach>
  161. </if>
  162. </select>
  163. </mapper>