MaProjectMapper.xml 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ylx.massage.mapper.MaProjectMapper">
  6. <resultMap type="MaProject" id="MaProjectResult">
  7. <result property="id" column="id" />
  8. <result property="projectName" column="project_name" />
  9. <result property="projectDescribe" column="project_describe" />
  10. <result property="projectDuration" column="project_duration" />
  11. <result property="projectUsersNum" column="project_users_num" />
  12. <result property="projectOriginalPrice" column="project_original_price" />
  13. <result property="projectCurrentPrice" column="project_current_price" />
  14. <result property="projectMasterImage" column="project_master_image" />
  15. <result property="projectDetailImage" column="project_detail_image" />
  16. <result property="projectIsEnable" column="project_is_enable" />
  17. <result property="createUser" column="create_user" />
  18. <result property="updateUser" column="update_user" />
  19. <result property="createTime" column="create_time" />
  20. <result property="updateTime" column="update_time" />
  21. <result property="isDelete" column="is_delete" />
  22. </resultMap>
  23. <sql id="selectMaProjectVo">
  24. select id, project_name, project_describe, project_duration, project_users_num, project_original_price, project_current_price, project_master_image, project_detail_image, project_is_enable, create_user, update_user, create_time, update_time, is_delete from ma_project
  25. </sql>
  26. <select id="selectMaProjectList" parameterType="MaProject" resultMap="MaProjectResult">
  27. <include refid="selectMaProjectVo"/>
  28. <where>
  29. is_delete !=1
  30. <if test="projectName != null and projectName != ''"> and project_name like concat('%', #{projectName}, '%')</if>
  31. <if test="projectDescribe != null and projectDescribe != ''"> and project_describe = #{projectDescribe}</if>
  32. <if test="projectDuration != null "> and project_duration = #{projectDuration}</if>
  33. <if test="projectUsersNum != null "> and project_users_num = #{projectUsersNum}</if>
  34. <if test="projectOriginalPrice != null "> and project_original_price = #{projectOriginalPrice}</if>
  35. <if test="projectCurrentPrice != null "> and project_current_price = #{projectCurrentPrice}</if>
  36. <if test="projectMasterImage != null and projectMasterImage != ''"> and project_master_image = #{projectMasterImage}</if>
  37. <if test="projectDetailImage != null and projectDetailImage != ''"> and project_detail_image = #{projectDetailImage}</if>
  38. <if test="projectIsEnable != null "> and project_is_enable = #{projectIsEnable}</if>
  39. <if test="createUser != null and createUser != ''"> and create_user = #{createUser}</if>
  40. <if test="updateUser != null and updateUser != ''"> and update_user = #{updateUser}</if>
  41. </where>
  42. </select>
  43. <select id="selectMaProjectById" parameterType="Long" resultMap="MaProjectResult">
  44. <include refid="selectMaProjectVo"/>
  45. where is_delete !=1 and id = #{id}
  46. </select>
  47. <insert id="insertMaProject" parameterType="MaProject" useGeneratedKeys="true" keyProperty="id">
  48. insert into ma_project
  49. <trim prefix="(" suffix=")" suffixOverrides=",">
  50. <if test="id != null">id,</if>
  51. <if test="projectName != null and projectName != ''">project_name,</if>
  52. <if test="projectDescribe != null and projectDescribe != ''">project_describe,</if>
  53. <if test="projectDuration != null">project_duration,</if>
  54. <if test="projectUsersNum != null">project_users_num,</if>
  55. <if test="projectOriginalPrice != null">project_original_price,</if>
  56. <if test="projectCurrentPrice != null">project_current_price,</if>
  57. <if test="projectMasterImage != null and projectMasterImage != ''">project_master_image,</if>
  58. <if test="projectDetailImage != null and projectDetailImage != ''">project_detail_image,</if>
  59. <if test="projectIsEnable != null">project_is_enable,</if>
  60. <if test="createUser != null and createUser != ''">create_user,</if>
  61. <if test="updateUser != null and updateUser != ''">update_user,</if>
  62. <if test="createTime != null">create_time,</if>
  63. <if test="updateTime != null">update_time,</if>
  64. <if test="isDelete != null">is_delete,</if>
  65. </trim>
  66. <trim prefix="values (" suffix=")" suffixOverrides=",">
  67. <if test="id != null">#{id},</if>
  68. <if test="projectName != null and projectName != ''">#{projectName},</if>
  69. <if test="projectDescribe != null and projectDescribe != ''">#{projectDescribe},</if>
  70. <if test="projectDuration != null">#{projectDuration},</if>
  71. <if test="projectUsersNum != null">#{projectUsersNum},</if>
  72. <if test="projectOriginalPrice != null">#{projectOriginalPrice},</if>
  73. <if test="projectCurrentPrice != null">#{projectCurrentPrice},</if>
  74. <if test="projectMasterImage != null and projectMasterImage != ''">#{projectMasterImage},</if>
  75. <if test="projectDetailImage != null and projectDetailImage != ''">#{projectDetailImage},</if>
  76. <if test="projectIsEnable != null">#{projectIsEnable},</if>
  77. <if test="createUser != null and createUser != ''">#{createUser},</if>
  78. <if test="updateUser != null and updateUser != ''">#{updateUser},</if>
  79. <if test="createTime != null">#{createTime},</if>
  80. <if test="updateTime != null">#{updateTime},</if>
  81. <if test="isDelete != null">#{isDelete},</if>
  82. </trim>
  83. </insert>
  84. <update id="updateMaProject" parameterType="MaProject">
  85. update ma_project
  86. <trim prefix="SET" suffixOverrides=",">
  87. <if test="projectName != null and projectName != ''">project_name = #{projectName},</if>
  88. <if test="projectDescribe != null and projectDescribe != ''">project_describe = #{projectDescribe},</if>
  89. <if test="projectDuration != null">project_duration = #{projectDuration},</if>
  90. <if test="projectUsersNum != null">project_users_num = #{projectUsersNum},</if>
  91. <if test="projectOriginalPrice != null">project_original_price = #{projectOriginalPrice},</if>
  92. <if test="projectCurrentPrice != null">project_current_price = #{projectCurrentPrice},</if>
  93. <if test="projectMasterImage != null and projectMasterImage != ''">project_master_image = #{projectMasterImage},</if>
  94. <if test="projectDetailImage != null and projectDetailImage != ''">project_detail_image = #{projectDetailImage},</if>
  95. <if test="projectIsEnable != null">project_is_enable = #{projectIsEnable},</if>
  96. <if test="createUser != null and createUser != ''">create_user = #{createUser},</if>
  97. <if test="updateUser != null and updateUser != ''">update_user = #{updateUser},</if>
  98. <if test="createTime != null">create_time = #{createTime},</if>
  99. <if test="updateTime != null">update_time = #{updateTime},</if>
  100. <if test="isDelete != null">is_delete = #{isDelete},</if>
  101. </trim>
  102. where id = #{id}
  103. </update>
  104. <update id="deleteMaProjectById" parameterType="Long">
  105. update ma_project set is_delete = 1 where id = #{id}
  106. </update>
  107. <delete id="deleteMaProjectByIds" parameterType="String">
  108. delete from ma_project where id in
  109. <foreach item="id" collection="array" open="(" separator="," close=")">
  110. #{id}
  111. </foreach>
  112. </delete>
  113. <!-- 推荐项目-->
  114. <select id="getMassageProjectRecommend" resultType="com.ylx.massage.domain.vo.MassageProjectRecommendVo">
  115. SELECT
  116. p.project_name AS projectName,
  117. p.project_duration AS projectDuration,
  118. t.avg_current_price AS avgCurrentPrice,
  119. j.highlight AS highlight,
  120. o.sales AS sales
  121. FROM (
  122. SELECT MIN(id) AS id
  123. FROM ma_project
  124. WHERE is_delete = 0 AND audit_status = 1
  125. GROUP BY project_id
  126. ) AS keep
  127. INNER JOIN ma_project p ON keep.id = p.id
  128. LEFT JOIN project j ON p.project_id = j.id
  129. LEFT JOIN (
  130. SELECT
  131. t.project_id,
  132. AVG(t.project_current_price) AS avg_current_price
  133. FROM ma_project t
  134. WHERE t.is_delete = 0
  135. GROUP BY t.project_id
  136. ) t ON p.project_id = t.project_id
  137. LEFT JOIN
  138. (
  139. SELECT
  140. o.project_id AS project_id,
  141. COUNT(*) AS sales
  142. FROM
  143. t_order o
  144. WHERE o.is_delete = 0
  145. AND o.n_status = 7
  146. AND o.project_type = 1
  147. GROUP BY o.project_id
  148. ) o
  149. ON p.project_id = o.project_id
  150. WHERE p.is_delete = 0
  151. and p.audit_status = 1
  152. </select>
  153. </mapper>