【Java开源代码栏目提醒】:本文主要为网学会员提供TicketBookResultAction.java,希望对需要TicketBookResultAction.java网友有所帮助,学习一下!
package atbs.view;
import java.util.*;
import javax.naming.Context;
import javax.naming.NamingException;
import atbs.entity.*;
import atbs.session.*;
public class TicketBookResultAction {
private List<Ticket> bookTicketList;
private int bookCount;
private int allValue;
private String payError;
private long bankAccountId;
private String bankAccountPassword;
private Context ctx;
private TicketSessionRemote ticketSession;
private BankAccountSessionRemote bankAccountSession;
private UserLogSessionRemote userLogSession;
public TicketBookResultAction(){
try {
ctx = RemoteContext.getContextInstance();
} catch (NamingException ex) {
ex.printStackTrace();
}
try {
ticketSession = (TicketSessionRemote) ctx.lookup("atbs/TicketSession/remote");
bankAccountSession = (BankAccountSessionRemote) ctx.lookup("atbs/BankAccountSession/remote");
userLogSession = (UserLogSessionRemote)ctx.lookup("atbs/UserLogSession/remote");
SysUser user = (SysUser)ManageContext.getSessionScopeBean("user");
this.bookTicketList = ticketSession.getTicketByUserName(user.getUserName(),Ticket.Ticket_STATUS_BOOKING);
} catch (NamingException ex1) {
ex1.printStackTrace();
}
this.bookCount = this.bookTicketList.size();
this.allValue = 0;
for(Ticket ticket:bookTicketList){
this.allValue += ticket.getValue();
}
}
/**
* this method don't transaction
* @return
*/
public String payManyTicketByBankAccount(){
//first:pay by account
SysUser user = (SysUser)ManageContext.getSessionScopeBean("user");
// check the user
if(user==null||(user.getRole().getId()!=4&&user.getRole().getId()!=5)||this.allValue==0){
return null;
}
if(bankAccountSession.payManyTicket(user.getUserName(), bankAccountId,bankAccountPassword, allValue)){
if(ticketSession.payManyTicketByAccount(bookTicketList)){
this.payError = "You pay these ticket success,The information of tickets have send to you email";
Map<String,String> map = new HashMap<String,String>();
map.put("address", user.getEmail());
map.put("subject", "TicketEasy:You Pay tickets Success");
StringBuffer content = new StringBuffer();
content.append("Welcome to TicketEasy,Access TicketEasy ,you can expediently get ticket you want.\r\n");
content.append("You :Ticketsr\r\n");
for(Ticket ticket:bookTicketList){
content.append("id:");
content.append(ticket.getId());
content.append(",value:");
content.append(ticket.getValue());
content.append(",airplane:");
content.append(ticket.getAirplane().getId());
content.append(",fly Time");
content.append(ticket.getAirplane().getStartTime().toString());
content.append("\r\n");
}
content.append("You can get the ticket from the sale clerk,congratulate you will have a good time...\r\n");
content.append("------------------------------------------TicketEasy");
map.put("content", content.toString());
RemoteContext.sendEmail(map);
UserLog userLog = new UserLog();
userLog.setTitle(UserLog.PAY_TICKET_BY_ACCOUNT);
userLog.setCustomer(user);
userLog.setContent(content.toString());
this.userLogSession.addUserLog(userLog);
}else{
this.payError = "GET Ticket Failed,Please contact administrator...";
}
}else{
this.payError = "Account&Password Error or There are not so much momey in you bank Account";
}
return null;
}
public List<Ticket> getBookTicketList() {
return bookTicketList;
}
public void setBookTicketList(List<Ticket> bookTicketList) {
this.bookTicketL