TradeCheckMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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.yc.ship.module.trade.dal.mysql.order.TradeCheckMapper">
  4. <select id="getCarNumById" resultType="java.lang.Integer">
  5. select ifnull(sum(ifnull(d.quantity_of_one,1)),0) num from trade_detail d
  6. where d.deleted = 0
  7. and EXISTS (
  8. select tdb.detail_id from trade_detail_base tdb
  9. inner join dispatch_car_dispatch_order_detail_base cdo on tdb.detail_id = cdo.detail_id
  10. and tdb.id = cdo.detail_base_id and tdb.order_id = cdo.order_id
  11. and cdo.deleted = 0 and tdb.use_date = cdo.use_date and cdo.car_dispatch_id = #{dispatchId}
  12. where tdb.deleted = 0 and tdb.order_id = d.order_id
  13. and tdb.use_status in (1,2,3,4,6)
  14. and d.id = tdb.detail_id
  15. )
  16. and NOT EXISTS (
  17. SELECT t2.order_id
  18. FROM dispatch_external_resource_dispatch t1
  19. inner JOIN dispatch_external_resource_dispatch_order t2 ON t1.id=t2.dispatch_id and t2.deleted = 0
  20. where t1.deleted = 0 and t1.status = 1 and t1.is_bill = 1 and t1.car_dispatch_id = #{dispatchId} and d.order_id = t2.order_id
  21. )
  22. </select>
  23. <select id="getBatchCarNumById" resultType="java.util.Map">
  24. select p.car_dispatch_id dispatch_id,ifnull(sum(ifnull(p.quantity_of_one,1)),0) num from (
  25. select cdo.car_dispatch_id,d.id,d.quantity_of_one from trade_detail d
  26. inner join trade_detail_base tdb on d.id = tdb.detail_id
  27. inner join dispatch_car_dispatch_order_detail_base cdo on tdb.detail_id = cdo.detail_id
  28. and tdb.id = cdo.detail_base_id and tdb.order_id = cdo.order_id
  29. and tdb.id = cdo.detail_base_id
  30. and cdo.deleted = 0 and tdb.use_date = cdo.use_date
  31. and cdo.car_dispatch_id in
  32. <foreach collection="dispatchIds" item="item" separator="," open="(" close=")">
  33. #{item}
  34. </foreach>
  35. where tdb.deleted = 0 and tdb.order_id = d.order_id
  36. and tdb.use_status in(1,2,3,4,6)
  37. and d.deleted = 0
  38. and NOT EXISTS (
  39. SELECT t2.order_id
  40. FROM dispatch_external_resource_dispatch t1
  41. inner JOIN dispatch_external_resource_dispatch_order t2 ON t1.id=t2.dispatch_id and t2.deleted = 0
  42. where t1.deleted = 0 and t1.status = 1 and t1.is_bill = 1
  43. and cdo.car_dispatch_id in
  44. <foreach collection="dispatchIds" item="item" separator="," open="(" close=")">
  45. #{item}
  46. </foreach>
  47. and d.order_id = t2.order_id
  48. )
  49. GROUP BY cdo.car_dispatch_id,d.id
  50. ) p GROUP BY p.car_dispatch_id
  51. </select>
  52. <select id="getBatchBoatNumById" resultType="java.util.Map">
  53. SELECT
  54. plan_id dispatch_id,ifnull( sum( ifnull( p.quantity_of_one, 1 ) ), 0 ) num from (SELECT
  55. cdo.plan_id,
  56. d.id,
  57. d.quantity_of_one
  58. FROM
  59. trade_detail d
  60. INNER JOIN trade_detail_base tdb
  61. on d.id = tdb.detail_id
  62. INNER JOIN dispatch_operate_plan_boat_order_detail_base cdo ON tdb.detail_id = cdo.detail_id
  63. AND tdb.id = cdo.detail_base_id
  64. AND tdb.order_id = cdo.order_id
  65. AND cdo.deleted = 0
  66. AND tdb.use_date = cdo.use_date
  67. and cdo.plan_id in
  68. <foreach collection="dispatchIds" item="item" separator="," open="(" close=")">
  69. #{item}
  70. </foreach>
  71. WHERE
  72. tdb.deleted = 0
  73. AND tdb.order_id = d.order_id
  74. AND tdb.use_status IN ( 1, 2, 3, 4, 6 )
  75. AND d.deleted = 0
  76. GROUP BY
  77. cdo.plan_id,
  78. d.id
  79. ) p GROUP BY plan_id
  80. </select>
  81. <select id="getBoatNumById" resultType="java.lang.Integer">
  82. select ifnull(sum(ifnull(d.quantity_of_one,1)),0) num from trade_detail d
  83. where d.deleted = 0 and EXISTS (
  84. select tdb.detail_id from trade_detail_base tdb
  85. inner join dispatch_operate_plan_boat_order_detail_base cdo on tdb.detail_id = cdo.detail_id
  86. and tdb.id = cdo.detail_base_id and tdb.order_id = cdo.order_id
  87. and cdo.deleted = 0 and tdb.use_date = cdo.use_date and cdo.plan_id = #{dispatchId}
  88. where tdb.deleted = 0 and tdb.order_id = d.order_id
  89. and tdb.use_status in(1,2,3,4,6) and d.id = tdb.detail_id
  90. )
  91. </select>
  92. <select id="pdaCheckTotalCount" resultType="java.lang.Integer">
  93. select count(distinct t4.id) num from trade_check t1
  94. inner join trade_check_detail t3 on t1.id = t3.check_id
  95. inner join trade_detail t2 on t1.detail_id = t2.id
  96. inner join trade_visitor t4 on t2.id = t4.detail_id
  97. where t3.dispatch_batch_id = #{dispatchId} and t2.voucher_status in (3,6,8,9)
  98. </select>
  99. <resultMap id="TradeCheckResultMap" type="com.yc.ship.module.trade.controller.admin.order.vo.check.CheckRespVO">
  100. <result property="id" column="id"/>
  101. <result property="operatorId" column="operator_id"/>
  102. <result property="type" column="type"/>
  103. <result property="orderId" column="order_id"/>
  104. <result property="detailId" column="detail_id"/>
  105. <result property="voucherCode" column="voucher_code"/>
  106. <result property="originalStatus" column="original_status"/>
  107. <association property="tradeDetailRespVO" resultMap="tradeDetailMap"/>
  108. </resultMap>
  109. <resultMap id="tradeDetailMap" type="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeDetailRespVO">
  110. <result property="id" column="detail_id"/>
  111. <result property="orderId" column="order_id"/>
  112. <result property="orderNo" column="order_no"/>
  113. <result property="voucherCode" column="voucher_code"/>
  114. <result property="voucherStatus" column="voucher_status"/>
  115. <result property="useDate" column="use_date"/>
  116. <result property="validityStartDate" column="validity_start_date"/>
  117. <result property="validityEndDate" column="validity_end_date"/>
  118. <result property="productId" column="product_id"/>
  119. <result property="productName" column="product_name"/>
  120. <result property="specType" column="spec_type"/>
  121. <collection property="visitors" resultMap="visitorResultMap"/>
  122. <collection property="detailBaseList" resultMap="tradeDetailBaseResMap"/>
  123. </resultMap>
  124. <resultMap id="visitorResultMap" type="com.yc.ship.module.trade.dal.dataobject.order.TradeVisitorDO">
  125. <id property="id" column="visitorId"/>
  126. <result property="detailId" column="detail_id"/>
  127. <result property="name" column="name"/>
  128. <result property="gender" column="gender"/>
  129. <result property="credentialNo" column="credential_no"/>
  130. <result property="credentialType" column="credential_type"/>
  131. <result property="mobile" column="mobile"/>
  132. <result property="otaDetailId" column="ota_detail_id"/>
  133. <result property="isInsure" column="is_insure"/>
  134. </resultMap>
  135. <resultMap id="tradeDetailBaseResMap" type="com.yc.ship.module.trade.controller.admin.order.vo.order.DetailBaseRespVO">
  136. <result property="id" column="detail_base_id"/>
  137. <result property="detailId" column="detailId"/>
  138. <result property="productBaseId" column="product_base_id"/>
  139. <result property="productBaseName" column="product_base_name"/>
  140. <result property="productBaseType" column="product_base_type"/>
  141. <result property="productResourceId" column="product_resource_id"/>
  142. <result property="productResourceName" column="product_resource_name"/>
  143. <result property="supplierProductId" column="supplier_product_id"/>
  144. <result property="supplierId" column="supplier_id"/>
  145. <result property="supplierName" column="supplier_name"/>
  146. <result property="useStatus" column="use_status"/>
  147. <result property="checkStatus" column="base_check_status"/>
  148. <result property="verifyTime" column="base_verify_time"/>
  149. <result property="usageCount" column="usage_count"/>
  150. <result property="productResourcePrice" column="product_resource_price"/>
  151. <result property="projectId" column="project_id"/>
  152. <result property="projectName" column="project_name"/>
  153. <result property="specificationId" column="specification_id"/>
  154. <result property="specificationName" column="specification_name"/>
  155. <result property="specType" column="base_spec_type"/>
  156. </resultMap>
  157. <select id="querySimpleCheckPage" resultType="com.yc.ship.module.trade.controller.admin.order.vo.check.CheckRespVO">
  158. SELECT tc.*,tc.create_time checkTime, td.route_plan_id routePlanId, td.order_no orderNo, u.contact_name contactName, u.mobile
  159. from trade_check tc
  160. INNER JOIN trade_order td on td.id= tc.order_id
  161. INNER JOIN trade_order_user u on u.order_id = tc.order_id
  162. where 1= 1
  163. <if test="param.machineId != null and param.machineId != ''">
  164. AND tc.machine_id =#{param.machineId}
  165. </if>
  166. <if test="param.orderId != null and param.orderId != ''">
  167. AND tc.order_id =#{param.orderId}
  168. </if>
  169. <if test="param.detailId != null and param.detailId != ''">
  170. AND tc.detail_id =#{param.detailId}
  171. </if>
  172. <if test="param.voucherCode != null and param.voucherCode != ''">
  173. AND tc.voucher_code =#{param.voucherCode}
  174. </if>
  175. <if test="param.operatorId != null and param.operatorId != ''">
  176. AND tc.operator_id =#{param.operatorId}
  177. </if>
  178. <if test="param.beginTime != null">
  179. and tc.create_time <![CDATA[>= ]]> #{param.beginTime}
  180. </if>
  181. <if test="param.endTime != null">
  182. and tc.create_time <![CDATA[<= ]]> #{param.endTime}
  183. </if>
  184. <if test="param.type != null ">
  185. AND tc.type=#{param.type}
  186. </if>
  187. <if test="param.orderNo != null and param.orderNo != ''">
  188. AND td.order_no=#{param.orderNo}
  189. </if>
  190. <if test="param.operatorName != null and param.operatorName != ''">
  191. AND tc.operator_name like concat('%', #{param.operatorName} ,'%')
  192. </if>
  193. order by tc.create_time desc
  194. </select>
  195. </mapper>