|
@@ -4,7 +4,7 @@
|
|
|
<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,
|
|
|
+ groundMall, shopID, name, aliasName, commodityType, bigTypeID, smallTypeID, tinyTypeID, mainImage,
|
|
|
brandID, productType, tags, includedTax,
|
|
|
<if test="productCategory != null and productCategory != '' ">
|
|
|
productCategory,
|
|
@@ -78,9 +78,18 @@
|
|
|
<if test="qualificationTime != null and qualificationTime != ''">
|
|
|
qualificationTime,
|
|
|
</if>
|
|
|
- updateTime,validFlag,newProductType,showFlag,newvalidFlag
|
|
|
+ <if test="trainingMethod != null and trainingMethod != ''">
|
|
|
+ trainingMethod,
|
|
|
+ </if>
|
|
|
+ <if test="trainingType != null and trainingType != ''">
|
|
|
+ trainingType,
|
|
|
+ </if>
|
|
|
+ <if test="trainingFee != null and trainingFee != ''">
|
|
|
+ trainingFee,
|
|
|
+ </if>
|
|
|
+ updateTime,newProductType,showFlag,newvalidFlag
|
|
|
) values (
|
|
|
- #{shopId}, #{name}, #{aliasName}, #{commodityType}, #{bigTypeId}, #{smallTypeId}, #{tinyTypeId}, #{mainImage},
|
|
|
+ #{groundMall}, #{shopId}, #{name}, #{aliasName}, #{commodityType}, #{bigTypeId}, #{smallTypeId}, #{tinyTypeId}, #{mainImage},
|
|
|
#{brandId}, #{productType}, #{tags}, #{includedTax},
|
|
|
<if test="productCategory != null and productCategory != '' ">
|
|
|
#{productCategory},
|
|
@@ -154,12 +163,21 @@
|
|
|
<if test="qualificationTime != null and qualificationTime != ''">
|
|
|
#{qualificationTime},
|
|
|
</if>
|
|
|
- #{updateTime}, #{validFlag},#{newProductType},#{showFlag},3
|
|
|
+ <if test="trainingMethod != null and trainingMethod != ''">
|
|
|
+ #{trainingMethod},
|
|
|
+ </if>
|
|
|
+ <if test="trainingType != null and trainingType != ''">
|
|
|
+ #{trainingType},
|
|
|
+ </if>
|
|
|
+ <if test="trainingFee != null and trainingFee != ''">
|
|
|
+ #{trainingFee},
|
|
|
+ </if>
|
|
|
+ #{updateTime}, #{newProductType},#{showFlag},3
|
|
|
)
|
|
|
</insert>
|
|
|
<update id="updateProduct">
|
|
|
update product set
|
|
|
- shopID = #{shopId}, name = #{name}, aliasName = #{aliasName}, commodityType = #{commodityType},
|
|
|
+ groundMall = #{groundMall}, shopID = #{shopId}, name = #{name}, aliasName = #{aliasName}, commodityType = #{commodityType},
|
|
|
bigTypeId = #{bigTypeId}, smallTypeId = #{smallTypeId}, tinyTypeId = #{tinyTypeId}, mainImage = #{mainImage},
|
|
|
brandId = #{brandId}, productType = #{productType}, tags = #{tags}, includedTax = #{includedTax},newProductType=#{newProductType},
|
|
|
<if test="qualificationNo !=null and qualificationNo != ''">
|
|
@@ -240,11 +258,25 @@
|
|
|
<if test="invoiceType != null and invoiceType != ''">
|
|
|
invoiceType = #{invoiceType},
|
|
|
</if>
|
|
|
+ <if test="trainingMethod != null and trainingMethod != ''">
|
|
|
+ trainingMethod = #{trainingMethod},
|
|
|
+ </if>
|
|
|
+ <if test="trainingType != null and trainingType != ''">
|
|
|
+ trainingType = #{trainingType},
|
|
|
+ </if>
|
|
|
updateTime = #{updateTime},
|
|
|
- validFlag = #{validFlag},
|
|
|
showFlag=#{showFlag}
|
|
|
where productID = #{productId}
|
|
|
</update>
|
|
|
+ <insert id="insertVaildFlag">
|
|
|
+ insert into cm_organize_product_info (organizeId, productId, validFlag)
|
|
|
+ values (#{organizeId},#{productId},#{validFlag})
|
|
|
+ </insert>
|
|
|
+ <update id="updateVaildFlag">
|
|
|
+ update cm_organize_product_info
|
|
|
+ set validFlag = #{validFlag}
|
|
|
+ where productId = #{productId} and organizeId = #{organizeId}
|
|
|
+ </update>
|
|
|
<insert id="insertProductImage">
|
|
|
insert into productimage (productID, shopID, addTime, image, mainFlag, sortIndex)
|
|
|
values (#{productId}, #{shopId}, #{addTime}, #{image}, #{mainFlag}, #{sortIndex})
|
|
@@ -267,9 +299,10 @@
|
|
|
values (#{name}, #{source}, #{userId}, #{status}, #{delFlag}, #{createDate}, #{updateDate}, #{logo},
|
|
|
#{description})
|
|
|
</insert>
|
|
|
- <insert id="insertSku">
|
|
|
+ <insert id="insertSku" keyColumn="skuId" keyProperty="skuId" parameterType="com.caimei365.commodity.model.dto.Sku">
|
|
|
insert into cm_sku
|
|
|
(productId,
|
|
|
+ organizeId,
|
|
|
normalPrice,
|
|
|
price,
|
|
|
costCheckFlag,
|
|
@@ -277,8 +310,12 @@
|
|
|
stock,
|
|
|
minBuyNumber,
|
|
|
unit,
|
|
|
- ladderPriceFlag)
|
|
|
+ ladderPriceFlag,
|
|
|
+ shopPercent,
|
|
|
+ organizePercent,
|
|
|
+ cmPercent)
|
|
|
values (#{productId},
|
|
|
+ #{organizeId},
|
|
|
#{normalPrice},
|
|
|
#{price},
|
|
|
ifnull(#{costCheckFlag}, 1),
|
|
@@ -286,7 +323,14 @@
|
|
|
#{stock},
|
|
|
#{minBuyNumber},
|
|
|
#{unit},
|
|
|
- ifnull(#{ladderPriceFlag}, 0))
|
|
|
+ ifnull(#{ladderPriceFlag}, 0),
|
|
|
+ #{shopPercent},
|
|
|
+ #{organizePercent},
|
|
|
+ #{cmPercent})
|
|
|
+ </insert>
|
|
|
+ <insert id="insertProductInfo">
|
|
|
+ insert into cm_organize_product_info (organizeId, productId, validFlag)
|
|
|
+ values (#{organizeId}, #{productId}, #{validFlag})
|
|
|
</insert>
|
|
|
<update id="updateBrand">
|
|
|
update cm_brand
|
|
@@ -348,9 +392,17 @@
|
|
|
and shopID = #{shopId}
|
|
|
</update>
|
|
|
<update id="updateProductValidFlag">
|
|
|
- update product
|
|
|
+ update cm_organize_product_info
|
|
|
set validFlag = #{validFlag}
|
|
|
- where productID = #{productId}
|
|
|
+ where productId = #{productId}
|
|
|
+ <if test="organizeId != 0">
|
|
|
+ <if test="organizeId == 1">
|
|
|
+ and organizeId = 0
|
|
|
+ </if>
|
|
|
+ <if test="organizeId == 2">
|
|
|
+ and organizeId = 4
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
</update>
|
|
|
<update id="updateProductCode">
|
|
|
update product
|
|
@@ -367,6 +419,17 @@
|
|
|
unit=#{unit}
|
|
|
where skuId = #{skuId}
|
|
|
</update>
|
|
|
+ <delete id="deleteSku">
|
|
|
+ delete from cm_sku
|
|
|
+ where productId = #{productId}
|
|
|
+ <if test="skuIds.size() > 0">
|
|
|
+ and skuId not in
|
|
|
+ <foreach collection="skuIds" item="skuId" open="(" separator="," close=")">
|
|
|
+ #{skuId}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ and organizeId = #{organizeId}
|
|
|
+ </delete>
|
|
|
<delete id="deleteProductImage">
|
|
|
delete
|
|
|
from productimage
|
|
@@ -384,18 +447,19 @@
|
|
|
p.shopID as shopId,
|
|
|
p.`name` as `name`,
|
|
|
p.mainImage as image,
|
|
|
- (select price from cm_sku where productId=p.productID order by price asc limit 1) as price,
|
|
|
- (select unit from cm_sku where productId=p.productID order by price asc limit 1) as unit,
|
|
|
+ (select price from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1) as price,
|
|
|
+ (select unit from cm_sku where productId=p.productID and organizeId = 0 order by price asc limit 1) as unit,
|
|
|
p.priceFlag as priceFlag,
|
|
|
IFNULL(p.visibility,3) as visibility,
|
|
|
p.productType
|
|
|
from product p
|
|
|
+ left join cm_organize_product_info copi on copi.productId = p.productID and copi.organizeId = 0
|
|
|
where p.shopID = #{shopId}
|
|
|
and p.visibility in
|
|
|
<foreach collection="visibilityList" item="visibility" index="index" open="(" separator="," close=")">
|
|
|
#{visibility}
|
|
|
</foreach>
|
|
|
- and p.validFlag = 2 and p.featuredFlag=1
|
|
|
+ and copi.validFlag = 2 and p.featuredFlag=1
|
|
|
order by p.productID desc limit 4
|
|
|
</select>
|
|
|
<select id="getShopProductsSelect" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
|
|
@@ -405,36 +469,39 @@
|
|
|
p.name,
|
|
|
p.aliasName,
|
|
|
p.mainImage as image,
|
|
|
- (select unit from cm_sku where productId=p.productId order by price asc LIMIT 1) as unit,
|
|
|
+ (select unit from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as unit,
|
|
|
p.productCode as code,
|
|
|
p.priceFlag,
|
|
|
- (select price from cm_sku where productId=p.productId order by price asc LIMIT 1) as price,
|
|
|
- (select normalPrice from cm_sku where productId=p.productId order by price asc LIMIT 1) as normalPrice,
|
|
|
+ (select price from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as price,
|
|
|
+ (select normalPrice from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as normalPrice,
|
|
|
p.searchKey as keyword,
|
|
|
- (select minBuyNumber from cm_sku where productId=p.productId order by price asc LIMIT 1) as minBuyNumber,
|
|
|
- (select ladderPriceFlag from cm_sku where productId=p.productId order by price asc LIMIT 1) as ladderPriceFlag,
|
|
|
+ (select minBuyNumber from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as minBuyNumber,
|
|
|
+ (select ladderPriceFlag from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as ladderPriceFlag,
|
|
|
p.step,
|
|
|
p.shopID as shopId,
|
|
|
p.taxPoint as taxRate,
|
|
|
p.includedTax,
|
|
|
p.invoiceType,
|
|
|
p.productCategory as productCategory,
|
|
|
- p.validFlag,
|
|
|
+ IFNULL((SELECT validFlag FROM cm_organize_product_info WHERE productId = p.productID AND organizeId = 0), 999) AS validFlag,
|
|
|
+ IFNULL((SELECT validFlag FROM cm_organize_product_info WHERE productId = p.productID AND organizeId = 4), 999) AS mallValidFlag,
|
|
|
p.featuredFlag,
|
|
|
p.commodityType,
|
|
|
p.bigTypeID as bigTypeId,
|
|
|
p.smallTypeID as smallTypeId,
|
|
|
p.tinyTypeID as tinyTypeId,
|
|
|
ifnull(p.newvalidFlag,3) as newvalidFlag,
|
|
|
- ifnull(p.showFlag,0) as showFlag
|
|
|
+ ifnull(p.showFlag,0) as showFlag,
|
|
|
+ p.groundMall AS groundMall
|
|
|
from product p
|
|
|
+ LEFT JOIN cm_organize_product_info copi ON copi.productId = p.productID
|
|
|
<where>
|
|
|
p.shopID = #{shopId}
|
|
|
<if test="productCode != null and productCode != ''">
|
|
|
and p.productCode = #{productCode}
|
|
|
</if>
|
|
|
- <if test="validFlag != null and validFlag != ''">
|
|
|
- and p.validFlag = #{validFlag}
|
|
|
+ <if test="validFlag != null">
|
|
|
+ and copi.validFlag = #{validFlag}
|
|
|
</if>
|
|
|
<if test="featuredFlag != null and featuredFlag != ''">
|
|
|
and p.featuredFlag = #{featuredFlag}
|
|
@@ -454,6 +521,9 @@
|
|
|
<if test="name != null and name != ''">
|
|
|
and p.name like CONCAT("%",#{name},"%")
|
|
|
</if>
|
|
|
+ <if test="groundMall != null">
|
|
|
+ and p.groundMall like concat('%',#{groundMall},'%')
|
|
|
+ </if>
|
|
|
<if test="newvalidFlag !=null and newvalidFlag!=''">
|
|
|
and newvalidFlag =#{newvalidFlag}
|
|
|
</if>
|
|
@@ -476,10 +546,9 @@
|
|
|
where shopID = #{shopId}
|
|
|
</select>
|
|
|
<select id="getMainProductsCount" resultType="java.lang.Integer">
|
|
|
- select count(*)
|
|
|
+ select count(distinct productId)
|
|
|
from product
|
|
|
where shopID = #{shopId}
|
|
|
- and validFlag = '2'
|
|
|
and featuredFlag = '1'
|
|
|
order by productID desc
|
|
|
</select>
|
|
@@ -509,12 +578,13 @@
|
|
|
</select>
|
|
|
<select id="getProductForm" resultType="com.caimei365.commodity.model.vo.ProductFormVo">
|
|
|
select productID as productId,
|
|
|
+ groundMall,
|
|
|
shopID as shopId,
|
|
|
name,
|
|
|
aliasName,
|
|
|
commodityType,
|
|
|
mainImage,
|
|
|
- (select stock from cm_sku where productId=p.productId order by price asc LIMIT 1) as stock,
|
|
|
+ (select stock from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as stock,
|
|
|
invoiceType,
|
|
|
bigTypeID as bigTypeId,
|
|
|
smallTypeID as smallTypeId,
|
|
@@ -524,32 +594,33 @@
|
|
|
brandID as brandId,
|
|
|
productType,
|
|
|
tags,
|
|
|
- (select unit from cm_sku where productId=p.productId order by price asc LIMIT 1)as unit,
|
|
|
- (select normalPrice from cm_sku where productId=p.productId order by price asc LIMIT 1)as normalPrice,
|
|
|
- (select price from cm_sku where productId=p.productId order by price asc LIMIT 1)as price,
|
|
|
+ (select unit from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as unit,
|
|
|
+ (select normalPrice from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as normalPrice,
|
|
|
+ (select price from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as price,
|
|
|
includedTax,
|
|
|
- (select minBuyNumber from cm_sku where productId=p.productId order by price asc LIMIT 1)as minBuyNumber,
|
|
|
+ (select minBuyNumber from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as minBuyNumber,
|
|
|
productCategory,
|
|
|
serviceNumber,
|
|
|
supplierTaxPoint,
|
|
|
priceFlag,
|
|
|
actFlag,
|
|
|
- (select ladderPriceFlag from cm_sku where productId=p.productId order by price asc LIMIT 1) as ladderPriceFlag,
|
|
|
+ (select ladderPriceFlag from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1) as ladderPriceFlag,
|
|
|
addTime,
|
|
|
hasSkuFlag,
|
|
|
sellNumber,
|
|
|
sortIndex,
|
|
|
featuredFlag,
|
|
|
- (select costCheckFlag from cm_sku where productId=p.productId order by price asc LIMIT 1)as costCheckFlag,
|
|
|
+ (select costCheckFlag from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as costCheckFlag,
|
|
|
recommendType,
|
|
|
machineType,
|
|
|
productCode,
|
|
|
updateTime,
|
|
|
- validFlag,
|
|
|
+ IFNULL((SELECT validFlag FROM cm_organize_product_info WHERE productId = p.productID AND organizeId = 0), 999) AS validFlag,
|
|
|
+ IFNULL((SELECT validFlag FROM cm_organize_product_info WHERE productId = p.productID AND organizeId = 4), 999) AS mallValidFlag,
|
|
|
searchKey,
|
|
|
allAreaFlag,
|
|
|
step,
|
|
|
- (select costPrice from cm_sku where productId=p.productId order by price asc LIMIT 1)as costPrice,
|
|
|
+ (select costPrice from cm_sku where productId=p.productId and organizeId = 0 order by price asc LIMIT 1)as costPrice,
|
|
|
provinceIds,
|
|
|
qualificationImg,
|
|
|
trainingMethod,
|
|
@@ -581,8 +652,8 @@
|
|
|
UNION
|
|
|
SELECT p.productImageID AS id, p.productID AS productId, p.shopId, p.ADDTIME, p.image, p.mainFlag, p.sortIndex
|
|
|
FROM productimage p
|
|
|
- LEFT JOIN cm_mall_organize_products cmop ON p.productId = cmop.productId
|
|
|
- WHERE cmop.id = #{productId}
|
|
|
+ LEFT JOIN product pt ON p.productId = pt.productId
|
|
|
+ WHERE pt.productId = #{productId}
|
|
|
order by mainFlag desc
|
|
|
</select>
|
|
|
<select id="getProductDetailInfo" resultType="com.caimei365.commodity.model.po.ProductDetailInfoPo">
|
|
@@ -615,8 +686,8 @@
|
|
|
p.seoKeyword,
|
|
|
p.seoDes
|
|
|
FROM productdetailinfo p
|
|
|
- LEFT JOIN cm_mall_organize_products cmop ON cmop.productId = p.productId
|
|
|
- WHERE p.productId = #{product} OR cmop.id = #{product}
|
|
|
+ LEFT JOIN product pt ON pt.productId = p.productId
|
|
|
+ WHERE p.productId = #{productId}
|
|
|
</select>
|
|
|
<select id="getProductShopById" resultType="com.caimei365.commodity.model.vo.ShopVo">
|
|
|
select userID as userId,
|
|
@@ -659,8 +730,9 @@
|
|
|
<select id="getProductNumById" resultType="java.lang.Integer">
|
|
|
select COUNT(*) as normalNum
|
|
|
from product p
|
|
|
+ left join cm_organize_product_info copi on copi.productId = p.productID
|
|
|
where p.shopID = #{shopId}
|
|
|
- and p.validFlag = 2
|
|
|
+ and copi.validFlag = 2
|
|
|
group by p.shopID
|
|
|
</select>
|
|
|
<select id="getUserIdentityById" resultType="java.lang.Integer">
|