create or replace procedure countchargenoproxy(v_merchantid in varchar2,--商家號
v_payclassid in number,--支付型別
v_amount in number,--交易金額
v_bankchar in number,--bank手續費
v_dinpaycharge out number,--dinpay手續費
v_oneproxycharge out number,--一級手續費
v_twoproxycharge out number,--二級手續費
v_threeproxycharge out number,-- **手續費
v_riskcharge out number, --風險保證金
v_oneproxyid out varchar2,
v_twoproxyid out varchar2,
v_threeproxyid out varchar2)
as begin
declare
v_charge_date date;
v_chargetype varchar2(2);
v_count number(1,0); --是否計算分潤(不等於0時計算)
v_proxy2_return_rate number(6,4):=0;
v_proxy3_return_rate number(6,4):=0;
begin
-- 1.根據支付型別與商家號查詢商家業務配置引數(手續費計算方式,費率,風險保證金收取方式,風險保證金值 )
--並計算dinpay總手續費 及 風險保證金
select charge_date,
case
when charge_type='1' then charge_value
when charge_type='0' or charge_type='2' then charge_value * v_amount
when charge_type='3' then (charge_value * v_amount)-v_bankchar
end,
case
when deposit_type='0' then 0
when charge_type='0' or charge_type='2' or charge_type='3' then v_amount*(1-charge_value)*deposit_value
when charge_type='1' then (v_amount-charge_value)*deposit_value
end,
charge_type
into v_charge_date,v_dinpaycharge,v_riskcharge,v_chargetype
from t_merchant_payclass_config where merchant_id=v_merchantid and payclass_id=v_payclassid;
--查詢****商id
select proxy_id into v_threeproxyid from t_merchant where id=v_merchantid;
--查詢是否需要計算分潤
select count(*) into v_count from t_proxy_payclass_config where proxy_id=v_threeproxyid and payclass_id=v_payclassid;
if sysdate>=v_charge_date and v_count>0 then --已過免手續費期
begin
if v_chargetype = '2' then --2表示固定費率 **商收費方式根據商家收費方式來定
begin
-- 計算**手續費 總手續費-總交易額*3級固定費率
select v_dinpaycharge-tp.return_fixed*v_amount,t.parent_id
into v_threeproxycharge,v_twoproxyid
from t_proxy_payclass_config tp,t_proxy t
where tp.proxy_id=t.id and tp.proxy_id=v_threeproxyid and tp.payclass_id=v_payclassid;
-- 計算二級手續費 總手續費-總交易額*2級固定費率-3級**手續費;
select v_dinpaycharge-tp.return_fixed*v_amount-v_threeproxycharge,t.parent_id
into v_twoproxycharge,v_oneproxyid
from t_proxy_payclass_config tp,t_proxy t where t.id=tp.proxy_id and tp.proxy_id=v_twoproxyid and tp.payclass_id=v_payclassid;
-- 計算一級手續費 1級**手續費=總手續費-總交易額*1級固定費率 - 2級**手續費-3級**手續費;
select v_dinpaycharge-tp.return_fixed*v_amount-v_threeproxycharge-v_twoproxycharge
into v_oneproxycharge
from t_proxy_payclass_config tp,t_proxy t where t.id=tp.proxy_id and tp.proxy_id=v_oneproxyid and tp.payclass_id=v_payclassid;
end;
elsif v_chargetype='0' or v_chargetype='1' or v_chargetype='3' then -- 當商家為返點或者 按筆收時 **商按返點演算法來計算手續費
begin
-- 計算**手續費 3級**手續費=總手續費*3級返利點;
select v_dinpaycharge*tp.return_rate,tp.return_rate,t.parent_id
into v_threeproxycharge,v_proxy3_return_rate,v_twoproxyid
from t_proxy_payclass_config tp,t_proxy t
where tp.proxy_id=t.id and tp.proxy_id=v_threeproxyid and tp.payclass_id=v_payclassid;
-- 計算二級手續費 2級**手續費=總手續費*(2級返利點-3級返利點)
select v_dinpaycharge*(tp.return_rate-v_proxy3_return_rate),tp.return_rate,t.parent_id
into v_twoproxycharge,v_proxy2_return_rate,v_oneproxyid
from t_proxy_payclass_config tp,t_proxy t where t.id=tp.proxy_id and tp.proxy_id=v_twoproxyid and tp.payclass_id=v_payclassid;
-- 計算一級手續費 1級**手續費=總手續費*(1級返利點-2級返利點)
select v_dinpaycharge*(tp.return_rate-v_proxy2_return_rate)
into v_oneproxycharge
from t_proxy_payclass_config tp,t_proxy t where t.id=tp.proxy_id and tp.proxy_id=v_oneproxyid and tp.payclass_id=v_payclassid;
end;
end if;
end;
elsif sysdate>=v_charge_date and v_count<=0 then --**商不參與分潤
begin
select parent_id into v_twoproxyid from t_proxy where id=v_threeproxyid and proxy_level=3;
select parent_id into v_oneproxyid from t_proxy where id=v_twoproxyid and proxy_level=2;
v_oneproxycharge := 0;
v_twoproxycharge := 0;
v_threeproxycharge := 0;
end;
else
begin
select parent_id into v_twoproxyid from t_proxy where id=v_threeproxyid and proxy_level=3;
select parent_id into v_oneproxyid from t_proxy where id=v_twoproxyid and proxy_level=2;
v_dinpaycharge := 0;
v_oneproxycharge := 0;
v_twoproxycharge := 0;
v_threeproxycharge := 0;
end;
end if;
end;
end;
mybatis 呼叫儲存過程
引數形式 create procedure sptest.adder in addend1 integer,in addend2 integer,out thesum integer begin atomic set thesum addend1 addend2 end go parameterma...
mybatis 呼叫儲存過程
至於為什麼用map作為引數,是因為別人寫的儲存過程 可能沒有返回出參,然後就會出現下面的問題。但是別人幾百行上千行的儲存過程,我是絕對不敢去動的。然後就只能用可以為null的物件去接收返回值了,所以就從實體變為了map。void callpwfsubmit mapmap 獲取儲存過程所需要的引數 p...
mybatis 呼叫儲存過程
mybatis中的statementtype詳解 呼叫儲存過程總共有兩總語句 call 和exec 兩種語句複製一下 示例更改即可使用 call 語句 call sp sanwjimport auto exec 語句 exec sp tmailauto 4651 1.使用 update 標籤 2.i...