123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384 |
- <?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.weisha.dao.CmOrganizeProductDao">
- <sql id="cmOrganizeProductColumns">
- a.id AS "id",
- a.organizeId AS "organizeId",
- a.productId AS "productId",
- a.ladderPriceFlag AS "ladderPriceFlag",
- a.price AS "price",
- a.includedTax AS "includedTax",
- a.invoiceType AS "invoiceType",
- a.clubTaxPoint,
- a.shopTaxPoint,
- a.minBuyNumber AS "minBuyNumber",
- a.costType AS "costType",
- a.costPrice AS "costPrice",
- a.costProportional AS "costProportional",
- a.status AS "status",
- a.addTime AS "addTime",
- a.delFlag AS "delFlag",
- p.name AS "productName",
- p.mainImage AS "productImage",
- # p.unit,
- s.name AS "shopName"
- </sql>
- <sql id="cmOrganizeProductJoins">
- left join product p on a.productId = p.productID
- left join shop s on p.shopID = s.shopID
- </sql>
- <select id="get" resultType="CmOrganizeProduct">
- SELECT
- <include refid="cmOrganizeProductColumns"/>
- FROM cm_organize_product a
- <include refid="cmOrganizeProductJoins"/>
- WHERE a.id = #{id}
- </select>
- <select id="findList" resultType="CmOrganizeProduct">
- SELECT
- <include refid="cmOrganizeProductColumns"/>
- FROM cm_organize_product a
- <include refid="cmOrganizeProductJoins"/>
- <where>
- a.delFlag = 0
- and p.productCategory = 1
- <if test="id != null and id != ''">
- AND a.id = #{id}
- </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>
- <if test="includedTax != null">
- AND a.includedTax = #{includedTax}
- </if>
- <if test="invoiceType != null">
- AND a.invoiceType = #{invoiceType}
- </if>
- <if test="status != null">
- AND a.status = #{status}
- </if>
- <if test="organizeId != null">
- AND a.organizeId = #{organizeId}
- </if>
- </where>
- order by a.addTime desc
- </select>
- <select id="findAllList" resultType="CmOrganizeProduct">
- SELECT
- <include refid="cmOrganizeProductColumns"/>
- FROM cm_organize_product a
- <include refid="cmOrganizeProductJoins"/>
- <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="getOrganizeProductList" resultType="com.caimei.modules.weisha.entity.CmOrganizeProduct">
- SELECT
- cmop.id,
- cmop.productID,
- p.name as productName,
- p.mainImage as productImage,
- s.name as shopName,
- cmop.validFlag as status,
- p.includedTax,
- p.invoiceType,
- cmop.addTime
- FROM cm_mall_organize_products cmop
- LEFT JOIN product p ON p.productId = cmop.productId
- LEFT JOIN shop s ON s.shopID = p.shopID
- <where>
- cmop.delFlag = 0
- <if test="productId != null and productId != ''">
- AND cmop.productId = #{productId}
- </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>
- <if test="includedTax != null">
- AND p.includedTax = #{includedTax}
- </if>
- <if test="status != null and status != ''">
- AND cmop.validFlag = #{status}
- </if>
- <if test="invoiceType != null">
- AND p.invoiceType = #{invoiceType}
- </if>
- <if test="organizeId != null">
- AND cmop.organizeID = #{organizeId}
- </if>
- </where>
- order by cmop.addTime desc
- </select>
- <select id="getOrganizeSku" resultType="com.caimei.modules.weisha.entity.CmOrganizeSku">
- SELECT
- cmps.id,
- cmps.productId,
- cmps.id,
- cmps.skuId,
- cmps.minBuyNumber,
- cmps.price,
- cs.unit,
- cs.price as clubPrice,
- cs.costCheckFlag as costCheckFlag,
- cs.costPrice as costPrice,
- cs.costProportional as costProportional,
- cs.minBuyNumber AS cmMinBuyNumber,
- cmps.organizePercent,
- cmps.shopPercent,
- cmps.cmPercent
- FROM cm_mall_product_sku cmps
- LEFT JOIN cm_sku cs ON cmps.skuId = cs.skuId
- <where>
- <if test="productIds.size() > 0">
- cmps.productId in
- <foreach collection="productIds" item="productId" open="(" separator="," close=")">
- #{productId}
- </foreach>
- </if>
- </where>
- </select>
- <update id="updateproduct">
- update cm_mall_organize_products
- set validFlag = #{validFlag}
- where id = #{id}
- </update>
- <select id="findProductList" resultType="com.caimei.modules.product.entity.Product">
- select p.productID, p.mainImage, p.name,
- s.name as shopName, IF(cmop.productId is not null, 0, 1) as validFlag
- from product p
- left join cm_mall_organize_products cmop on p.productID = cmop.productId and cmop.organizeId = #{organizeId} and cmop.delFlag = 0
- left join shop s on p.shopID = s.shopID
- <where>
- p.productCategory = 1
- <if test="productID != null">
- AND p.productID = #{productID}
- </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>
- </select>
- <select id="findProductByProductId" resultType="com.caimei.modules.weisha.entity.CmOrganizeProduct">
- select productID as productId, # ladderPriceFlag, price as price,
- ifnull(includedTax,2) as includedTax,invoiceType,taxPoint as clubTaxPoint,supplierTaxPoint as shopTaxPoint # minBuyNumber,
- # costCheckFlag as costType,
- # costPrice,costProportional
- from product
- where productID = #{productId}
- </select>
- <select id="findLadderPrice" resultType="com.caimei.modules.weisha.entity.OrganizeProductLadderPrice">
- select * from organize_product_ladder_price where productId = #{productId}
- </select>
- <select id="findFormerLadderPriceList"
- resultType="com.caimei.modules.weisha.entity.OrganizeProductLadderPrice">
- select ladderNum,buyNum,buyPrice from product_ladder_price where productId = #{productId}
- </select>
- <select id="getOrganizeInfo" resultType="com.caimei.modules.weisha.entity.CmMallOrganize">
- select a.id AS "id",
- a.organizeName AS "organizeName",
- a.organizeLinkName AS "organizeLinkName",
- a.mobile AS "mobile",
- a.status AS "status",
- a.contactNumber AS "contactNumber",
- a.systemName AS "systemName",
- a.systemImage AS "systemImage",
- a.introduction AS "introduction",
- a.afterSale AS "afterSale",
- a.shoppingNotes AS "shoppingNotes",
- a.updateTime AS "updateTime",
- a.addTime AS "addTime",
- a.delFlag AS "delFlag"
- from cm_mall_organize a
- where a.id = #{id}
- </select>
- <select id="getShopInfo" resultType="com.caimei.modules.weisha.entity.CmOrganizeProduct">
- SELECT
- p.productId,
- p.name AS productName,
- s.name AS shopName
- FROM product p
- LEFT JOIN shop s ON p.shopId = s.shopId
- <where>
- <if test="productIds.size()>0">
- productId in
- <foreach collection="productIds" item="productId" open="(" separator="," close=")">
- #{productId}
- </foreach>
- </if>
- </where>
- </select>
- <select id="getSkuInfo" resultType="com.caimei.modules.product.entity.CmSku">
- SELECT
- skuId,
- productId,
- normalPrice,
- price,
- costPrice,
- ladderPriceFlag,
- minBuyNumber
- FROM cm_sku
- where productId = #{productId}
- order by normalPrice
- </select>
- <insert id="insertMallProduct" parameterType="CmOrganizeProduct" keyProperty="id" useGeneratedKeys="true">
- INSERT INTO cm_mall_organize_products (organizeID, productID, normalPrice, costPrice, ladderPriceFlag, retailPrice, minBuyNumber, validFlag, ADDTIME, updateTime, delFlag)
- VALUES(#{organizeId}, #{productId}, #{normalPrice}, #{costPrice}, #{ladderPriceFlag}, #{retailPrice}, #{minBuyNumber}, #{status},#{addTime}, #{updateTime}, #{delFlag})
- </insert>
- <insert id="insertMallSku">
- INSERT INTO cm_mall_product_sku(skuId, productId, mallProductId, minBuyNumber, price)
- VALUES (#{skuId}, #{productId}, #{mallProductId}, #{minBuyNumber}, #{price})
- </insert>
- <update id="updateMallProduct">
- update cm_mall_organize_products
- <set>
- <if test="retailPrice != null and retailPrice != ''">
- retailPrice = #{retailPrice},
- </if>
- <if test="minBuyNumber != null and minBuyNumber != ''">
- minBuyNumber = #{minBuyNumber}
- </if>
- </set>
- where id =#{id}
- </update>
- <update id="updateMallProductSku">
- update cm_mall_product_sku
- <set>
- <if test="price != null and price != ''">
- price = #{price},
- </if>
- <if test="minBuyNumber != null and minBuyNumber != ''">
- minBuyNumber = #{minBuyNumber},
- </if>
- <if test="organizePercent != null and organizePercent != ''">
- organizePercent = #{organizePercent},
- </if>
- <if test="shopPercent != null and shopPercent != ''">
- shopPercent = #{shopPercent},
- </if>
- <if test="cmPercent != null and cmPercent != ''">
- cmPercent = #{cmPercent}
- </if>
- </set>
- where id =#{id}
- </update>
- <select id="getProductInfo" resultType="com.caimei.modules.weisha.entity.CmOrganizeProduct">
- SELECT cmop.id,
- cmop.organizeID AS organizeId,
- p.productID AS productId,
- p.mainImage AS productImage,
- p.name AS productName,
- s.name AS shopName,
- IF(cmop.productId IS NOT NULL, 0, 1) AS validFlag,
- p.includedTax,
- p.invoiceType,
- p.taxPoint,
- p.supplierTaxPoint
- FROM product p
- LEFT JOIN cm_mall_organize_products cmop ON p.productID = cmop.productId
- LEFT JOIN shop s ON p.shopID = s.shopID
- WHERE p.productCategory = 1 AND cmop.id = #{id}
- </select>
- <update id="deleteProduct">
- update cm_mall_organize_products
- set delFlag = 1
- where id = #{id}
- </update>
- <insert id="insert" parameterType="CmOrganizeProduct" keyProperty="id" useGeneratedKeys="true">
- INSERT INTO cm_organize_product(
- organizeId,
- productId,
- ladderPriceFlag,
- price,
- includedTax,
- invoiceType,
- clubTaxPoint,
- shopTaxPoint,
- minBuyNumber,
- costType,
- costPrice,
- costProportional,
- addTime
- ) VALUES (
- #{organizeId},
- #{productId},
- #{ladderPriceFlag},
- #{price},
- #{includedTax},
- #{invoiceType},
- #{clubTaxPoint},
- #{shopTaxPoint},
- #{minBuyNumber},
- #{costType},
- #{costPrice},
- #{costProportional},
- #{addTime}
- )
- </insert>
- <insert id="insertLadderPrice">
- insert into organize_product_ladder_price(
- productId, ladderNum, buyNum, buyPrice
- ) values (#{productId},#{ladderNum},#{buyNum},#{buyPrice})
- </insert>
- <update id="update">
- UPDATE cm_organize_product SET
- ladderPriceFlag = #{ladderPriceFlag},
- price = #{price},
- includedTax = #{includedTax},
- invoiceType = #{invoiceType},
- clubTaxPoint = #{clubTaxPoint},
- shopTaxPoint = #{shopTaxPoint},
- minBuyNumber = #{minBuyNumber},
- costType = #{costType},
- costPrice = #{costPrice},
- costProportional = #{costProportional},
- status = #{status},
- addTime = #{addTime},
- delFlag = #{delFlag}
- WHERE id = #{id}
- </update>
- <update id="updateStatus">
- UPDATE cm_organize_product SET
- status = #{status}
- WHERE id = #{id}
- </update>
- <update id="updateLadderPrice">
- update organize_product_ladder_price
- set productId = #{productId},ladderNum = #{ladderNum},buyNum=#{buyNum},buyPrice=#{buyPrice}
- where id = #{id}
- </update>
- <update id="updateLadderPriceFlag">
- update cm_organize_product set ladderPriceFlag = #{ladderPriceFlag} where id = #{productId}
- </update>
- <delete id="delete">
- UPDATE cm_organize_product set delFlag = 1 where id = #{id}
- </delete>
- <delete id="deleteLadderPriceById">
- delete from organize_product_ladder_price where id = #{ladderId}
- </delete>
- </mapper>
|