145 lines
6.2 KiB
XML
145 lines
6.2 KiB
XML
<?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.bms.price.mapper.PrcPayBillMapper">
|
|
|
|
<resultMap type="PrcPayBill" id="PrcPayBillResult">
|
|
<id property="payBillId" column="pay_bill_id" />
|
|
<result property="billId" column="bill_id" />
|
|
<result property="currency" column="currency" />
|
|
<result property="productAmount" column="product_amount" />
|
|
<result property="redlineAmount" column="redline_amount" />
|
|
<result property="costAmount" column="cost_amount" />
|
|
<result property="payTotal" column="pay_total" />
|
|
<result property="belongSaler" column="belong_saler" />
|
|
<result property="belongSalerCode" column="belong_saler_code" />
|
|
<result property="settlementMan" column="settlement_man" />
|
|
<result property="settlementManCode" column="settlement_man_code" />
|
|
<result property="createBy" column="create_by" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="updateBy" column="update_by" />
|
|
<result property="updateTime" column="update_time" />
|
|
</resultMap>
|
|
|
|
<sql id="selectPrcPayBillVo">
|
|
select pay_bill_id, bill_id, currency, product_amount, redline_amount,
|
|
cost_amount, pay_total,
|
|
belong_saler, belong_saler_code, settlement_man, settlement_man_code,
|
|
create_by, create_time, update_by, update_time
|
|
from prc_pay_bill
|
|
</sql>
|
|
|
|
<select id="selectByBillId" parameterType="Long" resultMap="PrcPayBillResult">
|
|
<include refid="selectPrcPayBillVo"/>
|
|
where bill_id = #{billId}
|
|
</select>
|
|
|
|
<select id="selectByPayBillId" parameterType="String" resultMap="PrcPayBillResult">
|
|
<include refid="selectPrcPayBillVo"/>
|
|
where pay_bill_id = #{payBillId}
|
|
</select>
|
|
|
|
<insert id="insertPrcPayBill" parameterType="PrcPayBill">
|
|
insert into prc_pay_bill (
|
|
pay_bill_id, bill_id, currency, product_amount, redline_amount,
|
|
cost_amount, pay_total,
|
|
belong_saler, belong_saler_code, settlement_man, settlement_man_code,
|
|
create_by, create_time
|
|
) values (
|
|
#{payBillId}, #{billId}, #{currency}, #{productAmount}, #{redlineAmount},
|
|
#{costAmount}, #{payTotal},
|
|
#{belongSaler}, #{belongSalerCode}, #{settlementMan}, #{settlementManCode},
|
|
#{createBy}, sysdate()
|
|
)
|
|
</insert>
|
|
|
|
<update id="updatePrcPayBill" parameterType="PrcPayBill">
|
|
update prc_pay_bill
|
|
set currency = #{currency},
|
|
product_amount = #{productAmount},
|
|
redline_amount = #{redlineAmount},
|
|
cost_amount = #{costAmount},
|
|
pay_total = #{payTotal},
|
|
belong_saler = #{belongSaler},
|
|
belong_saler_code = #{belongSalerCode},
|
|
settlement_man = #{settlementMan},
|
|
settlement_man_code = #{settlementManCode},
|
|
update_by = #{updateBy},
|
|
update_time = sysdate()
|
|
where bill_id = #{billId}
|
|
</update>
|
|
|
|
<insert id="upsertPrcPayBill" parameterType="PrcPayBill">
|
|
insert into prc_pay_bill (
|
|
pay_bill_id, bill_id, currency, product_amount, redline_amount,
|
|
cost_amount, pay_total,
|
|
belong_saler, belong_saler_code, settlement_man, settlement_man_code,
|
|
create_by, create_time
|
|
) values (
|
|
#{payBillId}, #{billId}, #{currency}, #{productAmount}, #{redlineAmount},
|
|
#{costAmount}, #{payTotal},
|
|
#{belongSaler}, #{belongSalerCode}, #{settlementMan}, #{settlementManCode},
|
|
#{createBy}, sysdate()
|
|
)
|
|
on duplicate key update
|
|
currency = values(currency),
|
|
product_amount = values(product_amount),
|
|
redline_amount = values(redline_amount),
|
|
cost_amount = values(cost_amount),
|
|
pay_total = values(pay_total),
|
|
belong_saler = values(belong_saler),
|
|
belong_saler_code = values(belong_saler_code),
|
|
settlement_man = values(settlement_man),
|
|
settlement_man_code = values(settlement_man_code),
|
|
update_by = values(update_by),
|
|
update_time = sysdate()
|
|
</insert>
|
|
|
|
<insert id="insertMissingPayBills">
|
|
insert into prc_pay_bill (
|
|
pay_bill_id, bill_id, currency, pay_total,
|
|
belong_saler, belong_saler_code, settlement_man, settlement_man_code,
|
|
create_by, create_time, update_by, update_time
|
|
)
|
|
select replace(uuid(), '-', ''), o.bill_id, ifnull(nullif(o.currency, ''), 'CNY'), 0,
|
|
o.belong_saler, o.belong_saler_code, o.settlement_man, o.settlement_man_code,
|
|
#{operator}, sysdate(), #{operator}, sysdate()
|
|
from prc_order_bill o
|
|
where o.bill_id in
|
|
<foreach collection="billIds" item="billId" open="(" separator="," close=")">#{billId}</foreach>
|
|
and not exists (
|
|
select 1 from prc_pay_bill b where b.bill_id = o.bill_id
|
|
)
|
|
</insert>
|
|
|
|
<update id="refreshPayTotal">
|
|
update prc_pay_bill b
|
|
left join (
|
|
select bill_id, ifnull(sum(amount), 0) as total
|
|
from prc_pay_bill_fee
|
|
where ifnull(is_deleted, '0') = '0'
|
|
and bill_id in
|
|
<foreach collection="billIds" item="billId" open="(" separator="," close=")">#{billId}</foreach>
|
|
group by bill_id
|
|
) s on s.bill_id = b.bill_id
|
|
set b.pay_total = ifnull(s.total, 0),
|
|
b.update_time = sysdate()
|
|
where b.bill_id in
|
|
<foreach collection="billIds" item="billId" open="(" separator="," close=")">#{billId}</foreach>
|
|
</update>
|
|
|
|
<update id="markCalcStatus">
|
|
update prc_pay_bill
|
|
set pay_calc_status = #{status},
|
|
pay_calc_msg = #{message},
|
|
update_by = #{operator},
|
|
update_time = sysdate()
|
|
where bill_id = #{billId}
|
|
</update>
|
|
|
|
<delete id="deleteByBillId" parameterType="String">
|
|
delete from prc_pay_bill where bill_id = #{billId}
|
|
</delete>
|
|
</mapper>
|