123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367 |
- <?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.CmHeheProductDao">
- <sql id="cmHeheProductColumns">
- a.id AS "id",
- a.productId AS "productId",
- ifnull(a.bigTypeId,0) AS "bigTypeId",
- ifnull(a.smallTypeId,0) AS "smallTypeId",
- a.validFlag AS "validFlag",
- a.includedTax AS "includedTax",
- a.invoiceType AS "invoiceType",
- a.clubTaxPoint AS "clubTaxPoint",
- a.shopTaxPoint AS "shopTaxPoint",
- a.oldProductId,
- a.addTime AS "addTime",
- p.name AS "name",
- p.mainImage AS "mainImage",
- s.name AS "shopName",
- chap.activityId,
- group_concat(chfp.floorId) as floorIds
- </sql>
- <sql id="cmHeheProductJoins">
- LEFT JOIN product p ON a.productId = p.productID
- LEFT JOIN shop s ON s.shopID = p.shopID
- left join cm_hehe_activity_product chap on a.productId = chap.productId
- left join cm_hehe_floor_product chfp on a.productId = chfp.productId
- </sql>
- <select id="get" resultType="CmHeheProduct">
- SELECT
- <include refid="cmHeheProductColumns"/>
- FROM cm_hehe_product a
- <include refid="cmHeheProductJoins"/>
- WHERE a.id = #{id}
- group by a.id
- </select>
- <select id="findList" resultType="CmHeheProduct">
- SELECT
- <include refid="cmHeheProductColumns"/>
- FROM cm_hehe_product a
- <include refid="cmHeheProductJoins"/>
- <where>
- <if test="productId != null and productId != ''">
- AND a.productId = #{productId}
- </if>
- <if test="validFlag != null and validFlag != ''">
- AND a.validFlag = #{validFlag}
- </if>
- <if test="includedTax != null and includedTax != ''">
- AND a.includedTax = #{includedTax}
- </if>
- <if test="invoiceType != null and invoiceType != ''">
- AND a.invoiceType = #{invoiceType}
- </if>
- <if test="id != null and id != ''">
- AND a.id = #{id}
- </if>
- <if test="name != null and name != ''">
- AND p.name LIKE CONCAT('%',#{name},'%')
- </if>
- <if test="shopName != null and shopName != ''">
- AND s.name LIKE CONCAT('%',#{shopName},'%')
- </if>
- </where>
- group by a.id
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- ORDER BY addTime DESC
- </otherwise>
- </choose>
- </select>
- <select id="findAllList" resultType="CmHeheProduct">
- SELECT
- <include refid="cmHeheProductColumns"/>
- FROM cm_hehe_product a
- <include refid="cmHeheProductJoins"/>
- <where>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
- <insert id="insert" parameterType="CmHeheProduct" keyProperty="id" useGeneratedKeys="true">
- INSERT INTO cm_hehe_product(productId,
- bigTypeId,
- smallTypeId,
- validFlag,
- includedTax,
- invoiceType,
- clubTaxPoint,
- shopTaxPoint,
- addTime)
- VALUES (#{productId},
- #{bigTypeId},
- #{smallTypeId},
- #{validFlag},
- #{includedTax},
- #{invoiceType},
- #{clubTaxPoint},
- #{shopTaxPoint},
- NOW())
- </insert>
- <insert id="addActivityProduct">
- insert into cm_hehe_activity_product (activityId, productId, addTime, delFlag)
- values (#{activityId}, #{productId}, NOW(), 0)
- </insert>
- <insert id="addFloorProduct">
- insert into cm_hehe_floor_product(floorId, productId, validFlag, recommend, sort, addTime)
- VALUES (#{floorId}, #{productId}, 1, 0, 1, NOW())
- </insert>
- <insert id="insertHeHeSkuPrice">
- insert into cm_hehe_sku(skuid, productid, price)
- values (#{skuId}, #{productId}, #{price})
- </insert>
- <update id="update">
- UPDATE cm_hehe_product
- SET productId = #{productId},
- bigTypeId = #{bigTypeId},
- smallTypeId = #{smallTypeId},
- validFlag = #{validFlag},
- includedTax = #{includedTax},
- invoiceType = #{invoiceType},
- clubTaxPoint = #{clubTaxPoint},
- shopTaxPoint = #{shopTaxPoint}
- WHERE id = #{id}
- </update>
- <delete id="delete">
- DELETE
- FROM cm_hehe_product
- WHERE id = #{id}
- </delete>
- <select id="findHeHeProductId" resultType="integer">
- SELECT productId
- FROM cm_hehe_product
- </select>
- <select id="findAllProduct" resultType="com.caimei.modules.product.entity.Product">
- SELECT
- a.*,s.name AS "shopName"
- FROM product a
- left join cm_organize_product_info copi on copi.productId = a.productID
- LEFT JOIN shop s on s.shopID = a.shopID
- <where>
- a.splitCode is not null and a.splitCode != '' and copi.validFlag=2
- and s.shopID in(SELECT shopID FROM shop WHERE name ='深圳市采美奥泰贸易有限公司')
- <if test="productID != null">
- AND a.productID = #{productID}
- </if>
- <if test="name != null and name != ''">
- AND a.name LIKE concat('%',#{name},'%')
- </if>
- <if test="shopName != null and shopName != ''">
- AND s.name LIKE concat('%',#{shopName},'%')
- </if>
- <if test="ids != null and ids.size() > 0 ">
- AND a.productID NOT IN
- <foreach collection="ids" open="(" close=")" item="id" separator=",">
- #{id}
- </foreach>
- </if>
- </where>
- group by a.productID
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- order by a.productID
- </otherwise>
- </choose>
- </select>
- <select id="findCouponProduct" resultType="com.caimei.modules.product.entity.Product">
- SELECT
- a.*,s.name AS "shopName"
- FROM cm_hehe_product
- product a
- LEFT JOIN shop s on s.shopID = a.shopID
- <where>
- <if test="productID != null">
- AND a.productID = #{productID}
- </if>
- <if test="name != null and name != ''">
- AND a.name LIKE concat('%',#{name},'%')
- </if>
- <if test="shopName != null and shopName != ''">
- AND s.name LIKE concat('%',#{shopName},'%')
- </if>
- <if test="ids != null and ids.size() > 0 ">
- AND a.productID NOT IN
- <foreach collection="ids" open="(" close=")" item="id" separator=",">
- #{id}
- </foreach>
- </if>
- </where>
- group by a.productID
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- order by a.productID
- </otherwise>
- </choose>
- </select>
- <select id="findProductActivity" resultType="java.lang.Integer">
- select activityId
- from cm_hehe_activity_product
- where productId = #{productId}
- </select>
- <select id="getNewProductId" resultType="java.lang.Integer">
- select productId
- from cm_hehe_product
- where oldProductId = #{oldProductId}
- </select>
- <select id="findHeHeFloorProductIds" resultType="java.lang.Integer">
- select i.productId
- from new_page_floor_image i
- left join cm_page_centre c on i.centreId = c.id
- left join cm_page p on c.pageId = p.id
- where p.type = 8
- </select>
- <select id="findAllHeheProduct" resultType="com.caimei.modules.product.entity.Product">
- SELECT
- a.*,s.name AS "shopName"
- FROM cm_hehe_product chp left join product a on chp.productId = a.productID
- LEFT JOIN shop s on s.shopID = a.shopID
- <where>
- chp.validFlag = 1
- <if test="productID != null">
- AND a.productID = #{productID}
- </if>
- <if test="name != null and name != ''">
- AND a.name LIKE concat('%',#{name},'%')
- </if>
- <if test="shopName != null and shopName != ''">
- AND s.name LIKE concat('%',#{shopName},'%')
- </if>
- <if test="ids != null and ids.size() > 0 ">
- AND a.productID NOT IN
- <foreach collection="ids" open="(" close=")" item="id" separator=",">
- #{id}
- </foreach>
- </if>
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- order by a.productID
- </otherwise>
- </choose>
- </select>
- <select id="findActivityProductIds" resultType="java.lang.Integer">
- SELECT a.productId
- FROM cm_hehe_activity_product a
- LEFT JOIN cm_hehe_activity cha ON a.activityId = cha.id
- WHERE a.delFlag = 0
- AND cha.delFlag = 0
- </select>
- <select id="findCollageProductIds" resultType="java.lang.Integer">
- select productId
- from cm_hehe_collage_product
- </select>
- <select id="findDiscountProductIds" resultType="java.lang.Integer">
- select productId
- from hehe_discount_activity_product hdap
- left join cm_hehe_discount_activity chda on hdap.activityId = chda.id
- where chda.id is not null
- </select>
- <select id="findProductElement" resultType="com.caimei.modules.hehe.entity.CmHeheProduct">
- select ifnull(chs.price, 0) as price,
- ifnull(cs.shopPercent, 0) as shopPercent,
- ifnull(cs.organizePercent, 0) as organizePercent,
- ifnull(cs.cmPercent, 0) as cmPercent,
- ifnull((SELECT costCheckFlag FROM cm_organize_product_info WHERE productId = cs.productId AND organizeId = cs.organizeId ), 0) as costType,
- ifnull(cs.costPrice, 0) as costPrice
- ,cs.organizeId
- from cm_sku cs
- left join cm_hehe_sku chs on cs.skuId = chs.skuId
- where cs.productId = #{productId}
- and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
- order by chs.price asc
- limit 1
- </select>
- <update id="deleteActivityProduct">
- UPDATE cm_hehe_activity_product
- SET delFlag = 1
- WHERE productId = #{productId}
- </update>
- <update id="deleteCmHeHeSku">
- delete from cm_hehe_sku
- WHERE productId = #{productId}
- </update>
- <update id="updateProductId">
- update cm_hehe_product
- set oldProductId = #{oldProductId},
- productId = #{newProductId}
- where productId = #{oldProductId}
- </update>
- <update id="updateHeHeSkuPrice">
- update cm_hehe_sku
- set price=#{price}
- where skuId = #{skuId}
- </update>
- <select id="findLadderList" resultType="com.caimei.modules.product.entity.CmLadderPrice">
- select id, buyPrice, buyNum
- from cm_hehe_activity_ladder
- where skuId = #{skuId}
- </select>
- <select id="findMobileByUserYear" resultType="String">
- select chu.mobile
- from cm_hehe_user chu
- left join user u on u.userID = chu.userID
- where chu.userIdentity='1' and u.validFlag='1' and u.loginTime >= DATE_SUB(NOW(), INTERVAL #{num} YEAR)
- </select>
- <select id="getMonthCount" resultType="java.lang.Integer">
- <if test="type != null and type == 1">
- select count(1)
- from cm_hehe_collage_product
- where addTime >= DATE_SUB(NOW(), INTERVAL #{num} MONTH)
- </if>
- <if test="type != null and type == 2">
- select count(1)
- from cm_hehe_activity_product
- where addTime >= DATE_SUB(NOW(), INTERVAL #{num} MONTH)
- </if>
- <if test="type != null and type == 3">
- select count(1)
- from hehe_discount_activity_product
- where addTime >= DATE_SUB(NOW(), INTERVAL #{num} MONTH)
- </if>
- </select>
- </mapper>
|