BaseMapper.xml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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.tools.mapper.BaseMapper">
  4. <select id="getAllUnsignedLogistics" resultType="com.caimei365.tools.model.po.LogisticsInfoPo">
  5. SELECT id,
  6. orderId,
  7. authId,
  8. nu,
  9. state,
  10. info,
  11. logisticsCompanyCode,
  12. mobile
  13. FROM logistics_information
  14. WHERE ((state != 3 AND state != 4 AND state != -1) OR state IS NULL)
  15. AND (updateDate > DATE_SUB(NOW(), interval 1 year))
  16. ORDER BY id DESC
  17. </select>
  18. <select id="getLogisticsPhoneByOrderId" resultType="java.lang.String">
  19. SELECT mobile
  20. FROM bp_order_userinfo
  21. WHERE orderId = #{orderId}
  22. LIMIT 1
  23. </select>
  24. <update id="updateLogistics" parameterType="com.caimei365.tools.model.po.LogisticsInfoPo">
  25. UPDATE logistics_information
  26. SET state=#{state},
  27. info=#{info},
  28. logisticsCompanyCode = #{logisticsCompanyCode},
  29. updateDate=#{updateDate}
  30. WHERE id = #{id}
  31. </update>
  32. <select id="findVip" resultType="com.caimei365.tools.model.po.SuperVipPo">
  33. select userId, endTime
  34. from cm_svip_user
  35. where delFlag = 0
  36. AND endTime between #{startTime} and #{endTime}
  37. </select>
  38. <select id="findMobile" resultType="java.lang.String">
  39. select bindMobile
  40. from user
  41. where userID = #{userid}
  42. </select>
  43. <select id="getMaturitySecondProductIds" resultType="java.lang.Integer">
  44. SELECT cshd.productID
  45. FROM cm_second_hand_detail cshd
  46. LEFT JOIN product p ON p.productID = cshd.productID
  47. WHERE p.validFlag = 2
  48. AND cshd.onLineDate <![CDATA[ < ]]> #{beforeDays}
  49. </select>
  50. <update id="updateProductValidFlag">
  51. UPDATE product
  52. SET validFlag = #{validFlag}
  53. where productID = #{productId}
  54. </update>
  55. <select id="getCouponUserIds" resultType="java.lang.Integer">
  56. SELECT userId
  57. FROM cm_coupon_club
  58. GROUP BY userId
  59. </select>
  60. <select id="getReceivedCoupons" resultType="com.caimei365.tools.model.bo.CouponDateBo">
  61. SELECT cc.id AS couponId,
  62. cc.startDate,
  63. cc.endDate
  64. FROM cm_coupon_club a
  65. LEFT JOIN cm_coupon cc ON a.couponId = cc.id
  66. WHERE cc.delFlag = 0
  67. AND a.delFlag = 0
  68. AND a.status = 1
  69. AND cc.status != 2
  70. AND a.userId = #{userId}
  71. AND NOW() BETWEEN cc.startDate AND cc.endDate
  72. ORDER BY a.createDate DESC
  73. </select>
  74. <select id="getUnclaimedCoupons" resultType="com.caimei365.tools.model.bo.CouponDateBo">
  75. SELECT
  76. id AS couponId,
  77. startDate,
  78. endDate
  79. FROM cm_coupon
  80. WHERE delFlag = 0 AND couponsMode = 0 AND status != 2
  81. AND NOW() BETWEEN startDate AND endDate
  82. <if test="userId == null or userId == 0">
  83. AND couponType != 2
  84. </if>
  85. <if test="userId > 0">
  86. AND id NOT IN(SELECT couponId FROM cm_coupon_club WHERE userId = #{userId})
  87. AND (couponType IN (0,1,3)
  88. OR couponType = 2 AND userId = #{userId}
  89. OR ((SELECT registerTime FROM USER WHERE userID = #{userId}) <![CDATA[ >= ]]> startDate
  90. AND couponType = 4))
  91. </if>
  92. ORDER BY createDate DESC
  93. </select>
  94. <insert id="insertShortLink">
  95. INSERT INTO cm_short_link (markId, shortLink, jumpLink, createTime)
  96. VALUES (#{markId}, #{shortLink}, #{url}, NOW())
  97. </insert>
  98. <insert id="insertProductViews">
  99. INSERT INTO cm_product_views_record (productId, views, viewTime)
  100. VALUES (#{productId}, #{views}, #{viewTime})
  101. </insert>
  102. <update id="updateSmsSendCount">
  103. UPDATE cm_sms_statistics
  104. SET sendNum = (sendNum + #{count})
  105. WHERE markId = #{markId}
  106. </update>
  107. <select id="findIdByShortLink" resultType="java.lang.Integer">
  108. SELECT id
  109. FROM cm_short_link
  110. WHERE shortLink = #{shortLink}
  111. </select>
  112. <select id="getInfoBykeyword" resultType="com.caimei365.tools.model.po.SearchFrequencyVo">
  113. select id,
  114. fromSearch,
  115. keyword,
  116. frequency,
  117. searchTime,
  118. trueStatus,
  119. linkageFrequency
  120. from cm_user_search_frequency
  121. where keyword = #{keyword}
  122. and fromSearch = #{fromSearch}
  123. and trueStatus = #{trueStutas}
  124. </select>
  125. <select id="findKeywordId" resultType="java.lang.Integer">
  126. select id
  127. from cm_user_search_frequency
  128. where keyword = #{keyword}
  129. and delStatus = 1
  130. limit 1
  131. </select>
  132. <select id="findUserNameById" resultType="com.caimei365.tools.model.po.SysUser">
  133. select ssr.systemId as id,su.username as username
  134. from sys_system_role ssr
  135. left join system_user su on ssr.systemId=su.id
  136. where ssr.sysId=#{id}
  137. </select>
  138. <select id="getRoleNamesByUserId" resultType="java.lang.String">
  139. SELECT DISTINCT r.role_name FROM system_role r
  140. LEFT JOIN system_role_user ru ON r.id = ru.role_id
  141. WHERE ru.user_id = #{userId}
  142. </select>
  143. <update id="upFrequencyById">
  144. update cm_user_search_frequency
  145. set frequency=#{frequency},
  146. delStatus=1
  147. where id = #{id}
  148. </update>
  149. <update id="uplinkageFrequencyById">
  150. update cm_user_search_frequency
  151. set linkageFrequency=#{linkageFrequency},
  152. frequency=#{frequency},
  153. delStatus=#{delStatus}
  154. where id = #{id}
  155. </update>
  156. <update id="updateKeywordTimes">
  157. UPDATE cm_user_search_frequency
  158. SET frequency = frequency + 1,
  159. searchtime = NOW()
  160. WHERE id = #{id}
  161. </update>
  162. <update id="updateAllKeyword">
  163. update cm_user_search_frequency
  164. set recommendFlag=0,
  165. recommendStatus=0
  166. where trueStatus = 0
  167. and delStatus = 1
  168. </update>
  169. <update id="getRecommendKeyword">
  170. SELECT keyWordId
  171. FROM cm_label_source
  172. WHERE saveTime BETWEEN #{date} AND NOW()
  173. GROUP BY keyWordId
  174. HAVING COUNT(keywordId) > 1
  175. </update>
  176. <update id="updateRecommend">
  177. update cm_user_search_frequency
  178. set recommendStatus = 1
  179. where id in
  180. <foreach collection="ids" separator="," item="id" open="(" close=")">
  181. #{id}
  182. </foreach>
  183. </update>
  184. <insert id="saveInfo" parameterType="com.caimei365.tools.model.po.SearchFrequencyVo" useGeneratedKeys="true"
  185. keyProperty="id">
  186. insert into cm_user_search_frequency(keyword, frequency, searchTime)
  187. values (#{keyword}, #{frequency}, now())
  188. </insert>
  189. <insert id="insertLabelSource">
  190. insert into cm_label_source(keywordId, saveTime, path)
  191. VALUES (#{id}, now(), #{path})
  192. </insert>
  193. </mapper>