123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- <?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.modules.hehe.dao.CmHeheCollageProductDao">
- <sql id="cmHeheCollageProductColumns">
- a.id AS "id",
- a.productId AS "productId",
- a.limitedNum AS "limitedNum",
- a.unlimitedFlag AS "unlimitedFlag",
- a.memberNum AS "memberNum",
- a.status AS "status",
- a.addTime AS "addTime",
- s.name AS shopName,
- p.name AS productName,
- p.mainImage AS productImage
- </sql>
- <sql id="cmHeheCollageProductJoins">
- left join product p on a.productId = p.productID
- left join cm_hehe_product chp on p.productID = chp.productId
- left join shop s on p.shopID = s.shopID
- </sql>
- <select id="get" resultType="CmHeheCollageProduct">
- SELECT
- <include refid="cmHeheCollageProductColumns"/>
- FROM cm_hehe_collage_product a
- <include refid="cmHeheCollageProductJoins"/>
- WHERE a.id = #{id}
- </select>
- <select id="findList" resultType="CmHeheCollageProduct">
- SELECT
- <include refid="cmHeheCollageProductColumns"/>
- FROM cm_hehe_collage_product a
- <include refid="cmHeheCollageProductJoins"/>
- <where>
- chp.id is not null
- <if test="id != null and id != ''">
- AND a.id = #{id}
- </if>
- <if test="status != null">
- AND a.status = #{status}
- </if>
- <if test="productName != null and productName != ''">
- and p.name like concat('%',#{productName},'%')
- </if>
- <if test="shopName != null and shopName != ''">
- and s.name like concat('%',#{shopName},'%')
- </if>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- order by a.addTime desc
- </otherwise>
- </choose>
- </select>
- <select id="findAllList" resultType="CmHeheCollageProduct">
- SELECT
- <include refid="cmHeheCollageProductColumns"/>
- FROM cm_hehe_collage_product a
- <include refid="cmHeheCollageProductJoins"/>
- <where>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
- <select id="findReductionProductIds" resultType="java.lang.Integer">
- select chp.id
- from cm_hehe_reduction chap
- left join cm_hehe_product chp on chap.productId = chp.productId;
- </select>
- <select id="getProductId" resultType="java.lang.Integer">
- select productId
- from cm_hehe_product
- where id = #{heheProductId}
- </select>
- <select id="findCollageSku" resultType="com.caimei.modules.product.entity.CmSku">
- select chs.price as 'price', chcs.collagePrice , chs.skuId
- from cm_hehe_sku chs
- left join cm_hehe_collage_sku chcs on chs.skuId = chcs.skuId
- left join cm_hehe_product chp on chs.productId = chp.productId
- where chs.productId = #{productId}
- </select>
- <select id="findCollageByHeHeId" resultType="com.caimei.modules.product.entity.CmSku">
- select chs.price as 'price', chcs.collagePrice as 'price', chs.skuId
- from cm_hehe_sku chs
- left join cm_hehe_collage_sku chcs on chs.skuId = chcs.skuId
- left join cm_hehe_product chp on chs.productId = chp.productId
- where chp.id = #{productId}
- </select>
- <select id="getSkuCollage" resultType="com.caimei.modules.product.entity.CmSku">
- select skuId, productId, collagePrice
- from cm_hehe_collage_sku
- where skuId = #{skuId}
- </select>
- <select id="getCollagePrice" resultType="java.lang.Double">
- select collagePrice
- from cm_hehe_collage_sku
- where productId = #{productId}
- order by collagePrice asc
- limit 1
- </select>
- <insert id="insert" parameterType="CmHeheCollageProduct" keyProperty="id" useGeneratedKeys="true">
- INSERT INTO cm_hehe_collage_product(productId,
- limitedNum,
- unlimitedFlag,
- memberNum,
- status,
- addTime)
- VALUES ((select productId from cm_hehe_product where id = #{productId}),
- #{limitedNum},
- #{unlimitedFlag},
- #{memberNum},
- #{status},
- NOW())
- </insert>
- <insert id="insertSkuCollage">
- insert into cm_hehe_collage_sku(skuId, productid, collageprice)
- values (#{skuId}, (select productId from cm_sku where skuId = #{skuId}), #{collagePrice})
- </insert>
- <update id="update">
- UPDATE cm_hehe_collage_product
- SET productId = #{productId},
- limitedNum = #{limitedNum},
- unlimitedFlag = #{unlimitedFlag},
- memberNum = #{memberNum},
- status = #{status}
- WHERE id = #{id}
- </update>
- <update id="updateStatus">
- update cm_hehe_collage_product
- set status = #{status}
- where id = #{id}
- </update>
- <update id="updateProductId">
- update cm_hehe_collage_product
- set productId = #{newProductId}
- where productId = #{oldProductId}
- </update>
- <update id="updateSkuCollage">
- update cm_hehe_collage_sku
- set collagePrice=#{collagePrice}
- where skuId = #{skuId}
- </update>
- <delete id="delete">
- DELETE
- FROM cm_hehe_collage_product
- WHERE id = #{id}
- </delete>
- </mapper>
|