PortalProductDao.xml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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.macro.mall.portal.dao.PortalProductDao">
  4. <resultMap id="cartProductMap" type="com.macro.mall.portal.domain.CartProduct" autoMapping="true">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <collection property="productAttributeList" columnPrefix="attr_" resultMap="com.macro.mall.mapper.PmsProductAttributeMapper.BaseResultMap">
  7. </collection>
  8. <collection property="skuStockList" columnPrefix="sku_" resultMap="com.macro.mall.mapper.PmsSkuStockMapper.BaseResultMap">
  9. </collection>
  10. </resultMap>
  11. <resultMap id="promotionProductMap" type="com.macro.mall.portal.domain.PromotionProduct" extends="com.macro.mall.mapper.PmsProductMapper.BaseResultMap">
  12. <id column="id" jdbcType="BIGINT" property="id" />
  13. <collection property="skuStockList" columnPrefix="sku_" resultMap="com.macro.mall.mapper.PmsSkuStockMapper.BaseResultMap">
  14. </collection>
  15. <collection property="productLadderList" columnPrefix="ladder_" resultMap="com.macro.mall.mapper.PmsProductLadderMapper.BaseResultMap">
  16. </collection>
  17. <collection property="productFullReductionList" columnPrefix="full_" resultMap="com.macro.mall.mapper.PmsProductFullReductionMapper.BaseResultMap">
  18. </collection>
  19. </resultMap>
  20. <select id="getCartProduct" resultMap="cartProductMap">
  21. SELECT
  22. p.id id,
  23. p.`name` name,
  24. p.sub_title subTitle,
  25. p.price price,
  26. p.pic pic,
  27. p.product_attribute_category_id productAttributeCategoryId,
  28. p.stock stock,
  29. pa.id attr_id,
  30. pa.`name` attr_name,
  31. ps.id sku_id,
  32. ps.sku_code sku_code,
  33. ps.price sku_price,
  34. ps.sp1 sku_sp1,
  35. ps.sp2 sku_sp2,
  36. ps.sp3 sku_sp3,
  37. ps.stock sku_stock,
  38. ps.pic sku_pic
  39. FROM
  40. pms_product p
  41. LEFT JOIN pms_product_attribute pa ON p.product_attribute_category_id = pa.product_attribute_category_id
  42. LEFT JOIN pms_sku_stock ps ON p.id=ps.product_id
  43. WHERE
  44. p.id = #{id}
  45. AND pa.type = 0
  46. ORDER BY pa.sort desc
  47. </select>
  48. <select id="getPromotionProductList" resultMap="promotionProductMap">
  49. SELECT
  50. p.id,
  51. p.`name`,
  52. p.promotion_type,
  53. p.gift_growth,
  54. p.gift_point,
  55. sku.id sku_id,
  56. sku.price sku_price,
  57. sku.sku_code sku_sku_code,
  58. sku.promotion_price sku_promotion_price,
  59. sku.stock sku_stock,
  60. sku.lock_stock sku_lock_stock,
  61. ladder.id ladder_id,
  62. ladder.count ladder_count,
  63. ladder.discount ladder_discount,
  64. full_re.id full_id,
  65. full_re.full_price full_full_price,
  66. full_re.reduce_price full_reduce_price
  67. FROM
  68. pms_product p
  69. LEFT JOIN pms_sku_stock sku ON p.id = sku.product_id
  70. LEFT JOIN pms_product_ladder ladder ON p.id = ladder.product_id
  71. LEFT JOIN pms_product_full_reduction full_re ON p.id = full_re.product_id
  72. WHERE
  73. p.id IN
  74. <foreach collection="ids" open="(" close=")" item="id" separator=",">
  75. #{id}
  76. </foreach>
  77. </select>
  78. </mapper>