后台服务
Você não pode selecionar mais de 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.

227 linhas
9.6 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.TtCouponMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.tt.TtCoupon">
  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="type" jdbcType="INTEGER" property="type"/>
  9. <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
  10. <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
  11. <result column="detail_picture" jdbcType="VARCHAR" property="detailPicture"/>
  12. <result column="title" jdbcType="VARCHAR" property="title"/>
  13. <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
  14. <result column="count_class" jdbcType="INTEGER" property="countClass"/>
  15. <result column="video_id" jdbcType="VARCHAR" property="videoId"/>
  16. <result column="video_time" jdbcType="VARCHAR" property="videoTime"/>
  17. <result column="video_url" jdbcType="VARCHAR" property="videoUrl"/>
  18. <result column="html" jdbcType="VARCHAR" property="html"/>
  19. <result column="is_landscape" jdbcType="INTEGER" property="isLandscape"/>
  20. <result column="is_payment" jdbcType="INTEGER" property="isPayment"/>
  21. <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
  22. <result column="orig_price" jdbcType="INTEGER" property="origPrice"/>
  23. <result column="is_preview" jdbcType="INTEGER" property="isPreview"/>
  24. <result column="preview_duration" jdbcType="INTEGER" property="previewDuration"/>
  25. <result column="detail" jdbcType="VARCHAR" property="detail"/>
  26. <result column="false_sell_count" jdbcType="INTEGER" property="falseSellCount"/>
  27. <result column="dy_title" jdbcType="VARCHAR" property="dyTitle"/>
  28. <result column="inventory" jdbcType="INTEGER" property="inventory"/>
  29. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  30. <result column="status" jdbcType="INTEGER" property="status"/>
  31. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  32. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  33. <result column="puton_date" jdbcType="TIMESTAMP" property="putonDate"/>
  34. <result column="see_count" jdbcType="INTEGER" property="seeCount"/>
  35. <result column="sell_count" jdbcType="INTEGER" property="sellCount"/>
  36. <result column="assess_count" jdbcType="INTEGER" property="assessCount"/>
  37. <result column="collect_count" jdbcType="INTEGER" property="collectCount"/>
  38. <result column="mark" jdbcType="INTEGER" property="mark"/>
  39. <result column="mark_time" jdbcType="INTEGER" property="markTime"/>
  40. <result column="is_del" jdbcType="INTEGER" property="isDel"/>
  41. <result column="column_id" jdbcType="BIGINT" property="columnId"/>
  42. <result column="popularity" jdbcType="INTEGER" property="popularity"/>
  43. <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
  44. <result column="business_id" jdbcType="BIGINT" property="businessId"/>
  45. <result column="business_name" jdbcType="VARCHAR" property="businessName"/>
  46. <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/>
  47. <result column="merchant_pic" jdbcType="VARCHAR" property="merchantPic"/>
  48. </resultMap>
  49. <sql id="allColumns">
  50. c.`id`, c.`tenant_id`, c.`parent_tenant_id`, c.`type`, c.`cover_img`, c.`cover_picture`, c.`detail_picture`,
  51. c.`title`, c.`sub_title`, c.`count_class`, c.`video_id`, c.`video_time`,c.`video_url`, c.`html`, c.`is_landscape`, c.`is_payment`,
  52. c.`sale_price`, c.`orig_price`, c.`is_preview`, c.`preview_duration`, c.`detail`, c.`false_sell_count`,
  53. c.`dy_title`, c.`inventory`, c.`remark`, c.`status`, c.`create_date`, c.`update_date`, c.`puton_date`,
  54. c.`see_count`, c.`sell_count`, c.`assess_count`, c.`collect_count`, c.`mark`,c.mark_time, c.`is_del`,
  55. c.`column_id`, c.`popularity`, c.`merchant_id`, c.`business_id`, c.`business_name`,
  56. m.name merchant_name, m.img_url merchant_pic
  57. </sql>
  58. <sql id="dynamicWhereConditions">
  59. where c.`is_del` = 0
  60. <if test=" null == type or type != 3">
  61. and c.`type` != 3
  62. </if>
  63. <if test=" null != id ">
  64. and c.`id` = #{id}
  65. </if>
  66. <if test=" null != tenantId and '' != tenantId">
  67. and c.`tenant_id` = #{tenantId}
  68. </if>
  69. <if test=" null != parentTenantId and '' != parentTenantId">
  70. and c.`parent_tenant_id` = #{parentTenantId}
  71. </if>
  72. <if test=" null != type ">
  73. and c.`type` = #{type}
  74. </if>
  75. <if test=" null != columnId ">
  76. and c.`column_id` = #{columnId}
  77. </if>
  78. <if test=" null != title and ''!=title">
  79. and c.`title` like concat('%', #{title},'%')
  80. </if>
  81. <if test=" null != isLandscape ">
  82. and c.`is_landscape` = #{isLandscape}
  83. </if>
  84. <if test=" null != isPayment ">
  85. and c.`is_payment` = #{isPayment}
  86. </if>
  87. <if test=" null != isPreview ">
  88. and c.`is_preview` = #{isPreview}
  89. </if>
  90. <if test=" null != status">
  91. and c.`status` = #{status}
  92. </if>
  93. <if test=" null != mark">
  94. <if test="mark == 0" >
  95. and (c.`mark` is null or c.`mark` &lt;&gt; 1)
  96. </if>
  97. <if test="mark == 1" >
  98. and c.`mark` = 1
  99. </if>
  100. </if>
  101. <if test="startdate != null">
  102. and c.`create_date` &gt;= #{startdate}
  103. </if>
  104. <if test="enddate != null">
  105. and c.`create_date` &lt;= #{enddate}
  106. </if>
  107. <if test=" null != businessId ">
  108. and c.`business_id` = #{businessId}
  109. </if>
  110. <if test=" null != merchantId ">
  111. and c.`merchant_id` = #{merchantId}
  112. </if>
  113. <if test=" null != merchantName and ''!=merchantName">
  114. and m.`name` like concat('%', #{merchantName},'%')
  115. </if>
  116. <if test=" null != ids ">
  117. and c.id in
  118. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  119. #{idItem}
  120. </foreach>
  121. </if>
  122. <if test=" null != sortColumns">order by ${sortColumns}</if>
  123. </sql>
  124. <select id="findList" parameterType="com.iformall.domain.po.tt.TtCoupon" resultMap="BaseResultMap">
  125. select
  126. <include refid="allColumns"/>
  127. from tt_coupon c
  128. left join wx_merchant m on m.id = c.merchant_id and m.status = 1
  129. <include refid="dynamicWhereConditions"/>
  130. </select>
  131. <select id="findCollectList" parameterType="com.iformall.domain.po.tt.TtCoupon" resultMap="BaseResultMap">
  132. select
  133. <include refid="allColumns"/>
  134. from tt_user_collect uc
  135. left join tt_coupon c on c.id = uc.coupon_id
  136. left join wx_merchant m on m.id = c.merchant_id
  137. where uc.`is_del` = 0 and uc.`user_id` = ${cUserId}
  138. and c.`is_del` = 0 and c.`type` != 3
  139. <if test=" null != type ">
  140. and c.`type` = #{type}
  141. </if>
  142. <if test=" null != title and ''!=title">
  143. and c.`title` like concat('%', #{title},'%')
  144. </if>
  145. <if test=" null != status">
  146. and c.`status` = #{status}
  147. </if>
  148. <if test=" null != mark">
  149. <if test="mark == 0" >
  150. and (c.`mark` is null or m.`mark` &lt;&gt; 1)
  151. </if>
  152. <if test="mark == 1" >
  153. and c.`mark` = 1
  154. </if>
  155. </if>
  156. <if test=" null != businessId ">
  157. and c.`business_id` = #{businessId}
  158. </if>
  159. order by uc.create_date desc
  160. </select>
  161. <select id="selectById" parameterType="Long" resultMap="BaseResultMap">
  162. select <include refid="allColumns"/>
  163. from tt_coupon c
  164. left join wx_merchant m on m.id = c.merchant_id
  165. where c.id = #{id}
  166. </select>
  167. <delete id="deleteById" parameterType="Long">
  168. update tt_coupon set is_del = 1, update_date=now() where id = #{id}
  169. </delete>
  170. <update id="addSeeCount" parameterType="Long">
  171. update tt_coupon SET see_count = see_count+1,popularity = popularity+1 where id = #{id}
  172. </update>
  173. <update id="addSellCount" parameterType="Long">
  174. update tt_coupon SET sell_count = sell_count+1,popularity = popularity+20, false_sell_count = false_sell_count+1 where id = #{id}
  175. </update>
  176. <update id="reduceSellCount" parameterType="Long">
  177. update tt_coupon SET sell_count = sell_count-1,popularity = popularity-20, false_sell_count = false_sell_count-1 where id = #{id}
  178. </update>
  179. <update id="addAssessCount" parameterType="Long">
  180. update tt_coupon SET assess_count = assess_count+1,popularity = popularity+10 where id = #{id}
  181. </update>
  182. <update id="addCollectCount" parameterType="Long">
  183. update tt_coupon SET collect_count = collect_count+1,popularity = popularity+5 where id = #{id}
  184. </update>
  185. <update id="reduceCollectCount" parameterType="Long">
  186. update tt_coupon SET collect_count = collect_count-1,popularity = popularity-5 where id = #{id}
  187. </update>
  188. <update id="addPopularity" parameterType="java.util.HashMap">
  189. update tt_coupon SET popularity = popularity+#{popularity} where id = #{id}
  190. </update>
  191. </mapper>