基于javaweb+mysql的springboot网上商城系统设计和实现(java+springboot+ssm+mysql+thymeleaf+html+maven)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot网上商城系统设计和实现(java+springboot+ssm+mysql+thymeleaf+html+maven)
一、项目简述
本系统主要实现的功能有: OnlineMall项目是一套电商系统,包括OnlineMall商城系 统及OnlineMall商城后台管理^统,基于Spring Boot 2.X 及相关技术栈开发。前台商城系统包含首页门户、商品分 类、新品上线、首页轮播、商品推荐、商品搜索、商品展 示、购物车、订单结算、订单流程、个人订单管理、会员 中心、帮助中心等模块。后台管理系统包含数据面板、轮 播图管理、商品管理、订单管理、会员管理、分类管理、 设置等模块。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: Springboot+ SpringMVC + MyBatis + ThymeLeaf + JavaScript + JQuery + Ajax + maven等等
if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult(result);
}
}
/**
* 出库
*/
@RequestMapping(value = "/orders/checkOut", method = RequestMethod.POST)
@ResponseBody
public Result checkOut(@RequestBody Long[] ids) {
if (ids.length < 1) {
return ResultGenerator.genFailResult("参数异常!");
}
String result = newBeeMallOrderService.checkOut(ids);
if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult(result);
}
}
/**
* 关闭订单
*/
@RequestMapping(value = "/orders/close", method = RequestMethod.POST)
@ResponseBody
public Result closeOrder(@RequestBody Long[] ids) {
if (ids.length < 1) {
return ResultGenerator.genFailResult("参数异常!");
}
String result = newBeeMallOrderService.closeOrder(ids);
if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult(result);
}
}
@PutMapping("/orders/{orderNo}/finish")
@ResponseBody
public Result finishOrder(@PathVariable("orderNo") String orderNo, HttpSession httpSession) {
NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);
String finishOrderResult = newBeeMallOrderService.finishOrder(orderNo, user.getUserId());
if (ServiceResultEnum.SUCCESS.getResult().equals(finishOrderResult)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult(finishOrderResult);
}
}
@GetMapping("/selectPayType")
public String selectPayType(HttpServletRequest request, @RequestParam("orderNo") String orderNo, HttpSession httpSession) {
NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);
NewBeeMallOrder newBeeMallOrder = newBeeMallOrderService.getNewBeeMallOrderByOrderNo(orderNo);
//todo 判断订单userId
//todo 判断订单状态
request.setAttribute("orderNo", orderNo);
request.setAttribute("totalPrice", newBeeMallOrder.getTotalPrice());
return "mall/pay-select";
}
@GetMapping("/payPage")
public String payOrder(HttpServletRequest request, @RequestParam("orderNo") String orderNo, HttpSession httpSession, @RequestParam("payType") int payType) {
NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);
NewBeeMallOrder newBeeMallOrder = newBeeMallOrderService.getNewBeeMallOrderByOrderNo(orderNo);
//todo 判断订单userId
//todo 判断订单状态
request.setAttribute("orderNo", orderNo);
request.setAttribute("totalPrice", newBeeMallOrder.getTotalPrice());
if (payType == 1) {
return "mall/alipay";
} else {
return "mall/wxpay";
}
}
@GetMapping("/paySuccess")
@ResponseBody
public Result paySuccess(@RequestParam("orderNo") String orderNo, @RequestParam("payType") int payType) {
String payResult = newBeeMallOrderService.paySuccess(orderNo, payType);
if (ServiceResultEnum.SUCCESS.getResult().equals(payResult)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult(payResult);
}
}
}
}
/**
* 购物车数量处理
*
*/
@Component
public class NewBeeMallCartNumberInterceptor implements HandlerInterceptor {
@Autowired
private NewBeeMallShoppingCartItemMapper newBeeMallShoppingCartItemMapper;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
//购物车中的数量会更改,但是在这些接口中并没有对session中的数据做修改,这里统一处理一下
if (null != request.getSession() && null != request.getSession().getAttribute(Constants.MALL_USER_SESSION_KEY)) {
//如果当前为登陆状态,就查询数据库并设置购物车中的数量值
NewBeeMallUserVO newBeeMallUserVO = (NewBeeMallUserVO) request.getSession().getAttribute(Constants.MALL_USER_SESSION_KEY);
//设置购物车中的数量
newBeeMallUserVO.setShopCartItemCount(newBeeMallShoppingCartItemMapper.selectCountByUserId(newBeeMallUserVO.getUserId()));
request.getSession().setAttribute(Constants.MALL_USER_SESSION_KEY, newBeeMallUserVO);
}
return true;
}
@Override
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
}
} else {
return "修改失败";
}
}
@GetMapping("/logout")
public String logout(HttpServletRequest request) {
request.getSession().removeAttribute("loginUserId");
request.getSession().removeAttribute("loginUser");
request.getSession().removeAttribute("errorMsg");
return "admin/login";
}
}
@Controller
public class PersonalController {
@Resource
private NewBeeMallUserService newBeeMallUserService;
@GetMapping("/personal")
public String personalPage(HttpServletRequest request,
HttpSession httpSession) {
request.setAttribute("path", "personal");
return "mall/personal";
}
@GetMapping("/logout")
public String logout(HttpSession httpSession) {
httpSession.removeAttribute(Constants.MALL_USER_SESSION_KEY);
* 详情
*/
@GetMapping("/indexConfigs/info/{id}")
@ResponseBody
public Result info(@PathVariable("id") Long id) {
IndexConfig config = newBeeMallIndexConfigService.getIndexConfigById(id);
if (config == null) {
return ResultGenerator.genFailResult("未查询到数据");
}
return ResultGenerator.genSuccessResult(config);
}
/**
* 删除
*/
@RequestMapping(value = "/indexConfigs/delete", method = RequestMethod.POST)
@ResponseBody
public Result delete(@RequestBody Long[] ids) {
if (ids.length < 1) {
return ResultGenerator.genFailResult("参数异常!");
}
if (newBeeMallIndexConfigService.deleteBatch(ids)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult("删除失败");
}
}
}
}
String result = newBeeMallOrderService.closeOrder(ids);
if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult(result);
}
}
}
/**
*/
@Controller
@RequestMapping("/admin")
public class NewBeeMallGoodsIndexConfigController {
@Resource
private NewBeeMallIndexConfigService newBeeMallIndexConfigService;
@GetMapping("/indexConfigs")
public String indexConfigsPage(HttpServletRequest request, @RequestParam("configType") int configType) {
IndexConfigTypeEnum indexConfigTypeEnum = IndexConfigTypeEnum.getIndexConfigTypeEnumByType(configType);
if (indexConfigTypeEnum.equals(IndexConfigTypeEnum.DEFAULT)) {
return "error/error_5xx";
}
request.setAttribute("path", indexConfigTypeEnum.getName());
request.setAttribute("configType", configType);
return "admin/newbee_mall_index_config";
}
return ResultGenerator.genFailResult(ServiceResultEnum.LOGIN_NAME_NULL.getResult());
}
if (StringUtils.isEmpty(password)) {
return ResultGenerator.genFailResult(ServiceResultEnum.LOGIN_PASSWORD_NULL.getResult());
}
if (StringUtils.isEmpty(verifyCode)) {
return ResultGenerator.genFailResult(ServiceResultEnum.LOGIN_VERIFY_CODE_NULL.getResult());
}
String kaptchaCode = httpSession.getAttribute(Constants.MALL_VERIFY_CODE_KEY) + "";
if (StringUtils.isEmpty(kaptchaCode) || !verifyCode.equals(kaptchaCode)) {
return ResultGenerator.genFailResult(ServiceResultEnum.LOGIN_VERIFY_CODE_ERROR.getResult());
}
//todo 清verifyCode
String registerResult = newBeeMallUserService.register(loginName, password);
//注册成功
if (ServiceResultEnum.SUCCESS.getResult().equals(registerResult)) {
return ResultGenerator.genSuccessResult();
}
//注册失败
return ResultGenerator.genFailResult(registerResult);
}
@PostMapping("/personal/updateInfo")
@ResponseBody
public Result updateInfo(@RequestBody MallUser mallUser, HttpSession httpSession) {
NewBeeMallUserVO mallUserTemp = newBeeMallUserService.updateUserInfo(mallUser, httpSession);
if (mallUserTemp == null) {
Result result = ResultGenerator.genFailResult("修改失败");
return result;
} else {
//返回成功
Result result = ResultGenerator.genSuccessResult();
return result;
}
}
}
return new ModelAndView("error/error_400");
} else if (HttpStatus.NOT_FOUND == status) {
return new ModelAndView("error/error_404");
} else {
return new ModelAndView("error/error_5xx");
}
}
@RequestMapping(value = ERROR_PATH)
@ResponseBody
public ResponseEntity<Map<String, Object>> error(HttpServletRequest request) {
Map<String, Object> body = getErrorAttributes(request, getTraceParameter(request));
HttpStatus status = getStatus(request);
return new ResponseEntity<Map<String, Object>>(body, status);
}
@Override
public String getErrorPath() {
return ERROR_PATH;
}
private boolean getTraceParameter(HttpServletRequest request) {
String parameter = request.getParameter("trace");
if (parameter == null) {
return false;
}
return !"false".equals(parameter.toLowerCase());
}
protected Map<String, Object> getErrorAttributes(HttpServletRequest request, boolean includeStackTrace) {
WebRequest webRequest = new ServletWebRequest(request);
return this.errorAttributes.getErrorAttributes(webRequest, includeStackTrace);
}
private HttpStatus getStatus(HttpServletRequest request) {
Integer statusCode = (Integer) request
.getAttribute("javax.servlet.error.status_code");
if (statusCode != null) {
try {
return HttpStatus.valueOf(statusCode);
} catch (Exception ex) {
}
}
return HttpStatus.INTERNAL_SERVER_ERROR;
}
if (newBeeMallIndexConfigService.deleteBatch(ids)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult("删除失败");
}
}
}
/**
*/
@Controller
public class CommonController {
@Autowired
private DefaultKaptcha captchaProducer;
@GetMapping("/common/kaptcha")
public void defaultKaptcha(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
byte[] captchaOutputStream = null;
ByteArrayOutputStream imgOutputStream = new ByteArrayOutputStream();
try {
//生产验证码字符串并保存到session中
String verifyCode = captchaProducer.createText();
httpServletRequest.getSession().setAttribute("verifyCode", verifyCode);
BufferedImage challenge = captchaProducer.createImage(verifyCode);
ImageIO.write(challenge, "jpg", imgOutputStream);
} catch (IllegalArgumentException e) {
httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
captchaOutputStream = imgOutputStream.toByteArray();
httpServletResponse.setHeader("Cache-Control", "no-store");
@Controller
public class ErrorPageController implements ErrorController {
private static ErrorPageController errorPageController;
@Autowired
private ErrorAttributes errorAttributes;
private final static String ERROR_PATH = "/error";
public ErrorPageController(ErrorAttributes errorAttributes) {
this.errorAttributes = errorAttributes;
}
public ErrorPageController() {
if (errorPageController == null) {
errorPageController = new ErrorPageController(errorAttributes);
}
}
@RequestMapping(value = ERROR_PATH, produces = "text/html")
public ModelAndView errorHtml(HttpServletRequest request) {
HttpStatus status = getStatus(request);
if (HttpStatus.BAD_REQUEST == status) {
return new ModelAndView("error/error_400");
} else if (HttpStatus.NOT_FOUND == status) {
return new ModelAndView("error/error_404");
} else {
return new ModelAndView("error/error_5xx");
}
}
@RequestMapping(value = ERROR_PATH)
@ResponseBody
public ResponseEntity<Map<String, Object>> error(HttpServletRequest request) {
Map<String, Object> body = getErrorAttributes(request, getTraceParameter(request));
HttpStatus status = getStatus(request);
return new ResponseEntity<Map<String, Object>>(body, status);
}
@Override
public String getErrorPath() {
return ERROR_PATH;
* 添加
*/
@RequestMapping(value = "/indexConfigs/save", method = RequestMethod.POST)
@ResponseBody
public Result save(@RequestBody IndexConfig indexConfig) {
if (Objects.isNull(indexConfig.getConfigType())
|| StringUtils.isEmpty(indexConfig.getConfigName())
|| Objects.isNull(indexConfig.getConfigRank())) {
return ResultGenerator.genFailResult("参数异常!");
}
String result = newBeeMallIndexConfigService.saveIndexConfig(indexConfig);
if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult(result);
}
}
/**
* 修改
*/
@RequestMapping(value = "/indexConfigs/update", method = RequestMethod.POST)
@ResponseBody
public Result update(@RequestBody IndexConfig indexConfig) {
if (Objects.isNull(indexConfig.getConfigType())
|| Objects.isNull(indexConfig.getConfigId())
|| StringUtils.isEmpty(indexConfig.getConfigName())
|| Objects.isNull(indexConfig.getConfigRank())) {
return ResultGenerator.genFailResult("参数异常!");
}
String result = newBeeMallIndexConfigService.updateIndexConfig(indexConfig);
if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult(result);
}
}
/**
* 详情
*/
@GetMapping("/indexConfigs/info/{id}")
@ResponseBody
public Result info(@PathVariable("id") Long id) {
IndexConfig config = newBeeMallIndexConfigService.getIndexConfigById(id);
if (config == null) {
return "mall/pay-select";
}
@GetMapping("/payPage")
public String payOrder(HttpServletRequest request, @RequestParam("orderNo") String orderNo, HttpSession httpSession, @RequestParam("payType") int payType) {
NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);
NewBeeMallOrder newBeeMallOrder = newBeeMallOrderService.getNewBeeMallOrderByOrderNo(orderNo);
//todo 判断订单userId
//todo 判断订单状态
request.setAttribute("orderNo", orderNo);
request.setAttribute("totalPrice", newBeeMallOrder.getTotalPrice());
if (payType == 1) {
return "mall/alipay";
} else {
return "mall/wxpay";
}
}
@GetMapping("/paySuccess")
@ResponseBody
public Result paySuccess(@RequestParam("orderNo") String orderNo, @RequestParam("payType") int payType) {
String payResult = newBeeMallOrderService.paySuccess(orderNo, payType);
if (ServiceResultEnum.SUCCESS.getResult().equals(payResult)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult(payResult);
}
}
}
PageResult pageResult = new PageResult(mallUsers, total, pageUtil.getLimit(), pageUtil.getPage());
return pageResult;
}
@Override
public String register(String loginName, String password) {
if (mallUserMapper.selectByLoginName(loginName) != null) {
return ServiceResultEnum.SAME_LOGIN_NAME_EXIST.getResult();
}
MallUser registerUser = new MallUser();
registerUser.setLoginName(loginName);
registerUser.setNickName(loginName);
String passwordMD5 = MD5Util.MD5Encode(password, "UTF-8");
registerUser.setPasswordMd5(passwordMD5);
if (mallUserMapper.insertSelective(registerUser) > 0) {
return ServiceResultEnum.SUCCESS.getResult();
}
return ServiceResultEnum.DB_ERROR.getResult();
}
@Override
public String login(String loginName, String passwordMD5, HttpSession httpSession) {
MallUser user = mallUserMapper.selectByLoginNameAndPasswd(loginName, passwordMD5);
if (user != null && httpSession != null) {
if (user.getLockedFlag() == 1) {
return ServiceResultEnum.LOGIN_USER_LOCKED.getResult();
}
//昵称太长 影响页面展示
if (user.getNickName() != null && user.getNickName().length() > 7) {
String tempNickName = user.getNickName().substring(0, 7) + "..";
user.setNickName(tempNickName);
}
NewBeeMallUserVO newBeeMallUserVO = new NewBeeMallUserVO();
BeanUtil.copyProperties(user, newBeeMallUserVO);
//设置购物车中的数量
httpSession.setAttribute(Constants.MALL_USER_SESSION_KEY, newBeeMallUserVO);
return ServiceResultEnum.SUCCESS.getResult();
}
return ServiceResultEnum.LOGIN_ERROR.getResult();
}
@Override
public NewBeeMallUserVO updateUserInfo(MallUser mallUser, HttpSession httpSession) {
MallUser user = mallUserMapper.selectByPrimaryKey(mallUser.getUserId());
if (user != null) {
user.setNickName(mallUser.getNickName());
user.setAddress(mallUser.getAddress());
user.setIntroduceSign(mallUser.getIntroduceSign());
if (category.getCategoryLevel() == NewBeeMallCategoryLevelEnum.LEVEL_ONE.getLevel()) {
//如果是一级分类则返回当前一级分类下的所有二级分类,以及二级分类列表中第一条数据下的所有三级分类列表
//查询一级分类列表中第一个实体的所有二级分类
List<GoodsCategory> secondLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(categoryId), NewBeeMallCategoryLevelEnum.LEVEL_TWO.getLevel());
if (!CollectionUtils.isEmpty(secondLevelCategories)) {
//查询二级分类列表中第一个实体的所有三级分类
List<GoodsCategory> thirdLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(secondLevelCategories.get(0).getCategoryId()), NewBeeMallCategoryLevelEnum.LEVEL_THREE.getLevel());
categoryResult.put("secondLevelCategories", secondLevelCategories);
categoryResult.put("thirdLevelCategories", thirdLevelCategories);
}
}
if (category.getCategoryLevel() == NewBeeMallCategoryLevelEnum.LEVEL_TWO.getLevel()) {
//如果是二级分类则返回当前分类下的所有三级分类列表
List<GoodsCategory> thirdLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(categoryId), NewBeeMallCategoryLevelEnum.LEVEL_THREE.getLevel());
categoryResult.put("thirdLevelCategories", thirdLevelCategories);
}
return ResultGenerator.genSuccessResult(categoryResult);
}
/**
* 添加
*/
@RequestMapping(value = "/categories/save", method = RequestMethod.POST)
@ResponseBody
public Result save(@RequestBody GoodsCategory goodsCategory) {
if (Objects.isNull(goodsCategory.getCategoryLevel())
|| StringUtils.isEmpty(goodsCategory.getCategoryName())
|| Objects.isNull(goodsCategory.getParentId())
|| Objects.isNull(goodsCategory.getCategoryRank())) {
return ResultGenerator.genFailResult("参数异常!");
}
String result = newBeeMallCategoryService.saveCategory(goodsCategory);
if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult(result);
}
}
/**
* 修改
*/
@RequestMapping(value = "/categories/update", method = RequestMethod.POST)
@ResponseBody
public Result update(@RequestBody GoodsCategory goodsCategory) {
if (Objects.isNull(goodsCategory.getCategoryId())
|| Objects.isNull(goodsCategory.getCategoryLevel())
|| StringUtils.isEmpty(goodsCategory.getCategoryName())
|| Objects.isNull(goodsCategory.getParentId())
/**
*/
@Controller
@RequestMapping("/admin")
public class NewBeeMallGoodsCategoryController {
@Resource
private NewBeeMallCategoryService newBeeMallCategoryService;
@GetMapping("/categories")
public String categoriesPage(HttpServletRequest request, @RequestParam("categoryLevel") Byte categoryLevel, @RequestParam("parentId") Long parentId, @RequestParam("backParentId") Long backParentId) {
if (categoryLevel == null || categoryLevel < 1 || categoryLevel > 3) {
return "error/error_5xx";
}
request.setAttribute("path", "newbee_mall_category");
request.setAttribute("parentId", parentId);
request.setAttribute("backParentId", backParentId);
request.setAttribute("categoryLevel", categoryLevel);
return "admin/newbee_mall_category";
}
/**
* 列表
*/
@RequestMapping(value = "/categories/list", method = RequestMethod.GET)
@ResponseBody
public Result list(@RequestParam Map<String, Object> params) {
if (StringUtils.isEmpty(params.get("page")) || StringUtils.isEmpty(params.get("limit"))) {
return ResultGenerator.genFailResult("参数异常!");
}
PageQueryUtil pageUtil = new PageQueryUtil(params);
return ResultGenerator.genSuccessResult(newBeeMallCategoryService.getCategorisPage(pageUtil));
//无收货地址
NewBeeMallException.fail(ServiceResultEnum.NULL_ADDRESS_ERROR.getResult());
}
if (CollectionUtils.isEmpty(myShoppingCartItems)) {
//购物车中无数据则跳转至错误页
NewBeeMallException.fail(ServiceResultEnum.SHOPPING_ITEM_ERROR.getResult());
}
//保存订单并返回订单号
String saveOrderResult = newBeeMallOrderService.saveOrder(user, myShoppingCartItems);
//跳转到订单详情页
return "redirect:/orders/" + saveOrderResult;
}
@PutMapping("/orders/{orderNo}/cancel")
@ResponseBody
public Result cancelOrder(@PathVariable("orderNo") String orderNo, HttpSession httpSession) {
NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);
String cancelOrderResult = newBeeMallOrderService.cancelOrder(orderNo, user.getUserId());
if (ServiceResultEnum.SUCCESS.getResult().equals(cancelOrderResult)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult(cancelOrderResult);
}
}
@PutMapping("/orders/{orderNo}/finish")
@ResponseBody
public Result finishOrder(@PathVariable("orderNo") String orderNo, HttpSession httpSession) {
NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);
String finishOrderResult = newBeeMallOrderService.finishOrder(orderNo, user.getUserId());
if (ServiceResultEnum.SUCCESS.getResult().equals(finishOrderResult)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult(finishOrderResult);
}
}
@GetMapping("/selectPayType")
public String selectPayType(HttpServletRequest request, @RequestParam("orderNo") String orderNo, HttpSession httpSession) {
NewBeeMallUserVO user = (NewBeeMallUserVO) httpSession.getAttribute(Constants.MALL_USER_SESSION_KEY);
NewBeeMallOrder newBeeMallOrder = newBeeMallOrderService.getNewBeeMallOrderByOrderNo(orderNo);
/**
*/
@Controller
@RequestMapping("/admin")
public class NewBeeMallOrderController {
@Resource
private NewBeeMallOrderService newBeeMallOrderService;
@GetMapping("/orders")
public String ordersPage(HttpServletRequest request) {
request.setAttribute("path", "orders");
return "admin/newbee_mall_order";
}
/**
* 列表
*/
@RequestMapping(value = "/orders/list", method = RequestMethod.GET)
@ResponseBody
public Result list(@RequestParam Map<String, Object> params) {
if (StringUtils.isEmpty(params.get("page")) || StringUtils.isEmpty(params.get("limit"))) {
return ResultGenerator.genFailResult("参数异常!");
}
PageQueryUtil pageUtil = new PageQueryUtil(params);
return ResultGenerator.genSuccessResult(newBeeMallOrderService.getNewBeeMallOrdersPage(pageUtil));
}
/**
* 修改
*/
@RequestMapping(value = "/orders/update", method = RequestMethod.POST)
@ResponseBody
public Result update(@RequestBody NewBeeMallOrder newBeeMallOrder) {
if (Objects.isNull(newBeeMallOrder.getTotalPrice())
|| Objects.isNull(newBeeMallOrder.getOrderId())
|| newBeeMallOrder.getOrderId() < 1
|| newBeeMallOrder.getTotalPrice() < 1
|| StringUtils.isEmpty(newBeeMallOrder.getUserAddress())) {
return ResultGenerator.genFailResult("参数异常!");
return ResultGenerator.genFailResult(result);
}
}
/**
* 详情
*/
@GetMapping("/categories/info/{id}")
@ResponseBody
public Result info(@PathVariable("id") Long id) {
GoodsCategory goodsCategory = newBeeMallCategoryService.getGoodsCategoryById(id);
if (goodsCategory == null) {
return ResultGenerator.genFailResult("未查询到数据");
}
return ResultGenerator.genSuccessResult(goodsCategory);
}
/**
* 分类删除
*/
@RequestMapping(value = "/categories/delete", method = RequestMethod.POST)
@ResponseBody
public Result delete(@RequestBody Integer[] ids) {
if (ids.length < 1) {
return ResultGenerator.genFailResult("参数异常!");
}
if (newBeeMallCategoryService.deleteBatch(ids)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult("删除失败");
}
}
}