mitao
2025-03-14 392b42c4891cf2e6beda57ab32c51598f290f4b7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?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.ruoyi.promotion.mapper.PromotionWishMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.promotion.domain.PromotionWish">
        <id column="id" property="id" />
        <result column="member_id" property="memberId" />
        <result column="phone" property="phone" />
        <result column="recommend_status" property="recommendStatus" />
        <result column="remark" property="remark" />
        <result column="create_by" property="createBy" />
        <result column="create_time" property="createTime" />
        <result column="update_by" property="updateBy" />
        <result column="update_time" property="updateTime" />
        <result column="del_flag" property="delFlag" />
    </resultMap>
 
    <resultMap id="WishResultMap" type="com.ruoyi.promotion.controller.forepart.vo.ForepartPromotionWishVO">
        <id column="id" property="id" />
        <result column="member_id" property="memberId" />
        <result column="phone" property="phone" />
        <result column="recommend_status" property="recommendStatus" />
        <result column="goodsName" property="goodsName" />
        <result column="create_time" property="createTime" />
        <collection property="recommendList" javaType="java.util.List" resultMap="RecommendResultMap"/>
    </resultMap>
 
    <resultMap id="RecommendResultMap" type="com.ruoyi.promotion.controller.forepart.vo.ForepartPromotionWishRecommendVO">
        <id column="recommendId" property="id" />
        <result column="recommendGoodsName" property="goodsName" />
        <result column="selling_price" property="sellingPrice" />
        <result column="available_num" property="availableNum" />
        <result column="goods_image_url" property="goodsImageUrl" />
        <result column="expire_time" property="expireTime" />
    </resultMap>
 
    <select id="getBulletList"
      resultType="com.ruoyi.promotion.controller.forepart.vo.ForepartPromotionWishBulletVO">
        SELECT tpw.member_id, tpw.create_time, tpwl.expected_year, tpwl.goods_name
        FROM t_promotion_wish tpw
                 INNER JOIN t_promotion_wish_list tpwl ON tpw.id = tpwl.wish_id
        <where>
          tpw.del_flag = 0 AND tpw.recommend_status = 1 and tpw.show_flag = 1
        </where>
            GROUP BY  tpwl.wish_id,tpw.member_id
    </select>
    <select id="getRecommendList"
      resultType="com.ruoyi.promotion.controller.forepart.vo.ForepartPromotionWishRecommendVO"
      parameterType="java.lang.Long">
        SELECT
        r.id, r.goods_name, r.selling_price, r.available_num, r.goods_image_url,r.expire_time
        FROM
        t_promotion_wish w
       LEFT JOIN
        t_promotion_wish_recommend r ON w.id  = r.wish_id
        <where>
            w.del_flag = 0
            AND w.member_id = #{memberId}
            AND w.recommend_status = 1
            AND r.purchase_status = 0
            AND r.expire_time &gt; NOW();
        </where>
    </select>
    <select id="selectNotRecommend" resultType="com.ruoyi.promotion.domain.PromotionWish"
      parameterType="java.lang.Long">
        SELECT
            *
        FROM
        t_promotion_wish
        <where>
            del_flag = 0
            AND member_id = #{memberId}
            AND recommend_status = 0
            AND (last_prompt_date IS NULL OR last_prompt_date &lt; CURDATE());
        </where>
    </select>
    <select id="getWishHistory" resultMap="WishResultMap">
        SELECT tpw.id,
               tpw.member_id,
               tpw.phone,
               tpw.recommend_status,
               tpw.create_time,
               GROUP_CONCAT(tpwl.goods_name) AS goodsName,
               tpwr.id AS recommendId,
               tpwr.goods_name AS recommendGoodsName,
               tpwr.selling_price,
               tpwr.available_num,
               tpwr.goods_image_url,
               tpwr.expire_time
        FROM t_promotion_wish tpw
                 LEFT JOIN t_promotion_wish_list tpwl ON tpw.id = tpwl.wish_id
                 LEFT JOIN t_promotion_wish_recommend tpwr ON tpwr.wish_id = tpw.id
        <where>
          tpw.del_flag = 0 AND tpw.show_flag = 1 AND tpw.member_id = #{memberId}
        </where>
        GROUP BY tpw.id
    </select>
  <select id="getRecommendNum" resultType="java.lang.Integer"
    parameterType="java.lang.Long">
    SELECT COALESCE(SUM(tpwr.available_num), 0)
    FROM t_promotion_wish tpw
           LEFT JOIN t_promotion_wish_recommend tpwr ON tpwr.wish_id = tpw.id
    <where>
      tpw.del_flag = 0
      AND tpwr.expire_time &gt;= NOW()
      AND tpw.member_id = #{memberId}
    </where>
  </select>
  <select id="getCompletedWishCount" resultType="java.lang.Long">
    SELECT COUNT(id)
    FROM t_promotion_wish
  </select>
 
</mapper>