ShoppingDao.xml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.www.mapper.ShoppingDao">
  4. <select id="getHeadCarts" resultType="com.caimei.www.pojo.order.CartItem">
  5. select
  6. p.productID as id,
  7. p.`name` as `name`,
  8. p.mainImage as image,
  9. p.price1 as price,
  10. p.unit as unit,
  11. c.productCount as number
  12. from cm_cart c
  13. left join product p on c.productID=p.productID
  14. where p.validFlag='2'
  15. and c.userID = #{userId}
  16. and p.price1TextFlag != '1'
  17. and p.stock != '0'
  18. and p.stock <![CDATA[ >= ]]> c.productCount
  19. </select>
  20. <select id="getCartSuppliers" resultType="com.caimei.www.pojo.order.CartSupplier">
  21. select
  22. s.shopID as id,
  23. s.name,
  24. s.logo
  25. from cm_cart c
  26. left join product p on c.productID = p.productID
  27. left join shop s on p.shopID = s.shopID
  28. where c.userID = #{userId}
  29. group by s.shopID
  30. order by MAX(c.addTime) desc
  31. </select>
  32. <select id="getShoppingCartBySupplierId" resultType="com.caimei.www.pojo.order.CartItem">
  33. select
  34. c.cm_cartID as id,
  35. p.productID as productId,
  36. p.`name` as `name`,
  37. p.mainImage as image,
  38. p.price1 as price,
  39. p.unit as unit,
  40. p.step as step,
  41. p.minBuyNumber as min,
  42. p.price1TextFlag as priceFlag,
  43. p.ladderPriceFlag as ladderFlag,
  44. p.validFlag as validFlag,
  45. p.stock as stock,
  46. c.productCount as number
  47. from product p
  48. left join cm_cart c on c.productID = p.productID
  49. where p.shopID = #{supplierId} and c.userID = #{userId}
  50. order by c.addTime desc
  51. </select>
  52. <select id="getActivityPriceByProductId" resultType="com.caimei.www.pojo.order.ActivityPrice">
  53. select ca.id,
  54. cpa.productId,
  55. cpa.actPrice as price,
  56. ca.startTime as beginTime,
  57. ca.endTime as endTime
  58. from cm_product_activity cpa
  59. left join cm_activity ca on cpa.activityId = ca.id
  60. where cpa.productId = #{productId}
  61. and ca.startTime <![CDATA[ <= ]]> NOW()
  62. and NOW() <![CDATA[ <= ]]> ca.endTime
  63. and cpa.delFlag = 0
  64. </select>
  65. <select id="getladderPricesByProductId" resultType="com.caimei.www.pojo.order.LadderPrice">
  66. select
  67. id, productId, ladderNum, buyNum, buyPrice
  68. from product_ladder_price
  69. where productId = #{productId} and userType = 3 and delFlag = 0
  70. order by ladderNum asc
  71. </select>
  72. <select id="getRepurchasePrice" resultType="java.lang.Double">
  73. select
  74. r.currentPrice
  75. from repeat_purchase_price r
  76. left join product p on p.productID = r.productId
  77. where r.productId = #{productId} and userId = #{userId}
  78. and ((p.costCheckFlag=1 and r.currentPrice <![CDATA[ >= ]]> p.costPrice) or p.costCheckFlag=0)
  79. and r.delFlag = 0
  80. </select>
  81. </mapper>