CmHeheReductionMapper.xml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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.caimei.modules.hehe.dao.CmHeheReductionDao">
  4. <sql id="cmHeheReductionColumns">
  5. a.id AS "id",
  6. a.name AS "name",
  7. a.reducedAmount AS "reducedAmount",
  8. a.touchPrice AS "touchPrice",
  9. a.shareNum AS "shareNum",
  10. a.startTime AS "startTime",
  11. a.endTime AS "endTime",
  12. a.addTime AS "addTime"
  13. </sql>
  14. <sql id="cmHeheReductionJoins">
  15. </sql>
  16. <select id="get" resultType="CmHeheReduction">
  17. SELECT
  18. <include refid="cmHeheReductionColumns"/>
  19. FROM cm_hehe_reduction a
  20. <include refid="cmHeheReductionJoins"/>
  21. WHERE a.id = #{id}
  22. </select>
  23. <select id="findList" resultType="CmHeheReduction">
  24. SELECT
  25. <include refid="cmHeheReductionColumns"/>
  26. FROM cm_hehe_reduction a
  27. <include refid="cmHeheReductionJoins"/>
  28. <where>
  29. <if test="name != null and name != ''">
  30. AND a.name LIKE
  31. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  32. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  33. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  34. </if>
  35. <if test="status != null">
  36. <if test="status == 1">
  37. and NOW() <![CDATA[ < ]]> a.startTime
  38. </if>
  39. <if test="status == 2">
  40. and NOW() <![CDATA[ >= ]]> a.startTime and NOW() <![CDATA[ <= ]]> a.endTime
  41. </if>
  42. <if test="status == 3">
  43. and NOW() <![CDATA[ > ]]> a.endTime
  44. </if>
  45. </if>
  46. </where>
  47. <choose>
  48. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  49. ORDER BY ${page.orderBy}
  50. </when>
  51. <otherwise>
  52. order by a.addTime desc
  53. </otherwise>
  54. </choose>
  55. </select>
  56. <select id="findAllList" resultType="CmHeheReduction">
  57. SELECT
  58. <include refid="cmHeheReductionColumns"/>
  59. FROM cm_hehe_reduction a
  60. <include refid="cmHeheReductionJoins"/>
  61. <where>
  62. </where>
  63. <choose>
  64. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  65. ORDER BY ${page.orderBy}
  66. </when>
  67. <otherwise>
  68. </otherwise>
  69. </choose>
  70. </select>
  71. <select id="findUserList" resultType="com.caimei.modules.hehe.entity.CmHeheReductionUser">
  72. select ru.id,chu.nickName,chu.mobile,ru.shareType,ru.shareTime
  73. from cm_hehe_reduction_user ru
  74. left join user u on ru.userId = u.userID
  75. left join cm_hehe_user chu on u.userID = chu.userId
  76. where reductionId = #{reductionId}
  77. <if test="nickName != null and nickName != ''">
  78. and chu.nickName like concat('%',#{nickName},'%')
  79. </if>
  80. <if test="mobile != null and mobile != ''">
  81. and chu.mobile like concat('%',#{mobile},'%')
  82. </if>
  83. <if test="shareType != null">
  84. and ru.shareType = #{shareType}
  85. </if>
  86. order by shareTime desc
  87. </select>
  88. <select id="getAllTime" resultType="com.caimei.modules.hehe.entity.CmHeheReduction">
  89. select id, startTime,endTime from cm_hehe_reduction;
  90. </select>
  91. <insert id="insert" parameterType="CmHeheReduction" keyProperty="id" useGeneratedKeys="true">
  92. INSERT INTO cm_hehe_reduction(
  93. name,
  94. reducedAmount,
  95. touchPrice,
  96. shareNum,
  97. startTime,
  98. endTime,
  99. addTime
  100. ) VALUES (
  101. #{name},
  102. #{reducedAmount},
  103. #{touchPrice},
  104. #{shareNum},
  105. #{startTime},
  106. #{endTime},
  107. NOW()
  108. )
  109. </insert>
  110. <update id="update">
  111. UPDATE cm_hehe_reduction SET
  112. name = #{name},
  113. reducedAmount = #{reducedAmount},
  114. touchPrice = #{touchPrice},
  115. shareNum = #{shareNum},
  116. startTime = #{startTime},
  117. endTime = #{endTime}
  118. WHERE id = #{id}
  119. </update>
  120. <update id="updateStatus">
  121. update cm_hehe_reduction set
  122. <if test="status == 3">
  123. endTime = NOW()
  124. </if>
  125. <if test="status == 2">
  126. startTime = NOW()
  127. </if>
  128. where id = #{id}
  129. </update>
  130. <update id="updateTime">
  131. update cm_hehe_reduction
  132. set startTime = #{startTime}, endTime = #{endTime}
  133. where id = #{id}
  134. </update>
  135. <delete id="delete">
  136. DELETE FROM cm_hehe_reduction
  137. WHERE id = #{id}
  138. </delete>
  139. </mapper>