ShoppingCartMapper.xml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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.caimei.mapper.ShoppingCartMapper">
  6. <select id="findCartProduct" resultType="com.caimei.model.po.CmCartPo">
  7. SELECT cm_cartID AS cartId,
  8. productID,
  9. skuId,
  10. userID,
  11. productCount,
  12. addTime,
  13. reBuyFlag,
  14. heUserId
  15. FROM cm_cart
  16. WHERE userID = #{userId}
  17. AND skuId = #{skuId}
  18. AND heUserId = #{heUserId}
  19. </select>
  20. <insert id="insertCart">
  21. INSERT INTO cm_cart (productID, userID, skuId, productCount, ADDTIME,
  22. reBuyFlag, heUserId)
  23. VALUES ((select productId from cm_hehe_sku where skuId = #{skuId}), #{userId}, #{skuId}, #{productCount}, NOW(),
  24. 0, #{heUserId})
  25. </insert>
  26. <update id="updateByProductCount">
  27. UPDATE
  28. cm_cart
  29. SET productCount = #{productCount}
  30. WHERE cm_cartID = #{cartId}
  31. </update>
  32. <update id="updateCart">
  33. update cm_cart
  34. set skuId=#{newSkuId},
  35. productCount=#{count}
  36. where cm_cartID = #{cartId}
  37. </update>
  38. <select id="getCartQuantity" resultType="integer">
  39. SELECT COUNT(cc.skuId)
  40. FROM cm_cart cc
  41. LEFT JOIN cm_hehe_product chp ON cc.productID = chp.productId
  42. WHERE cc.userID = #{userId}
  43. AND chp.validFlag = 1
  44. </select>
  45. <select id="findCartShop" resultType="com.caimei.model.vo.ShopVo">
  46. SELECT s.shopID AS shopId,
  47. s.name,
  48. s.logo
  49. FROM cm_cart cc
  50. LEFT JOIN cm_hehe_product chp ON cc.productID = chp.productId
  51. LEFT JOIN product p ON cc.productID = p.productID
  52. LEFT JOIN shop s ON p.shopID = s.shopID
  53. WHERE cc.userID = #{userId}
  54. AND chp.validFlag = 1
  55. GROUP BY s.shopID
  56. ORDER BY MAX(cc.addTime) DESC
  57. </select>
  58. <select id="getCartProductsByShopId" resultType="com.caimei.model.vo.CartProductVo">
  59. SELECT cc.skuId,
  60. cc.cm_cartID AS cartId,
  61. cc.productID AS productId,
  62. cc.productCount as num,
  63. cc.heUserId,
  64. chs.price,
  65. chs.price as normalPrice,
  66. chp.includedTax,
  67. chp.invoiceType,
  68. chp.clubTaxPoint,
  69. p.name,
  70. p.shopID AS shopId,
  71. p.mainImage as productImage,
  72. cs.unit as productUnit,
  73. cs.stock as stock
  74. FROM cm_cart cc
  75. LEFT JOIN cm_sku cs on cc.skuId = cs.skuId
  76. LEFT JOIN cm_hehe_product chp ON cc.productID = chp.productId
  77. LEFT JOIN cm_hehe_sku chs on cc.skuId = chs.skuId
  78. LEFT JOIN product p ON cc.productID = p.productID
  79. WHERE cc.userID = #{userId}
  80. AND chp.validFlag = 1
  81. AND p.shopID = #{shopId}
  82. </select>
  83. <select id="getInvalidProducts" resultType="com.caimei.model.vo.CartProductVo">
  84. SELECT cc.skuId,
  85. cc.cm_cartID AS cartId,
  86. cc.productID AS productId,
  87. cc.productCount as num,
  88. chs.price,
  89. chp.includedTax,
  90. chp.invoiceType,
  91. chp.clubTaxPoint,
  92. p.name,
  93. p.shopID AS shopId,
  94. p.mainImage as productImage,
  95. cs.unit as productUnit
  96. FROM cm_cart cc
  97. LEFT JOIN cm_sku cs on cc.skuId = cs.skuId
  98. LEFT JOIN cm_hehe_sku chs on cc.skuId = chs.skuId
  99. LEFT JOIN cm_hehe_product chp ON cc.productID = chp.productId
  100. LEFT JOIN product p ON cc.productID = p.productID
  101. WHERE cc.userID = #{userId}
  102. AND chp.validFlag = 2
  103. </select>
  104. <delete id="deleteCart">
  105. DELETE
  106. FROM cm_cart
  107. WHERE cm_cartID = #{cartId}
  108. </delete>
  109. </mapper>