123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- <?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.PriceMapper">
- <select id="getIdentityByUserId" resultType="java.lang.Integer">
- select userIdentity
- from user
- where userID = #{userId}
- </select>
- <select id="getDetailPrice" resultType="com.caimei365.commodity.model.vo.PriceVo">
- select p.productID as productId,
- p.actStatus,
- (select normalPrice from cm_sku where productId=#{productId} order by price asc limit 1) as normalPrice,
- p.maxBuyNumber,
- p.priceFlag,
- p.step,
- p.shopID as shopId,
- p.taxPoint as taxRate,
- p.includedTax,
- p.invoiceType,
- if(csp.id is not null, 1, 0) as svipProductFlag,
- csp.priceType as svipPriceType,
- csp.discount as svipDiscount,
- csp.discountPrice as svipDiscountPrice,
- p.productType
- from product p
- left join cm_svip_product csp on p.productID = csp.productId
- where p.productID = #{productId}
- </select>
- <select id="getListPriceByProductIds" resultType="com.caimei365.commodity.model.vo.PriceVo">
- select
- p.productID as productId,
- p.actStatus,
- p.maxBuyNumber,
- p.priceFlag,
- p.step,
- p.shopID as shopId,
- p.includedTax,
- p.invoiceType,
- p.taxPoint as taxRate,
- if(csp.id is not null,1,0) as svipProductFlag,
- csp.priceType as svipPriceType,
- csp.discount as svipDiscount,
- csp.discountPrice as svipDiscountPrice,
- p.productType,
- p.newvalidFlag
- from product p
- left join cm_svip_product csp on p.productID = csp.productId
- where p.productID in
- <foreach collection="productIds" open="(" separator="," close=")" item="productId">
- #{productId}
- </foreach>
- </select>
- <select id="getLadderPricesByProductId" resultType="com.caimei365.commodity.model.vo.LadderPriceVo">
- select id,
- productId,
- ladderNum,
- buyNum,
- buyPrice
- from product_ladder_price
- where skuId = #{skuId}
- and userType = 3
- and delFlag = 0
- order by ladderNum asc
- </select>
- <select id="findLowerLadderPrice" resultType="com.caimei365.commodity.model.vo.LadderPriceVo">
- select id,
- skuId,
- productId,
- ladderNum,
- buyNum,
- buyPrice
- from product_ladder_price
- where skuId = #{skuId}
- and userType = 3
- and delFlag = 0
- order by ladderNum DESC
- limit 1
- </select>
- <select id="findMaxLadderPrice" resultType="com.caimei365.commodity.model.vo.LadderPriceVo">
- select id,
- skuId,
- productId,
- ladderNum,
- buyNum,
- buyPrice
- from product_ladder_price
- where skuId = #{skuId}
- and userType = 3
- and delFlag = 0
- order by ladderNum asc
- limit 1
- </select>
- <select id="getRepurchasePrice" resultType="java.lang.Double">
- select r.currentPrice,
- p.productType
- from repeat_purchase_price r
- left join product p on p.productID = r.productId
- left join cm_sku cs on r.skuId = cs.skuId
- where r.skuId = #{skuId}
- and userId = #{userId}
- and ((cs.costCheckFlag = 1 and r.currentPrice <![CDATA[ >= ]]> cs.costPrice) or cs.costCheckFlag = 2)
- and cs.price <![CDATA[ >= ]]> r.currentPrice
- and r.delFlag = 0
- </select>
- <select id="getTaxByProductId" resultType="com.caimei365.commodity.model.vo.TaxVo">
- select p.includedTax as includedTax,
- p.invoiceType as invoiceType,
- p.taxPoint as taxPoint,
- p.productType
- from product p
- where productID = #{productId}
- </select>
- <select id="getSvipUserIdByUserId" resultType="java.lang.Integer">
- select userId
- from cm_svip_user
- where now() <![CDATA[ < ]]> endTime
- and delFlag = '0'
- and userId = #{userId}
- </select>
- <select id="getProductSalesInfo" resultType="com.caimei365.commodity.model.vo.ProductSalesVo">
- select p.productID AS productId,
- p.name AS productName,
- p.shopID AS shopId,
- p.commodityType,
- p.bigTypeID as bigTypeId,
- p.smallTypeID as smallTypeId,
- p.tinyTypeID as tinyTypeId,
- s.productId AS id,
- s.shop AS shopName,
- s.productCount AS productCount,
- s.property AS property,
- p.productType
- FROM product p
- LEFT JOIN cm_product_sales s ON p.productID = s.productId
- where p.productId = #{productId}
- </select>
- <insert id="insertProductSales" parameterType="com.caimei365.commodity.model.vo.ProductSalesVo">
- INSERT INTO cm_product_sales(productId, product, shop, productCount, property)
- VALUES (#{productId}, #{productName}, #{shopName}, #{productCount}, #{property})
- </insert>
- <insert id="insertProductSalesRecord">
- INSERT INTO cm_product_sales_record(productId, sales, saleTime)
- VALUES (#{productId}, #{sales}, NOW())
- </insert>
- <update id="updateProductSales" parameterType="com.caimei365.commodity.model.vo.ProductSalesVo">
- UPDATE cm_product_sales
- SET product=#{productName},
- shop=#{shopName},
- productCount=#{productCount},
- property=#{property}
- WHERE productId = #{productId}
- </update>
- <select id="getClubTypeById" resultType="java.lang.Integer">
- SELECT firstClubType
- FROM club
- WHERE userID = #{userId}
- </select>
- <select id="getShopIdByUserId" resultType="java.lang.Integer">
- SELECT shopID
- FROM shop
- WHERE userID = #{userId}
- </select>
- <select id="findSkus" resultType="com.caimei365.commodity.model.dto.Sku">
- select skuId,
- price,
- normalPrice,
- costPrice,
- ifnull(ladderPriceFlag, 0) as ladderPriceFlag,
- costCheckFlag,
- costProportional,
- stock,
- unit,
- minBuyNumber
- from cm_sku
- where productId = #{productId}
- ORDER BY price ASC
- </select>
- <select id="findLowPrice" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
- select plp.buyPrice as price, cs.unit as unit, cs.minBuyNumber as minBuyNumber, cs.skuId as skuId
- from product_ladder_price plp
- left join cm_sku cs on plp.skuId = cs.skuId
- where plp.productId = #{productId}
- order by buyPrice asc
- limit 1
- </select>
- </mapper>
|