源码获取:博客首页 "资源" 里下载!
一、项目简述
本系统功能包括: 一款基于Springboot+Vue的电商项目,前后端分离项目,前台后台都有,前台商品展示购买,购物车分类,订 单查询等等,后台商品管理,订单管理,信息维护,用户管理等等。本期源码免费,部分bug小辰已经处理完毕, 可放心下载,关注小辰哥的Java微信号,点击右下角联系我们加群即可,已发送到群文件,贡多资源优先发布微信号。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX (Webstorm也 行)+ Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts都支 持)。
项目技术: Springboot + Maven + Mybatis + Vue + Redis, B/S 模式+ Maven等等,附带支付宝沙箱环境以及支付环节代码。
订单相关业务:
/*** @description 订单相关业务*/@RestController@CrossOriginpublic class OrderController {final OrderService orderService;final ProductService productService;final LogisticsService logisticsService;final RedisTemplate<String,String> redisTemplate;public OrderController(RedisTemplate<String,String> redisTemplate,OrderService orderService,LogisticsService logisticsService,ProductService productService) {this.orderService = orderService;this.productService = productService;this.logisticsService = logisticsService;this.redisTemplate = redisTemplate;}@RequestMapping(value = "/order/findById")private CommonResult findOrderById(Integer orderId) {Order order= orderService.selectById(orderId);if(orderId!=null){return CommonResult.success("订单信息查询成功",order);}else{return CommonResult.error("订单信息查询失败");}}@RequestMapping(value = "/order/findOrderInfo")private CommonResult findOrderInfo(String userAccount) {List<Map<String, Object>> orderMap = orderService.selectAllOrder(userAccount);if(orderMap!=null){return CommonResult.success("订单信息查询成功",orderMap);}else{return CommonResult.error("订单信息查询失败");}}@RequestMapping(value = "/order/findAll")private CommonResult findAllOrder() {List<Order> orders = orderService.selectAll();System.out.println(orders);if(orders!=null){return CommonResult.success("订单信息查询成功",orders);}else{return CommonResult.error("订单信息查询失败");}}@RequestMapping(value = "/order/findCount")private CommonResult findCount() {Integer count = orderService.selectCount();if(count!=null){return CommonResult.success("订单数量查询成功",count);}else{return CommonResult.error("订单数量查询失败");}}@RequestMapping(value = "/order/add")private CommonResult addOrder(Order order) {if(order!=null){if(order.getProductNo().contains("Vip")){if(orderService.insertData(order)){return CommonResult.success("创建订单成功",order);}else{return CommonResult.error("创建订单失败");}}else{Product product = productService.selectByKey(order.getProductNo());Integer productStock = product.getProductStock();Integer payAmount = order.getPayAmount();boolean isOk =productStock >= payAmount;if(isOk){Product newProduct = new Product();newProduct.setProductId(product.getProductId());int newStock = productStock - payAmount;newProduct.setProductStock(newStock);newProduct.setIsStockOut(newStock<product.getLowestStock());// 如果库存小于等于0,自动下架newProduct.setIsSale(newStock>0);if(productService.updateById(newProduct)){if(orderService.insertData(order)){redisTemplate.opsForValue().set(order.getOrderNo(),order.getOrderNo(),24, TimeUnit.HOURS);return CommonResult.success("创建订单成功",order);}else{return CommonResult.error("创建订单失败");}}else{return CommonResult.error("创建订单失败");}}else{return CommonResult.error("商品库存不足");}}}else{return CommonResult.error("订单数据不完整");}}@RequestMapping(value = "/order/cartOrder")private CommonResult cartOrder(String orderNo,String ordersInfo) {JSONArray jsonArray = JSON.parseArray(ordersInfo);List<Order> orders = JSONObject.parseArray(jsonArray.toJSONString(), Order.class);if(orders!=null){ArrayList<String> orderInfo = new ArrayList<>();ArrayList<String> productInfo = new ArrayList<>();for (Order order : orders) {Product product = productService.selectByKey(order.getProductNo());Integer productStock = product.getProductStock();Integer payAmount = order.getPayAmount();boolean isOk =productStock >= payAmount;if(isOk){Product newProduct = new Product();newProduct.setProductId(product.getProductId());int newStock = productStock - payAmount;newProduct.setProductStock(newStock);newProduct.setIsStockOut(newStock<product.getLowestStock());// 如果库存小于等于0,自动下架newProduct.setIsSale(newStock>0);if(productService.updateById(newProduct)){if(orderService.insertData(order)){orderInfo.add(order.getOrderNo());productInfo.add(order.getProductNo());}}}}if(orderInfo.size()!=0){String orderNoInfo = StringUtils.join(orderInfo, ",");String productNoInfo = StringUtils.join(productInfo, ",");redisTemplate.opsForValue().set(orderNo,orderNoInfo,24, TimeUnit.HOURS);return CommonResult.success("创建订单成功",productNoInfo);}else{return CommonResult.success("创建订单失败");}}else{return CommonResult.error("订单数据不完整");}}@RequestMapping(value = "/order/update")private CommonResult updateOrder(Order order) {if(orderService.updateById(order)){return CommonResult.success("修改订单成功",order);}else{return CommonResult.error("修改订单失败");}}@RequestMapping(value = "/order/delete")private CommonResult deleteOrder(Integer orderId) {if(orderService.deleteById(orderId)){return CommonResult.success("删除订单成功","订单id:"+orderId);}else{return CommonResult.error("删除订单失败");}}@RequestMapping(value = "/order/receipt")private CommonResult updateOrder(Integer orderId) {Order order = new Order();order.setOrderId(orderId);order.setOrderState("已收货");if(orderService.updateById(order)){return CommonResult.success("商品收货成功",order);}else{return CommonResult.error("商品收货失败");}}@RequestMapping(value = "/orderDetail/orderInfo")private CommonResult orderInfo(String orderNo) {ArrayList<Object> resultList = new ArrayList<>();Order order = orderService.selectByKey(orderNo);Logistics logistics = logisticsService.selectOrderNo(orderNo);if(order!=null){resultList.add(order);}if(logistics!=null){resultList.add(logistics);}if(resultList.size()!=0){return CommonResult.success("订单详情查询成功",resultList);}else{return CommonResult.error("订单详情查询失败");}}}
数据分析,商品数量,订单数量等分析业务:
/*** @description 数据分析,商品数量,订单数量等分析业务*/@CrossOrigin@RestControllerpublic class OverViewController {final OrderService orderService;final ProductService productService;final ReturnGoodsService returnGoodsService;public OverViewController(OrderService orderService,ProductService productService,ReturnGoodsService returnGoodsService) {this.orderService = orderService;this.productService = productService;this.returnGoodsService = returnGoodsService;}@RequestMapping(value = "/view/dataInfo")private CommonResult dataInfo() {Map<String, Object> resultMap = new HashMap<>();Map<String, Object> productMap = productService.productOverview();Map<String, Object> orderMap = orderService.orderOverview();Map<String, Object> returnGoodsMap = returnGoodsService.returnGoodsOverview();if(productMap!=null){resultMap.putAll(productMap);}if(orderMap!=null){resultMap.putAll(orderMap);}if(returnGoodsMap!=null){resultMap.putAll(returnGoodsMap);}if(resultMap.size()!=0){return CommonResult.success("查询成功",resultMap);}else{return CommonResult.error("查询失败");}}@RequestMapping(value = "/view/orderChartDATE")private CommonResult orderChartDATE(String startTime,String endTime) {Map<String, Object> data = new HashMap<>();List<Map<String, Object>> lineData = orderService.selectChartDATE(startTime,endTime);List<Map<String, Object>> ringData = orderService.selectProductTypeChart(startTime, endTime);Map<String, Object> countData = orderService.selectCountAndAmount(startTime,endTime);if(lineData.size()!=0){data.put("lineData",lineData);}if(ringData.size()!=0){data.put("ringData",ringData);}if(countData.size()!=0){data.put("countData",countData);}if(data.size()!=0){return CommonResult.success("查询成功",data);}else{return CommonResult.error("查询失败");}}}
商品相关业务:
/*** @description 商品相关业务*/@RestController@CrossOriginpublic class ProductController {final ProductTypeService productTypeService;final ProductBrandService productBrandService;final ProductService productService;public ProductController(ProductService productService, ProductTypeService productTypeService,ProductBrandService productBrandService) {this.productTypeService = productTypeService;this.productBrandService = productBrandService;this.productService = productService;}/*商品类别*/@RequestMapping(value = "/product/findById")private CommonResult findById(Integer productId) {Product product = productService.selectById(productId);if(product!=null){return CommonResult.success("商品查询成功",product);}else{return CommonResult.error("商品查询失败");}}@RequestMapping(value = "/product/findByKey")private CommonResult findByKey(String productNo) {Product product = productService.selectByKey(productNo);if(product!=null){return CommonResult.success("商品查询成功",product);}else{return CommonResult.error("商品查询失败");}}@RequestMapping(value = "/product/findIdByKey")private CommonResult findIdByKey(String productNo) {Integer productId = productService.selectIdByKey(productNo);if(productId!=null){return CommonResult.success("商品id查询成功",productId);}else{return CommonResult.error("商品id查询失败");}}@RequestMapping(value = "/product/findCount")private CommonResult findCount() {Integer count = productService.selectCount();if(count!=null){return CommonResult.success("商品数量查询成功",count);}else{return CommonResult.error("商品数量查询失败");}}@RequestMapping(value = "/product/existsKey")private CommonResult existsKey(String productNo) {Boolean isExist = productService.existsWithPrimaryKey(productNo);if(isExist!=null){return CommonResult.success("商品是否存在查询成功",isExist);}else{return CommonResult.error("商品是否存在查询失败");}}@RequestMapping(value = "/product/existsType")private CommonResult existsType(String productType) {Boolean isExist = productService.existsProductType(productType);if(isExist!=null){return CommonResult.success("查询成功",isExist);}else{return CommonResult.error("查询失败");}}@RequestMapping(value = "/product/existsBrand")private CommonResult existsBrand(String productBrand) {Boolean isExist = productService.existsProductBrand(productBrand);if(isExist!=null){return CommonResult.success("查询成功",isExist);}else{return CommonResult.error("查询失败");}}@RequestMapping(value = "/product/findAll")private CommonResult findAll() {List<Product> products = productService.selectAll();if(products!=null){return CommonResult.success("全部商品信息查询成功",products);}else{return CommonResult.error("全部商品信息查询失败");}}@RequestMapping(value = "/product/findAllSale")private CommonResult findAllSale() {List<Product> products = productService.selectAllSale();if(products!=null){return CommonResult.success("全部商品信息查询成功",products);}else{return CommonResult.error("全部商品信息查询失败");}}@RequestMapping(value = "/product/findAllLikeName")private CommonResult findAllLikeName(String keyWord) {List<Product> products = productService.selectAllLikeName(keyWord);if(products!=null){return CommonResult.success("全部商品信息查询成功",products);}else{return CommonResult.error("全部商品信息查询失败");}}@RequestMapping(value = "/product/findAllLikeType")private CommonResult findAllLikeType(String keyWord) {List<Product> products = productService.selectAllLikeType(keyWord);if(products!=null){return CommonResult.success("全部商品信息查询成功",products);}else{return CommonResult.error("全部商品信息查询失败");}}@RequestMapping(value = "/product/findAllLikeBrand")private CommonResult findAllLikeBrand(String keyWord) {List<Product> products = productService.selectAllLikeBrand(keyWord);if(products!=null){return CommonResult.success("全部商品信息查询成功",products);}else{return CommonResult.error("全部商品信息查询失败");}}@RequestMapping(value = "/product/findAllByType")private CommonResult findAllByType() {List<Map<String, Object>> maps = productService.selectAllByType();if(maps!=null){return CommonResult.success("商品分类信息查询成功",maps);}else{return CommonResult.error("商品分类信息查询失败");}}@RequestMapping(value = "/product/add")private CommonResult add(Product product) {System.out.println(product);if(productService.insertData(product)){return CommonResult.success("添加商品成功",product);}else{return CommonResult.error("添加商品失败");}}@RequestMapping(value = "/product/update")private CommonResult update(Product product) {if(product.getIsNew()!=null && product.getIsNew()){product.setSaleTime(new Date());}if(productService.updateById(product)){return CommonResult.success("修改商品成功",product);}else{return CommonResult.error("修改商品失败");}}@RequestMapping(value = "/product/delete")private CommonResult delete(Integer productId) {if(productService.deleteById(productId)){return CommonResult.success("商品删除成功","productId:" + productId);}else{return CommonResult.error("商品删除失败");}}/*商品类别*/@RequestMapping(value = "/productType/add")private CommonResult addType(ProductType productType) {if(productTypeService.insertData(productType)){return CommonResult.success("商品分类添加成功",productType);}else{return CommonResult.error("商品分类添加失败");}}@RequestMapping(value = "/productType/update")private CommonResult updateType(ProductType productType) {if(productTypeService.updateById(productType)){return CommonResult.success("商品分类修改成功",productType);}else{return CommonResult.error("商品分类修改失败");}}@RequestMapping(value = "/productType/deleteById")private CommonResult deleteTypeById(Integer typeId) {if(productTypeService.deleteById(typeId)){return CommonResult.success("商品分类删除成功","typeId: "+typeId);}else{return CommonResult.error("商品分类删除失败");}}@RequestMapping(value = "/productType/deleteByName")private CommonResult deleteTypeByName(String typeName) {if(productTypeService.deleteByName(typeName)){return CommonResult.success("商品分类删除成功","typeName: "+typeName);}else{return CommonResult.error("商品分类删除失败");}}@RequestMapping(value = "/productType/existsTypeName")private CommonResult existsTypeName(Integer typeId,String typeName) {Boolean isExist = productTypeService.existsWithTypeName(typeId,typeName);if(isExist!=null){return CommonResult.success("查询成功",isExist);}else{return CommonResult.error("查询失败");}}@RequestMapping(value = "/productType/findAll")private CommonResult findAllType() {List<ProductType> productTypes = productTypeService.selectAll();if(productTypes!=null){return CommonResult.success("商品分类查询成功",productTypes);}else{return CommonResult.error("商品分类查询失败");}}@RequestMapping(value = "/productType/findAllName")private CommonResult findAllTypeName() {List<String> names = productTypeService.selectAllName();if(names!=null){return CommonResult.success("商品分类名称查询成功",names);}else{return CommonResult.error("商品分类名称查询失败");}}/*商品品牌*/@RequestMapping(value = "/productBrand/add")private CommonResult addBrand(ProductBrand productBrand) {if(productBrandService.insertData(productBrand)){return CommonResult.success("商品品牌添加成功",productBrand);}else{return CommonResult.error("商品品牌添加失败");}}@RequestMapping(value = "/productBrand/update")private CommonResult updateBrand(ProductBrand productBrand) {if(productBrandService.updateById(productBrand)){return CommonResult.success("商品品牌修改成功",productBrand);}else{return CommonResult.error("商品品牌修改失败");}}@RequestMapping(value = "/productBrand/deleteById")private CommonResult deleteBrandById(Integer brandId) {if(productBrandService.deleteById(brandId)){return CommonResult.success("商品品牌删除成功","brandId: "+brandId);}else{return CommonResult.error("商品品牌删除失败");}}@RequestMapping(value = "/productBrand/deleteByName")private CommonResult deleteBrandByName(String brandName) {if(productBrandService.deleteByName(brandName)){return CommonResult.success("商品品牌删除成功","brandName: "+brandName);}else{return CommonResult.error("商品品牌删除失败");}}@RequestMapping(value = "/productBrand/findAll")private CommonResult findAllBrand() {List<ProductBrand> productBrands = productBrandService.selectAll();if(productBrands!=null){return CommonResult.success("商品品牌查询成功",productBrands);}else{return CommonResult.error("商品品牌查询失败");}}@RequestMapping(value = "/productBrand/existsBrandName")private CommonResult existsBrandName(Integer brandId,String brandName) {Boolean isExist = productBrandService.existsWithBrandName(brandId,brandName);if(isExist!=null){return CommonResult.success("查询成功",isExist);}else{return CommonResult.error("查询失败");}}@RequestMapping(value = "/productBrand/findAllName")private CommonResult findAllBrandName() {List<String> names = productBrandService.selectAllName();if(names!=null){return CommonResult.success("商品品牌名称查询成功",names);}else{return CommonResult.error("商品品牌名称查询失败");}}}
用户授权等相关业务:
/*** @description 用户授权等相关业务*/@RestController@CrossOriginpublic class RoleController {final RoleService roleService;public RoleController(RoleService roleService) {this.roleService = roleService;}/*根据id查询用户*/@RequestMapping(value = "/role/findById")private CommonResult findById(Integer roleId) {Role role = roleService.selectById(roleId);if(role!=null){return CommonResult.success("查询成功",role);}else{return CommonResult.error("查询失败");}}/*根据角色名称查询角色*/@RequestMapping(value = "/role/findByKey")private CommonResult findByKey(String roleName) {Role role = roleService.selectByKey(roleName);if(role!=null){return CommonResult.success("查询成功",role);}else{return CommonResult.error("查询失败");}}/*根据key查询用户*/@RequestMapping(value = "/role/existRoleName")private CommonResult existRoleName(Integer roleId,String roleName) {Boolean isExist = roleService.existsRoleName(roleId,roleName);if(isExist!=null){return CommonResult.success("查询成功",isExist);}else{return CommonResult.error("查询失败");}}/*查询所有角色信息*/@RequestMapping(value = "/role/findAll")private CommonResult findAll() {List<Role> roles = roleService.selectAll();if(roles!=null){return CommonResult.success("查询成功",roles);}else{return CommonResult.error("查询失败");}}/*查询所有用户*/@RequestMapping(value = "/role/findAllUsable")private CommonResult findAllUsable() {List<Role> roles = roleService.selectAllUsable();if(roles!=null){return CommonResult.success("查询成功",roles);}else{return CommonResult.error("查询失败");}}@RequestMapping(value = "/role/count")private CommonResult findCount() {Integer count = roleService.selectCount();if(count!=null){return CommonResult.success("查询成功",count);}else{return CommonResult.error("查询失败");}}@RequestMapping(value = "/role/findIdByKey")private CommonResult findIdByKey(String key) {Integer id = roleService.selectIdByKey(key);if(id!=null){return CommonResult.success("查询成功","id: "+id);}else{return CommonResult.error("查询失败");}}@RequestMapping(value = "/role/add")private CommonResult add(Role role) {if(role!=null){if(roleService.insertData(role)){return CommonResult.success("添加成功",role);}else{return CommonResult.error("添加失败");}}return CommonResult.error("用户数据不存在");}@RequestMapping(value = "/role/update")private CommonResult update(Role role) {System.out.println(role);if(roleService.updateById(role)){return CommonResult.success("更新成功",role);}else{return CommonResult.error("更新失败");}}@RequestMapping(value = "/role/delete")private CommonResult delete(Integer roleId) {if(roleService.deleteById(roleId)){return CommonResult.success("删除成功",roleId);}else{return CommonResult.error("删除失败");}}}
源码获取:博客首页 "资源" 里下载!
如果觉得《Java项目:网上电商项目(前后端分离+java+vue+Springboot+ssm+mysql+maven+redis)》对你有帮助,请点赞、收藏,并留下你的观点哦!