ClubMapper.xml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. <update id="updateClubUserByUpdateInfo">
  5. update user set
  6. <if test="name != null and name != ''">
  7. name = #{name},
  8. </if>
  9. <if test="email != null and email != ''">
  10. email = #{email},
  11. </if>
  12. userName = #{userName}
  13. where userID = #{userId}
  14. </update>
  15. <update id="updateClubByUpdateInfo">
  16. update club set
  17. <if test="name != null and name != ''">
  18. name = #{name},
  19. </if>
  20. <if test="shortName != null and shortName != ''">
  21. sname = #{shortName},
  22. </if>
  23. <if test="contractEmail != null and contractEmail != ''">
  24. contractEmail1 = #{contractEmail},
  25. </if>
  26. contractPhone = #{contractPhone},
  27. <if test="linkMan != null and linkMan != ''">
  28. linkMan = #{linkMan},
  29. </if>
  30. <if test="townId != null and townId != ''">
  31. provinceID = #{provinceId}, cityID = #{cityId}, townID = #{townId}, address = #{address},
  32. </if>
  33. <if test="shopPhoto != null and shopPhoto != 'null' and shopPhoto != ''">
  34. headpic = #{shopPhoto},
  35. </if>
  36. <if test="businessLicense != null and businessLicense != ''">
  37. businessLicenseImage = #{businessLicense},
  38. </if>
  39. <if test="socialCreditCode != null and socialCreditCode != ''">
  40. socialCreditCode = #{socialCreditCode},
  41. </if>
  42. <if test="firstClubType != null and firstClubType != ''">
  43. firstClubType = #{firstClubType},
  44. </if>
  45. <if test="firstClubType == 1">
  46. secondClubType = #{secondClubType}, department = #{department}, medicalPracticeLicenseImg = #{medicalPracticeLicense},
  47. </if>
  48. <if test="mainProduct != null and mainProduct != ''">
  49. mainpro = #{mainProduct},
  50. </if>
  51. fax = #{fax},
  52. info = #{profile},
  53. lastModify = NOW()
  54. where clubID = #{clubId}
  55. </update>
  56. <select id="getClubById" resultType="com.caimei365.user.model.vo.ClubVo">
  57. select clubID as clubId, userID as userId, name, sname as shortName, contractMobile, contractEmail1 as contractEmail,
  58. contractPhone, linkMan, provinceID as proviceId, cityID as cityId, townID as townId,
  59. address, headpic as shopPhoto, businessLicenseImage as businessLicense, socialCreditCode,
  60. firstClubType, secondClubType, department, medicalPracticeLicenseImg as medicalPracticeLicense,
  61. mainpro as mainProduct, fax, info as profile, spID as serviceProviderId, addTime, status
  62. from club
  63. where clubID = #{clubId}
  64. </select>
  65. <select id="getOrderCount" resultType="com.caimei365.user.model.vo.OrderCountVo">
  66. select userID as userId,
  67. (select COUNT(*) from cm_order where userID = #{userId} and delFlag = '0') as orderCount,
  68. (select COUNT(*) from cm_order where userID = #{userId} and delFlag = '0' and status = '0') as confirmedCount,
  69. (select COUNT(*) from cm_order where userID = #{userId} and delFlag = '0' and status in(11,12,13,21,22,23)) as paymentCount,
  70. (select COUNT(*) from cm_order where userID = #{userId} and delFlag = '0' and status in(11,12,21,22,31,32)) as waitShipmentsCount,
  71. (select COUNT(*) from cm_order where userID = #{userId} and delFlag = '0' and status in(12,13,22,23,32,33)) as shipmentsCount,
  72. (select COUNT(*) from cm_order where userID = #{userId} and delFlag = '0' and status in(1,2)) as salesReturnCount
  73. from cm_order
  74. where userID = #{userId} and delFlag = '0'
  75. limit 1
  76. </select>
  77. <select id="findBeansHistoryByType" resultType="integer">
  78. SELECT id FROM user_beans_history WHERE userId = #{userId} AND beansType = #{beansType} AND delFlag = 0
  79. </select>
  80. <update id="updateUserBeans">
  81. UPDATE USER SET userBeans = #{userBeans} WHERE userID = #{userId}
  82. </update>
  83. <select id="findBeansHistory" resultType="com.caimei365.user.model.vo.BeansHistoryVo">
  84. SELECT
  85. beansType,
  86. num
  87. FROM
  88. user_beans_history
  89. WHERE
  90. pushStatus = 0
  91. AND beansType IN (1, 2, 3, 4, 8, 12)
  92. AND delFlag = 0
  93. AND userId = #{userId}
  94. ORDER BY
  95. ADDTIME DESC
  96. LIMIT
  97. 1
  98. </select>
  99. <select id="findByBeansType" resultType="integer">
  100. SELECT
  101. SUM(num)
  102. FROM
  103. user_beans_history
  104. WHERE
  105. userId = #{userId}
  106. AND beansType = #{beansType}
  107. AND pushStatus = 0
  108. AND delFlag = 0
  109. </select>
  110. <update id="updatePushStatus">
  111. UPDATE user_beans_history SET pushStatus = 1 WHERE userId = #{userId}
  112. </update>
  113. <select id="findAllBeansHistory" resultType="com.caimei365.user.model.vo.BeansHistoryVo">
  114. SELECT
  115. type,
  116. beansType,
  117. num,
  118. addTime
  119. FROM
  120. user_beans_history
  121. WHERE
  122. userId = #{userId}
  123. AND addTime <![CDATA[ >= ]]> #{startTime}
  124. AND addTime <![CDATA[ <= ]]> #{endTime}
  125. AND delFlag = 0
  126. <if test="type != null and type != 0">
  127. AND type = #{type}
  128. </if>
  129. ORDER BY addTime DESC
  130. </select>
  131. <select id="findLoginBeans" resultType="integer">
  132. SELECT
  133. id
  134. FROM
  135. user_beans_history
  136. WHERE
  137. beansType IN (1,12)
  138. AND DATE_FORMAT(addTime, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
  139. AND userId = #{userId}
  140. </select>
  141. <select id="findCountCoupon" resultType="integer">
  142. SELECT
  143. COUNT(a.id)
  144. FROM
  145. cm_coupon_club a
  146. LEFT JOIN cm_coupon cc ON a.couponId = cc.id
  147. WHERE
  148. cc.delFlag = 0
  149. AND a.delFlag = 0
  150. AND a.userId = #{userId}
  151. AND a.status = 1
  152. AND NOW() BETWEEN cc.startDate
  153. AND cc.endDate
  154. AND cc.status != 2
  155. </select>
  156. </mapper>