123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.caimei365.user.mapper.MessageCenterMapper">
- <resultMap id="MessageCenterResult" type="com.caimei365.user.model.vo.MessageCenter">
- <id property="id" column="id" />
- <result property="shopId" column="shopID" />
- <result property="clubId" column="clubId" />
- <result property="orderId" column="orderId" />
- <result property="userType" column="userType" />
- <result property="messageType" column="messageType" />
- <result property="content" column="content" />
- <result property="time" column="time" />
- <result property="accountType" column="accountType" />
- <result property="couponType" column="couponType" />
- <result property="couponFee" column="couponFee" />
- <result property="mainImage" column="mainImage" />
- <result property="onlinePayFlag" column="onlinePayFlag" />
- <result property="productName" column="productName" />
- <result property="shopMessType" column="shopMessType" />
- <result property="shopTieredType" column="shopTieredType" />
- <result property="orderMessageType" column="orderMessageType" />
- <result property="saved" column="saved" />
- <result property="couponMessageType" column="couponMessageType" />
- <result property="productCount" column="productCount" />
- <result property="refundType" column="refundType" />
- <result property="status" column="status" />
- <result property="productId" column="productId" />
- <result property="shopName" column="shopName" />
- </resultMap>
- <insert id="addMessageCenter">
- INSERT INTO message_center (shopID, clubID, userType, messageType, content,time,accountType,couponType,couponFee,couponMessageType,ShopMessType)
- VALUES (#{shopId}, #{clubId}, #{userType}, #{messageType}, #{content},#{time},#{accountType},#{couponType},#{couponFee},#{couponMessageType},#{shopMessType})
- </insert>
- <select id="clubIdCule" resultType="java.lang.Integer">
- SELECT clubID FROM `user` WHERE userId=#{userId}
- </select>
- <select id="shopID" resultType="java.lang.Integer">
- SELECT shopID FROM `shop` WHERE userId=#{userId}
- </select>
- <select id="clubList" resultType="com.caimei365.user.model.vo.UserVo">
- SELECT * FROM `user` WHERE userId=#{userId}
- </select>
- <select id="CouponList" resultType="com.caimei365.user.model.vo.CouponVo">
- SELECT * FROM cm_coupon WHERE couponType=#{couponType}
- AND NOW() >= startDate
- AND endDate >= NOW()
- AND status=1
- AND delFlag=0
- LIMIT 1
- </select>
- <select id="MessageCount" resultType="java.lang.Integer">
- SELECT COUNT(1) FROM `message_center`
- <where>
- <if test="userType == 1">
- and clubID=#{commonId}
- </if>
- <if test="userType == 2">
- and shopID=#{commonId}
- </if>
- <if test="userType == 3">
- and thisId=#{commonId}
- </if>
- AND messageType=#{messageType}
- and userType=#{userType}
- AND saved=0
- </where>
- </select>
- <select id="Count" resultType="java.lang.Integer">
- SELECT COUNT(1) FROM `message_center`
- <where>
- <if test="userType == 1">
- and clubID=#{commonId}
- </if>
- <if test="userType == 2">
- and shopID=#{commonId}
- </if>
- <if test="userType == 3">
- and thisId=#{commonId}
- </if>
- and userType=#{userType}
- AND saved=0
- </where>
- </select>
- <select id="receStatct" resultType="java.lang.Integer">
- SELECT COUNT(*) FROM `cm_discern_receipt` WHERE newReceiptType=1 AND shopID=#{shopID} AND receStatct=2
- </select>
- <select id="listingFee" resultType="java.lang.Integer">
- SELECT COUNT(*) FROM `cm_discern_receipt` WHERE newReceiptType=1 AND shopID=#{shopID}
- </select>
- <select id="listingfeeExpire" resultType="java.lang.Integer">
- SELECT COUNT(*) FROM `cm_discern_receipt` WHERE newReceiptType=1 AND shopID=#{shopID} AND NOW()> DATE_ADD(receiptDate, INTERVAL 1 YEAR)
- </select>
- <select id="MessageList" resultType="com.caimei365.user.model.vo.MessageCenter">
- SELECT * FROM `message_center`
- <where>
- <if test="messageType !=null">
- AND messageType=#{messageType}
- </if>
- <if test="userType == 1">
- and clubID=#{commonId}
- </if>
- <if test="userType == 2">
- and shopID=#{commonId}
- </if>
- <if test="userType == 3">
- and thisId=#{commonId}
- </if>
- and userType=#{userType}
- </where>
- ORDER BY id DESC
- </select>
- <select id="contractMobile" resultType="java.lang.String">
- SELECT contractMobile FROM club WHERE clubID=#{clubID}
- </select>
- <select id="contractMobiles" resultType="java.lang.String">
- SELECT contractMobile FROM shop WHERE shopID=#{shopID}
- </select>
- <select id="getOpenidListByPermission" resultType="java.lang.String">
- SELECT openid FROM `wechat_user` WHERE unionId= #{unionId}
- </select>
- <select id="FromUnionId" resultType="java.lang.String">
- SELECT unionID FROM `cm_order` WHERE userID=#{userID} AND unionID IS NOT NULL ORDER BY orderID DESC LIMIT 1
- </select>
- <select id="UnionIdList" resultType="java.lang.String">
- SELECT unionID FROM `cm_mall_operation_user` WHERE userID=#{userID} LIMIT 1
- </select>
- <select id="getVipHistoryCount" resultType="java.lang.Integer">
- SELECT count(1)
- FROM cm_svip_history
- WHERE userId = #{userId}
- </select>
- <select id="MainImage" resultType="com.caimei365.user.model.vo.MessageCenter">
- 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
- FROM cm_order co
- LEFT JOIN bp_order_userinfo bou ON bou.orderId = co.orderID
- LEFT JOIN USER u ON u.userID = co.userID
- LEFT JOIN club c ON u.userID = c.userID
- LEFT JOIN serviceprovider sp ON c.spID = sp.serviceProviderID AND sp.status = 90
- LEFT JOIN cm_order_product cop ON co.orderID = cop.orderID
- LEFT JOIN product p ON cop.productID = p.productID
- LEFT JOIN cm_shop_order cso ON co.orderid=cso.orderID
- <where>
- <if test="userType == 1">
- and c.clubID=#{commonId}
- </if>
- <if test="userType == 2">
- and p.shopID=#{commonId}
- </if>
- <if test="userType == 3">
- and sp.serviceProviderID=#{commonId}
- </if>
- and co.orderID=#{orderID}
- </where>
- LIMIT 1
- </select>
- <select id="productImage" resultType="com.caimei365.user.model.vo.MessageCenter">
- SELECT s.name as shopName,p.`shopID`,p.`productID`,p.`name` as productName,p.mainImage
- FROM product p
- LEFT JOIN cm_order_product cop ON p.productID = cop.productID
- LEFT JOIN shop s ON s.shopID = p.shopID
- <where>
- <if test="productID != null">
- and p.productID=#{productID}
- </if>
- and p.shopID=#{shopID}
- </where>
- LIMIT 1
- </select>
- <select id="productCount" resultType="java.lang.Integer">
- SELECT COUNT(productID) FROM cm_order_product
- WHERE orderID=#{orderID}
- </select>
- <select id="receiptDate" resultType="java.lang.String">
- SELECT
- a.receiptDate
- FROM cm_discern_receipt a
- LEFT JOIN shop s ON s.shopID = a.shopID
- where
- a.shopID=#{shopID}
- AND a.newReceiptType=1
- </select>
- <select id="receiptAmount" resultType="java.lang.Double">
- SELECT
- a.receiptAmount
- FROM cm_discern_receipt a
- LEFT JOIN shop s ON s.shopID = a.shopID
- where
- a.shopID=#{shopID}
- AND a.newReceiptType=1
- </select>
- <select id="newReceiptType" resultType="java.lang.Integer">
- SELECT
- a.newReceiptType
- FROM cm_discern_receipt a
- LEFT JOIN shop s ON s.shopID = a.shopID
- where
- a.shopID=#{shopID}
- LIMIT 1
- </select>
- <update id="updateMessageAsRead">
- UPDATE message_center SET saved = 1
- <where>
- <if test="userType == 1">
- and clubID=#{commonId}
- </if>
- <if test="userType == 2">
- and shopID=#{commonId}
- </if>
- <if test="userType == 3">
- and thisId=#{commonId}
- </if>
- <if test="messageType !=null">
- and messageType = #{messageType}
- </if>
- and userType=#{userType}
- </where>
- </update>
- <select id="userId" resultType="java.lang.Integer">
- SELECT userID FROM `cm_mall_operation_user` WHERE openid=#{openid} LIMIT 1
- </select>
- <delete id="deleteMessage">
- DELETE FROM message_center WHERE id = #{id}
- </delete>
- <update id="updateRead">
- UPDATE message_center SET saved = 1
- where userType=#{userType} and id=#{Id}
- </update>
- <select id="receiptShopID" resultType="java.lang.Integer">
- SELECT DISTINCT
- a.shopID
- FROM cm_discern_receipt a
- LEFT JOIN shop s ON s.shopID = a.shopID
- WHERE
- a.newReceiptType=1
- </select>
- <select id="shopName" resultType="java.lang.String">
- SELECT name FROM `shop` WHERE shopID=#{shopID}
- </select>
- <select id="getMessageCenterListDay" resultType="java.lang.Integer">
- select distinct d.shopID as shopID from cm_receipt as r
- LEFT JOIN cm_discern_receipt as d on r.receiptID=d.id
- LEFT JOIN shop as s on d.shopID=s.shopID
- WHERE receStatct=0 and DATEDIFF(r.dateStrings,NOW())=#{day}
- </select>
- <update id="updateMessageCenter" parameterType="com.caimei365.user.model.vo.MessageCenter">
- update message_center
- <set>
- <!-- <if test="id != null and id != 0">id = #{id},</if>-->
- <!-- <if test="shopID != null and shopID != ''">shopID = #{shopID},</if>-->
- <!-- <if test="clubID != null and clubID != ''">clubID = #{clubID},</if>-->
- <if test="orderId != null and orderId != '' ">orderID = #{orderId},</if>
- <if test="userType != null and userType != ''">userType = #{userType},</if>
- <if test="messageType != null and messageType != ''">messageType = #{messageType},</if>
- <if test="accountType != null and accountType != ''">accountType = #{accountType},</if>
- <if test="orderMessageType != null and orderMessageType != ''">orderMessageType = #{orderMessageType},</if>
- <if test="couponMessageType != null and couponMessageType != ''">couponMessageType = #{couponMessageType},</if>
- <if test="couponFee != null and couponFee != ''">couponFee = #{couponFee},</if>
- <if test="content != null and content != ''">content = #{content},</if>
- <if test="time != null and time != ''">`time` = #{time},</if>
- <if test="saved != null and saved != ''">saved = #{saved},</if>
- <if test="shopMessType != null and shopMessType != ''">shopMessType = #{shopMessType},</if>
- <if test="shopTieredType != null and sex != ''">shopTieredType = #{shopTieredType},</if>
- <if test="shopTieredType != null and shopTieredType != ''">couponType = #{couponType},</if>
- <if test="productId != null and productId != ''">productID = #{productId},</if>
- </set>
- <where>
- <if test="userType == 1">
- and shopID=#{shopId}
- </if>
- <if test="userType == 2">
- and clubID=#{clubId}
- </if>
- </where>
- </update>
- <insert id="insertMessageCenter" parameterType="com.caimei365.user.model.vo.MessageCenter">
- insert into message_center
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="shopId != null and shopId != ''">shopID,</if>
- <if test="clubId != null and clubId != ''">clubID,</if>
- <if test="orderId != null and orderId != '' ">orderID,</if>
- <if test="userType != null and userType != ''">userType ,</if>
- <if test="messageType != null and messageType != ''">messageType,</if>
- <if test="accountType != null and accountType != ''">accountType,</if>
- <if test="orderMessageType != null and orderMessageType != ''">orderMessageType,</if>
- <if test="couponMessageType != null and couponMessageType != ''">couponMessageTyp,</if>
- <if test="couponFee != null and couponFee != ''">couponFee,</if>
- <if test="content != null and content != ''">content,</if>
- <if test="time != null and time != ''">`time`,</if>
- <if test="saved != null and saved != ''">saved ,</if>
- <if test="shopMessType != null and shopMessType != ''">shopMessType,</if>
- <if test="shopTieredType != null and shopTieredType != ''">shopTieredType,</if>
- <if test="shopTieredType != null and shopTieredType != ''">couponType,</if>
- <if test="productId != null and productId != ''">productID,</if>
- </trim >
- values
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="shopId != null and shopId != ''"> #{shopId},</if>
- <if test="clubId != null and clubId != ''"> #{clubId},</if>
- <if test="orderId != null and orderId != '' "> #{orderId},</if>
- <if test="userType != null and userType != ''"> #{userType},</if>
- <if test="messageType != null and messageType != ''"> #{messageType},</if>
- <if test="accountType != null and accountType != ''"> #{accountType},</if>
- <if test="orderMessageType != null and orderMessageType != ''"> #{orderMessageType},</if>
- <if test="couponMessageType != null and couponMessageType != ''"> #{couponMessageType},</if>
- <if test="couponFee != null and couponFee != ''"> #{couponFee},</if>
- <if test="content != null and content != ''"> #{content},</if>
- <if test="time != null and time != ''"> #{time},</if>
- <if test="saved != null and saved != ''"> #{saved},</if>
- <if test="shopMessType != null and shopMessType != ''"> #{shopMessType},</if>
- <if test="shopTieredType != null and sex != ''"> #{shopTieredType},</if>
- <if test="shopTieredType != null and shopTieredType != ''"> #{couponType},</if>
- <if test="productId != null and productId != ''"> #{productId},</if>
- </trim>
- </insert>
- </mapper>
|