CREATE OR REPLACE PROCEDURE Get_Mall_Customer_Balance(Xv_Ret_Status OUT VARCHAR2
,Xv_Ret_Message OUT VARCHAR2
,Xn_Cust_Balance OUT NUMBER
,Pn_Org_Id IN NUMBER
,Pn_Cust_Acct_Id IN NUMBER
,Pn_Bussiness_Flag IN NUMBER) IS
Lv_Proc_Name CONSTANT VARCHAR2(50) := 'Refund_Validate_From_Mall';
Lv_Webapi_Url CONSTANT VARCHAR2(240) := 'http://xxx.xxx.xx.x:7001/ErpWsApp/jersey/ErpWsAppService/ErpGetCustomerBalance';
Lv_Para_Content VARCHAR2(1000);
Lraw_Para_Content RAW(32767);
Req Utl_Http.Req;
Resp Utl_Http.Resp;
Lv_Replyline VARCHAR2(4000);
Lv_Respond VARCHAR2(32767);
Lj_Respond Json;
Lv_Count VARCHAR2(30);
Lv_Status VARCHAR2(30);
Lv_Msg VARCHAR2(30);
Array_Data Json_List;
Jsonobj Json;
Lv_Meaning VARCHAR2(30);
Lv_Ebscustid VARCHAR2(30);
Lv_Lineamount VARCHAR2(30);
BEGIN
Xv_Ret_Status := Fnd_Api.g_Ret_Sts_Success;
Xv_Ret_Message := NULL;
Lv_Para_Content := '{"OU_ID":"' || Pn_Org_Id || '","EBS_CUST_ID":"' || Pn_Cust_Acct_Id ||
'","BUSINESS_FLAG":"' || Pn_Bussiness_Flag || '"}';
Utl_Http.Set_Transfer_Timeout(300);
Req := Utl_Http.Begin_Request(Lv_Webapi_Url
,'POST'
,Utl_Http.Http_Version_1_1);
Utl_Http.Set_Persistent_Conn_Support(Req, TRUE);
Utl_Http.Set_Header(Req, 'Content-Type', 'application/json;charset=UTF-8');
Utl_Http.Set_Header(Req, 'Content-Length', Length(Lv_Para_Content));
Utl_Http.Write_Text(Req, Lv_Para_Content);
Resp := Utl_Http.Get_Response(Req);
IF (Resp.Status_Code = Utl_Http.Http_Ok) THEN
BEGIN
LOOP
Utl_Http.Read_Line(Resp, Lv_Replyline, TRUE);
Lv_Respond := Lv_Respond || Lv_Replyline;
END LOOP;
Utl_Http.End_Response(Resp);
EXCEPTION
WHEN Utl_Http.End_Of_Body THEN
Utl_Http.End_Response(Resp);
END;
ELSE
Xv_Ret_Status := Fnd_Api.g_Ret_Sts_Error;
Xv_Ret_Message := '接口调用异常' || SQLERRM;
END IF;
Lj_Respond := Json(Lv_Respond);
Lv_Count := Json_Ext.Get_String(Lj_Respond, 'count');
Lv_Status := Json_Ext.Get_String(Lj_Respond, 'status');
Lv_Msg := Json_Ext.Get_String(Lj_Respond, 'msg');
Array_Data := Json_List();
Array_Data := Json_Ext.Get_Json_List(Lj_Respond, 'data');
FOR i IN 1 .. Array_Data.Count LOOP
Jsonobj := Json(Array_Data.Get(i));
Lv_Meaning := Json_Ext.Get_String(Jsonobj, 'Meaning');
Lv_Ebscustid := Json_Ext.Get_String(Jsonobj, 'EbsCustId');
Lv_Lineamount := Json_Ext.Get_String(Jsonobj, 'LineAmount');
END LOOP;
Xn_Cust_Balance := To_Number(Lv_Lineamount);
EXCEPTION
WHEN OTHERS THEN
Xv_Ret_Status := Fnd_Api.g_Ret_Sts_Error;
Xv_Ret_Message := Lv_Proc_Name || '时发生异常:' || SQLERRM;
Xn_Cust_Balance := 0;
END;