|
|
@@ -1192,4 +1192,151 @@
|
|
|
and t.acc_item_type = '账款类型-应收'
|
|
|
and tpo.from_id = #{id}::uuid
|
|
|
</select>
|
|
|
+
|
|
|
+ <!-- 以销定采查询销售订单查询表t_psi_order,(条件查询+分页)列表 -->
|
|
|
+ <select id="purchaseBasedOnSales" resultType="Map">
|
|
|
+ SELECT
|
|
|
+ T.order_type AS "orderType",
|
|
|
+ sys.f_get_name_i18n ( tdk1.kind_name_i18n, #{ i18n } ) AS "orderTypeName",
|
|
|
+ T.org_id AS "orgId",
|
|
|
+ tmo.org_name AS "orgName",
|
|
|
+ T.staff_id AS "staffId",
|
|
|
+ tms.staff_name AS "staffName",
|
|
|
+ T.cus_id AS "cusId",
|
|
|
+ tmc.cus_code AS "cusCode",
|
|
|
+ T.cus_name AS "cusName",
|
|
|
+ T.cus_phone AS "cusPhone",
|
|
|
+ T.address_area AS "addressArea",
|
|
|
+ T.address_name AS "addressName",
|
|
|
+ T.address_no AS "addressNo",
|
|
|
+ T.address_full AS "addressFull",
|
|
|
+ T.sales_channel AS "salesChannel",
|
|
|
+ tmsc.channel_name AS "channelName",
|
|
|
+ T.delivery_date AS "deliveryDate",
|
|
|
+ T.sale_discount AS "saleDiscount",
|
|
|
+ T.order_status AS "orderStatus",
|
|
|
+ sys.f_get_name_i18n ( tdk2.kind_name_i18n, #{ i18n } ) AS "orderStatusName",
|
|
|
+ T.out_status AS "outStatus",
|
|
|
+ sys.f_get_name_i18n ( tdk3.kind_name_i18n, #{ i18n } ) AS "outStatusName",
|
|
|
+ T.make_time AS "makingTime",
|
|
|
+ T.cp_id AS "cpId",
|
|
|
+ toi.item_id AS "itemId",
|
|
|
+ T.order_id AS "orderId",
|
|
|
+ T.order_no AS "orderNo",
|
|
|
+ toi.item_index AS "itemIndex",
|
|
|
+ toi.sku_id AS "skuId",
|
|
|
+ toi.item_qty AS "itemQty",
|
|
|
+ toi.price_std AS "priceStd",
|
|
|
+ toi.amt_std AS "amtStd",
|
|
|
+ toi.price_sale AS "priceSale",
|
|
|
+ toi.item_amt AS "itemAmt",
|
|
|
+ toi.price_discount AS "priceDiscount",
|
|
|
+ toi.non_std_code AS "nonStdCode",
|
|
|
+ toi.item_qty - toi.purchase_qty AS "transferableQuantity",
|
|
|
+ toi.remarks AS "remarks",
|
|
|
+ toi.cp_id AS "cpId",
|
|
|
+ tmgs.sku_code AS "skuCode",
|
|
|
+ tmgs.sku_model AS "skuModel",
|
|
|
+ tmgs.sku_name AS "skuName",
|
|
|
+ tmgb.brand_name AS "brandName",
|
|
|
+ tmgb.short_name AS "shortName",
|
|
|
+ tmgs.price_purchase AS "pricePurchase",
|
|
|
+ tmgs.price_standard AS "priceStandard",
|
|
|
+ toi.unit_id AS "unitId",
|
|
|
+ toi.sub_unit_id AS "subUnitId",
|
|
|
+ toi.pack_box AS "packBox",
|
|
|
+ toi.box AS "box",
|
|
|
+ toi.piece AS "piece",
|
|
|
+ tmgus.unit_name as "subUnitName",
|
|
|
+ tmgu.unit_name as "unitName",
|
|
|
+ tmgs.flg_sub_unit as "flgSubUnit"
|
|
|
+ FROM
|
|
|
+ dkic_b.t_psi_order
|
|
|
+ AS T
|
|
|
+ LEFT JOIN dkic_b.t_mst_sale_channel tmsc ON T.sales_channel = tmsc.channel_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_org tmo ON T.org_id = tmo.org_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_staff tms ON T.staff_id = tms.staff_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_customer tmc ON T.cus_id = tmc.cus_id
|
|
|
+ LEFT JOIN sys.t_data_kind AS tdk1 ON T.order_type = tdk1.kind_code
|
|
|
+ LEFT JOIN sys.t_data_kind AS tdk2 ON T.order_status = tdk2.kind_code
|
|
|
+ LEFT JOIN sys.t_data_kind AS tdk3 ON T.out_status = tdk3.kind_code
|
|
|
+ LEFT JOIN dkic_b.t_psi_order_item toi ON toi.order_id = T.order_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_goods_sku tmgs ON tmgs.sku_id = toi.sku_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_goods_brand tmgb ON tmgb.brand_id = tmgs.brand_id
|
|
|
+ left join dkic_b.t_mst_unit as tmgu on toi.unit_id = tmgu.unit_id
|
|
|
+ left join dkic_b.t_mst_unit as tmgus on toi.sub_unit_id = tmgus.unit_id
|
|
|
+ WHERE toi.sku_id is not null
|
|
|
+ and T.flg_valid
|
|
|
+ and toi.flg_valid
|
|
|
+ and toi.purchase_qty < toi.item_qty
|
|
|
+ <if test="cpId != null">
|
|
|
+ AND t.cp_id = #{cpId}
|
|
|
+ </if>
|
|
|
+ <if test="cusPhone != null and cusPhone != ''">
|
|
|
+ AND t.cus_phone LIKE concat('%',my_ex.likequery(#{cusPhone}),'%')
|
|
|
+ </if>
|
|
|
+ <if test="cusName != null and cusName != ''">
|
|
|
+ AND t.cus_name LIKE concat('%',my_ex.likequery(#{cusName}),'%')
|
|
|
+ </if>
|
|
|
+ <if test="makeTimeStart != null and makeTimeEnd != null">
|
|
|
+ AND t.make_time >= #{makeTimeStart}::timestamp with time zone
|
|
|
+ AND t.make_time < #{makeTimeEnd}::timestamp with time zone + interval '1 day'
|
|
|
+ </if>
|
|
|
+ <if test="skuName != null and skuName != ''">
|
|
|
+ AND toi.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
|
|
|
+ </if>
|
|
|
+ <if test="skuModel != null and skuModel != ''">
|
|
|
+ AND toi.sku_model LIKE concat('%',my_ex.likequery(#{skuModel}),'%')
|
|
|
+ </if>
|
|
|
+ order by t.op_create_time desc
|
|
|
+ <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
|
|
|
+ limit #{end} offset #{start}
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 查询表t_psi_order,(条件查询)个数 -->
|
|
|
+ <select id="purchaseBasedOnSalesCountByCond" resultType="Long">
|
|
|
+ SELECT
|
|
|
+ count(1)
|
|
|
+ FROM
|
|
|
+ dkic_b.t_psi_order
|
|
|
+ AS T
|
|
|
+ LEFT JOIN dkic_b.t_mst_sale_channel tmsc ON T.sales_channel = tmsc.channel_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_org tmo ON T.org_id = tmo.org_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_staff tms ON T.staff_id = tms.staff_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_customer tmc ON T.cus_id = tmc.cus_id
|
|
|
+ LEFT JOIN sys.t_data_kind AS tdk1 ON T.order_type = tdk1.kind_code
|
|
|
+ LEFT JOIN sys.t_data_kind AS tdk2 ON T.order_status = tdk2.kind_code
|
|
|
+ LEFT JOIN sys.t_data_kind AS tdk3 ON T.out_status = tdk3.kind_code
|
|
|
+ LEFT JOIN dkic_b.t_psi_order_item toi ON toi.order_id = T.order_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_goods_sku tmgs ON tmgs.sku_id = toi.sku_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_goods_brand tmgb ON tmgb.brand_id = tmgs.brand_id
|
|
|
+ left join dkic_b.t_mst_unit as tmgu on toi.unit_id = tmgu.unit_id
|
|
|
+ left join dkic_b.t_mst_unit as tmgus on toi.sub_unit_id = tmgus.unit_id
|
|
|
+ WHERE toi.sku_id is not null
|
|
|
+ and T.flg_valid
|
|
|
+ and toi.flg_valid
|
|
|
+ and toi.purchase_qty < toi.item_qty
|
|
|
+ <if test="cpId != null">
|
|
|
+ AND t.cp_id = #{cpId}
|
|
|
+ </if>
|
|
|
+ <if test="cusPhone != null and cusPhone != ''">
|
|
|
+ AND t.cus_phone LIKE concat('%',my_ex.likequery(#{cusPhone}),'%')
|
|
|
+ </if>
|
|
|
+ <if test="cusName != null and cusName != ''">
|
|
|
+ AND t.cus_name LIKE concat('%',my_ex.likequery(#{cusName}),'%')
|
|
|
+ </if>
|
|
|
+ <if test="makeTimeStart != null and makeTimeEnd != null">
|
|
|
+ AND t.make_time >= #{makeTimeStart}::timestamp with time zone
|
|
|
+ AND t.make_time < #{makeTimeEnd}::timestamp with time zone + interval '1 day'
|
|
|
+ </if>
|
|
|
+ <if test="skuName != null and skuName != ''">
|
|
|
+ AND toi.sku_name LIKE concat('%',my_ex.likequery(#{skuName}),'%')
|
|
|
+ </if>
|
|
|
+ <if test="skuModel != null and skuModel != ''">
|
|
|
+ AND toi.sku_model LIKE concat('%',my_ex.likequery(#{skuModel}),'%')
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
</mapper>
|