GoodsMapper.xml 28 KB

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