PurchaseProductMapper.xml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.caimei.modules.bulkpurchase.dao.PurchaseProductDao">
  4. <select id="findList" resultType="PurchaseProduct">
  5. SELECT b.name shopName ,b.`shopID` shopId,a.name purchaseProductName,
  6. a.`productID` productId,a.productCode productNo,a.mainImage image,a.includedTax AS includedTax,a.machineType,
  7. a.invoiceType AS invoiceType, a.taxPoint AS taxRate, a.supplierTaxPoint AS supplierTaxRate, a.commodityType,
  8. if(csp.id is not null and csu.id is not null and csp.status=0,1,0) as svipPriceFlag
  9. FROM product a LEFT JOIN shop b ON b.shopID=a.shopID
  10. left join cm_svip_product csp on a.productID = csp.productId
  11. left join cm_svip_user csu on csu.userId = #{userId} and csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
  12. <where>
  13. <if test="purchaseProductName != null and purchaseProductName != ''">
  14. AND a.name LIKE concat('%',#{purchaseProductName},'%')
  15. </if>
  16. <if test="productId != null and productId != ''">
  17. AND a.productID = #{productId}
  18. </if>
  19. <if test="shopName != null and shopName != ''">
  20. AND b.name like concat('%',#{shopName},'%')
  21. </if>
  22. and (a.validFlag=2 or a.validFlag = 9)
  23. AND a.productID != 999
  24. and a.productCategory = 1
  25. </where>
  26. <choose>
  27. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  28. ORDER BY ${page.orderBy}
  29. </when>
  30. <otherwise>
  31. </otherwise>
  32. </choose>
  33. </select>
  34. <select id="findSencondProductPage" resultType="com.caimei.modules.bulkpurchase.entity.PurchaseProduct">
  35. SELECT b.name as shopName ,b.`shopID` as shopId,a.name purchaseProductName,
  36. cs.price,a.`productID` as productId,a.productCode productNo,a.mainImage image
  37. ,cs.costCheckFlag,cs.costPrice,cs.shopPercent, cs.normalPrice
  38. ,a.productCategory as "productCategory",cshd.secondHandType as "secondHandType",cs.ladderPriceFlag
  39. ,a.includedTax,a.invoiceType
  40. FROM product a LEFT JOIN shop b ON b.shopID=a.shopID
  41. left join cm_sku cs on a.productID=cs.productId
  42. left join cm_second_hand_detail cshd on cshd.productID = a.productID
  43. <where>
  44. <if test="purchaseProductName != null and purchaseProductName != ''">
  45. AND a.name LIKE concat('%',#{purchaseProductName},'%')
  46. </if>
  47. <if test="productId != null and productId != ''">
  48. AND a.productID = #{productId}
  49. </if>
  50. <if test="shopName != null and shopName != ''">
  51. AND b.name like concat('%',#{shopName},'%')是否含税
  52. </if>
  53. and a.validFlag=2
  54. AND a.productID != 999
  55. and a.productCategory = 2
  56. and cshd.sold != 1
  57. </where>
  58. </select>
  59. <select id="findLadderPriceList" resultType="com.caimei.po.ProductLadderPrice">
  60. SELECT *
  61. FROM product_ladder_price
  62. WHERE productId = #{productId}
  63. AND buyNum is NOT null
  64. AND buyPrice is NOT null
  65. AND delFlag = 0
  66. ORDER BY ladderNum ASC
  67. </select>
  68. <select id="getSvipProduct" resultType="com.caimei.modules.svip.entity.CmSvipProduct">
  69. select ccs.priceType,
  70. if(csp.id is not null and csu.id is not null and csp.status=0, 1, 0) as svipPriceFlag
  71. from cm_svip_product csp
  72. left join cm_svip_user csu
  73. on csu.userId = #{userId} and csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
  74. left join (select csps.productId,csps.priceType from cm_svip_product_sku csps left join cm_sku cs on csps.skuId=cs.skuId
  75. where csps.productId=#{productId} order by cs.price asc limit 1) ccs on csp.productId=ccs.productId
  76. where csp.productId = #{productId};
  77. </select>
  78. <select id="findVipSku" resultType="com.caimei.modules.product.entity.CmSku">
  79. select discountPrice,discount,priceType
  80. from cm_svip_product_sku csps
  81. left join cm_sku cs on csps.productId = cs.productId
  82. where csps.productId=#{productId}
  83. order by cs.price asc limit 1
  84. </select>
  85. </mapper>