ClubMapper.xml 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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.caimei365.user.mapper.ClubMapper">
  4. <insert id="insertRemarks" parameterType="com.caimei365.user.model.po.ClubRemarksPo" keyProperty="remarksId" useGeneratedKeys="true">
  5. insert into cm_club_remarks(clubId, serviceProviderId, remarks, addTime)
  6. values (#{clubId}, #{serviceProviderId}, #{remarks}, now())
  7. </insert>
  8. <insert id="insertRemarksImage">
  9. insert into cm_club_remarks_file(remarksId, fileType, imageUrl)
  10. values (#{remarksId}, 1, #{imageUrl})
  11. </insert>
  12. <insert id="insertRemarksFile">
  13. insert into cm_club_remarks_file(remarksId, fileType, fileName, ossName)
  14. values (#{remarksId}, 2, #{fileName}, #{ossName})
  15. </insert>
  16. <update id="updateClubUserByUpdateInfo">
  17. update user set
  18. <if test="name != null and name != ''">
  19. name = #{name},
  20. </if>
  21. <if test="email != null and email != ''">
  22. email = #{email},
  23. </if>
  24. userName = #{userName}
  25. where userID = #{userId}
  26. </update>
  27. <update id="updateClubByUpdateInfo">
  28. update club set
  29. <if test="name != null and name != ''">
  30. name = #{name},
  31. </if>
  32. <if test="shortName != null and shortName != ''">
  33. sname = #{shortName},
  34. </if>
  35. <if test="contractEmail != null and contractEmail != ''">
  36. contractEmail1 = #{contractEmail},
  37. </if>
  38. contractPhone = #{contractPhone},
  39. <if test="linkMan != null and linkMan != ''">
  40. linkMan = #{linkMan},
  41. </if>
  42. <if test="townId != null and townId != ''">
  43. provinceID = #{provinceId}, cityID = #{cityId}, townID = #{townId}, address = #{address},
  44. </if>
  45. <if test="shopPhoto != null and shopPhoto != 'null' and shopPhoto != ''">
  46. headpic = #{shopPhoto},
  47. </if>
  48. <if test="businessLicense != null and businessLicense != ''">
  49. businessLicenseImage = #{businessLicense},
  50. </if>
  51. <if test="socialCreditCode != null and socialCreditCode != ''">
  52. socialCreditCode = #{socialCreditCode},
  53. </if>
  54. <if test="firstClubType != null and firstClubType != ''">
  55. firstClubType = #{firstClubType},
  56. </if>
  57. <if test="firstClubType == 1 or firstClubType == 2">
  58. secondClubType = #{secondClubType}, department = #{department}, medicalPracticeLicenseImg = #{medicalPracticeLicense},
  59. </if>
  60. <if test="mainProduct != null and mainProduct != ''">
  61. mainpro = #{mainProduct},
  62. </if>
  63. fax = #{fax},
  64. info = #{profile},
  65. lastModify = NOW()
  66. where clubID = #{clubId}
  67. </update>
  68. <delete id="clearRemarksFiles">
  69. delete from cm_club_remarks_file where id = #{remarksId}
  70. </delete>
  71. <delete id="deleteRemarks">
  72. delete from cm_club_remarks where id = #{remarksId}
  73. </delete>
  74. <delete id="deleteRemarksFiles">
  75. delete from cm_club_remarks_file where remarksId = #{remarksId}
  76. </delete>
  77. <select id="getClubById" resultType="com.caimei365.user.model.vo.ClubVo">
  78. select clubID as clubId, userID as userId, name, sname as shortName, contractMobile, contractEmail1 as contractEmail,
  79. contractPhone, linkMan, provinceID as proviceId, cityID as cityId, townID as townId,
  80. address, headpic as shopPhoto, businessLicenseImage as businessLicense, socialCreditCode,
  81. firstClubType, secondClubType, department, medicalPracticeLicenseImg as medicalPracticeLicense,
  82. mainpro as mainProduct, fax, info as profile, spID as serviceProviderId, addTime, status
  83. from club
  84. where clubID = #{clubId}
  85. </select>
  86. <select id="getOrderCount" resultType="com.caimei365.user.model.vo.OrderCountVo">
  87. select userID as userId,
  88. (select COUNT(*) from cm_order where userID = #{userId} and delFlag = '0') as orderCount,
  89. (select COUNT(*) from cm_order where userID = #{userId} and delFlag = '0' and status = '0') as confirmedCount,
  90. (select COUNT(*) from cm_order where userID = #{userId} and delFlag = '0' and status in(11,12,13,21,22,23)) as paymentCount,
  91. (select COUNT(*) from cm_order where userID = #{userId} and delFlag = '0' and status in(11,12,21,22,31,32)) as waitShipmentsCount,
  92. (select COUNT(*) from cm_order where userID = #{userId} and delFlag = '0' and status in(12,13,22,23,32,33)) as shipmentsCount,
  93. (select COUNT(*) from cm_order where userID = #{userId} and delFlag = '0' and status in(1,2)) as salesReturnCount
  94. from cm_order
  95. where userID = #{userId} and delFlag = '0'
  96. limit 1
  97. </select>
  98. <select id="findBeansHistoryByType" resultType="integer">
  99. SELECT id FROM user_beans_history WHERE userId = #{userId} AND beansType = #{beansType} AND delFlag = 0
  100. </select>
  101. <update id="updateUserBeans">
  102. UPDATE USER SET userBeans = #{userBeans} WHERE userID = #{userId}
  103. </update>
  104. <select id="findBeansHistory" resultType="com.caimei365.user.model.vo.BeansHistoryVo">
  105. SELECT
  106. beansType,
  107. num
  108. FROM
  109. user_beans_history
  110. WHERE
  111. pushStatus = 0
  112. AND beansType IN (1, 2, 3, 4, 8, 12)
  113. AND delFlag = 0
  114. AND userId = #{userId}
  115. ORDER BY
  116. ADDTIME DESC
  117. LIMIT
  118. 1
  119. </select>
  120. <select id="findByBeansType" resultType="integer">
  121. SELECT
  122. SUM(num)
  123. FROM
  124. user_beans_history
  125. WHERE
  126. userId = #{userId}
  127. AND beansType = #{beansType}
  128. AND pushStatus = 0
  129. AND delFlag = 0
  130. </select>
  131. <update id="updatePushStatus">
  132. UPDATE user_beans_history SET pushStatus = 1 WHERE userId = #{userId}
  133. </update>
  134. <update id="updateRemarks">
  135. update cm_club_remarks
  136. set remarks = #{remarks}
  137. where id = #{remarksId}
  138. </update>
  139. <select id="findAllBeansHistory" resultType="com.caimei365.user.model.vo.BeansHistoryVo">
  140. SELECT
  141. type,
  142. beansType,
  143. num,
  144. addTime
  145. FROM
  146. user_beans_history
  147. WHERE
  148. userId = #{userId}
  149. AND addTime <![CDATA[ >= ]]> #{startTime}
  150. AND addTime <![CDATA[ <= ]]> #{endTime}
  151. AND delFlag = 0
  152. <if test="type != null and type != 0">
  153. AND type = #{type}
  154. </if>
  155. ORDER BY addTime DESC
  156. </select>
  157. <select id="findLoginBeans" resultType="integer">
  158. SELECT
  159. id
  160. FROM
  161. user_beans_history
  162. WHERE
  163. beansType IN (1,12)
  164. AND DATE_FORMAT(addTime, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
  165. AND userId = #{userId}
  166. </select>
  167. <select id="findCountCoupon" resultType="integer">
  168. SELECT
  169. COUNT(a.id)
  170. FROM
  171. cm_coupon_club a
  172. LEFT JOIN cm_coupon cc ON a.couponId = cc.id
  173. WHERE
  174. cc.delFlag = 0
  175. AND a.delFlag = 0
  176. AND a.userId = #{userId}
  177. AND a.status = 1
  178. AND NOW() BETWEEN cc.startDate
  179. AND cc.endDate
  180. AND cc.status != 2
  181. </select>
  182. <select id="findBeansHistoryByArchiveId" resultType="java.lang.Integer">
  183. select id from user_beans_history where userId = #{userId} and archiveId = #{archiveId}
  184. </select>
  185. <select id="getBeansNumByUserId" resultType="java.lang.Integer">
  186. select userBeans
  187. from user
  188. where userID = #{userId}
  189. </select>
  190. <select id="getRemarksList" resultType="com.caimei365.user.model.vo.RemarksVo">
  191. select id as remarksId, remarks, addTime
  192. from cm_club_remarks
  193. where clubId = #{clubId}
  194. order by addTime desc
  195. </select>
  196. <select id="getRemarks" resultType="com.caimei365.user.model.vo.RemarksVo">
  197. select id as remarksId, remarks, addTime
  198. from cm_club_remarks
  199. where id = #{remarksId}
  200. </select>
  201. <select id="getRemarksImageList" resultType="java.lang.String">
  202. select imageUrl
  203. from cm_club_remarks_file
  204. where remarksId = #{remarksId}
  205. and fileType = 1
  206. </select>
  207. <select id="getRemarksFileList" resultType="com.caimei365.user.model.vo.RemarksFileVo">
  208. select fileName, ossName
  209. from cm_club_remarks_file
  210. where remarksId = #{remarksId}
  211. and fileType = 2
  212. </select>
  213. </mapper>