购物车列表查询条件疑问

来源:7-5 购物车列表

查杀1号

2023-02-11 10:39:26

<select id="selectList" resultType="com.imooc.mall.model.vo.CartVO"
    parameterType="java.lang.Integer">
    select
    c.id as id,
    p.id as productId,
    c.user_id as userId,
    c.quantity as quantity,
    c.selected as selected,
    p.price as price,
    p.name as productName,
    p.image as productImage
    from imooc_mall_cart c
    left join imooc_mall_product p on p.id = c.product_id
    where c.user_id = #{userId}
    and p.status = 1
  </select>

这边查询条件是限制status为上架的状态,是不是有一种可能是用户加入购物车的时候这个商品是上架的状态,但之后这个商品被管理员更改为下架的状态了,此时这个商品实际上仍在用户购物车里,如果条件设置为只查询上架状态,会不会导致数据不正确?

写回答

1回答

好帮手慕小脸

2023-02-11

同学你好,在实际工作中,这里的逻辑就跟淘宝这种类似,当加入购物车的商品处于下架状态时,会显示该商品失效,也就说之后商品即使上架了,也需要进入到对应界面进行重新加入购物车,课程里只是演示下架这一流程,并不追踪到非常具体的细节

祝学习愉快~

0

0 学习 · 9886 问题

查看课程