| | |
| | | |
| | | <select id="selectSalesLedgerList" resultType="com.ruoyi.sales.pojo.SalesLedger"> |
| | | SELECT |
| | | T1.id, |
| | | T1.sales_contract_no, |
| | | T1.customer_contract_no, |
| | | T1.project_name, |
| | | T1.entry_date, |
| | | T1.salesman, |
| | | T1.customer_id, |
| | | T1.customer_name, |
| | | T1.entry_person, |
| | | T1.remarks, |
| | | T1.attachment_materials, |
| | | T1.tenant_id, |
| | | T1.contract_amount, |
| | | T1.execution_date, |
| | | T2.nick_name AS entry_person_name, |
| | | T1.payment_method |
| | | FROM |
| | | sales_ledger T1 |
| | | LEFT JOIN sys_user T2 ON T1.entry_person = T2.user_id |
| | | <where> |
| | | <if test="salesLedgerDto.customerName != null and salesLedgerDto.customerName != '' "> |
| | | T1.customer_name LIKE CONCAT('%',#{salesLedgerDto.customerName},'%') |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | <select id="selectSalesLedgerListPage" resultType="com.ruoyi.sales.pojo.SalesLedger"> |
| | | SELECT |
| | | T1.id, |
| | | T1.sales_contract_no, |
| | | T1.customer_contract_no, |
| | |
| | | T1.attachment_materials, |
| | | T1.tenant_id, |
| | | T1.contract_amount, |
| | | T1.contract_amount as noInvoiceAmountTotal, |
| | | T1.execution_date, |
| | | T2.nick_name AS entry_person_name, |
| | | T1.payment_method |
| | | T1.payment_method, |
| | | DATEDIFF(T1.delivery_date, CURDATE()) AS delivery_days_diff |
| | | FROM |
| | | sales_ledger T1 |
| | | LEFT JOIN sys_user T2 ON T1.entry_person = T2.user_id |
| | | <where> |
| | | <if test="salesLedgerDto.customerName != null and salesLedgerDto.customerName != '' "> |
| | | T1.customer_name LIKE CONCAT('%',#{salesLedgerDto.customerName},'%') |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | <select id="selectSalesLedgerListPage" resultType="com.ruoyi.sales.pojo.SalesLedger"> |
| | | SELECT T1.id, |
| | | T1.sales_contract_no, |
| | | T1.customer_contract_no, |
| | | T1.project_name, |
| | | T1.entry_date, |
| | | T1.salesman, |
| | | T1.customer_id, |
| | | T1.customer_name, |
| | | T1.entry_person, |
| | | T1.remarks, |
| | | T1.attachment_materials, |
| | | T1.tenant_id, |
| | | T1.contract_amount, |
| | | T1.contract_amount as noInvoiceAmountTotal, |
| | | T1.execution_date, |
| | | T2.nick_name AS entry_person_name, |
| | | T1.payment_method, |
| | | T1.delivery_date, |
| | | DATEDIFF(T1.delivery_date, CURDATE()) AS delivery_days_diff, |
| | | CASE |
| | | WHEN shipping_status_counts.total_count = 0 THEN false |
| | | WHEN shipping_status_counts.unshipped_count = 0 THEN true |
| | | ELSE false |
| | | END AS is_fh |
| | | FROM sales_ledger T1 |
| | | LEFT JOIN sys_user T2 ON T1.entry_person = T2.user_id |
| | | LEFT JOIN ( |
| | | SELECT sales_ledger_id, |
| | | COUNT(*) as total_count, |
| | | SUM(CASE WHEN status != '已发货' THEN 1 ELSE 0 END) as unshipped_count |
| | | FROM shipping_info |
| | | GROUP BY sales_ledger_id |
| | | ) shipping_status_counts ON T1.id = shipping_status_counts.sales_ledger_id |
| | | <where> |
| | | <if test="salesLedgerDto.customerName != null and salesLedgerDto.customerName != '' "> |
| | | AND T1.customer_name LIKE CONCAT('%',#{salesLedgerDto.customerName},'%') |
| | |
| | | </where> |
| | | order by T1.entry_date desc |
| | | </select> |
| | | |
| | | <select id="selectIncomeStats" resultType="com.ruoyi.home.dto.IncomeExpenseAnalysisDto"> |
| | | SELECT DATE_FORMAT(entry_date, #{dateFormat}) as dateStr, IFNULL(SUM(contract_amount), 0) as amount |
| | | FROM sales_ledger |
| | | WHERE entry_date BETWEEN #{startDate} AND #{endDate} |
| | | GROUP BY dateStr |
| | | </select> |
| | | |
| | | <select id="selectCustomerSalesComposition" resultType="com.ruoyi.dto.MapDto"> |
| | | SELECT customer_name as name, CAST(IFNULL(SUM(contract_amount), 0) AS CHAR) as value |
| | | FROM sales_ledger |
| | | GROUP BY customer_name |
| | | </select> |
| | | </mapper> |