Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

206 linhas
8.3 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.WxCouponMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCoupon">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  7. <result column="type" jdbcType="INTEGER" property="type"/>
  8. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  9. <result column="title" jdbcType="VARCHAR" property="title"/>
  10. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  11. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  12. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  13. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  14. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  15. <result column="valid_type" jdbcType="INTEGER" property="validType"/>
  16. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  17. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  18. <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
  19. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  20. <result column="price" jdbcType="INTEGER" property="price"/>
  21. <result column="unit" jdbcType="INTEGER" property="unit"/>
  22. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  23. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  24. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  25. <result column="status" jdbcType="INTEGER" property="status"/>
  26. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  27. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  28. <result column="business" jdbcType="INTEGER" property="business"/>
  29. </resultMap>
  30. <sql id="allColumns">
  31. `id`,`tenant_id`,`type`,`cover_img`,`title`,`sub_title`,`sale_price`,`use_price`,`use_limit_quantity`,`send_type`,`valid_type`,`valid_start_date`,`valid_end_date`,`valid_days`,`detail`,`price`,`unit`,`remain_inventory`,`inventory`,`remark`,`status`,`create_date`,`update_date`,`business`
  32. </sql>
  33. <sql id="dynamicWhereConditions">
  34. where 1 = 1
  35. <if test=" null != id ">
  36. and `id` = #{id}
  37. </if>
  38. <if test=" null != tenantId ">
  39. and `tenant_id` = #{tenantId}
  40. </if>
  41. <if test=" null != type ">
  42. and `type` = #{type}
  43. </if>
  44. <if test=" null != coverImg ">
  45. and `cover_img` like concat('%', #{coverImg},'%')
  46. </if>
  47. <if test=" null != title and ''!=title">
  48. and `title` like concat('%', #{title},'%')
  49. </if>
  50. <if test=" null != subTitle ">
  51. and `sub_title` like concat('%', #{subTitle},'%')
  52. </if>
  53. <if test=" null != salePrice ">
  54. and `sale_price` = #{salePrice}
  55. </if>
  56. <if test=" null != usePrice ">
  57. and `use_price` = #{usePrice}
  58. </if>
  59. <if test=" null != useLimitQuantity ">
  60. and `use_limit_quantity` = #{useLimitQuantity}
  61. </if>
  62. <if test=" null != sendType ">
  63. and `send_type` = #{sendType}
  64. </if>
  65. <if test=" null != validType ">
  66. and `valid_type` = #{validType}
  67. </if>
  68. <if test=" null != validStartDate ">
  69. and `valid_start_date` = #{validStartDate}
  70. </if>
  71. <if test=" null != validEndDate ">
  72. and `valid_end_date` = #{validEndDate}
  73. </if>
  74. <if test=" null != validDays ">
  75. and `valid_days` = #{validDays}
  76. </if>
  77. <if test=" null != detail ">
  78. and `detail` like concat('%', #{detail},'%')
  79. </if>
  80. <if test=" null != price ">
  81. and `price` = #{price}
  82. </if>
  83. <if test=" null != unit ">
  84. and `unit` = #{unit}
  85. </if>
  86. <if test=" null != remainInventory ">
  87. and `remain_inventory` = #{remainInventory}
  88. </if>
  89. <if test=" null != inventory ">
  90. and `inventory` = #{inventory}
  91. </if>
  92. <if test=" null != remark ">
  93. and `remark` like concat('%', #{remark},'%')
  94. </if>
  95. <if test=" null != status">
  96. and `status` = #{status}
  97. </if>
  98. <if test=" null != startdate and null!=enddate">
  99. and `create_date` between #{startdate} and #{enddate}
  100. </if>
  101. <if test=" null != updateDate ">
  102. and `update_date` = #{updateDate}
  103. </if>
  104. <if test=" null != business ">
  105. and `business` = #{business}
  106. </if>
  107. <if test=" null != ids ">
  108. and id in
  109. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  110. #{idItem}
  111. </foreach>
  112. </if>
  113. <if test=" null != sortColumns">order by ${sortColumns}</if>
  114. </sql>
  115. <select id="findList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  116. select
  117. <include refid="allColumns"/>
  118. from wx_coupon
  119. <include refid="dynamicWhereConditions"/>
  120. </select>
  121. <resultMap id="WxCouponCVoMap" type="com.iformall.domain.vo.WxCouponCVo">
  122. <id column="id" jdbcType="BIGINT" property="id"/>
  123. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  124. <result column="type" jdbcType="INTEGER" property="type"/>
  125. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  126. <result column="title" jdbcType="VARCHAR" property="title"/>
  127. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  128. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  129. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  130. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  131. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  132. <result column="valid_type" jdbcType="INTEGER" property="validType"/>
  133. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  134. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  135. <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
  136. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  137. <result column="price" jdbcType="INTEGER" property="price"/>
  138. <result column="unit" jdbcType="INTEGER" property="unit"/>
  139. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  140. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  141. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  142. <result column="status" jdbcType="INTEGER" property="status"/>
  143. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  144. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  145. <result column="business" jdbcType="INTEGER" property="business"/>
  146. <collection column="{productId=coupon_id}" property="merchantVoList"
  147. ofType="com.iformall.domain.vo.WxMerchantVo"
  148. javaType="java.util.ArrayList"
  149. select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" >
  150. </collection>
  151. </resultMap>
  152. <select id="findVoDetail" parameterType="java.lang.Long" resultMap="WxCouponCVoMap">
  153. select
  154. <include refid="allColumns"/>
  155. from wx_coupon
  156. where id = #{id}
  157. </select>
  158. <update id="reduceInventory">
  159. update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and remain_inventory>= #{number}
  160. </update>
  161. <update id="offExpiriedCouponByValidDate">
  162. update wx_coupon SET status = 1, update_date = now()
  163. where status = 0 and valid_type = 1 and valid_end_date &lt; now()
  164. </update>
  165. <update id="offExpiriedCouponByMerchantStatus">
  166. update wx_coupon c, wx_merchant m SET c.status = 1, c.update_date = now()
  167. where c.status = 0 and m.status = 0 and m.id = c.merchant_id
  168. </update>
  169. </mapper>