|
@@ -1,6 +1,173 @@
|
|
|
<?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.caimei365.commodity.mapper.ShopMapper">
|
|
|
+ <insert id="insertProduct" keyColumn="productID" keyProperty="productId" parameterType="com.caimei365.commodity.model.po.ProductPo" useGeneratedKeys="true">
|
|
|
+ insert into product (
|
|
|
+ shopID, name, aliasName, commodityType, bigTypeID, smallTypeID, tinyTypeID, mainImage,
|
|
|
+ brandID, productType, tags, unit, normalPrice, price, includedTax, minBuyNumber, stock,
|
|
|
+ <if test="productCategory != null and productCategory != ''">
|
|
|
+ productCategory,
|
|
|
+ </if>
|
|
|
+ <if test="serviceNumber != null and serviceNumber != ''">
|
|
|
+ serviceNumber,
|
|
|
+ </if>
|
|
|
+ <if test="supplierTaxPoint != null and supplierTaxPoint != ''">
|
|
|
+ supplierTaxPoint,
|
|
|
+ </if>
|
|
|
+ <if test="addTime != null and addTime != ''">
|
|
|
+ addTime,
|
|
|
+ </if>
|
|
|
+ <if test="hasSkuFlag != null and hasSkuFlag != ''">
|
|
|
+ hasSkuFlag,
|
|
|
+ </if>
|
|
|
+ <if test="sellNumber != null and sellNumber != ''">
|
|
|
+ sellNumber,
|
|
|
+ </if>
|
|
|
+ <if test="sortIndex != null and sortIndex != ''">
|
|
|
+ sortIndex,
|
|
|
+ </if>
|
|
|
+ <if test="featuredFlag != null and featuredFlag != ''">
|
|
|
+ featuredFlag,
|
|
|
+ </if>
|
|
|
+ <if test="costCheckFlag != null and costCheckFlag != ''">
|
|
|
+ costCheckFlag,
|
|
|
+ </if>
|
|
|
+ <if test="recommendType != null and recommendType != ''">
|
|
|
+ recommendType,
|
|
|
+ </if>
|
|
|
+ <if test="priceFlag != null and priceFlag != ''">
|
|
|
+ price1TextFlag,
|
|
|
+ </if>
|
|
|
+ <if test="actFlag != null and actFlag != ''">
|
|
|
+ actFlag,
|
|
|
+ </if>
|
|
|
+ <if test="ladderPriceFlag != null and ladderPriceFlag != ''">
|
|
|
+ ladderPriceFlag,
|
|
|
+ </if>
|
|
|
+ <if test="visibility != null and visibility != ''">
|
|
|
+ visibility,
|
|
|
+ </if>
|
|
|
+ <if test="productCode != null and productCode != ''">
|
|
|
+ productCode,
|
|
|
+ </if>
|
|
|
+ updateTime, validFlag
|
|
|
+ ) values (
|
|
|
+ #{shopId}, #{name}, #{aliasName}, #{commodityType}, #{bigTypeId}, #{smallTypeId}, #{tinyTypeId}, #{mainImage},
|
|
|
+ #{brandId}, #{productType}, #{tags}, #{unit}, #{normalPrice}, #{price}, #{includedTax}, #{minBuyNumber}, #{stock},
|
|
|
+ <if test="productCategory != null and productCategory != ''">
|
|
|
+ #{productCategory},
|
|
|
+ </if>
|
|
|
+ <if test="serviceNumber != null and serviceNumber != ''">
|
|
|
+ #{serviceNumber},
|
|
|
+ </if>
|
|
|
+ <if test="supplierTaxPoint != null and supplierTaxPoint != ''">
|
|
|
+ #{supplierTaxPoint},
|
|
|
+ </if>
|
|
|
+ <if test="addTime != null and addTime != ''">
|
|
|
+ #{addTime},
|
|
|
+ </if>
|
|
|
+ <if test="hasSkuFlag != null and hasSkuFlag != ''">
|
|
|
+ #{hasSkuFlag},
|
|
|
+ </if>
|
|
|
+ <if test="sellNumber != null and sellNumber != ''">
|
|
|
+ #{sellNumber},
|
|
|
+ </if>
|
|
|
+ <if test="sortIndex != null and sortIndex != ''">
|
|
|
+ #{sortIndex},
|
|
|
+ </if>
|
|
|
+ <if test="featuredFlag != null and featuredFlag != ''">
|
|
|
+ #{featuredFlag},
|
|
|
+ </if>
|
|
|
+ <if test="costCheckFlag != null and costCheckFlag != ''">
|
|
|
+ #{costCheckFlag},
|
|
|
+ </if>
|
|
|
+ <if test="recommendType != null and recommendType != ''">
|
|
|
+ #{recommendType},
|
|
|
+ </if>
|
|
|
+ <if test="priceFlag != null and priceFlag != ''">
|
|
|
+ #{priceFlag},
|
|
|
+ </if>
|
|
|
+ <if test="actFlag != null and actFlag != ''">
|
|
|
+ #{actFlag},
|
|
|
+ </if>
|
|
|
+ <if test="ladderPriceFlag != null and ladderPriceFlag != ''">
|
|
|
+ #{ladderPriceFlag},
|
|
|
+ </if>
|
|
|
+ <if test="visibility != null and visibility != ''">
|
|
|
+ #{visibility},
|
|
|
+ </if>
|
|
|
+ <if test="productCode != null and productCode != ''">
|
|
|
+ #{productCode},
|
|
|
+ </if>
|
|
|
+ #{updateTime}, #{validFlag}
|
|
|
+ )
|
|
|
+ </insert>
|
|
|
+ <update id="updateProduct">
|
|
|
+ update product set
|
|
|
+ shopID = #{shopId}, name = #{name}, aliasName = #{aliasName}, commodityType = #{commodityType},
|
|
|
+ bigTypeId = #{bigTypeId}, smallTypeId = #{smallTypeId}, tinyTypeId = #{tinyTypeId}, mainImage = #{mainImage},
|
|
|
+ brandId = #{brandId}, productType = #{productType}, tags = #{tags}, unit = #{unit}, normalPrice = #{normalPrice},
|
|
|
+ price = #{price}, includedTax = #{includedTax}, minBuyNumber = #{minBuyNumber}, stock = #{stock},
|
|
|
+ <if test="productCategory != null and productCategory != ''">
|
|
|
+ productCategory = #{productCategory},
|
|
|
+ </if>
|
|
|
+ <if test="serviceNumber != null and serviceNumber != ''">
|
|
|
+ serviceNumber = #{serviceNumber},
|
|
|
+ </if>
|
|
|
+ <if test="supplierTaxPoint != null and supplierTaxPoint != ''">
|
|
|
+ supplierTaxPoint = #{supplierTaxPoint},
|
|
|
+ </if>
|
|
|
+ <if test="addTime != null and addTime != ''">
|
|
|
+ addTime = #{addTime},
|
|
|
+ </if>
|
|
|
+ <if test="hasSkuFlag != null and hasSkuFlag != ''">
|
|
|
+ hasSkuFlag = #{hasSkuFlag},
|
|
|
+ </if>
|
|
|
+ <if test="sellNumber != null and sellNumber != ''">
|
|
|
+ sellNumber = #{sellNumber},
|
|
|
+ </if>
|
|
|
+ <if test="sortIndex != null and sortIndex != ''">
|
|
|
+ sortIndex = #{sortIndex},
|
|
|
+ </if>
|
|
|
+ <if test="featuredFlag != null and featuredFlag != ''">
|
|
|
+ featuredFlag = #{featuredFlag},
|
|
|
+ </if>
|
|
|
+ <if test="costCheckFlag != null and costCheckFlag != ''">
|
|
|
+ costCheckFlag = #{costCheckFlag},
|
|
|
+ </if>
|
|
|
+ <if test="recommendType != null and recommendType != ''">
|
|
|
+ recommendType = #{recommendType},
|
|
|
+ </if>
|
|
|
+ <if test="priceFlag != null and priceFlag != ''">
|
|
|
+ price1TextFlag = #{priceFlag},
|
|
|
+ </if>
|
|
|
+ <if test="actFlag != null and actFlag != ''">
|
|
|
+ actFlag = #{actFlag},
|
|
|
+ </if>
|
|
|
+ <if test="ladderPriceFlag != null and ladderPriceFlag != ''">
|
|
|
+ ladderPriceFlag = #{ladderPriceFlag},
|
|
|
+ </if>
|
|
|
+ <if test="visibility != null and visibility != ''">
|
|
|
+ visibility = #{visibility},
|
|
|
+ </if>
|
|
|
+ <if test="productCode != null and productCode != ''">
|
|
|
+ productCode = #{productCode},
|
|
|
+ </if>
|
|
|
+ updateTime = #{updateTime}, validFlag = #{validFlag}
|
|
|
+ where productID = #{productId}
|
|
|
+ </update>
|
|
|
+ <insert id="insertProductImage">
|
|
|
+ insert into productimage (productID, shopID, addTime, image, mainFlag, sortIndex)
|
|
|
+ values (#{productId}, #{shopId}, #{addTime}, #{image}, #{mainFlag}, #{sortIndex})
|
|
|
+ </insert>
|
|
|
+ <update id="updateProductImage">
|
|
|
+ update productimage set productID = #{productId}, shopID = #{shopId}, addTime = #{addTime},
|
|
|
+ image = #{image}, mainFlag = #{mainFlag}, sortIndex = #{sortIndex}
|
|
|
+ where productImageId = #{id}
|
|
|
+ </update>
|
|
|
+ <delete id="deleteProductImage">
|
|
|
+ delete from productimage where productImageID = #{id}
|
|
|
+ </delete>
|
|
|
<select id="getMainProducts" resultType="com.caimei365.commodity.model.search.ProductListVo">
|
|
|
select
|
|
|
p.productID as id,
|
|
@@ -72,4 +239,28 @@
|
|
|
select count(*) from product where shopID = #{shopId}
|
|
|
and validFlag = '2' and featuredFlag='1' order by productID desc
|
|
|
</select>
|
|
|
+ <select id="getCodeByTypeId" resultType="java.lang.String">
|
|
|
+ select
|
|
|
+ CONCAT(IFNULL(b.bigTypeCode,''), IFNULL(s.smallTypeCode,''), IFNULL(t.tinyTypeCode,''))
|
|
|
+ from bigtype b
|
|
|
+ left join smalltype s on s.bigTypeID = b.bigTypeID
|
|
|
+ left join tinytype t on t.smallTypeID = s.smallTypeID
|
|
|
+ <where>
|
|
|
+ <if test="bigTypeId != null">
|
|
|
+ b.bigTypeID = #{bigTypeId}
|
|
|
+ </if>
|
|
|
+ <if test="smallTypeId != null">
|
|
|
+ and s.smallTypeID = #{smallTypeId}
|
|
|
+ </if>
|
|
|
+ <if test="tinyTypeId != null">
|
|
|
+ and t.tinyTypeID = #{tinyTypeId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+ <select id="getImageByProductId" resultType="com.caimei365.commodity.model.po.ProductImagePo">
|
|
|
+ select productImageID as id, productID as productId, shopID as shopId, addTime, image, mainFlag, sortIndex
|
|
|
+ from productimage
|
|
|
+ where productID = #{productId}
|
|
|
+ order by mainFlag DESC
|
|
|
+ </select>
|
|
|
</mapper>
|