FsIntegralCartMapper.xml 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. <where>
  43. <if test="params.userId != null">
  44. ic.user_id = #{params.userId}
  45. </if>
  46. <if test="params.goodsId != null">
  47. and ic.goods_id = #{params.goodsId}
  48. </if>
  49. </where>
  50. </select>
  51. <select id="getCartsByMap" resultType="com.fs.his.vo.FsIntegralCartVO">
  52. select
  53. ic.id,
  54. ic.goods_id,
  55. ig.goods_name,
  56. ig.img_url,
  57. ic.integral,
  58. ic.cash,
  59. ig.integral newIntegral,
  60. ig.cash newCash,
  61. ic.cart_num,
  62. ic.create_time,
  63. ic.update_time
  64. from fs_integral_cart ic
  65. inner join fs_integral_goods ig on ig.goods_id = ic.goods_id
  66. <where>
  67. <if test="params.userId != null">
  68. ic.user_id = #{params.userId}
  69. </if>
  70. <if test="params.ids != null and params.ids.size() > 0">
  71. and ic.id in
  72. <foreach collection="params.ids" item="id" open="(" close=")" separator=",">
  73. #{id}
  74. </foreach>
  75. </if>
  76. </where>
  77. </select>
  78. </mapper>