| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?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.fs.his.mapper.FsIntegralCartMapper">
- <insert id="insertOrUpdate">
- insert into fs_integral_cart (
- user_id,
- goods_id,
- integral,
- cash,
- cart_num,
- create_time,
- update_time
- ) values (
- #{userId},
- #{goodsId},
- #{integral},
- #{cash},
- #{cartNum},
- #{createTime},
- #{updateTime}
- )
- on duplicate key update
- integral = values(integral),
- cash = values(cash),
- update_time = values(update_time),
- cart_num =
- <choose>
- <when test="addToExist == true">
- cart_num + values(cart_num)
- </when>
- <otherwise>
- values(cart_num)
- </otherwise>
- </choose>
- </insert>
- <select id="getCartCountByMap" resultType="java.lang.Integer">
- select
- ifnull(sum(ic.cart_num), 0)
- from fs_integral_cart ic
- inner join fs_integral_goods ig on ig.goods_id = ic.goods_id
- <where>
- <if test="params.userId != null">
- ic.user_id = #{params.userId}
- </if>
- <if test="params.goodsId != null">
- and ic.goods_id = #{params.goodsId}
- </if>
- </where>
- </select>
- <select id="getCartsByMap" resultType="com.fs.his.vo.FsIntegralCartVO">
- select
- ic.id,
- ic.goods_id,
- ig.goods_name,
- ig.img_url,
- ic.integral,
- ic.cash,
- ig.integral newIntegral,
- ig.cash newCash,
- ig.stock,
- ic.cart_num,
- ic.create_time,
- ic.update_time
- from fs_integral_cart ic
- inner join fs_integral_goods ig on ig.goods_id = ic.goods_id
- <where>
- <if test="params.userId != null">
- ic.user_id = #{params.userId}
- </if>
- <if test="params.ids != null and params.ids.size() > 0">
- and ic.id in
- <foreach collection="params.ids" item="id" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </if>
- </where>
- </select>
- <delete id="deleteCartByGoodsId">
- delete from fs_integral_cart where goods_id = #{goodsId}
- </delete>
- </mapper>
|