From 6332b04bc7991a310b13aef044082621d618479a Mon Sep 17 00:00:00 2001
From: shiyunteng <shiyunteng@example.com>
Date: 星期二, 19 五月 2026 17:02:19 +0800
Subject: [PATCH] feat:新增赊销、抵抹账功能 合同新增销售模式字段,新增生成新合同接口 出库:出库多余配件处理

---
 platformx-business-finance-biz/src/main/resources/mapper/ContractMapper.xml |   96 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 96 insertions(+), 0 deletions(-)

diff --git a/platformx-business-finance-biz/src/main/resources/mapper/ContractMapper.xml b/platformx-business-finance-biz/src/main/resources/mapper/ContractMapper.xml
index a251b1e..4409166 100644
--- a/platformx-business-finance-biz/src/main/resources/mapper/ContractMapper.xml
+++ b/platformx-business-finance-biz/src/main/resources/mapper/ContractMapper.xml
@@ -4,4 +4,100 @@
 
 <mapper namespace="com.by4cloud.platformx.business.mapper.ContractMapper">
 
+    <select id="pageByCredit" resultType="com.by4cloud.platformx.business.vo.ContractCreditSalesPageVo">
+		SELECT
+		id,
+		contract_no,
+		contract_name,
+		party_a_id,
+		party_a,
+		party_b_id,
+		party_b,
+		amount,
+		currency,
+		contract_type,
+		supply_attribute,
+		contract_status,
+		contract_attribute,
+		sign_date,
+		effective_date,
+		delivery_cycle,
+		expiration_date,
+		attachment_url,
+		remark,
+		parent_id,
+		approve_time,
+		arrival_schedule_id,
+		accept_schedule_id,
+		erp_push_flag,
+		billing_status,
+		next_schedule_name,
+		template_id,
+		sales_model,
+		paid_amount,
+		create_by,
+		update_by,
+		create_time,
+		update_time,
+		del_flag,
+		comp_id,
+		(SELECT GROUP_CONCAT(DISTINCT t1.material_internal_name) from contract_subject_matter t1 WHERE t1.contract_id = t.id) productNames,
+		IFNULL( t.billing_amout, 0 ) billing_amout,
+		( SELECT IFNULL( sum( unit_price * delivered_quantity ), 0 ) FROM contract_subject_matter t1 WHERE t1.contract_id = t.id ) outBoundAmount,
+		((
+		SELECT
+		IFNULL( sum( unit_price * delivered_quantity ), 0 )
+		FROM
+		contract_subject_matter t1
+		WHERE
+		t1.contract_id = t.id
+		) - IFNULL( t.billing_amout, 0 )) creditAmount
+		FROM
+		contract t
+		WHERE
+		(
+		IFNULL( t.billing_amout, 0 )&lt;(
+		SELECT
+		IFNULL( sum( unit_price * delivered_quantity ), 0 )
+		FROM
+		contract_subject_matter t1
+		WHERE
+		t1.contract_id = t.id
+		))=1
+		<if test="queryDTO.contractName !=null and queryDTO.contractName !=''">
+			and t.contract_name LIKE CONCAT('%', #{queryDTO.contractName}, '%')
+		</if>
+		<if test="queryDTO.partyA !=null and queryDTO.partyA !=''">
+			and t.party_a LIKE CONCAT('%', #{queryDTO.partyA}, '%')
+		</if>
+		<if test="queryDTO.productNames !=null and queryDTO.productNames !=''">
+			and (SELECT GROUP_CONCAT(DISTINCT t1.material_internal_name) from contract_subject_matter t1 WHERE t1.contract_id = t.id) LIKE CONCAT('%', #{queryDTO.productNames}, '%')
+		</if>
+		<choose>
+			<when test="queryDTO.sortFiled !=null and queryDTO.sortFiled !='' and queryDTO.sortFiled == 'sign_date'">
+				order by ${queryDTO.sortFiled}
+			</when>
+			<when test="queryDTO.sortFiled !=null and queryDTO.sortFiled !='' and queryDTO.sortFiled == 'creditAmount'">
+				order by ((
+				SELECT
+				IFNULL( sum( unit_price * delivered_quantity ), 0 )
+				FROM
+				contract_subject_matter t1
+				WHERE
+				t1.contract_id = t.id
+				) - IFNULL( t.billing_amout, 0 ))
+			</when>
+			<otherwise>
+				order by t.create_time
+			</otherwise>
+		</choose>
+		<choose>
+			<when test="queryDTO.sortMethod !=null and queryDTO.sortMethod !=''">
+				${queryDTO.sortMethod}
+			</when>
+			<otherwise>
+				desc
+			</otherwise>
+		</choose>
+	</select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.1