ssh Action

package com.bluecat.cash.action;java


import java.io.IOException;spring

import java.text.DecimalFormat;apache

import java.util.List;session


import javax.annotation.Resource;this


import org.springframework.context.annotation.Scope;google

import org.springframework.stereotype.Controller;spa


import com.bluecat.admin.util.Tool;.net

import com.bluecat.biz.AssociatorBiz;prototype

import com.bluecat.biz.DiningTableBiz;orm

import com.bluecat.biz.OrderDetailBiz;

import com.bluecat.biz.OrderInfoBiz;

import com.bluecat.cash.util.CashTools;

import com.bluecat.cash.util.TicketBills;

import com.bluecat.entity.Associator;

import com.bluecat.entity.DiningTable;

import com.bluecat.entity.Employee;

import com.bluecat.entity.OrderDetail;

import com.bluecat.entity.OrderInfo;

import com.google.gson.Gson;

import com.sun.org.apache.xalan.internal.xsltc.compiler.sym;

@Controller

@Scope("prototype")

public class OrderInfoAction extends BaseAction{

private OrderInfo orderInfo=new OrderInfo();

private DiningTable diningTable=new DiningTable();

private Associator associator=new Associator();

@Resource

private OrderInfoBiz orderInfoBiz;

@Resource

private DiningTableBiz diningTableBiz;

@Resource

private OrderDetailBiz orderDetailBiz;

@Resource

private AssociatorBiz associatorBiz;

/** 

* @Description:  去到結帳頁面

* @return    

* @author xvechen

*/ 

public String toPayMoney(){

//查找出全部的桌臺號並放到請求域中

List<DiningTable> tableList=diningTableBiz.selectAllDingingTable();

this.request.setAttribute("tableList", tableList);

return "payMoney";

}

/**

* @Description:根據訂單號查看全部信息

* @return String

* @author luojin

* @version : 2013-11-20下午4:10:10

*/

public String checkctOrderId(){

try {

OrderInfo order=orderInfoBiz.selectorId(orderInfo);

if(order==null){

Tool.getResponse().getWriter().print(0);

}else {

Tool.getResponse().getWriter().print(1);

}

} catch (IOException e) {

e.printStackTrace();

}


return null;

}

/**

* @Description:點擊餐桌結帳若是狀態爲4不顯示結算界面

* @return String

* @author luojin

* @version : 2013-11-20下午4:51:31

*/

public String checkOrderStats(){

try {

String tabId= Tool.getRequest().getParameter("cttxt");

OrderInfo ordStats= orderInfoBiz.select1(tabId);

Tool.getResponse().getWriter().print(ordStats!=null?1:0);

} catch (IOException e) {

e.printStackTrace();

}

return null;

}

/** 

* @Description:  更具桌臺好查找相對應的訂單信息    

* @author xvechen;

* @chang luojin

*/ 

public String getOrderInfoByAjax(){

String tabId=request.getParameter("cttxt");

orderInfo.setOrderId(tabId);

OrderInfo orderinfo = orderInfoBiz.selectorId(orderInfo);

Tool.getRequest().setAttribute("order",orderinfo);

String money="¥";

Tool.getRequest().setAttribute("money", money);

String yuan="元";

Tool.getRequest().setAttribute("yuan", yuan);

if(orderinfo!=null){

List<OrderDetail> orderDetail=orderDetailBiz.select(orderinfo.getOrderId());

Tool.getRequest().setAttribute("detail", orderDetail);

}

List<DiningTable> tableList= this.diningTableBiz.selectAllDingingTable();

Tool.getRequest().setAttribute("tableList", tableList);

return "payMoney";


}

/** 

* @Description: 檢查餐檯信息    

* @author luojin;

*/ 

public String checkctEmpty(){

String tabId=request.getParameter("cttxt");

orderInfo = orderInfoBiz.checkct(tabId);

OrderInfo orderinfo = orderInfoBiz.select1(tabId);

Tool.getSession().setAttribute("ctnum", orderinfo.getDiningTable().getDinTabId());

Tool.getSession().setAttribute("servuser", orderinfo.getWaiter().getEmpName());

Tool.getSession().setAttribute("ordersession", orderinfo);

if(orderinfo!=null){

List<OrderDetail> orderDetail=orderDetailBiz.select(orderinfo.getOrderId());

Tool.getSession().setAttribute("detailsession", orderDetail);

}

List<DiningTable> tableList= this.diningTableBiz.selectAllDingingTable();

Tool.getSession().setAttribute("tableListsession", tableList);

if(orderInfo!=null){

orderInfo.setAssocCard(null);

orderInfo.setCasher(null);

orderInfo.setWaiter(null);

orderInfo.setDiningTable(null);

}

try {

response.getWriter().println(new Gson().toJson(orderInfo).toString());

} catch (IOException e) {

e.printStackTrace();

}

return "PayCounts";

}

/**

*  描述: 金額結算更新各表狀態

* @author luojin

* @throws IOException 

*/

public String CountPayMoney() throws IOException{

   String tel= Tool.getRequest().getParameter("Tel");

   String insertPrice=Tool.getRequest().getParameter("insertPrice");

   String rvsPrices=Tool.getRequest().getParameter("rvsPrices");

   String ogfIntegs=Tool.getRequest().getParameter("ogfIntegs");

   String rvsPrice=Tool.getRequest().getParameter("rvsPrice");

   Employee employee=(Employee) Tool.getSession().getAttribute("employee");

   Associator associators=null;

   List<OrderDetail> orderDetail=null;

OrderInfo getorderIdall=orderInfoBiz.selectSingleOrderInfo(orderInfo);

Employee emp=new Employee();

emp.setEmpId(employee.getEmpId());

getorderIdall.setCasher(emp);

orderInfoBiz.update(getorderIdall);

if(getorderIdall!=null){

orderDetail=orderDetailBiz.select(getorderIdall.getOrderId());

}

int integrals=CashTools.PriceToAssocIntegral(orderInfo.getTotalMoney());

getorderIdall.setOrderId(orderInfo.getOrderId());

//有輸入會員號的時候

if(tel!=null && !tel.trim().equals("")){

  associator.setAssocTel(tel);

  associator.setAssocIntegral(integrals);

  //還要根據會員號查出員原積分

  associators=associatorBiz.selectAssocTel(associator);

  associatorBiz.updateIntergs(associator);

  Associator asid=new Associator();

  asid.setAssocCard(associators.getAssocCard());

  getorderIdall.setAssocCard(asid);

  orderInfoBiz.update(getorderIdall);

}

getorderIdall.setOrderStatus(4);

//這裏修改金額

if(insertPrice.equals("0")){

getorderIdall.setTotalMoney((float) 0);

orderInfoBiz.update(getorderIdall);

}

if(!insertPrice.equals("0")){

getorderIdall.setTotalMoney(orderInfo.getTotalMoney());

orderInfoBiz.update(getorderIdall);

}

diningTable.setDinTabId(diningTable.getDinTabId());

DiningTable dTable= diningTableBiz.selectAll(diningTable);

dTable.setDinTabStatus(0);

diningTableBiz.update(dTable);

//輸出小票信息

String paths= Tool.getRequest().getServletContext().getRealPath("/");

String orgImg=paths+"Cash/images/bill.jpg";

String ysPrice=Tool.getRequest().getParameter("yingshou");

String zlinPrice=Tool.getRequest().getParameter("savePrice");

System.out.println("找零"+zlinPrice);

String zks=Tool.getRequest().getParameter("zks");

System.out.println("折扣"+zks);

System.out.println("折扣"+zks.equals(""));

TicketBills tBills=new TicketBills(orgImg,getorderIdall,associators,orderDetail,dTable,ysPrice,insertPrice,zlinPrice,zks,rvsPrices,ogfIntegs);

Tool.getResponse().getWriter().print(1);

return null;

}

public String accountFinsh() throws IOException{

Employee employee=(Employee) Tool.getSession().getAttribute("employee");

    List<Object[]> accounPrice=orderInfoBiz.accountFinsh(employee);

    System.out.println(accounPrice.size()+"dd"+accounPrice);

    if(accounPrice.size()!=1){

    float totals=0;

    String buss=null;

    for(int i=0;i<accounPrice.size();i++){

     totals=Float.valueOf((accounPrice.get(i)[0]).toString());

 buss=String.valueOf(accounPrice.get(i)[1]);

 System.out.println(buss+totals);

}

    orderInfo.setOrderId(buss);

    DecimalFormat df = new DecimalFormat("#.00");

    orderInfo.setTotalMoney(Float.valueOf(df.format(totals)));

    Tool.getRequest().setAttribute("cts",orderInfo);

    }

return "asscoutfinsh";

}

/**

* @Description:沒有時間作銷燬Session

* @return String

* @author luojin

* @version : 2013-11-29上午12:32:28

*/

    public String exit(){

    Tool.getSession().removeAttribute("ctnum");

    Tool.getSession().removeAttribute("servuser");

    Tool.getSession().removeAttribute("ordersession");

    Tool.getSession().removeAttribute("employee");

    return "exit";

    }

/** 

* 描述:  更新訂單狀態

* @author xvechen

* @date: 2013-11-5 下午10:22:12 

*/ 

public void updateOrderStatus(){

orderInfo=orderInfoBiz.selectSingleOrderInfo(orderInfo);

orderInfo.setOrderStatus(3);

orderInfoBiz.update(orderInfo);

}

public OrderInfo getOrderInfo() {

return orderInfo;

}

public void setOrderInfo(OrderInfo orderInfo) {

this.orderInfo = orderInfo;

}

public DiningTable getDiningTable() {

return diningTable;

}

public void setDiningTable(DiningTable diningTable) {

this.diningTable = diningTable;

}

public static void main(String[] args) {

OrderInfo o=new OrderInfo();

o.setOrderId("1");

System.out.println(new Gson().toJson(o));

}


}

相關文章
相關標籤/搜索