|
|
@@ -572,7 +572,7 @@
|
|
|
,tpp.amt_payable as "amtPayable"
|
|
|
,tpp.amt_residue as "amtResidue"
|
|
|
,tpp.remarks
|
|
|
- FROM dkic_b.t_psi_purchase tpp
|
|
|
+ FROM dkic_b.t_psi_purchase tpp
|
|
|
Left join dkic_b.t_mst_org tmo on tpp.org_id = tmo.org_id
|
|
|
Left join dkic_b.t_mst_supplier tmp on tpp.sup_id = tmp.sup_id
|
|
|
Left join dkic_b.t_mst_staff tms on tpp.staff_id = tms.staff_id
|
|
|
@@ -1572,6 +1572,7 @@
|
|
|
,tpp.org_id AS "orgId"
|
|
|
,tmo.org_name AS "orgName"
|
|
|
,tpp.staff_id AS "staffId"
|
|
|
+ ,tmsta.staff_name AS "staffName"
|
|
|
,tpp.sup_id AS "supId"
|
|
|
,tpp.contact_name AS "contactName"
|
|
|
,tpp.contact_phone AS "contactPhone"
|
|
|
@@ -1609,6 +1610,7 @@
|
|
|
left join sys.t_data_kind as tdk2 on tpp.pur_status = tdk2.kind_code
|
|
|
left join sys.t_data_kind as tdk3 on tpp.into_status = tdk3.kind_code
|
|
|
left join dkic_b.t_mst_org as tmo on tpp.org_id = tmo.org_id
|
|
|
+ left join dkic_b.t_mst_staff as tmsta on tpp.staff_id = tmsta.staff_id
|
|
|
<include refid="ConditionPurTrackingReport"/>
|
|
|
order by tpp.op_create_time desc
|
|
|
<if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
|
|
|
@@ -1660,6 +1662,8 @@
|
|
|
<result column="pricePur" property="pricePur"/>
|
|
|
<result column="itemQty" property="itemQty"/>
|
|
|
<result column="remarks" property="remarks"/>
|
|
|
+ <result column="sumQuantity" property="sumQuantity"/>
|
|
|
+ <result column="sumAmount" property="sumAmount"/>
|
|
|
</resultMap>
|
|
|
|
|
|
<!--采购跟踪表 明细查询-->
|
|
|
@@ -1692,6 +1696,8 @@
|
|
|
,T."pricePur" AS list_pricePur
|
|
|
,T."itemQty" AS list_itemQty
|
|
|
,T."remarks" AS list_remarks
|
|
|
+ ,T."sumQuantity" AS list_sumQuantity
|
|
|
+ ,T."sumAmount" AS list_sumAmount
|
|
|
FROM
|
|
|
(
|
|
|
SELECT
|
|
|
@@ -1728,7 +1734,7 @@
|
|
|
LEFT JOIN dkic_b.t_mst_goods_sku tmgs ON tmgs.sku_id = tppi.sku_id
|
|
|
LEFT JOIN dkic_b.t_mst_goods_brand tmgb ON tmgb.brand_id = tmgs.brand_id
|
|
|
WHERE
|
|
|
- tpp.pur_id = = #{id}::uuid
|
|
|
+ tpp.pur_id = #{id}::uuid
|
|
|
UNION ALL
|
|
|
SELECT
|
|
|
tpi.into_id AS "id"
|
|
|
@@ -1738,8 +1744,8 @@
|
|
|
,NULL AS "whId"
|
|
|
,NULL AS "makeTime"
|
|
|
,NULL AS "pickupDate"
|
|
|
- ,NULL AS "sumQuantity"
|
|
|
- ,NULL AS "sumAmount"
|
|
|
+ ,0.00 AS "sumQuantity"
|
|
|
+ ,0.00 AS "sumAmount"
|
|
|
,NULL AS "intoQty"
|
|
|
,0 AS "returnQty"
|
|
|
,0.00 AS "sumAmtRec"
|
|
|
@@ -1760,7 +1766,6 @@
|
|
|
WHEN tpii.into_status = '入库状态-入库中' THEN tpii.intoing_qty
|
|
|
ELSE tpii.into_qty
|
|
|
END AS "itemQty"
|
|
|
- -- 入库中显示入库中数量 已入库显示 已入库数量
|
|
|
,tpii.remarks AS "remarks"
|
|
|
FROM
|
|
|
dkic_b.t_psi_inbound_item tpii
|
|
|
@@ -1768,7 +1773,48 @@
|
|
|
LEFT JOIN dkic_b.t_mst_goods_sku tmgs ON tmgs.sku_id = tpii.sku_id
|
|
|
LEFT JOIN dkic_b.t_mst_goods_brand tmgb ON tmgb.brand_id = tmgs.brand_id
|
|
|
WHERE
|
|
|
- tpi.from_id = = #{id}::uuid
|
|
|
+ tpi.from_id = #{id}::uuid
|
|
|
+ AND tpi.into_type = '入库类型-采购入库'
|
|
|
+ UNION ALL
|
|
|
+ SELECT
|
|
|
+ tpi.into_id AS "id"
|
|
|
+ ,tpi.into_no AS "no"
|
|
|
+ ,NULL AS "contactName"
|
|
|
+ ,NULL AS "contactPhone"
|
|
|
+ ,NULL AS "whId"
|
|
|
+ ,NULL AS "makeTime"
|
|
|
+ ,NULL AS "pickupDate"
|
|
|
+ ,0.00 AS "sumQuantity"
|
|
|
+ ,0.00 AS "sumAmount"
|
|
|
+ ,NULL AS "intoQty"
|
|
|
+ ,0 AS "returnQty"
|
|
|
+ ,0.00 AS "sumAmtRec"
|
|
|
+ ,0.00 AS "sumShouldHandle"
|
|
|
+ ,0.00 AS "sumUsePaymentResidue"
|
|
|
+ ,0.00 AS "sumWaiveAmt"
|
|
|
+ ,tpii.item_id AS "itemId"
|
|
|
+ ,'采购退货' AS "type"
|
|
|
+ ,tpii.sku_id AS "skuId"
|
|
|
+ ,tmgs.sku_code AS "skuCode"
|
|
|
+ ,tmgs.sku_name AS "skuName"
|
|
|
+ ,tmgs.sku_model AS "skuModel"
|
|
|
+ ,tmgs.sku_images AS "skuImages"
|
|
|
+ ,tmgb.brand_name AS "brandName"
|
|
|
+ ,tmgb.short_name AS "shortName"
|
|
|
+ ,tpii.price_into AS "pricePur"
|
|
|
+ , CASE
|
|
|
+ WHEN tpii.into_status = '入库状态-入库中' THEN tpii.intoing_qty
|
|
|
+ ELSE tpii.into_qty
|
|
|
+ END AS "itemQty"
|
|
|
+ ,tpii.remarks AS "remarks"
|
|
|
+ FROM
|
|
|
+ dkic_b.t_psi_inbound_item tpii
|
|
|
+ LEFT JOIN dkic_b.t_psi_inbound tpi ON tpi.into_id = tpii.into_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_goods_sku tmgs ON tmgs.sku_id = tpii.sku_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_goods_brand tmgb ON tmgb.brand_id = tmgs.brand_id
|
|
|
+ WHERE
|
|
|
+ tpi.from_id = #{id}::uuid
|
|
|
+ AND tpi.into_type = '入库类型-采购入库退货'
|
|
|
UNION ALL
|
|
|
SELECT
|
|
|
tmrp.rp_id AS "id"
|
|
|
@@ -1778,8 +1824,8 @@
|
|
|
,NULL AS "whId"
|
|
|
,NULL AS "makeTime"
|
|
|
,NULL AS "pickupDate"
|
|
|
- ,NULL AS "sumQuantity"
|
|
|
- ,NULL AS "sumAmount"
|
|
|
+ ,0.00 AS "sumQuantity"
|
|
|
+ ,0.00 AS "sumAmount"
|
|
|
,NULL AS "intoQty"
|
|
|
,NULL AS "returnQty"
|
|
|
,tmrp.sum_amt_rec AS "sumAmtRec"
|
|
|
@@ -1810,45 +1856,45 @@
|
|
|
<!-- 日结对账表列表查询-->
|
|
|
<select id="getDailyReconciliationReport" resultType="java.util.Map">
|
|
|
SELECT
|
|
|
- T.item_id,
|
|
|
- T.item_id as "accItemId",
|
|
|
- T.acc_item_type,
|
|
|
- T.object_id,
|
|
|
- tmc.cus_code as "cusCode",
|
|
|
- tmc.cus_name as "cusName",
|
|
|
- tmc.cus_phone as "cusPhone",
|
|
|
- tmc.address_full as "addressFull",
|
|
|
- T.org_id,
|
|
|
- tmo.org_name as "orgName",
|
|
|
- T.staff_id,
|
|
|
- tms.staff_name as "staffName",
|
|
|
- T.biznis_type,
|
|
|
- T.biznis_id,
|
|
|
- T.biznis_no,
|
|
|
- T.acc_date,
|
|
|
- T.rec_status,
|
|
|
- sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "recStatusName",
|
|
|
- T.amt_rec,
|
|
|
- T.amt_pay,
|
|
|
- T.amt_should,
|
|
|
- T.amt_handle,
|
|
|
- T.amt_waive,
|
|
|
- T.amt_residue as "amtNotHandle",
|
|
|
- T.amt_residue as "amtReceivableHandle",
|
|
|
- T.amt_residue,
|
|
|
- T.remarks,
|
|
|
- T.make_staff,
|
|
|
- T.make_time,
|
|
|
- T.flg_valid,
|
|
|
- T.cp_id,
|
|
|
- ord.totalOrderAmount
|
|
|
+ T.item_id AS "itemId"
|
|
|
+ T.item_id AS "accItemId",
|
|
|
+ T.acc_item_type AS "accItemType",
|
|
|
+ T.object_id AS "objectId",
|
|
|
+ tmc.cus_code AS "cusCode",
|
|
|
+ tmc.cus_name AS "cusName",
|
|
|
+ tmc.cus_phone AS "cusPhone",
|
|
|
+ tmc.address_full AS "addressFull",
|
|
|
+ T.org_id AS "orgId",
|
|
|
+ tmo.org_name AS "orgName",
|
|
|
+ T.staff_id AS "staffId",
|
|
|
+ tms.staff_name AS "staffName",
|
|
|
+ T.biznis_type AS "biznisType",
|
|
|
+ T.biznis_id AS "biznisId",
|
|
|
+ T.biznis_no AS "bizniso",
|
|
|
+ T.acc_date AS "accDate",
|
|
|
+ T.rec_status AS "recStatus",
|
|
|
+ sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) AS "recStatusName",
|
|
|
+ T.amt_rec AS "amtRec",
|
|
|
+ T.amt_pay AS "amtPay",
|
|
|
+ T.amt_should AS "amtShould",
|
|
|
+ T.amt_handle AS "amtHandle",
|
|
|
+ T.amt_waive AS "amtWaive",
|
|
|
+ T.amt_residue AS "amtNotHandle",
|
|
|
+ T.amt_residue AS "amtReceivableHandle",
|
|
|
+ T.amt_residue AS "amtResidue",
|
|
|
+ T.remarks AS "remarks" ,
|
|
|
+ T.make_staff AS "makeStaff",
|
|
|
+ T.make_time AS "makeTime",
|
|
|
+ T.flg_valid AS "flgValid" ,
|
|
|
+ T.cp_id AS "cpId" ,
|
|
|
+ ord.totalOrderAmount
|
|
|
FROM dkic_b.t_mac_account_item as T
|
|
|
- left join (select sum(tpo.sum_amount) as totalOrderAmount ,tpo.cus_id from dkic_b.t_psi_order tpo group by tpo.cus_id ) ord on ord.cus_id =T.object_id
|
|
|
- left join dkic_b.t_mac_other_receivable as tmor on tmor.receivable_id = t.biznis_id and t.biznis_type = 't_mac_other_receivable'
|
|
|
- left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.object_id
|
|
|
- left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
|
|
|
- left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
|
|
|
- left join sys.t_data_kind as tdk1 on t.rec_status = tdk1.kind_code
|
|
|
+ LEFT JOIN (select sum(tpo.sum_amount) as totalOrderAmount ,tpo.cus_id from dkic_b.t_psi_order tpo group by tpo.cus_id ) ord ON ord.cus_id =T.object_id
|
|
|
+ LEFT JOIN dkic_b.t_mac_other_receivable as tmor ON tmor.receivable_id = T.biznis_id and T.biznis_type = 't_mac_other_receivable'
|
|
|
+ LEFT JOIN dkic_b.t_mst_customer tmc ON tmc.cus_id = T.object_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_org tmo ON tmo.org_id = T.org_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_staff tms ON tms.staff_id = T.staff_id
|
|
|
+ LEFT JOIN sys.t_data_kind as tdk1 ON T.rec_status = tdk1.kind_code
|
|
|
<include refid="ConditionDailyReconciliationReport"/>
|
|
|
order by tpo.op_create_time desc
|
|
|
<if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
|
|
|
@@ -1861,12 +1907,12 @@
|
|
|
SELECT count(1)
|
|
|
FROM
|
|
|
FROM dkic_b.t_mac_account_item as T
|
|
|
- left join (select sum(tpo.sum_amount) as totalOrderAmount ,tpo.cus_id from dkic_b.t_psi_order tpo group by tpo.cus_id ) ord on ord.cus_id =T.object_id
|
|
|
- left join dkic_b.t_mac_other_receivable as tmor on tmor.receivable_id = t.biznis_id and t.biznis_type = 't_mac_other_receivable'
|
|
|
- left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.object_id
|
|
|
- left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
|
|
|
- left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
|
|
|
- left join sys.t_data_kind as tdk1 on t.rec_status = tdk1.kind_code
|
|
|
+ LEFT JOIN (select sum(tpo.sum_amount) as totalOrderAmount ,tpo.cus_id from dkic_b.t_psi_order tpo group by tpo.cus_id ) ord ON ord.cus_id =T.object_id
|
|
|
+ LEFT JOIN dkic_b.t_mac_other_receivable as tmor ON tmor.receivable_id = T.biznis_id and T.biznis_type = 't_mac_other_receivable'
|
|
|
+ LEFT JOIN dkic_b.t_mst_customer tmc ON tmc.cus_id = T.object_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_org tmo ON tmo.org_id = T.org_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_staff tms ON tms.staff_id = T.staff_id
|
|
|
+ LEFT JOIN sys.t_data_kind as tdk1 ON T.rec_status = tdk1.kind_code
|
|
|
<include refid="ConditionDailyReconciliationReport"/>
|
|
|
</select>
|
|
|
|
|
|
@@ -1874,16 +1920,16 @@
|
|
|
<sql id="ConditionDailyReconciliationReport">
|
|
|
<where>
|
|
|
<if test="cpId != null">
|
|
|
- T.cp_id = #{cpId}
|
|
|
+ AND T.cp_id = #{cpId}
|
|
|
</if>
|
|
|
<if test="staffId != null">
|
|
|
- T.staff_id = #{staffId}
|
|
|
+ AND T.staff_id = #{staffId}
|
|
|
</if>
|
|
|
<if test="orgId != null">
|
|
|
- T.org_id = #{orgId}
|
|
|
+ AND T.org_id = #{orgId}
|
|
|
</if>
|
|
|
<if test="object_id != null">
|
|
|
- T.object_id = #{object_id}
|
|
|
+ AND T.object_id = #{object_id}
|
|
|
</if>
|
|
|
<if test="accDateStart != null">
|
|
|
AND T.acc_date >= #{accDateStart}::timestamp with time zone
|
|
|
@@ -1893,7 +1939,335 @@
|
|
|
</if>
|
|
|
</where>
|
|
|
</sql>
|
|
|
+
|
|
|
+ <!-- 日结对账表-查销售订单-->
|
|
|
+ <select id="getDailyReconciliationReportByOrder" resultType="java.util.Map">
|
|
|
+ SELECT
|
|
|
+ T.order_id AS "orderId",
|
|
|
+ T.order_no AS "orderNo",
|
|
|
+ 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",
|
|
|
+ tmc.cus_name AS "cusName",
|
|
|
+ tmc.cus_phone AS "cusPhone",
|
|
|
+ tmc.cus_from AS "cusFrom",
|
|
|
+ tmdd.data_value AS "cusFromName",
|
|
|
+ T.address_area AS "addressArea",
|
|
|
+ T.address_name AS "addressName",
|
|
|
+ T.address_no AS "addressNo",
|
|
|
+ T.address_gcj02 AS "addressGcj02",
|
|
|
+ T.address_full AS "addressFull",
|
|
|
+ T.contact_name AS "contactName",
|
|
|
+ T.contact_phone AS "contactPhone",
|
|
|
+ T.sales_channel AS "salesChannel",
|
|
|
+ tmsc.channel_name AS "channelName",
|
|
|
+ T.delivery_date AS "deliveryDate",
|
|
|
+ T.sum_quantity AS "sumQuantity",
|
|
|
+ T.sum_standard AS "sumStandard",
|
|
|
+ T.sum_amount AS "sumAmount",
|
|
|
+ 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 "orderStatus",
|
|
|
+ sys.f_get_name_i18n(tdk3.kind_name_i18n, #{i18n}) AS "outStatusName",
|
|
|
+ T.outing_qty AS "outingQty",
|
|
|
+ T.outing_amt AS "outingAmt",
|
|
|
+ T.out_qty AS "outQty",
|
|
|
+ T.out_amt AS "outAmt",
|
|
|
+ T.return_qty AS "returnQty",
|
|
|
+ T.return_amt AS "returnAmt",
|
|
|
+ T.amt_receivable AS "amtReceivable",
|
|
|
+ T.amt_handle AS "amtHandle",
|
|
|
+ T.amt_residue AS "amtResidue",
|
|
|
+ T.remarks AS "remarks",
|
|
|
+ T.annex_paths AS "annexPaths",
|
|
|
+ makestaff.staff_name AS "makeStaffName",
|
|
|
+ T.make_time AS "makeTime",
|
|
|
+ T.cp_id AS "cpId",
|
|
|
+ T.flg_valid AS "flgValid"
|
|
|
+ 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_staff as makestaff ON T.make_staff = makestaff.staff_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_customer tmc ON T.cus_id = tmc.cus_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_dictionary_data tmdd ON tmc.cus_from = tmdd.data_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
|
|
|
+ <include refid="ConditionDailyReconciliationReport"/>
|
|
|
+ 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>
|
|
|
+
|
|
|
+ <!-- 日结对账表-查销售订单数量-->
|
|
|
+ <select id="getDailyReconciliationReportByOrderCount" resultType="java.lang.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_staff as makestaff ON T.make_staff = makestaff.staff_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_customer tmc ON T.cus_id = tmc.cus_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_dictionary_data tmdd ON tmc.cus_from = tmdd.data_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
|
|
|
+ <include refid="ConditionDailyReconciliationReport"/>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 日结对账表查询条件-->
|
|
|
+ <sql id="ConditionDailyReconciliationReportByOrder">
|
|
|
+ <where>
|
|
|
+ <if test="orderNo != null">
|
|
|
+ AND T.order_no = #{orderNo}
|
|
|
+ </if>
|
|
|
+ <if test="cusName != null">
|
|
|
+ AND tmc.cus_name = #{cusName}
|
|
|
+ </if>
|
|
|
+ <if test="cusPhone != null">
|
|
|
+ AND tmc.cus_phone = #{cusPhone}
|
|
|
+ </if>
|
|
|
+ <if test="cus_id != null">
|
|
|
+ AND T.cus_id = #{cusId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </sql>
|
|
|
+
|
|
|
+
|
|
|
+ <!-- 日结对账表-查销售出库-->
|
|
|
+ <select id="getDailyReconciliationReportByOut" resultType="java.util.Map">
|
|
|
+ SELECT
|
|
|
+ T.out_id AS "outId",
|
|
|
+ T.out_no AS "outNo",
|
|
|
+ T.out_type AS "outType",
|
|
|
+ T.from_id AS "fromId",
|
|
|
+ T.from_no AS "fromNo",
|
|
|
+ T.from_no AS "biznisNo",
|
|
|
+ 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",
|
|
|
+ tmc.cus_name AS "cusName",
|
|
|
+ tmc.cus_phone AS "cusPhone",
|
|
|
+ tmc.cus_from AS "cusFrom",
|
|
|
+ tmc.contact_phone AS "contactPhone",
|
|
|
+ tmc.address_full AS "addressFull",
|
|
|
+ tmdd.data_value AS cus_from_name,
|
|
|
+ T.sup_id AS "supId",
|
|
|
+ tmp.sup_name AS "supplierName",
|
|
|
+ T.out_status AS "outStatus",
|
|
|
+ sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) AS "outStatusName",
|
|
|
+ sys.f_get_name_i18n(tdktype.kind_name_i18n, #{i18n}) AS "outTypeName",
|
|
|
+ T.outing_qty AS "outingQty",
|
|
|
+ T.outing_amt AS "outingAmt",
|
|
|
+ T.out_qty AS "outQty",
|
|
|
+ T.out_amt AS "outAmt",
|
|
|
+ T.return_qty AS "returnQty",
|
|
|
+ T.return_amt AS "returnAmt",
|
|
|
+ T.out_date AS "outDate",
|
|
|
+ T.remarks AS "remarks",
|
|
|
+ T.annex_paths AS "annexPaths",
|
|
|
+ T.make_staff AS "makeStaff",
|
|
|
+ makestaff.staff_name AS "makeStaffName",
|
|
|
+ T.make_time AS "makeTime",
|
|
|
+ T.receivable_id AS "receivableId",
|
|
|
+ T.cp_id AS "cpId",
|
|
|
+ T.flg_valid AS "flgValid"",
|
|
|
+ tmd.data_value as "outReasonName"
|
|
|
+ FROM dkic_b.t_psi_outbound as T
|
|
|
+ LEFT JOIN dkic_b.t_mst_org tmo ON tmo.org_id = T.org_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_supplier tmp ON tmp.sup_id = T.sup_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_staff tms ON tms.staff_id = T.staff_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_staff as makestaff ON makestaff.staff_id = T.make_staff
|
|
|
+ LEFT JOIN dkic_b.t_mst_customer tmc ON tmc.cus_id = T.cus_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_dictionary_data tmdd ON tmdd.data_id = tmc.cus_from
|
|
|
+ LEFT JOIN sys.t_data_kind as tdk1 ON tdk1.kind_code = T.out_status
|
|
|
+ LEFT JOIN sys.t_data_kind tdktype ON tdktype.kind_code = T.out_type
|
|
|
+ LEFT JOIN dkic_b.t_mst_dictionary_data tmd ON tmd.data_id = T.out_reason
|
|
|
+ <include refid="ConditionDailyReconciliationReportByOut"/>
|
|
|
+ order by t.make_time desc
|
|
|
+ <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
|
|
|
+ limit #{end} offset #{start}
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 日结对账表-查销售订单数量-->
|
|
|
+ <select id="getDailyReconciliationReportByOutCount" resultType="java.lang.Long">
|
|
|
+ SELECT count(1)
|
|
|
+ FROM dkic_b.t_psi_outbound as T
|
|
|
+ LEFT JOIN dkic_b.t_mst_org tmo ON tmo.org_id = T.org_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_supplier tmp ON tmp.sup_id = T.sup_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_staff tms ON tms.staff_id = T.staff_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_staff as makestaff ON makestaff.staff_id = T.make_staff
|
|
|
+ LEFT JOIN dkic_b.t_mst_customer tmc ON tmc.cus_id = T.cus_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_dictionary_data tmdd ON tmdd.data_id = tmc.cus_from
|
|
|
+ LEFT JOIN sys.t_data_kind as tdk1 ON tdk1.kind_code = T.out_status
|
|
|
+ LEFT JOIN sys.t_data_kind tdktype ON tdktype.kind_code = T.out_type
|
|
|
+ LEFT JOIN dkic_b.t_mst_dictionary_data tmd ON tmd.data_id = T.out_reason
|
|
|
+ <include refid="ConditionDailyReconciliationReportByOut"/>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 日结对账表查询条件-->
|
|
|
+ <sql id="ConditionDailyReconciliationReportByOut">
|
|
|
+ <where>
|
|
|
+ <if test="outNo != null">
|
|
|
+ AND T.out_no = #{outNo}
|
|
|
+ </if>
|
|
|
+ <if test="cusName != null">
|
|
|
+ AND tmc.cus_name = #{cusName}
|
|
|
+ </if>
|
|
|
+ <if test="cusPhone != null">
|
|
|
+ AND tmc.cus_phone = #{cusPhone}
|
|
|
+ </if>
|
|
|
+ <if test="cus_id != null">
|
|
|
+ AND T.cus_id = #{cusId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </sql>
|
|
|
|
|
|
+ <!-- 日结对账表-查收款单 -->
|
|
|
+ <select id="getDailyReconciliationReportByPay" resultType="java.util.Map">
|
|
|
+ select
|
|
|
+ T.rp_id AS "rpId",
|
|
|
+ T.rp_no AS "rpNo",
|
|
|
+ T.rp_type AS "rpType",
|
|
|
+ sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) AS "rpTypeName",
|
|
|
+ T.object_id AS "objectId",
|
|
|
+ tmc.cus_code AS "cusCode",
|
|
|
+ tmc.cus_name AS "cusName",
|
|
|
+ tmc.cus_phone AS "cusPhone",
|
|
|
+ tmc.address_full AS "addressFull",
|
|
|
+ T.org_id AS "orgId",
|
|
|
+ tmo.org_name AS "orgName",
|
|
|
+ T.staff_id AS "staffId",
|
|
|
+ tms.staff_name AS "staffName",
|
|
|
+ T.sum_amt_rec AS "sumAmtRec",
|
|
|
+ T.sum_amt_pay AS "sumAmtPay",
|
|
|
+ T.sum_should_handle AS "sumShouldHandle",
|
|
|
+ T.sum_use_receipt_residue AS "sumUseReceiptResidue",
|
|
|
+ T.sum_use_payment_residue AS "sumUsePaymentResidue",
|
|
|
+ T.sum_amt_receivable_handle AS "sumAmtReceivableHandle",
|
|
|
+ T.sum_amt_payable_handle AS "sumAmtPayableHandle",
|
|
|
+ T.sum_waive_amt AS "sumWaiveAmt",
|
|
|
+ T.acc_date AS "accDate",
|
|
|
+ T.remarks AS "remarks",
|
|
|
+ T.annex_paths AS "annexPaths",
|
|
|
+ T.biznis_type AS "biznisType",
|
|
|
+ T.biznis_id AS "biznisId",
|
|
|
+ T.biznis_no AS "biznisNo",
|
|
|
+ T.flg_lock AS "flgLock",
|
|
|
+ T.make_staff AS "makeStaff",
|
|
|
+ makestaff.staff_name AS "makeStaffName",
|
|
|
+ T.make_time AS "makeTime",
|
|
|
+ T.flg_valid AS "flgValid",
|
|
|
+ T.cp_id AS "cpId",
|
|
|
+ tma.receivable_residue AS "receivableResidue",
|
|
|
+ tma.receipt_residue AS "receiptResidue"
|
|
|
+ FROM dkic_b.t_mac_rec_pay as T
|
|
|
+ LEFT JOIN dkic_b.t_mst_customer tmc ON tmc.cus_id = T.object_id
|
|
|
+ LEFT JOIN sys.t_data_kind as tdk1 ON tdk1.kind_code = T.rp_type
|
|
|
+ LEFT JOIN dkic_b.t_mst_org tmo ON tmo.org_id = T.org_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_staff tms ON tms.staff_id = T.staff_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_staff as makestaff ON makestaff.staff_id = T.make_staff
|
|
|
+ LEFT JOIN dkic_b.t_mac_account tma ON tma.object_id = T.object_id and tma.object_type in ('对象类型-客户')
|
|
|
+ <include refid="ConditionDailyReconciliationReportByPay"/>
|
|
|
+ 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>
|
|
|
|
|
|
+ <!-- 日结对账表-查收款单数量-->
|
|
|
+ <select id="getDailyReconciliationReportByPayCount" resultType="java.lang.Long">
|
|
|
+ SELECT count(1)
|
|
|
+ FROM dkic_b.t_mac_rec_pay as T
|
|
|
+ LEFT JOIN dkic_b.t_mst_customer tmc ON tmc.cus_id = T.object_id
|
|
|
+ LEFT JOIN sys.t_data_kind as tdk1 ON tdk1.kind_code = T.rp_type
|
|
|
+ LEFT JOIN dkic_b.t_mst_org tmo ON tmo.org_id = T.org_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_staff tms ON tms.staff_id = T.staff_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_staff as makestaff ON makestaff.staff_id = T.make_staff
|
|
|
+ LEFT JOIN dkic_b.t_mac_account tma ON tma.object_id = T.object_id and tma.object_type in ('对象类型-客户')
|
|
|
+ <include refid="ConditionDailyReconciliationReportByPay"/>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 日结对账表-查收款单查询条件-->
|
|
|
+ <sql id="ConditionDailyReconciliationReportByPay">
|
|
|
+ <where>
|
|
|
+ T.rp_type = '收付款类型-收款'
|
|
|
+ <if test="rpNo != null">
|
|
|
+ AND T.rp_no = #{rpNo}
|
|
|
+ </if>
|
|
|
+ <if test="cusName != null">
|
|
|
+ AND tmc.cus_name = #{cusName}
|
|
|
+ </if>
|
|
|
+ <if test="cusPhone != null">
|
|
|
+ AND tmc.cus_phone = #{cusPhone}
|
|
|
+ </if>
|
|
|
+ <if test="cus_id != null">
|
|
|
+ AND T.cus_id = #{cusId}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!-- 供应商往来余额表 -->
|
|
|
+ <select id="getSupAccount" resultType="java.util.Map">
|
|
|
+ SELECT
|
|
|
+ tms.sup_name AS "supName",
|
|
|
+ tms.sup_id as "objectId",
|
|
|
+ SUM ( tmai.amt_pay ) as "sumAmtPay",
|
|
|
+ SUM ( tmai.amt_handle ) as "sumAmtHandle"
|
|
|
+ FROM
|
|
|
+ dkic_b.t_mac_account_item tmai
|
|
|
+ INNER JOIN dkic_b.t_mst_supplier tms ON tmai.object_id = tms.sup_id
|
|
|
+ <where>
|
|
|
+ tmai.flg_valid
|
|
|
+ AND tmai.acc_item_type IN ( '账款类型-应付', '账款类型-付款' )
|
|
|
+ and tmai.cp_id = #{cpId}
|
|
|
+ <!--开始日期-->
|
|
|
+ <if test="accDateStart != null">
|
|
|
+ AND tmai.acc_date >= #{accDateStart}::timestamp with time zone
|
|
|
+ </if>
|
|
|
+ <!--截止日期-->
|
|
|
+ <if test="accDateEnd != null">
|
|
|
+ AND tmai.acc_date <= #{accDateEnd}::timestamp with time zone + interval '1 day'
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY tms.sup_name,tms.sup_id
|
|
|
+ <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
|
|
|
+ limit #{end} offset #{start}
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 供应商往来余额表明细 -->
|
|
|
+ <select id="getSupAccountItem" resultType="java.util.Map">
|
|
|
+ SELECT
|
|
|
+ tmai.item_id as "itemId"
|
|
|
+ ,tmai.acc_item_type as "accItemType"
|
|
|
+ ,sys.f_get_name_i18n(tdk.kind_name_i18n,#{i18n}) AS "accItemTypeName"
|
|
|
+ ,tmai.org_id as "orgId"
|
|
|
+ ,tmo.org_name as "orgName"
|
|
|
+ ,tmai.staff_id as "staffId"
|
|
|
+ ,tms.staff_name as "staffName"
|
|
|
+ ,tmai.amt_pay as "amtPay"
|
|
|
+ ,tmai.amt_handle as "amtHandle"
|
|
|
+ FROM dkic_b.t_mac_account_item tmai
|
|
|
+ LEFT JOIN dkic_b.t_mst_org tmo ON tmo.org_id = tmai.org_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_staff tms ON tms.staff_id = tmai.staff_id
|
|
|
+ LEFT JOIN sys.t_data_kind tdk ON tdk.kind_code = tmai.acc_item_type
|
|
|
+ where tmai.flg_valid
|
|
|
+ and tmai.acc_item_type in ('账款类型-应付','账款类型-付款')
|
|
|
+ and tmai.object_id = #{objectId}::uuid
|
|
|
+ </select>
|
|
|
|
|
|
</mapper>
|