|
|
@@ -62,6 +62,8 @@
|
|
|
<result column="remarks" property="remarks"/>
|
|
|
<result column="flg_valid" property="flgValid"/>
|
|
|
<result column="cp_id" property="cpId"/>
|
|
|
+ <result column="order_no" property="orderNo"/>
|
|
|
+ <result column="transferableQuantity" property="transferableQuantity"/>
|
|
|
</resultMap>
|
|
|
|
|
|
<!-- 通用条件列 -->
|
|
|
@@ -410,4 +412,122 @@
|
|
|
and item_qty >=(out_qty + outing_qty)
|
|
|
</update>
|
|
|
|
|
|
+ <!-- 通用条件列 -->
|
|
|
+ <sql id="Condition_pur">
|
|
|
+ <where>
|
|
|
+ <if test="orderNo != null">
|
|
|
+ AND tpo.order_no like concat('%', my_ex.likequery(#{orderNo}) , '%')
|
|
|
+ </if>
|
|
|
+ <if test="orderId != null and orderId != ''">
|
|
|
+ AND t.order_id = #{orderId}::uuid
|
|
|
+ </if>
|
|
|
+ <if test="itemIndex != null">
|
|
|
+ AND t.item_index = #{itemIndex}
|
|
|
+ </if>
|
|
|
+ <if test="skuId != null and skuId != ''">
|
|
|
+ AND t.sku_id = #{skuId}
|
|
|
+ </if>
|
|
|
+ <if test="itemQty != null">
|
|
|
+ AND t.item_qty = #{itemQty}
|
|
|
+ </if>
|
|
|
+ <if test="priceStd != null">
|
|
|
+ AND t.price_std = #{priceStd}
|
|
|
+ </if>
|
|
|
+ <if test="amtStd != null">
|
|
|
+ AND t.amt_std = #{amtStd}
|
|
|
+ </if>
|
|
|
+ <if test="priceSale != null">
|
|
|
+ AND t.price_sale = #{priceSale}
|
|
|
+ </if>
|
|
|
+ <if test="itemAmt != null">
|
|
|
+ AND t.item_amt = #{itemAmt}
|
|
|
+ </if>
|
|
|
+ <if test="priceDiscount != null">
|
|
|
+ AND t.price_discount = #{priceDiscount}
|
|
|
+ </if>
|
|
|
+ <if test="nonStdCode != null and nonStdCode != ''">
|
|
|
+ AND t.non_std_code = #{nonStdCode}
|
|
|
+ </if>
|
|
|
+ <if test="outStatus != null and outStatus != ''">
|
|
|
+ AND t.out_status = #{outStatus}
|
|
|
+ </if>
|
|
|
+ <if test="outingQty != null">
|
|
|
+ AND t.outing_qty = #{outingQty}
|
|
|
+ </if>
|
|
|
+ <if test="outingAmt != null">
|
|
|
+ AND t.outing_amt = #{outingAmt}
|
|
|
+ </if>
|
|
|
+ <if test="outQty != null">
|
|
|
+ AND t.out_qty = #{outQty}
|
|
|
+ </if>
|
|
|
+ <if test="outAmt != null">
|
|
|
+ AND t.out_amt = #{outAmt}
|
|
|
+ </if>
|
|
|
+ <if test="returnQty != null">
|
|
|
+ AND t.return_qty = #{returnQty}
|
|
|
+ </if>
|
|
|
+ <if test="returnAmt != null">
|
|
|
+ AND t.return_amt = #{returnAmt}
|
|
|
+ </if>
|
|
|
+ <if test="remarks != null and remarks != ''">
|
|
|
+ AND t.remarks = #{remarks}
|
|
|
+ </if>
|
|
|
+ <if test="flgValid != null">
|
|
|
+ AND t.flg_valid = #{flgValid}
|
|
|
+ </if>
|
|
|
+ <if test="cpId != null">
|
|
|
+ AND t.cp_id = #{cpId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!-- 查询表t_psi_order_item,(条件查询+分页)列表 -->
|
|
|
+ <select id="purchaseBasedOnSaleSelectByCond" resultMap="BaseResultMapResponse">
|
|
|
+ SELECT t.item_id,
|
|
|
+ t.order_id,
|
|
|
+ tpo.order_no,
|
|
|
+ t.item_index,
|
|
|
+ t.sku_id,
|
|
|
+ tmgs.sku_code as "skuCode",
|
|
|
+ tmgs.sku_model as "skuModel",
|
|
|
+ tmgs.sku_name as "skuName",
|
|
|
+ t.item_qty,
|
|
|
+ t.price_std,
|
|
|
+ t.amt_std,
|
|
|
+ t.price_sale,
|
|
|
+ t.item_amt,
|
|
|
+ t.price_discount,
|
|
|
+ t.non_std_code,
|
|
|
+ t.out_status,
|
|
|
+ t.outing_qty,
|
|
|
+ t.outing_amt,
|
|
|
+ t.out_qty,
|
|
|
+ t.out_amt,
|
|
|
+ t.return_qty,
|
|
|
+ t.return_amt,
|
|
|
+ t.remarks,
|
|
|
+ t.item_qty - coalesce(sumQty,0) as "transferableQuantity"
|
|
|
+ FROM dkic_b.t_psi_order_item as t
|
|
|
+ left join dkic_b.t_psi_order as tpo on tpo.order_id = t.order_id
|
|
|
+ inner join dkic_b.t_mst_goods_sku tmgs on t.sku_id = tmgs.sku_id
|
|
|
+ left join(select from_item_id,sum(item_qty) as sumQty from t_psi_purchase_item
|
|
|
+ group by from_item_id) as pi on pi.from_item_id = t.item_id
|
|
|
+ <include refid="Condition_pur"/>
|
|
|
+ order by t.item_id
|
|
|
+ <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
|
|
|
+ limit #{end} offset #{start}
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 查询表t_psi_order_item,(条件查询+分页)列表 -->
|
|
|
+ <select id="purchaseBasedOnSaleContByCond" resultType="Long">
|
|
|
+ SELECT count(1)
|
|
|
+ FROM dkic_b.t_psi_order_item as t
|
|
|
+ left join dkic_b.t_psi_order as tpo on tpo.order_id = t.order_id
|
|
|
+ inner join dkic_b.t_mst_goods_sku tmgs on t.sku_id = tmgs.sku_id
|
|
|
+ <include refid="Condition_pur"/>
|
|
|
+ <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
|
|
|
+ limit #{end} offset #{start}
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
</mapper>
|