123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- <?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.caimei.mapper.ShoppingCartMapper">
- <select id="findCartProduct" resultType="com.caimei.model.po.CmCartPo">
- SELECT cm_cartID AS cartId,
- productID,
- skuId,
- userID,
- productCount,
- addTime,
- reBuyFlag,
- heUserId
- FROM cm_cart
- WHERE userID = #{userId}
- AND skuId = #{skuId}
- AND heUserId = #{heUserId}
- </select>
- <insert id="insertCart">
- INSERT INTO cm_cart (productID, userID, skuId, productCount, ADDTIME,
- reBuyFlag, heUserId)
- VALUES ((select productId from cm_hehe_sku where skuId = #{skuId}), #{userId}, #{skuId}, #{productCount}, NOW(),
- 0, #{heUserId})
- </insert>
- <update id="updateByProductCount">
- UPDATE
- cm_cart
- SET productCount = #{productCount}
- WHERE cm_cartID = #{cartId}
- </update>
- <update id="updateCart">
- update cm_cart
- set skuId=#{newSkuId},
- productCount=#{count}
- where cm_cartID = #{cartId}
- </update>
- <select id="getCartQuantity" resultType="integer">
- SELECT COUNT(cc.skuId)
- FROM cm_cart cc
- LEFT JOIN cm_hehe_product chp ON cc.productID = chp.productId
- WHERE cc.userID = #{userId}
- AND chp.validFlag = 1
- </select>
- <select id="findCartShop" resultType="com.caimei.model.vo.ShopVo">
- SELECT s.shopID AS shopId,
- s.name,
- s.logo
- FROM cm_cart cc
- LEFT JOIN cm_hehe_product chp ON cc.productID = chp.productId
- LEFT JOIN product p ON cc.productID = p.productID
- LEFT JOIN shop s ON p.shopID = s.shopID
- WHERE cc.userID = #{userId}
- AND chp.validFlag = 1
- GROUP BY s.shopID
- ORDER BY MAX(cc.addTime) DESC
- </select>
- <select id="getCartProductsByShopId" resultType="com.caimei.model.vo.CartProductVo">
- SELECT cc.skuId,
- cc.cm_cartID AS cartId,
- cc.productID AS productId,
- cc.productCount as num,
- cs.cmPercent,
- cs.organizePercent,
- cs.shopPercent,
- cs.costCheckFlag,
- cc.heUserId,
- chs.price,
- chs.price as normalPrice,
- chp.includedTax,
- chp.invoiceType,
- chp.clubTaxPoint,
- p.name,
- p.shopID AS shopId,
- p.mainImage as productImage,
- cs.unit as productUnit,
- cs.stock as stock
- FROM cm_cart cc
- LEFT JOIN cm_sku cs on cc.skuId = cs.skuId
- LEFT JOIN cm_hehe_product chp ON cc.productID = chp.productId
- LEFT JOIN cm_hehe_sku chs on cc.skuId = chs.skuId
- LEFT JOIN product p ON cc.productID = p.productID
- WHERE cc.userID = #{userId}
- AND chp.validFlag = 1
- AND p.shopID = #{shopId}
- </select>
- <select id="getInvalidProducts" resultType="com.caimei.model.vo.CartProductVo">
- SELECT cc.skuId,
- cc.cm_cartID AS cartId,
- cc.productID AS productId,
- cc.productCount as num,
- chs.price,
- chp.includedTax,
- chp.invoiceType,
- chp.clubTaxPoint,
- p.name,
- p.shopID AS shopId,
- p.mainImage as productImage,
- cs.cmPercent,
- cs.organizePercent,
- cs.shopPercent,
- cs.costCheckFlag,
- cs.unit as productUnit
- FROM cm_cart cc
- LEFT JOIN cm_sku cs on cc.skuId = cs.skuId
- LEFT JOIN cm_hehe_sku chs on cc.skuId = chs.skuId
- LEFT JOIN cm_hehe_product chp ON cc.productID = chp.productId
- LEFT JOIN product p ON cc.productID = p.productID
- WHERE cc.userID = #{userId}
- AND chp.validFlag = 2
- </select>
- <delete id="deleteCart">
- DELETE
- FROM cm_cart
- WHERE cm_cartID = #{cartId}
- </delete>
- </mapper>
|