ChannelProdMapper.xml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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.yami.shop.dao.ChannelProdMapper">
  4. <resultMap id="BaseResultMap" type="com.yami.shop.bean.model.ChannelProd">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="channel_id" jdbcType="BIGINT" property="channelId"/>
  7. <result column="sku_id" jdbcType="BIGINT" property="skuId"/>
  8. <result column="purchase_price" jdbcType="DECIMAL" property="purchasePrice"/>
  9. <result column="delivery_price" jdbcType="DECIMAL" property="deliveryPrice"/>
  10. <result column="channel_prod_price" jdbcType="DECIMAL" property="channelProdPrice"/>
  11. <result column="is_delete" jdbcType="TINYINT" property="isDelete"/>
  12. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  13. <result column="rec_time" jdbcType="TIMESTAMP" property="recTime"/>
  14. </resultMap>
  15. <select id="getChannelProdsBychannelId" resultMap="BaseResultMap">
  16. SELECT *
  17. FROM tz_channel_prod
  18. WHERE channel_id = #{channelId}
  19. AND is_delete = 0
  20. ORDER BY rec_time DESC
  21. </select>
  22. <select id="getChannelProdsBySkuId" resultMap="BaseResultMap">
  23. SELECT *
  24. FROM tz_channel_prod
  25. WHERE sku_id = #{skuId}
  26. AND is_delete = 0
  27. ORDER BY rec_time DESC
  28. </select>
  29. <select id="getChannelProdBychannelIdAndSkuId" resultMap="BaseResultMap">
  30. SELECT *
  31. FROM tz_channel_prod
  32. WHERE channel_id = #{channelId}
  33. AND sku_id = #{skuId}
  34. AND is_delete = 0
  35. </select>
  36. <select id="getChannelProdPage" resultMap="BaseResultMap">
  37. # 关联查询查询条件
  38. SELECT * FROM tz_channel_prod
  39. <where>
  40. is_delete = 0
  41. <if test="channelProd.channelId != null">
  42. AND channel_id = #{channelProd.channelId}
  43. </if>
  44. <if test="channelProd.skuId != null">
  45. AND sku_id = #{channelProd.skuId}
  46. </if>
  47. <if test="channelProd.purchasePrice != null">
  48. AND purchase_price = #{channelProd.purchasePrice}
  49. </if>
  50. <if test="channelProd.deliveryPrice != null">
  51. AND delivery_price = #{channelProd.deliveryPrice}
  52. </if>
  53. <if test="channelProd.channelProdPrice != null">
  54. AND channel_prod_price = #{channelProd.channelProdPrice}
  55. </if>
  56. </where>
  57. ORDER BY rec_time DESC
  58. </select>
  59. <update id="deleteBychannelId">
  60. UPDATE tz_channel_prod
  61. SET is_delete = 1,
  62. update_time = NOW()
  63. WHERE channel_id = #{channelId}
  64. </update>
  65. <update id="deleteBySkuId">
  66. UPDATE tz_channel_prod
  67. SET is_delete = 1,
  68. update_time = NOW()
  69. WHERE sku_id = #{skuId}
  70. </update>
  71. <update id="deleteChannelProd">
  72. UPDATE tz_channel_prod
  73. SET is_delete = 1,
  74. update_time = NOW()
  75. WHERE sku_id = #{skuId} AND shop_id = #{shopId}
  76. </update>
  77. <update id="updateBatchPrices">
  78. <foreach collection="channelProds" item="channelProd" separator=";">
  79. UPDATE tz_channel_prod
  80. SET purchase_price = #{channelProd.purchasePrice},
  81. delivery_price = #{channelProd.deliveryPrice},
  82. channel_prod_price = #{channelProd.channelProdPrice},
  83. update_time = NOW()
  84. WHERE id = #{channelProd.id}
  85. </foreach>
  86. </update>
  87. <select id="countBychannelId" resultType="java.lang.Integer">
  88. SELECT COUNT(*)
  89. FROM tz_channel_prod
  90. WHERE channel_id = #{channelId}
  91. AND is_delete = 0
  92. </select>
  93. <select id="countBySkuId" resultType="java.lang.Integer">
  94. SELECT COUNT(*)
  95. FROM tz_channel_prod
  96. WHERE sku_id = #{skuId}
  97. AND is_delete = 0
  98. </select>
  99. <select id="selectListAll" resultType="com.yami.shop.bean.vo.ProdChannelVO">
  100. SELECT c.id,c.channel_id channelId, c.channel_prod_price price,c.update_time updateTime, channel.channel_name channelName,s.shop_name shopName
  101. FROM tz_channel_prod c
  102. left join tz_shop_detail s on c.shop_id = s.shop_id
  103. left join tz_channel channel on c.channel_id = channel.id
  104. WHERE c.sku_id = #{skuId}
  105. AND c.shop_id = #{shopId}
  106. AND c.is_delete = 0
  107. </select>
  108. </mapper>