CouponCreateMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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.ygj.yuemum.dao.coupon.CouponCreateDao" >
  4. <resultMap id="BaseResultMap" type="com.ygj.yuemum.domain.coupon.CouponCreate" >
  5. <id column="id" property="id" jdbcType="INTEGER" />
  6. <result column="cb_code" property="cb_code" jdbcType="VARCHAR" />
  7. <result column="cb_name" property="cb_name" jdbcType="VARCHAR" />
  8. <result column="cc_quantity" property="cc_quantity" jdbcType="INTEGER" />
  9. <result column="cc_amount" property="cc_amount" jdbcType="INTEGER" />
  10. <result column="cc_createdate" property="cc_createdate" jdbcType="DATE" />
  11. <result column="cc_startdate" property="cc_startdate" jdbcType="DATE" />
  12. <result column="cc_enddate" property="cc_enddate" jdbcType="DATE" />
  13. <result column="cc_status" property="cc_status" jdbcType="INTEGER" />
  14. <result column="syncmodoodate" property="syncmodoodate" jdbcType="DATE" />
  15. <result column="syncmodoo" property="syncmodoo" jdbcType="VARCHAR" />
  16. <result column="usercode" property="usercode" jdbcType="VARCHAR" />
  17. <result column="cb_type" property="cb_type" jdbcType="BIT" />
  18. <result column="no_amount" property="no_amount" jdbcType="INTEGER" />
  19. </resultMap>
  20. <sql id="Base_Column_List" >
  21. id,cb_code,cc_quantity,cc_amount,cc_createdate,cc_startdate,cc_enddate,cc_status,syncmodoodate,syncmodoo,usercode,cb_type,no_amount
  22. </sql>
  23. <!--获取所有数据-->
  24. <select id="getCount" resultType="java.lang.Integer" >
  25. select
  26. count(1)
  27. from coupon_create
  28. </select>
  29. <select id="getAll" resultMap="BaseResultMap" >
  30. SELECT
  31. id,
  32. fgetcouponbatch(cb_code) cb_name,
  33. cc_startdate,
  34. cc_enddate,
  35. cc_createdate,
  36. cc_amount,
  37. cc_quantity,
  38. cc_status,
  39. cb_type,
  40. no_amount
  41. FROM
  42. coupon_create
  43. order by id desc
  44. </select>
  45. <select id="queryCollegeCoupon" resultMap="BaseResultMap" >
  46. SELECT
  47. id,
  48. fgetcouponbatch(cb_code) cb_name,
  49. cc_startdate,
  50. cc_enddate,
  51. cc_createdate,
  52. cc_amount,
  53. cc_quantity,
  54. cc_status,
  55. cb_type,
  56. no_amount
  57. FROM
  58. coupon_create
  59. where
  60. cb_type = 1
  61. order by id desc
  62. </select>
  63. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  64. select
  65. <include refid="Base_Column_List" />
  66. from coupon_create
  67. where id = #{id,jdbcType=INTEGER}
  68. </select>
  69. <select id="checkCouponBatch" resultType="java.lang.Integer" parameterType="java.lang.String" >
  70. select
  71. count(1)
  72. from coupon_create
  73. where cb_code = #{id,jdbcType=VARCHAR}
  74. </select>
  75. <select id="checkCouponBatchid" resultType="java.lang.Integer" parameterType="java.lang.Integer" >
  76. SELECT
  77. count(1)
  78. FROM
  79. coupon_create ta
  80. LEFT JOIN coupon_batch tb ON ta.cb_code = tb.cb_code
  81. WHERE
  82. tb.id = #{id,jdbcType=VARCHAR}
  83. </select>
  84. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
  85. delete from coupon_create
  86. where id = #{id,jdbcType=INTEGER}
  87. </delete>
  88. <!-- 插入一条培训信息 -->
  89. <insert id="insertSelective" parameterType="com.ygj.yuemum.domain.coupon.CouponCreate" >
  90. insert into coupon_create
  91. <trim prefix="(" suffix=")" suffixOverrides="," >
  92. <if test="cb_code != null" >
  93. cb_code,
  94. </if>
  95. <if test="cc_quantity != null" >
  96. cc_quantity,
  97. </if>
  98. <if test="cc_amount != null" >
  99. cc_amount,
  100. </if>
  101. <if test="cc_startdate != null" >
  102. cc_startdate,
  103. </if>
  104. <if test="cc_enddate != null" >
  105. cc_enddate,
  106. </if>
  107. <if test="cc_createdate != null" >
  108. cc_createdate,
  109. </if>
  110. <if test="cc_status != null" >
  111. cc_status,
  112. </if>
  113. <if test="cb_type != null" >
  114. cb_type,
  115. </if>
  116. <if test="no_amount != null" >
  117. no_amount
  118. </if>
  119. </trim>
  120. <trim prefix="values (" suffix=")" suffixOverrides="," >
  121. <if test="cb_code != null" >
  122. #{cb_code,jdbcType=VARCHAR},
  123. </if>
  124. <if test="cc_quantity != null" >
  125. #{cc_quantity,jdbcType=INTEGER},
  126. </if>
  127. <if test="cc_amount != null" >
  128. #{cc_amount,jdbcType=INTEGER},
  129. </if>
  130. <if test="cc_startdate != null" >
  131. #{cc_startdate,jdbcType=DATE},
  132. </if>
  133. <if test="cc_enddate != null" >
  134. #{cc_enddate,jdbcType=DATE},
  135. </if>
  136. <if test="cc_createdate != null" >
  137. #{cc_createdate,jdbcType=DATE},
  138. </if>
  139. <if test="cc_status != null" >
  140. #{cc_status,jdbcType=INTEGER},
  141. </if>
  142. <if test="cb_type != null" >
  143. #{cb_type,jdbcType=BIT}
  144. </if>
  145. <if test="no_amount != null" >
  146. #{no_amount,jdbcType=INTEGER}
  147. </if>
  148. </trim>
  149. </insert>
  150. <!-- 根据id更新一条培训信息 -->
  151. <update id="updateByPrimaryKeySelective" parameterType="com.ygj.yuemum.domain.coupon.CouponCreate" >
  152. update coupon_create
  153. <set >
  154. <if test="cb_code != null" >
  155. cb_code = #{cb_code,jdbcType=VARCHAR},
  156. </if>
  157. <if test="cb_desc != null" >
  158. cb_desc = #{cb_desc,jdbcType=VARCHAR},
  159. </if>
  160. <if test="cc_quantity != null" >
  161. cc_quantity = #{cc_quantity,jdbcType=INTEGER},
  162. </if>
  163. <if test="cc_amount != null" >
  164. cc_amount = #{cc_amount,jdbcType=INTEGER},
  165. </if>
  166. <if test="syncmodoodate != null" >
  167. syncmodoodate = #{syncmodoodate,jdbcType=DATE},
  168. </if>
  169. <if test="syncmodoo != null" >
  170. syncmodoo = #{syncmodoo,jdbcType=INTEGER},
  171. </if>
  172. <if test="usercode != null" >
  173. usercode = #{usercode,jdbcType=VARCHAR},
  174. </if>
  175. <if test="cb_type != null" >
  176. cb_type = #{cb_type,jdbcType=BIT},
  177. </if>
  178. <if test="date != null" >
  179. `date` = #{date,jdbcType=DATE},
  180. </if>
  181. <if test="no_amount != null" >
  182. no_amount = #{no_amount,jdbcType=INTEGER}
  183. </if>
  184. </set>
  185. where id = #{id,jdbcType=INTEGER}
  186. </update>
  187. <!--获取所有数据-->
  188. <select id="getQCouponCreateCount" resultType="java.lang.Integer" parameterType="com.ygj.yuemum.domain.coupon.CouponCreate">
  189. SELECT
  190. count(1)
  191. FROM
  192. coupon_create ta
  193. LEFT JOIN coupon_batch tb ON ta.cb_code = tb.cb_code
  194. where 1=1
  195. <if test="id != null and id != ''">
  196. and ta.id = #{id,jdbcType=INTEGER}
  197. </if>
  198. <if test="cb_code != null and cb_code != ''">
  199. and tb.cb_code = #{cb_code,jdbcType=VARCHAR}
  200. </if>
  201. <if test="cb_packages != null and cb_packages != ''">
  202. and tb.cb_packages like concat ('%',#{cb_packages,jdbcType=VARCHAR},'%')
  203. </if>
  204. <if test="cb_citys != null and cb_citys != ''">
  205. and tb.cb_citys like concat ('%',#{cb_citys,jdbcType=VARCHAR},'%')
  206. </if>
  207. <if test="cc_startdate != null and cc_startdate != ''">
  208. and ta.cc_startdate = #{cc_startdate,jdbcType=VARCHAR}
  209. </if>
  210. <if test="cc_enddate != null and cc_enddate != ''">
  211. and ta.cc_enddate = #{cc_enddate,jdbcType=VARCHAR}
  212. </if>
  213. <if test="cc_createdate != null and cc_createdate != ''">
  214. and ta.cc_createdate = #{cc_createdate,jdbcType=VARCHAR}
  215. </if>
  216. <if test="cc_amount != null and cc_amount != ''">
  217. and ta.cc_amount = #{cc_amount,jdbcType=INTEGER}
  218. </if>
  219. <if test="cc_quantity != null and cc_quantity != ''">
  220. and ta.cc_quantity = #{cc_quantity,jdbcType=INTEGER}
  221. </if>
  222. <if test="cc_status != null ">
  223. and ta.cc_status = #{cc_status,jdbcType=INTEGER}
  224. </if>
  225. </select>
  226. <select id="getQCouponCreate" resultMap="BaseResultMap" parameterType="com.ygj.yuemum.domain.coupon.CouponCreate">
  227. SELECT
  228. ta.id,
  229. tb.cb_code,
  230. tb.cb_name,
  231. ta.cc_amount,
  232. ta.cc_quantity,
  233. ta.cc_createdate,
  234. ta.cc_status,
  235. ta.cc_startdate,
  236. ta.cc_enddate,
  237. ta.no_amount
  238. FROM
  239. coupon_create ta
  240. LEFT JOIN coupon_batch tb ON ta.cb_code = tb.cb_code
  241. where 1=1
  242. <if test="id != null and id != ''">
  243. and ta.id = #{id,jdbcType=INTEGER}
  244. </if>
  245. <if test="cb_code != null and cb_code != ''">
  246. and tb.cb_code = #{cb_code,jdbcType=VARCHAR}
  247. </if>
  248. <if test="cb_packages != null and cb_packages != ''">
  249. and tb.cb_packages like concat ('%',#{cb_packages,jdbcType=VARCHAR},'%')
  250. </if>
  251. <if test="cb_citys != null and cb_citys != ''">
  252. and tb.cb_citys like concat ('%',#{cb_citys,jdbcType=VARCHAR},'%')
  253. </if>
  254. <if test="cc_startdate != null and cc_startdate != ''">
  255. and ta.cc_startdate = #{cc_startdate,jdbcType=VARCHAR}
  256. </if>
  257. <if test="cc_enddate != null and cc_enddate != ''">
  258. and ta.cc_enddate = #{cc_enddate,jdbcType=VARCHAR}
  259. </if>
  260. <if test="cc_createdate != null and cc_createdate != ''">
  261. and ta.cc_createdate = #{cc_createdate,jdbcType=VARCHAR}
  262. </if>
  263. <if test="cc_amount != null and cc_amount != ''">
  264. and ta.cc_amount = #{cc_amount,jdbcType=INTEGER}
  265. </if>
  266. <if test="cc_quantity != null and cc_quantity != ''">
  267. and ta.cc_quantity = #{cc_quantity,jdbcType=INTEGER}
  268. </if>
  269. <if test="cc_status != null ">
  270. and ta.cc_status = #{cc_status,jdbcType=INTEGER}
  271. </if>
  272. </select>
  273. <select id="getccpmid" resultType="java.lang.Integer" >
  274. SELECT auto_increment
  275. FROM information_schema.tables
  276. where table_schema="yuemum"
  277. and table_name="coupon_create";
  278. </select>
  279. <update id="disableCouponCreate" parameterType="java.lang.Integer" >
  280. update coupon_create
  281. set cc_status = 0
  282. where id = #{id,jdbcType=INTEGER}
  283. </update>
  284. <update id="enableCouponCreate" parameterType="java.lang.Integer" >
  285. update coupon_create
  286. set cc_status = 1
  287. where id = #{id,jdbcType=INTEGER}
  288. </update>
  289. </mapper>