MkStoreCampMinusGoodsDao.xml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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.kmall.admin.dao.mk.store.MkStoreCampMinusGoodsDao">
  4. <resultMap type="com.kmall.admin.entity.mk.store.MkStoreCampMinusGoodsEntity" id="mkStoreCampMinusGoodsMap">
  5. <result property="minusGoodId" column="minus_good_id"/>
  6. <result property="campMinusId" column="camp_minus_id"/>
  7. <result property="applyType" column="apply_type"/>
  8. <result property="storeRelaId" column="store_rela_id"/>
  9. <result property="isValid" column="is_valid"/>
  10. <result property="note" column="note"/>
  11. <result property="createrSn" column="creater_sn"/>
  12. <result property="createTime" column="create_time"/>
  13. <result property="moderSn" column="moder_sn"/>
  14. <result property="modTime" column="mod_time"/>
  15. <result property="tstm" column="tstm"/>
  16. </resultMap>
  17. <select id="queryObject" resultType="com.kmall.admin.entity.mk.store.MkStoreCampMinusGoodsEntity">
  18. select
  19. `minus_good_id`,
  20. `camp_minus_id`,
  21. `apply_type`,
  22. `store_rela_id`,
  23. `is_valid`,
  24. `note`,
  25. `creater_sn`,
  26. `create_time`,
  27. `moder_sn`,
  28. `mod_time`,
  29. `tstm`
  30. from mk_store_camp_minus_goods
  31. where minus_good_id = #{id}
  32. </select>
  33. <select id="queryList" resultType="com.kmall.admin.entity.mk.store.MkStoreCampMinusGoodsEntity">
  34. select
  35. `minus_good_id`,
  36. `camp_minus_id`,
  37. `apply_type`,
  38. `store_rela_id`,
  39. `is_valid`,
  40. `note`,
  41. `creater_sn`,
  42. `create_time`,
  43. `moder_sn`,
  44. `mod_time`,
  45. `tstm`
  46. from mk_store_camp_minus_goods
  47. WHERE 1=1
  48. <if test="name != null and name.trim() != ''">
  49. AND name LIKE concat('%',#{name},'%')
  50. </if>
  51. <choose>
  52. <when test="sidx != null and sidx.trim() != ''">
  53. order by ${sidx} ${order}
  54. </when>
  55. <otherwise>
  56. order by minus_good_id desc
  57. </otherwise>
  58. </choose>
  59. <if test="offset != null and limit != null">
  60. limit #{offset}, #{limit}
  61. </if>
  62. </select>
  63. <select id="queryTotal" resultType="int">
  64. select count(*) from mk_store_camp_minus_goods
  65. WHERE 1=1
  66. <if test="name != null and name.trim() != ''">
  67. AND name LIKE concat('%',#{name},'%')
  68. </if>
  69. </select>
  70. <insert id="save" parameterType="com.kmall.admin.entity.mk.store.MkStoreCampMinusGoodsEntity" useGeneratedKeys="true" keyProperty="minusGoodId">
  71. insert into mk_store_camp_minus_goods(
  72. `camp_minus_id`,
  73. `apply_type`,
  74. `store_rela_id`,
  75. `is_valid`,
  76. `note`,
  77. `creater_sn`,
  78. `create_time`,
  79. `moder_sn`,
  80. `mod_time`,
  81. `tstm`)
  82. values(
  83. #{campMinusId},
  84. #{applyType},
  85. #{storeRelaId},
  86. #{isValid},
  87. #{note},
  88. #{createrSn},
  89. #{createTime},
  90. #{moderSn},
  91. #{modTime},
  92. #{tstm})
  93. </insert>
  94. <update id="update" parameterType="com.kmall.admin.entity.mk.store.MkStoreCampMinusGoodsEntity">
  95. update mk_store_camp_minus_goods
  96. <set>
  97. <if test="campMinusId != null">`camp_minus_id` = #{campMinusId}, </if>
  98. <if test="applyType != null">`apply_type` = #{applyType}, </if>
  99. <if test="storeRelaId != null">`store_rela_id` = #{storeRelaId}, </if>
  100. <if test="isValid != null">`is_valid` = #{isValid}, </if>
  101. <if test="note != null">`note` = #{note}, </if>
  102. <if test="createrSn != null">`creater_sn` = #{createrSn}, </if>
  103. <if test="createTime != null">`create_time` = #{createTime}, </if>
  104. <if test="moderSn != null">`moder_sn` = #{moderSn}, </if>
  105. <if test="modTime != null">`mod_time` = #{modTime}, </if>
  106. <if test="tstm != null">`tstm` = #{tstm}</if>
  107. </set>
  108. where minus_good_id = #{minusGoodId}
  109. </update>
  110. <delete id="delete">
  111. delete from mk_store_camp_minus_goods where minus_good_id = #{value}
  112. </delete>
  113. <delete id="deleteBatch">
  114. delete from mk_store_camp_minus_goods where minus_good_id in
  115. <foreach item="minusGoodId" collection="array" open="(" separator="," close=")">
  116. #{minusGoodId}
  117. </foreach>
  118. </delete>
  119. <select id="queryCampMinusGoodsByIdList" resultType="com.kmall.admin.entity.mk.store.MkStoreCampMinusGoodsEntity">
  120. SELECT
  121. g.NAME 'goodsName',
  122. s.store_name 'storeName',
  123. r.retail_price 'retailPrice',
  124. r.market_price 'marketPrice',
  125. g.is_on_sale 'isOnSale',
  126. m.minus_good_id,
  127. (
  128. SELECT
  129. sum( o.actual_price )
  130. FROM
  131. mall_order o
  132. INNER JOIN mall_order_goods og ON o.id = og.order_id
  133. WHERE
  134. og.goods_id = r.goods_id
  135. AND o.store_id = cm.store_id
  136. AND o.activity_id = cm.store_topic_id
  137. ) 'actualTotalPrice'
  138. FROM
  139. mk_store_camp_minus_goods m
  140. LEFT JOIN mk_store_camp_minus cm ON m.camp_minus_id = cm.camp_minus_id
  141. LEFT JOIN mall_product_store_rela r ON m.store_rela_id = r.id
  142. LEFT JOIN mall_store s ON r.store_id = s.id
  143. LEFT JOIN mall_goods g ON r.goods_id = g.id
  144. WHERE 1=1
  145. <if test="goodsName != null and goodsName.trim() != ''">
  146. AND g.NAME LIKE concat('%',#{goodsName},'%')
  147. </if>
  148. <if test="campMinusId != null and campMinusId != ''">
  149. AND m.camp_minus_id = #{campMinusId}
  150. </if>
  151. <if test="offset != null and limit != null">
  152. limit #{offset}, #{limit}
  153. </if>
  154. </select>
  155. <select id="queryCampMinusGoodsByIdTotal" resultType="int">
  156. select count(*) FROM
  157. mk_store_camp_minus_goods m
  158. LEFT JOIN mk_store_camp_minus cm ON m.camp_minus_id = cm.camp_minus_id
  159. LEFT JOIN mall_product_store_rela r ON m.store_rela_id = r.id
  160. LEFT JOIN mall_store s ON r.store_id = s.id
  161. LEFT JOIN mall_goods g ON r.goods_id = g.id
  162. WHERE 1=1
  163. <if test="goodsName != null and goodsName.trim() != ''">
  164. AND g.NAME LIKE concat('%',#{goodsName},'%')
  165. </if>
  166. <if test="campMinusId != null and campMinusId != ''">
  167. AND m.camp_minus_id = #{campMinusId}
  168. </if>
  169. </select>
  170. <select id="queryCampMinusStoreTopicById" resultType="com.kmall.admin.entity.mk.store.MkStoreCampMinusGoodsEntity">
  171. select
  172. g.`minus_good_id`,
  173. g.`camp_minus_id`,
  174. g.`apply_type`,
  175. g.`store_rela_id`,
  176. g.`is_valid`,
  177. g.`note`,
  178. g.`creater_sn`,
  179. g.`create_time`,
  180. g.`moder_sn`,
  181. g.`mod_time`,
  182. g.`tstm`,
  183. m.store_topic_id 'storeTopicId'
  184. FROM
  185. `mk_store_camp_minus_goods` g
  186. INNER JOIN mk_store_camp_minus m ON g.camp_minus_id = m.camp_minus_id
  187. where minus_good_id = #{minusGoodId}
  188. </select>
  189. <delete id="deleteMinusGoodsByMinusId">
  190. delete from mk_store_camp_minus_goods where camp_minus_id = #{campMinusId}
  191. </delete>
  192. </mapper>