<?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.order.mapper.order.ShoppingCartMapper">
|
|
<resultMap type="ShoppingCart" id="ShoppingCartResult">
|
<result property="id" column="id" />
|
<result property="delFlag" column="del_flag" />
|
<result property="userId" column="user_id" />
|
<result property="shopId" column="shop_id" />
|
<result property="goodsId" column="goods_id" />
|
<result property="buyNum" column="buy_num" />
|
<result property="createTime" column="create_time" />
|
<result property="updateTime" column="update_time" />
|
</resultMap>
|
|
<sql id="selectShoppingCartVo">
|
select id, del_flag, user_id, shop_id, goods_id, buy_num, create_time, update_time from t_shopping_cart
|
</sql>
|
|
<select id="selectShoppingCartList" parameterType="ShoppingCart" resultMap="ShoppingCartResult">
|
<include refid="selectShoppingCartVo"/>
|
<where>
|
<if test="userId != null "> and user_id = #{userId}</if>
|
<if test="shopId != null "> and shop_id = #{shopId}</if>
|
<if test="goodsId != null and goodsId != ''"> and goods_id = #{goodsId}</if>
|
<if test="buyNum != null "> and buy_num = #{buyNum}</if>
|
</where>
|
</select>
|
|
<select id="selectShoppingCartById" parameterType="Long" resultMap="ShoppingCartResult">
|
<include refid="selectShoppingCartVo"/>
|
where id = #{id}
|
</select>
|
|
<insert id="insertShoppingCart" parameterType="ShoppingCart" useGeneratedKeys="true" keyProperty="id">
|
insert into t_shopping_cart
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="delFlag != null">del_flag,</if>
|
<if test="userId != null">user_id,</if>
|
<if test="shopId != null">shop_id,</if>
|
<if test="goodsId != null">goods_id,</if>
|
<if test="buyNum != null">buy_num,</if>
|
<if test="createTime != null">create_time,</if>
|
<if test="updateTime != null">update_time,</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="delFlag != null">#{delFlag},</if>
|
<if test="userId != null">#{userId},</if>
|
<if test="shopId != null">#{shopId},</if>
|
<if test="goodsId != null">#{goodsId},</if>
|
<if test="buyNum != null">#{buyNum},</if>
|
<if test="createTime != null">#{createTime},</if>
|
<if test="updateTime != null">#{updateTime},</if>
|
</trim>
|
</insert>
|
|
<update id="updateShoppingCart" parameterType="ShoppingCart">
|
update t_shopping_cart
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
<if test="userId != null">user_id = #{userId},</if>
|
<if test="shopId != null">shop_id = #{shopId},</if>
|
<if test="goodsId != null">goods_id = #{goodsId},</if>
|
<if test="buyNum != null">buy_num = #{buyNum},</if>
|
<if test="createTime != null">create_time = #{createTime},</if>
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
</trim>
|
where id = #{id}
|
</update>
|
|
<delete id="deleteShoppingCartById" parameterType="Long">
|
update t_shopping_cart set del_flag = 1 where id = #{id}
|
</delete>
|
|
<delete id="deleteShoppingCartByIds" parameterType="String">
|
update t_shopping_cart set del_flag = 1 where id in
|
<foreach item="ids" collection="array" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</delete>
|
|
<select id="listShoppingCartVo" resultType="com.ruoyi.order.domain.vo.AppShoppingCartVo">
|
SELECT
|
tsc.id shoppingCartId,
|
tg.goods_id goodsId,
|
tg.goods_name goodsName,
|
tg.goods_introduction goodsIntroduction,
|
tg.goods_type goodsType,
|
CASE tg.goods_type
|
WHEN 1 THEN "周期"
|
WHEN 2 THEN "服务"
|
WHEN 3 THEN "体验"
|
WHEN 4 THEN "单品"
|
END goodsTag,
|
IFNULL(tsg.sales_price,tg.sales_price) salesPrice,
|
tgf.file_url goodsPicture,
|
tg.goods_nurses goodsNurses,
|
buy_num buyNum
|
FROM t_shopping_cart tsc
|
INNER JOIN t_goods tg ON tsc.goods_id = tg.goods_id
|
LEFT JOIN t_goods_file tgf ON tg.goods_id = tgf.goods_id AND tgf.del_flag = 0 AND tgf.file_type = 1
|
LEFT JOIN t_shop_goods tsg ON tg.goods_id = tsg.goods_id AND tsg.shop_id = #{shopId}
|
WHERE tg.del_flag = 0 AND tsc.shop_id = #{shopId} AND tsc.user_id = #{userId} AND tg.del_flag = 0 AND tg.goods_status = 1 AND tg.recommend_flag = 1
|
ORDER BY tg.create_time DESC
|
</select>
|
</mapper>
|