——————————DescriptionStart——————————
运行环境 Java≥8、MySQL≥5.7
开发工具 eclipse/idea/myeclipse/sts等均可配置运行
适用 课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot化妆品商城系统(java+springboot+ssm+mysql+jsp+maven)
1 2 3 4 5 6 7 8 后台管理: admin 123456 前台: user1 123456 user2 123456 user3 123456
前台用户: 注册、登录、个人信息修改、商品浏览、商品查询、详情查询、立即购买、购物车管理、结算支付、订单查看、收货评价等等
后台管理员: 查询统计、产品管理、分类管理、用户管理、订单管理及发货、评价管理、信息修改等等。
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 } } package com.xq.tmall.controller.fore;@Controller public class ForeRewardController extends BaseController { @Resource(name = "rewardService") private RewardService rewardService; @Resource(name = "userService") private UserService userService; @ResponseBody @RequestMapping(value = "reward/add", method = RequestMethod.POST, produces = "application/json;charset=utf-8") public String addReward (HttpSession session, @RequestParam String name, @RequestParam String message) { JSONObject jsonObject = new JSONObject(); logger.info("检查用户是否登录" ); Object userId = checkUser(session); User user; if (userId == null ) { userId = 0 ; } logger.info("整合打赏信息" ); Reward reward = new Reward() .setReward_name(name) .setReward_content(message) .setReward_state(0 ) .setReward_amount(0.00 ) .setReward_createDate(new Date())
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 Product product = productService.get(orderItem_product_id); if (product == null ) { object.put("success" , false ); object.put("url" , "/" ); return object.toJSONString(); } if (product.getProduct_stock_count()<orderItem_number) { object.put("success" , false ); object.put("url" , "/not" ); return object.toJSONString(); } logger.info("将收货地址等相关信息存入Cookie中,便于下次使用" ); Cookie[] cookies = new Cookie[]{ new Cookie("addressId" , addressId), new Cookie("cityAddressId" , cityAddressId), new Cookie("districtAddressId" , districtAddressId), new Cookie("order_post" , URLEncoder.encode(productOrder_post, "UTF-8" )), new Cookie("order_receiver" , URLEncoder.encode(productOrder_receiver, "UTF-8" )), new Cookie("order_phone" , URLEncoder.encode(productOrder_mobile, "UTF-8" )), new Cookie("detailsAddress" , URLEncoder.encode(productOrder_detail_address, "UTF-8" )) }; int maxAge = 60 * 60 * 24 * 365 ; for (Cookie cookie : cookies){ cookie.setMaxAge(maxAge); response.addCookie(cookie); } StringBuffer productOrder_code = new StringBuffer() .append(new SimpleDateFormat("yyyyMMddHHmmss" ).format(new Date())) .append(0 ) .append(userId); logger.info("生成的订单号为:{}" , productOrder_code); logger.info("整合订单对象" ); ProductOrder productOrder = new ProductOrder() .setProductOrder_status((byte ) 0 ) .setProductOrder_address(new Address().setAddress_areaId(districtAddressId)) .setProductOrder_post(productOrder_post) .setProductOrder_user(new User().setUser_id(Integer.valueOf(userId.toString()))) .setProductOrder_mobile(productOrder_mobile) .setProductOrder_receiver(productOrder_receiver) .setProductOrder_detail_address(productOrder_detail_address) .setProductOrder_pay_date(new Date()) .setProductOrder_code(productOrder_code.toString()); Boolean yn = productOrderService.add(productOrder);
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 @PathVariable("category_id") Integer category_id) { JSONObject jsonObject = new JSONObject(); logger.info("整合分类信息" ); Category category = new Category() .setCategory_id(category_id) .setCategory_name(category_name) .setCategory_image_src(category_image_src.substring(category_image_src.lastIndexOf("/" ) + 1 )); logger.info("更新分类信息,分类ID值为:{}" , category_id); boolean yn = categoryService.update(category); if (yn) { logger.info("更新成功!" ); jsonObject.put("success" , true ); jsonObject.put("category_id" , category_id); } else { jsonObject.put("success" , false ); logger.info("更新失败!事务回滚" ); throw new RuntimeException(); } return jsonObject.toJSONString(); } @ResponseBody @RequestMapping(value = "admin/category/{index}/{count}", method = RequestMethod.GET, produces = "application/json;charset=utf-8") public String getCategoryBySearch (@RequestParam(required = false) String category_name, @PathVariable Integer index, @PathVariable Integer count) throws UnsupportedEncodingException { if (category_name != null ) { category_name = "" .equals(category_name) ? null : URLDecoder.decode(category_name, "UTF-8" ); } JSONObject object = new JSONObject(); logger.info("按条件获取第{}页的{}条分类" , index + 1 , count); PageUtil pageUtil = new PageUtil(index, count); List<Category> categoryList = categoryService.getList(category_name, pageUtil); object.put("categoryList" , JSONArray.parseArray(JSON.toJSONString(categoryList))); logger.info("按条件获取分类总数量" ); Integer categoryCount = categoryService.getTotal(category_name); object.put("categoryCount" , categoryCount); logger.info("获取分页信息" ); pageUtil.setTotal(categoryCount); object.put("totalPage" , pageUtil.getTotalPage()); object.put("pageUtil" , pageUtil);
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 for (Property property : propertyList) { for (PropertyValue propertyValue : propertyValueList) { if (property.getProperty_id().equals(propertyValue.getPropertyValue_property().getProperty_id())) { List<PropertyValue> property_value_item = new ArrayList<>(1 ); property_value_item.add(propertyValue); property.setPropertyValueList(property_value_item); break ; } } } JSONObject jsonObject = new JSONObject(); jsonObject.put("propertyList" , JSONArray.parseArray(JSON.toJSONString(propertyList))); return jsonObject.toJSONString(); } @ResponseBody @RequestMapping(value = "guess/{cid}", method = RequestMethod.GET, produces = "application/json;charset=utf-8") public String guessYouLike (@PathVariable("cid") Integer cid, @RequestParam Integer guessNumber) { logger.info("获取猜你喜欢列表" ); Integer total = productService.getTotal(new Product().setProduct_category(new Category().setCategory_id(cid)), new Byte[]{0 , 2 }); logger.info("分类ID为{}的产品总数为{}条" , cid, total); int i = new Random().nextInt(total); if (i + 2 >= total) { i = total - 3 ; } if (i < 0 ) { i = 0 ; } while (i == guessNumber) { i = new Random().nextInt(total); if (i + 2 >= total) { i = total - 3 ; } if (i < 0 ) { i = 0 ; break ; } } logger.info("guessNumber值为{},新guessNumber值为{}" , guessNumber, i); List<Product> loveProductList = productService.getList(new Product().setProduct_category( new Category().setCategory_id(cid)), new Byte[]{0 , 2 },
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 ); } logger.info("共有{}条产品预览图片数据" , productImageList.size()); yn = productImageService.addList(productImageList); if (yn) { logger.info("产品预览图片添加成功!" ); } else { logger.warn("产品预览图片添加失败!事务回滚" ); jsonObject.put("success" , false ); throw new RuntimeException(); } } if (productDetailsImageList != null && productDetailsImageList.length > 0 ) { logger.info("整合产品子信息-产品详情图片" ); List<ProductImage> productImageList = new ArrayList<>(5 ); for (String imageName : productDetailsImageList) { productImageList.add(new ProductImage() .setProductImage_type((byte ) 1 ) .setProductImage_src(imageName.substring(imageName.lastIndexOf("/" ) + 1 )) .setProductImage_product(product) ); } logger.info("共有{}条产品详情图片数据" , productImageList.size()); yn = productImageService.addList(productImageList); if (yn) { logger.info("产品详情图片添加成功!" ); } else { logger.warn("产品详情图片添加失败!事务回滚" ); jsonObject.put("success" , false ); throw new RuntimeException(); } } jsonObject.put("success" , true ); jsonObject.put("product_id" , product_id); return jsonObject.toJSONString(); } @ResponseBody @RequestMapping(value = "admin/product/{index}/{count}", method = RequestMethod.GET, produces = "application/json;charset=utf-8") public String getProductBySearch (@RequestParam(required = false) String product_name, @RequestParam(required = false) Integer category_id, @RequestParam(required = false) Double product_sale_price, @RequestParam(required = false) Double product_price, @RequestParam(required = false) Byte[] product_isEnabled_array, @RequestParam(required = false) String orderBy, @RequestParam(required = false,defaultValue = "true") Boolean isDesc,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 Category category = categoryService.get(cid); logger.info("获取分类子信息-属性列表" ); category.setPropertyList(propertyService.getList(new Property().setProperty_category(category), null )); map.put("category" , category); logger.info("转到后台管理-分类详情页-ajax方式" ); return "admin/include/categoryDetails" ; } @RequestMapping(value = "admin/category/new", method = RequestMethod.GET) public String goToAddPage (HttpSession session, Map<String, Object> map) { logger.info("转到后台管理-分类添加页-ajax方式" ); return "admin/include/categoryDetails" ; } @ResponseBody @RequestMapping(value = "admin/category", method = RequestMethod.POST, produces = "application/json;charset=utf-8") public String addCategory (@RequestParam String category_name, @RequestParam String category_image_src) { JSONObject jsonObject = new JSONObject(); logger.info("整合分类信息" ); Category category = new Category() .setCategory_name(category_name) .setCategory_image_src(category_image_src.substring(category_image_src.lastIndexOf("/" ) + 1 )); logger.info("添加分类信息" ); boolean yn = categoryService.add(category); if (yn) { int category_id = lastIDService.selectLastID(); logger.info("添加成功!,新增分类的ID值为:{}" , category_id); jsonObject.put("success" , true ); jsonObject.put("category_id" , category_id); } else { jsonObject.put("success" , false ); logger.warn("添加失败!事务回滚" ); throw new RuntimeException(); } return jsonObject.toJSONString(); } @ResponseBody @RequestMapping(value = "admin/category/{category_id}", method = RequestMethod.PUT, produces = "application/json;charset=utf-8") public String updateCategory (@RequestParam String category_name,
——————————PayStart——————————
项目链接: https://javayms.github.io?id=041422312105200hm https://javayms.pages.dev?id=041422312105200hm