MessageCenter.xml 15 KB

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