package com.daowen.controller;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.List;
import java.util.HashMap;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSONObject;
import com.daowen.dto.Shopcart;
import com.daowen.dto.ShopcartItem;
import com.daowen.util.JsonResult;
import com.daowen.util.SequenceUtil;
import com.daowen.util.StringUtil;
import com.daowen.vo.CouponVo;
import com.daowen.vo.CreateOrderDTO;
import com.daowen.vo.OrderDTO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.daowen.entity.*;
import com.daowen.service.*;
import com.daowen.ssm.simplecrud.SimpleController;
import com.daowen.webcontrol.PagerMetal;
import org.springframework.web.bind.annotation.ResponseBody;
/**************************
*
* 订单控制
*
*/
@Controller
public class ShorderController extends SimpleController {
@Autowired
private ShorderService shorderSrv = null;
@Autowired
private HuiyuanService huiyuanSrv=null;
@Autowired
private OrderitemService orderitemSrv=null;
@Autowired
private CouponService couponSrv=null;
@Autowired
private ShangpinService shangpinSrv=null;
private String cartName = "shopcart";
@Autowired
private SpcommentService spcommentSrv=null;
@Autowired
private ShopcartService shopcartSrv = null;
@Override
@RequestMapping("/admin/shordermanager.do")
public void mapping(HttpServletRequest request, HttpServletResponse response) {
mappingMethod(request, response);
}
private void saleTongji() {
String begdate = request.getParameter("begindate");
String enddate = request.getParameter("enddate");
HashMap<String,Object> map=new HashMap<>();
if(begdate!=null)
map.put("begdate",begdate);
if(enddate!=null)
map.put("enddate",enddate);
List<HashMap<String,Object>> listMap=shorderSrv.saleStat(map);
if(listMap!=null)
request.setAttribute("listMap",listMap);
dispatchParams(request, response);
String forwardurl = request.getParameter("forwardurl");
if (forwardurl == null) {
forwardurl = "/admin/xiaoshoutongjitext.jsp";
}
forward(forwardurl);
}
public void delete() {
String[] ids = request.getParameterValues("ids");
if (ids == null)
return;
for(String id : ids){
shorderSrv.delete("where id="+id);
orderitemSrv.delete("where orderid="+id);
}
}
@ResponseBody
@PostMapping("/admin/shorder/shouhuo")
public JsonResult shouhuo(){
String oiid=request.getParameter("oiid");
String star=request.getParameter("star");
String des=request.getParameter("des");
String appraiserid=request.getParameter("appraiserid");
if(oiid==null||oiid.equals(""))
return JsonResult.error(-1,"参数异常");
Orderitem orderitem=orderitemSrv.load("where id="+oiid);
Spcomment spcomment=new Spcomment();
spcomment.setCreatetime(new Date());
spcomment.setSpid(orderitem.getSpid());
spcomment.setOrderid(orderitem.getId());
spcomment.setCresult(star==null?1:Integer.parseInt(star));
spcomment.setAppraiserid(appraiserid==null?0:Integer.parseInt(appraiserid));
spcomment.setDes(des);
spcommentSrv.save(spcomment);
int count= orderitemSrv.executeUpdate(MessageFormat.format("update orderitem set state=4 where id={0} ",oiid));
int ndCount=orderitemSrv.getRecordCount(MessageFormat.format("where orderid={0,number,#} and state=3 ",orderitem.getOrderid()));
//商品全部发货则更新订单为已发货状态
if(ndCount==0)
shorderSrv.executeUpdate(MessageFormat.format("update shorder set state=4 where id={0,number,#}",orderitem.getOrderid()));
if(count>0)
return JsonResult.success(1,"收货成功");
return JsonResult.error(-2,"收货失败");
}
@ResponseBody
@PostMapping("/admin/shorder/payment")
public JsonResult payment(){
String id=request.getParameter("id");
String paystyle=request.getParameter("paystyle");
String paypwd=request.getParameter("paypwd");
if(paypwd==null||paypwd.equals("")){
return JsonResult.error(-1,"请输入支付密码");
}
if(id==null||paypwd.equals(""))
return JsonResult.error(-2,"订单编号异常");
if(!StringUtil.isNumeric(id))
return JsonResult.error(-3,"订单编号异常");
String couponid=request.getParameter("couponid");
Shorder order=shorderSrv.load("where id="+id);
if(order==null)
return JsonResult.error(-4,"订单号不存在");
Huiyuan huiyuan= huiyuanSrv.load("where id="+order.getPurchaser());
if(huiyuan==null)
return JsonResult.error(-5,"账户信息异常");
if(!paypwd.equals(huiyuan.getPaypwd()))
return JsonResult.error(-6,"支付密码不正确");
CouponVo couponVo =null;
if(couponid!=null){
HashMap<String,Object> map=new HashMap<>();
map.put("id",couponid);
couponVo = couponSrv.loadPlus(map);
if(couponVo.getHyid()!=huiyuan.getId()){
return JsonResult.error(-1,"这尼玛盗用?");
}
}
double fee=shorderSrv.getTotalPrice(order.getId());
if(couponVo!=null) {
fee = fee - couponVo.getFee();
couponSrv.executeUpdate(" update courecord set state =2 where id="+couponVo.getCrid());
}
int count= huiyuanSrv.deduct(order.getPurchaser(),fee);
if(count<=0)
return JsonResult.error(-7,"账户余额不足");
Boolean res=shorderSrv.changeToPayed(order.getId());
if(!res)
return JsonResult.error(-8,"系统异常");
return JsonResult.success(1,"付款成功");
}
@ResponseBody
@PostMapping("/admin/shorder/cancel")
public JsonResult cancel(){
String id=request.getParameter("id");
if(!StringUtil.isNumeric(id))
return JsonResult.error(-1,"订单编号异常");
shorderSrv.executeUpdate("update shorder set state=5 where id="+id);
orderitemSrv.executeUpdate("update orderitem set state=5 where orderid="+id);
return JsonResult.success(1,"付款成功");
}
@ResponseBody
@PostMapping("/admin/shorder/info")
public JsonResult info(){
String id=request.getParameter("id");
String state=request.getParameter("state");
if(id==null||id=="")
return JsonResult.error(-1,"需要id参数");
if(!StringUtil.isNumeric(id)){
return JsonResult.error(-2,"id参数应该为数字");
}
HashMap map=new HashMap<String,Object>();
if(id!=null)
map.put("id",id);
if(state!=null)
map.put("state",state);
OrderDTO purchaseOrder = shorderSrv.getOrderInfo(map);
return JsonResult.success(1,"获取订单成功",purchaseOrder);
}
@ResponseBody
@P
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
(基于ssm框架的Java毕业设计)网上书店系统(源码) 【项目技术】 开发语言:Java 框架:ssm 前端:jquery 数据库:mysql 【实现功能】 整体的功能模块包括前台和后台,前台就是主要的页面,包括用户登录与订单显示页面,添加用户信息,以及信息展示等页面。后台的模块主要有会员用户模块、商品模块、管理员模块、订单模块、公告模块等。
资源推荐
资源详情
资源评论
收起资源包目录
(基于ssm框架的Java毕业设计)网上书店系统(源码).zip (2774个子文件)
ShorderController.class 15KB
ShangpinController.class 15KB
HuiyuanController.class 12KB
XinxiController.class 12KB
PagesettingController.class 10KB
CouponController.class 9KB
UsersController.class 9KB
XinxiService.class 8KB
ShouhouController.class 8KB
ReceaddressController.class 7KB
CommentBuilder.class 7KB
ShopcartController.class 7KB
LanmuController.class 6KB
ShangpinBuilder.class 6KB
LeavewordController.class 6KB
SysroleController.class 6KB
RecursionTree.class 6KB
SptagController.class 6KB
SysconfigitemController.class 6KB
UploadController.class 6KB
CommentController.class 6KB
JiaodiantuController.class 6KB
NoticeController.class 6KB
SupplyorController.class 6KB
SysconfigController.class 6KB
ShoucangController.class 6KB
SitenavController.class 5KB
SubtypeController.class 5KB
FriendlinkController.class 5KB
ShorderService.class 5KB
SimpleStatistics.class 5KB
Shangpin.class 5KB
ShangpinService.class 4KB
LeavewordBuilder.class 4KB
FocusgraphicBuilder.class 4KB
Huiyuan.class 4KB
SingleFileUpload.class 4KB
HttpUtil.class 4KB
LanmuService.class 4KB
MailUtil.class 4KB
MySQLDatabaseUtil.class 4KB
Shopcart.class 4KB
OrderItemDTO.class 4KB
Users.class 3KB
AdminUserController.class 3KB
Xinxi.class 3KB
FileUtil.class 3KB
SitenavBuilder.class 3KB
FileUploadBase.class 3KB
Shouhou.class 3KB
Shorder.class 3KB
ViewHistory.class 3KB
SitesearchController.class 3KB
Comment.class 2KB
BeansUtil.class 2KB
LanmuContentVo.class 2KB
PagesettingService.class 2KB
SequenceUtil.class 2KB
JsonResult.class 2KB
Shoucang.class 2KB
Orderitem.class 2KB
ShangpinVo.class 2KB
Fcomment.class 2KB
Supplyor.class 2KB
Leaveword.class 2KB
Receaddress.class 2KB
SysroleService.class 2KB
CustomJsonDateConverter$2.class 2KB
MainApplication.class 2KB
NoticeBuilder.class 2KB
CreateOrderDTO.class 2KB
Notice.class 2KB
Spcomment.class 2KB
ShopcartItem.class 2KB
CustomJsonDateConverter$1.class 2KB
Jiaodiantu.class 2KB
HTMLUtil.class 2KB
FriendlinkBuilder.class 2KB
ShangpinAdapter.class 2KB
StringUtil.class 2KB
Coupon.class 2KB
HuiyuanService.class 2KB
Sysconfigitem.class 2KB
MainApplication$1.class 2KB
CustomJsonDateConverter.class 1KB
LeavewordService.class 1KB
ShouhouService.class 1KB
Agreerecord.class 1KB
ImageTextItem.class 1KB
Sitenav.class 1KB
LeavewordVo.class 1KB
Courecord.class 1KB
CouponVo.class 1KB
ShopcartService.class 1KB
Lanmu.class 1KB
SearchVo.class 1KB
UploadController$UploadExpress.class 1KB
PageContentVo.class 1KB
LanmuVo.class 1KB
OrderDTO.class 1KB
共 2774 条
- 1
- 2
- 3
- 4
- 5
- 6
- 28
资源评论
岛上程序猿
- 粉丝: 5517
- 资源: 4237
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功