ssh Action

package com.bluecat.cash.action;


import java.io.IOException;

import java.text.DecimalFormat;

import java.util.List;


import javax.annotation.Resource;


import org.springframework.context.annotation.Scope;

import org.springframework.stereotype.Controller;


import com.bluecat.admin.util.Tool;

import com.bluecat.biz.AssociatorBiz;

import com.bluecat.biz.DiningTableBiz;

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));

}


}


转载于:https://my.oschina.net/u/1042750/blog/186719

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值