?? authorize.jsp
字號:
<%@page contentType="text/html; charset=GBK" %>
<%@page import="com.onewaveinc.portalman.webpro.*"%>
<%@page import="com.onewaveinc.portalman.webpro.entity.*"%>
<%@page import="java.util.Date"%>
<%!
public String checkSuite(OWAuthorizeResult result){
if("true".equalsIgnoreCase(result.getErrorCode())){
String message=result.getMessage();
if(message!=null && message.indexOf("8000,")!=-1){
return message.substring(5);
}
}
return null;
}
%>
<%
//取得Vnet網頁傳回的vnetloginname值
String vnetloginname = request.getParameter("vnetloginname");
if(vnetloginname==null){
out.println("<p align='center'><font color='#FF0000'>非法請求,請退出重試!</font></p>");
return;
}
//ICP在Vnet上的服務代碼
String serviceCode = "45454";
//ICP產品信息
String productInfo = "測試包月服務離線扣款";
//ICP產品價格
int price = 1000;
//用戶在ICP上的登陸名,將顯示在用戶詳單中,也可在此寫注釋
String icpLoginName = "該服務僅供測試";
OWAuthorizeRequest authRequest = new OWAuthorizeRequest();
//如果需要傳入icp側loginname,則為
OWAuthorizeRequest2 authRequest = new OWAuthorizeRequest2();
//0:由Vnet系統自動判斷1:指明用在ADSL和163帳號中做檢查2:指明用在現金帳號中做檢查3:指定促消卡中扣款4:指定在業務卡中扣款
authRequest.setPayAccountCheckMode(0);
//ICP在Vnet上的服務代碼
authRequest.setServiceCode(serviceCode);
//如果是代收費模式,設置產品價格,單位為厘
authRequest.setExpenditure(price);
//設置產品信息
authRequest.setProductInfo(productInfo);
//Vnet 客戶統一登錄名
authRequest.setVnetLoginName(vnetloginname);
//設置用戶在icp一側的帳號
authRequest.setIcpLoginName(icpLoginName);
OWAuthorizeResult result = WebProManager.getOWAuthentication().OWAuthorizeOffLine(authRequest);
if(!"true".equalsIgnoreCase(result.getErrorCode())){
//發現授權失敗,ICP需要做相應的處理
out.println("授權失敗!");
out.println("<BR>錯誤代碼為:" + result.getErrorCode());
out.println("<BR>錯誤信息為:" + result.getMessage());
return;
}
//檢查用戶是否為套餐用戶
String suitename = checkSuite(result);
if(suitename!=null){
//為套餐用戶,做相應的處理。
System.out.println("該用戶已訂購了套餐:"+ suitename);
}
//生成計費Entity
OWAccountingRequest acrequest = new OWAccountingRequest();
//“1” 代表包月 “0” 非包月
acrequest.setAccountingType(1);
//客戶ICP登錄名, String 類型, 最長64位
acrequest.setIcpLoginName(icpLoginName);
//產品信息, String 類型, 最長64位
acrequest.setProductInfo(productInfo);
//用戶包月開始時間
acrequest.setStartTime(new Date());
//用戶包月結束時間
acrequest.setEndTime(new Date());
//全局唯一的交易號。
acrequest.setTransactionId(result.getTransactionID());
//Vnet 客戶統一登錄名
acrequest.setVnetLoginName(vnetloginname);
try{
//調用收費接口
OWAccountingResult result2 = WebProManager.getOWAccounting().setAccountingInfo(acrequest);
if(!("true".equalsIgnoreCase(result2.getErrorCode()))){
out.println("扣費時發現錯誤:" + result2.getMessage());
return;
}
}catch(Exception e){
e.printStackTrace();
out.println("扣費時發現錯誤:" + e.toString());
return;
}
%>
<html><head><title></title></head><body>
離線收費記錄已保存。<BR>到互聯星空上可以查到本次消費的詳單。<BR>
<%
if(suitename!=null){
//為套餐用戶,做相應的處理。
out.println("該用戶已訂購了套餐:"+ suitename);
}
%>
</body></html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -