2025-12-17 03:15:10 +00:00
<?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.sip.mapper.OmsReceivableBillMapper" >
<resultMap type= "com.ruoyi.sip.domain.OmsReceivableBill" id= "OmsReceivableBillResult" >
<result property= "id" column= "id" />
<result property= "receivableBillCode" column= "receivable_bill_code" />
<result property= "lastReceiptPlanId" column= "last_receipt_plan_id" />
<result property= "lastInvoicePlanId" column= "last_invoice_plan_id" />
<result property= "partnerCode" column= "partner_code" />
<result property= "partnerName" column= "partner_name" />
<result property= "orderCode" column= "order_code" />
<result property= "inventoryCode" column= "inventory_code" />
<result property= "productType" column= "product_type" />
<result property= "totalPriceWithTax" column= "total_price_with_tax" />
<result property= "totalPriceWithoutTax" column= "total_price_without_tax" />
<result property= "taxRate" column= "tax_rate" />
<result property= "taxAmount" column= "tax_amount" />
<result property= "receivedAmount" column= "received_amount" />
<result property= "unreceivedAmount" column= "unreceived_amount" />
<result property= "invoicedAmount" column= "invoiced_amount" />
<result property= "uninvoicedAmount" column= "uninvoiced_amount" />
<result property= "createBy" column= "create_by" />
<result property= "createTime" column= "create_time" />
<result property= "updateBy" column= "update_by" />
<result property= "updateTime" column= "update_time" />
<result property= "remark" column= "remark" />
</resultMap>
<sql id= "selectOmsReceivableBillVo" >
select t1.id, t1.receivable_bill_code, t1.last_receipt_plan_id, t1.last_invoice_plan_id, t1.partner_code, t1.partner_name, t1.order_code, t1.inventory_code, t1.product_type,
t1.total_price_with_tax, t1.total_price_without_tax, t1.tax_rate, t1.tax_amount, t1.received_amount, t1.unreceived_amount,
t1.invoiced_amount, t1.uninvoiced_amount, t1.create_by, t1.create_time, t1.update_by, t1.update_time, t1.remark, t1.del_flag
,t3.project_name, t3.project_code
2025-12-22 07:59:31 +00:00
,t4.plan_amount,t4.plan_receipt_date,
t5.plan_amount as plan_invoice_amount, t5.plan_invoice_date
2025-12-17 03:15:10 +00:00
from oms_receivable_bill t1
left join project_order_info t2 on t1.order_code=t2.order_code
left join project_info t3 on t2.project_id=t3.id
left join oms_receivable_receipt_plan t4 on t1.last_receipt_plan_id=t4.id
2025-12-22 07:59:31 +00:00
left join oms_receivable_invoice_plan t5 on t1.last_invoice_plan_id=t5.id
2025-12-17 03:15:10 +00:00
</sql>
<select id= "selectOmsReceivableBillById" parameterType= "Long" resultMap= "OmsReceivableBillResult" >
<include refid= "selectOmsReceivableBillVo" />
where t1.id = #{id}
</select>
<select id= "selectOmsReceivableBillList" parameterType= "com.ruoyi.sip.domain.OmsReceivableBill" resultMap= "OmsReceivableBillResult" >
<include refid= "selectOmsReceivableBillVo" />
<where >
<if test= "receivableBillCode != null and receivableBillCode != ''" > and t1.receivable_bill_code like concat('%', #{receivableBillCode}, '%')</if>
<if test= "idList != null and idList.size>0" > and t1.id in
<foreach item= "item" collection= "idList" separator= "," open= "(" close= ")" >
#{item}
</foreach>
</if>
<if test= "partnerCode != null and partnerCode != ''" > and t1.partner_code = #{partnerCode}</if>
<if test= "partnerName != null and partnerName != ''" > and t1.partner_name like concat('%', #{partnerName}, '%')</if>
<if test= "orderCode != null and orderCode != ''" > and t1.order_code = #{orderCode}</if>
<if test= "inventoryCode != null and inventoryCode != ''" > and t1.inventory_code = #{inventoryCode}</if>
<if test= "productType != null and productType != ''" > and t1.product_type = #{productType}</if>
<if test= "createBy != null and createBy != ''" > and t1.create_by = #{createBy}</if>
2025-12-29 07:31:27 +00:00
<if test= "projectName != null and projectName != ''" > and t3.project_name like concat('%', #{projectName}, '%')</if>
<if test= "(params.beginPlanReceiptDate != null and params.beginPlanReceiptDate != '') or (params.endPlanReceiptDate != null and params.endPlanReceiptDate!='')" >
<choose >
<when test= "(params.beginPlanReceiptDate != null and params.beginPlanReceiptDate != '') and (params.endPlanReceiptDate != null and params.endPlanReceiptDate!='')" >
and t4.plan_receipt_date between #{params.beginPlanReceiptDate} and #{params.endPlanReceiptDate}
</when>
<when test= "(params.beginPlanReceiptDate != null and params.beginPlanReceiptDate != '')" >
and t4.plan_receipt_date <![CDATA[ >= ]]> #{params.beginPlanReceiptDate}
</when>
<when test= "(params.endPlanReceiptDate != null and params.endPlanReceiptDate!='')" >
and t4.plan_receipt_date <![CDATA[ <= ]]> #{params.endPlanReceiptDate}
</when>
</choose>
</if>
2025-12-17 03:15:10 +00:00
and t1.del_flag = '0'
</where>
</select>
<insert id= "insertOmsReceivableBill" parameterType= "com.ruoyi.sip.domain.OmsReceivableBill" useGeneratedKeys= "true" keyProperty= "id" >
insert into oms_receivable_bill
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "receivableBillCode != null and receivableBillCode != ''" > receivable_bill_code,</if>
<if test= "lastReceiptPlanId != null" > last_receipt_plan_id,</if>
<if test= "lastInvoicePlanId != null" > last_invoice_plan_id,</if>
<if test= "partnerCode != null and partnerCode != ''" > partner_code,</if>
<if test= "partnerName != null and partnerName != ''" > partner_name,</if>
<if test= "orderCode != null and orderCode != ''" > order_code,</if>
<if test= "inventoryCode != null and inventoryCode != ''" > inventory_code,</if>
<if test= "productType != null and productType != ''" > product_type,</if>
<if test= "totalPriceWithTax != null" > total_price_with_tax,</if>
<if test= "totalPriceWithoutTax != null" > total_price_without_tax,</if>
<if test= "taxRate != null" > tax_rate,</if>
<if test= "taxAmount != null" > tax_amount,</if>
<if test= "receivedAmount != null" > received_amount,</if>
<if test= "unreceivedAmount != null" > unreceived_amount,</if>
<if test= "invoicedAmount != null" > invoiced_amount,</if>
<if test= "uninvoicedAmount != null" > uninvoiced_amount,</if>
<if test= "createBy != null and createBy != ''" > create_by,</if>
<if test= "createTime != null" > create_time,</if>
<if test= "updateBy != null and updateBy != ''" > update_by,</if>
<if test= "updateTime != null" > update_time,</if>
<if test= "remark != null and remark != ''" > remark,</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "receivableBillCode != null and receivableBillCode != ''" > #{receivableBillCode},</if>
<if test= "lastReceiptPlanId != null" > #{lastReceiptPlanId},</if>
<if test= "lastInvoicePlanId != null" > #{lastInvoicePlanId},</if>
<if test= "partnerCode != null and partnerCode != ''" > #{partnerCode},</if>
<if test= "partnerName != null and partnerName != ''" > #{partnerName},</if>
<if test= "orderCode != null and orderCode != ''" > #{orderCode},</if>
<if test= "inventoryCode != null and inventoryCode != ''" > #{inventoryCode},</if>
<if test= "productType != null and productType != ''" > #{productType},</if>
<if test= "totalPriceWithTax != null" > #{totalPriceWithTax},</if>
<if test= "totalPriceWithoutTax != null" > #{totalPriceWithoutTax},</if>
<if test= "taxRate != null" > #{taxRate},</if>
<if test= "taxAmount != null" > #{taxAmount},</if>
<if test= "receivedAmount != null" > #{receivedAmount},</if>
<if test= "unreceivedAmount != null" > #{unreceivedAmount},</if>
<if test= "invoicedAmount != null" > #{invoicedAmount},</if>
<if test= "uninvoicedAmount != null" > #{uninvoicedAmount},</if>
<if test= "createBy != null and createBy != ''" > #{createBy},</if>
<if test= "createTime != null" > #{createTime},</if>
<if test= "updateBy != null and updateBy != ''" > #{updateBy},</if>
<if test= "updateTime != null" > #{updateTime},</if>
<if test= "remark != null and remark != ''" > #{remark},</if>
</trim>
</insert>
<update id= "updateOmsReceivableBill" parameterType= "com.ruoyi.sip.domain.OmsReceivableBill" >
update oms_receivable_bill
<trim prefix= "SET" suffixOverrides= "," >
<if test= "receivableBillCode != null and receivableBillCode != ''" > receivable_bill_code = #{receivableBillCode},</if>
<if test= "lastReceiptPlanId != null" > last_receipt_plan_id = #{lastReceiptPlanId},</if>
<if test= "lastInvoicePlanId != null" > last_invoice_plan_id = #{lastInvoicePlanId},</if>
<if test= "partnerCode != null and partnerCode != ''" > partner_code = #{partnerCode},</if>
<if test= "partnerName != null and partnerName != ''" > partner_name = #{partnerName},</if>
<if test= "orderCode != null and orderCode != ''" > order_code = #{orderCode},</if>
<if test= "inventoryCode != null and inventoryCode != ''" > inventory_code = #{inventoryCode},</if>
<if test= "productType != null and productType != ''" > product_type = #{productType},</if>
<if test= "totalPriceWithTax != null" > total_price_with_tax = #{totalPriceWithTax},</if>
<if test= "totalPriceWithoutTax != null" > total_price_without_tax = #{totalPriceWithoutTax},</if>
<if test= "taxRate != null" > tax_rate = #{taxRate},</if>
<if test= "taxAmount != null" > tax_amount = #{taxAmount},</if>
<if test= "receivedAmount != null" > received_amount = #{receivedAmount},</if>
<if test= "unreceivedAmount != null" > unreceived_amount = #{unreceivedAmount},</if>
<if test= "invoicedAmount != null" > invoiced_amount = #{invoicedAmount},</if>
<if test= "uninvoicedAmount != null" > uninvoiced_amount = #{uninvoicedAmount},</if>
<if test= "updateBy != null and updateBy != ''" > update_by = #{updateBy},</if>
<if test= "updateTime != null" > update_time = #{updateTime},</if>
<if test= "remark != null and remark != ''" > remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id= "deleteOmsReceivableBillById" parameterType= "Long" >
update oms_receivable_bill set del_flag = '2' where id = #{id}
</delete>
<delete id= "deleteOmsReceivableBillByIds" parameterType= "String" >
update oms_receivable_bill set del_flag = '2' where id in
<foreach item= "id" collection= "ids.split(',')" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</delete>
<select id= "selectMaxCodeByPrefix" parameterType= "String" resultType= "java.lang.Integer" >
SELECT COALESCE(MAX(CAST(SUBSTRING(receivable_bill_code, LENGTH(#{codePrefix}) + 1) AS UNSIGNED)), 0)
FROM oms_receivable_bill
WHERE receivable_bill_code LIKE CONCAT(#{codePrefix}, '%')
AND receivable_bill_code REGEXP CONCAT('^', #{codePrefix}, '[0-9]+$')
</select>
<update id= "updateBatchReceivableBillInvoiceInfo" parameterType= "java.util.List" >
<foreach collection= "list" item= "item" separator= ";" >
UPDATE oms_receivable_bill
<set >
<if test= "item.invoicedAmount != null" > invoiced_amount = #{item.invoicedAmount},</if>
<if test= "item.uninvoicedAmount != null" > uninvoiced_amount = #{item.uninvoicedAmount},</if>
<if test= "item.lastInvoicePlanId != null" > last_invoice_plan_id = #{item.lastInvoicePlanId},</if>
<if test= "item.updateTime != null" > update_time = #{item.updateTime},</if>
<if test= "item.updateBy != null and item.updateBy != ''" > update_by = #{item.updateBy},</if>
</set>
WHERE id = #{item.id}
</foreach>
</update>
<update id= "updateBatchReceivableBillReceiptInfo" >
<foreach collection= "list" item= "item" separator= ";" >
UPDATE oms_receivable_bill
SET
last_receipt_plan_id = #{item.lastReceiptPlanId},
received_amount = #{item.receivedAmount},
unreceived_amount = #{item.unreceivedAmount},
update_time = NOW(),
update_by = #{item.updateBy}
WHERE id = #{item.id}
</foreach>
</update>
</mapper>