CmActivityMapper.xml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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.product.dao.CmActivityDao">
  4. <sql id="cmActivityColumns">
  5. a.id AS "id",
  6. a.activityName AS "activityName",
  7. a.startTime AS "startTime",
  8. a.endTime AS "endTime",
  9. a.addTime AS "addTime",
  10. a.delFlag AS "delFlag"
  11. </sql>
  12. <insert id="insertProductActivity">
  13. INSERT INTO cm_product_activity(
  14. activityId,
  15. productId,
  16. actPrice,
  17. addTime,
  18. delFlag
  19. ) VALUES (
  20. #{activityId},
  21. #{productId},
  22. #{price},
  23. now(),
  24. 0
  25. )
  26. </insert>
  27. <delete id="deleteProduct">
  28. DELETE FROM cm_product_activity
  29. WHERE activityId = #{id}
  30. </delete>
  31. <select id="findProduct" resultType="com.caimei.modules.product.entity.Product">
  32. SELECT
  33. p.*,
  34. s.name AS "shopName",
  35. cpa.actPrice AS "activityPrice"
  36. FROM
  37. cm_product_activity cpa
  38. LEFT JOIN product p ON cpa.productId = p.productID
  39. LEFT JOIN shop s ON s.shopID = p.shopID
  40. WHERE
  41. cpa.activityId = #{id}
  42. and p.productCategory = 1
  43. AND delFlag = '0'
  44. </select>
  45. <delete id="deleteActivityProduct">
  46. DELETE FROM cm_product_activity
  47. WHERE activityId = #{activityId}
  48. AND productId = #{productId}
  49. </delete>
  50. <select id="findAllProduct" resultType="com.caimei.modules.product.entity.Product">
  51. SELECT
  52. a.*,s.name AS "shopName"
  53. FROM product a
  54. LEFT JOIN shop s on s.shopID = a.shopID
  55. <where>
  56. <if test="productID != null" >
  57. AND a.productID = #{productID}
  58. </if>
  59. <if test="name != null and name != ''">
  60. AND a.name LIKE
  61. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  62. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  63. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  64. </if>
  65. <if test="shopName != null and shopName != ''">
  66. AND s.name LIKE
  67. <if test="dbName == 'oracle'">'%'||#{shopName}||'%'</if>
  68. <if test="dbName == 'mssql'">'%'+#{shopName}+'%'</if>
  69. <if test="dbName == 'mysql'">concat('%',#{shopName},'%')</if>
  70. </if>
  71. <if test="ids != null and ids.size() > 0 ">
  72. AND a.productID NOT IN
  73. <foreach collection="ids" open="(" close=")" item="id" separator=",">
  74. #{id}
  75. </foreach>
  76. </if>
  77. AND a.validFlag = 2
  78. and a.productCategory = 1
  79. </where>
  80. <choose>
  81. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  82. ORDER BY ${page.orderBy}
  83. </when>
  84. <otherwise>
  85. order by a.productID desc
  86. </otherwise>
  87. </choose>
  88. </select>
  89. <select id="findActivityId" resultType="integer">
  90. SELECT productId FROM cm_product_activity WHERE delFlag='0'
  91. </select>
  92. </mapper>