StudentGoodsSellMapper.xml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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="username_" property="userName" />
  17. <result column="organ_id_" property="organId" />
  18. <result column="author_user_" property="authorUser" />
  19. <result column="cooperation_organ_id_" property="cooperationOrganId" />
  20. <result column="create_time_" property="createTime" />
  21. <result column="update_time_" property="updateTime" />
  22. </resultMap>
  23. <!-- 根据主键查询一条记录 -->
  24. <select id="get" resultMap="StudentGoodsSell" >
  25. SELECT sgs.*,su.username_ FROM student_goods_sell sgs
  26. LEFT JOIN sys_user su ON su.id_ = sgs.user_id_
  27. WHERE sgs.id_ = #{id}
  28. </select>
  29. <!-- 全查询 -->
  30. <select id="findAll" resultMap="StudentGoodsSell">
  31. SELECT * FROM student_goods_sell ORDER BY id_
  32. </select>
  33. <!-- 向数据库增加一条记录 -->
  34. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentGoodsSell" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  35. INSERT INTO student_goods_sell (user_id_,teacher_id_,goods_json_,total_amount_,market_amount_,
  36. create_time_,update_time_,order_no_,organ_id_,author_user_,cooperation_organ_id_)
  37. VALUES(#{userId},#{teacherId},#{goodsJson},#{totalAmount},#{marketAmount},
  38. NOW(),NOW(),#{orderNo},#{organId},#{authorUser},#{cooperationOrganId})
  39. </insert>
  40. <!-- 根据主键查询一条记录 -->
  41. <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentGoodsSell">
  42. UPDATE student_goods_sell <set>
  43. <if test="cooperationOrganId != null">
  44. cooperation_organ_id_ = #{cooperationOrganId},
  45. </if>
  46. <if test="authorUser != null">
  47. author_user_ = #{authorUser},
  48. </if>
  49. <if test="organId != null">
  50. organ_id_ = #{organId},
  51. </if>
  52. <if test="orderNo != null">
  53. order_no_ = #{orderNo},
  54. </if>
  55. <if test="userId != null">
  56. user_id_ = #{userId},
  57. </if>
  58. <if test="totalAmount != null">
  59. total_amount_ = #{totalAmount},
  60. </if>
  61. <if test="marketAmount != null">
  62. market_amount_ = #{marketAmount},
  63. </if>
  64. <if test="teacherId != null">
  65. teacher_id_ = #{teacherId},
  66. </if>
  67. <if test="goodsJson != null">
  68. goods_json_ = #{goodsJson},
  69. </if>
  70. update_time_ = NOW()
  71. </set> WHERE id_ = #{id}
  72. </update>
  73. <update id="autoAffirmReceive">
  74. UPDATE student_payment_order SET receive_status_ = #{status},update_time_ = NOW() WHERE FIND_IN_SET(order_no_,#{orderNo})
  75. </update>
  76. <!-- 根据主键删除一条记录 -->
  77. <delete id="delete" >
  78. DELETE FROM student_goods_sell WHERE id_ = #{id}
  79. </delete>
  80. <!-- 分页查询 -->
  81. <select id="queryPage" resultMap="StudentGoodsSell" parameterType="map">
  82. SELECT * FROM student_goods_sell ORDER BY id_ <include refid="global.limit"/>
  83. </select>
  84. <!-- 查询当前表的总记录数 -->
  85. <select id="queryCount" resultType="int">
  86. SELECT COUNT(*) FROM student_goods_sell
  87. </select>
  88. <select id="countStudentGoodsOrders" resultType="java.lang.Integer">
  89. SELECT COUNT(spo.id_) FROM student_payment_order spo
  90. LEFT JOIN student_goods_sell sgs ON spo.order_no_ = sgs.order_no_
  91. LEFT JOIN sys_user su ON sgs.user_id_ = su.id_
  92. <include refid="queryStudentGoodsOrdersSql"/>
  93. </select>
  94. <resultMap type="com.ym.mec.biz.dal.dto.StudentGoodsSellDto" id="StudentGoodsSellDto" extends="com.ym.mec.biz.dal.dao.StudentPaymentOrderDao.StudentPaymentOrder">
  95. <result column="goods_json_" property="goodsJson" />
  96. <result column="total_amount_" property="totalAmount" />
  97. <result column="market_amount_" property="marketAmount" />
  98. <result column="username_" property="userName" />
  99. <result column="author_user_" property="authorUser" />
  100. </resultMap>
  101. <sql id="queryStudentGoodsOrdersSql">
  102. <where>
  103. <if test="teacherId != null">
  104. sgs.teacher_id_ = #{teacherId}
  105. </if>
  106. <if test="studentId != null">
  107. AND sgs.user_id_ = #{studentId}
  108. </if>
  109. <if test="status != null">
  110. AND spo.status_ = #{status}
  111. </if>
  112. <if test="receiveStatus != null and receiveStatus != ''">
  113. AND spo.receive_status_ = #{receiveStatus}
  114. </if>
  115. <if test="search != null and search != ''">
  116. AND (su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  117. </if>
  118. </where>
  119. </sql>
  120. <select id="queryStudentGoodsOrders" resultMap="StudentGoodsSellDto">
  121. SELECT spo.*,sgs.goods_json_,sgs.total_amount_,sgs.market_amount_,su.username_,sgs.author_user_
  122. FROM student_payment_order spo
  123. LEFT JOIN student_goods_sell sgs ON spo.order_no_ = sgs.order_no_
  124. LEFT JOIN sys_user su ON sgs.user_id_ = su.id_
  125. <include refid="queryStudentGoodsOrdersSql"/>
  126. ORDER BY spo.create_time_ DESC
  127. <include refid="global.limit"/>
  128. </select>
  129. <select id="findByOrderNo" resultMap="StudentGoodsSell">
  130. SELECT * FROM student_goods_sell WHERE order_no_ = #{orderNo} LIMIT 1
  131. </select>
  132. <select id="getStudentGoodsSellDto" resultMap="StudentGoodsSellDto">
  133. SELECT spo.*,sgs.goods_json_,sgs.total_amount_,sgs.market_amount_ FROM student_payment_order spo
  134. LEFT JOIN student_goods_sell sgs ON spo.order_no_ = sgs.order_no_
  135. WHERE spo.order_no_ = #{orderNo} LIMIT 1
  136. </select>
  137. <select id="queryNoAffirmOrderNo" resultType="java.lang.String">
  138. SELECT GROUP_CONCAT(DISTINCT so.order_no_) FROM sell_order so
  139. LEFT JOIN student_payment_order spo ON spo.order_no_ = so.order_no_
  140. WHERE spo.status_ = 'SUCCESS' AND TIMESTAMPDIFF(HOUR,spo.pay_time_,NOW()) >= #{autoAffirmReceiveTime}
  141. </select>
  142. <resultMap type="com.ym.mec.biz.dal.dto.StudentPaymentOrderDto" id="StudentPaymentOrderDto" extends="com.ym.mec.biz.dal.dao.StudentPaymentOrderDao.StudentPaymentOrder">
  143. <result column="goods_image_" property="image" />
  144. <result column="goods_name_" property="goodsName" />
  145. <result column="goods_num_" property="goodsNum" />
  146. <result column="goods_amount_" property="goodsAmount" />
  147. </resultMap>
  148. <sql id="queryStudentPaymentOrdersSql">
  149. <where>
  150. spo.type_ IN ('GOODS_SELL','APPLY','SUBJECT_CHANGE') AND so.id_ IS NOT NULL
  151. <if test="status != null">
  152. AND spo.status_ = #{status}
  153. </if>
  154. <if test="receiveStatus != null and receiveStatus != ''">
  155. AND spo.receive_status_ = #{receiveStatus}
  156. </if>
  157. <if test="studentId != null">
  158. AND spo.user_id_ = #{studentId}
  159. </if>
  160. </where>
  161. </sql>
  162. <select id="queryStudentPaymentOrders" resultMap="StudentPaymentOrderDto">
  163. SELECT spo.*,g.image_ goods_image_,g.name_ goods_name_,so.num_ goods_num_,so.expect_amount_ goods_amount_
  164. FROM student_payment_order spo
  165. LEFT JOIN sell_order so ON so.order_no_ = spo.order_no_
  166. LEFT JOIN goods g ON g.id_ = so.goods_id_
  167. <include refid="queryStudentPaymentOrdersSql"/>
  168. ORDER BY spo.pay_time_ DESC
  169. <include refid="global.limit"/>
  170. </select>
  171. <select id="countStudentPaymentOrders" resultType="java.lang.Integer">
  172. SELECT COUNT(DISTINCT spo.id_)
  173. FROM student_payment_order spo
  174. LEFT JOIN sell_order so ON so.order_no_ = spo.order_no_
  175. <include refid="queryStudentPaymentOrdersSql"/>
  176. </select>
  177. </mapper>