GoodsMapper.xml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  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="stock_warning_" property="stockWarning" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  38. <result column="student_show_organ_id_" property="studentShowOrganId"/>
  39. <result column="student_show_organ_name_" property="studentShowOrganName"/>
  40. <result column="education_show_organ_id_" property="educationShowOrganId"/>
  41. <result column="education_show_organ_name_" property="educationShowOrganName"/>
  42. <result column="replacement_show_organ_id_" property="replacementShowOrganId"/>
  43. <result column="replacement_show_organ_name_" property="replacementShowOrganName"/>
  44. <result column="course_fee_show_organ_id_" property="courseFeeShowOrganId"/>
  45. <result column="course_fee_show_organ_name_" property="courseFeeShowOrganName"/>
  46. <result column="member_fee_show_organ_id_" property="memberFeeShowOrganId"/>
  47. <result column="member_fee_show_organ_name_" property="memberFeeShowOrganName"/>
  48. </resultMap>
  49. <!-- 根据主键查询一条记录 -->
  50. <select id="get" resultMap="Goods" useCache="false" flushCache="true">
  51. SELECT * FROM goods g
  52. WHERE g.id_ = #{id}
  53. </select>
  54. <select id="lock" resultMap="Goods" useCache="false" flushCache="true">
  55. SELECT * FROM goods WHERE id_ = #{goodsId} LOCK IN SHARE MODE
  56. </select>
  57. <!-- 全查询 -->
  58. <select id="findAll" resultMap="Goods">
  59. SELECT * FROM goods ORDER BY id_
  60. </select>
  61. <!-- 向数据库增加一条记录 -->
  62. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.Goods" useGeneratedKeys="true" keyColumn="id"
  63. keyProperty="id">
  64. INSERT INTO goods
  65. (goods_category_id_,sn_,name_,brand_,specification_,image_,stock_count_,tax_stock_count_,sell_count_,market_price_,
  66. discount_price_,group_purchase_price_,brief_,desc_,is_new_,is_top_,status_,memo_,publish_time_,
  67. complement_goods_id_list_,update_time_,create_time_,type_,agree_cost_price_,stock_warning_,stock_type_
  68. ,student_show_organ_id_,education_show_organ_id_,replacement_show_organ_id_,course_fee_show_organ_id_,member_fee_show_organ_id_)
  69. VALUES(#{goodsCategoryId},#{sn},#{name},#{brand},#{specification},#{image},#{stockCount},#{taxStockCount},#{sellCount},#{marketPrice},
  70. #{discountPrice},#{groupPurchasePrice},#{brief},#{desc},
  71. #{isNew,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{isTop,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  72. #{memo},#{publishTime},#{complementGoodsIdList},now(),now(),#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{agreeCostPrice},
  73. #{stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  74. #{studentShowOrganId},#{educationShowOrganId},#{replacementShowOrganId},#{courseFeeShowOrganId},#{memberFeeShowOrganId})
  75. </insert>
  76. <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
  77. INSERT INTO goods
  78. (goods_category_id_,name_,brand_,specification_,image_,market_price_,
  79. discount_price_,group_purchase_price_,brief_,desc_,update_time_,create_time_,type_,agree_cost_price_,sn_,
  80. stock_count_,tax_stock_count_,stock_warning_,stock_type_
  81. ,student_show_organ_id_,education_show_organ_id_,replacement_show_organ_id_,course_fee_show_organ_id_,member_fee_show_organ_id_)
  82. VALUES
  83. <foreach collection="list" separator="," item="goods">
  84. (#{goods.goodsCategoryId},#{goods.name},#{goods.brand},#{goods.specification},#{goods.image},#{goods.marketPrice},
  85. #{goods.discountPrice},#{goods.groupPurchasePrice},#{goods.brief},#{goods.desc},now(),now(),
  86. #{goods.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{goods.agreeCostPrice},#{goods.sn},
  87. #{goods.stockCount},#{goods.taxStockCount},
  88. #{goods.stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  89. #{goods.stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  90. #{goods.studentShowOrganId},#{goods.educationShowOrganId},#{goods.replacementShowOrganId},#{goods.courseFeeShowOrganId},#{goods.memberFeeShowOrganId}
  91. )
  92. </foreach>
  93. </insert>
  94. <!-- 根据主键查询一条记录 -->
  95. <update id="update" parameterType="com.ym.mec.biz.dal.entity.Goods">
  96. UPDATE goods
  97. <set>
  98. <if test="studentShowOrganId != null">
  99. student_show_organ_id_ = #{studentShowOrganId},
  100. </if>
  101. <if test="educationShowOrganId != null">
  102. education_show_organ_id_ = #{educationShowOrganId},
  103. </if>
  104. <if test="replacementShowOrganId != null">
  105. replacement_show_organ_id_ = #{replacementShowOrganId},
  106. </if>
  107. <if test="courseFeeShowOrganId != null">
  108. course_fee_show_organ_id_ = #{courseFeeShowOrganId},
  109. </if>
  110. <if test="memberFeeShowOrganId != null">
  111. member_fee_show_organ_id_ = #{memberFeeShowOrganId},
  112. </if>
  113. <if test="agreeCostPrice != null">
  114. agree_cost_price_ = #{agreeCostPrice},
  115. </if>
  116. <if test="specification != null">
  117. specification_ = #{specification},
  118. </if>
  119. <if test="status != null">
  120. status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  121. </if>
  122. <if test="isTop != null">
  123. is_top_ = #{isTop,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  124. </if>
  125. <if test="type != null">
  126. type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  127. </if>
  128. <if test="sn != null">
  129. sn_ = #{sn},
  130. </if>
  131. <if test="marketPrice != null">
  132. market_price_ = #{marketPrice},
  133. </if>
  134. <if test="memo != null">
  135. memo_ = #{memo},
  136. </if>
  137. <if test="isNew != null">
  138. is_new_ = #{isNew,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  139. </if>
  140. <if test="groupPurchasePrice != null">
  141. group_purchase_price_ = #{groupPurchasePrice},
  142. </if>
  143. <if test="name != null">
  144. name_ = #{name},
  145. </if>
  146. <if test="stockCount != null">
  147. stock_count_ = #{stockCount},
  148. </if>
  149. <if test="goodsCategoryId != null">
  150. goods_category_id_ = #{goodsCategoryId},
  151. </if>
  152. <if test="brand != null">
  153. brand_ = #{brand},
  154. </if>
  155. <if test="brief != null">
  156. brief_ = #{brief},
  157. </if>
  158. <if test="discountPrice != null">
  159. discount_price_ = #{discountPrice},
  160. </if>
  161. <if test="sellCount != null">
  162. sell_count_ = #{sellCount},
  163. </if>
  164. <if test="image != null">
  165. image_ = #{image},
  166. </if>
  167. <if test="desc != null">
  168. desc_ = #{desc},
  169. </if>
  170. <if test="publishTime != null">
  171. publish_time_ = #{publishTime},
  172. </if>
  173. <if test="complementGoodsIdList != null">
  174. complement_goods_id_list_ = #{complementGoodsIdList},
  175. </if>
  176. <if test="taxStockCount != null">
  177. tax_stock_count_ = #{taxStockCount},
  178. </if>
  179. <if test="stockWarning != null">
  180. stock_warning_ = #{stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  181. </if>
  182. <if test="stockType != null">
  183. stock_type_ = #{stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  184. </if>
  185. update_time_ = NOW()
  186. </set>
  187. WHERE id_ = #{id}
  188. </update>
  189. <update id="batchUpdate" parameterType="com.ym.mec.biz.dal.entity.Goods">
  190. <foreach collection="goodsList" item="goods" separator=";">
  191. UPDATE goods
  192. <set>
  193. <if test="goods.studentShowOrganId != null">
  194. student_show_organ_id_ = #{goods.studentShowOrganId},
  195. </if>
  196. <if test="goods.educationShowOrganId != null">
  197. education_show_organ_id_ = #{goods.educationShowOrganId},
  198. </if>
  199. <if test="goods.replacementShowOrganId != null">
  200. replacement_show_organ_id_ = #{goods.replacementShowOrganId},
  201. </if>
  202. <if test="goods.courseFeeShowOrganId != null">
  203. course_fee_show_organ_id_ = #{goods.courseFeeShowOrganId},
  204. </if>
  205. <if test="goods.memberFeeShowOrganId != null">
  206. member_fee_show_organ_id_ = #{goods.memberFeeShowOrganId},
  207. </if>
  208. <if test="goods.agreeCostPrice != null">
  209. agree_cost_price_ = #{goods.agreeCostPrice},
  210. </if>
  211. <if test="goods.specification != null">
  212. specification_ = #{goods.specification},
  213. </if>
  214. <if test="goods.status != null">
  215. status_ = #{goods.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  216. </if>
  217. <if test="goods.isTop != null">
  218. is_top_ = #{goods.isTop,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  219. </if>
  220. <if test="goods.type != null">
  221. type_ = #{goods.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  222. </if>
  223. <if test="goods.sn != null">
  224. sn_ = #{goods.sn},
  225. </if>
  226. <if test="goods.marketPrice != null">
  227. market_price_ = #{goods.marketPrice},
  228. </if>
  229. <if test="goods.memo != null">
  230. memo_ = #{goods.memo},
  231. </if>
  232. <if test="goods.isNew != null">
  233. is_new_ = #{goods.isNew,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  234. </if>
  235. <if test="goods.groupPurchasePrice != null">
  236. group_purchase_price_ = #{goods.groupPurchasePrice},
  237. </if>
  238. <if test="goods.name != null">
  239. name_ = #{goods.name},
  240. </if>
  241. <if test="goods.stockCount != null">
  242. stock_count_ = #{goods.stockCount},
  243. </if>
  244. <if test="goods.goodsCategoryId != null">
  245. goods_category_id_ = #{goods.goodsCategoryId},
  246. </if>
  247. <if test="goods.brand != null">
  248. brand_ = #{goods.brand},
  249. </if>
  250. <if test="goods.brief != null">
  251. brief_ = #{goods.brief},
  252. </if>
  253. <if test="goods.discountPrice != null">
  254. discount_price_ = #{goods.discountPrice},
  255. </if>
  256. <if test="goods.sellCount != null">
  257. sell_count_ = #{goods.sellCount},
  258. </if>
  259. <if test="goods.image != null">
  260. image_ = #{goods.image},
  261. </if>
  262. <if test="goods.desc != null">
  263. desc_ = #{goods.desc},
  264. </if>
  265. <if test="goods.publishTime != null">
  266. publish_time_ = #{goods.publishTime},
  267. </if>
  268. <if test="goods.complementGoodsIdList != null">
  269. complement_goods_id_list_ = #{goods.complementGoodsIdList},
  270. </if>
  271. <if test="goods.taxStockCount != null">
  272. tax_stock_count_ = #{goods.taxStockCount},
  273. </if>
  274. <if test="goods.stockWarning != null">
  275. stock_warning_ = #{goods.stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  276. </if>
  277. <if test="goods.stockType != null">
  278. stock_type_ = #{goods.stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  279. </if>
  280. update_time_ = NOW()
  281. </set>
  282. WHERE id_ = #{goods.id}
  283. </foreach>
  284. </update>
  285. <!-- 根据主键删除一条记录 -->
  286. <delete id="delete">
  287. DELETE FROM goods WHERE id_ = #{id}
  288. </delete>
  289. <!-- 分页查询 -->
  290. <select id="queryPage" resultMap="Goods" parameterType="map">
  291. SELECT g.*,gc.name_ goods_category_name_ FROM goods g
  292. LEFT JOIN goods_category gc ON g.goods_category_id_ = gc.id_
  293. <include refid="queryGoodsPageSql"/>
  294. GROUP BY g.id_
  295. ORDER BY g.id_ DESC
  296. <include refid="global.limit"/>
  297. </select>
  298. <!-- 查询当前表的总记录数 -->
  299. <select id="queryCount" resultType="int">
  300. SELECT COUNT(*) FROM goods g
  301. <include refid="queryGoodsPageSql"/>
  302. </select>
  303. <sql id="queryGoodsPageSql">
  304. <where>
  305. <if test="goodsCategoryId != null">
  306. AND g.goods_category_id_ = #{goodsCategoryId}
  307. </if>
  308. <if test="type != null">
  309. AND g.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  310. </if>
  311. <if test="isNew != null">
  312. AND g.is_new_ = #{isNew,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  313. </if>
  314. <if test="isTop != null">
  315. AND g.is_top_ = #{isTop,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  316. </if>
  317. <if test="status != null">
  318. AND g.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  319. </if>
  320. <if test="groupGoods!=null and groupGoods==0">
  321. AND g.complement_goods_id_list_ IS NULL
  322. </if>
  323. <if test="groupGoods!=null and groupGoods==1">
  324. AND g.complement_goods_id_list_ IS NOT NULL
  325. </if>
  326. <if test="studentShowOrganId != null and studentShowOrganId!=''">
  327. AND INTE_ARRAY(#{studentShowOrganId},g.student_show_organ_id_)
  328. </if>
  329. <if test="educationShowOrganId != null and educationShowOrganId!=''">
  330. AND INTE_ARRAY(#{educationShowOrganId},g.education_show_organ_id_)
  331. </if>
  332. <if test="courseFeeShowOrganId != null and courseFeeShowOrganId!=''">
  333. AND INTE_ARRAY(#{courseFeeShowOrganId},g.course_fee_show_organ_id_)
  334. </if>
  335. <if test="memberFeeShowOrganId!=null and memberFeeShowOrganId!=''">
  336. AND INTE_ARRAY(#{memberFeeShowOrganId},g.member_fee_show_organ_id_)
  337. </if>
  338. <if test="replacementShowOrganId!=null and replacementShowOrganId!=''">
  339. AND INTE_ARRAY(#{replacementShowOrganId},g.replacement_show_organ_id_)
  340. </if>
  341. <if test="noOrganSearch == null">
  342. <if test="organId != null and organId != ''">
  343. AND INTE_ARRAY (#{organId},CONCAT_WS(",",replacement_show_organ_id_,member_fee_show_organ_id_,
  344. course_fee_show_organ_id_,education_show_organ_id_,student_show_organ_id_))
  345. </if>
  346. </if>
  347. <if test="search!=null and search!=''">
  348. AND (g.sn_=#{search} OR g.id_=#{search} OR g.name_ LIKE CONCAT('%', #{search}, '%'))
  349. </if>
  350. </where>
  351. </sql>
  352. <select id="findGoodsBySubId" resultMap="Goods">
  353. SELECT g.* FROM subject_goods_mapper sgm
  354. LEFT JOIN goods g ON sgm.goods_category_id_ = g.goods_category_id_
  355. <include refid="queryOrganIdSql"/>
  356. </select>
  357. <sql id="queryOrganIdSql">
  358. <where>
  359. AND g.status_ != 0
  360. <if test="goodsQuery.subjectId != null">
  361. AND sgm.subject_id_ = #{goodsQuery.subjectId}
  362. </if>
  363. <if test="goodsQuery.type != null and goodsQuery.type != ''">
  364. AND g.type_ = #{goodsQuery.type}
  365. </if>
  366. <if test="goodsQuery.studentShowOrganId != null">
  367. AND FIND_IN_SET(#{goodsQuery.studentShowOrganId},g.student_show_organ_id_)
  368. </if>
  369. <if test="goodsQuery.educationShowOrganId != null">
  370. AND FIND_IN_SET(#{goodsQuery.educationShowOrganId},g.education_show_organ_id_)
  371. </if>
  372. <if test="goodsQuery.courseFeeShowOrganId != null">
  373. AND FIND_IN_SET(#{goodsQuery.courseFeeShowOrganId},g.course_fee_show_organ_id_)
  374. </if>
  375. <if test="goodsQuery.memberFeeShowOrganId!=null">
  376. AND FIND_IN_SET(#{goodsQuery.memberFeeShowOrganId},g.member_fee_show_organ_id_)
  377. </if>
  378. <if test="goodsQuery.replacementShowOrganId!=null">
  379. AND FIND_IN_SET(#{goodsQuery.replacementShowOrganId},g.replacement_show_organ_id_)
  380. </if>
  381. <if test="goodsQuery.organId != null">
  382. AND FIND_IN_SET (#{goodsQuery.organId},CONCAT_WS(",",replacement_show_organ_id_,member_fee_show_organ_id_,
  383. course_fee_show_organ_id_,education_show_organ_id_,student_show_organ_id_))
  384. </if>
  385. </where>
  386. </sql>
  387. <!-- 根据 -->
  388. <select id="findGoodsNumByCategoryId" resultType="int">
  389. SELECT COUNT(*) FROM goods WHERE goods_category_id_ = #{goodsCategoryId}
  390. </select>
  391. <select id="findGoodsByIds" resultMap="Goods">
  392. SELECT * FROM goods WHERE FIND_IN_SET(id_,#{ids})
  393. </select>
  394. <select id="findTypeGoods" resultMap="Goods">
  395. SELECT * FROM goods WHERE type_ = #{type} AND status_ != 0
  396. </select>
  397. <select id="getGoodies" resultMap="Goods">
  398. SELECT * FROM goods WHERE id_ IN
  399. <foreach collection="goodsIds" item="goodsId" open="(" close=")" separator=",">
  400. #{goodsId}
  401. </foreach>
  402. </select>
  403. <select id="lockGoods" resultMap="Goods" useCache="false" flushCache="true">
  404. SELECT * FROM goods WHERE id_ IN
  405. <foreach collection="goodsIds" item="goodsId" open="(" close=")" separator=",">
  406. #{goodsId}
  407. </foreach>
  408. FOR UPDATE
  409. </select>
  410. <select id="findBySn" resultMap="Goods">
  411. SELECT * FROM goods WHERE sn_ = #{sn}
  412. </select>
  413. <select id="lockBySn" resultMap="Goods">
  414. SELECT * FROM goods WHERE sn_ = #{sn} FOR UPDATE
  415. </select>
  416. <select id="findBySns" resultMap="Goods">
  417. SELECT * FROM goods WHERE sn_ IN
  418. <foreach collection="sns" item="sn" separator="," open="(" close=")">
  419. #{sn}
  420. </foreach>
  421. </select>
  422. <select id="getInnerRepertoryWarnName" resultType="java.lang.String">
  423. SELECT GROUP_CONCAT( DISTINCT name_) FROM goods WHERE stock_count_ &lt;= #{innerRepertoryWarnNum} AND stock_warning_ = 1 AND complement_goods_id_list_ IS NULL
  424. </select>
  425. <select id="getOuterRepertoryWarnName" resultType="java.lang.String">
  426. SELECT GROUP_CONCAT( DISTINCT name_) FROM goods WHERE tax_stock_count_ &lt;= #{outerRepertoryWarnNum} AND stock_warning_ = 1 AND complement_goods_id_list_ IS NULL
  427. </select>
  428. <select id="getWithComplementGoodsAndStatus" resultMap="Goods">
  429. SELECT * FROM goods WHERE status_ = #{status} AND FIND_IN_SET(#{goodsId}, complement_goods_id_list_)
  430. </select>
  431. <resultMap id="GoodsSellDtoMap" type="com.ym.mec.biz.dal.dto.GoodsSellDto">
  432. <result property="goodsId" column="id_"/>
  433. <result property="image" column="image_"/>
  434. <result property="goodsName" column="name_"/>
  435. <result property="goodsType" column="type_"/>
  436. <result property="goodsPrice" column="discount_price_"/>
  437. <result property="totalGoodsPrice" column="discount_price_"/>
  438. </resultMap>
  439. <select id="queryGoodsSellDtos" resultMap="GoodsSellDtoMap">
  440. SELECT id_,image_,name_,type_,discount_price_ FROM goods WHERE FIND_IN_SET(id_,#{goodsId})
  441. </select>
  442. <resultMap id="MusicGroupGoods" type="com.ym.mec.biz.dal.dto.MusicGroupGoodsAndDiscountDto" extends="Goods"/>
  443. <select id="getMusicGroupGoodsAndDiscount" resultMap="MusicGroupGoods">
  444. SELECT g.* FROM subject_goods_mapper sgm
  445. LEFT JOIN goods g ON sgm.goods_category_id_ = g.goods_category_id_
  446. WHERE sgm.subject_id_ = #{subjectId} AND g.status_ != 0
  447. <if test="organId != null">
  448. <if test="courseViewType != null">
  449. <if test="courseViewType == 1">
  450. AND FIND_IN_SET(#{organId},g.member_fee_show_organ_id_)
  451. </if>
  452. <if test="courseViewType == 0">
  453. AND FIND_IN_SET(#{organId},g.course_fee_show_organ_id_)
  454. </if>
  455. </if>
  456. </if>
  457. <if test="type!=null">
  458. AND g.type_ = #{type}
  459. </if>
  460. </select>
  461. <select id="findByIdAndStatus" resultType="java.lang.Boolean">
  462. SELECT COUNT(0) FROM goods WHERE status_ = #{status} AND id_ = #{goodsId}
  463. </select>
  464. <select id="getGoodsInfo" resultMap="Goods">
  465. SELECT g.*,gc.name_ goods_category_name_ FROM goods g
  466. LEFT JOIN goods_category gc on g.goods_category_id_ = gc.id_
  467. WHERE g.id_=#{id}
  468. </select>
  469. <select id="getGoodiesAndCate" resultMap="Goods">
  470. SELECT g.*,gc.name_ goods_category_name_ FROM goods g
  471. LEFT JOIN goods_category gc on g.goods_category_id_ = gc.id_
  472. WHERE g.id_ IN
  473. <foreach collection="goodsIds" item="goodsId" open="(" close=")" separator=",">
  474. #{goodsId}
  475. </foreach>
  476. </select>
  477. <!-- 根据子商品获取所有包含的子商品的父商品(全部状态)-->
  478. <select id="getGoodsByBaseGoodsId" resultMap="Goods">
  479. SELECT * FROM goods WHERE FIND_IN_SET(#{goodsId}, complement_goods_id_list_)
  480. </select>
  481. <!-- 根据分部获取乐器置换的商品-->
  482. <select id="getReplacementGoodsPage" resultMap="com.ym.mec.biz.dal.dao.ReplacementInstrumentDao.ReplacementInstrument">
  483. SELECT g.id_,g.brand_,g.specification_,g.brief_ param_,g.market_price_,g.discount_price_,g.group_purchase_price_ sale_price_,
  484. (g.discount_price_-g.group_purchase_price_) depreciation_price_
  485. FROM subject_goods_mapper sgm
  486. LEFT JOIN goods_category gc ON gc.id_=sgm.goods_category_id_
  487. LEFT JOIN goods g ON sgm.goods_category_id_ = g.goods_category_id_
  488. <include refid="replacementQuerySql"/>
  489. <include refid="global.limit"/>
  490. </select>
  491. <select id="getReplacementInstrumentCount" resultType="int">
  492. SELECT COUNT(*)
  493. FROM subject_goods_mapper sgm
  494. LEFT JOIN goods_category gc ON gc.id_=sgm.goods_category_id_
  495. LEFT JOIN goods g ON sgm.goods_category_id_ = g.goods_category_id_
  496. <include refid="replacementQuerySql"/>
  497. <include refid="global.limit"/>
  498. </select>
  499. <sql id="replacementQuerySql">
  500. <where>
  501. g.status_ != 0
  502. AND g.type_ = 'INSTRUMENT'
  503. AND gc.del_flag_ = 0
  504. <if test="organId != null">
  505. AND FIND_IN_SET(#{organId},g.replacement_show_organ_id_)
  506. </if>
  507. <if test="subjectId != null">
  508. AND sgm.subject_id_ = #{subjectId}
  509. </if>
  510. <if test="brand != null and brand!=''">
  511. AND g.brand_ = #{brand}
  512. </if>
  513. <if test="specification != null and specification!=''">
  514. AND g.specification_ = #{specification}
  515. </if>
  516. </where>
  517. </sql>
  518. </mapper>