asinkj/asinkj-biz/asinkj-amz/src/main/resources/mapper/amz/BizShipmentPlanMapper.xml
2025-07-15 08:47:47 +08:00

205 lines
8.0 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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">
<mapper namespace="org.asinkj.amz.mapper.BizShipmentPlanMapper">
<update id="updateByFbaShipmentId">
<foreach collection="list" item="item" index="index" separator=";">
UPDATE biz_shipment_plan
<set>
<if test="item.boxQuantity != null">
box_quantity = #{item.boxQuantity},
</if>
<if test="item.boxQuantity != null">
box_size = #{item.boxSize},
</if>
<if test="item.boxQuantity != null">
vendor_weight = #{item.vendorWeight},
</if>
<if test="item.boxQuantity != null">
set_total = #{item.setTotal},
</if>
</set>
WHERE shipment_id = #{item.shipmentId}
</foreach>
</update>
<select id="selectExistingShipmentIds" resultType="java.lang.String">
SELECT shipment_id
FROM biz_shipment_plan
WHERE del_flag = '0'
WHERE shipment_id IN
<foreach item="id" collection="batchIds" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<resultMap id="shipmentPlanMap" type="org.asinkj.amz.domain.BizShipmentPlan">
<id property="id" column="id"/>
<result property="shipmentId" column="shipment_id"/>
<result property="shipmentName" column="shipment_name"/>
<result property="isClosed" column="is_closed"/>
<result property="shipmentStatus" column="shipment_status"/>
<result property="destination" column="destination"/>
<result property="shippingMode" column="shipping_mode"/>
<result property="shippingSolution" column="shipping_solution"/>
<result property="gmtModified" column="gmt_modified"/>
<result property="gmtCreate" column="gmt_create"/>
<result property="receivingTime" column="receiving_time"/>
<result property="staShipmentDate" column="sta_shipment_date"/>
<result property="staDeliveryStartDate" column="sta_delivery_start_date"/>
<result property="staDeliveryEndDate" column="sta_delivery_end_date"/>
<result property="shipFromAddress" column="ship_from_address"/>
<result property="shipToAddress" column="ship_to_address"/>
<result property="referenceId" column="reference_id"/>
<result property="staInboundPlanId" column="sta_inbound_plan_id"/>
<result property="isSta" column="is_sta"/>
<result property="delFlag" column="del_flag"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="createDept" column="create_dept"/>
<result property="tenantId" column="tenant_id"/>
<result property="shipmentUniqueId" column="shipment_unique_id"/>
<result property="inboundPlanId" column="inbound_plan_id"/>
<result property="fbaStatus" column="fba_status"/>
<result property="boxQuantity" column="box_quantity"/>
<result property="boxSize" column="box_size"/>
<result property="vendorWeight" column="vendor_weight"/>
<result property="setTotal" column="set_total"/>
<result property="channelId" column="channel_id"/>
<result property="channelName" column="channel_name"/>
<result property="logisticsProviderName" column="logistics_provider_name"/>
<result property="address" column="address"/>
<!--<result property="shippedTime" column="shipped_time"/>-->
<!--<result property="workingTime" column="working_time"/>-->
<!--<result property="closedTime" column="closed_time"/>-->
<!-- 如果有其他字段,请在此继续添加 -->
</resultMap>
<!-- 查询发货单与 shipment 的关系映射 -->
<resultMap id="orderShipmentRelationMap" type="org.asinkj.amz.domain.OrderShipmentRelation">
<result property="sendOrderId" column="send_order_id"/>
<result property="shipmentId" column="shipment_plan_id"/>
</resultMap>
<!-- 关系查询仅获取ID -->
<select id="findOrderShipmentRelations" resultMap="orderShipmentRelationMap">
SELECT
send_order_id,
shipment_plan_id
FROM biz_send_shipment_rel
WHERE send_order_id IN
<foreach item="id" collection="sendOrderIds" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<!-- 根据ID批量查询 shipment -->
<select id="findByIds" resultMap="shipmentPlanMap">
SELECT
bsp.id,
bsp.shipment_id,
bsp.shipment_name,
bsp.is_closed,
bsp.shipment_status,
bsp.destination,
bsp.shipping_mode,
bsp.shipping_solution,
bsp.gmt_modified,
bsp.gmt_create,
bsp.receiving_time,
bsp.sta_shipment_date,
bsp.sta_delivery_start_date,
bsp.sta_delivery_end_date,
bsp.ship_from_address,
bsp.ship_to_address,
bsp.reference_id,
bsp.sta_inbound_plan_id,
bsp.is_sta,
bsp.del_flag,
bsp.create_by,
bsp.create_time,
bsp.update_by,
bsp.update_time,
bsp.create_dept,
bsp.tenant_id,
bsp.shipment_unique_id,
bsp.inbound_plan_id,
bsp.fba_status,
bsp.box_quantity,
bsp.box_size,
bsp.vendor_weight,
bsp.set_total,
bsp.channel_id,
bsp.channel_name,
bsp.shipped_time,
bsp.working_time,
bsp.closed_time,
blo.logistics_provider_name AS logistics_provider_name,
su.address AS address
FROM biz_shipment_plan bsp
LEFT JOIN biz_logistics_order blo ON bsp.shipment_id = blo.fba_shipment_id
LEFT JOIN sys_user su ON su.user_id = blo.logistics_provider_id
WHERE bsp.id IN
<foreach item="id" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<delete id="deleteBySendOrderShipmentPlan">
DELETE FROM biz_send_shipment_rel
WHERE send_order_id = #{sendOrderId} and shipment_plan_id = #{shipmentPlanId}
</delete>
<!-- 查询询价单对应的货运计划ID -->
<select id="selectPlanIdsByRequestIds" resultType="java.lang.Long">
SELECT DISTINCT plan.id
FROM biz_shipment_plan plan
WHERE plan.shipment_id IN
<foreach item="id" collection="requestIds" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<!-- 通过货运计划ID批量查询发货单 -->
<select id="batchFindSendOrdersByPlanIds"
resultType="org.asinkj.amz.domain.BizSendOrder">
SELECT
o.*,
rel.shipment_plan_id AS requestId <!-- 用于分组的关联ID -->
FROM biz_send_order o
INNER JOIN biz_send_shipment_rel rel ON o.id = rel.send_order_id
WHERE rel.shipment_plan_id IN
<foreach item="id" collection="planIds" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="batchGetSendOrdersByShipmentIds"
resultType="org.asinkj.amz.domain.BizSendOrder">
SELECT DISTINCT
o.*,
<!-- 使用 shipmentId 作为分组键 -->
req.shipment_id AS shipmentIdKey
FROM biz_send_order o
<!-- 关联路径:发货单 → 关联表 → 货运计划 → 询价单-->
INNER JOIN biz_send_shipment_rel rel ON o.id = rel.send_order_id
INNER JOIN biz_shipment_plan plan ON plan.id = rel.shipment_plan_id
INNER JOIN biz_inquiry_request req ON req.shipment_id = plan.shipment_id
WHERE req.shipment_id IN
<foreach item="id" collection="shipmentIds" open="(" separator="," close=")">
#{id}
</foreach>
</select>
</mapper>