GoodsMapper.xml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.mapper.GoodsMapper">
  5. <select id="findGoodsList"
  6. resultType="Goods">
  7. select * from goods
  8. </select>
  9. <select id="paihang"
  10. resultType="Goods">
  11. select sum(goodsQuantity) goodsQuantity,goodsId goodsId from orderitem group by goodsId order by sum(goodsQuantity) desc limit 0,7
  12. </select>
  13. <select id="report2" parameterType="java.util.Map" resultType="Goods">
  14. select sum(goodsQuantity) goodsQuantity, DATE_FORMAT(orderdate, '%Y-%m-%d') orderdate,sum(goodsQuantity*goodsshichangjia) goodsshichangjia from orderitem a left join torder b on a.orderid=b.orderid left join goods c on a.goodsid=c.goodsid where orderZhuangtai != '未付款' and orderZhuangtai != '已取消' group by DATE_FORMAT(orderdate, '%Y-%m-%d')
  15. </select>
  16. <select id="query" parameterType="java.util.Map" resultType="Goods">
  17. select * from goods
  18. <where>
  19. <if test="goodsId!=null and goodsId!=0">
  20. and goodsId= #{goodsId}
  21. </if>
  22. <if test="goodsDel!=null and goodsDel!=''">
  23. and goodsDel= #{goodsDel}
  24. </if>
  25. <if test="tj!=null">
  26. and tj= #{tj}
  27. </if>
  28. <if test="qtj=='Y'.toString()">
  29. and ( tj=1 or goodsCatelogId in
  30. <foreach item="item" index="index" collection="cids" open="(" separator="," close=")">
  31. #{item}
  32. </foreach>
  33. )
  34. </if>
  35. <if test="zt!=null">
  36. and zt= #{zt}
  37. </if>
  38. <if test="goodsCatelogId!=null and goodsCatelogId!=0">
  39. and goodsCatelogId= #{goodsCatelogId}
  40. </if>
  41. <if test="goodsName!=null and goodsName!=''">
  42. and goodsName like '%${goodsName}%'
  43. </if>
  44. <if test="kucun==1000">
  45. and kucun &gt; 0 and goodsId!=#{own}
  46. </if>
  47. </where>
  48. order by zan desc
  49. <if test="page">
  50. limit #{offset} ,#{pageSize}
  51. </if>
  52. </select>
  53. <select id="getCount" parameterType="java.util.Map" resultType="Int">
  54. select count(0) from goods
  55. <where>
  56. <if test="goodsId!=null and goodsId!=0">
  57. and goodsId= #{goodsId}
  58. </if>
  59. <if test="goodsDel!=null and goodsDel!=''">
  60. and goodsDel= #{goodsDel}
  61. </if>
  62. <if test="zt!=null">
  63. and zt= #{zt}
  64. </if>
  65. <if test="goodsCatelogId!=null and goodsCatelogId!=0">
  66. and goodsCatelogId= #{goodsCatelogId}
  67. </if>
  68. <if test="goodsName!=null and goodsName!=''">
  69. and goodsName like '%${goodsName}%'
  70. </if>
  71. </where>
  72. </select>
  73. <select id="queryGoodsById" parameterType="int" resultType="Goods">
  74. select * from goods where goodsId=${value}
  75. </select>
  76. <insert id="insertGoods" useGeneratedKeys="true" keyProperty="id" parameterType="Goods">
  77. insert into goods
  78. (goodsName,goodsMiaoshu,goodsPic,goodsShichangjia,goodsCatelogId,goodsDel,zt,kucun,tj)
  79. values
  80. (#{goodsName},#{goodsMiaoshu},#{goodsPic},#{goodsShichangjia},#{goodsCatelogId},#{goodsDel},#{zt},#{kucun},0);
  81. </insert>
  82. <update id="updateGoods" parameterType="Goods" >
  83. update goods set
  84. goodsName=#{goodsName},goodsMiaoshu=#{goodsMiaoshu},goodsPic=#{goodsPic},goodsShichangjia=#{goodsShichangjia},goodsCatelogId=#{goodsCatelogId},goodsDel=#{goodsDel},zt=#{zt},kucun=#{kucun},zan=#{zan},tj=#{tj}
  85. where
  86. goodsId=#{goodsId}
  87. </update>
  88. <delete id="deleteGoods" parameterType="int">
  89. delete from goods where goodsId=${value}
  90. </delete>
  91. <select id="findSameGoods" parameterType="java.util.Map" resultType="Goods">
  92. select * from goods where goodsCatelogId= #{goodsCatelogId} and goodsId!=#{goodsId}
  93. limit 0 ,2
  94. </select>
  95. </mapper>