StudentGoodsSellMapper.xml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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.StudentGoodsSellDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.StudentGoodsSell" id="StudentGoodsSell">
  9. <result column="id_" property="id" />
  10. <result column="user_id_" property="userId" />
  11. <result column="teacher_id_" property="teacherId" />
  12. <result column="goods_json_" property="goodsJson" />
  13. <result column="total_amount_" property="totalAmount" />
  14. <result column="market_amount_" property="marketAmount" />
  15. <result column="order_no_" property="orderNo" />
  16. <result column="organ_id_" property="organId" />
  17. <result column="create_time_" property="createTime" />
  18. <result column="update_time_" property="updateTime" />
  19. </resultMap>
  20. <!-- 根据主键查询一条记录 -->
  21. <select id="get" resultMap="StudentGoodsSell" >
  22. SELECT * FROM student_goods_sell WHERE id_ = #{id}
  23. </select>
  24. <!-- 全查询 -->
  25. <select id="findAll" resultMap="StudentGoodsSell">
  26. SELECT * FROM student_goods_sell ORDER BY id_
  27. </select>
  28. <!-- 向数据库增加一条记录 -->
  29. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentGoodsSell" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  30. INSERT INTO student_goods_sell (id_,user_id_,teacher_id_,goods_json_,total_amount_,market_amount_,create_time_,update_time_,order_no_,organ_id_)
  31. VALUES(#{id},#{userId},#{teacherId},#{goodsJson},#{totalAmount},#{marketAmount},NOW(),NOW(),#{orderNo},#{organId})
  32. </insert>
  33. <!-- 根据主键查询一条记录 -->
  34. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentGoodsSell">
  35. UPDATE student_goods_sell <set>
  36. <if test="organId != null">
  37. organ_id_ = #{organId},
  38. </if>
  39. <if test="orderNo != null">
  40. order_no_ = #{orderNo},
  41. </if>
  42. <if test="userId != null">
  43. user_id_ = #{userId},
  44. </if>
  45. <if test="totalAmount != null">
  46. total_amount_ = #{totalAmount},
  47. </if>
  48. <if test="marketAmount != null">
  49. market_amount_ = #{marketAmount},
  50. </if>
  51. <if test="teacherId != null">
  52. teacher_id_ = #{teacherId},
  53. </if>
  54. <if test="goodsJson != null">
  55. goods_json_ = #{goodsJson},
  56. </if>
  57. update_time_ = NOW()
  58. </set> WHERE id_ = #{id}
  59. </update>
  60. <!-- 根据主键删除一条记录 -->
  61. <delete id="delete" >
  62. DELETE FROM student_goods_sell WHERE id_ = #{id}
  63. </delete>
  64. <!-- 分页查询 -->
  65. <select id="queryPage" resultMap="StudentGoodsSell" parameterType="map">
  66. SELECT * FROM student_goods_sell ORDER BY id_ <include refid="global.limit"/>
  67. </select>
  68. <!-- 查询当前表的总记录数 -->
  69. <select id="queryCount" resultType="int">
  70. SELECT COUNT(*) FROM student_goods_sell
  71. </select>
  72. <select id="countStudentGoodsOrders" resultType="java.lang.Integer">
  73. SELECT COUNT(spo.id_) FROM student_payment_order spo
  74. LEFT JOIN student_goods_sell sgs ON spo.order_no_ = sgs.order_no_
  75. LEFT JOIN sys_user su ON sgs.user_id_ = su.id_
  76. <include refid="queryStudentGoodsOrdersSql"/>
  77. </select>
  78. <resultMap type="com.ym.mec.biz.dal.dto.StudentGoodsSellDto" id="StudentGoodsSellDto" extends="com.ym.mec.biz.dal.dao.StudentPaymentOrderDao.StudentPaymentOrder">
  79. <result column="goods_json_" property="goodsJson" />
  80. <result column="total_amount_" property="totalAmount" />
  81. <result column="market_amount_" property="marketAmount" />
  82. <result column="user_name_" property="userName" />
  83. </resultMap>
  84. <sql id="queryStudentGoodsOrdersSql">
  85. <where>
  86. <if test="teacherId != null">
  87. sgs.teacher_id_ = #{teacherId}
  88. </if>
  89. <if test="studentId != null">
  90. AND sgs.user_id_ = #{studentId}
  91. </if>
  92. <if test="status != null">
  93. AND spo.status_ = #{status}
  94. </if>
  95. <if test="search != null and search != ''">
  96. AND (su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  97. </if>
  98. </where>
  99. </sql>
  100. <select id="queryStudentGoodsOrders" resultMap="StudentGoodsSellDto">
  101. SELECT spo.*,sgs.goods_json_,sgs.total_amount_,sgs.market_amount_,su.username_ FROM student_payment_order spo
  102. LEFT JOIN student_goods_sell sgs ON spo.order_no_ = sgs.order_no_
  103. LEFT JOIN sys_user su ON sgs.user_id_ = su.id_
  104. <include refid="queryStudentGoodsOrdersSql"/>
  105. ORDER BY spo.create_time_ DESC
  106. <include refid="global.limit"/>
  107. </select>
  108. <select id="findByOrderNo" resultMap="StudentGoodsSell">
  109. SELECT * FROM student_goods_sell WHERE order_no_ = #{orderNo} LIMIT 1
  110. </select>
  111. <select id="getStudentGoodsSellDto" resultMap="StudentGoodsSellDto">
  112. SELECT spo.*,sgs.goods_json_,sgs.total_amount_,sgs.market_amount_ FROM student_payment_order spo
  113. LEFT JOIN student_goods_sell sgs ON spo.order_no_ = sgs.order_no_
  114. WHERE spo.order_no_ = #{orderNo} LIMIT 1
  115. </select>
  116. </mapper>