| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | |
| | | |
| | | //新增销售单 |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public String addSale(String saleman, SaleDto saleDto) { |
| | | Sale sale = new Sale(); |
| | | BeanUtils.copyProperties(saleDto, sale); |
| | |
| | | |
| | | //根据销售单id删除 |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void delSale(Integer id) { |
| | | Sale sale = saleMapper.selectById(id); |
| | | sale.setState(0); |
| | |
| | | |
| | | //根据id批量删除 |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void delAllSale(List<Integer> ids) { |
| | | List<Sale> sales = saleMapper.selectBatchIds(ids); |
| | | for (Sale sale : sales) { |
| | |
| | | |
| | | //根据销售单id修改信息 |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateSaleById(String saleman, Integer id, SaleVo saleVo) { |
| | | Sale sale = saleMapper.selectById(id); |
| | | sale.setSaleman(saleman); |
| | | BeanUtils.copyProperties(saleVo, sale); |
| | | //更新销售单 |
| | | saleMapper.updateById(sale); |
| | | List<SaleMaterial> saleMaterials = saleMaterialMapper.selectSaleDatil(id); |
| | | for (SaleMaterial saleMaterial : saleMaterials) { |
| | | List<SaleMaterialDto> saleMaterialDtos = saleVo.getSaleMaterialList(); |
| | | for (SaleMaterialDto saleMaterialDto : saleMaterialDtos) { |
| | | BeanUtils.copyProperties(saleMaterialDto, saleMaterial); |
| | | //更新销售产品单 |
| | | saleMaterialMapper.updateById(saleMaterial); |
| | | } |
| | | List<SaleMaterialDto> saleMaterialDtos = saleVo.getSaleMaterialList(); |
| | | for (SaleMaterialDto saleMaterialDto : saleMaterialDtos) { |
| | | SaleMaterial saleMaterial = new SaleMaterial(); |
| | | BeanUtils.copyProperties(saleMaterialDto, saleMaterial); |
| | | saleMaterialMapper.updateById(saleMaterial); |
| | | } |
| | | } |
| | | |
| | | //审核 |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void check(String checkname, Integer id, Integer type) { |
| | | Sale sale = saleMapper.selectById(id); |
| | | sale.setType(type); |
| | | sale.setCheckname(checkname); |
| | | sale.setCheckTime(new Date()); |
| | | if (type == 1) { |
| | | //如果审核通过 |
| | | sale.setBianzhiState(1); |
| | | } else { |
| | | //如果审核不通过 |
| | | sale.setBianzhiState(2);//无编制 |
| | | } |
| | | saleMapper.updateById(sale); |
| | | //审核通过的销售单将销售单中的产品的状态改为待编制0 |
| | | List<SaleMaterial> saleMaterials = saleMaterialMapper.selectList(Wrappers.<SaleMaterial>query() |
| | | .eq("sale_id", id) |
| | | .eq("state", 1)); |
| | | if (type == 1) { |
| | | for (SaleMaterial saleMaterial : saleMaterials) { |
| | | saleMaterial.setType(0); |
| | | saleMaterialMapper.updateById(saleMaterial); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //根据订单号查询销售信息 |