GoodsMapper.xml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  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. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.biz.dal.dao.GoodsDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.Goods" id="Goods">
  9. <result column="id_" property="id"/>
  10. <result column="goods_category_id_" property="goodsCategoryId"/>
  11. <result column="goods_category_name_" property="goodsCategoryName"/>
  12. <result column="sn_" property="sn"/>
  13. <result column="name_" property="name"/>
  14. <result column="brand_" property="brand"/>
  15. <result column="specification_" property="specification"/>
  16. <result column="image_" property="image"/>
  17. <result column="stock_count_" property="stockCount"/>
  18. <result column="tax_stock_count_" property="taxStockCount"/>
  19. <result column="sell_count_" property="sellCount"/>
  20. <result column="market_price_" property="marketPrice"/>
  21. <result column="discount_price_" property="discountPrice"/>
  22. <result column="group_purchase_price_" property="groupPurchasePrice"/>
  23. <result column="agree_cost_price_" property="agreeCostPrice"/>
  24. <result column="brief_" property="brief"/>
  25. <result column="desc_" property="desc"/>
  26. <result column="is_new_" property="isNew" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  27. <result column="is_top_" property="isTop" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  28. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  29. <result column="memo_" property="memo"/>
  30. <result column="publish_time_" property="publishTime"/>
  31. <result column="create_time_" property="createTime"/>
  32. <result column="update_time_" property="updateTime"/>
  33. <result column="complement_goods_id_list_" property="complementGoodsIdList"/>
  34. <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  35. <result column="supply_channel_" property="supplyChannel" />
  36. <result column="stock_type_" property="stockType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  37. <result column="client_show_" property="clientShow" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  38. <result column="educational_show_" property="educationalShow" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  39. <result column="music_group_show_" property="musicGroupShow" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  40. <result column="replacement_show_" property="replacementShow" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  41. <result column="stock_warning_" property="stockWarning" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  42. </resultMap>
  43. <!-- 根据主键查询一条记录 -->
  44. <select id="get" resultMap="Goods" useCache="false" flushCache="true">
  45. SELECT * FROM goods WHERE id_ = #{id}
  46. </select>
  47. <select id="lock" resultMap="Goods" useCache="false" flushCache="true">
  48. SELECT * FROM goods WHERE id_ = #{goodsId} LOCK IN SHARE MODE
  49. </select>
  50. <!-- 全查询 -->
  51. <select id="findAll" resultMap="Goods">
  52. SELECT * FROM goods ORDER BY id_
  53. </select>
  54. <!-- 向数据库增加一条记录 -->
  55. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.Goods" useGeneratedKeys="true" keyColumn="id"
  56. keyProperty="id">
  57. INSERT INTO goods
  58. (goods_category_id_,sn_,name_,brand_,specification_,image_,stock_count_,tax_stock_count_,sell_count_,market_price_,
  59. discount_price_,group_purchase_price_,brief_,desc_,is_new_,is_top_,status_,memo_,publish_time_,
  60. complement_goods_id_list_,update_time_,create_time_,type_,agree_cost_price_,client_show_,educational_show_,music_group_show_,stock_warning_,stock_type_)
  61. VALUES(#{goodsCategoryId},#{sn},#{name},#{brand},#{specification},#{image},#{stockCount},#{taxStockCount},#{sellCount},#{marketPrice},
  62. #{discountPrice},#{groupPurchasePrice},#{brief},#{desc},
  63. #{isNew,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{isTop,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  64. #{memo},#{publishTime},#{complementGoodsIdList},now(),now(),#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{agreeCostPrice},
  65. #{clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{educationalShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  66. #{musicGroupShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  67. #{stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
  68. </insert>
  69. <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
  70. INSERT INTO goods
  71. (goods_category_id_,name_,brand_,specification_,image_,market_price_,
  72. discount_price_,group_purchase_price_,brief_,desc_,update_time_,create_time_,type_,agree_cost_price_,sn_,
  73. stock_count_,tax_stock_count_,client_show_,educational_show_,music_group_show_,stock_warning_,stock_type_)
  74. VALUES
  75. <foreach collection="list" separator="," item="goods">
  76. (#{goods.goodsCategoryId},#{goods.name},#{goods.brand},#{goods.specification},#{goods.image},#{goods.marketPrice},
  77. #{goods.discountPrice},#{goods.groupPurchasePrice},#{goods.brief},#{goods.desc},now(),now(),
  78. #{goods.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{goods.agreeCostPrice},#{goods.sn},
  79. #{goods.stockCount},#{goods.taxStockCount},#{goods.clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  80. #{goods.educationalShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  81. #{goods.musicGroupShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  82. #{goods.stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  83. #{goods.stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
  84. </foreach>
  85. </insert>
  86. <!-- 根据主键查询一条记录 -->
  87. <update id="update" parameterType="com.ym.mec.biz.dal.entity.Goods">
  88. UPDATE goods
  89. <set>
  90. <if test="agreeCostPrice != null">
  91. agree_cost_price_ = #{agreeCostPrice},
  92. </if>
  93. <if test="specification != null">
  94. specification_ = #{specification},
  95. </if>
  96. <if test="status != null">
  97. status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  98. </if>
  99. <if test="isTop != null">
  100. is_top_ = #{isTop,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  101. </if>
  102. <if test="type != null">
  103. type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  104. </if>
  105. <if test="sn != null">
  106. sn_ = #{sn},
  107. </if>
  108. <if test="marketPrice != null">
  109. market_price_ = #{marketPrice},
  110. </if>
  111. <if test="memo != null">
  112. memo_ = #{memo},
  113. </if>
  114. <if test="isNew != null">
  115. is_new_ = #{isNew,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  116. </if>
  117. <if test="groupPurchasePrice != null">
  118. group_purchase_price_ = #{groupPurchasePrice},
  119. </if>
  120. <if test="name != null">
  121. name_ = #{name},
  122. </if>
  123. <if test="stockCount != null">
  124. stock_count_ = #{stockCount},
  125. </if>
  126. <if test="goodsCategoryId != null">
  127. goods_category_id_ = #{goodsCategoryId},
  128. </if>
  129. <if test="brand != null">
  130. brand_ = #{brand},
  131. </if>
  132. <if test="brief != null">
  133. brief_ = #{brief},
  134. </if>
  135. <if test="discountPrice != null">
  136. discount_price_ = #{discountPrice},
  137. </if>
  138. <if test="sellCount != null">
  139. sell_count_ = #{sellCount},
  140. </if>
  141. <if test="image != null">
  142. image_ = #{image},
  143. </if>
  144. <if test="desc != null">
  145. desc_ = #{desc},
  146. </if>
  147. <if test="publishTime != null">
  148. publish_time_ = #{publishTime},
  149. </if>
  150. <if test="complementGoodsIdList != null">
  151. complement_goods_id_list_ = #{complementGoodsIdList},
  152. </if>
  153. <if test="taxStockCount != null">
  154. tax_stock_count_ = #{taxStockCount},
  155. </if>
  156. <if test="clientShow != null">
  157. client_show_ = #{clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  158. </if>
  159. <if test="educationalShow != null">
  160. educational_show_ = #{educationalShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  161. </if>
  162. <if test="musicGroupShow != null">
  163. music_group_show_ = #{musicGroupShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  164. </if>
  165. <if test="stockWarning != null">
  166. stock_warning_ = #{stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  167. </if>
  168. <if test="stockType != null">
  169. stock_type_ = #{stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  170. </if>
  171. update_time_ = NOW()
  172. </set>
  173. WHERE id_ = #{id}
  174. </update>
  175. <update id="batchUpdate" parameterType="com.ym.mec.biz.dal.entity.Goods">
  176. <foreach collection="goodsList" item="goods" separator=";">
  177. UPDATE goods
  178. <set>
  179. <if test="goods.agreeCostPrice != null">
  180. agree_cost_price_ = #{goods.agreeCostPrice},
  181. </if>
  182. <if test="goods.specification != null">
  183. specification_ = #{goods.specification},
  184. </if>
  185. <if test="goods.status != null">
  186. status_ = #{goods.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  187. </if>
  188. <if test="goods.isTop != null">
  189. is_top_ = #{goods.isTop,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  190. </if>
  191. <if test="goods.type != null">
  192. type_ = #{goods.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  193. </if>
  194. <if test="goods.sn != null">
  195. sn_ = #{goods.sn},
  196. </if>
  197. <if test="goods.marketPrice != null">
  198. market_price_ = #{goods.marketPrice},
  199. </if>
  200. <if test="goods.memo != null">
  201. memo_ = #{goods.memo},
  202. </if>
  203. <if test="goods.isNew != null">
  204. is_new_ = #{goods.isNew,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  205. </if>
  206. <if test="goods.groupPurchasePrice != null">
  207. group_purchase_price_ = #{goods.groupPurchasePrice},
  208. </if>
  209. <if test="goods.name != null">
  210. name_ = #{goods.name},
  211. </if>
  212. <if test="goods.stockCount != null">
  213. stock_count_ = #{goods.stockCount},
  214. </if>
  215. <if test="goods.goodsCategoryId != null">
  216. goods_category_id_ = #{goods.goodsCategoryId},
  217. </if>
  218. <if test="goods.brand != null">
  219. brand_ = #{goods.brand},
  220. </if>
  221. <if test="goods.brief != null">
  222. brief_ = #{goods.brief},
  223. </if>
  224. <if test="goods.discountPrice != null">
  225. discount_price_ = #{goods.discountPrice},
  226. </if>
  227. <if test="goods.sellCount != null">
  228. sell_count_ = #{goods.sellCount},
  229. </if>
  230. <if test="goods.image != null">
  231. image_ = #{goods.image},
  232. </if>
  233. <if test="goods.desc != null">
  234. desc_ = #{goods.desc},
  235. </if>
  236. <if test="goods.publishTime != null">
  237. publish_time_ = #{goods.publishTime},
  238. </if>
  239. <if test="goods.complementGoodsIdList != null">
  240. complement_goods_id_list_ = #{goods.complementGoodsIdList},
  241. </if>
  242. <if test="goods.taxStockCount != null">
  243. tax_stock_count_ = #{goods.taxStockCount},
  244. </if>
  245. <if test="goods.clientShow != null">
  246. client_show_ = #{goods.clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  247. </if>
  248. <if test="goods.educationalShow != null">
  249. educational_show_ = #{goods.educationalShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  250. </if>
  251. <if test="goods.musicGroupShow != null">
  252. music_group_show_ = #{goods.musicGroupShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  253. </if>
  254. <if test="goods.stockWarning != null">
  255. stock_warning_ = #{goods.stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  256. </if>
  257. <if test="goods.stockType != null">
  258. stock_type_ = #{goods.stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  259. </if>
  260. update_time_ = NOW()
  261. </set>
  262. WHERE id_ = #{goods.id}
  263. </foreach>
  264. </update>
  265. <!-- 根据主键删除一条记录 -->
  266. <delete id="delete">
  267. DELETE FROM goods WHERE id_ = #{id}
  268. </delete>
  269. <!-- 分页查询 -->
  270. <select id="queryPage" resultMap="Goods" parameterType="map">
  271. SELECT g.*,gc.name_ goods_category_name_ FROM goods g
  272. LEFT JOIN goods_category gc ON g.goods_category_id_ = gc.id_
  273. <include refid="queryGoodsPageSql"/>
  274. ORDER BY g.id_ DESC
  275. <include refid="global.limit"/>
  276. </select>
  277. <!-- 查询当前表的总记录数 -->
  278. <select id="queryCount" resultType="int">
  279. SELECT COUNT(*) FROM goods g
  280. <include refid="queryGoodsPageSql"/>
  281. </select>
  282. <sql id="queryGoodsPageSql">
  283. <where>
  284. <if test="goodsCategoryId != null">
  285. AND g.goods_category_id_ = #{goodsCategoryId}
  286. </if>
  287. <if test="type != null">
  288. AND g.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  289. </if>
  290. <if test="isNew != null">
  291. AND g.is_new_ = #{isNew,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  292. </if>
  293. <if test="isTop != null">
  294. AND g.is_top_ = #{isTop,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  295. </if>
  296. <if test="status != null">
  297. AND g.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  298. </if>
  299. <if test="groupGoods!=null and groupGoods==0">
  300. AND g.complement_goods_id_list_ IS NULL
  301. </if>
  302. <if test="groupGoods!=null and groupGoods==1">
  303. AND g.complement_goods_id_list_ IS NOT NULL
  304. </if>
  305. <if test="clientShow!=null">
  306. AND g.client_show_=#{clientShow}
  307. </if>
  308. <if test="educationalShow!=null">
  309. AND g.educational_show_=#{educationalShow}
  310. </if>
  311. <if test="musicGroupShow!=null">
  312. AND g.music_group_show_=#{musicGroupShow}
  313. </if>
  314. <if test="search!=null and search!=''">
  315. AND (g.sn_=#{search} OR g.id_=#{search} OR g.name_ LIKE CONCAT('%', #{search}, '%'))
  316. </if>
  317. </where>
  318. </sql>
  319. <select id="findGoodsBySubId" resultMap="Goods">
  320. SELECT g.* FROM subject_goods_mapper sgm
  321. LEFT JOIN goods g ON sgm.goods_category_id_ = g.goods_category_id_
  322. WHERE sgm.subject_id_ = #{subjectId} AND g.type_ = #{type} and g.status_ != 0
  323. </select>
  324. <!-- 根据 -->
  325. <select id="findGoodsNumByCategoryId" resultType="int">
  326. SELECT COUNT(*) FROM goods WHERE goods_category_id_ = #{goodsCategoryId}
  327. </select>
  328. <select id="findGoodsByIds" resultMap="Goods">
  329. SELECT * FROM goods WHERE FIND_IN_SET(id_,#{ids})
  330. </select>
  331. <select id="findTypeGoods" resultMap="Goods">
  332. SELECT * FROM goods WHERE type_ = #{type} AND status_ != 0
  333. </select>
  334. <select id="getGoodies" resultMap="Goods">
  335. SELECT * FROM goods WHERE id_ IN
  336. <foreach collection="goodsIds" item="goodsId" open="(" close=")" separator=",">
  337. #{goodsId}
  338. </foreach>
  339. </select>
  340. <select id="lockGoods" resultMap="Goods" useCache="false" flushCache="true">
  341. SELECT * FROM goods WHERE id_ IN
  342. <foreach collection="goodsIds" item="goodsId" open="(" close=")" separator=",">
  343. #{goodsId}
  344. </foreach>
  345. FOR UPDATE
  346. </select>
  347. <select id="findBySn" resultMap="Goods">
  348. SELECT * FROM goods WHERE sn_ = #{sn}
  349. </select>
  350. <select id="lockBySn" resultMap="Goods">
  351. SELECT * FROM goods WHERE sn_ = #{sn} FOR UPDATE
  352. </select>
  353. <select id="findBySns" resultMap="Goods">
  354. SELECT * FROM goods WHERE sn_ IN
  355. <foreach collection="sns" item="sn" separator="," open="(" close=")">
  356. #{sn}
  357. </foreach>
  358. </select>
  359. <select id="getInnerRepertoryWarnName" resultType="java.lang.String">
  360. SELECT GROUP_CONCAT( DISTINCT name_) FROM goods WHERE stock_count_ &lt;= #{innerRepertoryWarnNum} AND stock_warning_ = 1 AND complement_goods_id_list_ IS NULL
  361. </select>
  362. <select id="getOuterRepertoryWarnName" resultType="java.lang.String">
  363. SELECT GROUP_CONCAT( DISTINCT name_) FROM goods WHERE tax_stock_count_ &lt;= #{outerRepertoryWarnNum} AND stock_warning_ = 1 AND complement_goods_id_list_ IS NULL
  364. </select>
  365. <select id="getWithComplementGoodsAndStatus" resultMap="Goods">
  366. SELECT * FROM goods WHERE status_ = #{status} AND FIND_IN_SET(#{goodsId}, complement_goods_id_list_)
  367. </select>
  368. <resultMap id="GoodsSellDtoMap" type="com.ym.mec.biz.dal.dto.GoodsSellDto">
  369. <result property="goodsId" column="id_"/>
  370. <result property="image" column="image_"/>
  371. <result property="goodsName" column="name_"/>
  372. <result property="goodsType" column="type_"/>
  373. <result property="goodsPrice" column="discount_price_"/>
  374. <result property="totalGoodsPrice" column="discount_price_"/>
  375. </resultMap>
  376. <select id="queryGoodsSellDtos" resultMap="GoodsSellDtoMap">
  377. SELECT id_,image_,name_,type_,discount_price_ FROM goods WHERE FIND_IN_SET(id_,#{goodsId})
  378. </select>
  379. <resultMap id="MusicGroupGoods" type="com.ym.mec.biz.dal.dto.MusicGroupGoodsAndDiscountDto" extends="Goods"/>
  380. <select id="getMusicGroupGoodsAndDiscount" resultMap="MusicGroupGoods">
  381. SELECT g.* FROM subject_goods_mapper sgm
  382. LEFT JOIN goods g ON sgm.goods_category_id_ = g.goods_category_id_
  383. WHERE sgm.subject_id_ = #{subjectId} AND g.music_group_show_=1 AND g.status_ != 0
  384. <if test="type!=null">
  385. AND g.type_ = #{type}
  386. </if>
  387. </select>
  388. <select id="getMusicGroupGoodsAndDiscountWithSubjects" resultMap="MusicGroupGoods">
  389. SELECT g.* FROM subject_goods_mapper sgm
  390. LEFT JOIN goods g ON sgm.goods_category_id_ = g.goods_category_id_
  391. WHERE FIND_IN_SET(sgm.subject_id_, #{subjectIds}) and g.status_ != 0
  392. <if test="type!=null">
  393. AND g.type_ = #{type}
  394. </if>
  395. </select>
  396. <select id="findByIdAndStatus" resultType="java.lang.Boolean">
  397. SELECT COUNT(0) FROM goods WHERE status_ = #{status} AND id_ = #{goodsId}
  398. </select>
  399. <select id="getGoodsInfo" resultMap="Goods">
  400. SELECT g.*,gc.name_ goods_category_name_ FROM goods g
  401. LEFT JOIN goods_category gc on g.goods_category_id_ = gc.id_
  402. WHERE g.id_=#{id}
  403. </select>
  404. <select id="getGoodiesAndCate" resultMap="Goods">
  405. SELECT g.*,gc.name_ goods_category_name_ FROM goods g
  406. LEFT JOIN goods_category gc on g.goods_category_id_ = gc.id_
  407. WHERE g.id_ IN
  408. <foreach collection="goodsIds" item="goodsId" open="(" close=")" separator=",">
  409. #{goodsId}
  410. </foreach>
  411. </select>
  412. <!-- 根据子商品获取所有包含的子商品的父商品(全部状态)-->
  413. <select id="getGoodsByBaseGoodsId" resultMap="Goods">
  414. SELECT * FROM goods WHERE FIND_IN_SET(#{goodsId}, complement_goods_id_list_)
  415. </select>
  416. <!-- 根据分部获取乐器置换的商品-->
  417. <select id="getReplacementGoodsPage" resultMap="Goods">
  418. SELECT g.*
  419. FROM subject_goods_mapper sgm
  420. LEFT JOIN goods g ON sgm.goods_category_id_ = g.goods_category_id_
  421. WHERE g.replacement_show_ = 1
  422. AND g.status_ != 0
  423. AND g.type_ = 'INSTRUMENT'
  424. <include refid="replacementQuerySql"/>
  425. <include refid="global.limit"/>
  426. </select>
  427. <select id="getReplacementInstrumentCount" resultType="int">
  428. SELECT COUNT(*)
  429. FROM subject_goods_mapper sgm
  430. LEFT JOIN goods g ON sgm.goods_category_id_ = g.goods_category_id_
  431. WHERE g.replacement_show_ = 1
  432. AND g.status_ != 0
  433. AND g.type_ = 'INSTRUMENT'
  434. <include refid="replacementQuerySql"/>
  435. <include refid="global.limit"/>
  436. </select>
  437. <sql id="replacementQuerySql">
  438. <where>
  439. <if test="subjectId != null">
  440. AND sgm.subject_id_ = #{subjectId}
  441. </if>
  442. <if test="brand != null and brand!=''">
  443. AND g.brand_ = #{brand}
  444. </if>
  445. <if test="specification != null and specification!=''">
  446. AND g.specification_ = #{specification}
  447. </if>
  448. </where>
  449. </sql>
  450. </mapper>