PriceMapper.xml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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.caimei365.commodity.mapper.PriceMapper">
  4. <select id="getIdentityByUserId" resultType="java.lang.Integer">
  5. select userIdentity
  6. from user
  7. where userID = #{userId}
  8. </select>
  9. <select id="getDetailPrice" resultType="com.caimei365.commodity.model.vo.PriceVo">
  10. select p.productID as productId,
  11. p.actStatus,
  12. (select normalPrice from cm_sku where productId=#{productId} order by price asc limit 1) as normalPrice,
  13. p.maxBuyNumber,
  14. p.priceFlag,
  15. p.step,
  16. p.shopID as shopId,
  17. p.taxPoint as taxRate,
  18. p.includedTax,
  19. p.invoiceType,
  20. if(csp.id is not null, 1, 0) as svipProductFlag,
  21. csp.priceType as svipPriceType,
  22. csp.discount as svipDiscount,
  23. csp.discountPrice as svipDiscountPrice,
  24. p.productType
  25. from product p
  26. left join cm_svip_product csp on p.productID = csp.productId
  27. where p.productID = #{productId}
  28. </select>
  29. <select id="getListPriceByProductIds" resultType="com.caimei365.commodity.model.vo.PriceVo">
  30. select
  31. p.productID as productId,
  32. p.actStatus,
  33. p.maxBuyNumber,
  34. p.priceFlag,
  35. p.step,
  36. p.shopID as shopId,
  37. p.includedTax,
  38. p.invoiceType,
  39. p.taxPoint as taxRate,
  40. if(csp.id is not null,1,0) as svipProductFlag,
  41. csp.priceType as svipPriceType,
  42. csp.discount as svipDiscount,
  43. csp.discountPrice as svipDiscountPrice,
  44. p.productType,
  45. p.newvalidFlag
  46. from product p
  47. left join cm_svip_product csp on p.productID = csp.productId
  48. where p.productID in
  49. <foreach collection="productIds" open="(" separator="," close=")" item="productId">
  50. #{productId}
  51. </foreach>
  52. </select>
  53. <select id="getLadderPricesByProductId" resultType="com.caimei365.commodity.model.vo.LadderPriceVo">
  54. select id,
  55. productId,
  56. ladderNum,
  57. buyNum,
  58. buyPrice
  59. from product_ladder_price
  60. where skuId = #{skuId}
  61. and userType = 3
  62. and delFlag = 0
  63. order by ladderNum asc
  64. </select>
  65. <select id="findLowerLadderPrice" resultType="com.caimei365.commodity.model.vo.LadderPriceVo">
  66. select id,
  67. skuId,
  68. productId,
  69. ladderNum,
  70. buyNum,
  71. buyPrice
  72. from product_ladder_price
  73. where skuId = #{skuId}
  74. and userType = 3
  75. and delFlag = 0
  76. order by ladderNum DESC
  77. limit 1
  78. </select>
  79. <select id="findMaxLadderPrice" resultType="com.caimei365.commodity.model.vo.LadderPriceVo">
  80. select id,
  81. skuId,
  82. productId,
  83. ladderNum,
  84. buyNum,
  85. buyPrice
  86. from product_ladder_price
  87. where skuId = #{skuId}
  88. and userType = 3
  89. and delFlag = 0
  90. order by ladderNum asc
  91. limit 1
  92. </select>
  93. <select id="getRepurchasePrice" resultType="java.lang.Double">
  94. select r.currentPrice,
  95. p.productType
  96. from repeat_purchase_price r
  97. left join product p on p.productID = r.productId
  98. left join cm_sku cs on r.skuId = cs.skuId
  99. where r.skuId = #{skuId}
  100. and userId = #{userId}
  101. and ((cs.costCheckFlag = 1 and r.currentPrice <![CDATA[ >= ]]> cs.costPrice) or cs.costCheckFlag = 2)
  102. and cs.price <![CDATA[ >= ]]> r.currentPrice
  103. and r.delFlag = 0
  104. </select>
  105. <select id="getTaxByProductId" resultType="com.caimei365.commodity.model.vo.TaxVo">
  106. select p.includedTax as includedTax,
  107. p.invoiceType as invoiceType,
  108. p.taxPoint as taxPoint,
  109. p.productType
  110. from product p
  111. where productID = #{productId}
  112. </select>
  113. <select id="getSvipUserIdByUserId" resultType="java.lang.Integer">
  114. select userId
  115. from cm_svip_user
  116. where now() <![CDATA[ < ]]> endTime
  117. and delFlag = '0'
  118. and userId = #{userId}
  119. </select>
  120. <select id="getProductSalesInfo" resultType="com.caimei365.commodity.model.vo.ProductSalesVo">
  121. select p.productID AS productId,
  122. p.name AS productName,
  123. p.shopID AS shopId,
  124. p.commodityType,
  125. p.bigTypeID as bigTypeId,
  126. p.smallTypeID as smallTypeId,
  127. p.tinyTypeID as tinyTypeId,
  128. s.productId AS id,
  129. s.shop AS shopName,
  130. s.productCount AS productCount,
  131. s.property AS property,
  132. p.productType
  133. FROM product p
  134. LEFT JOIN cm_product_sales s ON p.productID = s.productId
  135. where p.productId = #{productId}
  136. </select>
  137. <insert id="insertProductSales" parameterType="com.caimei365.commodity.model.vo.ProductSalesVo">
  138. INSERT INTO cm_product_sales(productId, product, shop, productCount, property)
  139. VALUES (#{productId}, #{productName}, #{shopName}, #{productCount}, #{property})
  140. </insert>
  141. <insert id="insertProductSalesRecord">
  142. INSERT INTO cm_product_sales_record(productId, sales, saleTime)
  143. VALUES (#{productId}, #{sales}, NOW())
  144. </insert>
  145. <update id="updateProductSales" parameterType="com.caimei365.commodity.model.vo.ProductSalesVo">
  146. UPDATE cm_product_sales
  147. SET product=#{productName},
  148. shop=#{shopName},
  149. productCount=#{productCount},
  150. property=#{property}
  151. WHERE productId = #{productId}
  152. </update>
  153. <select id="getClubTypeById" resultType="java.lang.Integer">
  154. SELECT firstClubType
  155. FROM club
  156. WHERE userID = #{userId}
  157. </select>
  158. <select id="getShopIdByUserId" resultType="java.lang.Integer">
  159. SELECT shopID
  160. FROM shop
  161. WHERE userID = #{userId}
  162. </select>
  163. <select id="findSkus" resultType="com.caimei365.commodity.model.dto.Sku">
  164. select skuId,
  165. price,
  166. normalPrice,
  167. costPrice,
  168. ifnull(ladderPriceFlag, 0) as ladderPriceFlag,
  169. costCheckFlag,
  170. costProportional,
  171. stock,
  172. unit,
  173. minBuyNumber
  174. from cm_sku
  175. where productId = #{productId}
  176. ORDER BY price ASC
  177. </select>
  178. <select id="findLowPrice" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
  179. select plp.buyPrice as price, cs.unit as unit, cs.minBuyNumber as minBuyNumber, cs.skuId as skuId
  180. from product_ladder_price plp
  181. left join cm_sku cs on plp.skuId = cs.skuId
  182. where plp.productId = #{productId}
  183. order by buyPrice asc
  184. limit 1
  185. </select>
  186. </mapper>