博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ssh Action
阅读量:7047 次
发布时间:2019-06-28

本文共 7878 字,大约阅读时间需要 26 分钟。

hot3.png

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

private OrderInfoBiz orderInfoBiz;

private DiningTableBiz diningTableBiz;

private OrderDetailBiz orderDetailBiz;

private AssociatorBiz associatorBiz;

/** 

* @Description:  去到结账页面

*    

* xvechen

*/ 

public String toPayMoney(){

//查找出所有的桌台号并放到请求域中

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

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

return "payMoney";

}

/**

* @Description:根据订单号查看所有信息

* String

* luojin

* : 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不显示结算界面

* String

* luojin

* : 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:  更具桌台好查找相对应的订单信息    

* xvechen;

* 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: 检查餐台信息    

* 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";

}

/**

*  描述: 金额结算更新各表状态

* luojin

* 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

* String

* luojin

* : 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";

    }

/** 

* 描述:  更新订单状态

* 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

你可能感兴趣的文章
LeetCode-330.Patching Array
查看>>
zxing生成二维码转base64 img直接显示 Image对象转Base64码(java)
查看>>
xfire冲突问题解决(maven配置)
查看>>
C#面向对象(三)接口实现多态
查看>>
POJ 3069 Saruman's Army 【贪心】
查看>>
Linux下用Java获取本机IP
查看>>
HTML标签
查看>>
关联规则中的支持度与置信度
查看>>
轻松搭建持续集成工具jenkins
查看>>
剑指offer四:链表中倒数第k个结点
查看>>
web 前端开发学习路线
查看>>
Eclipse的Spring库导入
查看>>
velocity 判断 变量 是否不是空或empty
查看>>
【leetcode】123. Best Time to Buy and Sell Stock III
查看>>
角色设计的特点
查看>>
sublime text格式化json快捷键
查看>>
获得数据库自动生成的主键
查看>>
磁盘阵列
查看>>
y轴数据变换利器——yaxis-transformer
查看>>
Hibernate缓存机制
查看>>