123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?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.bulkpurchase.dao.PurchaseProductDao">
- <select id="findList" resultType="PurchaseProduct">
- SELECT b.name shopName ,b.`shopID` shopId,a.name purchaseProductName,
- a.`productID` productId,a.productCode productNo,a.mainImage image,a.includedTax AS includedTax,a.machineType,
- a.invoiceType AS invoiceType, a.taxPoint AS taxRate, a.supplierTaxPoint AS supplierTaxRate, a.commodityType,
- if(csp.id is not null and csu.id is not null and csp.status=0,1,0) as svipPriceFlag
- FROM product a LEFT JOIN shop b ON b.shopID=a.shopID
- left join cm_svip_product csp on a.productID = csp.productId
- left join cm_svip_user csu on csu.userId = #{userId} and csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
- <where>
- <if test="purchaseProductName != null and purchaseProductName != ''">
- AND a.name LIKE concat('%',#{purchaseProductName},'%')
- </if>
- <if test="productId != null and productId != ''">
- AND a.productID = #{productId}
- </if>
- <if test="shopName != null and shopName != ''">
- AND b.name like concat('%',#{shopName},'%')
- </if>
- and (a.validFlag=2 or a.validFlag = 9)
- AND a.productID != 999
- and a.productCategory = 1
- </where>
- <choose>
- <when test="page !=null and page.orderBy != null and page.orderBy != ''">
- ORDER BY ${page.orderBy}
- </when>
- <otherwise>
- </otherwise>
- </choose>
- </select>
- <select id="findSencondProductPage" resultType="com.caimei.modules.bulkpurchase.entity.PurchaseProduct">
- SELECT b.name as shopName ,b.`shopID` as shopId,a.name purchaseProductName,
- cs.price,a.`productID` as productId,a.productCode productNo,a.mainImage image
- ,cs.costCheckFlag,cs.costPrice,cs.shopPercent, cs.normalPrice
- ,a.productCategory as "productCategory",cshd.secondHandType as "secondHandType",cs.ladderPriceFlag
- ,a.includedTax,a.invoiceType
- FROM product a LEFT JOIN shop b ON b.shopID=a.shopID
- left join cm_sku cs on a.productID=cs.productId
- left join cm_second_hand_detail cshd on cshd.productID = a.productID
- <where>
- <if test="purchaseProductName != null and purchaseProductName != ''">
- AND a.name LIKE concat('%',#{purchaseProductName},'%')
- </if>
- <if test="productId != null and productId != ''">
- AND a.productID = #{productId}
- </if>
- <if test="shopName != null and shopName != ''">
- AND b.name like concat('%',#{shopName},'%')是否含税
- </if>
- and a.validFlag=2
- AND a.productID != 999
- and a.productCategory = 2
- and cshd.sold != 1
- </where>
- </select>
- <select id="findLadderPriceList" resultType="com.caimei.po.ProductLadderPrice">
- SELECT *
- FROM product_ladder_price
- WHERE productId = #{productId}
- AND buyNum is NOT null
- AND buyPrice is NOT null
- AND delFlag = 0
- ORDER BY ladderNum ASC
- </select>
- <select id="getSvipProduct" resultType="com.caimei.modules.svip.entity.CmSvipProduct">
- select ccs.priceType,
- if(csp.id is not null and csu.id is not null and csp.status=0, 1, 0) as svipPriceFlag
- from cm_svip_product csp
- left join cm_svip_user csu
- on csu.userId = #{userId} and csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
- left join (select csps.productId,csps.priceType from cm_svip_product_sku csps left join cm_sku cs on csps.skuId=cs.skuId
- where csps.productId=#{productId} order by cs.price asc limit 1) ccs on csp.productId=ccs.productId
- where csp.productId = #{productId};
- </select>
- <select id="findVipSku" resultType="com.caimei.modules.product.entity.CmSku">
- select discountPrice,discount,priceType
- from cm_svip_product_sku csps
- left join cm_sku cs on csps.productId = cs.productId
- where csps.productId=#{productId}
- order by cs.price asc limit 1
- </select>
- </mapper>
|