|
|
@@ -310,37 +310,62 @@
|
|
|
|
|
|
<!-- 根据条件进行查询(出库编辑用) -->
|
|
|
<select id="selectByCondForOutEdit" resultMap="BaseResultMapResponse">
|
|
|
- SELECT tpoi.item_id,
|
|
|
- tpoi.out_id,
|
|
|
- tpoi.from_item_id,
|
|
|
- tpoi.from_id,
|
|
|
- tpoi.item_index,
|
|
|
- tpoi.sku_id,
|
|
|
+ SELECT t.item_id,
|
|
|
+ t.out_id,
|
|
|
+ t.from_item_id,
|
|
|
+ t.from_id,
|
|
|
+ t.item_index,
|
|
|
+ t.sku_id,
|
|
|
tmgs.sku_code as "skuCode",
|
|
|
tmgs.sku_model as "skuModel",
|
|
|
tmgs.sku_name as "skuName",
|
|
|
- tpoi1.item_qty as "orderQty",
|
|
|
- tpoi1.item_qty - tpoi1.outing_qty + tpoi.outing_qty as "canOutingQty",
|
|
|
- tpoi.outing_qty,
|
|
|
- tpoi.price_out,
|
|
|
- tpoi.outing_amt,
|
|
|
- tpoi.out_qty,
|
|
|
- tpoi.out_amt,
|
|
|
- tpoi.non_std_code,
|
|
|
- tpoi.remarks,
|
|
|
- tpoi.inv_id,
|
|
|
+ tpoi.item_qty as "orderQty",
|
|
|
+ tpoi.item_qty - tpoi.outing_qty - tpoi.out_qty + t.outing_qty + t.out_qty as "canOutingQty",
|
|
|
+ t.price_out,
|
|
|
+ t.outing_qty + t.out_qty as outing_qty,
|
|
|
+ t.outing_amt + t.out_amt as outing_amt,
|
|
|
+ t.out_qty,
|
|
|
+ t.out_amt,
|
|
|
+ t.non_std_code,
|
|
|
+ t.remarks,
|
|
|
+ t.inv_id,
|
|
|
tpi.wh_id as "whId",
|
|
|
tpi.inv_qty as "invQty",
|
|
|
tpi.usable_qty as "usableQty",
|
|
|
tmw.wh_name as "whName"
|
|
|
- FROM dkic_b.t_psi_outbound_item as tpoi
|
|
|
- left join dkic_b.t_psi_order_item as tpoi1 on tpoi1.item_id = tpoi.from_item_id
|
|
|
- left join dkic_b.t_mst_goods_sku tmgs on tpoi1.sku_id = tmgs.sku_id
|
|
|
- left join dkic_b.t_psi_inventory as tpi on tpi.inv_id = tpoi.inv_id
|
|
|
+ FROM dkic_b.t_psi_outbound_item as t
|
|
|
+ left join dkic_b.t_psi_order_item as tpoi on tpoi.item_id = t.from_item_id
|
|
|
+ left join dkic_b.t_mst_goods_sku tmgs on tpoi.sku_id = tmgs.sku_id
|
|
|
+ left join dkic_b.t_psi_inventory as tpi on tpi.inv_id = t.inv_id
|
|
|
left join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id
|
|
|
- where tpoi.flg_valid
|
|
|
- and tpoi.out_id = #{id}::uuid
|
|
|
- order by tpoi.item_index
|
|
|
+ where t.flg_valid
|
|
|
+ and t.out_id = #{id}::uuid
|
|
|
+ order by t.item_index
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 获取出库信息(新建退货用) -->
|
|
|
+ <select id="selectByCondForReturn" resultMap="BaseResultMapResponse">
|
|
|
+ SELECT t.out_id as "sOutId",
|
|
|
+ t.item_id as "sOutItemId",
|
|
|
+ t.sku_id,
|
|
|
+ tmgs.sku_code as "skuCode",
|
|
|
+ tmgs.sku_model as "skuModel",
|
|
|
+ tmgs.sku_name as "skuName",
|
|
|
+ t.out_qty as "outboundOutQty",
|
|
|
+ t.out_qty - t.return_qty as "canReturnQty",
|
|
|
+ - (t.out_qty - t.return_qty) as outing_qty,
|
|
|
+ t.price_out,
|
|
|
+ - t.price_out * (t.out_qty - t.return_qty) as outing_amt,
|
|
|
+ t.inv_id,
|
|
|
+ t.non_std_code,
|
|
|
+ t.remarks
|
|
|
+ FROM dkic_b.t_psi_outbound_item as t
|
|
|
+ inner join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = t.sku_id
|
|
|
+ where t.flg_valid
|
|
|
+ and t.out_type = '出库类型-销售出库'
|
|
|
+ and t.out_qty > t.return_qty
|
|
|
+ and t.out_id = #{outId}::uuid
|
|
|
+ order by t.item_index
|
|
|
</select>
|
|
|
|
|
|
<!-- 根据条件进行查询(退货编辑用) -->
|
|
|
@@ -353,19 +378,26 @@
|
|
|
t.s_order_item_id,
|
|
|
t.item_index,
|
|
|
t.sku_id,
|
|
|
- tmgs.sku_code as "skuCode",
|
|
|
- tmgs.sku_model as "skuModel",
|
|
|
- tmgs.sku_name as "skuName",
|
|
|
- tpobi.out_qty as "outboundOutQty",
|
|
|
- tpobi.out_qty - tpobi.return_qty - t.outing_qty as "canReturnQty",
|
|
|
- t.outing_qty,
|
|
|
+ tmgs.sku_code as "skuCode",
|
|
|
+ tmgs.sku_model as "skuModel",
|
|
|
+ tmgs.sku_name as "skuName",
|
|
|
+ COALESCE(tpobi.out_qty, 0) as "outboundOutQty",
|
|
|
+ COALESCE(tpobi.out_qty, 0) - COALESCE(tpobi.return_qty, 0) + t.outing_qty + t.out_qty as "canReturnQty",
|
|
|
+ t.inv_id,
|
|
|
+ tpi.wh_id,
|
|
|
+ tpi.inv_qty as "invQty",
|
|
|
+ tpi.usable_qty as "usableQty",
|
|
|
+ tmw.wh_name as "whName",
|
|
|
t.price_out,
|
|
|
- t.outing_amt,
|
|
|
+ t.outing_qty + t.out_qty as outing_qty,
|
|
|
+ t.outing_amt + t.out_amt as outing_amt,
|
|
|
t.non_std_code,
|
|
|
t.remarks
|
|
|
FROM dkic_b.t_psi_outbound_item as t
|
|
|
- left join dkic_b.t_psi_outbound_item as tpobi on tpobi.item_id = t.s_out_item_id
|
|
|
left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = t.sku_id
|
|
|
+ left join dkic_b.t_psi_inventory tpi on tpi.inv_id = t.inv_id
|
|
|
+ left join dkic_b.t_mst_warehouse tmw on tmw.wh_id = tpi.wh_id
|
|
|
+ left join dkic_b.t_psi_outbound_item as tpobi on tpobi.item_id = t.s_out_item_id
|
|
|
where t.flg_valid
|
|
|
and t.out_id = #{id}::uuid
|
|
|
order by t.item_index
|