后台服务
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

196 lines
6.4 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`,`tenant_id`,`parent_tenant_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" resultType="Long">
  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 != productIds">
  96. and wcm.product_id in
  97. <foreach collection="productIds" index="index" item="productIdItem" open="(" separator="," close=")">
  98. #{productIdItem}
  99. </foreach>
  100. </if>
  101. <!--<if test=" null != merchantIdList">
  102. and wcm.merchant_id in
  103. <foreach collection="merchantIdList" index="index" item="merchantIdItem" open="(" separator="," close=")">
  104. #{merchantIdItem}
  105. </foreach>
  106. </if>-->
  107. GROUP BY product_id
  108. </select>
  109. <select id = "findMerchantProductIds" parameterType="java.util.Map" resultType="Long">
  110. SELECT distinct wcm.product_id
  111. FROM wx_coupon_merchant wcm
  112. WHERE wcm.`tenant_id` = #{tenantId}
  113. <if test=" null != status">
  114. and wcm.STATUS = #{status}
  115. </if>
  116. <if test=" null != merchantIdList">
  117. and wcm.merchant_id in
  118. <foreach collection="merchantIdList" index="index" item="merchantIdItem" open="(" separator="," close=")">
  119. #{merchantIdItem}
  120. </foreach>
  121. </if>
  122. </select>
  123. <select id = "findMerchantByProductIds" parameterType="java.util.Map" resultType="Long">
  124. SELECT distinct wcm.merchant_id
  125. FROM wx_coupon_merchant wcm
  126. WHERE wcm.STATUS = 0
  127. <if test=" null != tenantId and '' != tenantId">
  128. and wcm.`tenant_id` = #{tenantId}
  129. </if>
  130. <if test=" null != productIds">
  131. and wcm.product_id in
  132. <foreach collection="productIds" index="index" item="productIdItem" open="(" separator="," close=")">
  133. #{productIdItem}
  134. </foreach>
  135. </if>
  136. </select>
  137. <select id = "findOnlyMerchantProduct" parameterType="java.util.Map" resultMap="MerchantProductVoResultMap">
  138. SELECT wcm.product_id,wcm.merchant_id,COUNT(1) AS mc
  139. FROM wx_coupon_merchant wcm
  140. WHERE wcm.STATUS = 0
  141. <if test=" null != tenantId and '' != tenantId">
  142. and wcm.`tenant_id` = #{tenantId}
  143. </if>
  144. GROUP BY product_id
  145. HAVING mc = 1
  146. <if test=" null != merchantIdList">
  147. and wcm.merchant_id in
  148. <foreach collection="merchantIdList" index="index" item="merchantIdItem" open="(" separator="," close=")">
  149. #{merchantIdItem}
  150. </foreach>
  151. </if>
  152. </select>
  153. <select id = "findOnlyMerchantByProductIds" parameterType="java.util.Map" resultType="Long">
  154. SELECT distinct wcm.merchant_id
  155. FROM wx_coupon_merchant wcm
  156. WHERE wcm.STATUS = 0
  157. <if test=" null != tenantId and '' != tenantId">
  158. and wcm.`tenant_id` = #{tenantId}
  159. </if>
  160. GROUP BY product_id
  161. HAVING COUNT(merchant_id) = 1
  162. <if test=" null != productIds">
  163. and wcm.product_id in
  164. <foreach collection="productIds" index="index" item="productIdItem" open="(" separator="," close=")">
  165. #{productIdItem}
  166. </foreach>
  167. </if>
  168. </select>
  169. </mapper>