You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

300 lines
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.simple.mapper.WxCouponMapper">
  4. <resultMap id="BaseResultMap" type="com.simple.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` like concat('%', #{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 ">
  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 != createDate ">
  107. and `create_date` = #{createDate}
  108. </if>
  109. <if test=" null != updateDate ">
  110. and `update_date` = #{updateDate}
  111. </if>
  112. <if test=" null != business ">
  113. and `business` like concat('%', #{business},'%')
  114. </if>
  115. <if test=" null != ids ">
  116. and id in
  117. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  118. #{idItem}
  119. </foreach>
  120. </if>
  121. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  122. </sql>
  123. <select id="findList" parameterType="com.simple.domain.po.WxCoupon" resultMap="BaseResultMap">
  124. select <include refid="allColumns" /> from wx_coupon
  125. <include refid="dynamicWhereConditions" />
  126. </select>
  127. <resultMap id="CUserResultMap" type="com.simple.domain.vo.WxCouponCVo">
  128. <id column="id" jdbcType="BIGINT" property="id" />
  129. <result column="coupon_id" jdbcType="BIGINT" property="couponId" />
  130. <result column="begin_time" jdbcType="TIMESTAMP" property="beginTime" />
  131. <result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
  132. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  133. <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
  134. <result column="type" jdbcType="INTEGER" property="type" />
  135. <result column="cover_img" jdbcType="VARCHAR" property="coverImg" />
  136. <result column="title" jdbcType="VARCHAR" property="title" />
  137. <result column="sub_title" jdbcType="VARCHAR" property="subTitle" />
  138. <result column="sale_price" jdbcType="INTEGER" property="salePrice" />
  139. <result column="use_price" jdbcType="INTEGER" property="usePrice" />
  140. <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity" />
  141. <result column="target_ad" jdbcType="INTEGER" property="targetAd" />
  142. <result column="send_type" jdbcType="INTEGER" property="sendType" />
  143. <result column="valid_type" jdbcType="INTEGER" property="validType" />
  144. <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate" />
  145. <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate" />
  146. <result column="valid_days" jdbcType="INTEGER" property="validDays" />
  147. <result column="detail" jdbcType="VARCHAR" property="detail" />
  148. <result column="price" jdbcType="INTEGER" property="price" />
  149. <result column="unit" jdbcType="INTEGER" property="unit" />
  150. <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory" />
  151. <result column="inventory" jdbcType="INTEGER" property="inventory" />
  152. <result column="remark" jdbcType="VARCHAR" property="remark" />
  153. <result column="status" jdbcType="INTEGER" property="status" />
  154. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  155. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
  156. <result column="business" jdbcType="VARCHAR" property="business" />
  157. <result column="img_url" jdbcType="VARCHAR" property="merchantImgUrl" />
  158. <result column="name" jdbcType="VARCHAR" property="merchantName" />
  159. <result column="link_phone" jdbcType="VARCHAR" property="merchantLinkPhone" />
  160. <result column="status" jdbcType="VARCHAR" property="merchantStatus" />
  161. <result column="addr" jdbcType="VARCHAR" property="addr"/>
  162. <result column="shop_number" jdbcType="VARCHAR" property="shopNumber"/>
  163. <result column="building_name" jdbcType="VARCHAR" property="buildingName" />
  164. <result column="floor_name" jdbcType="VARCHAR" property="floorName" />
  165. <result column="baidu_poi" jdbcType="VARCHAR" property="baiduPoi"/>
  166. </resultMap>
  167. <sql id="allCUserColumns">
  168. 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.target_ad,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,
  169. m.img_url,m.name,m.link_phone,m.status,
  170. s.addr,s.shop_number,s.baidu_poi,
  171. mb.building_name,mf.floor_name,
  172. cc.id,cc.coupon_id,cc.begin_time,cc.end_time
  173. </sql>
  174. <select id="selectDetailForCUser" parameterType="com.simple.domain.po.WxCouponChannel" resultMap="CUserResultMap">
  175. select <include refid="allCUserColumns" />
  176. from wx_coupon_channel cc,
  177. wx_coupon c,wx_merchant m
  178. left join wx_merchant_shop ms on ms.merchant_id = m.id and ms.is_del = 0
  179. left join wx_shop s on ms.shop_id = s.id
  180. left join wx_mall_building mb on s.building = mb.id
  181. left join wx_mall_floor mf on s.floor = mf.id
  182. where c.merchant_id = m.id
  183. and cc.coupon_id = c.id
  184. <if test=" null != id ">
  185. and cc.id = #{id}
  186. </if>
  187. <if test=" null != couponId ">
  188. and c.id = #{couponId}
  189. </if>
  190. <if test=" null != tenantId ">
  191. and c.tenant_id = #{tenantId}
  192. </if>
  193. <if test=" null != targetAd ">
  194. and cc.target_ad = #{targetAd}
  195. </if>
  196. </select>
  197. <sql id="allCUserColumns2">
  198. 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.target_ad,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,
  199. m.img_url,m.name,m.link_phone,m.status,
  200. s.addr,s.shop_number,s.baidu_poi,
  201. mb.building_name,mf.floor_name
  202. </sql>
  203. <select id="selectDetailForCUserC" parameterType="com.simple.domain.po.WxCoupon" resultMap="CUserResultMap">
  204. select <include refid="allCUserColumns2" />
  205. from
  206. wx_coupon c,wx_merchant m
  207. left join wx_merchant_shop ms on ms.merchant_id = m.id and ms.is_del = 0
  208. left join wx_shop s on ms.shop_id = s.id
  209. left join wx_mall_building mb on s.building = mb.id
  210. left join wx_mall_floor mf on s.floor = mf.id
  211. where c.merchant_id = m.id
  212. <if test=" null != id ">
  213. and c.id = #{id}
  214. </if>
  215. <if test=" null != tenantId ">
  216. and c.tenant_id = #{tenantId}
  217. </if>
  218. </select>
  219. <update id="reduceInventory">
  220. update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and remain_inventory>= #{number}
  221. </update>
  222. </mapper>