|
@@ -1,134 +1,92 @@
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="com.sckw.order.dao.KwoTradeOrderMapper">
|
|
<mapper namespace="com.sckw.order.dao.KwoTradeOrderMapper">
|
|
|
|
|
+ <resultMap id="mainEntityMap" type="com.sckw.order.model.dto.OrderListResDTO">
|
|
|
|
|
+ <id column="tOrderId" property="tOrderId"/>
|
|
|
|
|
+ <result column="status" property="status"/>
|
|
|
|
|
+ <result column="tOrderNo" property="tOrderNo"/>
|
|
|
|
|
+ <result column="procureEntId" property="procureEntId"/>
|
|
|
|
|
+ <result column="procureFirmName" property="procureFirmName"/>
|
|
|
|
|
+ <result column="supplyEntId" property="supplyEntId"/>
|
|
|
|
|
+ <result column="supplyFirmName" property="supplyFirmName"/>
|
|
|
|
|
+ <result column="trading" property="trading"/>
|
|
|
|
|
+ <result column="deliveryType" property="deliveryType"/>
|
|
|
|
|
+ <result column="pickupType" property="pickupType"/>
|
|
|
|
|
+ <result column="source" property="source"/>
|
|
|
|
|
+ <result column="contractId" property="contractId"/>
|
|
|
|
|
+ <result column="contractNo" property="contractNo"/>
|
|
|
|
|
+ <result column="goodsId" property="goodsId"/>
|
|
|
|
|
+ <result column="unitPrice" property="unitPrice"/>
|
|
|
|
|
+ <result column="price" property="price"/>
|
|
|
|
|
+ <result column="amount" property="amount"/>
|
|
|
|
|
+ <result column="entrustAmount" property="entrustAmount"/>
|
|
|
|
|
+ <result column="actualAmount" property="actualAmount"/>
|
|
|
|
|
+ <result column="startTime" property="startTime"/>
|
|
|
|
|
+ <result column="endTime" property="endTime"/>
|
|
|
|
|
+ <result column="remark" property="remark"/>
|
|
|
|
|
+ <result column="unit" property="unit"/>
|
|
|
|
|
+ <result column="createBy" property="createBy"/>
|
|
|
|
|
+ <result column="createTime" property="createTime"/>
|
|
|
|
|
|
|
|
- <sql id="New_Query_Column_List">
|
|
|
|
|
- tOrderId,
|
|
|
|
|
- status,
|
|
|
|
|
- tOrderNo,
|
|
|
|
|
- procureEntId,
|
|
|
|
|
- procureFirmName,
|
|
|
|
|
- supplyEntId,
|
|
|
|
|
- supplyFirmName,
|
|
|
|
|
- trading,
|
|
|
|
|
- deliveryType,
|
|
|
|
|
- pickupType,
|
|
|
|
|
- source,
|
|
|
|
|
- contractId,
|
|
|
|
|
- contractNo,
|
|
|
|
|
- goodsId,
|
|
|
|
|
- unitPrice,
|
|
|
|
|
- price,
|
|
|
|
|
- amount,
|
|
|
|
|
- entrustAmount,
|
|
|
|
|
- waitEntrustAmount,
|
|
|
|
|
- actualAmount,
|
|
|
|
|
- actualPrice,
|
|
|
|
|
- loadName,
|
|
|
|
|
- loadType,
|
|
|
|
|
- loadCityName,
|
|
|
|
|
- loadCityCode,
|
|
|
|
|
- loadAddress,
|
|
|
|
|
- shipmentsContacts,
|
|
|
|
|
- shipmentsPhone,
|
|
|
|
|
- loadLat,
|
|
|
|
|
- loadLng,
|
|
|
|
|
- unloadName,
|
|
|
|
|
- unloadType,
|
|
|
|
|
- unloadCityName,
|
|
|
|
|
- unloadCityCode,
|
|
|
|
|
- unloadAddress,
|
|
|
|
|
- unloadLat,
|
|
|
|
|
- unloadLng,
|
|
|
|
|
- contract,
|
|
|
|
|
- createType
|
|
|
|
|
- </sql>
|
|
|
|
|
|
|
+ <collection property="loadAddresses" ofType="com.sckw.order.model.dto.LoadAddressDTO">
|
|
|
|
|
+ <id column="id" property="loadAddressId"/>
|
|
|
|
|
+ <result column="name" property="loadName"/>
|
|
|
|
|
+ <result column="cityName" property="loadCityName"/>
|
|
|
|
|
+ <result column="detailAddress" property="loadDetailAddress"/>
|
|
|
|
|
+ </collection>
|
|
|
|
|
+
|
|
|
|
|
+ <collection property="unloadAddresses" ofType="com.sckw.order.model.dto.UnloadAddressDTO">
|
|
|
|
|
+ <id column="id" property="unloadAddressId"/>
|
|
|
|
|
+ <result column="name" property="unloadName"/>
|
|
|
|
|
+ <result column="cityName" property="unloadCityName"/>
|
|
|
|
|
+ <result column="detailAddress" property="unloadDetailAddress"/>
|
|
|
|
|
+ </collection>
|
|
|
|
|
|
|
|
|
|
+ </resultMap>
|
|
|
<sql id="Query_Column_List_Accept_Carriage">
|
|
<sql id="Query_Column_List_Accept_Carriage">
|
|
|
- a.id AS lOrderId,
|
|
|
|
|
- a.l_order_no AS lOrderNo,
|
|
|
|
|
- a.t_order_id AS tOrderId,
|
|
|
|
|
|
|
+ a.id AS tOrderId,
|
|
|
|
|
+ a.status AS status,
|
|
|
a.t_order_no AS tOrderNo,
|
|
a.t_order_no AS tOrderNo,
|
|
|
- a.loss AS loss,
|
|
|
|
|
- a.loss_unit AS lossUnit,
|
|
|
|
|
- a.settlement_cycle AS accountsCycle,
|
|
|
|
|
- a.billing_mode AS billingMode,
|
|
|
|
|
- a.amount AS carryingCapacity,
|
|
|
|
|
- a.goods_price AS goodsPrice,
|
|
|
|
|
- a.goods_price_unit AS goodsPriceUnit,
|
|
|
|
|
- a.`status` AS status,
|
|
|
|
|
- a.settlement_cycle AS settlementCycle,
|
|
|
|
|
|
|
+ d.ent_id AS procureEntId,
|
|
|
|
|
+ d.firm_name AS procureFirmName,
|
|
|
|
|
+ e.ent_id AS supplyEntId,
|
|
|
|
|
+ e.firm_name AS supplyFirmName,
|
|
|
|
|
+ a.trading AS trading,
|
|
|
|
|
+ a.deliveryType AS deliveryType,
|
|
|
|
|
+ a.pickupType AS pickupType,
|
|
|
|
|
+ a.source AS source,
|
|
|
|
|
+ f.contract_id AS contractId,
|
|
|
|
|
+ f.contract_no AS contractNo,
|
|
|
|
|
+-- f.contract_name as contractName,
|
|
|
|
|
+-- f.signing_way AS contractSigningWay,
|
|
|
|
|
+ g.goods_id AS goodsId,
|
|
|
|
|
+-- g.goods_name AS goodsName,
|
|
|
|
|
+-- g.goods_spec AS goodsSpec,
|
|
|
|
|
+-- g.goods_tax_rate AS goodsTaxRate,
|
|
|
|
|
+-- g.goods_thumb AS goodsThumb,
|
|
|
|
|
+ g.unit_price AS unitPrice,
|
|
|
a.price AS price,
|
|
a.price AS price,
|
|
|
- a.price_type AS priceType,
|
|
|
|
|
- a.type AS orderSource,
|
|
|
|
|
- a.unit AS unit,
|
|
|
|
|
- a.subcontract_amount AS subcontractAmount,
|
|
|
|
|
|
|
+ a.amount AS amount,
|
|
|
a.entrust_amount AS entrustAmount,
|
|
a.entrust_amount AS entrustAmount,
|
|
|
- a.unload_amount AS unloadAmount,
|
|
|
|
|
- a.load_amount AS loadAmount,
|
|
|
|
|
- a.ignore_amount AS ignoreAmount,
|
|
|
|
|
- a.deficit_amount AS deficitAmount,
|
|
|
|
|
- a.deficit_price AS deficitPrice,
|
|
|
|
|
- a.total_load_amount AS totalLoadAmount,
|
|
|
|
|
- a.total_unload_amount AS totalUnloadAmount,
|
|
|
|
|
- a.payment AS payment,
|
|
|
|
|
- a.tax_rate AS taxRate,
|
|
|
|
|
- a.ent_id AS entId,
|
|
|
|
|
|
|
+ a.actual_amount AS actualAmount,
|
|
|
|
|
+ a.start_time AS startTime,
|
|
|
|
|
+ a.end_time AS endTime,
|
|
|
|
|
+ a.remark AS remark,
|
|
|
|
|
+ a.unit AS unit,
|
|
|
a.create_by AS createBy,
|
|
a.create_by AS createBy,
|
|
|
a.create_time AS createTime,
|
|
a.create_time AS createTime,
|
|
|
- a.update_by AS updateBy,
|
|
|
|
|
- a.update_time AS updateTime,
|
|
|
|
|
- a.start_time AS shipmentsDateTime,
|
|
|
|
|
- a.end_time AS receiveGoodsDateTime,
|
|
|
|
|
- a.remark AS remark,
|
|
|
|
|
- g.goods_id AS goodsId,
|
|
|
|
|
- g.goods_name AS goodsName,
|
|
|
|
|
- g.goods_type AS goodsType,
|
|
|
|
|
- f.contract_id AS contractId,
|
|
|
|
|
- f.contract_no AS contractNo,
|
|
|
|
|
- f.signing_way AS signing,
|
|
|
|
|
- d.ent_id AS consignCompanyId,
|
|
|
|
|
- d.top_ent_id AS consignTopEntId,
|
|
|
|
|
- d.firm_name AS consignCompany,
|
|
|
|
|
- d.contacts AS consignContacts,
|
|
|
|
|
- d.contacts_id AS consignContactsId,
|
|
|
|
|
- e.contacts_id AS carrierContactsId,
|
|
|
|
|
- d.phone AS consignPhone,
|
|
|
|
|
- e.ent_id AS carrierCompanyId,
|
|
|
|
|
- e.firm_name AS carrierCompany,
|
|
|
|
|
- e.top_ent_id AS carrierTopEntId,
|
|
|
|
|
- e.contacts AS carrierContacts,
|
|
|
|
|
- e.phone AS carrierPhone,
|
|
|
|
|
- b.`name` AS loadName,
|
|
|
|
|
- b.address_type AS loadType,
|
|
|
|
|
- b.city_name AS loadCityName,
|
|
|
|
|
- b.city_code AS loadCityCode,
|
|
|
|
|
- b.detail_address AS loadAddress,
|
|
|
|
|
- b.contacts AS shipmentsContacts,
|
|
|
|
|
- b.phone AS shipmentsPhone,
|
|
|
|
|
- b.lat AS loadLat,
|
|
|
|
|
- b.lng AS loadLng,
|
|
|
|
|
- c.`name` AS unloadName,
|
|
|
|
|
- c.address_type AS unloadType,
|
|
|
|
|
- c.contacts AS receiveGoodsContacts,
|
|
|
|
|
- c.phone AS receiveGoodsPhone,
|
|
|
|
|
- c.city_name AS unloadCityName,
|
|
|
|
|
- c.city_code AS unloadCityCode,
|
|
|
|
|
- c.detail_address AS unloadAddress,
|
|
|
|
|
- c.lat AS unloadLat,
|
|
|
|
|
- c.lng AS unloadLng,
|
|
|
|
|
- f.contract_name as contract
|
|
|
|
|
- ,
|
|
|
|
|
- a.del_flag as delFlag,
|
|
|
|
|
- case when a.ent_id = e.top_ent_id then 1 ELSE 2 end as createType
|
|
|
|
|
|
|
+ b.id AS loadAddressId,
|
|
|
|
|
+ b.name AS loadName,
|
|
|
|
|
+ b.cityName AS loadCityName,
|
|
|
|
|
+ b.detailAddress AS loadDetailAddress,
|
|
|
|
|
+ c.id AS unloadAddressId,
|
|
|
|
|
+ c.name AS unloadName,
|
|
|
|
|
+ c.cityName AS unloadCityName,
|
|
|
|
|
+ c.detailAddress AS unloadDetailAddress
|
|
|
</sql>
|
|
</sql>
|
|
|
|
|
|
|
|
<select id="tradeOrderSelect"
|
|
<select id="tradeOrderSelect"
|
|
|
- resultType="com.sckw.order.model.vo.res.OrderListResVO">
|
|
|
|
|
- SELECT
|
|
|
|
|
- <include refid="New_Query_Column_List">
|
|
|
|
|
- </include>
|
|
|
|
|
- FROM (
|
|
|
|
|
|
|
+ resultMap="mainEntityMap">
|
|
|
SELECT
|
|
SELECT
|
|
|
<include refid="Query_Column_List_Accept_Carriage">
|
|
<include refid="Query_Column_List_Accept_Carriage">
|
|
|
</include>
|
|
</include>
|
|
@@ -142,46 +100,83 @@
|
|
|
LEFT JOIN kwo_trade_order_unit e ON a.id = e.t_order_id
|
|
LEFT JOIN kwo_trade_order_unit e ON a.id = e.t_order_id
|
|
|
AND e.unit_type = "2" AND e.del_flag = 0
|
|
AND e.unit_type = "2" AND e.del_flag = 0
|
|
|
LEFT JOIN kwo_trade_order_goods g ON a.id = g.t_order_id AND g.del_flag = 0
|
|
LEFT JOIN kwo_trade_order_goods g ON a.id = g.t_order_id AND g.del_flag = 0
|
|
|
- LEFT JOIN kwo_trade_order_unit f ON a.id = f.t_order_id AND f.del_flag = 0
|
|
|
|
|
|
|
+ LEFT JOIN kwo_trade_order_contract f ON a.id = f.t_order_id AND f.del_flag = 0
|
|
|
<where>
|
|
<where>
|
|
|
a.del_flag = 0
|
|
a.del_flag = 0
|
|
|
|
|
+-- 数据权限匹配
|
|
|
|
|
+ <if test="query.isMain == 0">
|
|
|
|
|
+ and (
|
|
|
|
|
+ (a.ent_id = #{query.entId}
|
|
|
|
|
+ <if test="authUserIds != null and authUserIds.size() > 0">
|
|
|
|
|
+ and a.create_by in
|
|
|
|
|
+ <foreach collection="authUserIds" item="authUserId" open="(" close=")" separator=",">
|
|
|
|
|
+ #{authUserId}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ )or
|
|
|
|
|
+ (<if test="query.orderType == 1">
|
|
|
|
|
+ d.top_ent_id = #{query.entId}
|
|
|
|
|
+ and d.contacts_id in
|
|
|
|
|
+ <foreach collection="authUserIds" item="authUserId" open="(" close=")" separator=",">
|
|
|
|
|
+ #{authUserId}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="query.orderType == 2">
|
|
|
|
|
+ e.top_ent_id = #{query.entId}
|
|
|
|
|
+ and e.contacts_id in
|
|
|
|
|
+ <foreach collection="authUserIds" item="authUserId" open="(" close=")" separator=",">
|
|
|
|
|
+ #{authUserId}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>)
|
|
|
|
|
+ )
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="query.isMain == 1">
|
|
|
|
|
+ and (
|
|
|
|
|
+ (a.ent_id = #{query.entId})
|
|
|
|
|
+ or
|
|
|
|
|
+ (<if test="query.orderType == 1">
|
|
|
|
|
+ d.top_ent_id = #{query.entId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="query.orderType == 2">
|
|
|
|
|
+ e.top_ent_id = #{query.entId}
|
|
|
|
|
+ </if>)
|
|
|
|
|
+ )
|
|
|
|
|
+ </if>
|
|
|
|
|
+-- 状态匹配
|
|
|
|
|
+ <if test="query.status != null">
|
|
|
|
|
+ and a.status =#{query.status}
|
|
|
|
|
+ <if test="query.status == 0">
|
|
|
|
|
+-- 草稿状态只能创建订单的人能看
|
|
|
|
|
+ and a.create_by = #{query.userId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="query.status == null">
|
|
|
|
|
+-- 非草稿状态or草稿状态且是当前人
|
|
|
|
|
+ and (
|
|
|
|
|
+ a.status != 0
|
|
|
|
|
+ or (a.status = 0 and a.create_by = #{query.userId})
|
|
|
|
|
+ )
|
|
|
|
|
+ </if>
|
|
|
|
|
+-- 关键词匹配
|
|
|
<if test="query.keywords != null and query.keywords != ''">
|
|
<if test="query.keywords != null and query.keywords != ''">
|
|
|
and (
|
|
and (
|
|
|
a.t_order_no like concat('%', #{query.keywords}, '%')
|
|
a.t_order_no like concat('%', #{query.keywords}, '%')
|
|
|
or a.l_order_no like concat('%', #{query.keywords}, '%')
|
|
or a.l_order_no like concat('%', #{query.keywords}, '%')
|
|
|
or d.firm_name like concat('%', #{query.keywords}, '%')
|
|
or d.firm_name like concat('%', #{query.keywords}, '%')
|
|
|
or e.firm_name like concat('%', #{query.keywords}, '%')
|
|
or e.firm_name like concat('%', #{query.keywords}, '%')
|
|
|
- or g.goods_name like concat('%', #{query.keywords}, '%'))
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="orderList != null and orderList.size() > 0">
|
|
|
|
|
- and a.status in
|
|
|
|
|
- <foreach collection="orderList" item="status" open="(" close=")" separator=",">
|
|
|
|
|
- #{status}
|
|
|
|
|
- </foreach>
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="idsList != null and idsList.size() > 0">
|
|
|
|
|
- and a.id in
|
|
|
|
|
- <foreach collection="idsList" close=")" open="(" separator="," item="item">
|
|
|
|
|
- #{item}
|
|
|
|
|
- </foreach>
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="query.endBeginDateTime != null and query.endBeginDateTime != ''">
|
|
|
|
|
- and DATE ( a.end_time) <![CDATA[ >= ]]> #{query.endBeginDateTime}
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="query.endOverDateTime != null and query.endOverDateTime != ''">
|
|
|
|
|
- and DATE ( a.end_time ) <![CDATA[ <= ]]> #{query.endOverDateTime}
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="query.startBeginDateTime != null and query.startBeginDateTime != ''">
|
|
|
|
|
- and DATE ( a.start_time) <![CDATA[ >= ]]> #{query.startBeginDateTime}
|
|
|
|
|
|
|
+ <if test="goodIds != null and goodIds.size() > 0">
|
|
|
|
|
+ or g.goods_id in
|
|
|
|
|
+ <foreach collection="goodIds" item="goodId" open="(" close=")" separator=",">
|
|
|
|
|
+ #{goodId}
|
|
|
|
|
+ </foreach>
|
|
|
|
|
+ </if>
|
|
|
|
|
+ )
|
|
|
</if>
|
|
</if>
|
|
|
- <if test="query.startOverDateTime != null and query.startOverDateTime != ''">
|
|
|
|
|
- and DATE ( a.start_time ) <![CDATA[ <= ]]> #{query.startOverDateTime}
|
|
|
|
|
|
|
+ <if test="query.createStartTime != null ">
|
|
|
|
|
+ and a.create_time >= #{query.createStartTime}
|
|
|
</if>
|
|
</if>
|
|
|
- <if test="query.createStartTime != null and query.createStartTime != ''">
|
|
|
|
|
- and a.create_time >=#{query.createStartTime}
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="query.createEndTime != null and query.createEndTime != ''">
|
|
|
|
|
- and a.create_time <=#{query.createEndTime}
|
|
|
|
|
|
|
+ <if test="query.createEndTime != null ">
|
|
|
|
|
+ and a.create_time <= #{query.createEndTime}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="query.loadAddressCode != null and query.loadAddressCode != ''">
|
|
<if test="query.loadAddressCode != null and query.loadAddressCode != ''">
|
|
|
and b.city_code LIKE CONCAT(#{query.loadAddressCode}
|
|
and b.city_code LIKE CONCAT(#{query.loadAddressCode}
|
|
@@ -191,36 +186,20 @@
|
|
|
and c.city_code LIKE CONCAT(#{query.unloadAddressCode}
|
|
and c.city_code LIKE CONCAT(#{query.unloadAddressCode}
|
|
|
, '%')
|
|
, '%')
|
|
|
</if>
|
|
</if>
|
|
|
- <if test="query.billingMode != null and query.billingMode != ''">
|
|
|
|
|
- and a.billing_mode =#{query.billingMode}
|
|
|
|
|
|
|
+ <if test="query.trading != null and query.trading != ''">
|
|
|
|
|
+ and a.trading =#{query.trading}
|
|
|
</if>
|
|
</if>
|
|
|
- </where>
|
|
|
|
|
- ORDER BY a.create_time DESC
|
|
|
|
|
- ) tab
|
|
|
|
|
- <where>
|
|
|
|
|
- tab.delFlag = 0
|
|
|
|
|
- AND ((
|
|
|
|
|
- tab.createType = 1
|
|
|
|
|
- <if test="entId != null">
|
|
|
|
|
- and tab.entId = #{entId}
|
|
|
|
|
|
|
+ <if test="query.source != null and query.source != ''">
|
|
|
|
|
+ and a.source =#{query.source}
|
|
|
</if>
|
|
</if>
|
|
|
- <if test="userIds != null and userIds.size() > 0">
|
|
|
|
|
- AND tab.createBy IN
|
|
|
|
|
- <foreach collection="userIds" open="(" close=")" item="item" separator=",">
|
|
|
|
|
- #{item}
|
|
|
|
|
- </foreach>
|
|
|
|
|
|
|
+ <if test="query.deliveryType != null and query.deliveryType != ''">
|
|
|
|
|
+ and a.delivery_type =#{query.deliveryType}
|
|
|
</if>
|
|
</if>
|
|
|
- )
|
|
|
|
|
- OR (
|
|
|
|
|
- tab.carrierTopEntId = #{entId}
|
|
|
|
|
- <if test="contactsIds != null and contactsIds.size() > 0">
|
|
|
|
|
- AND tab.carrierContactsId IN
|
|
|
|
|
- <foreach collection="contactsIds" separator="," item="item" close=")" open="(">
|
|
|
|
|
- #{item}
|
|
|
|
|
- </foreach>
|
|
|
|
|
|
|
+ <if test="query.deliveryType != null and query.deliveryType != ''">
|
|
|
|
|
+ and a.delivery_type =#{query.deliveryType}
|
|
|
</if>
|
|
</if>
|
|
|
- ))
|
|
|
|
|
</where>
|
|
</where>
|
|
|
|
|
+ ORDER BY a.create_time DESC
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
<select id="getMaxOrderNoByDate" resultType="java.lang.String">
|
|
<select id="getMaxOrderNoByDate" resultType="java.lang.String">
|