package com.daowen.controller;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSONObject;
import com.daowen.entity.Lanmu;
import com.daowen.service.*;
import com.daowen.util.JsonResult;
import com.daowen.vo.LanmuVo;
import com.daowen.vo.ShangpinVo;
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.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.daowen.entity.Shangpin;
import com.daowen.ssm.simplecrud.SimpleController;
import com.daowen.util.SequenceUtil;
import com.daowen.webcontrol.PagerMetal;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class ShangpinController extends SimpleController {
@Override
@RequestMapping("/admin/shangpinmanager.do")
public void mapping(HttpServletRequest request, HttpServletResponse response) {
mappingMethod(request, response);
}
@ResponseBody
@PostMapping("/admin/shangpin/mylanmu")
public JsonResult list(){
List<LanmuVo> listLanmu=shangpinSrv.getMyLanmus();
return JsonResult.success(1,"获取栏目",listLanmu);
}
@ResponseBody
@PostMapping("/admin/shangpin/count")
public JsonResult counttongji(){
String sql=" select lm.name ,count(*) as value from shangpin sp,lanmu lm where lm.id=sp.typeid ";
String pubren=request.getParameter("pubren");
if(pubren!=null)
sql+=" and sp.pubren="+pubren;
sql+=" group by sp.typeid,lm.name ";
List<HashMap<String,Object>> listTongji=shangpinSrv.queryToMap(sql);
return JsonResult.success(1,"",listTongji);
}
@ResponseBody
@PostMapping("/admin/shangpin/saledstat")
public JsonResult saleStat(){
String sql=" select sp.name as name,sum(count) as value from shangpin sp,orderitem oi where sp.id=oi.spid ";
String pubren=request.getParameter("pubren");
if(pubren!=null)
sql+=" and sp.pubren="+pubren;
sql+=" group by sp.id,sp.name ";
List<HashMap<String,Object>> listTongji=shangpinSrv.queryToMap(sql);
return JsonResult.success(1,"",listTongji);
}
@ResponseBody
@PostMapping("/admin/shangpin/hotsales")
public JsonResult hotSales(){
String sql=" select sp.*,t.saledcount from shangpin sp inner join (select oi.spid,sum(oi.count) as saledcount from border o ,boitem oi where o.id=oi.orderid and o.state!=1 group by oi.spid) t on t.spid=sp.id order by saledcount desc limit 10 ";
List<HashMap<String,Object>> listMap=shangpinSrv.queryToMap(sql);
return JsonResult.success(1,"热销产品",listMap);
}
@ResponseBody
@GetMapping("/admin/shangpin/type")
public JsonResult getTypes(){
List<Lanmu> listLanmu=lanmuSrv.getEntity("where type=2");
return JsonResult.success(1,"获取 书籍类别",listLanmu);
}
@RequestMapping("/admin/shangpin/info")
@ResponseBody
public JsonResult info() {
String id = request.getParameter("id");
ShangpinVo shangpin = null;
if (id == null) {
return JsonResult.error(-1, "参数异常");
}
shangpin = shangpinSrv.loadPlus(Integer.parseInt(id));
return JsonResult.success(1, "获取 书籍信息", shangpin);
}
public void shenpi() {
String id = request.getParameter("id");
String forwardurl = request.getParameter("forwardurl");
String spstate = request.getParameter("spstate");
String reply = request.getParameter("reply");
String shenpiren = request.getParameter("shenpiren");
int statuscode = 3;
// 验证错误url
String errorurl = request.getParameter("errorurl");
if (id == null)
return;
Shangpin shangpin = shangpinSrv.load(" where id=" + id);
if (shangpin == null)
return;
if (spstate != null)
statuscode = Integer.parseInt(spstate);
shangpin.setSpstate(statuscode);
shangpinSrv.update(shangpin);
if (forwardurl == null) {
forwardurl = "/admin/shangpinmanager.do?actiontype=get";
}
redirect(forwardurl);
}
@ResponseBody
@PostMapping("/admin/shangpin/shangjia")
public JsonResult shangjia() {
String[] ids = request.getParameterValues("ids");
if (ids == null)
return JsonResult.error(-1,"参数异常");
String spliter = ",";
String sql = " update shangpin set state=1 where id in("
+ join(spliter, ids) + ")";
int count=shangpinSrv.executeUpdate(sql);
JSONObject jsonObject=new JSONObject();
jsonObject.put("count",count);
return JsonResult.success(1,"上架成功",jsonObject);
}
@ResponseBody
@PostMapping("/admin/shangpin/xiajia")
public JsonResult xiajia() {
String[] ids = request.getParameterValues("ids");
if (ids == null)
return JsonResult.error(-1,"参数异常");
String spliter = ",";
String sql = " update shangpin set state=2 where id in("
+ join(spliter, ids) + ")";
int count=shangpinSrv.executeUpdate(sql);
JSONObject jsonObject=new JSONObject();
jsonObject.put("count",count);
return JsonResult.success(1,"下架成功",jsonObject);
}
private void bindcoupon(){
String forwardurl = request.getParameter("forwardurl");
String id = request.getParameter("id");
String couponid=request.getParameter("couponid");
if (id == null)
return;
Shangpin shangpin = shangpinSrv.load("where id="+id);
if (shangpin == null)
return;
if(couponid!=null) {
shangpin.setCouponid(Integer.parseInt(couponid));
shangpinSrv.update(shangpin);
}
if (forwardurl == null) {
forwardurl = "/admin/shangpinmanager.do?actiontype=get";
}
redirect(forwardurl);
}
public void kucunadd() {
String forwardurl = request.getParameter("forwardurl");
String id = request.getParameter("id");
String supplor = request.getParameter("supplor");
String cgdate = request.getParameter("cgdate");
String cgren = request.getParameter("cgren");
if (id == null)
return;
Shangpin shangpin = shangpinSrv.load(new Integer(id));
if (shangpin == null)
return;
String shuliang = request.getParameter("shuliang");
String danwei = request.getParameter("danwei");
if (shuliang != null) {
shangpin.setKucun(shangpin.getKucun() + Integer.parseInt(shuliang));
shangpin.setDanwei(danwei);
shangpinSrv.update(shangpin);
}
if (forwardurl == null) {
forwardurl = "/admin/shangpinmanager.do?actiontype=get";
}
redirect(forwardurl);
}
@ResponseBody
@PostMapping("/admin/shangpin/delete")
public JsonResult delete() {
String[] ids = request.getParameterValues("ids");
if (ids == null)
return JsonResult.error(-1,"参数异常");
String spliter = ",";
String sql = " where id in(" + join(spliter, ids)+ ")";
int count=shangpinSrv.delete(sql);
JSONObject jsonObject=new JSONObject();
jsonObject.put("count",count);
return JsonResult.success(1,"删除成功",jsonObject);
}
public void save() {
String forwardurl = request.getParameter("forwardurl");
String name = request.getParameter("name");
String jiage = request.getParameter("jiage");
String tuijian = request.getParameter("tuijian");
String typeid = request.getParameter("typeid");
String subtypeid = request.getParameter("subtypeid");
String tupian = request.getParameter("tupian");
String jieshao = request.getParameter("jieshao");
String pubren = request.getParameter("pubren");
String subtitle = request.getParameter("subtitle");
String discount = request.getParameter("discount");
String chandi = request.getParameter("chandi");
String tagid = req
岛上程序猿
- 粉丝: 5819
- 资源: 4248
最新资源
- 博途S7-1200主站与S7-200从站实现RS485通讯程序 S7-200可以当作一个仪表
- C#、C++分别开发的OPC DA CLIENT软件. 1、枚举服务器名称; 2、连接服务器以后枚举出TAG; 3、根据TAG名称自动读取服务器数据; 4、图片内有OPC SERVER和CLIENT实
- python-workspace.zip.005
- 龙门上下料样本程序,四轴 用台达AS228T和台达触摸屏编写 注意软件是用台达新款软件ISPSOFT ,借鉴价值高,程序有注释
- 一款window下的串口监视抓包工具
- 欧姆龙CP1H与3台力士乐VFC-x610变频器通讯程序 功能:原创程序,可直接用于现场程序 欧姆龙CP1H的CIF11通讯板,实现对3台力士乐VFC-x610变频器 设定频率,控制正反转,读取实际
- dp111113333
- CV-密集人群图像数据集(5800张图片).rar
- 福特汽车主观评价规范,性能开发参考,英文原版直译,评价条目、规则描述非常细致 包含平顺舒适性,转向,操稳,NVH,制动,加速感,驾驶性等等性能,并详细描述了评价的准备工作 评价条目细分至第四级,共
- 三菱FX3S两轴标准程序,XZ两轴,包含轴点动,回零,相对与绝对定位,只要弄明白这个程序,就可以非常了解整个项目的程序如何去编写,从哪里开始下手,可提供程序问题解答,程序流程清晰明了,注释完整
- MATLAB代码:考虑P2G与碳捕集机组的多能微网低碳经济调度 关键词:碳交易 阶梯碳交易 碳捕集 多能微网 低碳调度 仿真平台:MATLAB+yalmip+cplex 主要内容:代码主要做的是一个
- 本程序采用matlab编写,主要是实现电流注入型牛拉法 除此之外,本人还编写了很多种关于潮流计算的程序,主要有牛拉法,前推回代法,以还有相和三相潮流计算程序
- 智能门锁架构图,供大家参考
- 三菱FX3U六轴标准程序,程序包含本体3轴控制,扩展3个1PG定位模块,一共六轴 程序有轴点动控制,回零控制,相对定位,绝对定位 另有气缸数个,一个大是DD马达控制的转盘,整个是转盘多工位流水作业
- 批量登录到远程Linux服务器检查服务器时间差的shell
- MATLAB电动车七自由度整车模型 MATLAB Simulink电动车转弯制动abs模型asr转弯制动防抱死abs模型+模糊控制算法+七自由度整车模型+纵向运动+侧向运动+横摆运动+四轮魔术公式+四
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈