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.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 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);
}
/********************************************************
******************信息注销监听支持*****************************
*********************************************************/
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);
}
}
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);
}
@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,"支付密码不正确");
double fee=shorderSrv.getTotalPrice(order.getId());
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
@PostMapping("/admin/shorder/deliver")
public JsonResult deliver(){
String oiid=request.getParameter("oiid");
String wlno=request.getParameter("wlno");
if(oiid==null||oiid.equals(""))
return JsonResult.error(-1,"参数异常");
Orderitem oi=orderitemSrv.load("where id="+oiid);
oi.setState(3);
oi.setWlno(wlno);
int count= orderitemSrv.upd
岛上程序猿
- 粉丝: 5818
- 资源: 4248
最新资源
- 基于fpga的交通灯设计,要求:A通道绿灯亮30S,黄灯亮5S,左拐灯亮15S,黄灯亮5S,这个过程中B通道一直亮红灯,之后A通道亮红灯,B通道绿灯亮40S,之后黄灯亮5S,之后左拐灯亮15S,之后黄
- 基于阶梯碳交易成本的含电转气-碳捕集(P2G-CCS)耦合的综合能源系统低碳经济优化调度,采用(Matlab+Yalmip+Cplex) 考虑P2G设备、碳捕集电厂、风电机组、光伏机组、CHP机组、燃
- 计及阶梯碳交易成本+多元储能(电储能、氢储能、气储能、热储能)+综合能源系统IES联合低碳优化调度(用Matlab+Yalmip+Cplex) 考虑机组和设备:热电联产机组、燃气机组、甲烷反应生成设备
- (OC)多代理实现 运行看效果
- visual basic 6 安装光盘文件
- 双碳+24小时分时综合能源系统低碳优化调度(用Matlab+Yalmip+Cplex) 包含新能源消纳、热电联产、电锅炉、储能电池、天然气、碳捕集CCS、计及碳交易市场等综合元素,实现系统总运行成本最
- 基恩士KV5500程序 基恩士KV5500,威伦通触摸屏,搭载KL-N20V.远程IO模块,KV-MC02V凸轮定位模块,KV-L2*V串行通信模块 全自动锂电池注液机 伺服轴进行位置控制,等
- 电力系统(30节点)机组组合优化调度 基于Matlab、yalmip、cpelx求解最优 针对机组组合问题,提出一种混合整数线性模型,相比传统方法,采用二进制变量和约束,节省计算时间优化收敛速度 为
- 基于门控循环单元GRU做多个特征变量输入,单个因变量输出的拟合预测建模 程序内注释详细,可学习性强 程序直接替数据就可以使用,不会替数据的可以免费指导替数据 程序语言是matlab的,需求版本是
- 图像处理领域的频域处理和复原:运动模糊和失焦模糊修复研究
- dmidecode-3.6
- 多目标遗传算法电力系统系统分布式电源选址定容(matlab程序) 基于IEEE14节点的电力系统多目标优化的遗传算法分布式电源选址定容 对于网损、容量和、电压稳定值的目标优化出来的选址定容 分为有DG
- Simulink 车用永磁同步电机弱磁控制 基于矢量控制 FOC
- GAPSO-LSTM,遗传粒子群优化算法来优化LSTM网络做预测,预测精度高于普通的PSO-LSTM 这里把遗传算法跟粒子群优化算法结合,指的不是用遗传算法来优化PSO的参数,而是解决PSO的容易收
- matlab实现PID控制四旋翼无人机综述模型-PID-四旋翼无人机-matlab
- 2024后台组保姆级学习路线.pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈