mitao
2024-06-06 3d2b51ea4520533de5e78f88dddf5b5c7dce4247
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
<?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.sinata.rest.modular.mall.dao.MallGoodsCartMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.sinata.rest.modular.mall.model.MallGoodsCart">
        <id column="id" property="id"/>
        <result column="create_time" property="createTime"/>
        <result column="merchant_id" property="merchantId"/>
        <result column="user_id" property="userId"/>
        <result column="goods_id" property="goodsId"/>
        <result column="goods_sku_id" property="goodsSkuId"/>
        <result column="number" property="number"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>
 
    <select id="getGoodsCarByUserIdList" resultType="com.sinata.rest.modular.mall.controller.vo.VoGoodsCart">
        SELECT sku.id      sku_id,
               sku.price,
               sku.price_sale,
               sku.price_member,
               sku.price_merchant,
               sku.grep_name,
               goods.id    goods_id,
               goods.goods_name,
               goods.goods_image,
               goods.state goods_state,
               goods.tag_ids,
               cart.id     cart_id,
               cart.number,
               mer.merchant_name
        FROM mall_goods_cart cart
                 LEFT JOIN mall_goods goods ON goods.id = cart.goods_id
                 LEFT JOIN mall_goods_sku sku ON sku.id = cart.goods_sku_id
                 LEFT JOIN mem_merchant mer ON mer.id = cart.merchant_id
        WHERE cart.user_id = #{userId}
    </select>
 
    <select id="getGoodsCarNum" parameterType="java.lang.Integer" resultType="java.lang.Integer">
        SELECT COUNT(goods_id)
        FROM (SELECT goods_id
              FROM mall_goods_cart
              WHERE user_id = #{userId}
              GROUP BY goods_id) car
    </select>
 
</mapper>