Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 

261 Zeilen
11 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="merchant_id" jdbcType="BIGINT" property="merchantId"/>
  8. <result column="type" jdbcType="INTEGER" property="type"/>
  9. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  10. <result column="title" jdbcType="VARCHAR" property="title"/>
  11. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  12. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  13. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  14. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  15. <result column="target_ad" jdbcType="INTEGER" property="targetAd"/>
  16. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  17. <result column="valid_type" jdbcType="INTEGER" property="validType"/>
  18. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  19. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  20. <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
  21. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  22. <result column="price" jdbcType="INTEGER" property="price"/>
  23. <result column="unit" jdbcType="INTEGER" property="unit"/>
  24. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  25. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  26. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  27. <result column="status" jdbcType="INTEGER" property="status"/>
  28. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  29. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  30. <result column="business" jdbcType="VARCHAR" property="business"/>
  31. </resultMap>
  32. <sql id="allColumns">
  33. `id`,`tenant_id`,`merchant_id`,`type`,`cover_img`,`title`,`sub_title`,`sale_price`,`use_price`,`use_limit_quantity`,`target_ad`,`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`
  34. </sql>
  35. <sql id="dynamicWhereConditions">
  36. where 1 = 1
  37. <if test=" null != id ">
  38. and `id` = #{id}
  39. </if>
  40. <if test=" null != tenantId ">
  41. and `tenant_id` = #{tenantId}
  42. </if>
  43. <if test=" null != merchantId ">
  44. and `merchant_id` = #{merchantId}
  45. </if>
  46. <if test=" null != type ">
  47. and `type` = #{type}
  48. </if>
  49. <if test=" null != coverImg ">
  50. and `cover_img` like concat('%', #{coverImg},'%')
  51. </if>
  52. <if test=" null != title and ''!=title">
  53. and `title` like concat('%', #{title},'%')
  54. </if>
  55. <if test=" null != subTitle ">
  56. and `sub_title` like concat('%', #{subTitle},'%')
  57. </if>
  58. <if test=" null != salePrice ">
  59. and `sale_price` = #{salePrice}
  60. </if>
  61. <if test=" null != usePrice ">
  62. and `use_price` = #{usePrice}
  63. </if>
  64. <if test=" null != useLimitQuantity ">
  65. and `use_limit_quantity` = #{useLimitQuantity}
  66. </if>
  67. <if test=" null != targetAd ">
  68. and `target_ad` = #{targetAd}
  69. </if>
  70. <if test=" null != sendType ">
  71. and `send_type` = #{sendType}
  72. </if>
  73. <if test=" null != validType ">
  74. and `valid_type` = #{validType}
  75. </if>
  76. <if test=" null != validStartDate ">
  77. and `valid_start_date` = #{validStartDate}
  78. </if>
  79. <if test=" null != validEndDate ">
  80. and `valid_end_date` = #{validEndDate}
  81. </if>
  82. <if test=" null != validDays ">
  83. and `valid_days` = #{validDays}
  84. </if>
  85. <if test=" null != detail ">
  86. and `detail` like concat('%', #{detail},'%')
  87. </if>
  88. <if test=" null != price ">
  89. and `price` = #{price}
  90. </if>
  91. <if test=" null != unit ">
  92. and `unit` = #{unit}
  93. </if>
  94. <if test=" null != remainInventory ">
  95. and `remain_inventory` = #{remainInventory}
  96. </if>
  97. <if test=" null != inventory ">
  98. and `inventory` = #{inventory}
  99. </if>
  100. <if test=" null != remark ">
  101. and `remark` like concat('%', #{remark},'%')
  102. </if>
  103. <if test=" null != status">
  104. and `status` = #{status}
  105. </if>
  106. <if test=" null != startdate and null!=enddate">
  107. and `create_date` between #{startdate} and #{enddate}
  108. </if>
  109. <if test=" null != updateDate ">
  110. and `update_date` = #{updateDate}
  111. </if>
  112. <if test=" null != business and '0' == business">
  113. and JSON_CONTAINS(`business`->'$',JSON_ARRAY('0'))
  114. </if>
  115. <if test=" null != business and '0' != business">
  116. and (JSON_CONTAINS(`business`->'$',JSON_ARRAY('0')) or (JSON_CONTAINS(`business`->'$',JSON_ARRAY(#{business}))))
  117. </if>
  118. <if test=" null != ids ">
  119. and id in
  120. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  121. #{idItem}
  122. </foreach>
  123. </if>
  124. <if test=" null != sortColumns">order by ${sortColumns}</if>
  125. </sql>
  126. <select id="findList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
  127. select
  128. <include refid="allColumns"/>
  129. from wx_coupon
  130. <include refid="dynamicWhereConditions"/>
  131. </select>
  132. <resultMap id="CUserResultMap" type="com.iformall.domain.vo.WxCouponCVo">
  133. <id column="id" jdbcType="BIGINT" property="id"/>
  134. <result column="coupon_id" jdbcType="BIGINT" property="couponId"/>
  135. <result column="begin_time" jdbcType="TIMESTAMP" property="beginTime"/>
  136. <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
  137. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  138. <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
  139. <result column="type" jdbcType="INTEGER" property="type"/>
  140. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  141. <result column="title" jdbcType="VARCHAR" property="title"/>
  142. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  143. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  144. <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
  145. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
  146. <result column="target_ad" jdbcType="INTEGER" property="targetAd"/>
  147. <result column="send_type" jdbcType="INTEGER" property="sendType"/>
  148. <result column="valid_type" jdbcType="INTEGER" property="validType"/>
  149. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
  150. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
  151. <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
  152. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  153. <result column="price" jdbcType="INTEGER" property="price"/>
  154. <result column="unit" jdbcType="INTEGER" property="unit"/>
  155. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
  156. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  157. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  158. <result column="status" jdbcType="INTEGER" property="status"/>
  159. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  160. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  161. <result column="business" jdbcType="VARCHAR" property="business"/>
  162. <result column="img_url" jdbcType="VARCHAR" property="merchantImgUrl"/>
  163. <result column="name" jdbcType="VARCHAR" property="merchantName"/>
  164. <result column="link_phone" jdbcType="VARCHAR" property="merchantLinkPhone"/>
  165. <result column="status" jdbcType="VARCHAR" property="merchantStatus"/>
  166. <result column="addr" jdbcType="VARCHAR" property="addr"/>
  167. <result column="shop_number" jdbcType="VARCHAR" property="shopNumber"/>
  168. <result column="building_name" jdbcType="VARCHAR" property="buildingName"/>
  169. <result column="floor_name" jdbcType="VARCHAR" property="floorName"/>
  170. <result column="baidu_poi" jdbcType="VARCHAR" property="baiduPoi"/>
  171. </resultMap>
  172. <sql id="allCUserColumns">
  173. c.tenant_id,c.merchant_id,c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.use_limit_quantity,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,c.valid_days,c.detail,c.price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,c.create_date,c.update_date,c.business,
  174. m.img_url,m.name,m.link_phone,m.status,
  175. s.addr,s.shop_number,s.baidu_poi,
  176. mb.building_name,mf.floor_name,
  177. cc.id,cc.coupon_id,cc.target_ad,cc.begin_time,cc.end_time
  178. </sql>
  179. <select id="selectDetailForCUser" parameterType="com.iformall.domain.po.WxCouponChannel" resultMap="CUserResultMap">
  180. select
  181. <include refid="allCUserColumns"/>
  182. from wx_coupon_channel cc,
  183. wx_coupon c,wx_merchant m
  184. left join wx_merchant_shop ms on ms.merchant_id = m.id and ms.is_del = 0
  185. left join wx_shop s on ms.shop_id = s.id
  186. left join wx_mall_building mb on s.building = mb.id
  187. left join wx_mall_floor mf on s.floor = mf.id
  188. where c.merchant_id = m.id
  189. and cc.coupon_id = c.id
  190. <if test=" null != id ">
  191. and cc.id = #{id}
  192. </if>
  193. <if test=" null != couponId ">
  194. and c.id = #{couponId}
  195. </if>
  196. <if test=" null != tenantId ">
  197. and c.tenant_id = #{tenantId}
  198. </if>
  199. <if test=" null != targetAd ">
  200. and cc.target_ad = #{targetAd}
  201. </if>
  202. </select>
  203. <update id="reduceInventory">
  204. update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and remain_inventory>= #{number}
  205. </update>
  206. <update id="offExpiriedCouponByValidDate">
  207. update wx_coupon SET status = 1, update_date = now()
  208. where status = 0 and valid_type = 1 and valid_end_date &lt; now()
  209. </update>
  210. <update id="offExpiriedCouponByMerchantStatus">
  211. update wx_coupon c, wx_merchant m SET c.status = 1, c.update_date = now()
  212. where c.status = 0 and m.status = 0 and m.id = c.merchant_id
  213. </update>
  214. </mapper>