package com.jf3q.sup.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jf3q.sup.domain.*;
import com.jf3q.sup.dto.SalesOrderDetailsDto;
import com.jf3q.sup.dto.SalesOrdersDto;
import com.jf3q.sup.mapper.*;
import com.jf3q.sup.service.OutboundShipmentsService;
import com.jf3q.sup.service.SalesOrdersService;
import com.jf3q.sup.utils.Constant;
import com.jf3q.sup.vo.SaleShowIndexVo;
import com.jf3q.sup.vo.SalesOrderDetailsVo;
import com.jf3q.sup.vo.SalesOrdersVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
*
*/
@Service
@Transactional
public class SalesOrdersServiceImpl extends ServiceImpl<SalesOrdersMapper, SalesOrders>
implements SalesOrdersService {
@Autowired
private OutboundShipmentsMapper outboundShipmentsMapper;
@Autowired
private OutboundShipmentDetailsMapper outboundShipmentDetailsMapper;
@Autowired
private ProductsMapper productsMapper;
@Autowired
private SalesOrderDetailsMapper salesOrderDetailsMapper;
@Override
public IPage<SalesOrdersVo> pages(SalesOrdersDto salesOrdersDto, Integer pageNum) {
IPage<SalesOrdersVo> page = Page.of(pageNum, Constant.PAGE_SIZE);
page = baseMapper.selectPages(new Page<>(page.getCurrent(), page.getSize()), salesOrdersDto);
return page;
}
@Override
public void addOrUpdate(SalesOrdersDto salesOrdersDto) {
boolean flag = salesOrdersDto.getId() == null || salesOrdersDto.getId() == 0 ? true : false;
try {
//销售订单类
SalesOrders salesOrders = new SalesOrders();
BeanUtils.copyProperties(salesOrdersDto, salesOrders);
//计算商品的价格
BigDecimal sum = BigDecimal.valueOf(0.00);
for (SalesOrderDetailsDto salesOrderDetailsDto : salesOrdersDto.getSalesOrderDetailsDto()) {
//查询商品信息
Products products = productsMapper.selectById(salesOrderDetailsDto.getProductId());
//判断商品库存是否足够
if (!isStockQuantity(products,salesOrders.getId(),salesOrderDetailsDto.getQuantity())){
throw new RuntimeException(products.getName()+"的库存不足");
}else {
//扣减库存
products.setStockQuantity(products.getStockQuantity()-salesOrderDetailsDto.getQuantity());
productsMapper.updateById(products);
}
//当前商品的总价
BigDecimal sumPrice = products.getPrice().multiply(BigDecimal.valueOf(salesOrderDetailsDto.getQuantity()));
//累加所有商品的价格
sum = sum.add(sumPrice);
}
//计算总金额
salesOrders.setTotalAmount(sum);
//出库表类
OutboundShipments shipments=new OutboundShipments()
.setCarrierId(salesOrdersDto.getCarrierId())
.setStatus(1)
.setShipmentDate(new Date());
if (flag) {
//// 新增销售订单
// salesOrders.setState(1);
baseMapper.insert(salesOrders);
// 新增出库信息
outboundShipmentsMapper.insert(shipments);
} else {
//修改销售订单
baseMapper.updateById(salesOrders);
}
if (!flag){
//根据销售订单id删除销售订单明细
salesOrderDetailsMapper.delete(
new LambdaQueryWrapper<SalesOrderDetails>()
.eq(SalesOrderDetails::getOrderId,salesOrders.getId()));
}
for (SalesOrderDetailsDto salesOrderDetailsDto : salesOrdersDto.getSalesOrderDetailsDto()) {
//查询商品信息
Products products = productsMapper.selectById(salesOrderDetailsDto.getProductId());
//订单详情类
SalesOrderDetails salesOrderDetails = new SalesOrderDetails()
.setOrderId(salesOrders.getId())
.setProductId(salesOrderDetailsDto.getProductId())
.setQuantity(salesOrderDetailsDto.getQuantity())
.setPrice(products.getPrice());
// 出库类
OutboundShipmentDetails shipmentDetails=new OutboundShipmentDetails()
.setOutboundShipmentId(shipments.getId())
.setProductId(products.getId())
.setQuantity(salesOrderDetailsDto.getQuantity());
if (flag) {
//新增销售订单明细
salesOrderDetailsMapper.insert(salesOrderDetails);
//新增出库详情订单
outboundShipmentDetailsMapper.insert(shipmentDetails);
} else {
//修改销售订单明细
salesOrderDetailsMapper.insert(salesOrderDetails);
}
}
} catch (BeansException e) {
System.out.println(e);
throw new RuntimeException("添加失败!");
}
}
@Override
public void del(Integer[] ids) {
for (int i = 0; i < ids.length; i++) {
//删除销售订单明细
salesOrderDetailsMapper.delete(
new LambdaQueryWrapper<SalesOrderDetails>().eq(SalesOrderDetails::getOrderId, ids[i])
);
//删除销售订单
baseMapper.deleteById(ids[i]);
}
}
@Override
public SalesOrdersVo getOrders(Integer id) {
return baseMapper.selectOrders(id);
}
@Override
public List<SaleShowIndexVo> getSaleShow(String time) {
return salesOrderDetailsMapper.getSaleShowList(time);
}
//判断库存
public boolean isStockQuantity(Products products,Integer ordersId,Integer quantity){
if (ordersId!=null){
//通过,ordersId获取销售订单详情
List<SalesOrderDetails> salesOrderDetails = salesOrderDetailsMapper.selectList(
new LambdaQueryWrapper<SalesOrderDetails>()
.eq(SalesOrderDetails::getOrderId, ordersId));
if (salesOrderDetails!=null){
for (SalesOrderDetails salesOrderDetail : salesOrderDetails) {
if (products.getId()!=salesOrderDetail.getProductId()){
continue;
}
//库存不足
if ((products.getStockQuantity()+salesOrderDetail.getQuantity())<quantity){
return false;
}
//库存充足归还数量重新扣减库存
products.setStockQuantity(products.getStockQuantity()+salesOrderDetail.getQuantity());
productsMapper.updateById(products);
return true;
}
}
}
//库存不足
if (products.getStockQuantity()<quantity){
return false;
}
return true;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
基于Java和Vue的超市进销存系统设计源码
共222个文件
java:144个
xml:24个
vue:22个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 66 浏览量
2024-10-06
05:21:09
上传
评论
收藏 3.15MB ZIP 举报
温馨提示
该系统是一款基于Java和Vue框架开发的超市进销存管理平台源码,总计包含224个文件,涵盖144个Java源代码文件、24个XML配置文件、22个Vue组件文件、20个JavaScript脚本文件、3个Markdown文档、3个JSON数据文件、2个Git忽略配置文件、2个图片文件以及1个YAML配置文件和1个LICENSE授权文件。系统设计精良,功能全面,适用于超市的库存管理、销售记录和进货流程等环节。
资源推荐
资源详情
资源评论
收起资源包目录
基于Java和Vue的超市进销存系统设计源码 (222个子文件)
.gitignore 292B
.gitignore 260B
index.html 593B
favicon.ico 4KB
SalesOrdersServiceImpl.java 8KB
EmpController.java 5KB
ProductsController.java 5KB
SalesOrdersController.java 5KB
PurchasesController.java 4KB
ProductCategoriesController.java 4KB
UsersServiceImpl.java 3KB
EmployeesServiceImpl.java 3KB
CustomersController.java 3KB
RoleController.java 3KB
CarriersController.java 3KB
SupplierController.java 3KB
UserController.java 3KB
ProductsServiceImpl.java 3KB
PositionsController.java 2KB
DepartmentsController.java 2KB
SecurityConfig.java 2KB
JwtUtils.java 2KB
Users.java 2KB
TokenFilter.java 2KB
ProductsEchartsVo.java 2KB
Employees.java 2KB
SuppliersServiceImpl.java 2KB
PurchasesServiceImpl.java 2KB
MenusServiceImpl.java 1KB
PurchaseDetailsServiceImpl.java 1KB
Purchases.java 1KB
OutboundShipmentsController.java 1KB
Products.java 1KB
CarriersServiceImpl.java 1KB
InboundShipmentsController.java 1KB
GlobalExceptionHandler.java 1KB
SalesOrderDetails.java 1KB
Suppliers.java 1KB
Carriers.java 1KB
PurchaseDetails.java 1KB
OutboundShipmentsServiceImpl.java 1KB
Menus.java 1KB
Roles.java 1KB
OutboundShipmentDetails.java 1KB
Customers.java 1KB
InboundShipmentsServiceImpl.java 1KB
InboundShipments.java 1KB
ProductCategoriesServiceImpl.java 1KB
SalesOrders.java 1KB
ProductCategories.java 1KB
OutboundShipments.java 1KB
Departments.java 1024B
Positions.java 996B
Warehouses.java 963B
Resources.java 959B
RoleResources.java 940B
UserRoles.java 924B
RoleMenus.java 924B
WarehousesController.java 900B
SalesOrdersVo.java 874B
SalesOrdersDto.java 872B
PurchasesAddDto.java 851B
ProductsMapper.java 806B
SalesOrdersMapper.java 796B
PersonalVo.java 764B
SalesOrdersService.java 735B
InboundShipmentsVo.java 734B
PurchaseDetailsDto.java 710B
RoleMenusServiceImpl.java 702B
MenuController.java 697B
MybatisConfig.java 691B
OutboundShipmentsMapper.java 643B
InboundShipmentsMapper.java 628B
ProductsVo.java 617B
EmployeesService.java 614B
EmployeesMapper.java 594B
ResultVo.java 589B
ProductCategoriesMapper.java 587B
ProductsService.java 569B
OutboundShipmentsVo.java 567B
InboundShipmentsDto.java 540B
SalesOrderDetailsVo.java 527B
OutboundShipmentDetailsServiceImpl.java 520B
DepartmentsServiceImpl.java 516B
PurchasesMapper.java 514B
UsersService.java 510B
PositionsServiceImpl.java 502B
OutboundShipmentsService.java 501B
SalesOrderDetailsServiceImpl.java 478B
MenusMapper.java 473B
InboundShipmentsService.java 467B
SuppliersService.java 461B
App.java 461B
PurchasesService.java 458B
AppTest.java 450B
RoleResourcesServiceImpl.java 450B
OutboundShipmentsDto.java 431B
WarehousesServiceImpl.java 429B
ProductCategoriesService.java 427B
UserDto.java 424B
共 222 条
- 1
- 2
- 3
资源评论
csbysj2020
- 粉丝: 2541
- 资源: 5471
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- cad定制家具平面图工具-(FG)门板覆盖柜体
- asp.net 原生js代码及HTML实现多文件分片上传功能(自定义上传文件大小、文件上传类型)
- whl@pip install pyaudio ERROR: Failed building wheel for pyaudio
- Constantsfd密钥和权限集合.kt
- 基于Java的财务报销管理系统后端开发源码
- 基于Python核心技术的cola项目设计源码介绍
- 基于Python及多语言集成的TSDT软件过程改进设计源码
- 基于Java语言的歌唱比赛评分系统设计源码
- 基于JavaEE技术的课程项目答辩源码设计——杨晔萌、李知林、岳圣杰、张俊范小组作品
- 基于Java原生安卓开发的蔚蓝档案娱乐应用设计源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功