MessageCenter.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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.MessageCenterMapper">
  4. <resultMap id="MessageCenterResult" type="com.caimei365.user.model.vo.MessageCenter">
  5. <id property="id" column="id" />
  6. <result property="shopId" column="shopID" />
  7. <result property="clubId" column="clubId" />
  8. <result property="orderId" column="orderId" />
  9. <result property="userType" column="userType" />
  10. <result property="messageType" column="messageType" />
  11. <result property="content" column="content" />
  12. <result property="time" column="time" />
  13. <result property="accountType" column="accountType" />
  14. <result property="couponType" column="couponType" />
  15. <result property="couponFee" column="couponFee" />
  16. <result property="mainImage" column="mainImage" />
  17. <result property="onlinePayFlag" column="onlinePayFlag" />
  18. <result property="productName" column="productName" />
  19. <result property="shopMessType" column="shopMessType" />
  20. <result property="shopTieredType" column="shopTieredType" />
  21. <result property="orderMessageType" column="orderMessageType" />
  22. <result property="saved" column="saved" />
  23. <result property="couponMessageType" column="couponMessageType" />
  24. <result property="productCount" column="productCount" />
  25. <result property="refundType" column="refundType" />
  26. <result property="status" column="status" />
  27. <result property="productId" column="productId" />
  28. <result property="shopName" column="shopName" />
  29. </resultMap>
  30. <insert id="addMessageCenter">
  31. INSERT INTO message_center (shopID, clubID, userType, messageType, content,time,accountType,couponType,couponFee,couponMessageType,ShopMessType)
  32. VALUES (#{shopId}, #{clubId}, #{userType}, #{messageType}, #{content},#{time},#{accountType},#{couponType},#{couponFee},#{couponMessageType},#{shopMessType})
  33. </insert>
  34. <select id="clubIdCule" resultType="java.lang.Integer">
  35. SELECT clubID FROM `user` WHERE userId=#{userId}
  36. </select>
  37. <select id="shopID" resultType="java.lang.Integer">
  38. SELECT shopID FROM `shop` WHERE userId=#{userId}
  39. </select>
  40. <select id="clubList" resultType="com.caimei365.user.model.vo.UserVo">
  41. SELECT * FROM `user` WHERE userId=#{userId}
  42. </select>
  43. <select id="CouponList" resultType="com.caimei365.user.model.vo.CouponVo">
  44. SELECT * FROM cm_coupon WHERE couponType=#{couponType}
  45. AND NOW() >= startDate
  46. AND endDate >= NOW()
  47. AND status=1
  48. AND delFlag=0
  49. LIMIT 1
  50. </select>
  51. <select id="MessageCount" resultType="java.lang.Integer">
  52. SELECT COUNT(1) FROM `message_center`
  53. <where>
  54. <if test="userType == 1">
  55. and clubID=#{commonId}
  56. </if>
  57. <if test="userType == 2">
  58. and shopID=#{commonId}
  59. </if>
  60. AND messageType=#{messageType}
  61. and userType=#{userType}
  62. AND saved=0
  63. </where>
  64. </select>
  65. <select id="Count" resultType="java.lang.Integer">
  66. SELECT COUNT(1) FROM `message_center`
  67. <where>
  68. <if test="userType == 1">
  69. and clubID=#{commonId}
  70. </if>
  71. <if test="userType == 2">
  72. and shopID=#{commonId}
  73. </if>
  74. and userType=#{userType}
  75. AND saved=0
  76. </where>
  77. </select>
  78. <select id="receStatct" resultType="java.lang.Integer">
  79. SELECT COUNT(*) FROM `cm_discern_receipt` WHERE newReceiptType=1 AND shopID=#{shopID} AND receStatct=2
  80. </select>
  81. <select id="listingFee" resultType="java.lang.Integer">
  82. SELECT COUNT(*) FROM `cm_discern_receipt` WHERE newReceiptType=1 AND shopID=#{shopID}
  83. </select>
  84. <select id="listingfeeExpire" resultType="java.lang.Integer">
  85. SELECT COUNT(*) FROM `cm_discern_receipt` WHERE newReceiptType=1 AND shopID=#{shopID} AND NOW()> DATE_ADD(receiptDate, INTERVAL 1 YEAR)
  86. </select>
  87. <select id="MessageList" resultType="com.caimei365.user.model.vo.MessageCenter">
  88. SELECT * FROM `message_center`
  89. <where>
  90. <if test="messageType !=null">
  91. AND messageType=#{messageType}
  92. </if>
  93. <if test="userType == 1">
  94. and clubID=#{commonId}
  95. </if>
  96. <if test="userType == 2">
  97. and shopID=#{commonId}
  98. </if>
  99. and userType=#{userType}
  100. </where>
  101. ORDER BY id DESC
  102. </select>
  103. <select id="contractMobile" resultType="java.lang.String">
  104. SELECT contractMobile FROM club WHERE clubID=#{clubID}
  105. </select>
  106. <select id="contractMobiles" resultType="java.lang.String">
  107. SELECT contractMobile FROM shop WHERE shopID=#{shopID}
  108. </select>
  109. <select id="getOpenidListByPermission" resultType="java.lang.String">
  110. SELECT openid FROM `wechat_user` WHERE unionId= #{unionId}
  111. </select>
  112. <select id="FromUnionId" resultType="java.lang.String">
  113. SELECT unionID FROM `cm_order` WHERE userID=#{userID} AND unionID IS NOT NULL ORDER BY orderID DESC LIMIT 1
  114. </select>
  115. <select id="UnionIdList" resultType="java.lang.String">
  116. SELECT unionID FROM `cm_mall_operation_user` WHERE userID=#{userID} LIMIT 1
  117. </select>
  118. <select id="getVipHistoryCount" resultType="java.lang.Integer">
  119. SELECT count(1)
  120. FROM cm_svip_history
  121. WHERE userId = #{userId}
  122. </select>
  123. <select id="MainImage" resultType="com.caimei365.user.model.vo.MessageCenter">
  124. SELECT co.refundType,COUNT(p.productID)AS productCount ,p.mainImage,co.onlinePayFlag,ifnull(p.name,'') as productName,co.orderID as orderID,co.status as status
  125. FROM cm_order co
  126. LEFT JOIN bp_order_userinfo bou ON bou.orderId = co.orderID
  127. LEFT JOIN USER u ON u.userID = co.userID
  128. LEFT JOIN club c ON u.userID = c.userID
  129. LEFT JOIN serviceprovider sp ON c.spID = sp.serviceProviderID AND sp.status = 90
  130. LEFT JOIN cm_order_product cop ON co.orderID = cop.orderID
  131. LEFT JOIN product p ON cop.productID = p.productID
  132. LEFT JOIN cm_shop_order cso ON co.orderid=cso.orderID
  133. <where>
  134. <if test="userType == 1">
  135. and c.clubID=#{commonId}
  136. </if>
  137. <if test="userType == 2">
  138. and p.shopID=#{commonId}
  139. </if>
  140. and co.orderID=#{orderID}
  141. </where>
  142. LIMIT 1
  143. </select>
  144. <select id="productImage" resultType="com.caimei365.user.model.vo.MessageCenter">
  145. SELECT s.name as shopName,p.`shopID`,p.`productID`,p.`name` as productName,p.mainImage
  146. FROM product p
  147. LEFT JOIN cm_order_product cop ON p.productID = cop.productID
  148. LEFT JOIN shop s ON s.shopID = p.shopID
  149. <where>
  150. <if test="productID != null">
  151. and p.productID=#{productID}
  152. </if>
  153. and p.shopID=#{shopID}
  154. </where>
  155. LIMIT 1
  156. </select>
  157. <select id="productCount" resultType="java.lang.Integer">
  158. SELECT COUNT(productID) FROM cm_order_product
  159. WHERE orderID=#{orderID}
  160. </select>
  161. <select id="receiptDate" resultType="java.lang.String">
  162. SELECT
  163. a.receiptDate
  164. FROM cm_discern_receipt a
  165. LEFT JOIN shop s ON s.shopID = a.shopID
  166. where
  167. a.shopID=#{shopID}
  168. AND a.newReceiptType=1
  169. </select>
  170. <select id="receiptAmount" resultType="java.lang.Double">
  171. SELECT
  172. a.receiptAmount
  173. FROM cm_discern_receipt a
  174. LEFT JOIN shop s ON s.shopID = a.shopID
  175. where
  176. a.shopID=#{shopID}
  177. AND a.newReceiptType=1
  178. </select>
  179. <select id="newReceiptType" resultType="java.lang.Integer">
  180. SELECT
  181. a.newReceiptType
  182. FROM cm_discern_receipt a
  183. LEFT JOIN shop s ON s.shopID = a.shopID
  184. where
  185. a.shopID=#{shopID}
  186. LIMIT 1
  187. </select>
  188. <update id="updateMessageAsRead">
  189. UPDATE message_center SET saved = 1
  190. <where>
  191. <if test="userType == 1">
  192. and clubID=#{commonId}
  193. </if>
  194. <if test="userType == 2">
  195. and shopID=#{commonId}
  196. </if>
  197. <if test="messageType !=null">
  198. and messageType = #{messageType}
  199. </if>
  200. and userType=#{userType}
  201. </where>
  202. </update>
  203. <select id="userId" resultType="java.lang.Integer">
  204. SELECT userID FROM `cm_mall_operation_user` WHERE openid=#{openid} LIMIT 1
  205. </select>
  206. <delete id="deleteMessage">
  207. DELETE FROM message_center WHERE id = #{id}
  208. </delete>
  209. <update id="updateRead">
  210. UPDATE message_center SET saved = 1
  211. where userType=#{userType} and id=#{Id}
  212. </update>
  213. <select id="receiptShopID" resultType="java.lang.Integer">
  214. SELECT DISTINCT
  215. a.shopID
  216. FROM cm_discern_receipt a
  217. LEFT JOIN shop s ON s.shopID = a.shopID
  218. WHERE
  219. a.newReceiptType=1
  220. </select>
  221. <select id="shopName" resultType="java.lang.String">
  222. SELECT name FROM `shop` WHERE shopID=#{shopID}
  223. </select>
  224. <select id="getMessageCenterListDay" resultType="java.lang.Integer">
  225. select distinct d.shopID as shopID from cm_receipt as r
  226. LEFT JOIN cm_discern_receipt as d on r.receiptID=d.id
  227. LEFT JOIN shop as s on d.shopID=s.shopID
  228. WHERE receStatct=0 and DATEDIFF(r.dateStrings,NOW())=#{day}
  229. </select>
  230. <update id="updateMessageCenter" parameterType="com.caimei365.user.model.vo.MessageCenter">
  231. update message_center
  232. <set>
  233. <!-- <if test="id != null and id != 0">id = #{id},</if>-->
  234. <!-- <if test="shopID != null and shopID != ''">shopID = #{shopID},</if>-->
  235. <!-- <if test="clubID != null and clubID != ''">clubID = #{clubID},</if>-->
  236. <if test="orderId != null and orderId != '' ">orderID = #{orderId},</if>
  237. <if test="userType != null and userType != ''">userType = #{userType},</if>
  238. <if test="messageType != null and messageType != ''">messageType = #{messageType},</if>
  239. <if test="accountType != null and accountType != ''">accountType = #{accountType},</if>
  240. <if test="orderMessageType != null and orderMessageType != ''">orderMessageType = #{orderMessageType},</if>
  241. <if test="couponMessageType != null and couponMessageType != ''">couponMessageType = #{couponMessageType},</if>
  242. <if test="couponFee != null and couponFee != ''">couponFee = #{couponFee},</if>
  243. <if test="content != null and content != ''">content = #{content},</if>
  244. <if test="time != null and time != ''">`time` = #{time},</if>
  245. <if test="saved != null and saved != ''">saved = #{saved},</if>
  246. <if test="shopMessType != null and shopMessType != ''">shopMessType = #{shopMessType},</if>
  247. <if test="shopTieredType != null and sex != ''">shopTieredType = #{shopTieredType},</if>
  248. <if test="shopTieredType != null and shopTieredType != ''">couponType = #{couponType},</if>
  249. <if test="productId != null and productId != ''">productID = #{productId},</if>
  250. </set>
  251. <where>
  252. <if test="userType == 1">
  253. and shopID=#{shopId}
  254. </if>
  255. <if test="userType == 2">
  256. and clubID=#{clubId}
  257. </if>
  258. </where>
  259. </update>
  260. <insert id="insertMessageCenter" parameterType="com.caimei365.user.model.vo.MessageCenter">
  261. insert into message_center
  262. <trim prefix="(" suffix=")" suffixOverrides=",">
  263. <if test="shopId != null and shopId != ''">shopID,</if>
  264. <if test="clubId != null and clubId != ''">clubID,</if>
  265. <if test="orderId != null and orderId != '' ">orderID,</if>
  266. <if test="userType != null and userType != ''">userType ,</if>
  267. <if test="messageType != null and messageType != ''">messageType,</if>
  268. <if test="accountType != null and accountType != ''">accountType,</if>
  269. <if test="orderMessageType != null and orderMessageType != ''">orderMessageType,</if>
  270. <if test="couponMessageType != null and couponMessageType != ''">couponMessageTyp,</if>
  271. <if test="couponFee != null and couponFee != ''">couponFee,</if>
  272. <if test="content != null and content != ''">content,</if>
  273. <if test="time != null and time != ''">`time`,</if>
  274. <if test="saved != null and saved != ''">saved ,</if>
  275. <if test="shopMessType != null and shopMessType != ''">shopMessType,</if>
  276. <if test="shopTieredType != null and shopTieredType != ''">shopTieredType,</if>
  277. <if test="shopTieredType != null and shopTieredType != ''">couponType,</if>
  278. <if test="productId != null and productId != ''">productID,</if>
  279. </trim >
  280. values
  281. <trim prefix="(" suffix=")" suffixOverrides=",">
  282. <if test="shopId != null and shopId != ''"> #{shopId},</if>
  283. <if test="clubId != null and clubId != ''"> #{clubId},</if>
  284. <if test="orderId != null and orderId != '' "> #{orderId},</if>
  285. <if test="userType != null and userType != ''"> #{userType},</if>
  286. <if test="messageType != null and messageType != ''"> #{messageType},</if>
  287. <if test="accountType != null and accountType != ''"> #{accountType},</if>
  288. <if test="orderMessageType != null and orderMessageType != ''"> #{orderMessageType},</if>
  289. <if test="couponMessageType != null and couponMessageType != ''"> #{couponMessageType},</if>
  290. <if test="couponFee != null and couponFee != ''"> #{couponFee},</if>
  291. <if test="content != null and content != ''"> #{content},</if>
  292. <if test="time != null and time != ''"> #{time},</if>
  293. <if test="saved != null and saved != ''"> #{saved},</if>
  294. <if test="shopMessType != null and shopMessType != ''"> #{shopMessType},</if>
  295. <if test="shopTieredType != null and sex != ''"> #{shopTieredType},</if>
  296. <if test="shopTieredType != null and shopTieredType != ''"> #{couponType},</if>
  297. <if test="productId != null and productId != ''"> #{productId},</if>
  298. </trim>
  299. </insert>
  300. </mapper>