KwtLogisticsOrderMapper.xml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  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.sckw.transport.dao.KwtLogisticsOrderMapper">
  4. <resultMap id="BaseResultMap" type="com.sckw.transport.model.KwtLogisticsOrder">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="ent_id" jdbcType="BIGINT" property="entId"/>
  7. <result column="type" jdbcType="BIGINT" property="type"/>
  8. <result column="t_order_id" jdbcType="BIGINT" property="tOrderId"/>
  9. <result column="t_order_no" jdbcType="VARCHAR" property="tOrderNo"/>
  10. <result column="l_order_no" jdbcType="VARCHAR" property="lOrderNo"/>
  11. <result column="pid" jdbcType="BIGINT" property="pid"/>
  12. <result column="pids" jdbcType="VARCHAR" property="pids"/>
  13. <result column="level" jdbcType="VARCHAR" property="level"/>
  14. <result column="bind_status" jdbcType="VARCHAR" property="bindStatus"/>
  15. <result column="total_load_amount" jdbcType="VARCHAR" property="totalLoadAmount"/>
  16. <result column="total_unload_amount" jdbcType="VARCHAR" property="totalUnloadAmount"/>
  17. <result column="settlement_cycle" jdbcType="BIGINT" property="settlementCycle"/>
  18. <result column="billing_mode" jdbcType="BIGINT" property="billingMode"/>
  19. <result column="price" jdbcType="DECIMAL" property="price"/>
  20. <result column="price_type" jdbcType="BIGINT" property="priceType"/>
  21. <result column="amount" jdbcType="DECIMAL" property="amount"/>
  22. <result column="unit" jdbcType="VARCHAR" property="unit"/>
  23. <result column="loss" jdbcType="DECIMAL" property="loss"/>
  24. <result column="loss_unit" jdbcType="VARCHAR" property="lossUnit"/>
  25. <result column="goods_price" jdbcType="DECIMAL" property="goodsPrice"/>
  26. <result column="goods_price_unit" jdbcType="VARCHAR" property="goodsPriceUnit"/>
  27. <result column="start_time" jdbcType="TIMESTAMP" property="startTime"/>
  28. <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
  29. <result column="subcontract_amount" jdbcType="DECIMAL" property="subcontractAmount"/>
  30. <result column="entrust_amount" jdbcType="DECIMAL" property="entrustAmount"/>
  31. <result column="unload_amount" jdbcType="DECIMAL" property="unloadAmount"/>
  32. <result column="load_amount" jdbcType="DECIMAL" property="loadAmount"/>
  33. <result column="ignore_amount" jdbcType="DECIMAL" property="ignoreAmount"/>
  34. <result column="deficit_amount" jdbcType="DECIMAL" property="deficitAmount"/>
  35. <result column="deficit_price" jdbcType="DECIMAL" property="deficitPrice"/>
  36. <result column="payment" jdbcType="BIGINT" property="payment"/>
  37. <result column="tax_rate" jdbcType="DECIMAL" property="taxRate"/>
  38. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  39. <result column="status" jdbcType="INTEGER" property="status"/>
  40. <result column="create_by" jdbcType="BIGINT" property="createBy"/>
  41. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  42. <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
  43. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  44. <result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
  45. </resultMap>
  46. <sql id="Base_Column_List">
  47. id
  48. , ent_id, t_order_id,type,level,bind_status,total_load_amount,total_unload_amount, t_order_no, l_order_no, pid,pids, settlement_cycle, price, price_type,billing_mode,
  49. amount, unit, loss, loss_unit, goods_price, goods_price_unit, start_time, end_time,
  50. subcontract_amount, entrust_amount, unload_amount, load_amount, ignore_amount, deficit_amount,
  51. deficit_price, payment, tax_rate, remark, `status`, create_by, create_time, update_by,
  52. update_time, del_flag
  53. </sql>
  54. <select id="selectOrderList" resultType="com.sckw.transport.model.dto.LogisticsOrderDTO">
  55. SELECT a.id as lOrderId,
  56. a.l_order_no as lOrderNo,
  57. b.`status` as `status`,
  58. a.t_order_id as tOrderId,
  59. a.t_order_no as tOrderNo,
  60. a.payment as payment,
  61. a.amount,
  62. a.price,
  63. a.loss,
  64. a.goods_price as goodsPrice,
  65. c.firm_name as comanyName,
  66. c.contacts,
  67. c.phone,
  68. a.create_by as createBy,
  69. a.create_time as createTime
  70. FROM kwt_logistics_order a
  71. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id and a.`status` = b.`status`
  72. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
  73. WHERE a.del_flag = '0'
  74. AND b.del_flag = '0'
  75. AND a.t_order_id = #{id,jdbcType=VARCHAR} limit #{page}
  76. , #{pageSize}
  77. </select>
  78. <select id="selectOrderListNotPage" resultType="com.sckw.transport.model.dto.LogisticsOrderDTO">
  79. SELECT a.id as lOrderId,
  80. a.l_order_no as lOrderNo,
  81. b.`status` as `status`,
  82. a.t_order_id as tOrderId,
  83. a.t_order_no as tOrderNo,
  84. a.payment as payment,
  85. a.amount,
  86. a.price,
  87. a.loss,
  88. a.goods_price as goodsPrice,
  89. c.firm_name as companyName,
  90. c.contacts,
  91. c.phone,
  92. a.create_by as createBy,
  93. a.create_time as createTime
  94. FROM kwt_logistics_order a
  95. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id and a.`status` = b.`status`
  96. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
  97. WHERE a.del_flag = '0'
  98. AND b.del_flag = '0'
  99. AND a.t_order_id = #{id,jdbcType=VARCHAR}
  100. order by createTime desc
  101. </select>
  102. <select id="selectOrderCount" resultType="java.lang.Long">
  103. SELECT count(a.id)
  104. FROM kwt_logistics_order a
  105. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id and a.`status` = b.`status`
  106. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
  107. WHERE a.del_flag = '0'
  108. AND b.del_flag = '0'
  109. AND a.t_order_id = #{id,jdbcType=VARCHAR}
  110. </select>
  111. <select id="selectLogisticOrderData" resultType="com.sckw.transport.api.model.vo.LogisticsOrderVO">
  112. SELECT
  113. DISTINCT a.id AS lOrderId,
  114. a.l_order_no AS lOrderNO,
  115. a.t_order_id AS tOrderId,
  116. a.t_order_no AS tOrderNO,
  117. a.payment AS payment,
  118. a.billing_mode AS billingMode,
  119. c.contract_id AS contractId,
  120. b.goods_name AS goodsName,
  121. a.amount,
  122. a.unit ,
  123. a.ignore_amount AS ignoreAmount,
  124. a.price,
  125. a.price_type as priceType,
  126. a.goods_price AS goodsPrice,
  127. a.loss,
  128. a.loss_unit AS lossUnit,
  129. a.tax_rate as taxRate,
  130. a.load_amount AS loadAmount,
  131. a.unload_amount AS unloadAmount,
  132. a.settlement_cycle as settlementCycle,
  133. a.start_time AS startTime,
  134. a.end_time AS endTime,
  135. a.create_time AS createTime,
  136. a.create_by AS createBy,
  137. a.update_by AS updateBy,
  138. a.update_time AS updateTime
  139. FROM
  140. kwt_logistics_order a
  141. LEFT JOIN kwt_logistics_order_goods b ON a.id = b.l_order_id and a.bind_status = '0'
  142. <!-- LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id-->
  143. LEFT JOIN kwt_logistics_order_contract c ON a.id = c.l_order_id
  144. <!-- LEFT JOIN ( SELECT l_order_id FROM kwt_logistics_order_unit WHERE unit_type = 1 AND ent_id = #{entId} ) g ON a.id = g.l_order_id-->
  145. <!-- LEFT JOIN ( SELECT ent_id FROM kwt_logistics_order_unit WHERE unit_type = 1 AND ent_id = #{entId} ) g ON a.id = g.l_order_id-->
  146. LEFT JOIN kwt_logistics_order_unit g on a.id =g.l_order_id and g.unit_type=1
  147. <where>
  148. a.del_flag = 0 and a.bind_status = '0' <!--and d.unit_type = 1-->
  149. <if test="dictValue != null and dictValue != ''">
  150. AND a.payment = #{dictValue}
  151. </if>
  152. <if test="logisticsOrderParam.companyId !=null and logisticsOrderParam.companyId != ''">
  153. <!-- AND d.ent_id = #{logisticsOrderParam.companyId}-->
  154. AND g.ent_id = #{logisticsOrderParam.companyId}
  155. </if>
  156. <if test="logisticsOrderParam.taxRate != null and logisticsOrderParam.taxRate != ''">
  157. AND a.tax_rate = #{logisticsOrderParam.taxRate}
  158. </if>
  159. <if test="logisticsOrderParam.goodsName != null and logisticsOrderParam.goodsName != ''">
  160. AND b.goods_name LIKE concat('%',#{logisticsOrderParam.goodsName},'%')
  161. </if>
  162. <if test="logisticsOrderParam.startTime != null and logisticsOrderParam.startTime !=''">
  163. AND a.start_time &gt;= #{logisticsOrderParam.startTime}
  164. </if>
  165. <if test="logisticsOrderParam.endTime != null and logisticsOrderParam.endTime !=''">
  166. AND a.end_time &lt;= #{logisticsOrderParam.endTime}
  167. </if>
  168. </where>
  169. ORDER BY a.create_time DESC
  170. <if test="logisticsOrderParam.page != null and logisticsOrderParam.pageSize != null ">
  171. limit #{logisticsOrderParam.page,jdbcType=INTEGER},#{logisticsOrderParam.pageSize,jdbcType=INTEGER}
  172. </if>
  173. </select>
  174. <select id="selectLogisticOrderCount" resultType="java.lang.Long">
  175. SELECT
  176. count(a.id)
  177. FROM
  178. kwt_logistics_order a
  179. LEFT JOIN kwt_logistics_order_goods b ON a.id = b.l_order_id
  180. LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
  181. LEFT JOIN kwt_logistics_order_contract c ON a.id=c.l_order_id
  182. <where>
  183. a.del_flag = 0 and d.unit_type = 1
  184. <if test="dictValue != null and dictValue != ''">
  185. AND a.payment = #{dictValue}
  186. </if>
  187. <if test="logisticsOrderParam.companyId !=null and logisticsOrderParam.companyId != ''">
  188. AND d.ent_id = #{logisticsOrderParam.companyId}
  189. </if>
  190. <if test="logisticsOrderParam.taxRate != null and logisticsOrderParam.taxRate != ''">
  191. AND a.tax_rate = #{logisticsOrderParam.taxRate}
  192. </if>
  193. <if test="logisticsOrderParam.goodsName != null and logisticsOrderParam.goodsName != ''">
  194. AND b.goods_name LIKE concat('%',#{logisticsOrderParam.goodsName},'%')
  195. </if>
  196. <if test="logisticsOrderParam.startTime != null and logisticsOrderParam.startTime !=''">
  197. AND a.start_time &gt;= #{logisticsOrderParam.startTime}
  198. </if>
  199. <if test="logisticsOrderParam.endTime != null and logisticsOrderParam.endTime !=''">
  200. AND a.end_time &lt;= #{logisticsOrderParam.endTime}
  201. </if>
  202. </where>
  203. ORDER BY a.create_time DESC
  204. </select>
  205. <select id="getRejectReason" resultType="java.util.Map">
  206. SELECT a.id AS lOrderId,
  207. b.remark remark
  208. FROM kwt_logistics_order a
  209. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id
  210. WHERE a.del_flag = '0'
  211. AND b.del_flag = '0'
  212. and b.status = #{status}
  213. and a.id = #{id}
  214. </select>
  215. <select id="getSubcontractConsignment" resultType="com.sckw.transport.model.vo.SubcontractConsignmentVO">
  216. SELECT a.id,
  217. a.pid,
  218. a.`status` as status,
  219. a.l_order_no as consignOrderNo,
  220. c.firm_name as carrierContacts,
  221. d.goods_name as goodsName,
  222. a.amount as amount,
  223. a.price,
  224. a.price_type as priceType,
  225. e.detail_address as loadAddress,
  226. f.detail_address as unloadAddress,
  227. a.billing_mode as billingMode,
  228. a.loss,
  229. a.loss_unit as lossUnit,
  230. a.goods_price as goodsPrice,
  231. a.goods_price_unit as goodsPriceUnit,
  232. a.settlement_cycle as settlementCycle,
  233. c.contacts as carrierContacts,
  234. c.phone as carrierPhone,
  235. b.firm_name as consignCompany,
  236. b.contacts as consignContacts,
  237. b.phone as consignPhone,
  238. e.contacts as loadContacts,
  239. e.phone as loadContacts,
  240. f.contacts as unloadContacts,
  241. f.phone as unloadPhone,
  242. a.start_time as shipmentsDate,
  243. a.end_time as receiveGoodsDate,
  244. a.remark,
  245. a.create_by as createBy,
  246. a.create_time as createTime,
  247. g.contract_id as contractId
  248. FROM kwt_logistics_order a
  249. LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  250. AND b.unit_type = 1
  251. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id
  252. AND c.unit_type = 2
  253. LEFT JOIN kwt_logistics_order_goods d ON a.id = d.l_order_id
  254. LEFT JOIN kwt_logistics_order_address e ON a.id = e.l_order_id
  255. AND e.address_type = 1
  256. LEFT JOIN kwt_logistics_order_address f ON a.id = f.l_order_id
  257. AND f.address_type = 2
  258. LEFT JOIN kwt_logistics_order_contract g ON a.id = g.l_order_id
  259. WHERE a.del_flag = 0
  260. AND b.del_flag = 0
  261. AND c.del_flag = 0
  262. AND e.del_flag = 0
  263. AND f.del_flag = 0
  264. and a.pid = #{lOrderId}
  265. ORDER BY a.create_time
  266. limit #{page}, #{pageSize}
  267. </select>
  268. <select id="getSubcontractConsignmentNotPage" resultType="com.sckw.transport.model.vo.SubcontractConsignmentVO">
  269. SELECT a.id,
  270. a.pid,
  271. a.`status` as status,
  272. a.l_order_no as consignOrderNo,
  273. c.firm_name as carrierContacts,
  274. d.goods_name as goodsName,
  275. a.amount as amount,
  276. a.price,
  277. a.price_type as priceType,
  278. e.detail_address as loadAddress,
  279. f.detail_address as unloadAddress,
  280. a.billing_mode as billingMode,
  281. a.loss,
  282. a.loss_unit as lossUnit,
  283. a.goods_price as goodsPrice,
  284. a.goods_price_unit as goodsPriceUnit,
  285. a.settlement_cycle as settlementCycle,
  286. c.contacts as carrierContacts,
  287. c.phone as carrierPhone,
  288. b.firm_name as consignCompany,
  289. b.contacts as consignContacts,
  290. b.phone as consignPhone,
  291. e.contacts as loadContacts,
  292. e.phone as loadContacts,
  293. f.contacts as unloadContacts,
  294. f.phone as unloadPhone,
  295. a.start_time as shipmentsDate,
  296. a.end_time as receiveGoodsDate,
  297. a.remark,
  298. a.create_by as createBy,
  299. a.create_time as createTime,
  300. g.contract_id as contractId
  301. FROM kwt_logistics_order a
  302. LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  303. AND b.unit_type = 1
  304. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id
  305. AND c.unit_type = 2
  306. LEFT JOIN kwt_logistics_order_goods d ON a.id = d.l_order_id
  307. LEFT JOIN kwt_logistics_order_address e ON a.id = e.l_order_id
  308. AND e.address_type = 1
  309. LEFT JOIN kwt_logistics_order_address f ON a.id = f.l_order_id
  310. AND f.address_type = 2
  311. LEFT JOIN kwt_logistics_order_contract g ON a.id = g.l_order_id
  312. WHERE a.del_flag = 0
  313. AND b.del_flag = 0
  314. AND c.del_flag = 0
  315. AND e.del_flag = 0
  316. AND f.del_flag = 0
  317. and a.pid = #{lOrderId}
  318. ORDER BY a.create_time desc
  319. </select>
  320. <select id="countSubcontractConsignmentById" resultType="java.util.Map">
  321. SELECT COUNT(0) as total,
  322. a.id,
  323. a.pid,
  324. a.`status` as status,
  325. a.l_order_no as consignOrderNo,
  326. c.firm_name as carrierContacts,
  327. d.goods_name as goodsName,
  328. a.amount as amount,
  329. a.price,
  330. a.price_type as priceType,
  331. e.detail_address as loadAddress,
  332. f.detail_address as unloadAddress,
  333. a.billing_mode as billingMode,
  334. a.loss,
  335. a.loss_unit as lossUnit,
  336. a.goods_price as goodsPrice,
  337. a.goods_price_unit as goodsPriceUnit,
  338. a.settlement_cycle as settlementCycle,
  339. c.contacts as carrierContacts,
  340. c.phone as carrierPhone,
  341. b.firm_name as consignCompany,
  342. b.contacts as consignContacts,
  343. b.phone as consignPhone,
  344. e.contacts as loadContacts,
  345. e.phone as loadContacts,
  346. f.contacts as unloadContacts,
  347. f.phone as unloadPhone,
  348. a.start_time as shipmentsDate,
  349. a.end_time as receiveGoodsDate,
  350. a.remark,
  351. a.create_by as createBy,
  352. a.create_time as createTime,
  353. g.contract_id as contractId
  354. FROM kwt_logistics_order a
  355. LEFT JOIN kwt_logistics_order_unit b ON a.id = b.l_order_id
  356. AND b.unit_type = 1
  357. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id
  358. AND c.unit_type = 2
  359. LEFT JOIN kwt_logistics_order_goods d ON a.id = d.l_order_id
  360. LEFT JOIN kwt_logistics_order_address e ON a.id = e.l_order_id
  361. AND e.address_type = 1
  362. LEFT JOIN kwt_logistics_order_address f ON a.id = f.l_order_id
  363. AND f.address_type = 2
  364. LEFT JOIN kwt_logistics_order_contract g ON a.id = g.l_order_id
  365. WHERE a.del_flag = 0
  366. AND b.del_flag = 0
  367. AND c.del_flag = 0
  368. AND e.del_flag = 0
  369. AND f.del_flag = 0
  370. and a.pid = #{lOrderId}
  371. ORDER BY a.create_time
  372. </select>
  373. <select id="selectDriverListById" resultType="com.sckw.transport.model.vo.DriverListVo">
  374. SELECT a.id AS lOrderId,
  375. b.driver_id AS driverId,
  376. b.id AS wOrderId,
  377. b.w_order_no AS wOrderNo,
  378. b.driver_name AS driverName,
  379. b.driver_phone AS driverPhone,
  380. b.driver_idcard AS driverIdCard,
  381. b.truck_no AS truckNo,
  382. COUNT( b.id ) AS count,
  383. b.`status` as transportStatus
  384. FROM
  385. kwt_waybill_order b,
  386. kwt_logistics_order_circulate c,
  387. kwt_logistics_order a
  388. WHERE
  389. a.id = c.l_order_id
  390. AND a.id = b.l_order_id
  391. AND a.del_flag = 0
  392. AND b.del_flag = 0
  393. AND b.type = '2'
  394. AND c.`status` = '0'
  395. <if test="driverParam.lOrderId != null and driverParam.lOrderId != ''">
  396. AND a.id =#{driverParam.lOrderId}
  397. </if>
  398. <if test="driverParam.driverName != null and driverParam.driverName != ''">
  399. and b.driver_name like concat('%',#{driverParam.driverName},'%')
  400. </if>
  401. <if test="driverParam.driverPhone != null and driverParam.driverPhone != ''">
  402. <!-- AND b.driver_phone =#{driverParam.driverPhone}-->
  403. AND b.driver_phone like concat('%',#{driverParam.driverPhone},'%')
  404. </if>
  405. <if test="driverParam.truckNo != null and driverParam.truckNo != ''">
  406. <!-- AND b.truck_no = #{driverParam.truckNo}-->
  407. AND b.truck_no like concat('%',#{driverParam.truckNo},'%')
  408. </if>
  409. GROUP BY b.truck_no
  410. </select>
  411. <select id="selectLogisticOrderList" resultType="com.sckw.transport.api.model.dto.LogisticsOrderDTO">
  412. SELECT
  413. DISTINCT a.id AS lOrderId,
  414. a.l_order_no AS lOrderNO,
  415. a.t_order_id AS tOrderId,
  416. a.t_order_no AS tOrderNO,
  417. a.payment AS payment,
  418. a.billing_mode AS billingMode,
  419. c.contract_id AS contractId,
  420. b.goods_name AS goodsName,
  421. a.amount,
  422. a.unit ,
  423. a.ignore_amount AS ignoreAmount,
  424. a.price,
  425. a.price_type as priceType,
  426. a.goods_price AS goodsPrice,
  427. a.loss,
  428. a.loss_unit AS lossUnit,
  429. a.tax_rate as taxRate,
  430. a.load_amount AS loadAmount,
  431. a.unload_amount AS unloadAmount,
  432. a.settlement_cycle as settlementCycle,
  433. a.start_time AS startTime,
  434. a.end_time AS endTime,
  435. a.create_time AS createTime,
  436. a.create_by AS createBy,
  437. a.update_by AS updateBy,
  438. a.update_time AS updateTime
  439. FROM
  440. kwt_logistics_order a
  441. LEFT JOIN kwt_logistics_order_goods b ON a.id = b.l_order_id and a.bind_status = '0'
  442. <!-- LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id-->
  443. LEFT JOIN kwt_logistics_order_contract c ON a.id = c.l_order_id
  444. <where>
  445. <if test="ids != null and ids.size() > 0">
  446. and a.id in
  447. <foreach collection="ids" item="item" open="(" close=")" separator=",">
  448. #{item}
  449. </foreach>
  450. </if>
  451. </where>
  452. ORDER BY a.create_time DESC
  453. </select>
  454. <select id="selectOrderFinishData" resultType="com.sckw.transport.model.vo.OrderFinishVO">
  455. SELECT b.amount as amount,COUNT(a.id) AS number,
  456. SUM(IFNULL(a.load_amount, 0)) as loadAmount,
  457. SUM(IFNULL(a.unload_amount, 0)) AS unloadAmount
  458. FROM kwt_waybill_order a
  459. LEFT JOIN kwt_logistics_order b ON b.id = a.l_order_id
  460. AND a.del_flag = 0
  461. AND b.del_flag = 0
  462. <where>
  463. <if test="orderId != null and orderId != ''">
  464. and b.id=#{orderId}
  465. </if>
  466. </where>
  467. </select>
  468. <select id="findLogisticsOrder" resultType="com.sckw.transport.model.KwtLogisticsOrder"
  469. parameterType="java.util.Map">
  470. select
  471. id, ent_id entId, t_order_id tOrderId, t_order_no tOrderNo, l_order_no lOrderNo, pid, pids,
  472. settlement_cycle settlementCycle, price, price_type priceType, billing_mode billingMode,
  473. amount, unit, loss, loss_unit lossUnit, goods_price goodsPrice, goods_price_unit goodsPriceUnit,
  474. start_time startTime, end_time endTime, subcontract_amount subcontractAmount, entrust_amount entrustAmount,
  475. unload_amount unloadAmount, load_amount loadAmount, ignore_amount ignoreAmount, deficit_amount deficitAmount,
  476. deficit_price deficitPrice, payment, tax_rate taxRate, remark, `status`, create_by createBy,
  477. create_time createTime, update_by updateBy, update_time updateTime
  478. from kwt_logistics_order
  479. where del_flag = 0
  480. <if test="id != null and id != ''">
  481. and id = #{id, jdbcType=BIGINT}
  482. </if>
  483. <if test="upperlOrderId != null and upperlOrderId != ''">
  484. and FIND_IN_SET(#{upperlOrderId, jdbcType=BIGINT}, pids)
  485. and id != #{ownOrderId, jdbcType=BIGINT}
  486. </if>
  487. <if test="belowlOrderId != null and belowlOrderId != ''">
  488. and FIND_IN_SET(id, #{belowlOrderId, jdbcType=VARCHAR})
  489. and id != #{ownOrderId, jdbcType=BIGINT}
  490. </if>
  491. </select>
  492. <select id="selectOrderCountByTorderId" resultType="com.sckw.transport.model.dto.LogisticsOrderDTO">
  493. SELECT a.id as lOrderId,
  494. a.l_order_no as lOrderNo,
  495. b.`status` as `status`,
  496. a.t_order_id as tOrderId,
  497. a.t_order_no as tOrderNo,
  498. a.payment as payment,
  499. a.amount,
  500. a.price,
  501. a.loss,
  502. a.goods_price as goodsPrice,
  503. c.firm_name as comanyName,
  504. c.contacts,
  505. c.phone,
  506. a.create_by as createBy,
  507. a.create_time as createTime
  508. FROM kwt_logistics_order a
  509. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id
  510. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
  511. WHERE a.del_flag = '0'
  512. AND b.del_flag = '0'
  513. AND a.t_order_id = #{id,jdbcType=VARCHAR}
  514. </select>
  515. <select id="getAddressList" resultType="java.lang.Integer">
  516. SELECT a.city_code
  517. FROM kwt_logistics_order_address a
  518. LEFT JOIN kwt_logistics_order b ON a.l_order_id = b.id
  519. where a.city_code is not null
  520. AND b.ent_id = #{entId}
  521. GROUP BY a.city_code
  522. </select>
  523. <select id="getAddressDetailListByEntId" resultType="com.sckw.transport.api.model.dto.AddressResDTO">
  524. </select>
  525. <select id="selectMaxLevel" resultType="java.lang.Integer">
  526. SELECT MAX(LEVEL)
  527. FROM kwt_logistics_order
  528. WHERE del_flag = 0
  529. AND FIND_IN_SET(#{id}, pids)
  530. </select>
  531. <select id="countAmountByTradeOrderId" resultType="java.util.Map">
  532. SELECT SUM(
  533. IFNULL(unload_amount, 0)) as unloadAmount,
  534. SUM(
  535. IFNULL(load_amount, 0)) as loadAmount,
  536. SUM(
  537. IFNULL(total_load_amount, 0)) AS totalLoadAmount,
  538. SUM(
  539. IFNULL(total_unload_amount, 0)) AS totalUnloadAmount
  540. FROM kwt_logistics_order
  541. WHERE del_flag = 0
  542. AND t_order_id = #{tOrderId}
  543. AND `status` IN (
  544. 8
  545. )
  546. </select>
  547. <select id="selectOrderListByIdsAndUnitType" resultType="com.sckw.transport.model.dto.LogisticsOrderDTO">
  548. SELECT a.id as lOrderId,
  549. a.l_order_no as lOrderNo,
  550. b.`status` as `status`,
  551. a.t_order_id as tOrderId,
  552. a.t_order_no as tOrderNo,
  553. a.payment as payment,
  554. a.amount,
  555. a.price,
  556. a.loss,
  557. a.goods_price as goodsPrice,
  558. c.firm_name as companyName,
  559. c.contacts,
  560. c.phone,
  561. a.create_by as createBy,
  562. a.create_time as createTime
  563. FROM kwt_logistics_order a
  564. LEFT JOIN kwt_logistics_order_track b ON a.id = b.l_order_id and a.`status` = b.`status`
  565. LEFT JOIN kwt_logistics_order_unit c ON a.id = c.l_order_id AND c.unit_type = #{type}
  566. WHERE a.del_flag = '0'
  567. AND b.del_flag = '0'
  568. AND a.t_order_id IN
  569. <foreach collection="ids" item="item" open="(" close=")" separator=",">
  570. #{item}
  571. </foreach>
  572. order by createTime desc
  573. </select>
  574. <select id="selectLoopOrderAndDriverListByOrderId" resultType="com.sckw.transport.model.vo.DriverListVo">
  575. SELECT DISTINCT
  576. b.id AS wOrderId,
  577. c.id AS circulateId,
  578. b.driver_id AS driverId,
  579. c.l_order_id AS lOrderId,
  580. b.driver_name AS driverName,
  581. b.driver_phone AS driverPhone,
  582. b.driver_idcard AS driverIdCard,
  583. b.truck_no AS truckNo ,
  584. c.total_take as count
  585. FROM
  586. kwt_logistics_order_circulate c
  587. LEFT JOIN kwt_waybill_order b ON b.l_order_id = c.l_order_id
  588. WHERE
  589. b.del_flag = 0
  590. AND c.del_flag = 0
  591. AND b.type = '2'
  592. and c.satus = 0
  593. <if test="driverParam.lOrderId != null and driverParam.lOrderId != ''">
  594. AND b.l_order_id =#{driverParam.lOrderId}
  595. </if>
  596. <if test="driverParam.driverName != null and driverParam.driverName != ''">
  597. and b.driver_name like concat('%',#{driverParam.driverName},'%')
  598. </if>
  599. <if test="driverParam.driverPhone != null and driverParam.driverPhone != ''">
  600. AND b.driver_phone like concat('%',#{driverParam.driverPhone},'%')
  601. </if>
  602. <if test="driverParam.truckNo != null and driverParam.truckNo != ''">
  603. AND b.truck_no like concat('%',#{driverParam.truckNo},'%')
  604. </if>
  605. <!-- GROUP BY b.truck_no-->
  606. </select>
  607. <select id="selectLoopOrderAndDriverListByOrderIds" resultType="com.sckw.transport.model.vo.DriverListVo">
  608. SELECT DISTINCT
  609. b.id AS wOrderId,
  610. c.id AS circulateId,
  611. b.driver_id AS driverId,
  612. c.l_order_id AS lOrderId,
  613. b.driver_name AS driverName,
  614. b.driver_phone AS driverPhone,
  615. b.driver_idcard AS driverIdCard,
  616. b.truck_no AS truckNo ,
  617. c.total_take as count
  618. FROM
  619. kwt_logistics_order_circulate c
  620. LEFT JOIN kwt_waybill_order b ON b.l_order_id = c.l_order_id
  621. WHERE
  622. b.del_flag = 0
  623. AND c.del_flag = 0
  624. AND b.type = '2'
  625. and c.satus = 0
  626. <if test="idsList != null and idsList.size() >0">
  627. AND b.l_order_id IN
  628. <foreach collection="idsList" item="item" open="(" close=")" separator=",">
  629. #{item}
  630. </foreach>
  631. </if>
  632. </select>
  633. </mapper>