ShoppingCartMapper.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. cs.cmPercent,
  64. cs.organizePercent,
  65. cs.shopPercent,
  66. cs.costCheckFlag,
  67. cc.heUserId,
  68. chs.price,
  69. chs.price as normalPrice,
  70. chp.includedTax,
  71. chp.invoiceType,
  72. chp.clubTaxPoint,
  73. p.name,
  74. p.shopID AS shopId,
  75. p.mainImage as productImage,
  76. cs.unit as productUnit,
  77. cs.stock as stock
  78. FROM cm_cart cc
  79. LEFT JOIN cm_sku cs on cc.skuId = cs.skuId
  80. LEFT JOIN cm_hehe_product chp ON cc.productID = chp.productId
  81. LEFT JOIN cm_hehe_sku chs on cc.skuId = chs.skuId
  82. LEFT JOIN product p ON cc.productID = p.productID
  83. WHERE cc.userID = #{userId}
  84. AND chp.validFlag = 1
  85. AND p.shopID = #{shopId}
  86. </select>
  87. <select id="getInvalidProducts" resultType="com.caimei.model.vo.CartProductVo">
  88. SELECT cc.skuId,
  89. cc.cm_cartID AS cartId,
  90. cc.productID AS productId,
  91. cc.productCount as num,
  92. chs.price,
  93. chp.includedTax,
  94. chp.invoiceType,
  95. chp.clubTaxPoint,
  96. p.name,
  97. p.shopID AS shopId,
  98. p.mainImage as productImage,
  99. cs.cmPercent,
  100. cs.organizePercent,
  101. cs.shopPercent,
  102. cs.costCheckFlag,
  103. cs.unit as productUnit
  104. FROM cm_cart cc
  105. LEFT JOIN cm_sku cs on cc.skuId = cs.skuId
  106. LEFT JOIN cm_hehe_sku chs on cc.skuId = chs.skuId
  107. LEFT JOIN cm_hehe_product chp ON cc.productID = chp.productId
  108. LEFT JOIN product p ON cc.productID = p.productID
  109. WHERE cc.userID = #{userId}
  110. AND chp.validFlag = 2
  111. </select>
  112. <delete id="deleteCart">
  113. DELETE
  114. FROM cm_cart
  115. WHERE cm_cartID = #{cartId}
  116. </delete>
  117. </mapper>