OrderMapper.xml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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.collectfee.dao.OrderDao">
  8. <resultMap type="com.ym.mec.collectfee.entity.Order" id="Order">
  9. <result column="id" property="id"/>
  10. <result column="oid" property="oid"/>
  11. <result column="branch_id" property="branchId"/>
  12. <result column="group_id" property="groupId"/>
  13. <result column="order_no" property="orderNo"/>
  14. <result column="user_id" property="userId"/>
  15. <result column="user_name" property="userName"/>
  16. <result column="amount" property="amount"/>
  17. <result column="type" property="type"/>
  18. <result column="pay" property="pay"/>
  19. <result column="bank" property="bank"/>
  20. <result column="account" property="account"/>
  21. <result column="u_account" property="uAccount"/>
  22. <result column="pay_id" property="payId"/>
  23. <result column="pay_time" property="payTime"/>
  24. <result column="remark" property="remark"/>
  25. <result column="class_id" property="classId"/>
  26. <result column="status" property="status"/>
  27. <result column="create_time" property="createTime"/>
  28. <result column="po_name" property="poName"/>
  29. <result column="voicy_part" property="voicyPart"/>
  30. <result column="balance" property="balance"/>
  31. <result column="batch_num" property="batchNum"/>
  32. <result column="tui_fee" property="tuiFee"/>
  33. <result column="goods_fee" property="goodsFee"/>
  34. <result column="sd_name" property="sdName"/>
  35. <result column="sd_fee" property="sdFee"/>
  36. </resultMap>
  37. <!-- 根据主键查询一条记录 -->
  38. <select id="get" resultMap="Order">
  39. SELECT * FROM `order` WHERE id = #{id}
  40. </select>
  41. <!-- 全查询 -->
  42. <select id="findAll" resultMap="Order">
  43. SELECT * FROM `order` ORDER BY id
  44. </select>
  45. <!-- 向数据库增加一条记录 -->
  46. <insert id="insert" parameterType="com.ym.mec.collectfee.entity.Order" useGeneratedKeys="true" keyColumn="id"
  47. keyProperty="id">
  48. <!--
  49. <selectKey resultClass="int" keyProperty="id" >
  50. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  51. </selectKey>
  52. -->
  53. INSERT INTO `order`
  54. (id,oid,order_no,branch_id,group_id,user_id,user_name,amount,type,pay,bank,account,u_account,pay_id,pay_time,remark,class_id,status,create_time,po_name,voicy_part,balance,batch_num,tui_fee,goods_fee,sd_name,sd_fee)
  55. VALUES(#{id},#{oid},#{orderNo},#{branchId},#{groupId},#{userId},#{userName},#{amount},#{type},#{pay},#{bank},#{account},#{uAccount},#{payId},#{payTime},#{remark},#{classId},#{status},#{createTime},#{poName},#{voicyPart},#{balance},#{batchNum},#{tuiFee},#{goodsFee},#{sdName},#{sdFee})
  56. </insert>
  57. <!-- 根据主键查询一条记录 -->
  58. <update id="update" parameterType="com.ym.mec.collectfee.entity.Order">
  59. UPDATE `order`
  60. <set>
  61. <if test="tuiFee != null">
  62. tui_fee = #{tuiFee},
  63. </if>
  64. <if test="goodsFee != null">
  65. goods_fee = #{goodsFee},
  66. </if>
  67. <if test="sdName != null">
  68. sd_name = #{sdName},
  69. </if>
  70. <if test="sdFee != null">
  71. sd_fee = #{sdFee},
  72. </if>
  73. <if test="amount != null">
  74. amount = #{amount},
  75. </if>
  76. <if test="classId != null">
  77. class_id = #{classId},
  78. </if>
  79. <if test="pay != null">
  80. pay = #{pay},
  81. </if>
  82. <if test="uAccount != null">
  83. u_account = #{uAccount},
  84. </if>
  85. <if test="remark != null">
  86. remark = #{remark},
  87. </if>
  88. <if test="oid != null">
  89. oid = #{oid},
  90. </if>
  91. <if test="batchNum != null">
  92. batch_num = #{batchNum},
  93. </if>
  94. <if test="payTime != null">
  95. pay_time = #{payTime},
  96. </if>
  97. <if test="bank != null">
  98. bank = #{bank},
  99. </if>
  100. <if test="balance != null">
  101. balance = #{balance},
  102. </if>
  103. <if test="userId != null">
  104. user_id = #{userId},
  105. </if>
  106. <if test="voicyPart != null">
  107. voicy_part = #{voicyPart},
  108. </if>
  109. <if test="poName != null">
  110. po_name = #{poName},
  111. </if>
  112. <if test="account != null">
  113. account = #{account},
  114. </if>
  115. <if test="payId != null">
  116. pay_id = #{payId},
  117. </if>
  118. <if test="status != null">
  119. status = #{status},
  120. </if>
  121. </set>
  122. WHERE id = #{id}
  123. </update>
  124. <!-- 根据主键删除一条记录 -->
  125. <delete id="delete">
  126. DELETE FROM `order` WHERE id = #{id}
  127. </delete>
  128. <!-- 分页查询 -->
  129. <select id="queryPage" resultMap="Order" parameterType="map">
  130. SELECT * FROM `order` ORDER BY id
  131. <include refid="global.limit"/>
  132. </select>
  133. <!-- 查询当前表的总记录数 -->
  134. <select id="queryCount" resultType="int">
  135. SELECT COUNT(*) FROM `order`
  136. </select>
  137. <select id="getOrderByUserId" resultMap="Order">
  138. SELECT * FROM `order` WHERE user_id = #{userId}
  139. </select>
  140. <select id="getOrderByClassId" resultMap="Order">
  141. SELECT * FROM `order` WHERE status=2
  142. <if test="classId != null">
  143. and class_id = #{classId}
  144. </if>
  145. <if test="type != null">
  146. and type = #{type}
  147. </if>
  148. </select>
  149. <select id="getOrderByBatch" resultMap="Order">
  150. SELECT * FROM `order` WHERE batch_num = #{batchNum}
  151. </select>
  152. <select id="countOrder" resultType="java.lang.Integer">
  153. SELECT COUNT(DISTINCT user_id) num FROM `order` WHERE po_name = #{poName} AND voicy_part = #{voicePort} AND status >= 1
  154. </select>
  155. <select id="getOrderByOrderNo" resultMap="Order">
  156. SELECT * FROM `order` WHERE order_no = #{orderNo} AND status = 1
  157. </select>
  158. <select id="findOrderByStatus" resultType="com.ym.mec.collectfee.entity.Order">
  159. SELECT * FROM `order` WHERE user_id = #{userId} AND status = #{status}
  160. </select>
  161. <!-- 获取支付中和成功的订单数-->
  162. <select id="getPayOrderNums" resultType="java.lang.Integer">
  163. SELECT COUNT(*) FROM `order` WHERE status >= 1
  164. </select>
  165. <!-- 获取支付中的订单-->
  166. <select id="findPayingOrders" resultMap="Order">
  167. SELECT * FROM `order` WHERE status = 1
  168. </select>
  169. <!-- 获取支付中和成功的订单数-->
  170. <select id="getPayingOrderNums" resultType="java.lang.Integer" parameterType="int">
  171. SELECT COUNT(*) FROM `order` WHERE `group_id`= #{groupId} AND status = 1
  172. </select>
  173. <!-- 根据id和status更新订单 -->
  174. <update id="updateByIdAndStatus" parameterType="map">
  175. UPDATE `order`
  176. <set>
  177. <if test="pay != null">
  178. pay = #{pay},
  179. </if>
  180. <if test="payTime != null">
  181. pay_time = #{payTime},
  182. </if>
  183. <if test="bank != null">
  184. bank = #{bank},
  185. </if>
  186. <if test="payId != null">
  187. pay_id = #{payId},
  188. </if>
  189. <if test="status != null">
  190. status = #{status}
  191. </if>
  192. </set>
  193. WHERE id = #{id} AND `status` = #{oldStatus}
  194. </update>
  195. <!-- 查询支付中超过30分钟的订单 -->
  196. <select id="findPayingOrdersOver" resultMap="Order" parameterType="map">
  197. SELECT * FROM `order` WHERE `order_no` IN
  198. <foreach collection="orderNoList" item="orderNo" index="index" open="(" close=")" separator=",">
  199. #{orderNo}
  200. </foreach>
  201. <![CDATA[ AND `status`=1 AND `create_time` <= ]]> #{berferTime}
  202. </select>
  203. </mapper>