Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 

205 rader
6.9 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 != sortColumns"> order by ${sortColumns} </if>
  51. </sql>
  52. <select id="findList" parameterType="com.iformall.domain.po.WxCouponMerchant" resultMap="BaseResultMap">
  53. select
  54. <include refid="allColumns"/>
  55. from wx_coupon_merchant
  56. <include refid="dynamicWhereConditions" />
  57. </select>
  58. <sql id="allMerchantVoColumns">
  59. m.id,m.img_url,m.name,m.link_phone,m.status,m.business_id,m.sub_business_id,
  60. cm.parameter,m.link_line_phone
  61. </sql>
  62. <resultMap id="MerchantVoResultMap" type="com.iformall.domain.vo.WxMerchantVo">
  63. <id column="id" jdbcType="BIGINT" property="id"/>
  64. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  65. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
  66. <result column="img_url" jdbcType="VARCHAR" property="merchantImgUrl"/>
  67. <result column="name" jdbcType="VARCHAR" property="merchantName"/>
  68. <result column="link_phone" jdbcType="VARCHAR" property="merchantLinkPhone"/>
  69. <result column="status" jdbcType="VARCHAR" property="merchantStatus"/>
  70. <result column="business_id" jdbcType="INTEGER" property="businessId"/>
  71. <result column="sub_business_id" jdbcType="INTEGER" property="subBusinessId"/>
  72. <result column="parameter" jdbcType="VARCHAR" property="parameter"/>
  73. <result column="link_line_phone" property="linkLinePhone"/>
  74. <collection column="{merchantId=id}" property="shopVoList"
  75. ofType="com.iformall.domain.vo.WxShopVo"
  76. javaType="java.util.List"
  77. select="com.iformall.mapper.WxShopMapper.findShopVoList">
  78. </collection>
  79. </resultMap>
  80. <select id="findMerchantVoList" parameterType="java.util.Map" resultMap="MerchantVoResultMap">
  81. select
  82. <include refid="allMerchantVoColumns"/>
  83. from wx_coupon_merchant cm
  84. left join wx_merchant m on m.id = cm.merchant_id
  85. where cm.status = 0
  86. and cm.product_id = #{productId} and cm.tenant_id = #{tenantId}
  87. </select>
  88. <sql id="allMerchantNameColumns">
  89. m.id,m.name,m.status
  90. </sql>
  91. <sql id="allMerchantBaseColumns">
  92. m.id,
  93. m.img_url,m.name,m.link_phone,m.status,m.business_id,m.sub_business_id,
  94. cm.parameter
  95. </sql>
  96. <select id="findMerchantNameList" parameterType="java.util.Map" resultMap="MerchantVoResultMap">
  97. select
  98. <include refid="allMerchantNameColumns"/>
  99. from wx_coupon_merchant cm
  100. left join wx_merchant m on m.id = cm.merchant_id
  101. where cm.status = 0
  102. and cm.product_id = #{productId} and cm.tenant_id = #{tenantId}
  103. </select>
  104. <select id="findMerchantBaseList" parameterType="java.util.Map" resultMap="MerchantVoResultMap">
  105. select
  106. <include refid="allMerchantBaseColumns"/>
  107. from wx_coupon_merchant cm
  108. left join wx_merchant m on m.id = cm.merchant_id
  109. where cm.status = 0
  110. and cm.product_id = #{productId} and cm.tenant_id = #{tenantId}
  111. </select>
  112. <resultMap id="MerchantProductVoResultMap" type="com.iformall.domain.vo.WxMerchantProductVo">
  113. <result column="product_id" jdbcType="BIGINT" property="productId"/>
  114. <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
  115. <result column="mc" jdbcType="INTEGER" property="mc"/>
  116. </resultMap>
  117. <select id = "findMerchantProduct" parameterType="java.util.Map" resultMap="MerchantProductVoResultMap">
  118. SELECT wcm.product_id,wcm.merchant_id,COUNT(1) AS mc
  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 != merchantIdList">
  125. and wcm.merchant_id in
  126. <foreach collection="merchantIdList" index="index" item="merchantIdItem" open="(" separator="," close=")">
  127. #{merchantIdItem}
  128. </foreach>
  129. </if>
  130. GROUP BY product_id
  131. </select>
  132. <select id = "findMerchantProductIds" parameterType="java.util.Map" resultType="Long">
  133. SELECT distinct wcm.product_id
  134. FROM wx_coupon_merchant wcm
  135. WHERE wcm.STATUS = 0
  136. <if test=" null != tenantId and '' != tenantId">
  137. and wcm.`tenant_id` = #{tenantId}
  138. </if>
  139. <if test=" null != merchantIdList">
  140. and wcm.merchant_id in
  141. <foreach collection="merchantIdList" index="index" item="merchantIdItem" open="(" separator="," close=")">
  142. #{merchantIdItem}
  143. </foreach>
  144. </if>
  145. </select>
  146. <select id = "findOneMerchantProductIds" parameterType="java.util.Map" resultType="Long">
  147. SELECT wcm.product_id
  148. FROM wx_coupon_merchant wcm
  149. WHERE wcm.STATUS = 0
  150. <if test=" null != tenantId and '' != tenantId">
  151. and wcm.`tenant_id` = #{tenantId}
  152. </if>
  153. <if test=" null != merchantId">
  154. and wcm.merchant_id = #{merchantId}
  155. </if>
  156. </select>
  157. <select id = "findMerchantByProductIds" parameterType="java.util.Map" resultType="Long">
  158. SELECT distinct wcm.merchant_id
  159. FROM wx_coupon_merchant wcm
  160. WHERE wcm.STATUS = 0
  161. <if test=" null != tenantId and '' != tenantId">
  162. and wcm.`tenant_id` = #{tenantId}
  163. </if>
  164. <if test=" null != productIds">
  165. and wcm.product_id in
  166. <foreach collection="productIds" index="index" item="productIdItem" open="(" separator="," close=")">
  167. #{productIdItem}
  168. </foreach>
  169. </if>
  170. </select>
  171. </mapper>