基于javaweb+mysql的springboot网上电商项目(前后端分离+java+vue+springboot+ssm+mysql+maven+redis)

基于javaweb+mysql的springboot网上电商项目(前后端分离+java+vue+springboot+ssm+mysql+maven+redis)

运行环境

Java≥8、MySQL≥5.7、Node.js≥10

开发工具

后端:eclipse/idea/myeclipse/sts等均可配置运行

前端:WebStorm/VSCode/HBuilderX等均可

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的SpringBoot网上电商项目(前后端分离+java+vue+springboot+ssm+mysql+maven+redis)

一、项目简述

本系统功能包括: 一款基于Springboot+Vue的电商项目,前后端分离项目,前台后台都有,前台商品展示购买,购物车分类,订 单查询等等,后台商品管理,订单管理,信息维护,用户管理等等。

二、项目运行

环境配置: Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX (Webstorm也 行)+ Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts都支 持)。

项目技术: Springboot + Maven + Mybatis + Vue + Redis, B/S 模式+ Maven等等,附带支付宝沙箱环境以及支付环节代码。

    private CommonResult findById(Integer supplierId) {
        Supplier supplier = supplierService.selectById(supplierId);
        if(supplier!=null){
            return CommonResult.success("供货商查询成功",supplier);
        }else{
            return CommonResult.error("供货商查询失败");
        }
    }
    /*查询全部供应商*/
    @RequestMapping(value = "/supplier/findAll")
    private CommonResult findAll() {
        List<Supplier> suppliers = supplierService.selectAll();
        if(suppliers!=null){
            return CommonResult.success("供货商查询成功",suppliers);
        }else{
            return CommonResult.error("供货商查询失败");
        }
    }
    /*查询全部供应商*/
    @RequestMapping(value = "/supplier/findAllUsable")
    private CommonResult findAllUsable() {
        List<Supplier> suppliers = supplierService.selectAllUsable();
        if(suppliers!=null){
            return CommonResult.success("供货商查询成功",suppliers);
        }else{
            return CommonResult.error("供货商查询失败");
        }
    }
    /*查询全部供应商名称*/
    @RequestMapping(value = "/supplier/findAllName")
    private CommonResult findAllName() {
        List<String> names = supplierService.selectAllName();
        if(names!=null){
            return CommonResult.success("供货商名称查询成功",names);
        }else{
            return CommonResult.error("供货商名称查询失败");
        }
    }
    /*查询供应商是否存在*/
    @RequestMapping(value = "/supplier/existSupplier")
    private CommonResult existSupplier(Integer supplierId,String supplierName) {
        }else{
            return CommonResult.error("供货商查询失败");
        }
    }
    /*查询全部供应商*/
    @RequestMapping(value = "/supplier/findAll")
    private CommonResult findAll() {
        List<Supplier> suppliers = supplierService.selectAll();
        if(suppliers!=null){
            return CommonResult.success("供货商查询成功",suppliers);
        }else{
            return CommonResult.error("供货商查询失败");
        }
    }
    /*查询全部供应商*/
    @RequestMapping(value = "/supplier/findAllUsable")
    private CommonResult findAllUsable() {
        List<Supplier> suppliers = supplierService.selectAllUsable();
        if(suppliers!=null){
            return CommonResult.success("供货商查询成功",suppliers);
        }else{
            return CommonResult.error("供货商查询失败");
        }
    }
    /*查询全部供应商名称*/
    @RequestMapping(value = "/supplier/findAllName")
    private CommonResult findAllName() {
        List<String> names = supplierService.selectAllName();
        if(names!=null){
            return CommonResult.success("供货商名称查询成功",names);
        }else{
            return CommonResult.error("供货商名称查询失败");
        }
    }
    /*查询供应商是否存在*/
    @RequestMapping(value = "/supplier/existSupplier")
    private CommonResult existSupplier(Integer supplierId,String supplierName) {
        Boolean isExist = supplierService.existsWithSupplierName(supplierId,supplierName);
        if(isExist!=null){
            return CommonResult.success("查询成功",isExist);
        }else{
            return CommonResult.error("查询失败");
        }
    }
    /*添加供应商*/
    @RequestMapping(value = "/supplier/addSupplier")
    private CommonResult addSupplier(Supplier supplier) {
        if(supplier!=null){
            if(supplierService.insertData(supplier)){
                return CommonResult.success("添加成功",supplier);
            }else{
                return CommonResult.error("添加失败");
            }
    private CommonResult existSupplier(Integer supplierId,String supplierName) {
        Boolean isExist = supplierService.existsWithSupplierName(supplierId,supplierName);
        if(isExist!=null){
            return CommonResult.success("查询成功",isExist);
        }else{
            return CommonResult.error("查询失败");
        }
    }
    /*添加供应商*/
    @RequestMapping(value = "/supplier/addSupplier")
    private CommonResult addSupplier(Supplier supplier) {
        if(supplier!=null){
            if(supplierService.insertData(supplier)){
                return CommonResult.success("添加成功",supplier);
            }else{
                return CommonResult.error("添加失败");
            }
        }
        return CommonResult.error("供应商数据不存在");
    }
    /*修改供应商*/
    @RequestMapping(value = "/supplier/updateSupplier")
    private CommonResult updateSupplier(Supplier supplier) {
        if(supplier!=null){
            if(supplierService.updateById(supplier)){
                return CommonResult.success("更新成功",supplier);
            }else{
                return CommonResult.error("更新失败");
            }
        }
        return CommonResult.error("供应商数据不存在");
    }
    /*删除供应商*/
    @RequestMapping(value = "/supplier/deleteSupplier")
    private CommonResult deleteSupplier(Integer supplierId) {
        if(supplierId!=null){
            if(supplierService.deleteById(supplierId)){
                return CommonResult.success("删除成功",supplierId);
            }else{
                return CommonResult.error("删除失败");
            }
        }
        return CommonResult.error("供应商数据不存在");
    }
    @RequestMapping(value = "/returnGoods/dealRefund")
    private CommonResult dealRefund(Integer returnId,String operatorNumber,String operatorName) {
        if(returnId!=null){
            ReturnGoods returnGoods = returnGoodsService.selectById(returnId);
            returnGoods.setReturnState("退款完成");
            returnGoods.setDealTime(new Date());
            returnGoods.setOperatorNumber(operatorNumber);
            returnGoods.setOperatorName(operatorName);
            String orderNo = returnGoods.getOrderNo();
            Integer orderId = orderService.selectIdByKey(orderNo);
            Order order = new Order();
            order.setOrderId(orderId);
            order.setReturnState(true);
            order.setOrderState("已退款");
            Logistics logistics = logisticsService.selectOrderNo(orderNo);
            if(logistics!=null){
                logisticsService.deleteById(logistics.getLogisticId());
            }
            if(orderService.updateById(order)){
                if(returnGoodsService.updateById(returnGoods)){
                    return CommonResult.success("更新成功",returnGoods);
                }else{
                    return CommonResult.error("更新失败");
                }
            }else{
                return CommonResult.error("更新失败");
            }
        }
        return CommonResult.error("商品退款数据不存在");
    }

    /*拒绝买家退款申请*/
    @RequestMapping(value = "/returnGoods/rejectRefund")
    private CommonResult rejectRefund(Integer returnId,String operatorNumber,String operatorName) {
        if(returnId!=null){
            ReturnGoods returnGoods = returnGoodsService.selectById(returnId);
            returnGoods.setReturnState("拒绝退款");
            returnGoods.setDealTime(new Date());
            returnGoods.setOperatorNumber(operatorNumber);
            returnGoods.setOperatorName(operatorName);
            String orderNo = returnGoods.getOrderNo();
            Integer orderId = orderService.selectIdByKey(orderNo);
            Order order = new Order();
        }
    }
    @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("商品分类添加失败");
        }
    }

 */

@RestController
@CrossOrigin
public class UserController {
    final RoleService roleService;
    final UserService userService;
    final UserRoleService userRoleService;
    final VipService vipService;
    public UserController(UserService userService, RoleService roleService,VipService vipService, UserRoleService userRoleService) {
        this.userService = userService;
        this.roleService = roleService;
        this.userRoleService = userRoleService;
        this.vipService = vipService;
    }

    /*根据id查询用户*/
    @RequestMapping(value = "/user/findById")
    private CommonResult findById(Integer id) {
        User user = userService.selectById(id);
        if(user!=null){
            return CommonResult.success("查询成功",user);
        }else{
            return CommonResult.error("查询失败");
        }
    }

    /*根据帐号查询用户*/
    @RequestMapping(value = "/user/findByKey")
    private CommonResult findByKey(String key) {
        User user = userService.selectByKey(key);
        if(user!=null){
            return CommonResult.success("查询成功",user);
        }else{
            return CommonResult.error("查询失败");
        }
    }

    /*查询所有用户*/
    @RequestMapping(value = "/user/findAll")
    private CommonResult findAll() {
        List<User> users = userService.selectAll();
            return CommonResult.success("退货订单数量查询成功",count);
        }else{
            return CommonResult.error("退货订单数量查询失败");
        }
    }

    @RequestMapping(value = "/returnGoods/addReturn")
    private CommonResult addReturn(ReturnGoods returnGoods) {
        if(returnGoods!=null){
            Integer orderId = orderService.selectIdByKey(returnGoods.getOrderNo());
            System.out.println(returnGoods);
            System.out.println(orderId);
            Order order = new Order();
            order.setOrderId(orderId);
            order.setOrderState("待处理");
            if (orderService.updateById(order)){
                if(returnGoodsService.insertData(returnGoods)){
                    return CommonResult.success("添加成功",returnGoods);
                }else{
                    return CommonResult.error("添加失败");
                }
            }else{
                return CommonResult.error("添加失败");
            }
        }
        return CommonResult.error("商品退货数据不存在");
    }

    @RequestMapping(value = "/returnGoods/updateReturn")
    private CommonResult updateReturn(ReturnGoods returnGoods) {
        if(returnGoods!=null){
            returnGoods.setDealTime(new Date());
            if(returnGoodsService.updateById(returnGoods)){
                return CommonResult.success("更新成功",returnGoods);
            }else{
                return CommonResult.error("更新失败");
            }
        }
        return CommonResult.error("商品退货数据不存在");
    }

            data.put("year", Calendar.getInstance().get(Calendar.YEAR));
            mailService.sendTemplateMail(sendTo, "权限管理", "role", data);
            return CommonResult.success("授权信息发送成功");
        } catch (Exception e) {
            return CommonResult.error("授权信息发送失败");
        }
    }

    @RequestMapping(value = "/allow/sendHtmlResetPwd")
    public CommonResult sendResetPwd(String sendTo, String pwd) {
        try {
            Map<String, Object> data = new HashMap<>();
            data.put("password", pwd);
            data.put("year", Calendar.getInstance().get(Calendar.YEAR));
            mailService.sendTemplateMail(sendTo, "重置密码", "resetpwd", data);
            return CommonResult.success("新密码信息发送成功");
        } catch (Exception e) {
            return CommonResult.error("新密码信息发送失败");
        }
    }

    /**
     * 发送一个邮箱附件
     *
     * @param sendTo 收件人
     */
    @RequestMapping(value = "/util/sendFile")
    public String sendmailFile(String sendTo, String content) {
        try {
            String filePath = "F:\\IDEA\\JAVA_Program\\Springboot-Mall\\src\\main\\resources\\static\\1.zip";
            mailService.sendAttachmentsMail(sendTo, "文件操作", content, filePath);
            return "发送成功!";
        } catch (Exception e) {
            e.printStackTrace();
            return "发送邮件时发生异常,稍后请重新发送!";
        }
    }

    /**
     * 验证输入的验证码是否正确
     *
     * @param key  验证的依据
     * @param code 验证码
     */
    @RequestMapping(value = "/allow/checkCode")
    public CommonResult checkCode(String key, String code) {
        String codeK = redisTemplate.opsForValue().get(key);
        if (codeK == null) {
            return CommonResult.error("验证码不存在或已过期,请重新发送!");
        }
            //更新最后登录时间
            user.setLoginTime(new Date());
            userService.updateById(user);
            //存放sessionId, 即 token
            info.put("sessionId", authorization);
            List<Role> roles = roleService.selectAll();
            List<String> rs = new ArrayList<>();    // rs 存放的是role的名称
            List<String> rsInfo = new ArrayList<>();    //rsInfo 存放role的描述
            for (Role role : roles) {
                rs.add(role.getRoleName());
                rsInfo.add(role.getRoleName());
            }
            boolean[] booleans = subject.hasRoles(rs);
            for (int i = booleans.length - 1; i >= 0; i--) {
                if (!booleans[i]) {
                    rs.remove(i);
                    rsInfo.remove(i);
                }
            }
            info.put("role", rs);
            info.put("roleInfo", rsInfo);
            return CommonResult.success("登录成功", info);
        }catch (LockedAccountException e){
            return CommonResult.error("您的帐号存在异常行为,已被封停(请联系工作人员)");
        } catch (IncorrectCredentialsException e) {
            return CommonResult.error("密码错误,请重新输入");
        } catch (AuthenticationException e) {
            return CommonResult.error("该用户不存在");
        }
    }

    /**
     * 退出登录操作
     * @param key       用户登录的帐号
     * @param session  前端存储的session(token)
     */
    @RequestMapping(value = "/logout")
    private CommonResult logout(String key,String session) {
        if(key!=null){
            try{
                User user = userService.selectByKey(key);
                Subject subject = SecurityUtils.getSubject();
                //清除用户缓存
                RealmSecurityManager securityManager = (RealmSecurityManager) SecurityUtils.getSecurityManager();
                UserRealm userRealm = (UserRealm) securityManager.getRealms().iterator().next();
                //清空redis中的缓存信息
                userRealm.clearRedis(user,session);
                userRealm.clearCache(SecurityUtils.getSubject().getPrincipals());
    private CommonResult findById(Integer cartId) {
        ShoppingCart shoppingCart = shoppingCartService.selectById(cartId);
        if(shoppingCart!=null){
            return CommonResult.success("购物车查询成功",shoppingCart);
        }else{
            return CommonResult.error("购物车查询失败");
        }
    }

}

/**
 * @email qiudb.top@aliyun.com
 * @description 用户授权类
 */

@RestController
@CrossOrigin
public class UserRoleController {

    final UserRoleService userRoleService;
    public UserRoleController(UserRoleService userRoleService) {
        this.userRoleService = userRoleService;
    }
    /*根据id查询用户*/
    @RequestMapping(value = "/userRole/findById")
    private CommonResult findById(Integer userId) {
        List<UserRole> userRoles = userRoleService.selectByUserId(userId);
        if(userRoles!=null){
    final UserService userService;
    final UserRoleService userRoleService;
    final VipService vipService;
    public UserController(UserService userService, RoleService roleService,VipService vipService, UserRoleService userRoleService) {
        this.userService = userService;
        this.roleService = roleService;
        this.userRoleService = userRoleService;
        this.vipService = vipService;
    }

    /*根据id查询用户*/
    @RequestMapping(value = "/user/findById")
    private CommonResult findById(Integer id) {
        User user = userService.selectById(id);
        if(user!=null){
            return CommonResult.success("查询成功",user);
        }else{
            return CommonResult.error("查询失败");
        }
    }

    /*根据帐号查询用户*/
    @RequestMapping(value = "/user/findByKey")
    private CommonResult findByKey(String key) {
        User user = userService.selectByKey(key);
        if(user!=null){
            return CommonResult.success("查询成功",user);
        }else{
            return CommonResult.error("查询失败");
        }
    }

    /*查询所有用户*/
    @RequestMapping(value = "/user/findAll")
    private CommonResult findAll() {
        List<User> users = userService.selectAll();
        if(users!=null){
            return CommonResult.success("查询成功",users);
        }else{
            return CommonResult.error("查询失败");
        }
    }

    /*判断某个用户是否还存在*/
    @RequestMapping(value = "/user/existKey")
    private CommonResult existKey(String key) {
        Boolean isExist = userService.existsWithPrimaryKey(key);
    @RequestMapping(value = "/specs/update")
    private CommonResult updateSpecs(Specs specs) {
        if(specsService.updateById(specs)){
            return CommonResult.success("更新成功",specs);
        }else{
            return CommonResult.error("更新失败");
        }
    }

    @RequestMapping(value = "/specs/delete")
    private CommonResult deleteSpecs(Integer specsId) {
        if(specsService.deleteById(specsId)){
            return CommonResult.success("删除成功",specsId);
        }else{
            return CommonResult.error("删除失败");
        }
    }

    /*商品 与 规格 的关联表*/

    /*查询所有商品规格对应信息*/
    @RequestMapping(value = "/productSpecs/findAll")
    private CommonResult findAll() {
        List<ProductSpecs> productSpecs = productSpecsService.selectAll();
        if(productSpecs!=null){
            return CommonResult.success("查询成功",productSpecs);
        }else{
            return CommonResult.error("查询失败");
        }
    }

    @RequestMapping(value = "/productSpecs/findAllByProId")
    private CommonResult findAllByProId(Integer productId) {
        List<String> specsName = productSpecsService.selectAllByProId(productId);
        if(specsName!=null){
            return CommonResult.success("查询成功",specsName);
        }else{
        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("全部商品信息查询失败");
        }
    }
            return CommonResult.error("购物车删除失败");
        }
    }

    @RequestMapping(value = "/shoppingCart/findAll")
    private CommonResult findAllShoppingCart(String accountNumber) {
        List<Map<String, Object>> shoppingInfo = shoppingCartService.selectAll(accountNumber);
        if(shoppingInfo!=null){
            return CommonResult.success("购物车查询成功",shoppingInfo);
        }else{
            return CommonResult.error("购物车查询失败");
        }
    }

    @RequestMapping(value = "/shoppingCart/findById")
    private CommonResult findById(Integer cartId) {
        ShoppingCart shoppingCart = shoppingCartService.selectById(cartId);
        if(shoppingCart!=null){
            return CommonResult.success("购物车查询成功",shoppingCart);
        }else{
            return CommonResult.error("购物车查询失败");
        }
    }

}

/**
 * @email qiudb.top@aliyun.com
 * @description 用户授权类
 */

    @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("商品品牌删除失败");
        }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();
 * @email qiudb.top@aliyun.com
 * @description 数据分析,商品数量,订单数量等分析业务
 */
@CrossOrigin
@RestController
public 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) {
                    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);

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值