MessageCenter.xml 15 KB

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