FsIntegralCartMapper.xml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.his.mapper.FsIntegralCartMapper">
  6. <insert id="insertOrUpdate">
  7. insert into fs_integral_cart (
  8. user_id,
  9. goods_id,
  10. integral,
  11. cash,
  12. cart_num,
  13. create_time,
  14. update_time
  15. ) values (
  16. #{userId},
  17. #{goodsId},
  18. #{integral},
  19. #{cash},
  20. #{cartNum},
  21. #{createTime},
  22. #{updateTime}
  23. )
  24. on duplicate key update
  25. integral = values(integral),
  26. cash = values(cash),
  27. update_time = values(update_time),
  28. cart_num =
  29. <choose>
  30. <when test="addToExist == true">
  31. cart_num + values(cart_num)
  32. </when>
  33. <otherwise>
  34. values(cart_num)
  35. </otherwise>
  36. </choose>
  37. </insert>
  38. <select id="getCartCountByMap" resultType="java.lang.Integer">
  39. select
  40. ifnull(sum(ic.cart_num), 0)
  41. from fs_integral_cart ic
  42. inner join fs_integral_goods ig on ig.goods_id = ic.goods_id
  43. <where>
  44. <if test="params.userId != null">
  45. ic.user_id = #{params.userId}
  46. </if>
  47. <if test="params.goodsId != null">
  48. and ic.goods_id = #{params.goodsId}
  49. </if>
  50. </where>
  51. </select>
  52. <select id="getCartsByMap" resultType="com.fs.his.vo.FsIntegralCartVO">
  53. select
  54. ic.id,
  55. ic.goods_id,
  56. ig.goods_name,
  57. ig.img_url,
  58. ic.integral,
  59. ic.cash,
  60. ig.integral newIntegral,
  61. ig.cash newCash,
  62. ig.stock,
  63. ic.cart_num,
  64. ic.create_time,
  65. ic.update_time
  66. from fs_integral_cart ic
  67. inner join fs_integral_goods ig on ig.goods_id = ic.goods_id
  68. <where>
  69. <if test="params.userId != null">
  70. ic.user_id = #{params.userId}
  71. </if>
  72. <if test="params.ids != null and params.ids.size() > 0">
  73. and ic.id in
  74. <foreach collection="params.ids" item="id" open="(" close=")" separator=",">
  75. #{id}
  76. </foreach>
  77. </if>
  78. </where>
  79. </select>
  80. <delete id="deleteCartByGoodsId">
  81. delete from fs_integral_cart where goods_id = #{goodsId}
  82. </delete>
  83. </mapper>