package com.zhang.you.action;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.text.MessageFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.zhang.you.bll.SystemParam;
import com.zhang.you.dal.DALBase;
import com.zhang.you.entity.Attachement;
import com.zhang.you.entity.Dingdan;
import com.zhang.you.entity.Dingdanitems;
import com.zhang.you.entity.Huiyuan;
import com.zhang.you.entity.Shangpin;
import com.zhang.you.util.PagerMetal;
public class DingdanAction extends PageActionBase {
public void onLoad() {
String actiontype = request.getParameter("actiontype");
System.out.println("actiontype=" + actiontype);
if (actiontype == null)
return ;
if(actiontype.equals("modifyAmount")){
modifyAmount();
}
if (actiontype.equals("shopcart")) {
shopcart();
}
if (actiontype.equals("clearshopcart")) {
clearshopcart();
}
if (actiontype.equals("removeShangpin")) {
removeShangpin();
}
if(actiontype.equals("payfor"))
fukuan();
if(actiontype.equals("fahuo"))
fahuo();
}
private void fahuo() {
String ddid=request.getParameter("ddid");
String fahuoren=request.getParameter("fahuoren");
if(ddid!=null)
{
Dingdan dingdan=(Dingdan)DALBase.load("dingdan", "where id="+ddid);
dingdan.setStatus("已发货");
dingdan.setFahuoren(fahuoren);
dingdan.setFahuotime(new Date());
DALBase.update(dingdan);
}
String forwardurl = request.getParameter("forwardurl");
if (forwardurl != null)
try {
response.sendRedirect(SystemParam.getSiteRoot() + forwardurl);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void fukuan() {
String ddid=request.getParameter("ddid");
String accountname=request.getParameter("accountname");
String errorurl=request.getParameter("errorurl");
if(ddid!=null)
{
Dingdan dingdan=(Dingdan)DALBase.load("dingdan", "where id="+ddid);
if(accountname!=null)
{
Huiyuan hy=(Huiyuan)DALBase.load("huiyuan", "where accountname='"+accountname+"'");
if(hy.getYue()<dingdan.getTotalprice()){
request.setAttribute("errormsg", "<label class='error'>账户余额不足于支付订单,请充值</label>");
try {
request.getRequestDispatcher("/e/huiyuan/fukuan.jsp?id="+ddid).forward(request, response);
return;
} catch (ServletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else {
hy.setYue((float)(hy.getYue()-dingdan.getTotalprice()));
hy.setJifen(hy.getJifen()+(int)dingdan.getTotalprice());
DALBase.update(hy);
dingdan.setStatus("已付款");
DALBase.update(dingdan);
request.getSession().setAttribute("huiyuan", hy);
}
}
}
String forwardurl = request.getParameter("forwardurl");
if (forwardurl != null)
try {
response.sendRedirect(SystemParam.getSiteRoot() + forwardurl);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/*
* 修改购物车数量
* */
private void modifyAmount(){
String spid=request.getParameter("spid");
String shuliang=request.getParameter("shuliang");
List<Dingdanitems> temlist=(List<Dingdanitems>)request.getSession().getAttribute("cart");
if(temlist!=null)
{
for(Iterator<Dingdanitems> it= temlist.iterator();it.hasNext();)
{
Dingdanitems ddi=it.next();
if(ddi.getSpid()==new Integer(spid))
{
ddi.setShuliang(new Integer(shuliang));
}
}
}
calcuateTotalfee();
String forwardurl = request.getParameter("forwardurl");
if (forwardurl != null)
try {
response.sendRedirect(SystemParam.getSiteRoot() + forwardurl);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void removeShangpin() {
String spid=request.getParameter("spid");
List<Dingdanitems> temlist=(List<Dingdanitems>)request.getSession().getAttribute("cart");
if(temlist!=null)
{
for(Iterator<Dingdanitems> it= temlist.iterator();it.hasNext();)
{
Dingdanitems ddi=it.next();
if(ddi.getSpid()==new Integer(spid))
{
it.remove();
float totalfee=Float.parseFloat(request.getSession().getAttribute("totalfee").toString());
totalfee-=ddi.getShuliang()* Float.parseFloat(ddi.getJiage());
request.getSession().setAttribute("totalfee", totalfee);
}
}
}
String forwardurl = request.getParameter("forwardurl");
if (forwardurl != null)
try {
response.sendRedirect(SystemParam.getSiteRoot() + forwardurl);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void clearshopcart() {
request.getSession().removeAttribute("cart");
request.getSession().removeAttribute("totalfee");
String forwardurl = request.getParameter("forwardurl");
if (forwardurl != null)
try {
response.sendRedirect(SystemParam.getSiteRoot() + forwardurl);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void calcuateTotalfee()
{
List<Dingdanitems> cart = (List<Dingdanitems>) request.getSession()
.getAttribute("cart");
int totalfee=0;
for (Dingdanitems dditem : cart) {
totalfee += dditem.getShuliang()
* new Double(dditem.getJiage());
}
request.getSession().setAttribute("totalfee", totalfee);
}
private void shopcart() {
String forwardurl = request.getParameter("forwardurl");
// 商品ID
String spid = request.getParameter("spid");
// 商品名
String spname2 = request.getParameter("spname");
//
String command = request.getParameter("command");
// request.setCharacterEncoding("UTF-8");
float totalfee = 0;
List<Dingdanitems> cart = (List<Dingdanitems>) request.getSession()
.getAttribute("cart");
if (spid != null) {
if (cart == null) {
cart = new ArrayList<Dingdanitems>();
request.getSession().setAttribute("cart", cart);
}
Shangpin addshangpin = (Shangpin) DALBase.load("shangpin",
"where id=" + spid);
Boolean hasin = false;
for (Dingdanitems dditem : cart) {
System.out.println("addshangpin.getId()" + addshangpin.getId());
System.out.println("dditem.getId()" + dditem.getId());
if (addshangpin.getId() == dditem.getSpid()) {
hasin = true;
if (command!=null&&command.equals("modifyCount")) {
String shuliang = request.getParameter("shuliang");
dditem.setShuliang(new Integer(shuliang));
} else
dditem.setShuliang(dditem.getShuliang() + 1);
}
totalfee += dditem.getShuliang()
* new Double(dditem.getJiage());
}
if (!hasin) {
Dingdanitems temitem = new Dingdanitems();
temitem.setSpname(addshangpin.getName());
temitem.setSpimage(addshangpin.getTupian());
temitem.setSpno(addshangpin.getSpno());
temitem.setSpid(addshangpin.getId());
temitem.setShuliang(1);
temitem.setJiage(String.va
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于javaweb的宠物商城管理系统源码.zip 基于javaweb的宠物商城管理系统源码.zip基于javaweb的宠物商城管理系统源码.zip基于javaweb的宠物商城管理系统源码.zip基于javaweb的宠物商城管理系统源码.zip基于javaweb的宠物商城管理系统源码.zip基于javaweb的宠物商城管理系统源码.zip基于javaweb的宠物商城管理系统源码.zip基于javaweb的宠物商城管理系统源码.zip基于javaweb的宠物商城管理系统源码.zip基于javaweb的宠物商城管理系统源码.zip基于javaweb的宠物商城管理系统源码.zip基于javaweb的宠物商城管理系统源码.zip基于javaweb的宠物商城管理系统源码.zip基于javaweb的宠物商城管理系统源码.zip基于javaweb的宠物商城管理系统源码.zip基于javaweb的宠物商城管理系统源码.zip基于javaweb的宠物商城管理系统源码.zip基于javaweb的宠物商城管理系统源码.zip基于javaweb的宠物商城管理系统源码.zip基于javaweb的宠物商城管理系
资源推荐
资源详情
资源评论
收起资源包目录
基于javaweb的宠物商城管理系统源码.zip (2000个子文件)
.classpath 825B
.classpath 825B
org.eclipse.wst.common.component 465B
org.eclipse.wst.jsdt.ui.superType.container 49B
jquery-ui.css 31KB
jquery-ui.css 31KB
jquery.treetable.theme.default.css 29KB
jquery.treetable.theme.default.css 29KB
jquery-ui.min.css 26KB
jquery-ui.min.css 26KB
web2table.css 25KB
web2table.css 25KB
jquery-ui.min.css 25KB
jquery-ui.min.css 25KB
index.css 24KB
index.css 24KB
custom.css 23KB
custom.css 23KB
box.css 23KB
box.css 23KB
_all.css 21KB
_all.css 21KB
lanmu.css 20KB
lanmu.css 20KB
default.css 18KB
default.css 18KB
jquery.ui.theme.css 17KB
jquery.ui.theme.css 17KB
_all.css 15KB
_all.css 15KB
_all.css 15KB
_all.css 15KB
jquery.ui.theme.min.css 13KB
jquery.ui.theme.min.css 13KB
_all.css 13KB
_all.css 13KB
common.css 10KB
common.css 10KB
normalize.css 9KB
normalize.css 9KB
green.css 8KB
green.css 8KB
black.css 8KB
black.css 8KB
blue.css 8KB
blue.css 8KB
default.css 8KB
default.css 8KB
list.css 7KB
list.css 7KB
opera.css 7KB
opera.css 7KB
aero.css 7KB
aero.css 7KB
idialog.css 7KB
idialog.css 7KB
chrome.css 6KB
chrome.css 6KB
twitter.css 6KB
twitter.css 6KB
simple.css 6KB
simple.css 6KB
colorbox.css 4KB
colorbox.css 4KB
easydropdown.flat.css 4KB
easydropdown.flat.css 4KB
jquery.ui.datepicker.css 4KB
jquery.ui.datepicker.css 4KB
easydropdown.metro.css 4KB
easydropdown.metro.css 4KB
register.css 3KB
register.css 3KB
simple.css 3KB
simple.css 3KB
toolbar.css 3KB
toolbar.css 3KB
jquery.ui.datepicker.min.css 3KB
jquery.ui.datepicker.min.css 3KB
easydropdown.css 3KB
easydropdown.css 3KB
layout.css 3KB
layout.css 3KB
jquery.ui.button.css 2KB
jquery.ui.button.css 2KB
uploadify.css 2KB
uploadify.css 2KB
login.css 2KB
login.css 2KB
purple.css 2KB
yellow.css 2KB
purple.css 2KB
yellow.css 2KB
orange.css 2KB
orange.css 2KB
green.css 2KB
green.css 2KB
pink.css 2KB
aero.css 2KB
grey.css 2KB
blue.css 2KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
- 老丝儿。2024-03-15非常有用的资源,有一定的参考价值,受益匪浅,值得下载。
- 2301_804649232023-12-29这个资源对我启发很大,受益匪浅,学到了很多,谢谢分享~
不安分的小女孩
- 粉丝: 9200
- 资源: 1990
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功