<?xml version="1.0" encoding="UTF-8"?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<mapper namespace="com.ruoyi.account.mapper.sales.AccountInvoiceApplicationMapper">
|
|
<select id="listPageAccountInvoiceApplication"
|
resultType="com.ruoyi.account.bean.vo.sales.AccountInvoiceApplicationVo">
|
select * from (select aia.*,
|
c.customer_name,
|
GROUP_CONCAT(sour.outbound_batches SEPARATOR ',') AS outboundBatches
|
from account_invoice_application aia
|
left join customer c on aia.customer_id = c.id
|
left join stock_out_record sour on FIND_IN_SET(sour.id, aia.stock_out_record_ids) > 0
|
GROUP BY aia.id)A
|
<where>
|
<if test="req.customerId != null">
|
AND A.customer_id = #{req.customerId}
|
</if>
|
<if test="req.invoiceApplicationNo != null and req.invoiceApplicationNo != ''">
|
AND A.invoice_application_no LIKE CONCAT('%',#{req.invoiceApplicationNo},'%')
|
</if>
|
<if test="req.status != null">
|
AND A.status = #{req.status}
|
</if>
|
<if test="req.startDate != null and req.endDate != null">
|
AND A.apply_date BETWEEN #{req.startDate} AND #{req.endDate}
|
</if>
|
</where>
|
</select>
|
<select id="getOutboundBatchesByCustomer"
|
resultType="com.ruoyi.account.bean.vo.sales.SalesOutboundVo">
|
SELECT
|
sor.id,
|
sor.outbound_batches,
|
sl.customer_name,
|
sor.create_time as shippingDate,
|
p.product_name,
|
pm.model as specification_model,
|
slp.tax_rate,
|
sor.stock_out_num * slp.tax_inclusive_unit_price as outboundAmount,
|
s.shipping_no,
|
sl.sales_contract_no
|
FROM stock_out_record sor
|
left join shipping_info s on sor.record_id = s.id
|
LEFT JOIN sales_ledger sl ON s.sales_ledger_id = sl.id
|
LEFT JOIN sales_ledger_product slp ON s.sales_ledger_product_id = slp.id and slp.type = 1
|
left join product_model pm on slp.product_model_id = pm.id
|
left join product p on pm.product_id = p.id
|
WHERE sor.record_type='13' and sor.approval_status=1
|
and sl.customer_id=#{customerId}
|
|
and sor.id NOT IN (
|
SELECT DISTINCT SUBSTRING_INDEX(SUBSTRING_INDEX(a.stock_out_record_ids, ',', n.n), ',', -1)
|
FROM account_invoice_application a
|
CROSS JOIN (
|
SELECT 1 n UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
|
SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6
|
) n
|
WHERE n.n <= CHAR_LENGTH(a.stock_out_record_ids) - CHAR_LENGTH(REPLACE(a.stock_out_record_ids, ',', '')) + 1
|
and a.status!=2
|
)
|
|
order by sor.id DESC
|
</select>
|
<select id="existsByStockOutRecordId" resultType="java.lang.Boolean">
|
SELECT COUNT(*) > 0
|
FROM account_invoice_application
|
WHERE
|
<foreach collection="stockOutRecordIds" item="id" open="(" separator=" OR " close=")">
|
FIND_IN_SET(#{id}, stock_out_record_ids)
|
</foreach>
|
</select>
|
|
</mapper>
|