MtGoodsMapper.xml 4.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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.fuint.repository.mapper.MtGoodsMapper">
  4. <select id="getStoreGoodsList" resultType="com.fuint.repository.model.MtGoods">
  5. select * from mt_goods t where (t.STORE_ID = #{storeId} or (t.STORE_ID = 0 AND t.id IN( SELECT s.GOODS_ID FROM mt_store_goods s WHERE s.STORE_ID = #{storeId} AND s.STATUS = 'A')))
  6. <if test="cateId != null and cateId > 0">
  7. AND t.CATE_ID = #{cateId}
  8. </if>
  9. <if test="platform != null and (platform == 'H5' or platform == 'MP-WEIXIN')">
  10. AND t.platform IN(0, 1)
  11. </if>
  12. <if test="platform != null and platform == 'PC'">
  13. AND t.platform IN(0, 2)
  14. </if>
  15. and t.MERCHANT_ID = #{merchantId}
  16. and t.PRICE > 0
  17. and t.STATUS = 'A' order by t.sort asc
  18. </select>
  19. <select id="searchStoreGoodsList" resultType="com.fuint.repository.model.MtGoods">
  20. select * from mt_goods t where t.STATUS = 'A'
  21. <if test="merchantId != null and merchantId > 0">
  22. AND t.MERCHANT_ID = #{merchantId}
  23. </if>
  24. <if test="storeId != null and storeId > 0">
  25. and (t.STORE_ID = #{storeId} or (t.STORE_ID = 0 AND t.id IN( SELECT s.GOODS_ID FROM mt_store_goods s WHERE s.STORE_ID = #{storeId} AND s.STATUS = 'A' )))
  26. </if>
  27. <if test="platform != null and (platform == 'H5' or platform == 'MP-WEIXIN')">
  28. AND t.platform IN(0, 1)
  29. </if>
  30. <if test="platform != null and platform == 'PC'">
  31. AND t.platform IN(0, 2)
  32. </if>
  33. and t.PRICE > 0
  34. and (t.name like concat('%',#{keyword},'%') or t.goods_no = #{keyword} or t.ID = #{keyword} or t.description like concat('%',#{keyword},'%'))
  35. order by t.sort asc
  36. </select>
  37. <select id="getByGoodsNo" resultType="com.fuint.repository.model.MtGoods">
  38. select * from mt_goods t where t.GOODS_NO = #{goodsNo} and t.STATUS = 'A'
  39. <if test="merchantId != null and merchantId > 0">
  40. AND t.MERCHANT_ID = #{merchantId}
  41. </if>
  42. </select>
  43. <select id="getByGoodsName" resultType="com.fuint.repository.model.MtGoods">
  44. select * from mt_goods t where t.NAME = #{goodsName} and t.STATUS != 'D'
  45. <if test="merchantId != null and merchantId > 0">
  46. AND t.MERCHANT_ID = #{merchantId}
  47. </if>
  48. </select>
  49. <update id="updateInitSale">
  50. update mt_goods t set t.INIT_SALE = t.INIT_SALE + #{saleNum} where t.ID = #{goodsId}
  51. </update>
  52. <select id="selectGoodsList" resultType="com.fuint.repository.bean.GoodsBean">
  53. SELECT g.LOGO as logo,g.STORE_ID as storeId,g.ID AS goodsId,g.CATE_ID AS cateId,g.GOODS_NO AS goodsNo,g.NAME as name,g.PRICE as price, g.STOCK as stock,s.`SPEC_IDS` as specIds,s.`PRICE` as skuPrice, s.STOCK as skuStock FROM `mt_goods` g LEFT JOIN `mt_goods_sku` s ON g.id = s.`GOODS_ID`
  54. WHERE g.`status` = 'A'
  55. <if test="merchantId != null and merchantId > 0">
  56. AND g.MERCHANT_ID = #{merchantId}
  57. </if>
  58. <if test="storeId != null and storeId > 0">
  59. AND (g.STORE_ID = #{storeId} OR (g.STORE_ID = 0 AND g.id IN( SELECT s.GOODS_ID FROM mt_store_goods s WHERE s.STORE_ID = #{storeId} AND s.STATUS = 'A')))
  60. </if>
  61. <if test="cateId != null and cateId > 0">
  62. AND g.CATE_ID = #{cateId}
  63. </if>
  64. <if test="keyword != null">
  65. AND (g.name LIKE concat('%',#{keyword},'%') OR g.GOODS_NO = #{keyword} OR s.SKU_NO = #{keyword})
  66. </if>
  67. ORDER BY g.`SORT` ASC
  68. </select>
  69. <select id="getGoodsSaleTopList" resultType="com.fuint.repository.bean.GoodsTopBean">
  70. SELECT g.id AS ID,g.name AS NAME,g.GOODS_NO,SUM(o.`NUM`) AS num, SUM(o.price) as amount FROM `mt_goods` g,`mt_order_goods` o WHERE g.`ID` = o.`GOODS_ID`
  71. <if test="merchantId != null and merchantId > 0">
  72. AND g.MERCHANT_ID = #{merchantId}
  73. </if>
  74. <if test="storeId != null and storeId > 0">
  75. AND g.STORE_ID = #{storeId}
  76. </if>
  77. <if test="startTime != null">
  78. AND o.CREATE_TIME &gt;= #{startTime}
  79. </if>
  80. <if test="endTime != null">
  81. AND o.CREATE_TIME &lt;= #{endTime}
  82. </if>
  83. GROUP BY g.`ID` ORDER BY SUM(o.`NUM`) DESC LIMIT 10
  84. </select>
  85. <update id="removeMerchantGoods">
  86. update mt_goods t set t.STATUS = 'D' where t.MERCHANT_ID = #{merchantId}
  87. </update>
  88. </mapper>