|
@@ -2,43 +2,40 @@
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="com.caimei365.tools.mapper.MessageCenterMapper">
|
|
|
<insert id="addMessageCenter">
|
|
|
- INSERT INTO message_center (shopID, clubID, userType, messageType, content,time,accountType,couponType,couponFee,couponMessageType,ShopMessType,ShopTieredType)
|
|
|
- VALUES (#{shopId}, #{clubId}, #{userType}, #{messageType}, #{content},#{time},#{accountType},#{couponType},#{couponFee},#{couponMessageType},#{shopMessType},#{shopTieredType})
|
|
|
+ INSERT INTO message_center (shopID, clubID, userType, messageType, content, time, accountType, couponType,
|
|
|
+ couponFee, couponMessageType, ShopMessType, ShopTieredType)
|
|
|
+ VALUES (#{shopId}, #{clubId}, #{userType}, #{messageType}, #{content}, #{time}, #{accountType}, #{couponType},
|
|
|
+ #{couponFee}, #{couponMessageType}, #{shopMessType}, #{shopTieredType})
|
|
|
+ </insert>
|
|
|
+ <insert id="sendInsideMessage">
|
|
|
+ INSERT INTO message_center (shopID, clubID, orderID, userType, messageType, accountType, orderMessageType,
|
|
|
+ couponMessageType, couponFee, content, time, saved, shopMessType,
|
|
|
+ shopTieredType, couponType, productID)
|
|
|
+ VALUES (#{shopId}, #{clubId}, #{orderId}, #{userType}, #{messageType}, #{accountType}, #{orderMessageType},
|
|
|
+ #{couponMessageType}, #{couponFee}, #{content}, now(), 0, #{shopMessType},
|
|
|
+ #{shopTieredType}, #{couponType}, #{productId})
|
|
|
</insert>
|
|
|
|
|
|
<select id="clubIdCule" resultType="java.lang.Integer">
|
|
|
- SELECT clubID FROM `user` WHERE userId=#{userId}
|
|
|
+ SELECT clubID
|
|
|
+ FROM `user`
|
|
|
+ WHERE userId = #{userId}
|
|
|
</select>
|
|
|
|
|
|
<select id="shopID" resultType="java.lang.Integer">
|
|
|
- SELECT shopID FROM `shop` WHERE userId=#{userId}
|
|
|
+ SELECT shopID
|
|
|
+ FROM `shop`
|
|
|
+ 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}
|
|
|
+ and clubID=#{commonId}
|
|
|
</if>
|
|
|
<if test="userType == 2">
|
|
|
- and shopID=#{commonId}
|
|
|
+ and shopID=#{commonId}
|
|
|
</if>
|
|
|
AND messageType=#{messageType}
|
|
|
and userType=#{userType}
|
|
@@ -50,10 +47,10 @@
|
|
|
SELECT COUNT(1) FROM `message_center`
|
|
|
<where>
|
|
|
<if test="userType == 1">
|
|
|
- and clubID=#{commonId}
|
|
|
+ and clubID=#{commonId}
|
|
|
</if>
|
|
|
<if test="userType == 2">
|
|
|
- and shopID=#{commonId}
|
|
|
+ and shopID=#{commonId}
|
|
|
</if>
|
|
|
and userType=#{userType}
|
|
|
AND saved=0
|
|
@@ -62,75 +59,88 @@
|
|
|
|
|
|
|
|
|
<select id="receStatct" resultType="java.lang.Integer">
|
|
|
- SELECT COUNT(*) FROM `cm_discern_receipt` WHERE newReceiptType=1 AND shopID=#{shopID} AND receStatct=2
|
|
|
+ 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 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 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>-->
|
|
|
-<!-- and userType=#{userType}-->
|
|
|
-<!-- </where>-->
|
|
|
-<!-- ORDER BY id DESC-->
|
|
|
-<!-- </select>-->
|
|
|
-
|
|
|
<select id="contractMobile" resultType="java.lang.String">
|
|
|
- SELECT contractMobile FROM club WHERE clubID=#{clubID}
|
|
|
+ SELECT contractMobile
|
|
|
+ FROM club
|
|
|
+ WHERE clubID = #{clubID}
|
|
|
</select>
|
|
|
|
|
|
<select id="contractMobiles" resultType="java.lang.String">
|
|
|
- SELECT contractMobile FROM shop WHERE shopID=#{shopID}
|
|
|
+ SELECT contractMobile
|
|
|
+ FROM shop
|
|
|
+ WHERE shopID = #{shopID}
|
|
|
</select>
|
|
|
|
|
|
<select id="getOpenidListByPermission" resultType="java.lang.String">
|
|
|
- SELECT openid FROM `wechat_user` WHERE unionId= #{unionId}
|
|
|
+ SELECT openid
|
|
|
+ FROM wechat_user
|
|
|
+ WHERE unionId = (
|
|
|
+ SELECT unionID
|
|
|
+ FROM cm_order co
|
|
|
+ LEFT JOIN shop s ON co.userId = s.userId
|
|
|
+ WHERE s.shopId = #{shopId}
|
|
|
+ AND unionID IS NOT NULL
|
|
|
+ ORDER BY orderID DESC
|
|
|
+ LIMIT 1)
|
|
|
</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 unionID
|
|
|
+ FROM `cm_order`
|
|
|
+ WHERE userID = #{userID}
|
|
|
+ AND unionID IS NOT NULL
|
|
|
+ ORDER BY orderID DESC
|
|
|
+ LIMIT 1
|
|
|
</select>
|
|
|
|
|
|
<select id="getVipHistoryCount" resultType="java.lang.Integer">
|
|
|
SELECT count(1)
|
|
|
FROM cm_svip_history
|
|
|
- WHERE userId = #{userId}
|
|
|
+ WHERE userId = #{userId}
|
|
|
</select>
|
|
|
|
|
|
<select id="MainImage" resultType="com.caimei365.tools.model.po.MessageCenterPo">
|
|
|
- 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
|
|
|
+ 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
|
|
|
+ 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}
|
|
|
+ and c.clubID=#{commonId}
|
|
|
</if>
|
|
|
<if test="userType == 2">
|
|
|
- and p.shopID=#{commonId}
|
|
|
+ and p.shopID=#{commonId}
|
|
|
</if>
|
|
|
- and co.orderID=#{orderID}
|
|
|
+ and co.orderID=#{orderID}
|
|
|
</where>
|
|
|
LIMIT 1
|
|
|
</select>
|
|
@@ -144,123 +154,132 @@
|
|
|
<if test="productID != null">
|
|
|
and p.productID=#{productID}
|
|
|
</if>
|
|
|
- and p.shopID=#{shopID}
|
|
|
+ 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 COUNT(productID)
|
|
|
+ FROM cm_order_product
|
|
|
+ WHERE orderID = #{orderID}
|
|
|
</select>
|
|
|
|
|
|
|
|
|
<select id="receiptDate" resultType="java.lang.String">
|
|
|
- SELECT
|
|
|
- c.dateStrings
|
|
|
+ SELECT c.dateStrings
|
|
|
FROM cm_receipt c
|
|
|
- LEFT JOIN cm_discern_receipt a ON c.receiptID = a.id
|
|
|
- LEFT JOIN shop s ON s.shopID = a.shopID
|
|
|
- WHERE
|
|
|
- a.shopID=10324
|
|
|
- AND a.newReceiptType=1
|
|
|
+ LEFT JOIN cm_discern_receipt a ON c.receiptID = a.id
|
|
|
+ LEFT JOIN shop s ON s.shopID = a.shopID
|
|
|
+ WHERE a.shopID = 10324
|
|
|
+ AND a.newReceiptType = 1
|
|
|
ORDER BY a.id DESC
|
|
|
LIMIT 1
|
|
|
</select>
|
|
|
|
|
|
<select id="receiptAmount" resultType="java.lang.Double">
|
|
|
- SELECT
|
|
|
- a.receiptAmount
|
|
|
+ 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
|
|
|
+ LEFT JOIN shop s ON s.shopID = a.shopID
|
|
|
+ where a.shopID = #{shopID}
|
|
|
+ AND a.newReceiptType = 1
|
|
|
LIMIT 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>
|
|
|
+ <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="messageType !=null">
|
|
|
- and messageType = #{messageType}
|
|
|
- </if>
|
|
|
- and userType=#{userType}
|
|
|
+ <if test="userType == 1">
|
|
|
+ and clubID=#{commonId}
|
|
|
+ </if>
|
|
|
+ <if test="userType == 2">
|
|
|
+ and shopID=#{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 userID
|
|
|
+ FROM `cm_mall_operation_user`
|
|
|
+ WHERE openid = #{openid}
|
|
|
+ LIMIT 1
|
|
|
</select>
|
|
|
|
|
|
- <delete id="deleteMessage">
|
|
|
- DELETE FROM message_center WHERE id = #{id}
|
|
|
+ <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 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 DISTINCT shopID
|
|
|
+ FROM cm_discern_receipt
|
|
|
+ WHERE newReceiptType = 1
|
|
|
</select>
|
|
|
|
|
|
<select id="userIds" resultType="java.lang.Integer">
|
|
|
- SELECT DISTINCT
|
|
|
- a.userID
|
|
|
+ SELECT DISTINCT a.userID
|
|
|
FROM shop a
|
|
|
- WHERE
|
|
|
- a.shopOD=#{shopID}
|
|
|
+ WHERE a.shopOD = #{shopID}
|
|
|
</select>
|
|
|
|
|
|
<select id="ClubIds" resultType="java.lang.Integer">
|
|
|
- SELECT clubID FROM `user` WHERE YEAR(loginTime)>YEAR(NOW())-3 AND clubID IS NOT NULL
|
|
|
+ SELECT clubID
|
|
|
+ FROM `user`
|
|
|
+ WHERE YEAR(loginTime) > YEAR(NOW()) - 3
|
|
|
+ AND clubID IS NOT NULL
|
|
|
# ORDER BY clubID DESC
|
|
|
</select>
|
|
|
|
|
|
<select id="couponTime" resultType="com.caimei365.tools.model.po.CmCouponPo">
|
|
|
- SELECT * FROM `cm_coupon` WHERE
|
|
|
- NOW() >= startDate
|
|
|
- AND endDate >= NOW()
|
|
|
- AND STATUS = 1
|
|
|
- AND delFlag=0
|
|
|
+ SELECT *
|
|
|
+ FROM `cm_coupon`
|
|
|
+ WHERE NOW() >= startDate
|
|
|
+ AND endDate >= NOW()
|
|
|
+ AND STATUS = 1
|
|
|
+ AND delFlag = 0
|
|
|
</select>
|
|
|
|
|
|
<select id="clubList" resultType="com.caimei365.tools.model.po.CmUserPo">
|
|
|
- SELECT * FROM `user` WHERE clubId=#{clubId} LIMIT 1
|
|
|
+ SELECT *
|
|
|
+ FROM `user`
|
|
|
+ WHERE clubId = #{clubId}
|
|
|
+ LIMIT 1
|
|
|
</select>
|
|
|
|
|
|
<select id="clubLists" resultType="com.caimei365.tools.model.po.CmUserPo">
|
|
|
- SELECT * FROM `user` WHERE userId=#{userId} LIMIT 1
|
|
|
+ SELECT *
|
|
|
+ FROM `user`
|
|
|
+ WHERE userId = #{userId}
|
|
|
+ LIMIT 1
|
|
|
</select>
|
|
|
|
|
|
<select id="CouponList" resultType="com.caimei365.tools.model.po.CmCouponPo">
|
|
|
- SELECT * FROM cm_coupon WHERE couponType=#{couponType}
|
|
|
- AND NOW() >= startDate
|
|
|
- AND endDate >= NOW()
|
|
|
- AND status=1
|
|
|
- AND delFlag=0
|
|
|
+ SELECT *
|
|
|
+ FROM cm_coupon
|
|
|
+ WHERE couponType = #{couponType}
|
|
|
+ AND NOW() >= startDate
|
|
|
+ AND endDate >= NOW()
|
|
|
+ AND status = 1
|
|
|
+ AND delFlag = 0
|
|
|
ORDER BY id DESC
|
|
|
LIMIT 1
|
|
|
</select>
|
|
@@ -272,13 +291,20 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="CouponLists" resultType="com.caimei365.tools.model.po.CmCouponPo">
|
|
|
- SELECT * FROM cm_coupon a
|
|
|
+ SELECT *
|
|
|
+ FROM cm_coupon a
|
|
|
LEFT JOIN cm_coupon_club s ON s.couponId = a.id
|
|
|
- WHERE s.userId=#{userID}
|
|
|
+ WHERE s.userId = #{userID}
|
|
|
AND NOW() >= a.startDate
|
|
|
AND a.endDate >= NOW()
|
|
|
- AND a.status=1
|
|
|
- AND a.delFlag=0
|
|
|
+ AND a.status = 1
|
|
|
+ AND a.delFlag = 0
|
|
|
</select>
|
|
|
|
|
|
+ <select id="findExpireShopId" resultType="com.caimei365.tools.model.po.ShopReceiptVo">
|
|
|
+ SELECT cr.dateStrings,cdr.shopId,cdr.receiptAmount,cr.validityDate
|
|
|
+ FROM cm_receipt cr
|
|
|
+ LEFT JOIN cm_discern_receipt cdr ON cr.receiptId = cdr.id
|
|
|
+ WHERE DATE_FORMAT(cr.dateStrings, '%y-%m-%d') = DATE_FORMAT(DATE_ADD(NOW(), INTERVAL #{day} DAY), '%y-%m-%d')
|
|
|
+ </select>
|
|
|
</mapper>
|